Revert "TODO not needed??? tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm Function switch...
[metze/wireshark/wip.git] / writecap / pcapio.h
1 /** @file
2  *
3  * Declarations of our own routines for writing pcap and pcapng files.
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * Derived from code in the Wiretap Library
10  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
11  *
12  * SPDX-License-Identifier: GPL-2.0-or-later
13  */
14
15 /* Writing pcap files */
16
17 /** Write the file header to a dump file.
18    Returns true on success, false on failure.
19    Sets "*err" to an error code, or 0 for a short write, on failure*/
20 extern bool
21 libpcap_write_file_header(FILE* pfile, int linktype, int snaplen,
22                           bool ts_nsecs, uint64_t *bytes_written, int *err);
23
24 /** Write a record for a packet to a dump file.
25    Returns true on success, false on failure. */
26 extern bool
27 libpcap_write_packet(FILE* pfile,
28                      time_t sec, uint32_t usec,
29                      uint32_t caplen, uint32_t len,
30                      const uint8_t *pd,
31                      uint64_t *bytes_written, int *err);
32
33 /* Writing pcapng files */
34
35 /* Write a pre-formatted pcapng block */
36 extern bool
37 pcapng_write_block(FILE* pfile,
38                   const uint8_t *data,
39                   uint32_t block_total_length,
40                   uint64_t *bytes_written,
41                   int *err);
42
43 /** Write a section header block (SHB)
44  *
45  */
46 extern bool
47 pcapng_write_section_header_block(FILE* pfile,  /**< Write information */
48                                   GPtrArray *comments,  /**< Comments on the section, Optinon 1 opt_comment
49                                                          * UTF-8 strings containing comments that areassociated to the current block.
50                                                          */
51                                   const char *hw,       /**< HW, Optinon 2 shb_hardware
52                                                          * An UTF-8 string containing the description of the hardware  used to create this section.
53                                                          */
54                                   const char *os,       /**< Operating system name, Optinon 3 shb_os
55                                                          * An UTF-8 string containing the name of the operating system used to create this section.
56                                                          */
57                                   const char *appname,  /**< Application name, Optinon 4 shb_userappl
58                                                          * An UTF-8 string containing the name of the application  used to create this section.
59                                                          */
60                                   uint64_t section_length, /**< Length of section */
61                                   uint64_t *bytes_written, /**< Number of written bytes */
62                                   int *err /**< Error type */
63                                   );
64
65 extern bool
66 pcapng_write_interface_description_block(FILE* pfile,
67                                          const char *comment,  /* OPT_COMMENT           1 */
68                                          const char *name,     /* IDB_NAME              2 */
69                                          const char *descr,    /* IDB_DESCRIPTION       3 */
70                                          const char *filter,   /* IDB_FILTER           11 */
71                                          const char *os,       /* IDB_OS               12 */
72                                          const char *hardware, /* IDB_HARDWARE         15 */
73                                          int link_type,
74                                          int snap_len,
75                                          uint64_t *bytes_written,
76                                          uint64_t if_speed,     /* IDB_IF_SPEED          8 */
77                                          uint8_t tsresol,       /* IDB_TSRESOL           9 */
78                                          int *err);
79
80 extern bool
81 pcapng_write_interface_statistics_block(FILE* pfile,
82                                         uint32_t interface_id,
83                                         uint64_t *bytes_written,
84                                         const char *comment,   /* OPT_COMMENT           1 */
85                                         uint64_t isb_starttime, /* ISB_STARTTIME         2 */
86                                         uint64_t isb_endtime,   /* ISB_ENDTIME           3 */
87                                         uint64_t isb_ifrecv,    /* ISB_IFRECV            4 */
88                                         uint64_t isb_ifdrop,    /* ISB_IFDROP            5 */
89                                         int *err);
90
91 extern bool
92 pcapng_write_enhanced_packet_block(FILE* pfile,
93                                    const char *comment,
94                                    time_t sec, uint32_t usec,
95                                    uint32_t caplen, uint32_t len,
96                                    uint32_t interface_id,
97                                    unsigned ts_mul,
98                                    const uint8_t *pd,
99                                    uint32_t flags,
100                                    uint64_t *bytes_written,
101                                    int *err);
102
103 /*
104  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
105  *
106  * Local variables:
107  * c-basic-offset: 4
108  * tab-width: 8
109  * indent-tabs-mode: nil
110  * End:
111  *
112  * vi: set shiftwidth=4 tabstop=8 expandtab:
113  * :indentSize=4:tabSize=8:noTabs=true:
114  */