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>
40 #include <epan/wmem/wmem.h>
43 PARAM_UINT, /* Unused? */
44 PARAM_STRING, /* Unused? */
45 PARAM_ENUM, /* SCSI SRT */
46 PARAM_UUID, /* DCE-RPC. Unused? */
50 typedef struct _tap_param {
51 param_type type; /* type of parameter */
52 const char *name; /* name to use in error messages */
53 const char *title; /* title to use in GUI widgets */
54 const enum_val_t *enum_vals; /* values for PARAM_ENUM */
55 gboolean optional; /* TRUE if the parameter is optional */
59 * UI information for a tap.
61 typedef void (* stat_tap_init_cb)(const char *, void*);
62 typedef struct _stat_tap_ui {
63 register_stat_group_t group; /* group to which statistic belongs */
64 const char *title; /* title of statistic */
65 const char *cli_string; /* initial part of the "-z" argument for statistic */
66 stat_tap_init_cb tap_init_cb; /* callback to init function of the tap */
67 size_t nparams; /* number of parameters */
68 tap_param *params; /* pointer to table of parameter info */
78 } stat_tap_table_item_enum;
80 typedef struct _stat_tap_table_item_type
82 stat_tap_table_item_enum type;
87 const char* string_value;
91 /* Scratch space for the dissector. Alternatively we could also add support
92 * for hidden columns. */
97 const char* string_value;
102 } stat_tap_table_item_type;
104 /* Possible alignments */
108 } tap_alignment_type;
110 typedef struct _stat_tap_table_item
112 stat_tap_table_item_enum type;
113 tap_alignment_type align;
114 const char* column_name;
115 const char* field_format; /* printf style formating of field. Currently unused? */
117 } stat_tap_table_item;
120 /* Description of a UI table */
121 typedef struct _stat_tap_table
124 const char *filter_string; /**< append procedure number (%d) to this string to create a display filter */
127 stat_tap_table_item_type **elements;
131 typedef void (*new_stat_tap_gui_init_cb)(stat_tap_table* stat_table, void* gui_data); /* GTK+ only? */
132 typedef void (*new_stat_tap_gui_reset_cb)(stat_tap_table* stat_table, void* gui_data); /* GTK+ only? */
133 typedef void (*new_stat_tap_gui_free_cb)(stat_tap_table* stat_table, void* gui_data); /* GTK+ only? */
136 * UI information for a tap with a table-based UI.
138 typedef struct _stat_tap_table_ui {
139 register_stat_group_t group; /* group to which statistic belongs */
140 const char *title; /* title of statistic */
141 const char *tap_name;
142 const char *cli_string; /* initial part of the "-z" argument for statistic */
143 void (* stat_tap_init_cb)(struct _stat_tap_table_ui* new_stat, new_stat_tap_gui_init_cb gui_callback, void* gui_data);
144 tap_packet_cb packet_func;
145 void (* stat_tap_reset_table_cb)(stat_tap_table* table);
146 void (* stat_tap_free_table_item_cb)(stat_tap_table* table, guint row, guint column, stat_tap_table_item_type* field_data);
147 void (* stat_filter_check_cb)(const char *opt_arg, const char **filter, char** err); /* Dissector chance to reject filter */
148 size_t nfields; /* number of fields */
149 stat_tap_table_item* fields;
150 size_t nparams; /* number of parameters */
151 tap_param *params; /* pointer to table of parameter info */
152 GArray *tables; /* An array of stat_tap_table* */
153 guint refcount; /* a reference count for deallocation */
159 typedef struct _new_stat_data_t {
160 stat_tap_table_ui *stat_tap_data;
161 void *user_data; /**< "GUI" specifics (if necessary) */
165 /** Register UI information for a tap.
167 * @param ui UI information for the tap.
168 * @param userdata Additional data for the init routine.
170 WS_DLL_PUBLIC void register_stat_tap_ui(stat_tap_ui *ui, void *userdata);
172 WS_DLL_PUBLIC void register_stat_tap_table_ui(stat_tap_table_ui *ui);
173 WS_DLL_PUBLIC void new_stat_tap_iterate_tables(wmem_foreach_func func, gpointer user_data);
174 WS_DLL_PUBLIC void new_stat_tap_get_filter(stat_tap_table_ui* new_stat, const char *opt_arg, const char **filter, char** err);
175 WS_DLL_PUBLIC stat_tap_table* new_stat_tap_init_table(const char *name, int num_fields, int num_elements,
176 const char *filter_string, new_stat_tap_gui_init_cb gui_callback, void* gui_data);
177 WS_DLL_PUBLIC void new_stat_tap_add_table(stat_tap_table_ui* new_stat, stat_tap_table* table);
179 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);
180 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);
181 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);
182 WS_DLL_PUBLIC void reset_stat_table(stat_tap_table_ui* new_stat, new_stat_tap_gui_reset_cb gui_callback, void *callback_data);
184 WS_DLL_PUBLIC stat_tap_table_ui *new_stat_tap_by_name(const char *name);
186 /** Free all of the tables associated with a stat_tap_table_ui.
188 * Frees data created by stat_tap_ui.stat_tap_init_cb.
189 * stat_tap_table_ui.stat_tap_free_table_item_cb is called for each index in each
192 * @param new_stat Parent stat_tap_table_ui struct, provided by the dissector.
193 * @param gui_callback Per-table callback, run before rows are removed.
194 * Provided by the UI.
195 * @param callback_data Data for the per-table callback.
197 WS_DLL_PUBLIC void free_stat_tables(stat_tap_table_ui* new_stat, new_stat_tap_gui_free_cb gui_callback, void *callback_data);
200 WS_DLL_PUBLIC gboolean process_stat_cmd_arg(char *optstr);
202 WS_DLL_PUBLIC void list_stat_cmd_args(void);
204 WS_DLL_PUBLIC void start_requested_stats(void);
208 #endif /* __cplusplus */
218 * indent-tabs-mode: nil
221 * ex: set shiftwidth=4 tabstop=8 expandtab:
222 * :indentSize=4:tabSize=8:noTabs=true: