2 * GUI independent helper routines common to all Response Time Delay (RTD) taps.
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef __RTD_TABLE_H__
13 #define __RTD_TABLE_H__
16 #include "timestats.h"
17 #include "value_string.h"
18 #include <epan/wmem_scopes.h>
22 #endif /* __cplusplus */
24 typedef struct _rtd_timestat
{
25 unsigned num_timestat
; /**< number of elements on rtd array */
27 uint32_t open_req_num
;
28 uint32_t disc_rsp_num
;
33 /** Statistics table */
34 typedef struct _rtd_stat_table
{
36 unsigned num_rtds
; /**< number of elements on time_stats array */
37 rtd_timestat
* time_stats
;
42 typedef struct _rtd_data_t
{
43 rtd_stat_table stat_table
; /**< RTD table data */
44 void *user_data
; /**< "GUI" specifics (sharkd only?) */
47 /** Structure for information about a registered service response table */
49 typedef struct register_rtd register_rtd_t
;
51 typedef void (*rtd_gui_init_cb
)(rtd_stat_table
* rtd
, void* gui_data
);
52 typedef void (*rtd_filter_check_cb
)(const char *opt_arg
, const char **filter
, char** err
);
54 /** Register the response time delay table.
56 * @param proto_id is the protocol with conversation
57 * @param tap_listener string for register_tap_listener (NULL to just use protocol name)
58 * @param num_tables number of tables
59 * @param num_timestats number of timestamps in the table
60 * @param vs_type value_string for the stat types
61 * @param rtd_packet_func the tap processing function
62 * @param filter_check_cb callback for verification of filter or other dissector checks
64 WS_DLL_PUBLIC
void register_rtd_table(const int proto_id
, const char* tap_listener
, unsigned num_tables
, unsigned num_timestats
, const value_string
* vs_type
,
65 tap_packet_cb rtd_packet_func
, rtd_filter_check_cb filter_check_cb
);
67 /** Get protocol ID from RTD
69 * @param rtd Registered RTD
70 * @return protocol id of RTD
72 WS_DLL_PUBLIC
int get_rtd_proto_id(register_rtd_t
* rtd
);
74 /** Get string for register_tap_listener call. Typically just dissector name
76 * @param rtd Registered RTD
77 * @return string for register_tap_listener call
79 WS_DLL_PUBLIC
const char* get_rtd_tap_listener_name(register_rtd_t
* rtd
);
81 /** Get tap function handler from RTD
83 * @param rtd Registered RTD
84 * @return tap function handler of RTD
86 WS_DLL_PUBLIC tap_packet_cb
get_rtd_packet_func(register_rtd_t
* rtd
);
88 /** Get the number of RTD tables
90 * @param rtd Registered RTD
91 * @return The number of registered tables.
93 WS_DLL_PUBLIC
unsigned get_rtd_num_tables(register_rtd_t
* rtd
);
95 /** Get value_string used for RTD
97 * @param rtd Registered RTD
98 * @return value_string of RTD
100 WS_DLL_PUBLIC
const value_string
* get_rtd_value_string(register_rtd_t
* rtd
);
102 /** Get RTD table by its dissector name
104 * @param name dissector name to fetch.
105 * @return RTD table pointer or NULL.
107 WS_DLL_PUBLIC register_rtd_t
* get_rtd_table_by_name(const char* name
);
109 /** Free the RTD table data.
111 * @param table RTD stat table array
113 WS_DLL_PUBLIC
void free_rtd_table(rtd_stat_table
* table
);
115 /** Reset table data in the RTD.
117 * @param table RTD table
119 WS_DLL_PUBLIC
void reset_rtd_table(rtd_stat_table
* table
);
121 /** Interator to walk RTD tables and execute func
122 * Used for initialization
124 * @param func action to be performed on all conversation tables
125 * @param user_data any data needed to help perform function
127 WS_DLL_PUBLIC
void rtd_table_iterate_tables(wmem_foreach_func func
, void *user_data
);
129 /** Return filter used for register_tap_listener
131 * @param rtd Registered RTD
132 * @param opt_arg passed in opt_arg from GUI
133 * @param filter returned filter string to be used for registering tap
134 * @param err returned error if opt_arg string can't be successfully handled. Caller must free memory
136 WS_DLL_PUBLIC
void rtd_table_get_filter(register_rtd_t
* rtd
, const char *opt_arg
, const char **filter
, char** err
);
138 /** "Common" initialization function for all GUIs
140 * @param rtd Registered RTD
141 * @param table RTD table
142 * @param gui_callback optional GUI callback function
143 * @param callback_data optional GUI callback data
145 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
);
147 /** Helper function to get tap string name
148 * Caller is responsible for freeing returned string
150 * @param rtd Registered RTD
151 * @return RTD tap string
153 WS_DLL_PUBLIC
char* rtd_table_get_tap_string(register_rtd_t
* rtd
);
157 #endif /* __cplusplus */
159 #endif /* __RTD_TABLE_H__ */
167 * indent-tabs-mode: nil
170 * ex: set shiftwidth=4 tabstop=8 expandtab:
171 * :indentSize=4:tabSize=8:noTabs=true: