Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
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 <[email protected]>
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#include <epan/packet.h> /* for conversation dissector type */
17#include <epan/wmem_scopes.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif /* __cplusplus */
22
41#define NO_ADDR2 0x01
42#define NO_PORT2 0x02
43#define NO_PORT2_FORCE 0x04
44#define CONVERSATION_TEMPLATE 0x08
45#define NO_PORTS 0x010
46
51#define NO_MASK_B 0xFFFF0000
52#define NO_ADDR_B 0x00010000
53#define NO_PORT_B 0x00020000
54#define NO_PORT_X 0x00040000
55#define NO_GREEDY 0x00100000
56#define EXACT_EXCLUDED 0x00200000
57
59#define USE_LAST_ENDPOINT 0x08
61/* Types of conversations Wireshark knows about. */
62/* XXX: There should be a way to register conversation types used only
63 * within one dissector, similar to address types, instead of changing
64 * the global typedef.
65 */
66typedef enum {
67 CONVERSATION_NONE, /* no conversation key */
68 CONVERSATION_SCTP, /* SCTP */
69 CONVERSATION_TCP, /* TCP address/port pairs */
70 CONVERSATION_UDP, /* UDP address/port pairs */
71 CONVERSATION_DCCP, /* DCCP */
72 CONVERSATION_IPX, /* IPX sockets */
73 CONVERSATION_NCP, /* NCP connection */
74 CONVERSATION_EXCHG, /* Fibre Channel exchange */
75 CONVERSATION_DDP, /* DDP AppleTalk address/port pair */
76 CONVERSATION_SBCCS, /* FICON */
77 CONVERSATION_IDP, /* XNS IDP sockets */
78 CONVERSATION_TIPC, /* TIPC PORT */
79 CONVERSATION_USB, /* USB endpoint 0xffff means the host */
80 CONVERSATION_I2C,
81 CONVERSATION_IBQP, /* Infiniband QP number */
82 CONVERSATION_BLUETOOTH,
83 CONVERSATION_TDMOP,
84 CONVERSATION_DVBCI,
85 CONVERSATION_ISO14443,
86 CONVERSATION_ISDN, /* ISDN channel number */
87 CONVERSATION_H223, /* H.223 logical channel number */
88 CONVERSATION_X25, /* X.25 logical channel number */
89 CONVERSATION_IAX2, /* IAX2 call id */
90 CONVERSATION_DLCI, /* Frame Relay DLCI */
91 CONVERSATION_ISUP, /* ISDN User Part CIC */
92 CONVERSATION_BICC, /* BICC Circuit identifier */
93 CONVERSATION_GSMTAP,
94 CONVERSATION_IUUP,
95 CONVERSATION_DVBBBF, /* DVB Base Band Frame ISI/PLP_ID */
96 CONVERSATION_IWARP_MPA, /* iWarp MPA */
97 CONVERSATION_BT_UTP, /* BitTorrent uTP Connection ID */
98 CONVERSATION_LOG, /* Logging source */
99 CONVERSATION_LTP, /* LTP Engine ID and Session Number */
100 CONVERSATION_MCTP,
101 CONVERSATION_NVME_MI, /* NVMe management interface */
102 CONVERSATION_BP, /* Bundle Protocol endpoint IDs */
103 CONVERSATION_SNMP, /* SNMP */
104 CONVERSATION_QUIC, /* QUIC */
105 CONVERSATION_IDN,
106 CONVERSATION_IP, /* IP */
107 CONVERSATION_IPV6, /* IPv6 */
108 CONVERSATION_ETH, /* ETHERNET classic */
109 CONVERSATION_ETH_NN, /* ETHERNET deinterlaced Interface:N VLAN:N */
110 CONVERSATION_ETH_NV, /* ETHERNET deinterlaced Interface:N VLAN:Y */
111 CONVERSATION_ETH_IN, /* ETHERNET deinterlaced Interface:Y VLAN:N */
112 CONVERSATION_ETH_IV, /* ETHERNET deinterlaced Interface:Y VLAN:Y */
113 CONVERSATION_VSPC_VMOTION, /* VMware vSPC vMotion (Telnet) */
114 CONVERSATION_OPENVPN,
115 CONVERSATION_PROXY,
116 CONVERSATION_GNSS,
117 CONVERSATION_DNP3,
118 CONVERSATION_ILNP, /* ILNP */
119} conversation_type;
120
121/*
122 * XXX - for now, we just #define these to be the same as the
123 * corresponding CONVERSATION_ values, for backwards source
124 * compatibility.
125 *
126 * In the long term, we should make this into a separate enum,
127 * with elements corresponding to conversation types that do
128 * not have known endpoints removed.
129 */
130/* Types of conversation endpoints Wireshark knows about. */
131#define ENDPOINT_NONE CONVERSATION_NONE
132#define ENDPOINT_SCTP CONVERSATION_SCTP
133#define ENDPOINT_TCP CONVERSATION_TCP
134#define ENDPOINT_UDP CONVERSATION_UDP
135#define ENDPOINT_DCCP CONVERSATION_DCCP
136#define ENDPOINT_IPX CONVERSATION_IPX
137#define ENDPOINT_NCP CONVERSATION_NCP
138#define ENDPOINT_EXCHG CONVERSATION_EXCHG
139#define ENDPOINT_DDP CONVERSATION_DDP
140#define ENDPOINT_SBCCS CONVERSATION_SBCCS
141#define ENDPOINT_IDP CONVERSATION_IDP
142#define ENDPOINT_TIPC CONVERSATION_TIPC
143#define ENDPOINT_USB CONVERSATION_USB
144#define ENDPOINT_I2C CONVERSATION_I2C
145#define ENDPOINT_IBQP CONVERSATION_IBQP
146#define ENDPOINT_BLUETOOTH CONVERSATION_BLUETOOTH
147#define ENDPOINT_TDMOP CONVERSATION_TDMOP
148#define ENDPOINT_DVBCI CONVERSATION_DVBCI
149#define ENDPOINT_ISO14443 CONVERSATION_ISO14443
150#define ENDPOINT_ISDN CONVERSATION_ISDN
151#define ENDPOINT_H223 CONVERSATION_H223
152#define ENDPOINT_X25 CONVERSATION_X25
153#define ENDPOINT_IAX2 CONVERSATION_IAX2
154#define ENDPOINT_DLCI CONVERSATION_DLCI
155#define ENDPOINT_ISUP CONVERSATION_ISUP
156#define ENDPOINT_BICC CONVERSATION_BICC
157#define ENDPOINT_GSMTAP CONVERSATION_GSMTAP
158#define ENDPOINT_IUUP CONVERSATION_IUUP
159#define ENDPOINT_DVBBBF CONVERSATION_DVBBBF
160#define ENDPOINT_IWARP_MPA CONVERSATION_IWARP_MPA
161#define ENDPOINT_BT_UTP CONVERSATION_BT_UTP
162#define ENDPOINT_LOG CONVERSATION_LOG
163#define ENDPOINT_MCTP CONVERSATION_MCTP
164#define ENDPOINT_NVME_MI CONVERSATION_NVME_MI
165#define ENDPOINT_SNMP CONVERSATION_SNMP
166#define ENDPOINT_IP CONVERSATION_IP
167#define ENDPOINT_IPv6 CONVERSATION_IPv6
168#define ENDPOINT_ETH CONVERSATION_ETH
169#define ENDPOINT_ILNP CONVERSATION_ILNP
170
171typedef conversation_type endpoint_type;
172
176typedef enum {
177 CE_CONVERSATION_TYPE, /* CONVERSATION_ value */
178 CE_ADDRESS, /* address */
179 CE_PORT, /* unsigned integer representing a port */
180 CE_STRING, /* string */
181 CE_UINT, /* unsigned integer not representing a port */
182 CE_UINT64, /* 64-bit unsigned integer */
183 CE_INT, /* signed integer */
184 CE_INT64, /* signed integer */
185 CE_BLOB, /* arbitrary binary data */
187
209typedef struct conversation_element {
211 union {
212 conversation_type conversation_type_val;
214 unsigned int port_val;
215 const char *str_val;
216 unsigned int uint_val;
217 uint64_t uint64_val;
219 int64_t int64_val;
220 struct {
221 const uint8_t *val;
222 size_t len;
224 };
226
230typedef struct conversation {
231 struct conversation *next;
234 uint32_t conv_index;
235 uint32_t setup_frame;
236 /* Assume that setup_frame is also the lowest frame number for now. */
237 uint32_t last_frame;
240 unsigned options;
243
244/*
245 * For some protocols, we store, in the packet_info structure, a pair
246 * of address/port endpoints, for use by code that might want to
247 * construct a conversation for that protocol.
248 *
249 * This appears to have been done in order to allow protocols to save
250 * that information *without* overwriting the addresses or ports in the
251 * packet_info structure, so that the other code that uses those values,
252 * such as the code that fills in the address and port columns in the
253 * packet summary, will pick up the values put there by protocols such
254 * as IP and UDP, rather than the values put there by protocols such as
255 * TDMoP, FCIP, TIPC, and DVB Dynamic Mode Adaptation. See commit
256 * 66b441f3d63e21949530d672bf1406dea94ed254 and issue #11340.
257 *
258 * That is set by conversation_set_conv_addr_port_endpoints().
259 *
260 * In find_conversation_pinfo() and find_or_create_conversation(), if
261 * any dissector has set this, that address/port endpoint pair is used
262 * to look up or create the conversation.
263 *
264 * Prior to 4.0, conversations identified by a single integer value
265 * (such as a circuit ID) were handled by creating a pair of address/port
266 * endpoints with null addresses, the first port equal to the integer
267 * value, the second port missing, and a port type being an ENDPOINT_
268 * type specifying the protocol for the conversation. Now we use an
269 * array of elements, with a CE_UINT value for the integer followed
270 * by a CE_CONVERSATION_TYPE value specifying the protocol for the
271 * conversation.
272 *
273 * XXX - is there any reason why we shouldn't use an array of conversation
274 * elements, with the appropriate addresses and ports, instead of this
275 * structure? It would at least simplify find_conversation_pinfo() and
276 * find_or_create_conversation().
277 */
280
281WS_DLL_PUBLIC const address* conversation_key_addr1(const conversation_element_t *key);
282WS_DLL_PUBLIC uint32_t conversation_key_port1(const conversation_element_t *key);
283WS_DLL_PUBLIC const address* conversation_key_addr2(const conversation_element_t *key);
284WS_DLL_PUBLIC uint32_t conversation_key_port2(const conversation_element_t *key);
285
289extern void conversation_init(void);
290
294extern void conversation_epan_reset(void);
295
302WS_DLL_PUBLIC WS_RETNONNULL conversation_t *conversation_new_full(const uint32_t setup_frame, conversation_element_t *elements);
303
323WS_DLL_PUBLIC WS_RETNONNULL conversation_t *conversation_new(const uint32_t setup_frame, const address *addr1, const address *addr2,
324 const conversation_type ctype, const uint32_t port1, const uint32_t port2, const unsigned options);
325
326WS_DLL_PUBLIC WS_RETNONNULL conversation_t *conversation_new_by_id(const uint32_t setup_frame, const conversation_type ctype, const uint32_t id);
327
337WS_DLL_PUBLIC WS_RETNONNULL conversation_t *conversation_new_err_pkts(const uint32_t setup_frame, const conversation_type ctype, const uint32_t id, const uint32_t rid);
338
345WS_DLL_PUBLIC bool is_deinterlacing_supported(const packet_info *pinfo);
346
350WS_DLL_PUBLIC WS_RETNONNULL conversation_t *conversation_new_deinterlaced(const uint32_t setup_frame, const address *addr1, const address *addr2,
351 const conversation_type ctype, const uint32_t port1, const uint32_t port2, const uint32_t anchor, const unsigned options);
352
366WS_DLL_PUBLIC WS_RETNONNULL conversation_t *conversation_new_deinterlacer(const uint32_t setup_frame, const address *addr1, const address *addr2,
367 const conversation_type ctype, const uint32_t key1, const uint32_t key2, const uint32_t key3);
368
379WS_DLL_PUBLIC WS_RETNONNULL conversation_t *conversation_new_strat(const packet_info *pinfo, const conversation_type ctype, const unsigned options);
380
381WS_DLL_PUBLIC WS_RETNONNULL conversation_t *conversation_new_strat_xtd(const packet_info *pinfo, const uint32_t setup_frame, const address *addr1, const address *addr2,
382 const conversation_type ctype, const uint32_t port1, const uint32_t port2, const unsigned options);
383
390WS_DLL_PUBLIC conversation_t *find_conversation_full(const uint32_t frame_num, conversation_element_t *elements);
391
439WS_DLL_PUBLIC conversation_t *find_conversation(const uint32_t frame_num, const address *addr_a, const address *addr_b,
440 const conversation_type ctype, const uint32_t port_a, const uint32_t port_b, const unsigned options);
441
442WS_DLL_PUBLIC conversation_t *find_conversation_deinterlaced(const uint32_t frame_num, const address *addr_a, const address *addr_b,
443 const conversation_type ctype, const uint32_t port_a, const uint32_t port_b, const uint32_t anchor, const unsigned options);
444
445WS_DLL_PUBLIC conversation_t *find_conversation_deinterlacer(const uint32_t frame_num, const address *addr_a, const address *addr_b,
446 const conversation_type ctype, const uint32_t key_a, const uint32_t key_b, const uint32_t key_c);
447
454
455WS_DLL_PUBLIC conversation_t *find_conversation_by_id(const uint32_t frame, const conversation_type ctype, const uint32_t id);
456
457WS_DLL_PUBLIC conversation_t *find_conversation_err_pkts(const uint32_t frame, const conversation_type ctype, const uint32_t id, const uint32_t rid);
458
463WS_DLL_PUBLIC conversation_t *find_conversation_strat(const packet_info *pinfo, const conversation_type ctype, const unsigned options, const bool direction);
464WS_DLL_PUBLIC conversation_t *find_conversation_strat_xtd(const packet_info *pinfo, const uint32_t setup_frame, const address *addr1, const address *addr2,
465 const conversation_type ctype, const uint32_t port1, const uint32_t port2, const unsigned options);
466
467
471WS_DLL_PUBLIC conversation_t *find_conversation_pinfo(const packet_info *pinfo, const unsigned options);
472
473WS_DLL_PUBLIC conversation_t *find_conversation_pinfo_strat(const packet_info *pinfo, const unsigned options);
474
481WS_DLL_PUBLIC conversation_t *find_conversation_pinfo_ro(const packet_info *pinfo, const unsigned options);
482
493WS_DLL_PUBLIC WS_RETNONNULL conversation_t *find_or_create_conversation(const packet_info *pinfo);
494WS_DLL_PUBLIC WS_RETNONNULL conversation_t *find_or_create_conversation_strat(const packet_info *pinfo);
495
500WS_DLL_PUBLIC WS_RETNONNULL conversation_t *find_or_create_conversation_by_id(packet_info *pinfo, const conversation_type ctype, const uint32_t id);
501
507WS_DLL_PUBLIC void conversation_add_proto_data(conversation_t *conv, const int proto, void *proto_data);
508
514WS_DLL_PUBLIC void *conversation_get_proto_data(const conversation_t *conv, const int proto);
515
520WS_DLL_PUBLIC void conversation_delete_proto_data(conversation_t *conv, const int proto);
521
522WS_DLL_PUBLIC void conversation_set_dissector(conversation_t *conversation, const dissector_handle_t handle);
523
524WS_DLL_PUBLIC void conversation_set_dissector_from_frame_number(conversation_t *conversation,
525 const uint32_t starting_frame_num, const dissector_handle_t handle);
526
527WS_DLL_PUBLIC dissector_handle_t conversation_get_dissector(conversation_t *conversation, const uint32_t frame_num);
528
540WS_DLL_PUBLIC void conversation_set_conv_addr_port_endpoints(struct _packet_info *pinfo, address* addr1, address* addr2,
541 conversation_type ctype, uint32_t port1, uint32_t port2);
542
551WS_DLL_PUBLIC void conversation_set_elements_by_id(struct _packet_info *pinfo,
552 conversation_type ctype, uint32_t id);
553
562WS_DLL_PUBLIC uint32_t conversation_get_id_from_elements(struct _packet_info *pinfo,
563 conversation_type ctype, const unsigned options);
564
575WS_DLL_PUBLIC bool try_conversation_dissector(const address *addr_a, const address *addr_b, const conversation_type ctype,
576 const uint32_t port_a, const uint32_t port_b, tvbuff_t *tvb, packet_info *pinfo,
577 proto_tree *tree, void* data, const unsigned options);
578
579WS_DLL_PUBLIC bool try_conversation_dissector_strat(packet_info *pinfo, const conversation_type ctype,
580 tvbuff_t *tvb, proto_tree *tree, void* data, const unsigned options);
581
582WS_DLL_PUBLIC bool try_conversation_dissector_by_id(const conversation_type ctype, const uint32_t id, tvbuff_t *tvb,
583 packet_info *pinfo, proto_tree *tree, void* data);
584
585/* These routines are used to set undefined values for a conversation */
586
592WS_DLL_PUBLIC void conversation_set_port2(conversation_t *conv, const uint32_t port);
593
599WS_DLL_PUBLIC void conversation_set_addr2(conversation_t *conv, const address *addr);
600
607WS_DLL_PUBLIC wmem_map_t *get_conversation_hashtables(void);
608
609/* Temporary function to handle port_type to conversation_type conversion
610 For now it's a 1-1 mapping, but the intention is to remove
611 many of the port_type instances in favor of conversation_type
612 */
613WS_DLL_PUBLIC conversation_type conversation_pt_to_conversation_type(port_type pt);
614
615/* Temporary function to handle port_type to endpoint_type conversion
616 For now it's a 1-1 mapping, but the intention is to remove
617 many of the port_type instances in favor of endpoint_type
618 */
619WS_DLL_PUBLIC endpoint_type conversation_pt_to_endpoint_type(port_type pt);
620
621#ifdef __cplusplus
622}
623#endif /* __cplusplus */
624
625#endif /* conversation.h */
WS_DLL_PUBLIC bool try_conversation_dissector(const address *addr_a, const address *addr_b, const conversation_type ctype, const uint32_t port_a, const uint32_t port_b, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data, const unsigned options)
Definition conversation.c:2823
WS_DLL_PUBLIC conversation_t * find_conversation_full(const uint32_t frame_num, conversation_element_t *elements)
Definition conversation.c:1594
void conversation_epan_reset(void)
Definition conversation.c:784
WS_DLL_PUBLIC void * conversation_get_proto_data(const conversation_t *conv, const int proto)
Definition conversation.c:2741
struct conversation conversation_t
WS_DLL_PUBLIC conversation_t * find_conversation_deinterlacer_pinfo(const packet_info *pinfo)
Definition conversation.c:2652
WS_DLL_PUBLIC void conversation_set_addr2(conversation_t *conv, const address *addr)
Definition conversation.c:1520
WS_DLL_PUBLIC WS_RETNONNULL conversation_t * find_or_create_conversation_by_id(packet_info *pinfo, const conversation_type ctype, const uint32_t id)
Definition conversation.c:3296
WS_DLL_PUBLIC void conversation_set_conv_addr_port_endpoints(struct _packet_info *pinfo, address *addr1, address *addr2, conversation_type ctype, uint32_t port1, uint32_t port2)
Definition conversation.c:3314
WS_DLL_PUBLIC WS_RETNONNULL conversation_t * find_or_create_conversation(const packet_info *pinfo)
Definition conversation.c:3224
WS_DLL_PUBLIC void conversation_set_elements_by_id(struct _packet_info *pinfo, conversation_type ctype, uint32_t id)
Definition conversation.c:3334
WS_DLL_PUBLIC WS_RETNONNULL conversation_t * conversation_new_full(const uint32_t setup_frame, conversation_element_t *elements)
Definition conversation.c:911
WS_DLL_PUBLIC void conversation_delete_proto_data(conversation_t *conv, const int proto)
Definition conversation.c:2755
struct conversation_element conversation_element_t
WS_DLL_PUBLIC WS_RETNONNULL conversation_t * conversation_new_strat(const packet_info *pinfo, const conversation_type ctype, const unsigned options)
Definition conversation.c:1145
WS_DLL_PUBLIC WS_RETNONNULL conversation_t * conversation_new_deinterlacer(const uint32_t setup_frame, const address *addr1, const address *addr2, const conversation_type ctype, const uint32_t key1, const uint32_t key2, const uint32_t key3)
Definition conversation.c:1232
WS_DLL_PUBLIC conversation_t * find_conversation_pinfo(const packet_info *pinfo, const unsigned options)
Definition conversation.c:3004
WS_DLL_PUBLIC conversation_t * find_conversation_pinfo_ro(const packet_info *pinfo, const unsigned options)
Definition conversation.c:3130
WS_DLL_PUBLIC uint32_t conversation_get_id_from_elements(struct _packet_info *pinfo, conversation_type ctype, const unsigned options)
Get the ID value from the conversation elements in the packet info.
Definition conversation.c:3344
WS_DLL_PUBLIC conversation_t * find_conversation(const uint32_t frame_num, const address *addr_a, const address *addr_b, const conversation_type ctype, const uint32_t port_a, const uint32_t port_b, const unsigned options)
Definition conversation.c:1840
WS_DLL_PUBLIC void conversation_set_port2(conversation_t *conv, const uint32_t port)
Definition conversation.c:1476
WS_DLL_PUBLIC bool is_deinterlacing_supported(const packet_info *pinfo)
Definition conversation.c:3095
void conversation_init(void)
Definition conversation.c:572
conversation_element_type
Definition conversation.h:176
WS_DLL_PUBLIC wmem_map_t * get_conversation_hashtables(void)
Get a hash table of conversation hash table.
Definition conversation.c:3362
WS_DLL_PUBLIC conversation_t * find_conversation_strat(const packet_info *pinfo, const conversation_type ctype, const unsigned options, const bool direction)
Definition conversation.c:2957
WS_DLL_PUBLIC void conversation_add_proto_data(conversation_t *conv, const int proto, void *proto_data)
Definition conversation.c:2728
WS_DLL_PUBLIC WS_RETNONNULL conversation_t * conversation_new(const uint32_t setup_frame, const address *addr1, const address *addr2, const conversation_type ctype, const uint32_t port1, const uint32_t port2, const unsigned options)
Definition conversation.c:955
WS_DLL_PUBLIC WS_RETNONNULL conversation_t * conversation_new_err_pkts(const uint32_t setup_frame, const conversation_type ctype, const uint32_t id, const uint32_t rid)
Definition conversation.c:1210
Definition address.h:58
Definition packet_info.h:43
Definition proto.h:907
Definition wmem_map.c:60
Internal representation of a wmem balanced tree.
Definition wmem_tree-int.h:81
Definition conversation.c:49
Definition conversation.h:209
const char * str_val
Definition conversation.h:215
conversation_type conversation_type_val
Definition conversation.h:212
const uint8_t * val
Definition conversation.h:221
unsigned int uint_val
Definition conversation.h:216
size_t len
Definition conversation.h:222
struct conversation_element::@23::@25 blob
conversation_element_type type
Definition conversation.h:210
uint64_t uint64_val
Definition conversation.h:217
address addr_val
Definition conversation.h:213
int int_val
Definition conversation.h:218
unsigned int port_val
Definition conversation.h:214
int64_t int64_val
Definition conversation.h:219
Definition conversation.h:230
wmem_tree_t * dissector_tree
Definition conversation.h:239
struct conversation * last
Definition conversation.h:232
struct conversation * latest_found
Definition conversation.h:233
uint32_t setup_frame
Definition conversation.h:235
unsigned options
Definition conversation.h:240
wmem_tree_t * data_list
Definition conversation.h:238
uint32_t last_frame
Definition conversation.h:237
uint32_t conv_index
Definition conversation.h:234
conversation_element_t * key_ptr
Definition conversation.h:241
Definition packet.c:848
Definition tvbuff-int.h:35