diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
commit | e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch) | |
tree | 68cb5ef9081156392f1dd62a00c6ccc1451b93df /epan/rtd_table.h | |
parent | Initial commit. (diff) | |
download | wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip |
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/rtd_table.h')
-rw-r--r-- | epan/rtd_table.h | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/epan/rtd_table.h b/epan/rtd_table.h new file mode 100644 index 00000000..a4679a09 --- /dev/null +++ b/epan/rtd_table.h @@ -0,0 +1,172 @@ +/** @file + * GUI independent helper routines common to all Response Time Delay (RTD) taps. + * Based on srt_table.h + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef __RTD_TABLE_H__ +#define __RTD_TABLE_H__ + +#include "tap.h" +#include "timestats.h" +#include "value_string.h" +#include <epan/wmem_scopes.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct _rtd_timestat { + guint num_timestat; /**< number of elements on rtd array */ + timestat_t* rtd; + guint32 open_req_num; + guint32 disc_rsp_num; + guint32 req_dup_num; + guint32 rsp_dup_num; +} rtd_timestat; + +/** Statistics table */ +typedef struct _rtd_stat_table { + char *filter; + guint num_rtds; /**< number of elements on time_stats array */ + rtd_timestat* time_stats; +} rtd_stat_table; + +/** tap data + */ +typedef struct _rtd_data_t { + rtd_stat_table stat_table; /**< RTD table data */ + void *user_data; /**< "GUI" specifics (sharkd only?) */ +} rtd_data_t; + +/** Structure for information about a registered service response table */ +struct register_rtd; +typedef struct register_rtd register_rtd_t; + +typedef void (*rtd_gui_init_cb)(rtd_stat_table* rtd, void* gui_data); +typedef void (*rtd_filter_check_cb)(const char *opt_arg, const char **filter, char** err); + +/** Register the response time delay table. + * + * @param proto_id is the protocol with conversation + * @param tap_listener string for register_tap_listener (NULL to just use protocol name) + * @param num_tables number of tables + * @param num_timestats number of timestamps in the table + * @param vs_type value_string for the stat types + * @param rtd_packet_func the tap processing function + * @param filter_check_cb callback for verification of filter or other dissector checks + */ +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, + tap_packet_cb rtd_packet_func, rtd_filter_check_cb filter_check_cb); + +/** Get protocol ID from RTD + * + * @param rtd Registered RTD + * @return protocol id of RTD + */ +WS_DLL_PUBLIC int get_rtd_proto_id(register_rtd_t* rtd); + +/** Get string for register_tap_listener call. Typically just dissector name + * + * @param rtd Registered RTD + * @return string for register_tap_listener call + */ +WS_DLL_PUBLIC const char* get_rtd_tap_listener_name(register_rtd_t* rtd); + +/** Get tap function handler from RTD + * + * @param rtd Registered RTD + * @return tap function handler of RTD + */ +WS_DLL_PUBLIC tap_packet_cb get_rtd_packet_func(register_rtd_t* rtd); + +/** Get the number of RTD tables + * + * @param rtd Registered RTD + * @return The number of registered tables. + */ +WS_DLL_PUBLIC guint get_rtd_num_tables(register_rtd_t* rtd); + +/** Get value_string used for RTD + * + * @param rtd Registered RTD + * @return value_string of RTD + */ +WS_DLL_PUBLIC const value_string* get_rtd_value_string(register_rtd_t* rtd); + +/** Get RTD table by its dissector name + * + * @param name dissector name to fetch. + * @return RTD table pointer or NULL. + */ +WS_DLL_PUBLIC register_rtd_t* get_rtd_table_by_name(const char* name); + +/** Free the RTD table data. + * + * @param table RTD stat table array + */ +WS_DLL_PUBLIC void free_rtd_table(rtd_stat_table* table); + +/** Reset table data in the RTD. + * + * @param table RTD table + */ +WS_DLL_PUBLIC void reset_rtd_table(rtd_stat_table* table); + +/** Interator to walk RTD tables and execute func + * Used for initialization + * + * @param func action to be performed on all converation tables + * @param user_data any data needed to help perform function + */ +WS_DLL_PUBLIC void rtd_table_iterate_tables(wmem_foreach_func func, gpointer user_data); + +/** Return filter used for register_tap_listener + * + * @param rtd Registered RTD + * @param opt_arg passed in opt_arg from GUI + * @param filter returned filter string to be used for registering tap + * @param err returned error if opt_arg string can't be successfully handled. Caller must free memory + */ +WS_DLL_PUBLIC void rtd_table_get_filter(register_rtd_t* rtd, const char *opt_arg, const char **filter, char** err); + +/** "Common" initialization function for all GUIs + * + * @param rtd Registered RTD + * @param table RTD table + * @param gui_callback optional GUI callback function + * @param callback_data optional GUI callback data + */ +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); + +/** Helper function to get tap string name + * Caller is responsible for freeing returned string + * + * @param rtd Registered RTD + * @return RTD tap string + */ +WS_DLL_PUBLIC gchar* rtd_table_get_tap_string(register_rtd_t* rtd); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __RTD_TABLE_H__ */ + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ |