Include packet-dcerpc-witness.h, so it's in the source tarball.
[metze/wireshark/wip.git] / epan / rtd_table.h
1 /* rtd_table.h
2  * GUI independent helper routines common to all Response Time Delay (RTD) taps.
3  * Based on srt_table.h
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23
24 #ifndef __RTD_TABLE_H__
25 #define __RTD_TABLE_H__
26
27 #include "tap.h"
28 #include "timestats.h"
29 #include "value_string.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34
35 typedef struct _rtd_timestat {
36         guint num_timestat;              /**< number of elements on rtd array */
37         timestat_t* rtd;
38         guint32 open_req_num;
39         guint32 disc_rsp_num;
40         guint32 req_dup_num;
41         guint32 rsp_dup_num;
42 } rtd_timestat;
43
44 /** Statistics table */
45 typedef struct _rtd_stat_table {
46         char *filter;
47         guint num_rtds;              /**< number of elements on time_stats array */
48         rtd_timestat* time_stats;
49 } rtd_stat_table;
50
51 /** tap data
52  */
53 typedef struct _rtd_data_t {
54         rtd_stat_table  stat_table;  /**< RTD table data */
55         void        *user_data;       /**< "GUI" specifics (GTK+ only) */
56 } rtd_data_t;
57
58 /** Structure for information about a registered service response table */
59 struct register_rtd;
60 typedef struct register_rtd register_rtd_t;
61
62 typedef void (*rtd_gui_init_cb)(rtd_stat_table* rtd, void* gui_data);
63 typedef void (*rtd_gui_reset_cb)(rtd_stat_table* rtd, void* gui_data); /* GTK+ only. */
64 typedef void (*rtd_gui_free_cb)(rtd_stat_table* rtd, void* gui_data); /* GTK+ only. */
65 typedef void (*rtd_init_cb)(struct register_rtd* rtd, rtd_gui_init_cb gui_callback, void* gui_data); /* GTK+ only. */
66 typedef void (*rtd_filter_check_cb)(const char *opt_arg, const char **filter, char** err);
67
68 /** Register the response time delay table.
69  *
70  * @param proto_id is the protocol with conversation
71  * @param tap_listener string for register_tap_listener (NULL to just use protocol name)
72  * @param num_tables number of tables
73  * @param num_timestats number of timestamps in the table
74  * @param vs_type value_string for the stat types
75  * @param rtd_packet_func the tap processing function
76  * @param filter_check_cb callback for verification of filter or other dissector checks
77  */
78 WS_DLL_PUBLIC void register_rtd_table(const int proto_id, const char* tap_listener, guint num_tables, guint num_timestats, const value_string* vs_type,
79                                       tap_packet_cb rtd_packet_func, rtd_filter_check_cb filter_check_cb);
80
81 /** Get protocol ID from RTD
82  *
83  * @param rtd Registered RTD
84  * @return protocol id of RTD
85  */
86 WS_DLL_PUBLIC int get_rtd_proto_id(register_rtd_t* rtd);
87
88 /** Get string for register_tap_listener call. Typically just dissector name
89  *
90  * @param rtd Registered RTD
91  * @return string for register_tap_listener call
92  */
93 WS_DLL_PUBLIC const char* get_rtd_tap_listener_name(register_rtd_t* rtd);
94
95 /** Get tap function handler from RTD
96  *
97  * @param rtd Registered RTD
98  * @return tap function handler of RTD
99  */
100 WS_DLL_PUBLIC tap_packet_cb get_rtd_packet_func(register_rtd_t* rtd);
101
102 /** Get the number of RTD tables
103  *
104  * @param rtd Registered RTD
105  * @return The number of registered tables.
106  */
107 WS_DLL_PUBLIC guint get_rtd_num_tables(register_rtd_t* rtd);
108
109 /** Get value_string used for RTD
110  *
111  * @param rtd Registered RTD
112  * @return value_string of RTD
113  */
114 WS_DLL_PUBLIC const value_string* get_rtd_value_string(register_rtd_t* rtd);
115
116 /** Get RTD table by its dissector name
117  *
118  * @param name dissector name to fetch.
119  * @return RTD table pointer or NULL.
120  */
121 WS_DLL_PUBLIC register_rtd_t* get_rtd_table_by_name(const char* name);
122
123 /** Free the RTD table data.
124  *
125  * @param table RTD stat table array
126  * @param gui_callback optional callback from GUI
127  * @param callback_data callback data needed for GUI
128  */
129 WS_DLL_PUBLIC void free_rtd_table(rtd_stat_table* table, rtd_gui_free_cb gui_callback, void *callback_data);
130
131 /** Reset table data in the RTD.
132  *
133  * @param table RTD table
134  * @param gui_callback optional callback from GUI
135  * @param callback_data callback data needed for GUI
136  */
137 WS_DLL_PUBLIC void reset_rtd_table(rtd_stat_table* table, rtd_gui_reset_cb gui_callback, void *callback_data);
138
139 /** Interator to walk RTD tables and execute func
140  * Used for initialization
141  *
142  * @param func action to be performed on all converation tables
143  * @param user_data any data needed to help perform function
144  */
145 WS_DLL_PUBLIC void rtd_table_iterate_tables(GFunc func, gpointer user_data);
146
147 /** Return filter used for register_tap_listener
148  *
149  * @param rtd Registered RTD
150  * @param opt_arg passed in opt_arg from GUI
151  * @param filter returned filter string to be used for registering tap
152  * @param err returned error if opt_arg string can't be successfully handled. Caller must free memory
153  */
154 WS_DLL_PUBLIC void rtd_table_get_filter(register_rtd_t* rtd, const char *opt_arg, const char **filter, char** err);
155
156 /** "Common" initialization function for all GUIs
157  *
158  * @param rtd Registered RTD
159  * @param table RTD table
160  * @param gui_callback optional GUI callback function
161  * @param callback_data optional GUI callback data
162  */
163 WS_DLL_PUBLIC void rtd_table_dissector_init(register_rtd_t* rtd, rtd_stat_table* table, rtd_gui_init_cb gui_callback, void *callback_data);
164
165 /** Helper function to get tap string name
166  * Caller is responsible for freeing returned string
167  *
168  * @param rtd Registered RTD
169  * @return RTD tap string
170  */
171 WS_DLL_PUBLIC gchar* rtd_table_get_tap_string(register_rtd_t* rtd);
172
173 #ifdef __cplusplus
174 }
175 #endif /* __cplusplus */
176
177 #endif /* __RTD_TABLE_H__ */
178
179 /*
180  * Editor modelines
181  *
182  * Local Variables:
183  * c-basic-offset: 4
184  * tab-width: 8
185  * indent-tabs-mode: nil
186  * End:
187  *
188  * ex: set shiftwidth=4 tabstop=8 expandtab:
189  * :indentSize=4:tabSize=8:noTabs=true:
190  */