Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
exported_pdu.h
1 /*
2  * exported_pdu.h
3  * Routines for exported_pdu dissection
4  * Copyright 2013, Anders Broman <anders-broman@ericsson.com>
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12 
13 #ifndef EXPORTED_PDU_H
14 #define EXPORTED_PDU_H
15 
16 #include "ws_symbol_export.h"
17 #include "ws_attributes.h"
18 
19 #include <glib.h>
20 
21 #include <epan/tvbuff.h>
22 #include <epan/packet_info.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27 
28 /*
29  * Define different common tap names to extract PDUs at different layers,
30  * otherwise one packet may be exported several times at different layers
31  * if all taps are run.
32  */
33 #define EXPORT_PDU_TAP_NAME_LAYER_3 "OSI layer 3"
34 #define EXPORT_PDU_TAP_NAME_LAYER_4 "OSI layer 4"
35 #define EXPORT_PDU_TAP_NAME_LAYER_7 "OSI layer 7"
36 
37 /* To add dynamically an export name, call the following function
38  It returns the registered tap */
39 WS_DLL_PUBLIC gint register_export_pdu_tap(const char *name);
40 WS_DLL_PUBLIC GSList *get_export_pdu_tap_list(void);
41 
64 /* Tag values
65  *
66  * Do NOT add new values to this list without asking
67  * wireshark-dev[AT]wireshark.org for a value. Otherwise, you run the risk of
68  * using a value that's already being used for some other purpose, and of
69  * having tools that read exported_pdu captures not being able to handle
70  * captures with your new tag value, with no hope that they will ever be
71  * changed to do so (as that would destroy their ability to read captures
72  * using that value for that other purpose).
73  */
74 #define EXP_PDU_TAG_END_OF_OPT 0
75 /* 1 - 9 reserved */
76 #define EXP_PDU_TAG_OPTIONS_LENGTH 10
77 #define EXP_PDU_TAG_LINKTYPE 11
78 #define EXP_PDU_TAG_PROTO_NAME 12
82 #define EXP_PDU_TAG_HEUR_PROTO_NAME 13
87 #define EXP_PDU_TAG_DISSECTOR_TABLE_NAME 14
93 /* Add protocol type related tags here.
94  * NOTE Only one protocol type tag may be present in a packet, the first one
95  * found will be used*/
96 /* 13 - 19 reserved */
97 #define EXP_PDU_TAG_IPV4_SRC 20
98 #define EXP_PDU_TAG_IPV4_DST 21
99 #define EXP_PDU_TAG_IPV6_SRC 22
100 #define EXP_PDU_TAG_IPV6_DST 23
101 
102 #define EXP_PDU_TAG_PORT_TYPE 24
103 #define EXP_PDU_TAG_SRC_PORT 25
104 #define EXP_PDU_TAG_DST_PORT 26
105 
106 #define EXP_PDU_TAG_SS7_OPC 28
107 #define EXP_PDU_TAG_SS7_DPC 29
108 
109 #define EXP_PDU_TAG_ORIG_FNO 30
110 
111 #define EXP_PDU_TAG_DVBCI_EVT 31
112 
113 #define EXP_PDU_TAG_DISSECTOR_TABLE_NAME_NUM_VAL 32
117 #define EXP_PDU_TAG_COL_PROT_TEXT 33
130 #define EXP_PDU_TAG_TCP_INFO_DATA 34
131 
132 typedef struct _exp_pdu_data_t {
133  guint tlv_buffer_len;
134  guint8 *tlv_buffer;
135  guint tvb_captured_length;
136  guint tvb_reported_length;
137  tvbuff_t *pdu_tvb;
139 
140 #define EXP_PDU_TAG_IPV4_LEN 4
141 #define EXP_PDU_TAG_IPV6_LEN 16
142 
143 #define EXP_PDU_TAG_PORT_TYPE_LEN 4
144 #define EXP_PDU_TAG_PORT_LEN 4
145 
146 #define EXP_PDU_TAG_SS7_OPC_LEN 8 /* 4 bytes PC, 2 bytes standard type, 1 byte NI, 1 byte padding */
147 #define EXP_PDU_TAG_SS7_DPC_LEN 8 /* 4 bytes PC, 2 bytes standard type, 1 byte NI, 1 byte padding */
148 
149 #define EXP_PDU_TAG_ORIG_FNO_LEN 4
150 
151 #define EXP_PDU_TAG_DVBCI_EVT_LEN 1
152 
153 #define EXP_PDU_TAG_DISSECTOR_TABLE_NUM_VAL_LEN 4
154 
155 /* Port types are no longer used for conversation/endpoints so
156  many of the enumerated values have been eliminated
157  Since export PDU functionality is serializing them,
158  keep the old values around for conversion */
159 #define OLD_PT_NONE 0
160 #define OLD_PT_SCTP 1
161 #define OLD_PT_TCP 2
162 #define OLD_PT_UDP 3
163 #define OLD_PT_DCCP 4
164 #define OLD_PT_IPX 5
165 #define OLD_PT_NCP 6
166 #define OLD_PT_EXCHG 7
167 #define OLD_PT_DDP 8
168 #define OLD_PT_SBCCS 9
169 #define OLD_PT_IDP 10
170 #define OLD_PT_TIPC 11
171 #define OLD_PT_USB 12
172 #define OLD_PT_I2C 13
173 #define OLD_PT_IBQP 14
174 #define OLD_PT_BLUETOOTH 15
175 #define OLD_PT_TDMOP 16
176 
177 
184 typedef int (*exp_pdu_get_size)(packet_info *pinfo, void* data);
185 
194 typedef int (*exp_pdu_populate_data)(packet_info *pinfo, void* data, guint8 *tlv_buffer, guint32 tlv_buffer_size);
195 
196 typedef struct exp_pdu_data_item
197 {
198  exp_pdu_get_size size_func;
199  exp_pdu_populate_data populate_data;
200  void* data;
202 
214 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);
215 
231 WS_DLL_PUBLIC exp_pdu_data_t *export_pdu_create_common_tags(packet_info *pinfo, const char *proto_name, guint16 tag_type);
232 
233 WS_DLL_PUBLIC int exp_pdu_data_dissector_table_num_value_size(packet_info *pinfo, void* data);
234 WS_DLL_PUBLIC int exp_pdu_data_dissector_table_num_value_populate_data(packet_info *pinfo, void* data, guint8 *tlv_buffer, guint32 buffer_size);
235 
236 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_ip;
237 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_ip;
238 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_port_type;
239 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_port;
240 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_port;
241 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_orig_frame_num;
242 
243 extern void export_pdu_init(void);
244 
245 extern void export_pdu_cleanup(void);
246 
247 #ifdef __cplusplus
248 }
249 #endif /* __cplusplus */
250 
251 #endif /* EXPORTED_PDU_H */
Definition: exported_pdu.h:147
Definition: packet_info.h:44
Definition: tvbuff-int.h:35
Definition: exported_pdu.h:211