forked from osmocom/wireshark
Switch follow (tables) to use wmem_tree_t instead of (sorted) GSList.
Change-Id: Iabf354d2533ae429c002b115c5de33b592019997 Reviewed-on: https://code.wireshark.org/review/20018 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
89dfa6bdf4
commit
c5483f4213
|
@ -224,7 +224,6 @@ epan_cleanup(void)
|
|||
capture_dissector_cleanup();
|
||||
export_pdu_cleanup();
|
||||
stat_tap_table_cleanup();
|
||||
follow_cleanup();
|
||||
disabled_protos_cleanup();
|
||||
stats_tree_cleanup();
|
||||
#ifdef HAVE_LUA
|
||||
|
|
|
@ -42,16 +42,7 @@ struct register_follow {
|
|||
follow_tap_func tap_handler; /* tap listener handler */
|
||||
};
|
||||
|
||||
static GSList *registered_followers = NULL;
|
||||
|
||||
static gint
|
||||
insert_sorted_by_name(gconstpointer aparam, gconstpointer bparam)
|
||||
{
|
||||
const register_follow_t *a = (const register_follow_t *)aparam;
|
||||
const register_follow_t *b = (const register_follow_t *)bparam;
|
||||
|
||||
return g_ascii_strcasecmp(proto_get_protocol_short_name(find_protocol_by_id(a->proto_id)), proto_get_protocol_short_name(find_protocol_by_id(b->proto_id)));
|
||||
}
|
||||
static wmem_tree_t *registered_followers = NULL;
|
||||
|
||||
void register_follow_stream(const int proto_id, const char* tap_listener,
|
||||
follow_conv_filter_func conv_filter, follow_index_filter_func index_filter, follow_address_filter_func address_filter,
|
||||
|
@ -65,7 +56,7 @@ void register_follow_stream(const int proto_id, const char* tap_listener,
|
|||
DISSECTOR_ASSERT(port_to_display);
|
||||
DISSECTOR_ASSERT(tap_handler);
|
||||
|
||||
follower = g_new(register_follow_t,1);
|
||||
follower = wmem_new(wmem_epan_scope(), register_follow_t);
|
||||
|
||||
follower->proto_id = proto_id;
|
||||
follower->tap_listen_str = tap_listener;
|
||||
|
@ -75,7 +66,10 @@ void register_follow_stream(const int proto_id, const char* tap_listener,
|
|||
follower->port_to_display = port_to_display;
|
||||
follower->tap_handler = tap_handler;
|
||||
|
||||
registered_followers = g_slist_insert_sorted(registered_followers, follower, insert_sorted_by_name);
|
||||
if (registered_followers == NULL)
|
||||
registered_followers = wmem_tree_new(wmem_epan_scope());
|
||||
|
||||
wmem_tree_insert_string(registered_followers, wmem_strdup(wmem_epan_scope(), proto_get_protocol_filter_name(proto_id)), follower, 0);
|
||||
}
|
||||
|
||||
int get_follow_proto_id(register_follow_t* follower)
|
||||
|
@ -120,31 +114,14 @@ follow_tap_func get_follow_tap_handler(register_follow_t* follower)
|
|||
}
|
||||
|
||||
|
||||
static gint
|
||||
find_matching_follower(gconstpointer arg1, gconstpointer arg2)
|
||||
{
|
||||
register_follow_t *follower = (register_follow_t *)arg1;
|
||||
const gchar *name = (const gchar *)arg2;
|
||||
|
||||
return strcmp(proto_get_protocol_short_name(find_protocol_by_id(follower->proto_id)), name);
|
||||
}
|
||||
|
||||
register_follow_t* get_follow_by_name(const char* proto_short_name)
|
||||
{
|
||||
GSList *found_follower;
|
||||
|
||||
found_follower = g_slist_find_custom(registered_followers,
|
||||
(gpointer)proto_short_name, find_matching_follower);
|
||||
|
||||
if (found_follower)
|
||||
return (register_follow_t*)found_follower->data;
|
||||
|
||||
return NULL;
|
||||
return (register_follow_t*)wmem_tree_lookup_string(registered_followers, proto_short_name, 0);
|
||||
}
|
||||
|
||||
void follow_iterate_followers(GFunc func, gpointer user_data)
|
||||
void follow_iterate_followers(wmem_foreach_func func, gpointer user_data)
|
||||
{
|
||||
g_slist_foreach(registered_followers, func, user_data);
|
||||
wmem_tree_foreach(registered_followers, func, user_data);
|
||||
}
|
||||
|
||||
gchar* follow_get_stat_tap_string(register_follow_t* follower)
|
||||
|
@ -245,19 +222,6 @@ follow_tvb_tap_listener(void *tapdata, packet_info *pinfo,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
clear_follower(gpointer p, gpointer user_data _U_)
|
||||
{
|
||||
g_free(p);
|
||||
}
|
||||
|
||||
void
|
||||
follow_cleanup(void)
|
||||
{
|
||||
g_slist_foreach(registered_followers, clear_follower, NULL);
|
||||
g_slist_free(registered_followers);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
|
|
@ -32,6 +32,7 @@ extern "C" {
|
|||
#include <epan/epan.h>
|
||||
#include <epan/packet.h>
|
||||
#include <epan/ipv6.h>
|
||||
#include <epan/wmem/wmem.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
typedef enum {
|
||||
|
@ -188,7 +189,7 @@ follow_tvb_tap_listener(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _
|
|||
* @param func action to be performed on all converation tables
|
||||
* @param user_data any data needed to help perform function
|
||||
*/
|
||||
WS_DLL_PUBLIC void follow_iterate_followers(GFunc func, gpointer user_data);
|
||||
WS_DLL_PUBLIC void follow_iterate_followers(wmem_foreach_func func, gpointer user_data);
|
||||
|
||||
/** Generate -z stat (tap) name for a follower
|
||||
* Currently used only by TShark
|
||||
|
@ -211,10 +212,6 @@ WS_DLL_PUBLIC void follow_reset_stream(follow_info_t* info);
|
|||
*/
|
||||
WS_DLL_PUBLIC void follow_info_free(follow_info_t* follow_info);
|
||||
|
||||
/** Free the internal structures
|
||||
*/
|
||||
extern void follow_cleanup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -492,10 +492,10 @@ static void follow_stream(const char *opt_argp, void *userdata)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
follow_register(gpointer data, gpointer user_data _U_)
|
||||
static gboolean
|
||||
follow_register(const void *key _U_, void *value, void *userdata _U_)
|
||||
{
|
||||
register_follow_t *follower = (register_follow_t*)data;
|
||||
register_follow_t *follower = (register_follow_t*)value;
|
||||
stat_tap_ui follow_ui;
|
||||
|
||||
follow_ui.group = REGISTER_STAT_GROUP_GENERIC;
|
||||
|
@ -505,6 +505,7 @@ follow_register(gpointer data, gpointer user_data _U_)
|
|||
follow_ui.nparams = 0;
|
||||
follow_ui.params = NULL;
|
||||
register_stat_tap_ui(&follow_ui, follower);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue