Wireshark 4.7.0
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
20extern "C" {
21#endif /* __cplusplus */
22
23/*
24 * Parameters for taps.
25 */
26
27typedef enum {
28 PARAM_UINT, /* Unused? */
29 PARAM_STRING, /* Unused? */
30 PARAM_ENUM, /* SCSI SRT */
31 PARAM_UUID, /* DCE-RPC. Unused? */
32 PARAM_FILTER
33} param_type;
34
35typedef struct _tap_param {
36 param_type type; /* type of parameter */
37 const char *name; /* name to use in error messages */
38 const char *title; /* title to use in GUI widgets */
39 const enum_val_t *enum_vals; /* values for PARAM_ENUM */
40 bool optional; /* true if the parameter is optional */
41} tap_param;
42
43/*
44 * UI information for a tap.
45 */
46typedef bool (* stat_tap_init_cb)(const char *, void*);
47typedef struct _stat_tap_ui {
48 register_stat_group_t group; /* group to which statistic belongs */
49 const char *title; /* title of statistic */
50 const char *cli_string; /* initial part of the "-z" argument for statistic */
51 stat_tap_init_cb tap_init_cb; /* callback to init function of the tap */
52 size_t nparams; /* number of parameters */
53 tap_param *params; /* pointer to table of parameter info */
55
56typedef enum {
57 TABLE_ITEM_NONE = 0,
58 TABLE_ITEM_UINT,
59 TABLE_ITEM_INT,
60 TABLE_ITEM_STRING,
61 TABLE_ITEM_FLOAT,
62 TABLE_ITEM_ENUM
63} stat_tap_table_item_enum;
64
73{
74 stat_tap_table_item_enum type;
81 union {
82 unsigned uint_value;
84 const char* string_value;
85 double float_value;
88
95 union {
96 unsigned uint_value;
97 int int_value;
98 const char* string_value;
99 double float_value;
100 int enum_value;
101 void* ptr_value;
104
105/* Possible alignments */
106typedef enum {
107 TAP_ALIGN_LEFT = 0,
108 TAP_ALIGN_RIGHT
109} tap_alignment_type;
110
112{
113 stat_tap_table_item_enum type;
114 tap_alignment_type align;
115 const char* column_name;
116 const char* field_format; /* printf style formatting of field. */
117
119
120
121/* Description of a UI table */
122typedef struct _stat_tap_table
123{
124 const char* title;
125 const char *filter_string;
126 unsigned num_fields;
127 unsigned num_elements;
128 stat_tap_table_item_type **elements;
129
131
132/*
133 * UI information for a tap with a table-based UI.
134 */
135typedef struct _stat_tap_table_ui {
136 register_stat_group_t group; /* group to which statistic belongs */
137 const char *title; /* title of statistic */
138 const char *tap_name;
139 const char *cli_string; /* initial part of the "-z" argument for statistic */
140 void (* stat_tap_init_cb)(struct _stat_tap_table_ui* new_stat);
141 tap_packet_cb packet_func;
142 void (* stat_tap_reset_table_cb)(stat_tap_table* table);
143 void (* stat_tap_free_table_item_cb)(stat_tap_table* table, unsigned row, unsigned column, stat_tap_table_item_type* field_data);
144 void (* stat_filter_check_cb)(const char *opt_arg, const char **filter, char** err); /* Dissector chance to reject filter */
145 size_t nfields; /* number of fields */
146 stat_tap_table_item* fields;
147 size_t nparams; /* number of parameters */
148 tap_param *params; /* pointer to table of parameter info */
149 GArray *tables; /* An array of stat_tap_table* */
150 unsigned refcount; /* a reference count for deallocation */
152
153
156typedef struct _stat_data_t {
157 stat_tap_table_ui *stat_tap_data;
158 void *user_data;
160
165extern void stat_tap_init(void);
166
172WS_DLL_PUBLIC void register_stat_tap_ui(stat_tap_ui *ui, void *userdata);
173
174WS_DLL_PUBLIC void register_stat_tap_table_ui(stat_tap_table_ui *ui);
175WS_DLL_PUBLIC void stat_tap_iterate_tables(wmem_foreach_func func, void *user_data);
176WS_DLL_PUBLIC void stat_tap_get_filter(stat_tap_table_ui* new_stat, const char *opt_arg, const char **filter, char** err);
177WS_DLL_PUBLIC stat_tap_table* stat_tap_init_table(const char *name, int num_fields, int num_elements,
178 const char *filter_string);
179
186WS_DLL_PUBLIC void stat_tap_add_table(stat_tap_table_ui* new_stat, stat_tap_table* table);
187
195WS_DLL_PUBLIC stat_tap_table *stat_tap_find_table(stat_tap_table_ui *ui, const char *name);
196WS_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);
197WS_DLL_PUBLIC stat_tap_table_item_type* stat_tap_get_field_data(const stat_tap_table *stat_table, unsigned table_index, unsigned field_index);
198
207WS_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);
208WS_DLL_PUBLIC void reset_stat_table(stat_tap_table_ui* new_stat);
209
210WS_DLL_PUBLIC stat_tap_table_ui *stat_tap_by_name(const char *name);
211
221WS_DLL_PUBLIC void free_stat_tables(stat_tap_table_ui* new_stat);
222
229WS_DLL_PUBLIC bool process_stat_cmd_arg(const char *optstr);
230
236WS_DLL_PUBLIC void list_stat_cmd_args(void);
237
245WS_DLL_PUBLIC bool start_requested_stats(void);
246
247#ifdef __cplusplus
248}
249#endif /* __cplusplus */
250
251/*
252 * Editor modelines
253 *
254 * Local Variables:
255 * c-basic-offset: 4
256 * tab-width: 8
257 * indent-tabs-mode: nil
258 * End:
259 *
260 * ex: set shiftwidth=4 tabstop=8 expandtab:
261 * :indentSize=4:tabSize=8:noTabs=true:
262 */
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
enum register_stat_group_e register_stat_group_t
WS_DLL_PUBLIC void register_stat_tap_ui(stat_tap_ui *ui, void *userdata)
Definition stat_tap_ui.c:68
WS_DLL_PUBLIC bool start_requested_stats(void)
Start requested statistics.
Definition stat_tap_ui.c:136
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
struct _stat_data_t stat_data_t
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
WS_DLL_PUBLIC bool process_stat_cmd_arg(const char *optstr)
Processes a command argument for statistics.
Definition stat_tap_ui.c:88
void stat_tap_init(void)
Initializes the statistics tap system, setting up necessary data structures.
Definition stat_tap_ui.c:61
WS_DLL_PUBLIC void list_stat_cmd_args(void)
List command-line arguments for requested statistics.
Definition stat_tap_ui.c:127
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
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
struct _stat_tap_table_item_type stat_tap_table_item_type
Represents a single item in a statistics tap table.
Definition stat_tap_ui.h:156
void * user_data
Definition stat_tap_ui.h:158
Represents a single item in a statistics tap table.
Definition stat_tap_ui.h:73
double float_value
Definition stat_tap_ui.h:85
const char * string_value
Definition stat_tap_ui.h:84
void * ptr_value
Definition stat_tap_ui.h:101
union _stat_tap_table_item_type::@491 value
The primary value of the item.
int int_value
Definition stat_tap_ui.h:83
int enum_value
Definition stat_tap_ui.h:86
unsigned uint_value
Definition stat_tap_ui.h:82
stat_tap_table_item_enum type
Definition stat_tap_ui.h:74
union _stat_tap_table_item_type::@492 user_data
Scratch space for dissector use.
Definition stat_tap_ui.h:112
Definition stat_tap_ui.h:135
Definition stat_tap_ui.h:123
const char * filter_string
Definition stat_tap_ui.h:125
Definition stat_tap_ui.h:47
Definition stat_tap_ui.h:35
Definition params.h:20