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 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef __STAT_TAP_UI_H__
24 #define __STAT_TAP_UI_H__
26 #include "ws_symbol_export.h"
30 #endif /* __cplusplus */
33 * Parameters for taps.
36 #include <epan/params.h>
37 #include <epan/stat_groups.h>
38 #include <epan/packet_info.h>
42 PARAM_UINT, /* Unused? */
43 PARAM_STRING, /* Unused? */
44 PARAM_ENUM, /* SCSI SRT */
45 PARAM_UUID, /* DCE-RPC. Unused? */
49 typedef struct _tap_param {
50 param_type type; /* type of parameter */
51 const char *name; /* name to use in error messages */
52 const char *title; /* title to use in GUI widgets */
53 const enum_val_t *enum_vals; /* values for PARAM_ENUM */
54 gboolean optional; /* TRUE if the parameter is optional */
58 * UI information for a tap.
60 typedef void (* stat_tap_init_cb)(const char *, void*);
61 typedef struct _stat_tap_ui {
62 register_stat_group_t group; /* group to which statistic belongs */
63 const char *title; /* title of statistic */
64 const char *cli_string; /* initial part of the "-z" argument for statistic */
65 stat_tap_init_cb tap_init_cb; /* callback to init function of the tap */
66 size_t nparams; /* number of parameters */
67 tap_param *params; /* pointer to table of parameter info */
77 } stat_tap_table_item_enum;
79 typedef struct _stat_tap_table_item_type
81 stat_tap_table_item_enum type;
86 const char* string_value;
90 /* Scratch space for the dissector. Alternatively we could also add support
91 * for hidden columns. */
96 const char* string_value;
101 } stat_tap_table_item_type;
103 /* Possible alignments */
107 } tap_alignment_type;
109 typedef struct _stat_tap_table_item
111 stat_tap_table_item_enum type;
112 tap_alignment_type align;
113 const char* column_name;
114 const char* field_format; /* printf style formating of field. Currently unused? */
116 } stat_tap_table_item;
119 /* Description of a UI table */
120 typedef struct _stat_tap_table
123 const char *filter_string; /**< append procedure number (%d) to this string to create a display filter */
126 stat_tap_table_item_type **elements;
130 typedef void (*new_stat_tap_gui_init_cb)(stat_tap_table* stat_table, void* gui_data); /* GTK+ only? */
131 typedef void (*new_stat_tap_gui_reset_cb)(stat_tap_table* stat_table, void* gui_data); /* GTK+ only? */
132 typedef void (*new_stat_tap_gui_free_cb)(stat_tap_table* stat_table, void* gui_data); /* GTK+ only? */
135 * UI information for a tap with a table-based UI.
137 typedef struct _stat_tap_table_ui {
138 register_stat_group_t group; /* group to which statistic belongs */
139 const char *title; /* title of statistic */
140 const char *tap_name;
141 const char *cli_string; /* initial part of the "-z" argument for statistic */
142 void (* stat_tap_init_cb)(struct _stat_tap_table_ui* new_stat, new_stat_tap_gui_init_cb gui_callback, void* gui_data);
143 tap_packet_cb packet_func;
144 void (* stat_tap_reset_table_cb)(stat_tap_table* table);
145 void (* stat_tap_free_table_item_cb)(stat_tap_table* table, guint row, guint column, stat_tap_table_item_type* field_data);
146 void (* stat_filter_check_cb)(const char *opt_arg, const char **filter, char** err); /* Dissector chance to reject filter */
147 size_t nfields; /* number of fields */
148 stat_tap_table_item* fields;
149 size_t nparams; /* number of parameters */
150 tap_param *params; /* pointer to table of parameter info */
151 GArray *tables; /* An array of stat_tap_table* */
157 typedef struct _new_stat_data_t {
158 stat_tap_table_ui *stat_tap_data;
159 void *user_data; /**< "GUI" specifics (if necessary) */
163 /** Register UI information for a tap.
165 * @param ui UI information for the tap.
166 * @param userdata Additional data for the init routine.
168 WS_DLL_PUBLIC void register_stat_tap_ui(stat_tap_ui *ui, void *userdata);
170 WS_DLL_PUBLIC void register_stat_tap_table_ui(stat_tap_table_ui *ui);
171 WS_DLL_PUBLIC void new_stat_tap_iterate_tables(GFunc func, gpointer user_data);
172 WS_DLL_PUBLIC void new_stat_tap_get_filter(stat_tap_table_ui* new_stat, const char *opt_arg, const char **filter, char** err);
173 WS_DLL_PUBLIC stat_tap_table* new_stat_tap_init_table(const char *name, int num_fields, int num_elements,
174 const char *filter_string, new_stat_tap_gui_init_cb gui_callback, void* gui_data);
175 WS_DLL_PUBLIC void new_stat_tap_add_table(stat_tap_table_ui* new_stat, stat_tap_table* table);
177 WS_DLL_PUBLIC void new_stat_tap_init_table_row(stat_tap_table *stat_table, guint table_index, guint num_fields, const stat_tap_table_item_type* fields);
178 WS_DLL_PUBLIC stat_tap_table_item_type* new_stat_tap_get_field_data(const stat_tap_table *stat_table, guint table_index, guint field_index);
179 WS_DLL_PUBLIC void new_stat_tap_set_field_data(stat_tap_table *stat_table, guint table_index, guint field_index, stat_tap_table_item_type* field_data);
180 WS_DLL_PUBLIC void reset_stat_table(stat_tap_table_ui* new_stat, new_stat_tap_gui_reset_cb gui_callback, void *callback_data);
182 /** Free all of the tables associated with a stat_tap_table_ui.
184 * Frees data created by stat_tap_ui.stat_tap_init_cb.
185 * stat_tap_table_ui.stat_tap_free_table_item_cb is called for each index in each
188 * @param new_stat Parent stat_tap_table_ui struct, provided by the dissector.
189 * @param gui_callback Per-table callback, run before rows are removed.
190 * Provided by the UI.
191 * @param callback_data Data for the per-table callback.
193 WS_DLL_PUBLIC void free_stat_tables(stat_tap_table_ui* new_stat, new_stat_tap_gui_free_cb gui_callback, void *callback_data);
196 WS_DLL_PUBLIC gboolean process_stat_cmd_arg(char *optstr);
198 WS_DLL_PUBLIC void list_stat_cmd_args(void);
200 WS_DLL_PUBLIC void start_requested_stats(void);
204 #endif /* __cplusplus */
214 * indent-tabs-mode: nil
217 * ex: set shiftwidth=4 tabstop=8 expandtab:
218 * :indentSize=4:tabSize=8:noTabs=true: