Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pcapio.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <wiretap/wtap.h>
18
19typedef struct pcapio_writer pcapio_writer;
20
21extern pcapio_writer*
22writecap_fopen(const char *filename, wtap_compression_type ctype, int *err);
23
24extern pcapio_writer*
25writecap_fdopen(int fd, wtap_compression_type ctype, int *err);
26
27extern pcapio_writer*
28writecap_open_stdout(wtap_compression_type ctype, int *err);
29
30extern bool
31writecap_flush(pcapio_writer* pfile, int *err);
32
33/* Close open file handles and frees memory associated with pfile.
34 *
35 * Return true on success, returns false and sets err (optional) on failure.
36 * err can be NULL, e.g. if closing after some other failure that is more
37 * relevant to report, or when exiting a program. */
38extern bool
39writecap_close(pcapio_writer* pfile, int *err);
40
41/* Writing pcap files */
42
46extern bool
47libpcap_write_file_header(pcapio_writer* pfile, int linktype, int snaplen,
48 bool ts_nsecs, uint64_t *bytes_written, int *err);
49
52extern bool
54 time_t sec, uint32_t usec,
55 uint32_t caplen, uint32_t len,
56 const uint8_t *pd,
57 uint64_t *bytes_written, int *err);
58
59/* Writing pcapng files */
60
61/* Write a pre-formatted pcapng block */
62extern bool
63pcapng_write_block(pcapio_writer* pfile,
64 const uint8_t *data,
65 uint32_t block_total_length,
66 uint64_t *bytes_written,
67 int *err);
68
72extern bool
74 GPtrArray *comments,
77 const char *hw,
80 const char *os,
83 const char *appname,
86 uint64_t section_length,
87 uint64_t *bytes_written,
88 int *err
89 );
90
91extern bool
92pcapng_write_interface_description_block(pcapio_writer* pfile,
93 const char *comment, /* OPT_COMMENT 1 */
94 const char *name, /* IDB_NAME 2 */
95 const char *descr, /* IDB_DESCRIPTION 3 */
96 const char *filter, /* IDB_FILTER 11 */
97 const char *os, /* IDB_OS 12 */
98 const char *hardware, /* IDB_HARDWARE 15 */
99 int link_type,
100 int snap_len,
101 uint64_t *bytes_written,
102 uint64_t if_speed, /* IDB_IF_SPEED 8 */
103 uint8_t tsresol, /* IDB_TSRESOL 9 */
104 int *err);
105
106extern bool
107pcapng_write_interface_statistics_block(pcapio_writer* pfile,
108 uint32_t interface_id,
109 uint64_t *bytes_written,
110 const char *comment, /* OPT_COMMENT 1 */
111 uint64_t isb_starttime, /* ISB_STARTTIME 2 */
112 uint64_t isb_endtime, /* ISB_ENDTIME 3 */
113 uint64_t isb_ifrecv, /* ISB_IFRECV 4 */
114 uint64_t isb_ifdrop, /* ISB_IFDROP 5 */
115 int *err);
116
117extern bool
118pcapng_write_enhanced_packet_block(pcapio_writer* pfile,
119 const char *comment,
120 time_t sec, uint32_t usec,
121 uint32_t caplen, uint32_t len,
122 uint32_t interface_id,
123 unsigned ts_mul,
124 const uint8_t *pd,
125 uint32_t flags,
126 uint64_t *bytes_written,
127 int *err);
bool libpcap_write_file_header(pcapio_writer *pfile, int linktype, int snaplen, bool ts_nsecs, uint64_t *bytes_written, int *err)
Definition pcapio.c:460
bool libpcap_write_packet(pcapio_writer *pfile, time_t sec, uint32_t usec, uint32_t caplen, uint32_t len, const uint8_t *pd, uint64_t *bytes_written, int *err)
Definition pcapio.c:479
bool pcapng_write_section_header_block(pcapio_writer *pfile, GPtrArray *comments, const char *hw, const char *os, const char *appname, uint64_t section_length, uint64_t *bytes_written, int *err)
Definition pcapio.c:572
Definition pcapio.c:54