Wireshark 2.9.0-477-g68ec514b The Wireshark network protocol analyzer

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

conversation.h
Go to the documentation of this file.
1 /* conversation.h
2 * Routines for building lists of packets that are part of a "conversation"
3 *
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11 #ifndef __CONVERSATION_H__
12 #define __CONVERSATION_H__
13
14 #include "ws_symbol_export.h"
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
19
23 /*
24 * Flags to pass to "conversation_new()" to indicate that the address 2
25 * and/or port 2 values for the conversation should be wildcards.
26 * The CONVERSATION_TEMPLATE option tells that any of the other supplied
27 * port and / or address wildcards will be used to match an infinite number
28 * of new connections to the conversation(s) that have the CONVERSATION_-
29 * TEMPLATE flag set. Any conversation created without the CONVERSATION_-
30 * TEMPLATE flag will be altered once the first connections (connection
31 * oriented protocols only) to include the newly found information which
32 * matched the wildcard options.
33 */
34 #define NO_ADDR2 0x01
35 #define NO_PORT2 0x02
36 #define NO_PORT2_FORCE 0x04
37 #define CONVERSATION_TEMPLATE 0x08
38
39 /*
40 * Flags to pass to "find_conversation()" to indicate that the address B
41 * and/or port B search arguments are wildcards.
42 */
43 #define NO_ADDR_B 0x01
44 #define NO_PORT_B 0x02
45
46 /* Flags to handle endpoints */
47 #define USE_LAST_ENDPOINT 0x08 /* Use last endpoint created, regardless of type */
48
49 #include "packet.h" /* for conversation dissector type */
50
51 /* Types of port numbers Wireshark knows about. */
52 typedef enum {
53 ENDPOINT_NONE, /* no endpoint */
54 ENDPOINT_SCTP, /* SCTP */
55 ENDPOINT_TCP, /* TCP */
56 ENDPOINT_UDP, /* UDP */
57 ENDPOINT_DCCP, /* DCCP */
58 ENDPOINT_IPX, /* IPX sockets */
59 ENDPOINT_NCP, /* NCP connection */
60 ENDPOINT_EXCHG, /* Fibre Channel exchange */
61 ENDPOINT_DDP, /* DDP AppleTalk connection */
62 ENDPOINT_SBCCS, /* FICON */
63 ENDPOINT_IDP, /* XNS IDP sockets */
64 ENDPOINT_TIPC, /* TIPC PORT */
65 ENDPOINT_USB, /* USB endpoint 0xffff means the host */
66 ENDPOINT_I2C,
67 ENDPOINT_IBQP, /* Infiniband QP number */
68 ENDPOINT_BLUETOOTH,
69 ENDPOINT_TDMOP,
70 ENDPOINT_DVBCI,
71 ENDPOINT_ISO14443,
72 ENDPOINT_ISDN, /* ISDN channel number */
73 ENDPOINT_H223, /* H.223 logical channel number */
74 ENDPOINT_X25, /* X.25 logical channel number */
75 ENDPOINT_IAX2, /* IAX2 call id */
76 ENDPOINT_DLCI, /* Frame Relay DLCI */
77 ENDPOINT_ISUP, /* ISDN User Part CIC */
78 ENDPOINT_BICC, /* BICC Circuit identifier */
79 ENDPOINT_GSMTAP,
80 ENDPOINT_IUUP
81 } endpoint_type;
82
86 struct conversation_key;
87 typedef struct conversation_key* conversation_key_t;
88
89 typedef struct conversation {
90 struct conversation *next;
91 struct conversation *last;
92 struct conversation *latest_found;
94 guint32 conv_index;
95 guint32 setup_frame;
96 /* Assume that setup_frame is also the lowest frame number for now. */
97 guint32 last_frame;
98 wmem_tree_t *data_list;
99 wmem_tree_t *dissector_tree;
101 guint options;
102 conversation_key_t key_ptr;
103 } conversation_t;
104
105
106 struct endpoint;
107 typedef struct endpoint* endpoint_t;
108
109 WS_DLL_PUBLIC address* conversation_key_addr1(const conversation_key_t key);
110 WS_DLL_PUBLIC address* conversation_key_addr2(const conversation_key_t key);
111 WS_DLL_PUBLIC guint32 conversation_key_port1(const conversation_key_t key);
112 WS_DLL_PUBLIC guint32 conversation_key_port2(const conversation_key_t key);
113
117 extern void conversation_init(void);
118
122 extern void conversation_epan_reset(void);
123
124 /*
125 * Given two address/port pairs for a packet, create a new conversation
126 * to contain packets between those address/port pairs.
127 *
128 * The options field is used to specify whether the address 2 value
129 * and/or port 2 value are not given and any value is acceptable
130 * when searching for this conversation.
131 */
132 WS_DLL_PUBLIC conversation_t *conversation_new(const guint32 setup_frame, const address *addr1, const address *addr2,
133 const endpoint_type etype, const guint32 port1, const guint32 port2, const guint options);
134
135 WS_DLL_PUBLIC conversation_t *conversation_new_by_id(const guint32 setup_frame, const endpoint_type etype, const guint32 id, const guint options);
136
173 WS_DLL_PUBLIC conversation_t *find_conversation(const guint32 frame_num, const address *addr_a, const address *addr_b,
174 const endpoint_type etype, const guint32 port_a, const guint32 port_b, const guint options);
175
176 WS_DLL_PUBLIC conversation_t *find_conversation_by_id(const guint32 frame, const endpoint_type etype, const guint32 id, const guint options);
177
181 WS_DLL_PUBLIC conversation_t *find_conversation_pinfo(packet_info *pinfo, const guint options);
182
189 WS_DLL_PUBLIC conversation_t *find_or_create_conversation(packet_info *pinfo);
190
191 WS_DLL_PUBLIC void conversation_add_proto_data(conversation_t *conv, const int proto,
192 void *proto_data);
193 WS_DLL_PUBLIC void *conversation_get_proto_data(const conversation_t *conv, const int proto);
194 WS_DLL_PUBLIC void conversation_delete_proto_data(conversation_t *conv, const int proto);
195
196 WS_DLL_PUBLIC void conversation_set_dissector(conversation_t *conversation,
197 const dissector_handle_t handle);
198
199 WS_DLL_PUBLIC void conversation_set_dissector_from_frame_number(conversation_t *conversation,
200 const guint32 starting_frame_num, const dissector_handle_t handle);
201
202 WS_DLL_PUBLIC dissector_handle_t conversation_get_dissector(conversation_t *conversation,
203 const guint32 frame_num);
204
205 WS_DLL_PUBLIC void conversation_create_endpoint(struct _packet_info *pinfo, address* addr1, address* addr2,
206 endpoint_type etype, guint32 port1, guint32 port2, const guint options);
207
208 WS_DLL_PUBLIC void conversation_create_endpoint_by_id(struct _packet_info *pinfo,
209 endpoint_type etype, guint32 id, const guint options);
210
211 WS_DLL_PUBLIC guint32 conversation_get_endpoint_by_id(struct _packet_info *pinfo,
212 endpoint_type etype, const guint options);
213
224 extern gboolean
225 try_conversation_dissector(const address *addr_a, const address *addr_b, const endpoint_type etype,
226 const guint32 port_a, const guint32 port_b, tvbuff_t *tvb, packet_info *pinfo,
227 proto_tree *tree, void* data, const guint options);
228
229 extern gboolean
230 try_conversation_dissector_by_id(const endpoint_type etype, const guint32 id, tvbuff_t *tvb,
231 packet_info *pinfo, proto_tree *tree, void* data);
232
233 /* These routines are used to set undefined values for a conversation */
234
235 extern void conversation_set_port2(conversation_t *conv, const guint32 port);
236 extern void conversation_set_addr2(conversation_t *conv, const address *addr);
237
238 WS_DLL_PUBLIC
239 wmem_map_t *get_conversation_hashtable_exact(void);
240
241 WS_DLL_PUBLIC
242 wmem_map_t *get_conversation_hashtable_no_addr2(void);
243
244 WS_DLL_PUBLIC
245 wmem_map_t * get_conversation_hashtable_no_port2(void);
246
247 WS_DLL_PUBLIC
248 wmem_map_t *get_conversation_hashtable_no_addr2_or_port2(void);
249
250 /* Temporary function to handle port_type to endpoint_type conversion
251 For now it's a 1-1 mapping, but the intention is to remove
252 many of the port_type instances in favor of endpoint_type
253 */
254 WS_DLL_PUBLIC
255 endpoint_type conversation_pt_to_endpoint_type(port_type pt);
256
257 WS_DLL_PUBLIC guint
258 conversation_hash_exact(gconstpointer v);
259
260 /* Provide a wmem_alloced (NULL scope) hash string using HTML tags */
261 WS_DLL_PUBLIC gchar*
262 conversation_get_html_hash(const conversation_key_t key);
263
264 #ifdef __cplusplus
265 }
266 #endif /* __cplusplus */
267
268 #endif /* conversation.h */
_wmem_tree_t
Definition: wmem_tree-int.h:47
conversation::data_list
wmem_tree_t * data_list
Definition: conversation.h:98
conversation::dissector_tree
wmem_tree_t * dissector_tree
Definition: conversation.h:99
conversation::setup_frame
guint32 setup_frame
Definition: conversation.h:95
_wmem_map_t
Definition: wmem_map.c:44
conversation::last
struct conversation * last
Definition: conversation.h:91
_packet_info
Definition: packet_info.h:44
try_conversation_dissector
gboolean try_conversation_dissector(const address *addr_a, const address *addr_b, const endpoint_type etype, const guint32 port_a, const guint32 port_b, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data, const guint options)
Definition: conversation.c:1264
tvbuff
Definition: tvbuff-int.h:35
conversation_epan_reset
void conversation_epan_reset(void)
Definition: conversation.c:477
dissector_handle
Definition: packet.c:659
conversation
Definition: conversation.h:89
conversation_init
void conversation_init(void)
Definition: conversation.c:449
find_or_create_conversation
WS_DLL_PUBLIC conversation_t * find_or_create_conversation(packet_info *pinfo)
Definition: conversation.c:1379
endpoint
Definition: conversation.c:27
conversation::options
guint options
Definition: conversation.h:101
conversation::conv_index
guint32 conv_index
Definition: conversation.h:94
conversation_key
Definition: conversation.c:36
conversation::last_frame
guint32 last_frame
Definition: conversation.h:97
find_conversation_pinfo
WS_DLL_PUBLIC conversation_t * find_conversation_pinfo(packet_info *pinfo, const guint options)
Definition: conversation.c:1336
_proto_node
Definition: proto.h:759
conversation::latest_found
struct conversation * latest_found
Definition: conversation.h:92
conversation::key_ptr
conversation_key_t key_ptr
Definition: conversation.h:102
_address
Definition: address.h:47
find_conversation
WS_DLL_PUBLIC conversation_t * find_conversation(const guint32 frame_num, const address *addr_a, const address *addr_b, const endpoint_type etype, const guint32 port_a, const guint32 port_b, const guint options)
Definition: conversation.c:848