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 
116 typedef struct _conversation_item_t {
120  conversation_type ctype;
121  guint32 src_port;
122  guint32 dst_port;
125  guint64 rx_frames;
126  guint64 tx_frames;
127  guint64 rx_bytes;
128  guint64 tx_bytes;
130  guint64 rx_frames_total;
131  guint64 tx_frames_total;
132  guint64 rx_bytes_total;
133  guint64 tx_bytes_total;
139  gboolean filtered;
141 
143 typedef struct _endpoint_item_t {
146  endpoint_type etype;
147  guint32 port;
149  guint64 rx_frames;
150  guint64 tx_frames;
151  guint64 rx_bytes;
152  guint64 tx_bytes;
154  guint64 rx_frames_total;
155  guint64 tx_frames_total;
156  guint64 rx_bytes_total;
157  guint64 tx_bytes_total;
159  gboolean modified;
160  gboolean filtered;
163 
164 /* For backwards source compatibility */
165 G_DEPRECATED_FOR(endpoint_item_t)
167 
168 #define ENDPOINT_TAP_PREFIX "endpoints"
169 
177 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);
178 
184 WS_DLL_PUBLIC gboolean get_conversation_hide_ports(register_ct_t* ct);
185 
191 WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t* ct);
192 
198 WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t* ct);
199 
205 WS_DLL_PUBLIC tap_packet_cb get_endpoint_packet_func(register_ct_t* ct);
206 
207 /* For backwards source and binary compatibility */
208 G_DEPRECATED_FOR(get_endpoint_packet_func)
209 WS_DLL_PUBLIC tap_packet_cb get_hostlist_packet_func(register_ct_t* ct);
210 
211 
217 WS_DLL_PUBLIC register_ct_t* get_conversation_by_proto_id(int proto_id);
218 
225 WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb);
226 
233 WS_DLL_PUBLIC void endpoint_table_set_gui_info(endpoint_gui_init_cb init_cb);
234 
235 /* For backwards source and binary compatibility */
236 G_DEPRECATED_FOR(endpoint_table_set_gui_info)
237 WS_DLL_PUBLIC void hostlist_table_set_gui_info(endpoint_gui_init_cb init_cb);
238 
244 WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void* user_data);
245 
248 WS_DLL_PUBLIC guint conversation_table_get_num(void);
249 
254 WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch);
255 
260 WS_DLL_PUBLIC void reset_endpoint_table_data(conv_hash_t *ch);
261 
262 /* For backwards source and binary compatibility */
263 G_DEPRECATED_FOR(reset_endpoint_table_data)
264 WS_DLL_PUBLIC void reset_hostlist_table_data(conv_hash_t *ch);
265 
271 WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void* userdata);
272 
278 WS_DLL_PUBLIC void dissector_endpoint_init(const char *opt_arg, void* userdata);
279 
280 /* For backwards source and binary compatibility */
281 G_DEPRECATED_FOR(dissector_endpoint_init)
282 WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata);
283 
291 WS_DLL_PUBLIC char *get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names);
292 
303 WS_DLL_PUBLIC char *get_conversation_port(wmem_allocator_t *allocator, guint32 port, conversation_type ctype, gboolean resolve_names);
304 
315 WS_DLL_PUBLIC char *get_endpoint_port(wmem_allocator_t *allocator, endpoint_item_t *item, gboolean resolve_names);
316 
323 WS_DLL_PUBLIC char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction);
324 
331 WS_DLL_PUBLIC char *get_endpoint_filter(endpoint_item_t *endpoint_item);
332 
333 /* For backwards source and binary compatibility */
334 G_DEPRECATED_FOR(get_endpoint_filter)
335 WS_DLL_PUBLIC char *get_hostlist_filter(endpoint_item_t *endpoint_item);
336 
351 WS_DLL_PUBLIC void add_conversation_table_data(conv_hash_t *ch, const address *src, const address *dst,
352  guint32 src_port, guint32 dst_port, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts,
353  ct_dissector_info_t *ct_info, conversation_type ctype);
354 
372 WS_DLL_PUBLIC void
373 add_conversation_table_data_with_conv_id(conv_hash_t *ch, const address *src, const address *dst, guint32 src_port,
374  guint32 dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
375  nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
376  conversation_type ctype);
377 
389 WS_DLL_PUBLIC void add_endpoint_table_data(conv_hash_t *ch, const address *addr,
390  guint32 port, gboolean sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
391 
392 /* For backwards source and binary compatibility */
393 G_DEPRECATED_FOR(add_endpoint_table_data)
394 WS_DLL_PUBLIC void add_hostlist_table_data(conv_hash_t *ch, const address *addr,
395  guint32 port, gboolean sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
396 
397 #ifdef __cplusplus
398 }
399 #endif /* __cplusplus */
400 
401 #endif /* __CONVERSATION_TABLE_H__ */
402 
403 /*
404  * Editor modelines
405  *
406  * Local Variables:
407  * c-basic-offset: 4
408  * tab-width: 8
409  * indent-tabs-mode: nil
410  * End:
411  *
412  * ex: set shiftwidth=4 tabstop=8 expandtab:
413  * :indentSize=4:tabSize=8:noTabs=true:
414  */
guint32 conv_id_t
Definition: conv_id.h:32
WS_DLL_PUBLIC guint conversation_table_get_num(void)
Definition: conversation_table.c:204
WS_DLL_PUBLIC void 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
WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t *ct)
Definition: conversation_table.c:38
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:811
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:55
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:116
conversation_type ctype
Definition: conversation_table.h:120
nstime_t start_time
Definition: conversation_table.h:135
guint32 dst_port
Definition: conversation_table.h:122
conv_id_t conv_id
Definition: conversation_table.h:123
address src_address
Definition: conversation_table.h:118
nstime_t start_abs_time
Definition: conversation_table.h:137
guint64 tx_bytes
Definition: conversation_table.h:128
ct_dissector_info_t * dissector_info
Definition: conversation_table.h:117
guint64 tx_bytes_total
Definition: conversation_table.h:133
address dst_address
Definition: conversation_table.h:119
guint64 rx_bytes_total
Definition: conversation_table.h:132
gboolean filtered
Definition: conversation_table.h:139
guint64 tx_frames_total
Definition: conversation_table.h:131
guint64 rx_frames_total
Definition: conversation_table.h:130
guint64 rx_frames
Definition: conversation_table.h:125
guint64 tx_frames
Definition: conversation_table.h:126
guint32 src_port
Definition: conversation_table.h:121
guint64 rx_bytes
Definition: conversation_table.h:127
nstime_t stop_time
Definition: conversation_table.h:136
Definition: conversation_table.h:61
Definition: conversation_table.h:85
Definition: conversation_table.h:143
address myaddress
Definition: conversation_table.h:145
gboolean modified
Definition: conversation_table.h:159
gboolean filtered
Definition: conversation_table.h:160
guint64 rx_frames_total
Definition: conversation_table.h:154
et_dissector_info_t * dissector_info
Definition: conversation_table.h:144
guint64 rx_bytes_total
Definition: conversation_table.h:156
guint64 rx_frames
Definition: conversation_table.h:149
endpoint_type etype
Definition: conversation_table.h:146
guint64 tx_frames
Definition: conversation_table.h:150
guint32 port
Definition: conversation_table.h:147
guint64 tx_bytes
Definition: conversation_table.h:152
guint64 tx_bytes_total
Definition: conversation_table.h:157
guint64 tx_frames_total
Definition: conversation_table.h:155
guint64 rx_bytes
Definition: conversation_table.h:151
Definition: conversation_table.h:92
Definition: wmem_allocator.h:27
Definition: conversation_table.h:69
Definition: nstime.h:26
Definition: conversation_table.c:24