Wireshark  4.3.0
The Wireshark network protocol analyzer
exported_pdu.h
Go to the documentation of this file.
1 
12 #ifndef EXPORTED_PDU_H
13 #define EXPORTED_PDU_H
14 
15 #include "ws_symbol_export.h"
16 #include "ws_attributes.h"
17 
18 #include <glib.h>
19 
20 #include <epan/tvbuff.h>
21 #include <epan/packet_info.h>
22 
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28 
29 /*
30  * Define different common tap names to extract PDUs at different layers,
31  * otherwise one packet may be exported several times at different layers
32  * if all taps are run.
33  */
34 #define EXPORT_PDU_TAP_NAME_LAYER_3 "OSI layer 3"
35 #define EXPORT_PDU_TAP_NAME_LAYER_4 "OSI layer 4"
36 #define EXPORT_PDU_TAP_NAME_LAYER_7 "OSI layer 7"
37 
38 /* To add dynamically an export name, call the following function
39  It returns the registered tap */
40 WS_DLL_PUBLIC gint register_export_pdu_tap(const char *name);
41 /* Same as above, but for export taps that use an encapsulation other
42  * than WTAP_ENCAP_WIRESHARK_UPPER_PDU */
43 WS_DLL_PUBLIC gint register_export_pdu_tap_with_encap(const char *name, gint encap);
44 WS_DLL_PUBLIC GSList *get_export_pdu_tap_list(void);
45 
46 WS_DLL_PUBLIC gint export_pdu_tap_get_encap(const char* name);
47 
54 typedef int (*exp_pdu_get_size)(packet_info *pinfo, void* data);
55 
64 typedef int (*exp_pdu_populate_data)(packet_info *pinfo, void* data, guint8 *tlv_buffer, guint32 tlv_buffer_size);
65 
66 typedef struct exp_pdu_data_item
67 {
68  exp_pdu_get_size size_func;
69  exp_pdu_populate_data populate_data;
70  void* data;
72 
73 /*
74  * This struct is used as the data part of tap_queue_packet() and contains a
75  * buffer with metadata of the protocol PDU included in the tvb in the struct.
76  *
77  * The metadata is a sequence of TLVs in the format for the header of
78  * LINKTYPE_WIRESHARK_UPPER_PDU packets in pcap pcapng files.
79  */
80 typedef struct _exp_pdu_data_t {
81  guint tlv_buffer_len;
82  guint8 *tlv_buffer;
83  guint tvb_captured_length;
84  guint tvb_reported_length;
85  tvbuff_t *pdu_tvb;
87 
99 WS_DLL_PUBLIC exp_pdu_data_t *export_pdu_create_tags(packet_info *pinfo, const char* proto_name, guint16 tag_type, const exp_pdu_data_item_t **items);
100 
116 WS_DLL_PUBLIC exp_pdu_data_t *export_pdu_create_common_tags(packet_info *pinfo, const char *proto_name, guint16 tag_type);
117 
118 WS_DLL_PUBLIC int exp_pdu_data_dissector_table_num_value_size(packet_info *pinfo, void* data);
119 WS_DLL_PUBLIC int exp_pdu_data_dissector_table_num_value_populate_data(packet_info *pinfo, void* data, guint8 *tlv_buffer, guint32 buffer_size);
120 
121 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_ip;
122 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_ip;
123 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_port_type;
124 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_port;
125 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_port;
126 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_orig_frame_num;
127 
128 extern void export_pdu_init(void);
129 
130 extern void export_pdu_cleanup(void);
131 
132 #ifdef __cplusplus
133 }
134 #endif /* __cplusplus */
135 
136 #endif /* EXPORTED_PDU_H */
WS_DLL_PUBLIC exp_pdu_data_t * export_pdu_create_common_tags(packet_info *pinfo, const char *proto_name, guint16 tag_type)
Definition: exported_pdu.c:199
int(* exp_pdu_populate_data)(packet_info *pinfo, void *data, guint8 *tlv_buffer, guint32 tlv_buffer_size)
Definition: exported_pdu.h:64
int(* exp_pdu_get_size)(packet_info *pinfo, void *data)
Definition: exported_pdu.h:54
WS_DLL_PUBLIC exp_pdu_data_t * export_pdu_create_tags(packet_info *pinfo, const char *proto_name, guint16 tag_type, const exp_pdu_data_item_t **items)
Definition: exported_pdu.c:220
Definition: exported_pdu.h:80
Definition: packet_info.h:44
Definition: exported_pdu.h:67
Definition: tvbuff-int.h:35