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 <[email protected]>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11#pragma once
12#include "tap.h"
13#include "conversation.h"
14#include <epan/wmem_scopes.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
37typedef uint32_t conv_id_t;
38#define CONV_ID_UNSET UINT32_MAX
39
44typedef enum {
45 CONV_FT_SRC_ADDRESS,
46 CONV_FT_DST_ADDRESS,
47 CONV_FT_ANY_ADDRESS,
48 CONV_FT_SRC_PORT,
49 CONV_FT_DST_PORT,
50 CONV_FT_ANY_PORT
51} conv_filter_type_e;
52
53/* Filter direction */
54typedef enum {
55 CONV_DIR_A_TO_FROM_B,
56 CONV_DIR_A_TO_B,
57 CONV_DIR_A_FROM_B,
58 CONV_DIR_A_TO_FROM_ANY,
59 CONV_DIR_A_TO_ANY,
60 CONV_DIR_A_FROM_ANY,
61 CONV_DIR_ANY_TO_FROM_B,
62 CONV_DIR_ANY_TO_B,
63 CONV_DIR_ANY_FROM_B
64} conv_direction_e;
65
69typedef struct _conversation_hash_t {
70 GHashTable *hashtable;
71 GArray *conv_array;
72 void *user_data;
73 unsigned flags;
75
77typedef struct _conversation_key_t {
78 address addr1;
79 address addr2;
80 uint32_t port1;
81 uint32_t port2;
82 conv_id_t conv_id;
84
85typedef struct {
86 address myaddress;
87 uint32_t port;
89
90/*
91 * For backwards source compatibility.
92 * Yes, G_DEPRECATED_FOR() has to be at the beginning, so that this
93 * works with MSVC.
94 */
95G_DEPRECATED_FOR(endpoint_key_t)
97
99typedef const char* (*conv_get_filter_type)(struct _conversation_item_t* item, conv_filter_type_e filter);
100
101typedef struct _ct_dissector_info {
102 conv_get_filter_type get_filter_type;
104
105struct _endpoint_item_t;
106typedef const char* (*endpoint_get_filter_type)(struct _endpoint_item_t* item, conv_filter_type_e filter_type);
107
108typedef struct _et_dissector_info {
109 endpoint_get_filter_type get_filter_type;
111
112/* For backwards source compatibiity */
113G_DEPRECATED_FOR(et_dissector_info_t)
115
116#define CONV_FILTER_INVALID "INVALID"
117
118
119struct register_ct;
120typedef void (*conv_gui_init_cb)(struct register_ct* ct, const char *filter);
121
122typedef void (*endpoint_gui_init_cb)(struct register_ct* ct, const char *filter);
123
130
135
164
186
187/* For backwards source compatibility */
188G_DEPRECATED_FOR(endpoint_item_t)
190
191#define ENDPOINT_TAP_PREFIX "endpoints"
192
195extern void conversation_table_init(void);
196
204WS_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);
205
211WS_DLL_PUBLIC bool get_conversation_hide_ports(register_ct_t* ct);
212
218WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t* ct);
219
225WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t* ct);
226
232WS_DLL_PUBLIC tap_packet_cb get_endpoint_packet_func(register_ct_t* ct);
233
234/* For backwards source and binary compatibility */
235G_DEPRECATED_FOR(get_endpoint_packet_func)
236WS_DLL_PUBLIC tap_packet_cb get_hostlist_packet_func(register_ct_t* ct);
237
238
244WS_DLL_PUBLIC register_ct_t* get_conversation_by_proto_id(int proto_id);
245
252WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb);
253
260WS_DLL_PUBLIC void endpoint_table_set_gui_info(endpoint_gui_init_cb init_cb);
261
262/* For backwards source and binary compatibility */
268G_DEPRECATED_FOR(endpoint_table_set_gui_info)
269WS_DLL_PUBLIC void hostlist_table_set_gui_info(endpoint_gui_init_cb init_cb);
270
276WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void* user_data);
277
280WS_DLL_PUBLIC unsigned conversation_table_get_num(void);
281
286WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch);
287
292WS_DLL_PUBLIC void reset_endpoint_table_data(conv_hash_t *ch);
293
294/* For backwards source and binary compatibility */
295G_DEPRECATED_FOR(reset_endpoint_table_data)
296WS_DLL_PUBLIC void reset_hostlist_table_data(conv_hash_t *ch);
297
304WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void* userdata);
305
311WS_DLL_PUBLIC void dissector_endpoint_init(const char *opt_arg, void* userdata);
312
313/* For backwards source and binary compatibility */
320G_DEPRECATED_FOR(dissector_endpoint_init)
321WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata);
322
331WS_DLL_PUBLIC char *get_conversation_address(wmem_allocator_t *allocator, address *addr, bool resolve_names);
332
344WS_DLL_PUBLIC char *get_conversation_port(wmem_allocator_t *allocator, uint32_t port, conversation_type ctype, bool resolve_names);
345
357WS_DLL_PUBLIC char *get_endpoint_port(wmem_allocator_t *allocator, endpoint_item_t *item, bool resolve_names);
358
366WS_DLL_PUBLIC char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction);
367
375WS_DLL_PUBLIC char *get_endpoint_filter(endpoint_item_t *endpoint_item);
376
377/* For backwards source and binary compatibility */
378G_DEPRECATED_FOR(get_endpoint_filter)
379WS_DLL_PUBLIC char *get_hostlist_filter(endpoint_item_t *endpoint_item);
380
396WS_DLL_PUBLIC void add_conversation_table_data(conv_hash_t *ch, const address *src, const address *dst,
397 uint32_t src_port, uint32_t dst_port, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts,
398 ct_dissector_info_t *ct_info, conversation_type ctype);
399
417WS_DLL_PUBLIC conv_item_t *
418add_conversation_table_data_with_conv_id(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port,
419 uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
420 nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
421 conversation_type ctype);
422
427WS_DLL_PUBLIC void
428add_conversation_table_data_extended(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port,
429 uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
430 nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
431 conversation_type ctype, uint32_t frameid, int (*proto_conv_cb)(conversation_t *));
432
437WS_DLL_PUBLIC void
438add_conversation_table_data_ipv4_subnet(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port,
439 uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
440 nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
441 conversation_type ctype);
442
455WS_DLL_PUBLIC void add_endpoint_table_data(conv_hash_t *ch, const address *addr,
456 uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
457
462WS_DLL_PUBLIC void add_endpoint_table_data_ipv4_subnet(conv_hash_t *ch, const address *addr,
463 uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
464
465/* For backwards source and binary compatibility */
478G_DEPRECATED_FOR(add_endpoint_table_data)
479WS_DLL_PUBLIC void add_hostlist_table_data(conv_hash_t *ch, const address *addr,
480 uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
481
482#ifdef __cplusplus
483}
484#endif /* __cplusplus */
485
486/*
487 * Editor modelines
488 *
489 * Local Variables:
490 * c-basic-offset: 4
491 * tab-width: 8
492 * indent-tabs-mode: nil
493 * End:
494 *
495 * ex: set shiftwidth=4 tabstop=8 expandtab:
496 * :indentSize=4:tabSize=8:noTabs=true:
497 */
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)
Add some data to the endpoint table.
Definition conversation_table.c:951
WS_DLL_PUBLIC char * get_endpoint_filter(endpoint_item_t *endpoint_item)
Get a display filter for the given endpoint.
Definition conversation_table.c:613
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
WS_DLL_PUBLIC char * get_endpoint_port(wmem_allocator_t *allocator, endpoint_item_t *item, bool resolve_names)
Get the string representation of the port for an endpoint_item_t.
Definition conversation_table.c:369
WS_DLL_PUBLIC bool get_conversation_hide_ports(register_ct_t *ct)
Definition conversation_table.c:33
WS_DLL_PUBLIC void add_hostlist_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)
Adds data to the hostlist table for a conversation.
Definition conversation_table.c:1079
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
struct _conversation_extension_tcp_t conv_extension_tcp_t
WS_DLL_PUBLIC char * get_conversation_port(wmem_allocator_t *allocator, uint32_t port, conversation_type ctype, bool resolve_names)
Get the string representation of a port.
Definition conversation_table.c:350
WS_DLL_PUBLIC register_ct_t * get_conversation_by_proto_id(int proto_id)
Definition conversation_table.c:133
WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t *ct)
Definition conversation_table.c:38
WS_DLL_PUBLIC void dissector_endpoint_init(const char *opt_arg, void *userdata)
Definition conversation_table.c:116
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:217
WS_DLL_PUBLIC unsigned conversation_table_get_num(void)
Definition conversation_table.c:222
void conversation_table_init(void)
Definition conversation_table.c:138
struct _conversation_key_t conv_key_t
WS_DLL_PUBLIC tap_packet_cb get_endpoint_packet_func(register_ct_t *ct)
Definition conversation_table.c:51
WS_DLL_PUBLIC char * get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction)
Get a display filter for the given conversation and direction.
Definition conversation_table.c:437
uint32_t conv_id_t
Definition conversation_table.h:37
WS_DLL_PUBLIC char * get_conversation_address(wmem_allocator_t *allocator, address *addr, bool resolve_names)
Get the string representation of an address.
Definition conversation_table.c:341
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)
Add some data to the conversation table.
Definition conversation_table.c:662
WS_DLL_PUBLIC void reset_endpoint_table_data(conv_hash_t *ch)
Definition conversation_table.c:311
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
struct _endpoint_item_t endpoint_item_t
WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void *userdata)
Initialize the dissector host list with the given options and user data.
Definition conversation_table.c:123
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
WS_DLL_PUBLIC void endpoint_table_set_gui_info(endpoint_gui_init_cb init_cb)
Definition conversation_table.c:206
WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb)
Definition conversation_table.c:182
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
struct _conversation_hash_t conv_hash_t
WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch)
Definition conversation_table.c:286
WS_DLL_PUBLIC void hostlist_table_set_gui_info(endpoint_gui_init_cb init_cb)
Set GUI initialization callback for hostlist table.
Definition conversation_table.c:212
WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void *userdata)
Initialize dissector conversation for stats and (possibly) GUI.
Definition conversation_table.c:86
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
Definition address.h:55
Definition conversation_table.h:132
uint64_t flows
Definition conversation_table.h:133
Definition conversation_table.h:69
GArray * conv_array
Definition conversation_table.h:71
void * user_data
Definition conversation_table.h:72
GHashTable * hashtable
Definition conversation_table.h:70
unsigned flags
Definition conversation_table.h:73
Definition conversation_table.h:137
conversation_type ctype
Definition conversation_table.h:141
nstime_t start_time
Definition conversation_table.h:156
uint64_t tx_bytes
Definition conversation_table.h:149
conv_id_t conv_id
Definition conversation_table.h:144
address src_address
Definition conversation_table.h:139
nstime_t start_abs_time
Definition conversation_table.h:158
uint64_t tx_frames_total
Definition conversation_table.h:152
uint64_t rx_frames_total
Definition conversation_table.h:151
bool filtered
Definition conversation_table.h:160
uint64_t rx_frames
Definition conversation_table.h:146
ct_dissector_info_t * dissector_info
Definition conversation_table.h:138
uint64_t tx_bytes_total
Definition conversation_table.h:154
address dst_address
Definition conversation_table.h:140
uint32_t dst_port
Definition conversation_table.h:143
uint32_t src_port
Definition conversation_table.h:142
uint64_t rx_bytes
Definition conversation_table.h:148
uint64_t rx_bytes_total
Definition conversation_table.h:153
uint64_t tx_frames
Definition conversation_table.h:147
nstime_t stop_time
Definition conversation_table.h:157
conv_extension_tcp_t ext_tcp
Definition conversation_table.h:162
Definition conversation_table.h:77
Definition conversation_table.h:101
Definition conversation_table.h:166
uint64_t rx_frames_total
Definition conversation_table.h:177
bool modified
Definition conversation_table.h:182
address myaddress
Definition conversation_table.h:168
uint64_t rx_frames
Definition conversation_table.h:172
uint64_t rx_bytes
Definition conversation_table.h:174
uint64_t tx_bytes
Definition conversation_table.h:175
et_dissector_info_t * dissector_info
Definition conversation_table.h:167
endpoint_type etype
Definition conversation_table.h:169
uint64_t tx_bytes_total
Definition conversation_table.h:180
uint64_t rx_bytes_total
Definition conversation_table.h:179
uint64_t tx_frames
Definition conversation_table.h:173
bool filtered
Definition conversation_table.h:183
uint64_t tx_frames_total
Definition conversation_table.h:178
uint32_t port
Definition conversation_table.h:170
Definition conversation_table.h:108
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Definition conversation.h:227
Definition conversation_table.h:85
Definition nstime.h:26
Definition conversation_table.c:24