3 * Declarations of our own routines for writing pcap and pcapng files.
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Derived from code in the Wiretap Library
10 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 /* Writing pcap files */
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*/
21 libpcap_write_file_header(FILE* pfile, int linktype, int snaplen,
22 bool ts_nsecs, uint64_t *bytes_written, int *err);
24 /** Write a record for a packet to a dump file.
25 Returns true on success, false on failure. */
27 libpcap_write_packet(FILE* pfile,
28 time_t sec, uint32_t usec,
29 uint32_t caplen, uint32_t len,
31 uint64_t *bytes_written, int *err);
33 /* Writing pcapng files */
35 /* Write a pre-formatted pcapng block */
37 pcapng_write_block(FILE* pfile,
39 uint32_t block_total_length,
40 uint64_t *bytes_written,
43 /** Write a section header block (SHB)
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.
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.
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.
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.
60 uint64_t section_length, /**< Length of section */
61 uint64_t *bytes_written, /**< Number of written bytes */
62 int *err /**< Error type */
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 */
75 uint64_t *bytes_written,
76 uint64_t if_speed, /* IDB_IF_SPEED 8 */
77 uint8_t tsresol, /* IDB_TSRESOL 9 */
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 */
92 pcapng_write_enhanced_packet_block(FILE* pfile,
94 time_t sec, uint32_t usec,
95 uint32_t caplen, uint32_t len,
96 uint32_t interface_id,
100 uint64_t *bytes_written,
104 * Editor modelines - https://www.wireshark.org/tools/modelines.html
109 * indent-tabs-mode: nil
112 * vi: set shiftwidth=4 tabstop=8 expandtab:
113 * :indentSize=4:tabSize=8:noTabs=true: