9#ifndef __PCAP_MODULE_H__
10#define __PCAP_MODULE_H__
14#include "ws_symbol_export.h"
26#define BLOCK_TYPE_SHB 0x0A0D0D0A
27#define BLOCK_TYPE_IDB 0x00000001
28#define BLOCK_TYPE_PB 0x00000002
29#define BLOCK_TYPE_SPB 0x00000003
30#define BLOCK_TYPE_NRB 0x00000004
31#define BLOCK_TYPE_ISB 0x00000005
32#define BLOCK_TYPE_EPB 0x00000006
33#define BLOCK_TYPE_IRIG_TS 0x00000007
34#define BLOCK_TYPE_ARINC_429 0x00000008
35#define BLOCK_TYPE_SYSTEMD_JOURNAL_EXPORT 0x00000009
36#define BLOCK_TYPE_DSB 0x0000000A
37#define BLOCK_TYPE_HP_MIB 0x00000101
38#define BLOCK_TYPE_HP_CEB 0x00000102
39#define BLOCK_TYPE_SYSDIG_MI 0x00000201
40#define BLOCK_TYPE_SYSDIG_PL_V1 0x00000202
41#define BLOCK_TYPE_SYSDIG_FDL_V1 0x00000203
42#define BLOCK_TYPE_SYSDIG_EVENT 0x00000204
43#define BLOCK_TYPE_SYSDIG_IL_V1 0x00000205
44#define BLOCK_TYPE_SYSDIG_UL_V1 0x00000206
45#define BLOCK_TYPE_SYSDIG_PL_V2 0x00000207
46#define BLOCK_TYPE_SYSDIG_EVF 0x00000208
47#define BLOCK_TYPE_SYSDIG_PL_V3 0x00000209
48#define BLOCK_TYPE_SYSDIG_PL_V4 0x00000210
49#define BLOCK_TYPE_SYSDIG_PL_V5 0x00000211
50#define BLOCK_TYPE_SYSDIG_PL_V6 0x00000212
51#define BLOCK_TYPE_SYSDIG_PL_V7 0x00000213
52#define BLOCK_TYPE_SYSDIG_PL_V8 0x00000214
53#define BLOCK_TYPE_SYSDIG_PL_V9 0x00000215
54#define BLOCK_TYPE_SYSDIG_EVENT_V2 0x00000216
55#define BLOCK_TYPE_SYSDIG_EVF_V2 0x00000217
56#define BLOCK_TYPE_SYSDIG_FDL_V2 0x00000218
57#define BLOCK_TYPE_SYSDIG_IL_V2 0x00000219
58#define BLOCK_TYPE_SYSDIG_UL_V2 0x00000220
59#define BLOCK_TYPE_SYSDIG_EVENT_V2_LARGE 0x00000221
60#define BLOCK_TYPE_SYSDIG_EVF_V2_LARGE 0x00000222
61#define BLOCK_TYPE_CB_COPY 0x00000BAD
62#define BLOCK_TYPE_CB_NO_COPY 0x40000BAD
63#define BLOCK_TYPE_LEGACY_DPIB 0x80000001
107typedef bool (*block_reader)(
wtap* wth, FILE_T fh, uint32_t block_type,
108 uint32_t block_content_length,
111 int *err,
char **err_info);
113 int *err,
char **err_info);
141typedef bool (*option_parser)(wtap_block_t block,
bool byte_swapped,
142 unsigned option_length,
143 const uint8_t *option_content,
144 int *err,
char **err_info);
145typedef uint32_t (*option_sizer)(
unsigned option_id,
wtap_optval_t *optval);
146typedef bool (*option_writer)(
wtap_dumper *wdh,
unsigned option_id,
168 option_parser parser,
170 option_writer writer);
208 unsigned opt_cont_buf_len,
215 int *err,
char **err_info);
228 uint16_t option_code, uint16_t option_length,
229 const uint8_t *option_content);
245 uint16_t option_code, uint16_t option_length,
246 const uint8_t *option_content);
262 uint16_t option_code, uint16_t option_length,
263 const uint8_t *option_content);
279 uint16_t option_code, uint16_t option_length,
280 const uint8_t *option_content);
296 uint16_t option_code, uint16_t option_length,
297 const uint8_t *option_content);
309 uint16_t option_length,
const uint8_t *option_content);
321 uint16_t option_length,
const uint8_t *option_content);
343typedef bool (*write_option_func)(
wtap_dumper *wdh, wtap_block_t block,
347 int *err,
char **err_info);
362 wtap_block_t block, write_option_func write_option,
363 int *err,
char **err_info);
368typedef bool (*custom_option_parser)(FILE_T fh,
section_info_t* section_info,
370 int* err,
char** err_info);
373 const uint8_t* value, uint16_t length);
414 uint32_t block_content_length,
int *err);
428pcapng_write_padding(
wtap_dumper *wdh,
size_t pad,
int *err)
431 const uint32_t zero_pad = 0;
432 if (!wtap_dump_file_write(wdh, &zero_pad, pad, err))
459 void *(*provision)(void);
WS_DLL_PUBLIC void pcapng_process_uint64_option(wtapng_block_t *wblock, section_info_t *section_info, pcapng_opt_byte_order_e byte_order, uint16_t option_code, uint16_t option_length, const uint8_t *option_content)
Process a 64-bit unsigned integer option in a PCAP-NG block.
Definition pcapng.c:656
WS_DLL_PUBLIC void * pcapng_get_lb_section_info_data(section_info_t *section_info, uint32_t block_type, const section_info_funcs_t *funcs)
Find local block information from a section_info_t; add a newly-created one and return it if none is ...
Definition pcapng.c:482
WS_DLL_PUBLIC bool pcapng_write_block_footer(wtap_dumper *wdh, uint32_t block_content_length, int *err)
Writes a block footer for a PCAPNG file.
Definition pcapng.c:6283
WS_DLL_PUBLIC void pcapng_process_timestamp_option(wtapng_block_t *wblock, section_info_t *section_info, pcapng_opt_byte_order_e byte_order, uint16_t option_code, uint16_t option_length, const uint8_t *option_content)
Process a timestamp option in a PCAPng block.
Definition pcapng.c:597
WS_DLL_PUBLIC uint32_t pcapng_compute_options_size(wtap_block_t block, compute_option_size_func compute_option_size)
Computes the total size of all options in a PCAPNG block.
Definition pcapng.c:4144
WS_DLL_PUBLIC void pcapng_process_uint32_option(wtapng_block_t *wblock, section_info_t *section_info, pcapng_opt_byte_order_e byte_order, uint16_t option_code, uint16_t option_length, const uint8_t *option_content)
Process a 32-bit unsigned integer option in a PCAPNG block.
Definition pcapng.c:540
WS_DLL_PUBLIC void * pcapng_get_cb_section_info_data(section_info_t *section_info, uint32_t pen, const section_info_funcs_t *funcs)
Find local block information from a section_info_t; add a newly-created one and return it if none is ...
Definition pcapng.c:429
WS_DLL_PUBLIC void pcapng_process_uint8_option(wtapng_block_t *wblock, uint16_t option_code, uint16_t option_length, const uint8_t *option_content)
Helper routines to process options with types used in more than one block type.
Definition pcapng.c:525
WS_DLL_PUBLIC void pcapng_process_int64_option(wtapng_block_t *wblock, section_info_t *section_info, pcapng_opt_byte_order_e byte_order, uint16_t option_code, uint16_t option_length, const uint8_t *option_content)
Process a 64-bit integer option in a PCAPNG block.
Definition pcapng.c:708
struct wtapng_block_s wtapng_block_t
Transient container used to pass a parsed pcapng block between internal read functions.
WS_DLL_PUBLIC void register_pcapng_option_handler(unsigned block_type, unsigned option_code, option_parser parser, option_sizer sizer, option_writer writer)
Register a handler for a pcapng option code for a particular block type.
Definition pcapng.c:365
pcapng_opt_byte_order_e
Byte order of the options within a block.
Definition pcapng_module.h:186
@ OPT_BIG_ENDIAN
Definition pcapng_module.h:188
@ OPT_LITTLE_ENDIAN
Definition pcapng_module.h:189
@ OPT_SECTION_BYTE_ORDER
Definition pcapng_module.h:187
WS_DLL_PUBLIC void register_pcapng_block_type_information(pcapng_block_type_information_t *handler)
Register a handler for a pcapng block type.
Definition pcapng.c:238
WS_DLL_PUBLIC void pcapng_process_string_option(wtapng_block_t *wblock, uint16_t option_code, uint16_t option_length, const uint8_t *option_content)
Process a string option in a PCAPNG block.
Definition pcapng.c:760
WS_DLL_PUBLIC void pcapng_process_bytes_option(wtapng_block_t *wblock, uint16_t option_code, uint16_t option_length, const uint8_t *option_content)
Processes a bytes option in a PCAPng block.
Definition pcapng.c:781
WS_DLL_PUBLIC bool pcapng_write_block_header(wtap_dumper *wdh, uint32_t block_type, uint32_t block_content_length, int *err)
Write a pcapng block header.
Definition pcapng.c:6263
WS_DLL_PUBLIC GHashTable * pcapng_create_option_handler_table(void)
Create a table of handlers for pcapng option codes.
Definition pcapng.c:337
WS_DLL_PUBLIC bool pcapng_process_options(FILE_T fh, wtapng_block_t *wblock, section_info_t *section_info, unsigned opt_cont_buf_len, bool(*process_option)(wtapng_block_t *, section_info_t *, uint16_t, uint16_t, const uint8_t *, int *, char **), pcapng_opt_byte_order_e byte_order, int *err, char **err_info)
Process the options section of a block.
Definition pcapng.c:933
WS_DLL_PUBLIC void register_pcapng_custom_block_enterprise_handler(unsigned enterprise_number, pcapng_custom_block_enterprise_handler_t const *handler)
Register a handler for a pcapng custom block with an enterprise number.
Definition pcapng.c:2948
WS_DLL_PUBLIC bool pcapng_write_options(wtap_dumper *wdh, pcapng_opt_byte_order_e byte_order, wtap_block_t block, write_option_func write_option, int *err, char **err_info)
Writes options to a pcapng file.
Definition pcapng.c:4810
Accumulator and callback used to compute the total serialized size of a block's options.
Definition pcapng_module.h:328
compute_option_size_func compute_option_size
Definition pcapng_module.h:330
uint32_t size
Definition pcapng_module.h:329
Dispatch table for handling a vendor-specific pcapng custom block identified by a Private Enterprise ...
Definition pcapng_module.h:378
custom_option_processor processor
Definition pcapng_module.h:380
block_writer writer
Definition pcapng_module.h:381
custom_option_parser parser
Definition pcapng_module.h:379
Holds the allocation and deallocation callbacks for custom or local block data associated with a sect...
Definition pcapng_module.h:458
GDestroyNotify free
Definition pcapng_module.h:460
Per-section state accumulated while reading a pcapng Section Header Block and its contents.
Definition pcapng_module.h:94
uint16_t version_major
Definition pcapng_module.h:96
int64_t shb_off
Definition pcapng_module.h:99
uint16_t version_minor
Definition pcapng_module.h:97
GHashTable * local_block_data
Definition pcapng_module.h:101
GHashTable * custom_block_data
Definition pcapng_module.h:100
GArray * interfaces
Definition pcapng_module.h:98
bool byte_swapped
Definition pcapng_module.h:95
Wiretap dumper handle and associated state.
Definition wtap_module.h:163
Represents a single capture record read from or written to a capture file, regardless of record type.
Definition wtap.h:1599
Definition wtap_module.h:58
Transient container used to pass a parsed pcapng block between internal read functions.
Definition pcapng_module.h:79
wtap_block_t block
Definition pcapng_module.h:82
uint32_t type
Definition pcapng_module.h:80
bool internal
Definition pcapng_module.h:81
wtap_rec * rec
Definition pcapng_module.h:83
Discriminated union holding the value of any Wiretap option type.
Definition wtap_opttypes.h:552
wtap_opttype_e
Data types for option values stored within a wtap block.
Definition wtap_opttypes.h:404