[SIP] Display tel uri in VoIP calls.
[metze/wireshark/wip.git] / epan / srt_table.h
1 /* srt_table.h
2  * GUI independent helper routines common to all service response time (SRT) taps.
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 __SRT_TABLE_H__
24 #define __SRT_TABLE_H__
25
26 #include "tap.h"
27 #include "timestats.h"
28 #include "wmem/wmem.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 /** Procedure data */
35 typedef struct _srt_procedure_t {
36         int  proc_index;
37         timestat_t stats;   /**< stats */
38         char *procedure;   /**< column entries */
39 } srt_procedure_t;
40
41 /** Statistics table */
42 typedef struct _srt_stat_table {
43         const char *name;   /**< table name */
44         const char *short_name;   /**< tab name */
45         char *filter_string;        /**< append procedure number (%d) to this string
46                                 to create a display filter */
47         int num_procs;              /**< number of elements on procedures array */
48         const char *proc_column_name;   /**< procedure column name (if different from default) */
49         srt_procedure_t *procedures;/**< the procedures array */
50     void* table_specific_data; /** any dissector/table specific data needed for packet filtering */
51 } srt_stat_table;
52
53 struct register_srt;
54 struct _srt_data_t;
55 typedef void (*srt_gui_init_cb)(srt_stat_table* rst, void* gui_data); /* GTK+ only? */
56 typedef void (*srt_gui_reset_cb)(srt_stat_table* rst, void* gui_data);  /* GTK+ only? */
57 typedef void (*srt_gui_free_cb)(srt_stat_table* rst, void* gui_data);  /* GTK+ only? */
58 typedef void (*srt_proc_table_cb)(srt_stat_table* rst, int indx, struct _srt_data_t* gui_data);
59 typedef void (*srt_init_cb)(struct register_srt* srt, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data);
60 typedef guint (*srt_param_handler_cb)(struct register_srt* srt, const char* opt_arg, char** err);
61
62 /** tap data
63  */
64 typedef struct _srt_data_t {
65     GArray      *srt_array;      /**< array of srt_stat_table */
66     void        *user_data;       /**< "GUI" specifics (if necessary) */
67 } srt_data_t;
68
69 /** Structure for information about a registered service response table */
70 typedef struct register_srt register_srt_t;
71
72 /** Register the service response time table for the srt windows.
73  *
74  * @param proto_id is the protocol with conversation
75  * @param tap_listener string for register_tap_listener (NULL to just use protocol name)
76  * @param max_tables maximum number of tables
77  * @param srt_packet_func the tap processing function
78  * @param init_cb initialize dissector SRT function
79  * @param param_cb handles dissection of parameters to optional arguments of tap string
80  */
81 WS_DLL_PUBLIC void register_srt_table(const int proto_id, const char* tap_listener, int max_tables,
82                                        tap_packet_cb srt_packet_func, srt_init_cb init_cb, srt_param_handler_cb param_cb);
83
84 /** Get protocol ID from SRT
85  *
86  * @param srt Registered SRT
87  * @return protocol id of SRT
88  */
89 WS_DLL_PUBLIC int get_srt_proto_id(register_srt_t* srt);
90
91 /** Get string for register_tap_listener call.  Typically just dissector name
92  *
93  * @param srt Registered SRT
94  * @return string for register_tap_listener call
95  */
96 WS_DLL_PUBLIC const char* get_srt_tap_listener_name(register_srt_t* srt);
97
98 /** Get maximum number of tables from SRT
99  *
100  * @param srt Registered SRT
101  * @return maximum number of tables of SRT
102  */
103 WS_DLL_PUBLIC int get_srt_max_tables(register_srt_t* srt);
104
105 /** Get tap function handler from SRT
106  *
107  * @param srt Registered SRT
108  * @return tap function handler of SRT
109  */
110 WS_DLL_PUBLIC tap_packet_cb get_srt_packet_func(register_srt_t* srt);
111
112 /** Set parameter data from SRT parsed from tap string. Data will be
113  * freed on tap reset
114  *
115  * @param srt Registered SRT
116  * @param data Parameter data
117  */
118 WS_DLL_PUBLIC void set_srt_table_param_data(register_srt_t* srt, void* data);
119
120 /** Get parameter data from SRT
121  *
122  * @param srt Registered SRT
123  * @return Parameter data
124  */
125 WS_DLL_PUBLIC void* get_srt_table_param_data(register_srt_t* srt);
126
127 /** Get SRT table by its dissector name
128  *
129  * @param name dissector name to fetch.
130  * @return SRT table pointer or NULL.
131  */
132 WS_DLL_PUBLIC register_srt_t* get_srt_table_by_name(const char* name);
133
134 /** Free the srt table data.
135  *
136  * @param rst the srt table
137  */
138 WS_DLL_PUBLIC void free_srt_table_data(srt_stat_table *rst);
139
140 /** Free the srt table data.
141  *
142  * @param srt Registered SRT
143  * @param srt_array SRT table array
144  * @param gui_callback optional callback from GUI
145  * @param callback_data callback data needed for GUI
146  */
147 WS_DLL_PUBLIC void free_srt_table(register_srt_t *srt, GArray* srt_array, srt_gui_free_cb gui_callback, void *callback_data);
148
149 /** Reset ALL tables in the srt.
150  *
151  * @param srt_array SRT table array
152  * @param gui_callback optional callback from GUI
153  * @param callback_data callback data needed for GUI
154  */
155 WS_DLL_PUBLIC void reset_srt_table(GArray* srt_array, srt_gui_reset_cb gui_callback, void *callback_data);
156
157 /** Interator to walk srt tables and execute func
158  * Used for initialization
159  *
160  * @param func action to be performed on all converation tables
161  * @param user_data any data needed to help perform function
162  */
163 WS_DLL_PUBLIC void srt_table_iterate_tables(wmem_foreach_func func, gpointer user_data);
164
165 /** Return filter used for register_tap_listener
166  *
167  * @param srt Registered SRT
168  * @param opt_arg passed in opt_arg from GUI
169  * @param filter returned filter string to be used for registering tap
170  * @param err returned error if opt_arg string can't be successfully parsed. Caller must free memory
171  */
172 WS_DLL_PUBLIC void srt_table_get_filter(register_srt_t* srt, const char *opt_arg, const char **filter, char** err);
173
174 /** "Common" initialization function for all GUIs
175  *
176  * @param srt Registered SRT
177  * @param srt_array SRT table array
178  * @param gui_callback optional callback from GUI
179  * @param callback_data callback data needed for GUI
180  */
181 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
183 /** Helper function to get tap string name
184  * Caller is responsible for freeing returned string
185  *
186  * @param srt Registered SRT
187  * @return SRT tap string
188  */
189 WS_DLL_PUBLIC gchar* srt_table_get_tap_string(register_srt_t* srt);
190
191 /** Init an srt table data structure.
192  *
193  * @param name the table name
194  * @param short_name the name used in a tab display
195  * @param srt_array the srt table array to add to
196  * @param num_procs number of procedures
197  * @param proc_column_name procedure column name (if different from "Procedure")
198  * @param filter_string table filter string or NULL
199  * @param gui_callback optional GUI callback
200  * @param gui_data GUI content data
201  * @param table_specific_data Table specific data
202  * @return newly created srt_stat_table
203  */
204 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,
205                 const char *filter_string, srt_gui_init_cb gui_callback, void* gui_data, void* table_specific_data);
206
207 /** Init an srt table row data structure.
208  *
209  * @param rst the srt table
210  * @param proc_index number of procedure
211  * @param procedure the procedures name
212  */
213 WS_DLL_PUBLIC void init_srt_table_row(srt_stat_table *rst, int proc_index, const char *procedure);
214
215 /** Add srt response to table row data.
216  *
217  * @param rst the srt table
218  * @param proc_index number of procedure
219  * @param req_time the time of the corresponding request
220  * @param pinfo current packet info
221  */
222 WS_DLL_PUBLIC void add_srt_table_data(srt_stat_table *rst, int proc_index, const nstime_t *req_time, packet_info *pinfo);
223
224 #ifdef __cplusplus
225 }
226 #endif /* __cplusplus */
227
228 #endif /* __SRT_TABLE_H__ */
229
230 /*
231  * Editor modelines
232  *
233  * Local Variables:
234  * c-basic-offset: 4
235  * tab-width: 8
236  * indent-tabs-mode: nil
237  * End:
238  *
239  * ex: set shiftwidth=4 tabstop=8 expandtab:
240  * :indentSize=4:tabSize=8:noTabs=true:
241  */