2 * Declarations of our own routines for writing libpcap files.
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * Derived from code in the Wiretap Library
9 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 /* Writing pcap files */
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*/
20 libpcap_write_file_header(FILE* pfile, int linktype, int snaplen,
21 gboolean ts_nsecs, guint64 *bytes_written, int *err);
23 /** Write a record for a packet to a dump file.
24 Returns TRUE on success, FALSE on failure. */
26 libpcap_write_packet(FILE* pfile,
27 time_t sec, guint32 usec,
28 guint32 caplen, guint32 len,
30 guint64 *bytes_written, int *err);
32 /* Writing pcapng files */
34 /* Write a pre-formatted pcapng block */
36 pcapng_write_block(FILE* pfile,
38 guint32 block_total_length,
39 guint64 *bytes_written,
42 /** Write a section header block (SHB)
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.
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.
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.
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.
59 guint64 section_length, /**< Length of section */
60 guint64 *bytes_written, /**< Number of written bytes */
61 int *err /**< Error type */
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 */
73 guint64 *bytes_written,
74 guint64 if_speed, /* IDB_IF_SPEED 8 */
75 guint8 tsresol, /* IDB_TSRESOL 9 */
79 pcapng_write_interface_statistics_block(FILE* pfile,
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 */
90 pcapng_write_enhanced_packet_block(FILE* pfile,
92 time_t sec, guint32 usec,
93 guint32 caplen, guint32 len,
98 guint64 *bytes_written,
102 * Editor modelines - https://www.wireshark.org/tools/modelines.html
107 * indent-tabs-mode: nil
110 * vi: set shiftwidth=4 tabstop=8 expandtab:
111 * :indentSize=4:tabSize=8:noTabs=true: