drsuapi_SupportedExtensionsExt
[wireshark-sm.git] / epan / exported_pdu.h
blob4fcbceafbc790b0cfc84031469afb0ad4f91acc4
1 /** @file
2 * Routines for exported_pdu dissection
3 * Copyright 2013, Anders Broman <anders-broman@ericsson.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef EXPORTED_PDU_H
13 #define EXPORTED_PDU_H
15 #include "ws_symbol_export.h"
16 #include "ws_attributes.h"
18 #include <epan/tvbuff.h>
19 #include <epan/packet_info.h>
21 #include <wsutil/exported_pdu_tlvs.h>
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
28 * Define different common tap names to extract PDUs at different layers,
29 * otherwise one packet may be exported several times at different layers
30 * if all taps are run.
32 #define EXPORT_PDU_TAP_NAME_LAYER_3 "OSI layer 3"
33 #define EXPORT_PDU_TAP_NAME_LAYER_4 "OSI layer 4"
34 #define EXPORT_PDU_TAP_NAME_LAYER_7 "OSI layer 7"
36 /* To add dynamically an export name, call the following function
37 It returns the registered tap */
38 WS_DLL_PUBLIC int register_export_pdu_tap(const char *name);
39 /* Same as above, but for export taps that use an encapsulation other
40 * than WTAP_ENCAP_WIRESHARK_UPPER_PDU */
41 WS_DLL_PUBLIC int register_export_pdu_tap_with_encap(const char *name, int encap);
42 WS_DLL_PUBLIC GSList *get_export_pdu_tap_list(void);
44 WS_DLL_PUBLIC int export_pdu_tap_get_encap(const char* name);
46 /** Compute the size (in bytes) of a pdu item
48 @param pinfo Packet info that may contain data for the pdu item
49 @param data optional data of the pdu item
50 @return the size of the pdu item
52 typedef int (*exp_pdu_get_size)(packet_info *pinfo, void* data);
54 /** Populate a buffer with pdu item data
56 @param pinfo Packet info that may contain data for the PDU item
57 @param data optional data of the PDU item
58 @param tlv_buffer buffer to be populated with PDU item
59 @param tlv_buffer_size size of buffer to be populated
60 @return the number of bytes populated to the buffer (typically PDU item size)
62 typedef int (*exp_pdu_populate_data)(packet_info *pinfo, void* data, uint8_t *tlv_buffer, uint32_t tlv_buffer_size);
64 typedef struct exp_pdu_data_item
66 exp_pdu_get_size size_func;
67 exp_pdu_populate_data populate_data;
68 void* data;
69 } exp_pdu_data_item_t;
72 * This struct is used as the data part of tap_queue_packet() and contains a
73 * buffer with metadata of the protocol PDU included in the tvb in the struct.
75 * The metadata is a sequence of TLVs in the format for the header of
76 * LINKTYPE_WIRESHARK_UPPER_PDU packets in pcap pcapng files.
78 typedef struct _exp_pdu_data_t {
79 unsigned tlv_buffer_len;
80 uint8_t *tlv_buffer;
81 unsigned tvb_captured_length;
82 unsigned tvb_reported_length;
83 tvbuff_t *pdu_tvb;
84 } exp_pdu_data_t;
86 /**
87 Allocates and fills the exp_pdu_data_t struct according to the list of items
89 The tags in the tag buffer SHOULD be added in numerical order.
91 @param pinfo Packet info that may contain data for the PDU items
92 @param proto_name Name of protocol that is exporting PDU
93 @param tag_type Tag type for protocol's PDU. Must be EXP_PDU_TAG_DISSECTOR_NAME or EXP_PDU_TAG_HEUR_DISSECTOR_NAME.
94 @param items PDU items to be exported
95 @return filled exp_pdu_data_t struct
97 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);
99 /**
100 Allocates and fills the exp_pdu_data_t struct with a common list of items
101 The items that will be exported as the PDU are:
102 1. Source IP
103 2. Destination IP
104 3. Port type
105 4. Source Port
106 5. Destination Port
107 6. Original frame number
109 @param pinfo Packet info that may contain data for the PDU items
110 @param tag_type Tag type for protocol's PDU. Must be EXP_PDU_TAG_DISSECTOR_NAME, EXP_PDU_TAG_HEUR_DISSECTOR_NAME or EXP_PDU_TAG_DISSECTOR_TABLE_NAME
111 @param proto_name Name of protocol that is exporting PDU
112 @return filled exp_pdu_data_t struct
114 WS_DLL_PUBLIC exp_pdu_data_t *export_pdu_create_common_tags(packet_info *pinfo, const char *proto_name, uint16_t tag_type);
116 WS_DLL_PUBLIC int exp_pdu_data_dissector_table_num_value_size(packet_info *pinfo, void* data);
117 WS_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);
119 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_ip;
120 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_ip;
121 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_port_type;
122 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_port;
123 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_port;
124 WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_orig_frame_num;
126 extern void export_pdu_init(void);
128 extern void export_pdu_cleanup(void);
130 #ifdef __cplusplus
132 #endif /* __cplusplus */
134 #endif /* EXPORTED_PDU_H */