update epan/dissectors/pidl/drsuapi/drsuapi.idl from samba
[wireshark-sm.git] / epan / stat_tap_ui.h
blob9fe8aca6385289aef5661f0546ca8a97fd1d8c0c
1 /** @file
2 * Declarations of routines to register UI information for stats
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 #ifndef __STAT_TAP_UI_H__
12 #define __STAT_TAP_UI_H__
14 #include "ws_symbol_export.h"
16 #include <epan/params.h>
17 #include <epan/stat_groups.h>
18 #include <epan/packet_info.h>
19 #include <epan/tap.h>
20 #include <epan/wmem_scopes.h>
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
27 * Parameters for taps.
30 typedef enum {
31 PARAM_UINT, /* Unused? */
32 PARAM_STRING, /* Unused? */
33 PARAM_ENUM, /* SCSI SRT */
34 PARAM_UUID, /* DCE-RPC. Unused? */
35 PARAM_FILTER
36 } param_type;
38 typedef struct _tap_param {
39 param_type type; /* type of parameter */
40 const char *name; /* name to use in error messages */
41 const char *title; /* title to use in GUI widgets */
42 const enum_val_t *enum_vals; /* values for PARAM_ENUM */
43 bool optional; /* true if the parameter is optional */
44 } tap_param;
47 * UI information for a tap.
49 typedef void (* stat_tap_init_cb)(const char *, void*);
50 typedef struct _stat_tap_ui {
51 register_stat_group_t group; /* group to which statistic belongs */
52 const char *title; /* title of statistic */
53 const char *cli_string; /* initial part of the "-z" argument for statistic */
54 stat_tap_init_cb tap_init_cb; /* callback to init function of the tap */
55 size_t nparams; /* number of parameters */
56 tap_param *params; /* pointer to table of parameter info */
57 } stat_tap_ui;
59 typedef enum {
60 TABLE_ITEM_NONE = 0,
61 TABLE_ITEM_UINT,
62 TABLE_ITEM_INT,
63 TABLE_ITEM_STRING,
64 TABLE_ITEM_FLOAT,
65 TABLE_ITEM_ENUM
66 } stat_tap_table_item_enum;
68 typedef struct _stat_tap_table_item_type
70 stat_tap_table_item_enum type;
71 union
73 unsigned uint_value;
74 int int_value;
75 const char* string_value;
76 double float_value;
77 int enum_value;
78 } value;
79 /* Scratch space for the dissector. Alternatively we could also add support
80 * for hidden columns. */
81 union
83 unsigned uint_value;
84 int int_value;
85 const char* string_value;
86 double float_value;
87 int enum_value;
88 void* ptr_value;
89 } user_data;
90 } stat_tap_table_item_type;
92 /* Possible alignments */
93 typedef enum {
94 TAP_ALIGN_LEFT = 0,
95 TAP_ALIGN_RIGHT
96 } tap_alignment_type;
98 typedef struct _stat_tap_table_item
100 stat_tap_table_item_enum type;
101 tap_alignment_type align;
102 const char* column_name;
103 const char* field_format; /* printf style formating of field. Currently unused? */
105 } stat_tap_table_item;
108 /* Description of a UI table */
109 typedef struct _stat_tap_table
111 const char* title;
112 const char *filter_string; /**< append procedure number (%d) to this string to create a display filter */
113 unsigned num_fields;
114 unsigned num_elements;
115 stat_tap_table_item_type **elements;
117 } stat_tap_table;
120 * UI information for a tap with a table-based UI.
122 typedef struct _stat_tap_table_ui {
123 register_stat_group_t group; /* group to which statistic belongs */
124 const char *title; /* title of statistic */
125 const char *tap_name;
126 const char *cli_string; /* initial part of the "-z" argument for statistic */
127 void (* stat_tap_init_cb)(struct _stat_tap_table_ui* new_stat);
128 tap_packet_cb packet_func;
129 void (* stat_tap_reset_table_cb)(stat_tap_table* table);
130 void (* stat_tap_free_table_item_cb)(stat_tap_table* table, unsigned row, unsigned column, stat_tap_table_item_type* field_data);
131 void (* stat_filter_check_cb)(const char *opt_arg, const char **filter, char** err); /* Dissector chance to reject filter */
132 size_t nfields; /* number of fields */
133 stat_tap_table_item* fields;
134 size_t nparams; /* number of parameters */
135 tap_param *params; /* pointer to table of parameter info */
136 GArray *tables; /* An array of stat_tap_table* */
137 unsigned refcount; /* a reference count for deallocation */
138 } stat_tap_table_ui;
141 /** tap data
143 typedef struct _stat_data_t {
144 stat_tap_table_ui *stat_tap_data;
145 void *user_data; /**< "GUI" specifics (if necessary) */
146 } stat_data_t;
149 /** Register UI information for a tap.
151 * @param ui UI information for the tap.
152 * @param userdata Additional data for the init routine.
154 WS_DLL_PUBLIC void register_stat_tap_ui(stat_tap_ui *ui, void *userdata);
156 WS_DLL_PUBLIC void register_stat_tap_table_ui(stat_tap_table_ui *ui);
157 WS_DLL_PUBLIC void stat_tap_iterate_tables(wmem_foreach_func func, void *user_data);
158 WS_DLL_PUBLIC void stat_tap_get_filter(stat_tap_table_ui* new_stat, const char *opt_arg, const char **filter, char** err);
159 WS_DLL_PUBLIC stat_tap_table* stat_tap_init_table(const char *name, int num_fields, int num_elements,
160 const char *filter_string);
161 WS_DLL_PUBLIC void stat_tap_add_table(stat_tap_table_ui* new_stat, stat_tap_table* table);
162 WS_DLL_PUBLIC stat_tap_table *stat_tap_find_table(stat_tap_table_ui *ui, const char *name);
163 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);
164 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);
165 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);
166 WS_DLL_PUBLIC void reset_stat_table(stat_tap_table_ui* new_stat);
168 WS_DLL_PUBLIC stat_tap_table_ui *stat_tap_by_name(const char *name);
170 /** Free all of the tables associated with a stat_tap_table_ui.
172 * Frees data created by stat_tap_ui.stat_tap_init_cb.
173 * stat_tap_table_ui.stat_tap_free_table_item_cb is called for each index in each
174 * row.
176 * @param new_stat Parent stat_tap_table_ui struct, provided by the dissector.
178 WS_DLL_PUBLIC void free_stat_tables(stat_tap_table_ui* new_stat);
181 WS_DLL_PUBLIC bool process_stat_cmd_arg(const char *optstr);
183 WS_DLL_PUBLIC void list_stat_cmd_args(void);
185 WS_DLL_PUBLIC void start_requested_stats(void);
187 #ifdef __cplusplus
189 #endif /* __cplusplus */
191 #endif
194 * Editor modelines
196 * Local Variables:
197 * c-basic-offset: 4
198 * tab-width: 8
199 * indent-tabs-mode: nil
200 * End:
202 * ex: set shiftwidth=4 tabstop=8 expandtab:
203 * :indentSize=4:tabSize=8:noTabs=true: