| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
stat_tap_ui.h
Go to the documentation of this file.
1
10#pragma once
11#include "ws_symbol_export.h"
12
13#include <epan/params.h>
14#include <epan/stat_groups.h>
15#include <epan/packet_info.h>
16#include <epan/tap.h>
17#include <epan/wmem_scopes.h>
18
19#ifdef __cplusplus
20 extern "C" {
21#endif /* __cplusplus */
22
26 typedef enum {
27 PARAM_UINT,
28 PARAM_STRING,
29 PARAM_ENUM,
30 PARAM_UUID,
31 PARAM_FILTER
32} param_type;
33
34
38 typedef struct _tap_param {
39 param_type type;
40 const char *name;
41 const char *title;
42 const enum_val_t *enum_vals;
43 bool optional;
44} tap_param;
45
46
53 typedef bool (*stat_tap_init_cb)(const char *opt_arg, void *userdata);
54
55
59 typedef struct _stat_tap_ui {
60 register_stat_group_t group;
61 const char *title;
62 const char *cli_string;
63 stat_tap_init_cb tap_init_cb;
64 size_t nparams;
65 tap_param *params;
66} stat_tap_ui;
67
68
72 typedef enum {
73 TABLE_ITEM_NONE = 0,
74 TABLE_ITEM_UINT,
75 TABLE_ITEM_INT,
76 TABLE_ITEM_STRING,
77 TABLE_ITEM_FLOAT,
78 TABLE_ITEM_ENUM
79} stat_tap_table_item_enum;
80
88 typedef struct _stat_tap_table_item_type
89{
90 stat_tap_table_item_enum type;
91
97 union {
98 unsigned uint_value;
99 int int_value;
100 const char* string_value;
101 double float_value;
102 int enum_value;
103 } value;
104
111 union {
112 unsigned uint_value;
113 int int_value;
114 const char* string_value;
115 double float_value;
116 int enum_value;
117 void* ptr_value;
118 } user_data;
119} stat_tap_table_item_type;
120
124 typedef enum {
125 TAP_ALIGN_LEFT = 0,
126 TAP_ALIGN_RIGHT
127} tap_alignment_type;
128
129
133 typedef struct _stat_tap_table_item {
134 stat_tap_table_item_enum type;
135 tap_alignment_type align;
136 const char *column_name;
137 const char *field_format;
138} stat_tap_table_item;
139
140
144 typedef struct _stat_tap_table {
145 const char *title;
146 const char *filter_string;
147 unsigned num_fields;
148 unsigned num_elements;
149 stat_tap_table_item_type **elements;
150} stat_tap_table;
151
152
156 typedef struct _stat_tap_table_ui {
157 register_stat_group_t group;
158 const char *title;
159 const char *tap_name;
160 const char *cli_string;
161
166 void (*stat_tap_init_cb)(struct _stat_tap_table_ui *new_stat);
167
168 tap_packet_cb packet_func;
169
174 void (*stat_tap_reset_table_cb)(stat_tap_table *table);
175
183 void (*stat_tap_free_table_item_cb)(stat_tap_table *table, unsigned row, unsigned column, stat_tap_table_item_type *field_data);
184
191 void (*stat_filter_check_cb)(const char *opt_arg, const char **filter, char **err);
192
193 size_t nfields;
194 stat_tap_table_item *fields;
195 size_t nparams;
196 tap_param *params;
197 GArray *tables;
198 unsigned refcount;
199} stat_tap_table_ui;
200
201
205 typedef struct _stat_data_t {
206 stat_tap_table_ui *stat_tap_data;
207 void *user_data;
208} stat_data_t;
209
214 extern void stat_tap_init(void);
215
221WS_DLL_PUBLIC void register_stat_tap_ui(stat_tap_ui *ui, void *userdata);
222
229WS_DLL_PUBLIC void register_stat_tap_table_ui(stat_tap_table_ui *ui);
230
238WS_DLL_PUBLIC void stat_tap_iterate_tables(wmem_foreach_func func, void *user_data);
239
253WS_DLL_PUBLIC void stat_tap_get_filter(stat_tap_table_ui *new_stat, const char *opt_arg,
254 const char **filter, char **err);
255
268WS_DLL_PUBLIC stat_tap_table *stat_tap_init_table(const char *name, int num_fields,
269 int num_elements,
270 const char *filter_string);
271
278WS_DLL_PUBLIC void stat_tap_add_table(stat_tap_table_ui* new_stat, stat_tap_table* table);
279
287WS_DLL_PUBLIC stat_tap_table *stat_tap_find_table(stat_tap_table_ui *ui, const char *name);
288
302WS_DLL_PUBLIC void stat_tap_init_table_row(stat_tap_table *stat_table,
303 unsigned table_index,
304 unsigned num_fields,
305 const stat_tap_table_item_type *fields);
306
317WS_DLL_PUBLIC stat_tap_table_item_type *stat_tap_get_field_data(
318 const stat_tap_table *stat_table,
319 unsigned table_index,
320 unsigned field_index);
321
330WS_DLL_PUBLIC void stat_tap_set_field_data(stat_tap_table *stat_table, unsigned table_index, unsigned field_index, stat_tap_table_item_type* field_data);
331
336WS_DLL_PUBLIC void reset_stat_table(stat_tap_table_ui *new_stat);
337
338
345WS_DLL_PUBLIC stat_tap_table_ui *stat_tap_by_name(const char *name);
346
356WS_DLL_PUBLIC void free_stat_tables(stat_tap_table_ui* new_stat);
357
364WS_DLL_PUBLIC bool process_stat_cmd_arg(const char *optstr);
365
371WS_DLL_PUBLIC void list_stat_cmd_args(void);
372
380WS_DLL_PUBLIC bool start_requested_stats(void);
381
382#ifdef __cplusplus
383}
384#endif /* __cplusplus */
385
386/*
387 * Editor modelines
388 *
389 * Local Variables:
390 * c-basic-offset: 4
391 * tab-width: 8
392 * indent-tabs-mode: nil
393 * End:
394 *
395 * ex: set shiftwidth=4 tabstop=8 expandtab:
396 * :indentSize=4:tabSize=8:noTabs=true:
397 */
wmem_foreach_func
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
packet_info.h
params.h
stat_groups.h
register_stat_group_t
enum register_stat_group_e register_stat_group_t
register_stat_tap_ui
WS_DLL_PUBLIC void register_stat_tap_ui(stat_tap_ui *ui, void *userdata)
Definition stat_tap_ui.c:68
stat_tap_by_name
WS_DLL_PUBLIC stat_tap_table_ui * stat_tap_by_name(const char *name)
Look up a registered table-based statistics tap UI by its option name.
Definition stat_tap_ui.c:157
tap_param
struct _tap_param tap_param
Describes a single configurable parameter accepted by a tap statistic.
reset_stat_table
WS_DLL_PUBLIC void reset_stat_table(stat_tap_table_ui *new_stat)
Reset all tables belonging to a statistics tap UI to their initial state.
Definition stat_tap_ui.c:266
start_requested_stats
WS_DLL_PUBLIC bool start_requested_stats(void)
Start requested statistics.
Definition stat_tap_ui.c:136
stat_tap_find_table
WS_DLL_PUBLIC stat_tap_table * stat_tap_find_table(stat_tap_table_ui *ui, const char *name)
Finds a table by its UI structure and name.
Definition stat_tap_ui.c:199
stat_data_t
struct _stat_data_t stat_data_t
Per-tap-instance data passed between the tap engine and the statistics UI.
stat_tap_iterate_tables
WS_DLL_PUBLIC void stat_tap_iterate_tables(wmem_foreach_func func, void *user_data)
Iterate over all registered table-based statistics tap UIs.
Definition stat_tap_ui.c:162
param_type
param_type
Parameter types for tap statistics dialogs and CLI argument parsing.
Definition stat_tap_ui.h:26
PARAM_STRING
@ PARAM_STRING
Definition stat_tap_ui.h:28
PARAM_UINT
@ PARAM_UINT
Definition stat_tap_ui.h:27
PARAM_ENUM
@ PARAM_ENUM
Definition stat_tap_ui.h:29
PARAM_FILTER
@ PARAM_FILTER
Definition stat_tap_ui.h:31
PARAM_UUID
@ PARAM_UUID
Definition stat_tap_ui.h:30
free_stat_tables
WS_DLL_PUBLIC void free_stat_tables(stat_tap_table_ui *new_stat)
Free all of the tables associated with a stat_tap_table_ui.
Definition stat_tap_ui.c:280
stat_tap_ui
struct _stat_tap_ui stat_tap_ui
Registration descriptor for a tap-based statistics dialog or CLI report.
process_stat_cmd_arg
WS_DLL_PUBLIC bool process_stat_cmd_arg(const char *optstr)
Processes a command argument for statistics.
Definition stat_tap_ui.c:88
stat_tap_init_table
WS_DLL_PUBLIC stat_tap_table * stat_tap_init_table(const char *name, int num_fields, int num_elements, const char *filter_string)
Allocate and initialise a stat_tap_table.
Definition stat_tap_ui.c:185
stat_tap_table_item_enum
stat_tap_table_item_enum
Value type for a cell within a statistics tap table.
Definition stat_tap_ui.h:72
TABLE_ITEM_FLOAT
@ TABLE_ITEM_FLOAT
Definition stat_tap_ui.h:77
TABLE_ITEM_STRING
@ TABLE_ITEM_STRING
Definition stat_tap_ui.h:76
TABLE_ITEM_UINT
@ TABLE_ITEM_UINT
Definition stat_tap_ui.h:74
TABLE_ITEM_INT
@ TABLE_ITEM_INT
Definition stat_tap_ui.h:75
TABLE_ITEM_NONE
@ TABLE_ITEM_NONE
Definition stat_tap_ui.h:73
TABLE_ITEM_ENUM
@ TABLE_ITEM_ENUM
Definition stat_tap_ui.h:78
register_stat_tap_table_ui
WS_DLL_PUBLIC void register_stat_tap_table_ui(stat_tap_table_ui *ui)
Register a table-based statistics tap UI descriptor.
Definition stat_tap_ui.c:152
stat_tap_init
void stat_tap_init(void)
Initializes the statistics tap system, setting up necessary data structures.
Definition stat_tap_ui.c:61
stat_tap_init_cb
bool(* stat_tap_init_cb)(const char *opt_arg, void *userdata)
Callback invoked to initialize a tap statistic with its CLI argument string.
Definition stat_tap_ui.h:53
tap_alignment_type
tap_alignment_type
Horizontal alignment for a statistics table column.
Definition stat_tap_ui.h:124
TAP_ALIGN_LEFT
@ TAP_ALIGN_LEFT
Definition stat_tap_ui.h:125
TAP_ALIGN_RIGHT
@ TAP_ALIGN_RIGHT
Definition stat_tap_ui.h:126
stat_tap_table
struct _stat_tap_table stat_tap_table
A single statistics table instance, holding rows of tap-collected data.
list_stat_cmd_args
WS_DLL_PUBLIC void list_stat_cmd_args(void)
List command-line arguments for requested statistics.
Definition stat_tap_ui.c:127
stat_tap_set_field_data
WS_DLL_PUBLIC void stat_tap_set_field_data(stat_tap_table *stat_table, unsigned table_index, unsigned field_index, stat_tap_table_item_type *field_data)
Set field data for a specific table and field index.
Definition stat_tap_ui.c:254
stat_tap_get_filter
WS_DLL_PUBLIC void stat_tap_get_filter(stat_tap_table_ui *new_stat, const char *opt_arg, const char **filter, char **err)
Parse the display filter from a statistics option argument string.
Definition stat_tap_ui.c:167
stat_tap_get_field_data
WS_DLL_PUBLIC stat_tap_table_item_type * stat_tap_get_field_data(const stat_tap_table *stat_table, unsigned table_index, unsigned field_index)
Return a pointer to the field value at a given row and column.
Definition stat_tap_ui.c:242
stat_tap_table_item
struct _stat_tap_table_item stat_tap_table_item
Schema descriptor for a single column in a statistics tap table.
stat_tap_init_table_row
WS_DLL_PUBLIC void stat_tap_init_table_row(stat_tap_table *stat_table, unsigned table_index, unsigned num_fields, const stat_tap_table_item_type *fields)
Initialise a row in a stat_tap_table with field values.
Definition stat_tap_ui.c:225
stat_tap_table_ui
struct _stat_tap_table_ui stat_tap_table_ui
Registration descriptor and runtime state for a table-based tap statistics UI.
stat_tap_add_table
WS_DLL_PUBLIC void stat_tap_add_table(stat_tap_table_ui *new_stat, stat_tap_table *table)
Adds a new table to the statistics tap.
Definition stat_tap_ui.c:217
stat_tap_table_item_type
struct _stat_tap_table_item_type stat_tap_table_item_type
Represents a single item in a statistics tap table.
_stat_data_t
Per-tap-instance data passed between the tap engine and the statistics UI.
Definition stat_tap_ui.h:205
_stat_data_t::user_data
void * user_data
Definition stat_tap_ui.h:207
_stat_data_t::stat_tap_data
stat_tap_table_ui * stat_tap_data
Definition stat_tap_ui.h:206
_stat_tap_table_item_type
Represents a single item in a statistics tap table.
Definition stat_tap_ui.h:89
_stat_tap_table_item_type::float_value
double float_value
Definition stat_tap_ui.h:101
_stat_tap_table_item_type::string_value
const char * string_value
Definition stat_tap_ui.h:100
_stat_tap_table_item_type::ptr_value
void * ptr_value
Definition stat_tap_ui.h:117
_stat_tap_table_item_type::int_value
int int_value
Definition stat_tap_ui.h:99
_stat_tap_table_item_type::enum_value
int enum_value
Definition stat_tap_ui.h:102
_stat_tap_table_item_type::user_data
union _stat_tap_table_item_type::@375074273144247024323050265261320372120336316367 user_data
Scratch space for dissector use.
_stat_tap_table_item_type::value
union _stat_tap_table_item_type::@276327366222253000250171370312060307064257221227 value
The primary value of the item.
_stat_tap_table_item_type::uint_value
unsigned uint_value
Definition stat_tap_ui.h:98
_stat_tap_table_item_type::type
stat_tap_table_item_enum type
Definition stat_tap_ui.h:90
_stat_tap_table_item
Schema descriptor for a single column in a statistics tap table.
Definition stat_tap_ui.h:133
_stat_tap_table_item::align
tap_alignment_type align
Definition stat_tap_ui.h:135
_stat_tap_table_item::column_name
const char * column_name
Definition stat_tap_ui.h:136
_stat_tap_table_item::type
stat_tap_table_item_enum type
Definition stat_tap_ui.h:134
_stat_tap_table_item::field_format
const char * field_format
Definition stat_tap_ui.h:137
_stat_tap_table_ui
Registration descriptor and runtime state for a table-based tap statistics UI.
Definition stat_tap_ui.h:156
_stat_tap_table_ui::refcount
unsigned refcount
Definition stat_tap_ui.h:198
_stat_tap_table_ui::tap_name
const char * tap_name
Definition stat_tap_ui.h:159
_stat_tap_table_ui::stat_tap_free_table_item_cb
void(* stat_tap_free_table_item_cb)(stat_tap_table *table, unsigned row, unsigned column, stat_tap_table_item_type *field_data)
Callback invoked to release resources held by a single table cell.
Definition stat_tap_ui.h:183
_stat_tap_table_ui::cli_string
const char * cli_string
Definition stat_tap_ui.h:160
_stat_tap_table_ui::packet_func
tap_packet_cb packet_func
Definition stat_tap_ui.h:168
_stat_tap_table_ui::title
const char * title
Definition stat_tap_ui.h:158
_stat_tap_table_ui::group
register_stat_group_t group
Definition stat_tap_ui.h:157
_stat_tap_table_ui::fields
stat_tap_table_item * fields
Definition stat_tap_ui.h:194
_stat_tap_table_ui::stat_tap_reset_table_cb
void(* stat_tap_reset_table_cb)(stat_tap_table *table)
Callback invoked to reset (clear) all rows in a table without freeing its schema.
Definition stat_tap_ui.h:174
_stat_tap_table_ui::nfields
size_t nfields
Definition stat_tap_ui.h:193
_stat_tap_table_ui::tables
GArray * tables
Definition stat_tap_ui.h:197
_stat_tap_table_ui::stat_filter_check_cb
void(* stat_filter_check_cb)(const char *opt_arg, const char **filter, char **err)
Callback giving the dissector a chance to validate or transform the filter string.
Definition stat_tap_ui.h:191
_stat_tap_table_ui::nparams
size_t nparams
Definition stat_tap_ui.h:195
_stat_tap_table_ui::params
tap_param * params
Definition stat_tap_ui.h:196
_stat_tap_table_ui::stat_tap_init_cb
void(* stat_tap_init_cb)(struct _stat_tap_table_ui *new_stat)
Callback invoked once to allocate and initialize the statistic's tables.
Definition stat_tap_ui.h:166
_stat_tap_table
A single statistics table instance, holding rows of tap-collected data.
Definition stat_tap_ui.h:144
_stat_tap_table::filter_string
const char * filter_string
Definition stat_tap_ui.h:146
_stat_tap_table::num_elements
unsigned num_elements
Definition stat_tap_ui.h:148
_stat_tap_table::num_fields
unsigned num_fields
Definition stat_tap_ui.h:147
_stat_tap_table::title
const char * title
Definition stat_tap_ui.h:145
_stat_tap_table::elements
stat_tap_table_item_type ** elements
Definition stat_tap_ui.h:149
_stat_tap_ui
Registration descriptor for a tap-based statistics dialog or CLI report.
Definition stat_tap_ui.h:59
_stat_tap_ui::tap_init_cb
stat_tap_init_cb tap_init_cb
Definition stat_tap_ui.h:63
_stat_tap_ui::cli_string
const char * cli_string
Definition stat_tap_ui.h:62
_stat_tap_ui::params
tap_param * params
Definition stat_tap_ui.h:65
_stat_tap_ui::group
register_stat_group_t group
Definition stat_tap_ui.h:60
_stat_tap_ui::nparams
size_t nparams
Definition stat_tap_ui.h:64
_stat_tap_ui::title
const char * title
Definition stat_tap_ui.h:61
_tap_param
Describes a single configurable parameter accepted by a tap statistic.
Definition stat_tap_ui.h:38
_tap_param::optional
bool optional
Definition stat_tap_ui.h:43
_tap_param::type
param_type type
Definition stat_tap_ui.h:39
_tap_param::enum_vals
const enum_val_t * enum_vals
Definition stat_tap_ui.h:42
_tap_param::name
const char * name
Definition stat_tap_ui.h:40
_tap_param::title
const char * title
Definition stat_tap_ui.h:41
enum_val_t
Defines a single named value within an enumerated preference or option type.
Definition params.h:16
tap.h
wmem_scopes.h