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