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