Zbee ZCL se: fix typo found by conflict hf
[metze/wireshark/wip.git] / epan / stat_tap_ui.h
1 /* stat_tap_ui.h
2  * Declarations of routines to register UI information for stats
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 #ifndef __STAT_TAP_UI_H__
24 #define __STAT_TAP_UI_H__
25
26 #include "ws_symbol_export.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 /*
33  * Parameters for taps.
34  */
35
36 #include <epan/params.h>
37 #include <epan/stat_groups.h>
38 #include <epan/packet_info.h>
39 #include <epan/tap.h>
40 #include <epan/wmem/wmem.h>
41
42 typedef enum {
43     PARAM_UINT,   /* Unused? */
44     PARAM_STRING, /* Unused? */
45     PARAM_ENUM,   /* SCSI SRT */
46     PARAM_UUID,   /* DCE-RPC. Unused? */
47     PARAM_FILTER
48 } param_type;
49
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 */
56 } tap_param;
57
58 /*
59  * UI information for a tap.
60  */
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 */
69 } stat_tap_ui;
70
71 typedef enum {
72     TABLE_ITEM_NONE = 0,
73     TABLE_ITEM_UINT,
74     TABLE_ITEM_INT,
75     TABLE_ITEM_STRING,
76     TABLE_ITEM_FLOAT,
77     TABLE_ITEM_ENUM
78 } stat_tap_table_item_enum;
79
80 typedef struct _stat_tap_table_item_type
81 {
82     stat_tap_table_item_enum type;
83     union
84     {
85         guint uint_value;
86         gint  int_value;
87         const char* string_value;
88         double float_value;
89         gint enum_value;
90     } value;
91     /* Scratch space for the dissector. Alternatively we could also add support
92      * for hidden columns. */
93     union
94     {
95         guint uint_value;
96         gint  int_value;
97         const char* string_value;
98         double float_value;
99         gint enum_value;
100         void* ptr_value;
101     } user_data;
102 } stat_tap_table_item_type;
103
104 /* Possible alignments */
105 typedef enum {
106     TAP_ALIGN_LEFT = 0,
107     TAP_ALIGN_RIGHT
108 } tap_alignment_type;
109
110 typedef struct _stat_tap_table_item
111 {
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? */
116
117 } stat_tap_table_item;
118
119
120 /* Description of a UI table */
121 typedef struct _stat_tap_table
122 {
123     const char* title;
124     const char *filter_string;        /**< append procedure number (%d) to this string to create a display filter */
125     guint num_fields;
126     guint num_elements;
127     stat_tap_table_item_type **elements;
128
129 } stat_tap_table;
130
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? */
134
135 /*
136  * UI information for a tap with a table-based UI.
137  */
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 */
154 } stat_tap_table_ui;
155
156
157 /** tap data
158  */
159 typedef struct _new_stat_data_t {
160     stat_tap_table_ui *stat_tap_data;
161     void        *user_data;       /**< "GUI" specifics (if necessary) */
162 } new_stat_data_t;
163
164
165 /** Register UI information for a tap.
166  *
167  * @param ui UI information for the tap.
168  * @param userdata Additional data for the init routine.
169  */
170 WS_DLL_PUBLIC void register_stat_tap_ui(stat_tap_ui *ui, void *userdata);
171
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);
178
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);
183
184 WS_DLL_PUBLIC stat_tap_table_ui *new_stat_tap_by_name(const char *name);
185
186 /** Free all of the tables associated with a stat_tap_table_ui.
187  *
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
190  * row.
191  *
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.
196  */
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);
198
199
200 WS_DLL_PUBLIC gboolean process_stat_cmd_arg(char *optstr);
201
202 WS_DLL_PUBLIC void list_stat_cmd_args(void);
203
204 WS_DLL_PUBLIC void start_requested_stats(void);
205
206 #ifdef __cplusplus
207 }
208 #endif /* __cplusplus */
209
210 #endif
211
212 /*
213  * Editor modelines
214  *
215  * Local Variables:
216  * c-basic-offset: 4
217  * tab-width: 8
218  * indent-tabs-mode: nil
219  * End:
220  *
221  * ex: set shiftwidth=4 tabstop=8 expandtab:
222  * :indentSize=4:tabSize=8:noTabs=true:
223  */