Wireshark  4.3.0
The Wireshark network protocol analyzer
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 "conv_id.h"
16 #include "tap.h"
17 #include "conversation.h"
18 #include <epan/wmem_scopes.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
23 
28 typedef enum {
29  CONV_FT_SRC_ADDRESS,
30  CONV_FT_DST_ADDRESS,
31  CONV_FT_ANY_ADDRESS,
32  CONV_FT_SRC_PORT,
33  CONV_FT_DST_PORT,
34  CONV_FT_ANY_PORT
35 } conv_filter_type_e;
36 
37 /* Filter direction */
38 typedef enum {
39  CONV_DIR_A_TO_FROM_B,
40  CONV_DIR_A_TO_B,
41  CONV_DIR_A_FROM_B,
42  CONV_DIR_A_TO_FROM_ANY,
43  CONV_DIR_A_TO_ANY,
44  CONV_DIR_A_FROM_ANY,
45  CONV_DIR_ANY_TO_FROM_B,
46  CONV_DIR_ANY_TO_B,
47  CONV_DIR_ANY_FROM_B
48 } conv_direction_e;
49 
53 typedef struct _conversation_hash_t {
54  GHashTable *hashtable;
55  GArray *conv_array;
56  void *user_data;
57  guint flags;
59 
61 typedef struct _conversation_key_t {
62  address addr1;
63  address addr2;
64  guint32 port1;
65  guint32 port2;
66  conv_id_t conv_id;
68 
69 typedef struct {
70  address myaddress;
71  guint32 port;
73 
74 /*
75  * For backwards source compatibiity.
76  * Yes, G_DEPRECATED_FOR() has to be at the beginning, so that this
77  * works with MSVC.
78  */
79 G_DEPRECATED_FOR(endpoint_key_t)
81 
83 typedef const char* (*conv_get_filter_type)(struct _conversation_item_t* item, conv_filter_type_e filter);
84 
85 typedef struct _ct_dissector_info {
86  conv_get_filter_type get_filter_type;
88 
89 struct _endpoint_item_t;
90 typedef const char* (*endpoint_get_filter_type)(struct _endpoint_item_t* item, conv_filter_type_e filter_type);
91 
92 typedef struct _et_dissector_info {
93  endpoint_get_filter_type get_filter_type;
95 
96 /* For backwards source compatibiity */
97 G_DEPRECATED_FOR(et_dissector_info_t)
99 
100 #define CONV_FILTER_INVALID "INVALID"
101 
102 
103 struct register_ct;
104 typedef void (*conv_gui_init_cb)(struct register_ct* ct, const char *filter);
105 
106 typedef void (*endpoint_gui_init_cb)(struct register_ct* ct, const char *filter);
107 
113 typedef struct register_ct register_ct_t;
114 
117  guint64 flows;
119 
121 typedef struct _conversation_item_t {
125  conversation_type ctype;
126  guint32 src_port;
127  guint32 dst_port;
130  guint64 rx_frames;
131  guint64 tx_frames;
132  guint64 rx_bytes;
133  guint64 tx_bytes;
135  guint64 rx_frames_total;
136  guint64 tx_frames_total;
137  guint64 rx_bytes_total;
138  guint64 tx_bytes_total;
144  gboolean filtered;
148 
150 typedef struct _endpoint_item_t {
153  endpoint_type etype;
154  guint32 port;
156  guint64 rx_frames;
157  guint64 tx_frames;
158  guint64 rx_bytes;
159  guint64 tx_bytes;
161  guint64 rx_frames_total;
162  guint64 tx_frames_total;
163  guint64 rx_bytes_total;
164  guint64 tx_bytes_total;
166  gboolean modified;
167  gboolean filtered;
170 
171 /* For backwards source compatibility */
172 G_DEPRECATED_FOR(endpoint_item_t)
174 
175 #define ENDPOINT_TAP_PREFIX "endpoints"
176 
184 WS_DLL_PUBLIC void register_conversation_table(const int proto_id, gboolean hide_ports, tap_packet_cb conv_packet_func, tap_packet_cb endpoint_packet_func);
185 
191 WS_DLL_PUBLIC gboolean get_conversation_hide_ports(register_ct_t* ct);
192 
198 WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t* ct);
199 
205 WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t* ct);
206 
212 WS_DLL_PUBLIC tap_packet_cb get_endpoint_packet_func(register_ct_t* ct);
213 
214 /* For backwards source and binary compatibility */
215 G_DEPRECATED_FOR(get_endpoint_packet_func)
216 WS_DLL_PUBLIC tap_packet_cb get_hostlist_packet_func(register_ct_t* ct);
217 
218 
224 WS_DLL_PUBLIC register_ct_t* get_conversation_by_proto_id(int proto_id);
225 
232 WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb);
233 
240 WS_DLL_PUBLIC void endpoint_table_set_gui_info(endpoint_gui_init_cb init_cb);
241 
242 /* For backwards source and binary compatibility */
243 G_DEPRECATED_FOR(endpoint_table_set_gui_info)
244 WS_DLL_PUBLIC void hostlist_table_set_gui_info(endpoint_gui_init_cb init_cb);
245 
251 WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void* user_data);
252 
255 WS_DLL_PUBLIC guint conversation_table_get_num(void);
256 
261 WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch);
262 
267 WS_DLL_PUBLIC void reset_endpoint_table_data(conv_hash_t *ch);
268 
269 /* For backwards source and binary compatibility */
270 G_DEPRECATED_FOR(reset_endpoint_table_data)
271 WS_DLL_PUBLIC void reset_hostlist_table_data(conv_hash_t *ch);
272 
278 WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void* userdata);
279 
285 WS_DLL_PUBLIC void dissector_endpoint_init(const char *opt_arg, void* userdata);
286 
287 /* For backwards source and binary compatibility */
288 G_DEPRECATED_FOR(dissector_endpoint_init)
289 WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata);
290 
298 WS_DLL_PUBLIC char *get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names);
299 
310 WS_DLL_PUBLIC char *get_conversation_port(wmem_allocator_t *allocator, guint32 port, conversation_type ctype, gboolean resolve_names);
311 
322 WS_DLL_PUBLIC char *get_endpoint_port(wmem_allocator_t *allocator, endpoint_item_t *item, gboolean resolve_names);
323 
330 WS_DLL_PUBLIC char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction);
331 
338 WS_DLL_PUBLIC char *get_endpoint_filter(endpoint_item_t *endpoint_item);
339 
340 /* For backwards source and binary compatibility */
341 G_DEPRECATED_FOR(get_endpoint_filter)
342 WS_DLL_PUBLIC char *get_hostlist_filter(endpoint_item_t *endpoint_item);
343 
358 WS_DLL_PUBLIC void add_conversation_table_data(conv_hash_t *ch, const address *src, const address *dst,
359  guint32 src_port, guint32 dst_port, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts,
360  ct_dissector_info_t *ct_info, conversation_type ctype);
361 
379 WS_DLL_PUBLIC conv_item_t *
380 add_conversation_table_data_with_conv_id(conv_hash_t *ch, const address *src, const address *dst, guint32 src_port,
381  guint32 dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
382  nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
383  conversation_type ctype);
384 
389 WS_DLL_PUBLIC void
390 add_conversation_table_data_extended(conv_hash_t *ch, const address *src, const address *dst, guint32 src_port,
391  guint32 dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
392  nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
393  conversation_type ctype, guint32 frameid, int (*proto_conv_cb)(conversation_t *));
394 
406 WS_DLL_PUBLIC void add_endpoint_table_data(conv_hash_t *ch, const address *addr,
407  guint32 port, gboolean sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
408 
409 /* For backwards source and binary compatibility */
410 G_DEPRECATED_FOR(add_endpoint_table_data)
411 WS_DLL_PUBLIC void add_hostlist_table_data(conv_hash_t *ch, const address *addr,
412  guint32 port, gboolean sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
413 
414 #ifdef __cplusplus
415 }
416 #endif /* __cplusplus */
417 
418 #endif /* __CONVERSATION_TABLE_H__ */
419 
420 /*
421  * Editor modelines
422  *
423  * Local Variables:
424  * c-basic-offset: 4
425  * tab-width: 8
426  * indent-tabs-mode: nil
427  * End:
428  *
429  * ex: set shiftwidth=4 tabstop=8 expandtab:
430  * :indentSize=4:tabSize=8:noTabs=true:
431  */
uint32_t conv_id_t
Definition: conv_id.h:34
WS_DLL_PUBLIC guint conversation_table_get_num(void)
Definition: conversation_table.c:204
WS_DLL_PUBLIC conv_item_t * add_conversation_table_data_with_conv_id(conv_hash_t *ch, const address *src, const address *dst, guint32 src_port, guint32 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:633
WS_DLL_PUBLIC register_ct_t * get_conversation_by_proto_id(int proto_id)
Definition: conversation_table.c:117
struct _conversation_extension_tcp_t conv_extension_tcp_t
WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t *ct)
Definition: conversation_table.c:38
WS_DLL_PUBLIC void add_conversation_table_data_extended(conv_hash_t *ch, const address *src, const address *dst, guint32 src_port, guint32 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, guint32 frameid, int(*proto_conv_cb)(conversation_t *))
Definition: conversation_table.c:777
WS_DLL_PUBLIC char * get_endpoint_port(wmem_allocator_t *allocator, endpoint_item_t *item, gboolean resolve_names)
Definition: conversation_table.c:351
WS_DLL_PUBLIC char * get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names)
Definition: conversation_table.c:323
WS_DLL_PUBLIC gboolean get_conversation_hide_ports(register_ct_t *ct)
Definition: conversation_table.c:33
WS_DLL_PUBLIC void register_conversation_table(const int proto_id, gboolean hide_ports, tap_packet_cb conv_packet_func, tap_packet_cb endpoint_packet_func)
Definition: conversation_table.c:123
WS_DLL_PUBLIC void dissector_endpoint_init(const char *opt_arg, void *userdata)
Definition: conversation_table.c:84
struct _conversation_item_t conv_item_t
WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t *ct)
Definition: conversation_table.c:46
WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void *user_data)
Definition: conversation_table.c:199
WS_DLL_PUBLIC char * get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction)
Definition: conversation_table.c:419
struct _conversation_key_t conv_key_t
WS_DLL_PUBLIC void add_conversation_table_data(conv_hash_t *ch, const address *src, const address *dst, guint32 src_port, guint32 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:626
WS_DLL_PUBLIC tap_packet_cb get_endpoint_packet_func(register_ct_t *ct)
Definition: conversation_table.c:51
WS_DLL_PUBLIC void reset_endpoint_table_data(conv_hash_t *ch)
Definition: conversation_table.c:293
struct _endpoint_item_t endpoint_item_t
WS_DLL_PUBLIC char * get_endpoint_filter(endpoint_item_t *endpoint_item)
Definition: conversation_table.c:577
WS_DLL_PUBLIC void add_endpoint_table_data(conv_hash_t *ch, const address *addr, guint32 port, gboolean sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype)
Definition: conversation_table.c:854
WS_DLL_PUBLIC void endpoint_table_set_gui_info(endpoint_gui_init_cb init_cb)
Definition: conversation_table.c:188
WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb)
Definition: conversation_table.c:164
struct _conversation_hash_t conv_hash_t
WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch)
Definition: conversation_table.c:268
WS_DLL_PUBLIC char * get_conversation_port(wmem_allocator_t *allocator, guint32 port, conversation_type ctype, gboolean resolve_names)
Definition: conversation_table.c:332
WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void *userdata)
Definition: conversation_table.c:65
bool(* wmem_foreach_func)(const void *key, void *value, void *userdata)
Definition: wmem_tree.h:220
Definition: address.h:56
Definition: conversation_table.h:116
guint64 flows
Definition: conversation_table.h:117
Definition: conversation_table.h:53
guint flags
Definition: conversation_table.h:57
GArray * conv_array
Definition: conversation_table.h:55
void * user_data
Definition: conversation_table.h:56
GHashTable * hashtable
Definition: conversation_table.h:54
Definition: conversation_table.h:121
conversation_type ctype
Definition: conversation_table.h:125
nstime_t start_time
Definition: conversation_table.h:140
guint32 dst_port
Definition: conversation_table.h:127
conv_id_t conv_id
Definition: conversation_table.h:128
address src_address
Definition: conversation_table.h:123
nstime_t start_abs_time
Definition: conversation_table.h:142
guint64 tx_bytes
Definition: conversation_table.h:133
ct_dissector_info_t * dissector_info
Definition: conversation_table.h:122
guint64 tx_bytes_total
Definition: conversation_table.h:138
address dst_address
Definition: conversation_table.h:124
guint64 rx_bytes_total
Definition: conversation_table.h:137
gboolean filtered
Definition: conversation_table.h:144
guint64 tx_frames_total
Definition: conversation_table.h:136
guint64 rx_frames_total
Definition: conversation_table.h:135
guint64 rx_frames
Definition: conversation_table.h:130
guint64 tx_frames
Definition: conversation_table.h:131
guint32 src_port
Definition: conversation_table.h:126
guint64 rx_bytes
Definition: conversation_table.h:132
nstime_t stop_time
Definition: conversation_table.h:141
conv_extension_tcp_t ext_tcp
Definition: conversation_table.h:146
Definition: conversation_table.h:61
Definition: conversation_table.h:85
Definition: conversation_table.h:150
address myaddress
Definition: conversation_table.h:152
gboolean modified
Definition: conversation_table.h:166
gboolean filtered
Definition: conversation_table.h:167
guint64 rx_frames_total
Definition: conversation_table.h:161
et_dissector_info_t * dissector_info
Definition: conversation_table.h:151
guint64 rx_bytes_total
Definition: conversation_table.h:163
guint64 rx_frames
Definition: conversation_table.h:156
endpoint_type etype
Definition: conversation_table.h:153
guint64 tx_frames
Definition: conversation_table.h:157
guint32 port
Definition: conversation_table.h:154
guint64 tx_bytes
Definition: conversation_table.h:159
guint64 tx_bytes_total
Definition: conversation_table.h:164
guint64 tx_frames_total
Definition: conversation_table.h:162
guint64 rx_bytes
Definition: conversation_table.h:158
Definition: conversation_table.h:92
Definition: wmem_allocator.h:27
Definition: conversation.h:220
Definition: conversation_table.h:69
Definition: nstime.h:26
Definition: conversation_table.c:24