1 /* rtd_table.h 2 * GUI independent helper routines common to all Response Time Delay (RTD) taps. 3 * Based on srt_table.h 4 * 5 * Wireshark - Network traffic analyzer 6 * By Gerald Combs <gerald@wireshark.org> 7 * Copyright 1998 Gerald Combs 8 * 9 * SPDX-License-Identifier: GPL-2.0-or-later 10 */ 11 12 #ifndef __RTD_TABLE_H__ 13 #define __RTD_TABLE_H__ 14 15 #include "tap.h" 16 #include "timestats.h" 17 #include "value_string.h" 18 #include <epan/wmem_scopes.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif /* __cplusplus */ 23 24 typedef struct _rtd_timestat { 25 guint num_timestat; /**< number of elements on rtd array */ 26 timestat_t* rtd; 27 guint32 open_req_num; 28 guint32 disc_rsp_num; 29 guint32 req_dup_num; 30 guint32 rsp_dup_num; 31 } rtd_timestat; 32 33 /** Statistics table */ 34 typedef struct _rtd_stat_table { 35 char *filter; 36 guint num_rtds; /**< number of elements on time_stats array */ 37 rtd_timestat* time_stats; 38 } rtd_stat_table; 39 40 /** tap data 41 */ 42 typedef struct _rtd_data_t { 43 rtd_stat_table stat_table; /**< RTD table data */ 44 void *user_data; /**< "GUI" specifics (sharkd only?) */ 45 } rtd_data_t; 46 47 /** Structure for information about a registered service response table */ 48 struct register_rtd; 49 typedef struct register_rtd register_rtd_t; 50 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); 53 54 /** Register the response time delay table. 55 * 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 63 */ 64 WS_DLL_PUBLIC void register_rtd_table(const int proto_id, const char* tap_listener, guint num_tables, guint num_timestats, const value_string* vs_type, 65 tap_packet_cb rtd_packet_func, rtd_filter_check_cb filter_check_cb); 66 67 /** Get protocol ID from RTD 68 * 69 * @param rtd Registered RTD 70 * @return protocol id of RTD 71 */ 72 WS_DLL_PUBLIC int get_rtd_proto_id(register_rtd_t* rtd); 73 74 /** Get string for register_tap_listener call. Typically just dissector name 75 * 76 * @param rtd Registered RTD 77 * @return string for register_tap_listener call 78 */ 79 WS_DLL_PUBLIC const char* get_rtd_tap_listener_name(register_rtd_t* rtd); 80 81 /** Get tap function handler from RTD 82 * 83 * @param rtd Registered RTD 84 * @return tap function handler of RTD 85 */ 86 WS_DLL_PUBLIC tap_packet_cb get_rtd_packet_func(register_rtd_t* rtd); 87 88 /** Get the number of RTD tables 89 * 90 * @param rtd Registered RTD 91 * @return The number of registered tables. 92 */ 93 WS_DLL_PUBLIC guint get_rtd_num_tables(register_rtd_t* rtd); 94 95 /** Get value_string used for RTD 96 * 97 * @param rtd Registered RTD 98 * @return value_string of RTD 99 */ 100 WS_DLL_PUBLIC const value_string* get_rtd_value_string(register_rtd_t* rtd); 101 102 /** Get RTD table by its dissector name 103 * 104 * @param name dissector name to fetch. 105 * @return RTD table pointer or NULL. 106 */ 107 WS_DLL_PUBLIC register_rtd_t* get_rtd_table_by_name(const char* name); 108 109 /** Free the RTD table data. 110 * 111 * @param table RTD stat table array 112 */ 113 WS_DLL_PUBLIC void free_rtd_table(rtd_stat_table* table); 114 115 /** Reset table data in the RTD. 116 * 117 * @param table RTD table 118 */ 119 WS_DLL_PUBLIC void reset_rtd_table(rtd_stat_table* table); 120 121 /** Interator to walk RTD tables and execute func 122 * Used for initialization 123 * 124 * @param func action to be performed on all converation tables 125 * @param user_data any data needed to help perform function 126 */ 127 WS_DLL_PUBLIC void rtd_table_iterate_tables(wmem_foreach_func func, gpointer user_data); 128 129 /** Return filter used for register_tap_listener 130 * 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 135 */ 136 WS_DLL_PUBLIC void rtd_table_get_filter(register_rtd_t* rtd, const char *opt_arg, const char **filter, char** err); 137 138 /** "Common" initialization function for all GUIs 139 * 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 144 */ 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); 146 147 /** Helper function to get tap string name 148 * Caller is responsible for freeing returned string 149 * 150 * @param rtd Registered RTD 151 * @return RTD tap string 152 */ 153 WS_DLL_PUBLIC gchar* rtd_table_get_tap_string(register_rtd_t* rtd); 154 155 #ifdef __cplusplus 156 } 157 #endif /* __cplusplus */ 158 159 #endif /* __RTD_TABLE_H__ */ 160 161 /* 162 * Editor modelines 163 * 164 * Local Variables: 165 * c-basic-offset: 4 166 * tab-width: 8 167 * indent-tabs-mode: nil 168 * End: 169 * 170 * ex: set shiftwidth=4 tabstop=8 expandtab: 171 * :indentSize=4:tabSize=8:noTabs=true: 172 */ 173