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#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
55
56
71
75typedef struct _conversation_hash_t {
76 GHashTable *hashtable;
77 GArray *conv_array;
78 void *user_data;
79 unsigned flags;
81
92
96typedef struct {
98 uint32_t port;
100
101/*
102 * For backwards source compatibility.
103 * Yes, G_DEPRECATED_FOR() has to be at the beginning, so that this
104 * works with MSVC.
105 */
106G_DEPRECATED_FOR(endpoint_key_t)
108
110typedef const char* (*conv_get_filter_type)(struct _conversation_item_t* item, conv_filter_type_e filter);
111
115typedef struct _ct_dissector_info {
116 conv_get_filter_type get_filter_type;
118
119struct _endpoint_item_t;
120
127typedef const char* (*endpoint_get_filter_type)(struct _endpoint_item_t* item, conv_filter_type_e filter_type);
128
135
136/* For backwards source compatibility */
137G_DEPRECATED_FOR(et_dissector_info_t)
139
140#define CONV_FILTER_INVALID "INVALID"
141
142
143struct register_ct;
144typedef void (*conv_gui_init_cb)(struct register_ct* ct, const char *filter);
145
146typedef void (*endpoint_gui_init_cb)(struct register_ct* ct, const char *filter);
147
154
159
188
210
211/* For backwards source compatibility */
212G_DEPRECATED_FOR(endpoint_item_t)
214
215#define ENDPOINT_TAP_PREFIX "endpoints"
216
220extern void conversation_table_init(void);
221
229WS_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);
230
237WS_DLL_PUBLIC bool get_conversation_hide_ports(register_ct_t* ct);
238
245WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t* ct);
246
253WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t* ct);
254
261WS_DLL_PUBLIC tap_packet_cb get_endpoint_packet_func(register_ct_t* ct);
262
263/* For backwards source and binary compatibility */
264G_DEPRECATED_FOR(get_endpoint_packet_func)
265
266
272WS_DLL_PUBLIC tap_packet_cb get_hostlist_packet_func(register_ct_t* ct);
273
274
281WS_DLL_PUBLIC register_ct_t* get_conversation_by_proto_id(int proto_id);
282
290WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb);
291
299WS_DLL_PUBLIC void endpoint_table_set_gui_info(endpoint_gui_init_cb init_cb);
300
301/* For backwards source and binary compatibility */
307G_DEPRECATED_FOR(endpoint_table_set_gui_info)
308WS_DLL_PUBLIC void hostlist_table_set_gui_info(endpoint_gui_init_cb init_cb);
309
316WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void* user_data);
317
322WS_DLL_PUBLIC unsigned conversation_table_get_num(void);
323
329WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch);
330
336WS_DLL_PUBLIC void reset_endpoint_table_data(conv_hash_t *ch);
337
338/* For backwards source and binary compatibility */
339G_DEPRECATED_FOR(reset_endpoint_table_data)
340
341
346WS_DLL_PUBLIC void reset_hostlist_table_data(conv_hash_t *ch);
347
354WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void* userdata);
355
362WS_DLL_PUBLIC void dissector_endpoint_init(const char *opt_arg, void* userdata);
363
364/* For backwards source and binary compatibility */
371G_DEPRECATED_FOR(dissector_endpoint_init)
372WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata);
373
382WS_DLL_PUBLIC char *get_conversation_address(wmem_allocator_t *allocator, address *addr, bool resolve_names);
383
395WS_DLL_PUBLIC char *get_conversation_port(wmem_allocator_t *allocator, uint32_t port, conversation_type ctype, bool resolve_names);
396
408WS_DLL_PUBLIC char *get_endpoint_port(wmem_allocator_t *allocator, endpoint_item_t *item, bool resolve_names);
409
417WS_DLL_PUBLIC char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction);
418
426WS_DLL_PUBLIC char *get_endpoint_filter(endpoint_item_t *endpoint_item);
427
428/* For backwards source and binary compatibility */
429G_DEPRECATED_FOR(get_endpoint_filter)
430
431
437WS_DLL_PUBLIC char *get_hostlist_filter(endpoint_item_t *endpoint_item);
438
454WS_DLL_PUBLIC void add_conversation_table_data(conv_hash_t *ch, const address *src, const address *dst,
455 uint32_t src_port, uint32_t dst_port, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts,
456 ct_dissector_info_t *ct_info, conversation_type ctype);
457
476WS_DLL_PUBLIC conv_item_t *
477add_conversation_table_data_with_conv_id(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port,
478 uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
479 nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
480 conversation_type ctype);
481
501WS_DLL_PUBLIC void
502add_conversation_table_data_extended(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port,
503 uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
504 nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
505 conversation_type ctype, uint32_t frameid, int (*proto_conv_cb)(conversation_t *));
506
524WS_DLL_PUBLIC void
525add_conversation_table_data_ipv4_subnet(conv_hash_t *ch, const address *src, const address *dst, uint32_t src_port,
526 uint32_t dst_port, conv_id_t conv_id, int num_frames, int num_bytes,
527 nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info,
528 conversation_type ctype);
529
542WS_DLL_PUBLIC void add_endpoint_table_data(conv_hash_t *ch, const address *addr,
543 uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
544
558WS_DLL_PUBLIC void add_endpoint_table_data_ipv4_subnet(conv_hash_t *ch, const address *addr,
559 uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
560
561/* For backwards source and binary compatibility */
574G_DEPRECATED_FOR(add_endpoint_table_data)
575WS_DLL_PUBLIC void add_hostlist_table_data(conv_hash_t *ch, const address *addr,
576 uint32_t port, bool sender, int num_frames, int num_bytes, et_dissector_info_t *et_info, endpoint_type etype);
577
578#ifdef __cplusplus
579}
580#endif /* __cplusplus */
581
582/*
583 * Editor modelines
584 *
585 * Local Variables:
586 * c-basic-offset: 4
587 * tab-width: 8
588 * indent-tabs-mode: nil
589 * End:
590 *
591 * ex: set shiftwidth=4 tabstop=8 expandtab:
592 * :indentSize=4:tabSize=8:noTabs=true:
593 */
conversation_type
Conversation key types recognized by Wireshark dissectors.
Definition conversation.h:65
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)
Encapsulates add_conversation_table_data_with_conv_id() for the IPv4 specific case when the subnet ag...
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)
Should port columns be hidden?
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)
Add some data to the conversation table, passing a value to be used in addition to the address and po...
Definition conversation_table.c:669
const char *(* endpoint_get_filter_type)(struct _endpoint_item_t *item, conv_filter_type_e filter_type)
Callback that resolves a display filter field name for a given endpoint item and filter type.
Definition conversation_table.h:127
struct _conversation_extension_tcp_t conv_extension_tcp_t
WS_DLL_PUBLIC char * get_hostlist_filter(endpoint_item_t *endpoint_item)
Retrieves a hostlist filter for an endpoint item.
Definition conversation_table.c:656
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
conv_filter_type_e
Field type selector for building a conversation display filter.
Definition conversation_table.h:47
@ CONV_FT_ANY_ADDRESS
Definition conversation_table.h:50
@ CONV_FT_DST_ADDRESS
Definition conversation_table.h:49
@ CONV_FT_SRC_ADDRESS
Definition conversation_table.h:48
@ CONV_FT_SRC_PORT
Definition conversation_table.h:51
@ CONV_FT_ANY_PORT
Definition conversation_table.h:53
@ CONV_FT_DST_PORT
Definition conversation_table.h:52
WS_DLL_PUBLIC register_ct_t * get_conversation_by_proto_id(int proto_id)
get conversation table from protocol ID
Definition conversation_table.c:133
WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t *ct)
Get protocol ID of a conversation table.
Definition conversation_table.c:38
WS_DLL_PUBLIC void dissector_endpoint_init(const char *opt_arg, void *userdata)
Initialize dissector endpoint for stats and (possibly) GUI.
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)
Get conversation tap function handler of a conversation table.
Definition conversation_table.c:46
WS_DLL_PUBLIC void conversation_table_iterate_tables(wmem_foreach_func func, void *user_data)
Iterator to walk conversation tables and execute func.
Definition conversation_table.c:217
WS_DLL_PUBLIC unsigned conversation_table_get_num(void)
Get the total number of conversation tables.
Definition conversation_table.c:222
void conversation_table_init(void)
Initialize the conversation table system.
Definition conversation_table.c:138
struct _conversation_key_t conv_key_t
Composite hash table key identifying a conversation by its two endpoints and optional ID.
WS_DLL_PUBLIC tap_packet_cb get_endpoint_packet_func(register_ct_t *ct)
Get endpoint tap function handler for a conversation table.
Definition conversation_table.c:51
struct _et_dissector_info et_dissector_info_t
Dissector info block for an endpoint table, providing filter-type resolution.
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
struct _ct_dissector_info ct_dissector_info_t
Dissector info block for a conversation table, providing filter-type resolution.
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
conv_direction_e
Directional filter scope for a conversation, relative to endpoints A and B.
Definition conversation_table.h:60
@ CONV_DIR_ANY_FROM_B
Definition conversation_table.h:69
@ CONV_DIR_A_TO_B
Definition conversation_table.h:62
@ CONV_DIR_A_TO_FROM_B
Definition conversation_table.h:61
@ CONV_DIR_A_TO_ANY
Definition conversation_table.h:65
@ CONV_DIR_ANY_TO_FROM_B
Definition conversation_table.h:67
@ CONV_DIR_ANY_TO_B
Definition conversation_table.h:68
@ CONV_DIR_A_FROM_ANY
Definition conversation_table.h:66
@ CONV_DIR_A_TO_FROM_ANY
Definition conversation_table.h:64
@ CONV_DIR_A_FROM_B
Definition conversation_table.h:63
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)
Remove all entries from the endpoint table.
Definition conversation_table.c:311
WS_DLL_PUBLIC void reset_hostlist_table_data(conv_hash_t *ch)
Reset data in hostlist table.
Definition conversation_table.c:336
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)
Register the conversation table for the conversation and endpoint windows.
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 *))
Decorates add_conversation_table_data_with_conv_id() in order to be able to add protocol dependent ad...
Definition conversation_table.c:813
WS_DLL_PUBLIC tap_packet_cb get_hostlist_packet_func(register_ct_t *ct)
Get the packet callback function for hostlist conversations.
Definition conversation_table.c:57
WS_DLL_PUBLIC void endpoint_table_set_gui_info(endpoint_gui_init_cb init_cb)
Register "initialization function" used by the GUI to create endpoint table display in GUI.
Definition conversation_table.c:206
WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb)
Register "initialization function" used by the GUI to create conversation table display in GUI.
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)
Encapsulates add_endpoint_table_data() for the IPv4 specific case when the subnet aggregation user pr...
Definition conversation_table.c:1036
struct _conversation_hash_t conv_hash_t
WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch)
Remove all entries from the conversation table.
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
Holds a network or link-layer address of any supported type.
Definition address.h:62
Definition conversation_table.h:156
uint64_t flows
Definition conversation_table.h:157
Definition conversation_table.h:75
GArray * conv_array
Definition conversation_table.h:77
void * user_data
Definition conversation_table.h:78
GHashTable * hashtable
Definition conversation_table.h:76
unsigned flags
Definition conversation_table.h:79
Definition conversation_table.h:161
conversation_type ctype
Definition conversation_table.h:165
nstime_t start_time
Definition conversation_table.h:180
uint64_t tx_bytes
Definition conversation_table.h:173
conv_id_t conv_id
Definition conversation_table.h:168
address src_address
Definition conversation_table.h:163
nstime_t start_abs_time
Definition conversation_table.h:182
uint64_t tx_frames_total
Definition conversation_table.h:176
uint64_t rx_frames_total
Definition conversation_table.h:175
bool filtered
Definition conversation_table.h:184
uint64_t rx_frames
Definition conversation_table.h:170
ct_dissector_info_t * dissector_info
Definition conversation_table.h:162
uint64_t tx_bytes_total
Definition conversation_table.h:178
address dst_address
Definition conversation_table.h:164
uint32_t dst_port
Definition conversation_table.h:167
uint32_t src_port
Definition conversation_table.h:166
uint64_t rx_bytes
Definition conversation_table.h:172
uint64_t rx_bytes_total
Definition conversation_table.h:177
uint64_t tx_frames
Definition conversation_table.h:171
nstime_t stop_time
Definition conversation_table.h:181
conv_extension_tcp_t ext_tcp
Definition conversation_table.h:186
Composite hash table key identifying a conversation by its two endpoints and optional ID.
Definition conversation_table.h:85
address addr2
Definition conversation_table.h:87
uint32_t port1
Definition conversation_table.h:88
address addr1
Definition conversation_table.h:86
conv_id_t conv_id
Definition conversation_table.h:90
uint32_t port2
Definition conversation_table.h:89
Dissector info block for a conversation table, providing filter-type resolution.
Definition conversation_table.h:115
conv_get_filter_type get_filter_type
Definition conversation_table.h:116
Definition conversation_table.h:190
uint64_t rx_frames_total
Definition conversation_table.h:201
bool modified
Definition conversation_table.h:206
address myaddress
Definition conversation_table.h:192
uint64_t rx_frames
Definition conversation_table.h:196
uint64_t rx_bytes
Definition conversation_table.h:198
uint64_t tx_bytes
Definition conversation_table.h:199
et_dissector_info_t * dissector_info
Definition conversation_table.h:191
endpoint_type etype
Definition conversation_table.h:193
uint64_t tx_bytes_total
Definition conversation_table.h:204
uint64_t rx_bytes_total
Definition conversation_table.h:203
uint64_t tx_frames
Definition conversation_table.h:197
bool filtered
Definition conversation_table.h:207
uint64_t tx_frames_total
Definition conversation_table.h:202
uint32_t port
Definition conversation_table.h:194
Dissector info block for an endpoint table, providing filter-type resolution.
Definition conversation_table.h:132
endpoint_get_filter_type get_filter_type
Definition conversation_table.h:133
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Definition conversation.h:229
Composite hash table key identifying a single network endpoint by address and port.
Definition conversation_table.h:96
uint32_t port
Definition conversation_table.h:98
address myaddress
Definition conversation_table.h:97
Definition nstime.h:26
Definition conversation_table.c:24