forked from osmocom/wireshark
Switch export objects to use wmem_tree_t instead of (sorted) GSList.
Change-Id: Iaaa7b44954337c7857dbb541b727924e2de57c9d Reviewed-on: https://code.wireshark.org/review/20016 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
64a00dc0a8
commit
243c09fa06
|
@ -223,7 +223,6 @@ epan_cleanup(void)
|
||||||
expert_cleanup();
|
expert_cleanup();
|
||||||
capture_dissector_cleanup();
|
capture_dissector_cleanup();
|
||||||
export_pdu_cleanup();
|
export_pdu_cleanup();
|
||||||
export_object_cleanup();
|
|
||||||
stat_tap_table_cleanup();
|
stat_tap_table_cleanup();
|
||||||
follow_cleanup();
|
follow_cleanup();
|
||||||
disabled_protos_cleanup();
|
disabled_protos_cleanup();
|
||||||
|
|
|
@ -35,16 +35,7 @@ struct register_eo {
|
||||||
export_object_gui_reset_cb reset_cb; /* function to parse parameters of optional arguments of tap string */
|
export_object_gui_reset_cb reset_cb; /* function to parse parameters of optional arguments of tap string */
|
||||||
};
|
};
|
||||||
|
|
||||||
static GSList *registered_eo_tables = NULL;
|
static wmem_tree_t *registered_eo_tables = NULL;
|
||||||
|
|
||||||
static gint
|
|
||||||
insert_sorted_by_table_name(gconstpointer aparam, gconstpointer bparam)
|
|
||||||
{
|
|
||||||
const register_eo_t *a = (const register_eo_t *)aparam;
|
|
||||||
const register_eo_t *b = (const register_eo_t *)bparam;
|
|
||||||
|
|
||||||
return g_ascii_strcasecmp(proto_get_protocol_filter_name(a->proto_id), proto_get_protocol_filter_name(b->proto_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
register_export_object(const int proto_id, tap_packet_cb export_packet_func, export_object_gui_reset_cb reset_cb)
|
register_export_object(const int proto_id, tap_packet_cb export_packet_func, export_object_gui_reset_cb reset_cb)
|
||||||
|
@ -52,14 +43,17 @@ register_export_object(const int proto_id, tap_packet_cb export_packet_func, exp
|
||||||
register_eo_t *table;
|
register_eo_t *table;
|
||||||
DISSECTOR_ASSERT(export_packet_func);
|
DISSECTOR_ASSERT(export_packet_func);
|
||||||
|
|
||||||
table = g_new(register_eo_t,1);
|
table = wmem_new(wmem_epan_scope(), register_eo_t);
|
||||||
|
|
||||||
table->proto_id = proto_id;
|
table->proto_id = proto_id;
|
||||||
table->tap_listen_str = g_strdup_printf("%s_eo", proto_get_protocol_filter_name(proto_id));
|
table->tap_listen_str = wmem_strdup_printf(wmem_epan_scope(), "%s_eo", proto_get_protocol_filter_name(proto_id));
|
||||||
table->eo_func = export_packet_func;
|
table->eo_func = export_packet_func;
|
||||||
table->reset_cb = reset_cb;
|
table->reset_cb = reset_cb;
|
||||||
|
|
||||||
registered_eo_tables = g_slist_insert_sorted(registered_eo_tables, table, insert_sorted_by_table_name);
|
if (registered_eo_tables == NULL)
|
||||||
|
registered_eo_tables = wmem_tree_new(wmem_epan_scope());
|
||||||
|
|
||||||
|
wmem_tree_insert_string(registered_eo_tables, wmem_strdup(wmem_epan_scope(), proto_get_protocol_filter_name(proto_id)), table, 0);
|
||||||
return register_tap(table->tap_listen_str);
|
return register_tap(table->tap_listen_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,31 +80,14 @@ export_object_gui_reset_cb get_eo_reset_func(register_eo_t* eo)
|
||||||
return eo->reset_cb;
|
return eo->reset_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
|
||||||
find_matching_eo(gconstpointer arg1, gconstpointer arg2)
|
|
||||||
{
|
|
||||||
register_eo_t *eo = (register_eo_t*)arg1;
|
|
||||||
const gchar *name = (const gchar *)arg2;
|
|
||||||
|
|
||||||
return strcmp(proto_get_protocol_filter_name(eo->proto_id), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
register_eo_t* get_eo_by_name(const char* name)
|
register_eo_t* get_eo_by_name(const char* name)
|
||||||
{
|
{
|
||||||
GSList *found_eo;
|
return (register_eo_t*)wmem_tree_lookup_string(registered_eo_tables, name, 0);
|
||||||
|
|
||||||
found_eo = g_slist_find_custom(registered_eo_tables,
|
|
||||||
(gpointer)name, find_matching_eo);
|
|
||||||
|
|
||||||
if (found_eo)
|
|
||||||
return (register_eo_t*)found_eo->data;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void eo_iterate_tables(GFunc func, gpointer user_data)
|
void eo_iterate_tables(wmem_foreach_func func, gpointer user_data)
|
||||||
{
|
{
|
||||||
g_slist_foreach(registered_eo_tables, func, user_data);
|
wmem_tree_foreach(registered_eo_tables, func, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GString *eo_rename(GString *gstr, int dupn)
|
static GString *eo_rename(GString *gstr, int dupn)
|
||||||
|
@ -198,20 +175,6 @@ void eo_free_entry(export_object_entry_t *entry)
|
||||||
g_free(entry);
|
g_free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
free_eo_table(gpointer p, gpointer user_data _U_)
|
|
||||||
{
|
|
||||||
register_eo_t *table = (register_eo_t*)p;
|
|
||||||
g_free((gpointer)table->tap_listen_str);
|
|
||||||
g_free(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
void export_object_cleanup(void)
|
|
||||||
{
|
|
||||||
g_slist_foreach(registered_eo_tables, free_eo_table, NULL);
|
|
||||||
g_slist_free(registered_eo_tables);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Editor modelines
|
* Editor modelines
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define __EXPORT_OBJECT_H__
|
#define __EXPORT_OBJECT_H__
|
||||||
|
|
||||||
#include "tap.h"
|
#include "tap.h"
|
||||||
|
#include "wmem/wmem.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -111,7 +112,7 @@ WS_DLL_PUBLIC register_eo_t* get_eo_by_name(const char* name);
|
||||||
* @param func action to be performed on all Export Objects
|
* @param func action to be performed on all Export Objects
|
||||||
* @param user_data any data needed to help perform function
|
* @param user_data any data needed to help perform function
|
||||||
*/
|
*/
|
||||||
WS_DLL_PUBLIC void eo_iterate_tables(GFunc func, gpointer user_data);
|
WS_DLL_PUBLIC void eo_iterate_tables(wmem_foreach_func func, gpointer user_data);
|
||||||
|
|
||||||
/** Find all disallowed characters/bytes and replace them with %xx
|
/** Find all disallowed characters/bytes and replace them with %xx
|
||||||
*
|
*
|
||||||
|
@ -135,10 +136,6 @@ WS_DLL_PUBLIC const char *eo_ct2ext(const char *content_type);
|
||||||
*/
|
*/
|
||||||
WS_DLL_PUBLIC void eo_free_entry(export_object_entry_t *entry);
|
WS_DLL_PUBLIC void eo_free_entry(export_object_entry_t *entry);
|
||||||
|
|
||||||
/** Free the export objects table
|
|
||||||
*/
|
|
||||||
extern void export_object_cleanup(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
|
@ -96,12 +96,11 @@ typedef struct _export_object_list_gui_t {
|
||||||
|
|
||||||
static GHashTable* eo_opts = NULL;
|
static GHashTable* eo_opts = NULL;
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
list_exportobject_protocol(gpointer data, gpointer user_data _U_)
|
list_exportobject_protocol(const void *key, void *value _U_, void *userdata _U_)
|
||||||
{
|
{
|
||||||
register_eo_t *eo = (register_eo_t*)data;
|
fprintf(stderr, " %s\n", (gchar*)key);
|
||||||
|
return FALSE;
|
||||||
fprintf(stderr, " %s\n", proto_get_protocol_filter_name(get_eo_proto_id(eo)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void eo_list_object_types(void)
|
void eo_list_object_types(void)
|
||||||
|
|
|
@ -2818,11 +2818,11 @@ menu_exportobject_cb(GtkAction *action _U_, gpointer user_data)
|
||||||
exportobject_cb(eo);
|
exportobject_cb(eo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
add_export_object_menuitem(gpointer data, gpointer user_data)
|
add_export_object_menuitem(const void *key _U_, void *value, void *userdata)
|
||||||
{
|
{
|
||||||
register_eo_t *eo = (register_eo_t*)data;
|
register_eo_t *eo = (register_eo_t*)value;
|
||||||
eo_menu_t *eo_menu_data = (eo_menu_t*)user_data;
|
eo_menu_t *eo_menu_data = (eo_menu_t*)userdata;
|
||||||
gchar *action_name;
|
gchar *action_name;
|
||||||
GtkAction *action;
|
GtkAction *action;
|
||||||
|
|
||||||
|
@ -2846,6 +2846,7 @@ add_export_object_menuitem(gpointer data, gpointer user_data)
|
||||||
FALSE);
|
FALSE);
|
||||||
g_free(action_name);
|
g_free(action_name);
|
||||||
eo_menu_data->counter++;
|
eo_menu_data->counter++;
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1986,10 +1986,10 @@ void MainWindow::initConversationMenus()
|
||||||
connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeActionTriggered()));
|
connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeActionTriggered()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addExportObjectsMenuItem(gpointer data, gpointer user_data)
|
gboolean MainWindow::addExportObjectsMenuItem(const void *key _U_, void *value, void *userdata)
|
||||||
{
|
{
|
||||||
register_eo_t *eo = (register_eo_t*)data;
|
register_eo_t *eo = (register_eo_t*)value;
|
||||||
MainWindow *window = (MainWindow*)user_data;
|
MainWindow *window = (MainWindow*)userdata;
|
||||||
|
|
||||||
ExportObjectAction *export_action = new ExportObjectAction(window->main_ui_->menuFileExportObjects, eo);
|
ExportObjectAction *export_action = new ExportObjectAction(window->main_ui_->menuFileExportObjects, eo);
|
||||||
window->main_ui_->menuFileExportObjects->addAction(export_action);
|
window->main_ui_->menuFileExportObjects->addAction(export_action);
|
||||||
|
@ -2000,6 +2000,7 @@ void MainWindow::addExportObjectsMenuItem(gpointer data, gpointer user_data)
|
||||||
connect(&window->capture_file_, SIGNAL(captureFileOpened()), export_action, SLOT(captureFileOpened()));
|
connect(&window->capture_file_, SIGNAL(captureFileOpened()), export_action, SLOT(captureFileOpened()));
|
||||||
connect(&window->capture_file_, SIGNAL(captureFileClosed()), export_action, SLOT(captureFileClosed()));
|
connect(&window->capture_file_, SIGNAL(captureFileClosed()), export_action, SLOT(captureFileClosed()));
|
||||||
connect(export_action, SIGNAL(triggered()), window, SLOT(applyExportObject()));
|
connect(export_action, SIGNAL(triggered()), window, SLOT(applyExportObject()));
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initExportObjectsMenus()
|
void MainWindow::initExportObjectsMenus()
|
||||||
|
|
|
@ -300,7 +300,7 @@ private slots:
|
||||||
|
|
||||||
void initViewColorizeMenu();
|
void initViewColorizeMenu();
|
||||||
void initConversationMenus();
|
void initConversationMenus();
|
||||||
static void addExportObjectsMenuItem(gpointer data, gpointer user_data);
|
static gboolean addExportObjectsMenuItem(const void *key, void *value, void *userdata);
|
||||||
void initExportObjectsMenus();
|
void initExportObjectsMenus();
|
||||||
|
|
||||||
// in main_window_slots.cpp
|
// in main_window_slots.cpp
|
||||||
|
|
Loading…
Reference in New Issue