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 * SPDX-License-Identifier: GPL-2.0-or-later
11 #ifndef __SRT_TABLE_H__
12 #define __SRT_TABLE_H__
15 #include "timestats.h"
16 #include <epan/wmem_scopes.h>
20 #endif /* __cplusplus */
23 typedef struct _srt_procedure_t
{
25 timestat_t stats
; /**< stats */
26 char *procedure
; /**< column entries */
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 */
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 unsigned (*srt_param_handler_cb
)(struct register_srt
* srt
, const char* opt_arg
, char** err
);
49 typedef struct _srt_data_t
{
50 GArray
*srt_array
; /**< array of srt_stat_table */
51 void *user_data
; /**< "GUI" specifics (if necessary) */
54 /** Structure for information about a registered service response table */
55 typedef struct register_srt register_srt_t
;
57 /** Register the service response time table for the srt windows.
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
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
);
69 /** Get protocol ID from SRT
71 * @param srt Registered SRT
72 * @return protocol id of SRT
74 WS_DLL_PUBLIC
int get_srt_proto_id(register_srt_t
* srt
);
76 /** Get string for register_tap_listener call. Typically just dissector name
78 * @param srt Registered SRT
79 * @return string for register_tap_listener call
81 WS_DLL_PUBLIC
const char* get_srt_tap_listener_name(register_srt_t
* srt
);
83 /** Get maximum number of tables from SRT
85 * @param srt Registered SRT
86 * @return maximum number of tables of SRT
88 WS_DLL_PUBLIC
int get_srt_max_tables(register_srt_t
* srt
);
90 /** Get tap function handler from SRT
92 * @param srt Registered SRT
93 * @return tap function handler of SRT
95 WS_DLL_PUBLIC tap_packet_cb
get_srt_packet_func(register_srt_t
* srt
);
97 /** Set parameter data from SRT parsed from tap string. Data will be
100 * @param srt Registered SRT
101 * @param data Parameter data
103 WS_DLL_PUBLIC
void set_srt_table_param_data(register_srt_t
* srt
, void* data
);
105 /** Get parameter data from SRT
107 * @param srt Registered SRT
108 * @return Parameter data
110 WS_DLL_PUBLIC
void* get_srt_table_param_data(register_srt_t
* srt
);
112 /** Get SRT table by its dissector name
114 * @param name dissector name to fetch.
115 * @return SRT table pointer or NULL.
117 WS_DLL_PUBLIC register_srt_t
* get_srt_table_by_name(const char* name
);
119 /** Free the srt table data.
121 * @param rst the srt table
123 WS_DLL_PUBLIC
void free_srt_table_data(srt_stat_table
*rst
);
125 /** Free the srt table data.
127 * @param srt Registered SRT
128 * @param srt_array SRT table array
130 WS_DLL_PUBLIC
void free_srt_table(register_srt_t
*srt
, GArray
* srt_array
);
132 /** Reset ALL tables in the srt.
134 * @param srt_array SRT table array
136 WS_DLL_PUBLIC
void reset_srt_table(GArray
* srt_array
);
138 /** Iterator to walk srt tables and execute func
139 * Used for initialization
141 * @param func action to be performed on all conversation tables
142 * @param user_data any data needed to help perform function
144 WS_DLL_PUBLIC
void srt_table_iterate_tables(wmem_foreach_func func
, void *user_data
);
146 /** Return filter used for register_tap_listener
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
153 WS_DLL_PUBLIC
void srt_table_get_filter(register_srt_t
* srt
, const char *opt_arg
, const char **filter
, char** err
);
155 /** "Common" initialization function for all GUIs
157 * @param srt Registered SRT
158 * @param srt_array SRT table array
160 WS_DLL_PUBLIC
void srt_table_dissector_init(register_srt_t
* srt
, GArray
* srt_array
);
162 /** Helper function to get tap string name
163 * Caller is responsible for freeing returned string
165 * @param srt Registered SRT
166 * @return SRT tap string
168 WS_DLL_PUBLIC
char* srt_table_get_tap_string(register_srt_t
* srt
);
170 /** Init an srt table data structure.
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
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
);
184 /** Init an srt table row data structure.
186 * @param rst the srt table
187 * @param proc_index number of procedure
188 * @param procedure the procedures name
190 WS_DLL_PUBLIC
void init_srt_table_row(srt_stat_table
*rst
, int proc_index
, const char *procedure
);
192 /** Add srt response to table row data.
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
199 WS_DLL_PUBLIC
void add_srt_table_data(srt_stat_table
*rst
, int proc_index
, const nstime_t
*req_time
, packet_info
*pinfo
);
203 #endif /* __cplusplus */
205 #endif /* __SRT_TABLE_H__ */
213 * indent-tabs-mode: nil
216 * ex: set shiftwidth=4 tabstop=8 expandtab:
217 * :indentSize=4:tabSize=8:noTabs=true: