2 * GUI independent helper routines common to all service response time (SRT) taps.
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 __SRT_TABLE_H__
24 #define __SRT_TABLE_H__
27 #include "timestats.h"
31 #endif /* __cplusplus */
34 typedef struct _srt_procedure_t {
36 timestat_t stats; /**< stats */
37 char *procedure; /**< column entries */
40 /** Statistics table */
41 typedef struct _srt_stat_table {
42 const char *name; /**< table name */
43 const char *short_name; /**< tab name */
44 char *filter_string; /**< append procedure number (%d) to this string
45 to create a display filter */
46 int num_procs; /**< number of elements on procedures array */
47 const char *proc_column_name; /**< procedure column name (if different from default) */
48 srt_procedure_t *procedures;/**< the procedures array */
49 void* table_specific_data; /** any dissector/table specific data needed for packet filtering */
54 typedef void (*srt_gui_init_cb)(srt_stat_table* rst, void* gui_data); /* GTK+ only? */
55 typedef void (*srt_gui_reset_cb)(srt_stat_table* rst, void* gui_data); /* GTK+ only? */
56 typedef void (*srt_gui_free_cb)(srt_stat_table* rst, void* gui_data); /* GTK+ only? */
57 typedef void (*srt_proc_table_cb)(srt_stat_table* rst, int indx, struct _srt_data_t* gui_data);
58 typedef void (*srt_init_cb)(struct register_srt* srt, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data);
59 typedef guint (*srt_param_handler_cb)(struct register_srt* srt, const char* opt_arg, char** err);
63 typedef struct _srt_data_t {
64 GArray *srt_array; /**< array of srt_stat_table */
65 void *user_data; /**< "GUI" specifics (if necessary) */
68 /** Structure for information about a registered service response table */
69 typedef struct register_srt register_srt_t;
71 /** Register the service response time table for the srt windows.
73 * @param proto_id is the protocol with conversation
74 * @param tap_listener string for register_tap_listener (NULL to just use protocol name)
75 * @param max_tables maximum number of tables
76 * @param srt_packet_func the tap processing function
77 * @param init_cb initialize dissector SRT function
78 * @param param_cb handles dissection of parameters to optional arguments of tap string
80 WS_DLL_PUBLIC void register_srt_table(const int proto_id, const char* tap_listener, int max_tables,
81 tap_packet_cb srt_packet_func, srt_init_cb init_cb, srt_param_handler_cb param_cb);
83 /** Get protocol ID from SRT
85 * @param srt Registered SRT
86 * @return protocol id of SRT
88 WS_DLL_PUBLIC int get_srt_proto_id(register_srt_t* srt);
90 /** Get string for register_tap_listener call. Typically just dissector name
92 * @param srt Registered SRT
93 * @return string for register_tap_listener call
95 WS_DLL_PUBLIC const char* get_srt_tap_listener_name(register_srt_t* srt);
97 /** Get maximum number of tables from SRT
99 * @param srt Registered SRT
100 * @return maximum number of tables of SRT
102 WS_DLL_PUBLIC int get_srt_max_tables(register_srt_t* srt);
104 /** Get tap function handler from SRT
106 * @param srt Registered SRT
107 * @return tap function handler of SRT
109 WS_DLL_PUBLIC tap_packet_cb get_srt_packet_func(register_srt_t* srt);
111 /** Set parameter data from SRT parsed from tap string. Data will be
114 * @param srt Registered SRT
115 * @param data Parameter data
117 WS_DLL_PUBLIC void set_srt_table_param_data(register_srt_t* srt, void* data);
119 /** Get parameter data from SRT
121 * @param srt Registered SRT
122 * @return Parameter data
124 WS_DLL_PUBLIC void* get_srt_table_param_data(register_srt_t* srt);
126 /** Get SRT table by its dissector name
128 * @param name dissector name to fetch.
129 * @return SRT table pointer or NULL.
131 WS_DLL_PUBLIC register_srt_t* get_srt_table_by_name(const char* name);
133 /** Free the srt table data.
135 * @param rst the srt table
137 WS_DLL_PUBLIC void free_srt_table_data(srt_stat_table *rst);
139 /** Free the srt table data.
141 * @param srt Registered SRT
142 * @param srt_array SRT table array
143 * @param gui_callback optional callback from GUI
144 * @param callback_data callback data needed for GUI
146 WS_DLL_PUBLIC void free_srt_table(register_srt_t *srt, GArray* srt_array, srt_gui_free_cb gui_callback, void *callback_data);
148 /** Reset ALL tables in the srt.
150 * @param srt_array SRT table array
151 * @param gui_callback optional callback from GUI
152 * @param callback_data callback data needed for GUI
154 WS_DLL_PUBLIC void reset_srt_table(GArray* srt_array, srt_gui_reset_cb gui_callback, void *callback_data);
156 /** Interator to walk srt tables and execute func
157 * Used for initialization
159 * @param func action to be performed on all converation tables
160 * @param user_data any data needed to help perform function
162 WS_DLL_PUBLIC void srt_table_iterate_tables(GFunc func, gpointer user_data);
164 /** Return filter used for register_tap_listener
166 * @param srt Registered SRT
167 * @param opt_arg passed in opt_arg from GUI
168 * @param filter returned filter string to be used for registering tap
169 * @param err returned error if opt_arg string can't be successfully parsed. Caller must free memory
171 WS_DLL_PUBLIC void srt_table_get_filter(register_srt_t* srt, const char *opt_arg, const char **filter, char** err);
173 /** "Common" initialization function for all GUIs
175 * @param srt Registered SRT
176 * @param srt_array SRT table array
177 * @param gui_callback optional callback from GUI
178 * @param callback_data callback data needed for GUI
180 WS_DLL_PUBLIC void srt_table_dissector_init(register_srt_t* srt, GArray* srt_array, srt_gui_init_cb gui_callback, void *callback_data);
182 /** Helper function to get tap string name
183 * Caller is responsible for freeing returned string
185 * @param srt Registered SRT
186 * @return SRT tap string
188 WS_DLL_PUBLIC gchar* srt_table_get_tap_string(register_srt_t* srt);
190 /** Init an srt table data structure.
192 * @param name the table name
193 * @param short_name the name used in a tab display
194 * @param srt_array the srt table array to add to
195 * @param num_procs number of procedures
196 * @param proc_column_name procedure column name (if different from "Procedure")
197 * @param filter_string table filter string or NULL
198 * @param gui_callback optional GUI callback
199 * @param gui_data GUI content data
200 * @param table_specific_data Table specific data
201 * @return newly created srt_stat_table
203 WS_DLL_PUBLIC srt_stat_table* init_srt_table(const char *name, const char *short_name, GArray *srt_array, int num_procs, const char* proc_column_name,
204 const char *filter_string, srt_gui_init_cb gui_callback, void* gui_data, void* table_specific_data);
206 /** Init an srt table row data structure.
208 * @param rst the srt table
209 * @param index number of procedure
210 * @param procedure the procedures name
212 WS_DLL_PUBLIC void init_srt_table_row(srt_stat_table *rst, int index, const char *procedure);
214 /** Add srt response to table row data.
216 * @param rst the srt table
217 * @param index number of procedure
218 * @param req_time the time of the corresponding request
219 * @param pinfo current packet info
221 WS_DLL_PUBLIC void add_srt_table_data(srt_stat_table *rst, int index, const nstime_t *req_time, packet_info *pinfo);
226 #endif /* __cplusplus */
228 #endif /* __SRT_TABLE_H__ */
236 * indent-tabs-mode: nil
239 * ex: set shiftwidth=4 tabstop=8 expandtab:
240 * :indentSize=4:tabSize=8:noTabs=true: