Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pcapng_module.h
Go to the documentation of this file.
1
9#ifndef __PCAP_MODULE_H__
10#define __PCAP_MODULE_H__
11
12#include "ws_symbol_export.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif /* __cplusplus */
17
18/*
19 * These are the officially registered block types, from the pcapng
20 * specification.
21 *
22 * XXX - Dear Sysdig People: please add your blocks to the spec!
23 */
24#define BLOCK_TYPE_SHB 0x0A0D0D0A /* Section Header Block */
25#define BLOCK_TYPE_IDB 0x00000001 /* Interface Description Block */
26#define BLOCK_TYPE_PB 0x00000002 /* Packet Block (obsolete) */
27#define BLOCK_TYPE_SPB 0x00000003 /* Simple Packet Block */
28#define BLOCK_TYPE_NRB 0x00000004 /* Name Resolution Block */
29#define BLOCK_TYPE_ISB 0x00000005 /* Interface Statistics Block */
30#define BLOCK_TYPE_EPB 0x00000006 /* Enhanced Packet Block */
31#define BLOCK_TYPE_IRIG_TS 0x00000007 /* IRIG Timestamp Block */
32#define BLOCK_TYPE_ARINC_429 0x00000008 /* ARINC 429 in AFDX Encapsulation Information Block */
33#define BLOCK_TYPE_SYSTEMD_JOURNAL_EXPORT 0x00000009 /* systemd journal entry */
34#define BLOCK_TYPE_DSB 0x0000000A /* Decryption Secrets Block */
35#define BLOCK_TYPE_HP_MIB 0x00000101 /* Hone Project Machine Info Block */
36#define BLOCK_TYPE_HP_CEB 0x00000102 /* Hone Project Connection Event Block */
37#define BLOCK_TYPE_SYSDIG_MI 0x00000201 /* Sysdig Machine Info Block */
38#define BLOCK_TYPE_SYSDIG_PL_V1 0x00000202 /* Sysdig Process List Block */
39#define BLOCK_TYPE_SYSDIG_FDL_V1 0x00000203 /* Sysdig File Descriptor List Block */
40#define BLOCK_TYPE_SYSDIG_EVENT 0x00000204 /* Sysdig Event Block */
41#define BLOCK_TYPE_SYSDIG_IL_V1 0x00000205 /* Sysdig Interface List Block */
42#define BLOCK_TYPE_SYSDIG_UL_V1 0x00000206 /* Sysdig User List Block */
43#define BLOCK_TYPE_SYSDIG_PL_V2 0x00000207 /* Sysdig Process List Block version 2 */
44#define BLOCK_TYPE_SYSDIG_EVF 0x00000208 /* Sysdig Event Block with flags */
45#define BLOCK_TYPE_SYSDIG_PL_V3 0x00000209 /* Sysdig Process List Block version 3 */
46#define BLOCK_TYPE_SYSDIG_PL_V4 0x00000210 /* Sysdig Process List Block version 4 */
47#define BLOCK_TYPE_SYSDIG_PL_V5 0x00000211 /* Sysdig Process List Block version 5 */
48#define BLOCK_TYPE_SYSDIG_PL_V6 0x00000212 /* Sysdig Process List Block version 6 */
49#define BLOCK_TYPE_SYSDIG_PL_V7 0x00000213 /* Sysdig Process List Block version 7 */
50#define BLOCK_TYPE_SYSDIG_PL_V8 0x00000214 /* Sysdig Process List Block version 8 */
51#define BLOCK_TYPE_SYSDIG_PL_V9 0x00000215 /* Sysdig Process List Block version 9 */
52#define BLOCK_TYPE_SYSDIG_EVENT_V2 0x00000216 /* Sysdig Event Block version 2 */
53#define BLOCK_TYPE_SYSDIG_EVF_V2 0x00000217 /* Sysdig Event Block with flags version 2 */
54#define BLOCK_TYPE_SYSDIG_FDL_V2 0x00000218 /* Sysdig File Descriptor List Block */
55#define BLOCK_TYPE_SYSDIG_IL_V2 0x00000219 /* Sysdig Interface List Block version 2 */
56#define BLOCK_TYPE_SYSDIG_UL_V2 0x00000220 /* Sysdig User List Block version 2 */
57#define BLOCK_TYPE_SYSDIG_EVENT_V2_LARGE 0x00000221 /* Sysdig Event Block version 2 with large payload */
58#define BLOCK_TYPE_SYSDIG_EVF_V2_LARGE 0x00000222 /* Sysdig Event Block with flags version 2 with large payload */
59#define BLOCK_TYPE_CB_COPY 0x00000BAD /* Custom Block which can be copied */
60#define BLOCK_TYPE_CB_NO_COPY 0x40000BAD /* Custom Block which should not be copied */
61
62/* TODO: the following are not yet well defined in the draft spec,
63 * and do not yet have block type values assigned to them:
64 * Alternative Packet Blocks
65 * Compression Block
66 * Encryption Block
67 * Fixed Length Block
68 * Directory Block
69 * Traffic Statistics and Monitoring Blocks
70 * Event/Security Block
71 */
72
73/* Block data to be passed between functions during reading */
74typedef struct wtapng_block_s {
75 uint32_t type; /* block_type as defined by pcapng */
76 bool internal; /* true if this block type shouldn't be returned from pcapng_read() */
77 wtap_block_t block;
78 wtap_rec *rec;
80
81/* Section data in private struct */
82/*
83 * XXX - there needs to be a more general way to implement the Netflix
84 * BBLog blocks and options.
85 */
86typedef struct section_info_t {
88 uint16_t version_major;
89 uint16_t version_minor;
90 GArray *interfaces;
91 int64_t shb_off;
92 uint32_t bblog_version;
94 uint64_t bblog_offset_tv_usec;
96
97/*
98 * Reader and writer routines for pcapng block types.
99 */
100typedef bool (*block_reader)(FILE_T fh, uint32_t block_read,
101 bool byte_swapped, wtapng_block_t *wblock,
102 int *err, char **err_info);
103typedef bool (*block_writer)(wtap_dumper *wdh, const wtap_rec *rec,
104 int *err, char **err_info);
105
106/*
107 * Register a handler for a pcapng block type.
108 */
109WS_DLL_PUBLIC
110void register_pcapng_block_type_handler(unsigned block_type, block_reader reader,
111 block_writer writer);
112
113/*
114 * Handler routines for pcapng option type.
115 */
116typedef bool (*option_parser)(wtap_block_t block, bool byte_swapped,
117 unsigned option_length,
118 const uint8_t *option_content,
119 int *err, char **err_info);
120typedef uint32_t (*option_sizer)(unsigned option_id, wtap_optval_t *optval);
121typedef bool (*option_writer)(wtap_dumper *wdh, unsigned option_id,
122 wtap_optval_t *optval, int *err);
123
124/*
125 * Register a handler for a pcapng option code for a particular block
126 * type.
127 */
128WS_DLL_PUBLIC
129void register_pcapng_option_handler(unsigned block_type, unsigned option_code,
130 option_parser parser,
131 option_sizer sizer,
132 option_writer writer);
133
134/*
135 * Byte order of the options within a block.
136 *
137 * This is usually the byte order of the section, but, for options
138 * within a Custom Block, it needs to be a specified byte order,
139 * or a byte order indicated by data in the Custom Data (stored in
140 * a fashion that doesn't require knowing the byte order of the
141 * Custom Data, as it's also the byte order of the Custom Data
142 * itself), so that programs ignorant of the format of a given
143 * type of Custom Block can still read a block from one file and
144 * write it to another, even if the host doing the writing has
145 * a byte order different from the host that previously wrote
146 * the file.
147 */
148typedef enum {
149 OPT_SECTION_BYTE_ORDER, /* byte order of this section */
150 OPT_BIG_ENDIAN, /* as it says */
151 OPT_LITTLE_ENDIAN /* ditto */
152} pcapng_opt_byte_order_e;
153
154/*
155 * Process the options section of a block. process_option points to
156 * a routine that processes all the block-specific options, i.e.
157 * options other than the end-of-options, comment, and custom
158 * options.
159 */
160WS_DLL_PUBLIC
161bool pcapng_process_options(FILE_T fh, wtapng_block_t *wblock,
162 section_info_t *section_info,
163 unsigned opt_cont_buf_len,
164 bool (*process_option)(wtapng_block_t *,
165 const section_info_t *,
166 uint16_t, uint16_t,
167 const uint8_t *,
168 int *, char **),
169 pcapng_opt_byte_order_e byte_order,
170 int *err, char **err_info);
171
172/*
173 * Helper routines to process options with types used in more than one
174 * block type.
175 */
176WS_DLL_PUBLIC
177void pcapng_process_uint8_option(wtapng_block_t *wblock,
178 uint16_t option_code, uint16_t option_length,
179 const uint8_t *option_content);
180
181WS_DLL_PUBLIC
182void pcapng_process_uint32_option(wtapng_block_t *wblock,
183 const section_info_t *section_info,
184 pcapng_opt_byte_order_e byte_order,
185 uint16_t option_code, uint16_t option_length,
186 const uint8_t *option_content);
187
188WS_DLL_PUBLIC
189void pcapng_process_timestamp_option(wtapng_block_t *wblock,
190 const section_info_t *section_info,
191 pcapng_opt_byte_order_e byte_order,
192 uint16_t option_code, uint16_t option_length,
193 const uint8_t *option_content);
194
195WS_DLL_PUBLIC
196void pcapng_process_uint64_option(wtapng_block_t *wblock,
197 const section_info_t *section_info,
198 pcapng_opt_byte_order_e byte_order,
199 uint16_t option_code, uint16_t option_length,
200 const uint8_t *option_content);
201
202WS_DLL_PUBLIC
203void pcapng_process_int64_option(wtapng_block_t *wblock,
204 const section_info_t *section_info,
205 pcapng_opt_byte_order_e byte_order,
206 uint16_t option_code, uint16_t option_length,
207 const uint8_t *option_content);
208
209WS_DLL_PUBLIC
210void pcapng_process_string_option(wtapng_block_t *wblock, uint16_t option_code,
211 uint16_t option_length, const uint8_t *option_content);
212
213WS_DLL_PUBLIC
214void pcapng_process_bytes_option(wtapng_block_t *wblock, uint16_t option_code,
215 uint16_t option_length, const uint8_t *option_content);
216
217typedef uint32_t (*compute_option_size_func)(wtap_block_t, unsigned, wtap_opttype_e, wtap_optval_t*);
218
220{
221 uint32_t size;
222 compute_option_size_func compute_option_size;
224
225WS_DLL_PUBLIC
226uint32_t pcapng_compute_options_size(wtap_block_t block, compute_option_size_func compute_option_size);
227
228typedef bool (*write_option_func)(wtap_dumper *, wtap_block_t, unsigned, wtap_opttype_e, wtap_optval_t*, int*);
229
230WS_DLL_PUBLIC
231bool pcapng_write_options(wtap_dumper *wdh, wtap_block_t block, write_option_func write_option, int *err);
232
233#ifdef __cplusplus
234}
235#endif /* __cplusplus */
236
237#endif /* __PCAP_MODULE_H__ */
Definition pcapng_module.h:220
Definition pcapng_module.h:86
uint16_t version_major
Definition pcapng_module.h:88
int64_t shb_off
Definition pcapng_module.h:91
uint32_t bblog_version
Definition pcapng_module.h:92
uint16_t version_minor
Definition pcapng_module.h:89
uint64_t bblog_offset_tv_sec
Definition pcapng_module.h:93
GArray * interfaces
Definition pcapng_module.h:90
bool byte_swapped
Definition pcapng_module.h:87
Definition wtap_opttypes.c:85
Definition wtap-int.h:97
Definition file_wrappers.c:215
Definition wtap.h:1433
Definition pcapng_module.h:74
Definition wtap_opttypes.h:433