Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
exported_pdu.h
Go to the documentation of this file.
1
11#pragma once
12#include "ws_symbol_export.h"
13#include "ws_attributes.h"
14
15#include <epan/tvbuff.h>
16#include <epan/packet_info.h>
17
19
20#ifdef __cplusplus
21extern "C" {
22#endif /* __cplusplus */
23
24/*
25 * Define different common tap names to extract PDUs at different layers,
26 * otherwise one packet may be exported several times at different layers
27 * if all taps are run.
28 */
29#define EXPORT_PDU_TAP_NAME_LAYER_3 "OSI layer 3"
30#define EXPORT_PDU_TAP_NAME_LAYER_4 "OSI layer 4"
31#define EXPORT_PDU_TAP_NAME_LAYER_7 "OSI layer 7"
32
33/* To add dynamically an export name, call the following function
34 It returns the registered tap */
41WS_DLL_PUBLIC int register_export_pdu_tap(const char *name);
42/* Same as above, but for export taps that use an encapsulation other
43 * than WTAP_ENCAP_WIRESHARK_UPPER_PDU */
44WS_DLL_PUBLIC int register_export_pdu_tap_with_encap(const char *name, int encap);
45WS_DLL_PUBLIC GSList *get_export_pdu_tap_list(void);
46
47WS_DLL_PUBLIC int export_pdu_tap_get_encap(const char* name);
48
56typedef int (*exp_pdu_get_size)(packet_info *pinfo, void* data);
57
67typedef int (*exp_pdu_populate_data)(packet_info *pinfo, void* data, uint8_t *tlv_buffer, uint32_t tlv_buffer_size);
68
69typedef struct exp_pdu_data_item
70{
71 exp_pdu_get_size size_func;
72 exp_pdu_populate_data populate_data;
73 void* data;
75
76/*
77 * This struct is used as the data part of tap_queue_packet() and contains a
78 * buffer with metadata of the protocol PDU included in the tvb in the struct.
79 *
80 * The metadata is a sequence of TLVs in the format for the header of
81 * LINKTYPE_WIRESHARK_UPPER_PDU packets in pcap pcapng files.
82 */
83typedef struct _exp_pdu_data_t {
84 unsigned tlv_buffer_len;
85 uint8_t *tlv_buffer;
86 unsigned tvb_captured_length;
87 unsigned tvb_reported_length;
88 tvbuff_t *pdu_tvb;
90
102WS_DLL_PUBLIC exp_pdu_data_t *export_pdu_create_tags(packet_info *pinfo, const char* proto_name, uint16_t tag_type, const exp_pdu_data_item_t **items);
103
119WS_DLL_PUBLIC exp_pdu_data_t *export_pdu_create_common_tags(packet_info *pinfo, const char *proto_name, uint16_t tag_type);
120
121WS_DLL_PUBLIC int exp_pdu_data_dissector_table_num_value_size(packet_info *pinfo, void* data);
122WS_DLL_PUBLIC int exp_pdu_data_dissector_table_num_value_populate_data(packet_info *pinfo, void* data, uint8_t *tlv_buffer, uint32_t buffer_size);
123
124WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_ip;
125WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_ip;
126WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_port_type;
127WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_port;
128WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_port;
129WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_orig_frame_num;
130
136extern void export_pdu_init(void);
137
144extern void export_pdu_cleanup(void);
145
146#ifdef __cplusplus
147}
148#endif /* __cplusplus */
WS_DLL_PUBLIC int register_export_pdu_tap(const char *name)
Register an export PDU tap with a default encapsulation.
Definition exported_pdu.c:284
void export_pdu_cleanup(void)
Cleans up resources used by exported PDU handling.
Definition exported_pdu.c:327
int(* exp_pdu_get_size)(packet_info *pinfo, void *data)
Compute the size (in bytes) of a pdu item.
Definition exported_pdu.h:56
int(* exp_pdu_populate_data)(packet_info *pinfo, void *data, uint8_t *tlv_buffer, uint32_t tlv_buffer_size)
Populate a buffer with pdu item data.
Definition exported_pdu.h:67
WS_DLL_PUBLIC exp_pdu_data_t * export_pdu_create_common_tags(packet_info *pinfo, const char *proto_name, uint16_t tag_type)
Definition exported_pdu.c:197
void export_pdu_init(void)
Initializes the PDU export system.
Definition exported_pdu.c:322
WS_DLL_PUBLIC exp_pdu_data_t * export_pdu_create_tags(packet_info *pinfo, const char *proto_name, uint16_t tag_type, const exp_pdu_data_item_t **items)
Definition exported_pdu.c:218
Definition exported_pdu.h:83
Definition packet_info.h:40
Definition exported_pdu.h:70
Definition tvbuff-int.h:33