Wireshark  2.9.0-477-g68ec514b
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 "wmem/wmem.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 } conv_hash_t;
58 
60 typedef struct _conversation_key_t {
61  address addr1;
62  address addr2;
63  guint32 port1;
64  guint32 port2;
65  conv_id_t conv_id;
66 } conv_key_t;
67 
68 typedef struct {
69  address myaddress;
70  guint32 port;
71 } host_key_t;
72 
74 typedef const char* (*conv_get_filter_type)(struct _conversation_item_t* item, conv_filter_type_e filter);
75 
76 typedef struct _ct_dissector_info {
77  conv_get_filter_type get_filter_type;
79 
80 struct _hostlist_talker_t;
81 typedef const char* (*host_get_filter_type)(struct _hostlist_talker_t* item, conv_filter_type_e filter_type);
82 
83 typedef struct _hostlist_dissector_info {
84  host_get_filter_type get_filter_type;
86 
87 #define CONV_FILTER_INVALID "INVALID"
88 
89 
90 struct register_ct;
91 typedef void (*conv_gui_init_cb)(struct register_ct* ct, const char *filter);
92 
93 typedef void (*host_gui_init_cb)(struct register_ct* host, const char *filter);
94 
96 typedef struct register_ct register_ct_t;
97 
99 typedef struct _conversation_item_t {
103  endpoint_type etype;
104  guint32 src_port;
105  guint32 dst_port;
106  conv_id_t conv_id;
108  guint64 rx_frames;
109  guint64 tx_frames;
110  guint64 rx_bytes;
111  guint64 tx_bytes;
117  gboolean modified;
118 } conv_item_t;
119 
121 typedef struct _hostlist_talker_t {
124  endpoint_type etype;
125  guint32 port;
127  guint64 rx_frames;
128  guint64 tx_frames;
129  guint64 rx_bytes;
130  guint64 tx_bytes;
132  gboolean modified;
135 
136 #define HOSTLIST_TAP_PREFIX "endpoints"
137 
145 WS_DLL_PUBLIC void register_conversation_table(const int proto_id, gboolean hide_ports, tap_packet_cb conv_packet_func, tap_packet_cb hostlist_func);
146 
152 WS_DLL_PUBLIC gboolean get_conversation_hide_ports(register_ct_t* ct);
153 
159 WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t* ct);
160 
166 WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t* ct);
167 
173 WS_DLL_PUBLIC tap_packet_cb get_hostlist_packet_func(register_ct_t* ct);
174 
180 WS_DLL_PUBLIC register_ct_t* get_conversation_by_proto_id(int proto_id);
181 
188 WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb);
189 
196 WS_DLL_PUBLIC void hostlist_table_set_gui_info(host_gui_init_cb init_cb);
197 
203 WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void* user_data);
204 
207 WS_DLL_PUBLIC guint conversation_table_get_num(void);
208 
213 WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch);
214 
219 WS_DLL_PUBLIC void reset_hostlist_table_data(conv_hash_t *ch);
220 
226 WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void* userdata);
227 
233 WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata);
234 
242 WS_DLL_PUBLIC char *get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names);
243 
252 WS_DLL_PUBLIC char *get_conversation_port(wmem_allocator_t *allocator, guint32 port, endpoint_type etype, gboolean resolve_names);
253 
260 WS_DLL_PUBLIC char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction);
261 
268 WS_DLL_PUBLIC char *get_hostlist_filter(hostlist_talker_t *host);
269 
284 WS_DLL_PUBLIC void add_conversation_table_data(conv_hash_t *ch, const address *src, const address *dst,
285  guint32 src_port, guint32 dst_port, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts,
286  ct_dissector_info_t *ct_info, endpoint_type etype);
287 
305 WS_DLL_PUBLIC void
306 add_conversation_table_data_with_conv_id(conv_hash_t *ch, const address *src, const address *dst, guint32 src_port,
307  guint32 dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
308  nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info, endpoint_type etype);
309 
321 WS_DLL_PUBLIC void add_hostlist_table_data(conv_hash_t *ch, const address *addr,
322  guint32 port, gboolean sender, int num_frames, int num_bytes, hostlist_dissector_info_t *host_info, endpoint_type etype);
323 
324 #ifdef __cplusplus
325 }
326 #endif /* __cplusplus */
327 
328 #endif /* __CONVERSATION_TABLE_H__ */
329 
330 /*
331  * Editor modelines
332  *
333  * Local Variables:
334  * c-basic-offset: 4
335  * tab-width: 8
336  * indent-tabs-mode: nil
337  * End:
338  *
339  * ex: set shiftwidth=4 tabstop=8 expandtab:
340  * :indentSize=4:tabSize=8:noTabs=true:
341  */
conv_id_t conv_id
Definition: conversation_table.h:106
WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch)
Definition: conversation_table.c:248
Definition: conversation_table.h:53
guint64 tx_frames
Definition: conversation_table.h:109
struct _hostlist_talker_t hostlist_talker_t
guint32 src_port
Definition: conversation_table.h:104
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, endpoint_type etype)
Definition: conversation_table.c:569
Definition: conversation_table.h:68
GArray * conv_array
Definition: conversation_table.h:55
WS_DLL_PUBLIC tap_packet_cb get_hostlist_packet_func(register_ct_t *ct)
Definition: conversation_table.c:51
hostlist_dissector_info_t * dissector_info
Definition: conversation_table.h:122
endpoint_type etype
Definition: conversation_table.h:124
Definition: conversation_table.c:24
gboolean(* wmem_foreach_func)(const void *key, void *value, void *userdata)
Definition: wmem_tree.h:213
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, endpoint_type etype)
Definition: conversation_table.c:562
guint64 rx_frames
Definition: conversation_table.h:127
endpoint_type etype
Definition: conversation_table.h:103
gboolean modified
Definition: conversation_table.h:132
ct_dissector_info_t * dissector_info
Definition: conversation_table.h:100
nstime_t stop_time
Definition: conversation_table.h:114
Definition: conversation_table.h:76
WS_DLL_PUBLIC void add_hostlist_table_data(conv_hash_t *ch, const address *addr, guint32 port, gboolean sender, int num_frames, int num_bytes, hostlist_dissector_info_t *host_info, endpoint_type etype)
Definition: conversation_table.c:732
WS_DLL_PUBLIC register_ct_t * get_conversation_by_proto_id(int proto_id)
Definition: conversation_table.c:103
guint64 tx_bytes
Definition: conversation_table.h:130
void * user_data
Definition: conversation_table.h:56
WS_DLL_PUBLIC gboolean get_conversation_hide_ports(register_ct_t *ct)
Definition: conversation_table.c:33
Definition: nstime.h:27
WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t *ct)
Definition: conversation_table.c:38
struct _conversation_item_t conv_item_t
struct _conversation_key_t conv_key_t
address dst_address
Definition: conversation_table.h:102
WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void *userdata)
Definition: conversation_table.c:59
WS_DLL_PUBLIC guint conversation_table_get_num(void)
Definition: conversation_table.c:184
guint32 dst_port
Definition: conversation_table.h:105
WS_DLL_PUBLIC char * get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction)
Definition: conversation_table.c:371
WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void *user_data)
Definition: conversation_table.c:179
WS_DLL_PUBLIC void register_conversation_table(const int proto_id, gboolean hide_ports, tap_packet_cb conv_packet_func, tap_packet_cb hostlist_func)
Definition: conversation_table.c:109
guint32 port
Definition: conversation_table.h:125
WS_DLL_PUBLIC char * get_conversation_address(wmem_allocator_t *allocator, address *addr, gboolean resolve_names)
Definition: conversation_table.c:297
address myaddress
Definition: conversation_table.h:123
guint64 rx_frames
Definition: conversation_table.h:108
address src_address
Definition: conversation_table.h:101
Definition: wmem_allocator.h:26
WS_DLL_PUBLIC void reset_hostlist_table_data(conv_hash_t *ch)
Definition: conversation_table.c:273
guint64 rx_bytes
Definition: conversation_table.h:110
WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void *userdata)
Definition: conversation_table.c:78
GHashTable * hashtable
Definition: conversation_table.h:54
Definition: conversation_table.h:121
guint64 tx_bytes
Definition: conversation_table.h:111
gboolean modified
Definition: conversation_table.h:117
guint64 rx_bytes
Definition: conversation_table.h:129
WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t *ct)
Definition: conversation_table.c:46
Definition: conversation_table.h:83
WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb)
Definition: conversation_table.c:150
guint64 tx_frames
Definition: conversation_table.h:128
WS_DLL_PUBLIC void hostlist_table_set_gui_info(host_gui_init_cb init_cb)
Definition: conversation_table.c:174
WS_DLL_PUBLIC char * get_conversation_port(wmem_allocator_t *allocator, guint32 port, endpoint_type etype, gboolean resolve_names)
Definition: conversation_table.c:306
struct _conversation_hash_t conv_hash_t
nstime_t start_abs_time
Definition: conversation_table.h:115
Definition: conversation_table.h:99
nstime_t start_time
Definition: conversation_table.h:113
Definition: conversation_table.h:60
WS_DLL_PUBLIC char * get_hostlist_filter(hostlist_talker_t *host)
Definition: conversation_table.c:529
Definition: address.h:47