| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
conversation_table.h
Go to the documentation of this file.
1/* conversation_table.h
2 * GUI independent helper routines common to all conversations taps.
3 * Refactored original conversations_table by Ronnie Sahlberg
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12#ifndef __CONVERSATION_TABLE_H__
13#define __CONVERSATION_TABLE_H__
14
15#include "tap.h"
16#include "conversation.h"
17#include <epan/wmem_scopes.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif /* __cplusplus */
22
40 typedef uint32_t conv_id_t;
41#define CONV_ID_UNSET UINT32_MAX
42
47typedef enum {
48 CONV_FT_SRC_ADDRESS,
49 CONV_FT_DST_ADDRESS,
50 CONV_FT_ANY_ADDRESS,
51 CONV_FT_SRC_PORT,
52 CONV_FT_DST_PORT,
53 CONV_FT_ANY_PORT
54} conv_filter_type_e;
55
56/* Filter direction */
57typedef enum {
58 CONV_DIR_A_TO_FROM_B,
59 CONV_DIR_A_TO_B,
60 CONV_DIR_A_FROM_B,
61 CONV_DIR_A_TO_FROM_ANY,
62 CONV_DIR_A_TO_ANY,
63 CONV_DIR_A_FROM_ANY,
64 CONV_DIR_ANY_TO_FROM_B,
65 CONV_DIR_ANY_TO_B,
66 CONV_DIR_ANY_FROM_B
67} conv_direction_e;
68
72 typedef struct _conversation_hash_t {
73 GHashTable *hashtable;
74 GArray *conv_array;
75 void *user_data;
76 unsigned flags;
77} conv_hash_t;
78
80 typedef struct _conversation_key_t {
81 address addr1;
82 address addr2;
83 uint32_t port1;
84 uint32_t port2;
85 conv_id_t conv_id;
86} conv_key_t;
87
88 typedef struct {
89 address myaddress;
90 uint32_t port;
91} endpoint_key_t;
92
93/*
94 * For backwards source compatibility.
95 * Yes, G_DEPRECATED_FOR() has to be at the beginning, so that this
96 * works with MSVC.
97 */
98G_DEPRECATED_FOR(endpoint_key_t)
99typedef endpoint_key_t host_key_t;
100
101struct _conversation_item_t;
102typedef const char* (*conv_get_filter_type)(struct _conversation_item_t* item, conv_filter_type_e filter);
103
104 typedef struct _ct_dissector_info {
105 conv_get_filter_type get_filter_type;
106} ct_dissector_info_t;
107
108struct _endpoint_item_t;
109typedef const char* (*endpoint_get_filter_type)(struct _endpoint_item_t* item, conv_filter_type_e filter_type);
110
111 typedef struct _et_dissector_info {
112 endpoint_get_filter_type get_filter_type;
113} et_dissector_info_t;
114
115/* For backwards source compatibiity */
116G_DEPRECATED_FOR(et_dissector_info_t)
117typedef et_dissector_info_t hostlist_dissector_info_t;
118
119#define CONV_FILTER_INVALID "INVALID"
120
121
122struct register_ct;
123typedef void (*conv_gui_init_cb)(struct register_ct* ct, const char *filter);
124
125typedef void (*endpoint_gui_init_cb)(struct register_ct* ct, const char *filter);
126
132 typedef struct register_ct register_ct_t;
133
135 typedef struct _conversation_extension_tcp_t {
136 uint64_t flows;
137} conv_extension_tcp_t;
138
140 typedef struct _conversation_item_t {
141 ct_dissector_info_t *dissector_info;
142 address src_address;
143 address dst_address;
144 conversation_type ctype;
145 uint32_t src_port;
146 uint32_t dst_port;
147 conv_id_t conv_id;
149 uint64_t rx_frames;
150 uint64_t tx_frames;
151 uint64_t rx_bytes;
152 uint64_t tx_bytes;
154 uint64_t rx_frames_total;
155 uint64_t tx_frames_total;
156 uint64_t rx_bytes_total;
157 uint64_t tx_bytes_total;
159 nstime_t start_time;
160 nstime_t stop_time;
161 nstime_t start_abs_time;
163 bool filtered;
165 conv_extension_tcp_t ext_tcp;
166} conv_item_t;
167
169 typedef struct _endpoint_item_t {
170 et_dissector_info_t *dissector_info;
171 address myaddress;
172 endpoint_type etype;
173 uint32_t port;
175 uint64_t rx_frames;
176 uint64_t tx_frames;
177 uint64_t rx_bytes;
178 uint64_t tx_bytes;
180 uint64_t rx_frames_total;
181 uint64_t tx_frames_total;
182 uint64_t rx_bytes_total;
183 uint64_t tx_bytes_total;
185 bool modified;
186 bool filtered;
188} endpoint_item_t;
189
190/* For backwards source compatibility */
191G_DEPRECATED_FOR(endpoint_item_t)
192typedef endpoint_item_t hostlist_talker_t;
193
194#define ENDPOINT_TAP_PREFIX "endpoints"
195
198extern void conversation_table_init(void);
199
207WS_DLL_PUBLIC void register_conversation_table(const int proto_id, bool hide_ports, tap_packet_cb conv_packet_func, tap_packet_cb endpoint_packet_func);
208
214WS_DLL_PUBLIC bool get_conversation_hide_ports(register_ct_t* ct);
215
221WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t* ct);
222
228WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t* ct);
229
235WS_DLL_PUBLIC tap_packet_cb get_endpoint_packet_func(register_ct_t* ct);
236
237/* For backwards source and binary compatibility */
238G_DEPRECATED_FOR(get_endpoint_packet_func)
239WS_DLL_PUBLIC tap_packet_cb get_hostlist_packet_func(register_ct_t* ct);
240
241
247WS_DLL_PUBLIC register_ct_t* get_conversation_by_proto_id(int proto_id);
248
255WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb);
256
263WS_DLL_PUBLIC void endpoint_table_set_gui_info(endpoint_gui_init_cb init_cb);
264
265/* For backwards source and binary compatibility */
266G_DEPRECATED_FOR(endpoint_table_set_gui_info)
267WS_DLL_PUBLIC void hostlist_table_set_gui_info(endpoint_gui_init_cb init_cb);
268
274WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void* user_data);
275
278WS_DLL_PUBLIC unsigned conversation_table_get_num(void);
279
284WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch);
285
290WS_DLL_PUBLIC void reset_endpoint_table_data(conv_hash_t *ch);
291
292/* For backwards source and binary compatibility */
293G_DEPRECATED_FOR(reset_endpoint_table_data)
294WS_DLL_PUBLIC void reset_hostlist_table_data(conv_hash_t *ch);
295
301WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void* userdata);
302
308WS_DLL_PUBLIC void dissector_endpoint_init(const char *opt_arg, void* userdata);
309
310/* For backwards source and binary compatibility */
311G_DEPRECATED_FOR(dissector_endpoint_init)
312WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata);
313
321WS_DLL_PUBLIC char *get_conversation_address(wmem_allocator_t *allocator, address *addr, bool resolve_names);
322
333WS_DLL_PUBLIC char *get_conversation_port(wmem_allocator_t *allocator, uint32_t port, conversation_type ctype, bool resolve_names);
334
345WS_DLL_PUBLIC char *get_endpoint_port(wmem_allocator_t *allocator, endpoint_item_t *item, bool resolve_names);
346
353WS_DLL_PUBLIC char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction);
354
361WS_DLL_PUBLIC char *get_endpoint_filter(endpoint_item_t *endpoint_item);
362
363/* For backwards source and binary compatibility */
364G_DEPRECATED_FOR(get_endpoint_filter)
365WS_DLL_PUBLIC char *get_hostlist_filter(endpoint_item_t *endpoint_item);
366
381WS_DLL_PUBLIC void add_conversation_table_data(conv_hash_t *ch, const address *src, const address *dst,
382 uint32_t src_port, uint32_t dst_port, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts,
383 ct_dissector_info_t *ct_info, conversation_type ctype);
384
402WS_DLL_PUBLIC conv_item_t *
403 add_conversation_table_data_with_conv_id(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port,
404 uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
405 nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
406 conversation_type ctype);
407
412WS_DLL_PUBLIC void
413 add_conversation_table_data_extended(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port,
414 uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
415 nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
416 conversation_type ctype, uint32_t frameid, int (*proto_conv_cb)(conversation_t *));
417
422WS_DLL_PUBLIC void
423 add_conversation_table_data_ipv4_subnet(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port,
424 uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
425 nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
426 conversation_type ctype);
427
439WS_DLL_PUBLIC void add_endpoint_table_data(conv_hash_t *ch, const address *addr,
440 uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
441
446WS_DLL_PUBLIC void add_endpoint_table_data_ipv4_subnet(conv_hash_t *ch, const address *addr,
447 uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
448
449/* For backwards source and binary compatibility */
450G_DEPRECATED_FOR(add_endpoint_table_data)
451WS_DLL_PUBLIC void add_hostlist_table_data(conv_hash_t *ch, const address *addr,
452 uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
453
454#ifdef __cplusplus
455}
456#endif /* __cplusplus */
457
458#endif /* __CONVERSATION_TABLE_H__ */
459
460/*
461 * Editor modelines
462 *
463 * Local Variables:
464 * c-basic-offset: 4
465 * tab-width: 8
466 * indent-tabs-mode: nil
467 * End:
468 *
469 * ex: set shiftwidth=4 tabstop=8 expandtab:
470 * :indentSize=4:tabSize=8:noTabs=true:
471 */
conversation.h
add_endpoint_table_data
WS_DLL_PUBLIC void add_endpoint_table_data(conv_hash_t *ch, const address *addr, uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype)
Definition conversation_table.c:951
get_endpoint_filter
WS_DLL_PUBLIC char * get_endpoint_filter(endpoint_item_t *endpoint_item)
Definition conversation_table.c:613
add_conversation_table_data_ipv4_subnet
WS_DLL_PUBLIC void add_conversation_table_data_ipv4_subnet(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port, uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info, conversation_type ctype)
Definition conversation_table.c:855
get_endpoint_port
WS_DLL_PUBLIC char * get_endpoint_port(wmem_allocator_t *allocator, endpoint_item_t *item, bool resolve_names)
Definition conversation_table.c:369
get_conversation_hide_ports
WS_DLL_PUBLIC bool get_conversation_hide_ports(register_ct_t *ct)
Definition conversation_table.c:33
add_conversation_table_data_with_conv_id
WS_DLL_PUBLIC conv_item_t * add_conversation_table_data_with_conv_id(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port, uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info, conversation_type ctype)
Definition conversation_table.c:669
conv_extension_tcp_t
struct _conversation_extension_tcp_t conv_extension_tcp_t
get_conversation_port
WS_DLL_PUBLIC char * get_conversation_port(wmem_allocator_t *allocator, uint32_t port, conversation_type ctype, bool resolve_names)
Definition conversation_table.c:350
get_conversation_by_proto_id
WS_DLL_PUBLIC register_ct_t * get_conversation_by_proto_id(int proto_id)
Definition conversation_table.c:133
get_conversation_proto_id
WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t *ct)
Definition conversation_table.c:38
dissector_endpoint_init
WS_DLL_PUBLIC void dissector_endpoint_init(const char *opt_arg, void *userdata)
Definition conversation_table.c:116
conv_item_t
struct _conversation_item_t conv_item_t
get_conversation_packet_func
WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t *ct)
Definition conversation_table.c:46
conversation_table_iterate_tables
WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void *user_data)
Definition conversation_table.c:217
conversation_table_get_num
WS_DLL_PUBLIC unsigned conversation_table_get_num(void)
Definition conversation_table.c:222
conversation_table_init
void conversation_table_init(void)
Definition conversation_table.c:138
conv_key_t
struct _conversation_key_t conv_key_t
get_endpoint_packet_func
WS_DLL_PUBLIC tap_packet_cb get_endpoint_packet_func(register_ct_t *ct)
Definition conversation_table.c:51
get_conversation_filter
WS_DLL_PUBLIC char * get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction)
Definition conversation_table.c:437
conv_id_t
uint32_t conv_id_t
Definition conversation_table.h:40
get_conversation_address
WS_DLL_PUBLIC char * get_conversation_address(wmem_allocator_t *allocator, address *addr, bool resolve_names)
Definition conversation_table.c:341
add_conversation_table_data
WS_DLL_PUBLIC void add_conversation_table_data(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port, uint32_t dst_port, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info, conversation_type ctype)
Definition conversation_table.c:662
reset_endpoint_table_data
WS_DLL_PUBLIC void reset_endpoint_table_data(conv_hash_t *ch)
Definition conversation_table.c:311
register_conversation_table
WS_DLL_PUBLIC void register_conversation_table(const int proto_id, bool hide_ports, tap_packet_cb conv_packet_func, tap_packet_cb endpoint_packet_func)
Definition conversation_table.c:144
endpoint_item_t
struct _endpoint_item_t endpoint_item_t
add_conversation_table_data_extended
WS_DLL_PUBLIC void add_conversation_table_data_extended(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port, uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info, conversation_type ctype, uint32_t frameid, int(*proto_conv_cb)(conversation_t *))
Definition conversation_table.c:813
endpoint_table_set_gui_info
WS_DLL_PUBLIC void endpoint_table_set_gui_info(endpoint_gui_init_cb init_cb)
Definition conversation_table.c:206
conversation_table_set_gui_info
WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb)
Definition conversation_table.c:182
add_endpoint_table_data_ipv4_subnet
WS_DLL_PUBLIC void add_endpoint_table_data_ipv4_subnet(conv_hash_t *ch, const address *addr, uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype)
Definition conversation_table.c:1036
conv_hash_t
struct _conversation_hash_t conv_hash_t
reset_conversation_table_data
WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch)
Definition conversation_table.c:286
dissector_conversation_init
WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void *userdata)
Definition conversation_table.c:86
wmem_foreach_func
bool(* wmem_foreach_func)(const void *key, void *value, void *userdata)
Function type for processing one node of a tree during a traversal.
Definition wmem_tree.h:389
_address
Definition address.h:58
_conversation_extension_tcp_t
Definition conversation_table.h:135
_conversation_extension_tcp_t::flows
uint64_t flows
Definition conversation_table.h:136
_conversation_hash_t
Definition conversation_table.h:72
_conversation_hash_t::conv_array
GArray * conv_array
Definition conversation_table.h:74
_conversation_hash_t::user_data
void * user_data
Definition conversation_table.h:75
_conversation_hash_t::hashtable
GHashTable * hashtable
Definition conversation_table.h:73
_conversation_hash_t::flags
unsigned flags
Definition conversation_table.h:76
_conversation_item_t
Definition conversation_table.h:140
_conversation_item_t::ctype
conversation_type ctype
Definition conversation_table.h:144
_conversation_item_t::start_time
nstime_t start_time
Definition conversation_table.h:159
_conversation_item_t::tx_bytes
uint64_t tx_bytes
Definition conversation_table.h:152
_conversation_item_t::conv_id
conv_id_t conv_id
Definition conversation_table.h:147
_conversation_item_t::src_address
address src_address
Definition conversation_table.h:142
_conversation_item_t::start_abs_time
nstime_t start_abs_time
Definition conversation_table.h:161
_conversation_item_t::tx_frames_total
uint64_t tx_frames_total
Definition conversation_table.h:155
_conversation_item_t::rx_frames_total
uint64_t rx_frames_total
Definition conversation_table.h:154
_conversation_item_t::filtered
bool filtered
Definition conversation_table.h:163
_conversation_item_t::rx_frames
uint64_t rx_frames
Definition conversation_table.h:149
_conversation_item_t::dissector_info
ct_dissector_info_t * dissector_info
Definition conversation_table.h:141
_conversation_item_t::tx_bytes_total
uint64_t tx_bytes_total
Definition conversation_table.h:157
_conversation_item_t::dst_address
address dst_address
Definition conversation_table.h:143
_conversation_item_t::dst_port
uint32_t dst_port
Definition conversation_table.h:146
_conversation_item_t::src_port
uint32_t src_port
Definition conversation_table.h:145
_conversation_item_t::rx_bytes
uint64_t rx_bytes
Definition conversation_table.h:151
_conversation_item_t::rx_bytes_total
uint64_t rx_bytes_total
Definition conversation_table.h:156
_conversation_item_t::tx_frames
uint64_t tx_frames
Definition conversation_table.h:150
_conversation_item_t::stop_time
nstime_t stop_time
Definition conversation_table.h:160
_conversation_item_t::ext_tcp
conv_extension_tcp_t ext_tcp
Definition conversation_table.h:165
_conversation_key_t
Definition conversation_table.h:80
_ct_dissector_info
Definition conversation_table.h:104
_endpoint_item_t
Definition conversation_table.h:169
_endpoint_item_t::rx_frames_total
uint64_t rx_frames_total
Definition conversation_table.h:180
_endpoint_item_t::modified
bool modified
Definition conversation_table.h:185
_endpoint_item_t::myaddress
address myaddress
Definition conversation_table.h:171
_endpoint_item_t::rx_frames
uint64_t rx_frames
Definition conversation_table.h:175
_endpoint_item_t::rx_bytes
uint64_t rx_bytes
Definition conversation_table.h:177
_endpoint_item_t::tx_bytes
uint64_t tx_bytes
Definition conversation_table.h:178
_endpoint_item_t::dissector_info
et_dissector_info_t * dissector_info
Definition conversation_table.h:170
_endpoint_item_t::etype
endpoint_type etype
Definition conversation_table.h:172
_endpoint_item_t::tx_bytes_total
uint64_t tx_bytes_total
Definition conversation_table.h:183
_endpoint_item_t::rx_bytes_total
uint64_t rx_bytes_total
Definition conversation_table.h:182
_endpoint_item_t::tx_frames
uint64_t tx_frames
Definition conversation_table.h:176
_endpoint_item_t::filtered
bool filtered
Definition conversation_table.h:186
_endpoint_item_t::tx_frames_total
uint64_t tx_frames_total
Definition conversation_table.h:181
_endpoint_item_t::port
uint32_t port
Definition conversation_table.h:173
_et_dissector_info
Definition conversation_table.h:111
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
conversation
Definition conversation.h:230
endpoint_key_t
Definition conversation_table.h:88
nstime_t
Definition nstime.h:26
register_ct
Definition conversation_table.c:24
tap.h
wmem_scopes.h