diff options
-rw-r--r-- | epan/packet.c | 43 | ||||
-rw-r--r-- | epan/packet.h | 16 | ||||
-rw-r--r-- | epan/wslua/wslua_proto.c | 2 | ||||
-rw-r--r-- | ui/gtk/dissector_tables_dlg.c | 2 |
4 files changed, 52 insertions, 11 deletions
diff --git a/epan/packet.c b/epan/packet.c index a0379a5c25..6dd5e9c613 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1724,6 +1724,7 @@ typedef struct dissector_foreach_table_info { /* * Called for each entry in the table of all dissector tables. + * This is used if we directly process the hash table. */ static void dissector_all_tables_foreach_table_func (gpointer key, const gpointer value, const gpointer user_data) @@ -1738,6 +1739,7 @@ dissector_all_tables_foreach_table_func (gpointer key, const gpointer value, con /* * Called for each key in the table of all dissector tables. + * This is used if we get a list of table names, sort it, and process the list. */ static void dissector_all_tables_foreach_list_func (gpointer key, gpointer user_data) @@ -1756,8 +1758,8 @@ dissector_all_tables_foreach_list_func (gpointer key, gpointer user_data) */ void dissector_all_tables_foreach_table (DATFunc_table func, - gpointer user_data, - GCompareFunc compare_key_func) + gpointer user_data, + GCompareFunc compare_key_func) { dissector_foreach_table_info_t info; GList *list; @@ -2072,6 +2074,10 @@ dissector_dump_heur_decodes_display(const gchar *table_name, heur_dissector_list } +/* + * Called for each entry in the table of all heuristic dissector tables. + * This is used if we directly process the hash table. + */ static void dissector_all_heur_tables_foreach_table_func (gpointer key, const gpointer value, const gpointer user_data) { @@ -2082,18 +2088,45 @@ dissector_all_heur_tables_foreach_table_func (gpointer key, const gpointer value } /* + * Called for each key in the table of all dissector tables. + * This is used if we get a list of table names, sort it, and process the list. + */ +static void +dissector_all_heur_tables_foreach_list_func (gpointer key, gpointer user_data) +{ + heur_dissector_list_t *list; + heur_dissector_foreach_table_info_t *info; + + list = (heur_dissector_list_t *)g_hash_table_lookup(heur_dissector_lists, key); + info = (heur_dissector_foreach_table_info_t *)user_data; + (*info->caller_func)((gchar*)key, list, info->caller_data); +} + +/* * Walk all heuristic dissector tables calling a user supplied function on each * table. */ void dissector_all_heur_tables_foreach_table (DATFunc_heur_table func, - gpointer user_data) + gpointer user_data, + GCompareFunc compare_key_func) { heur_dissector_foreach_table_info_t info; + GList *list; info.caller_data = user_data; info.caller_func = func; - g_hash_table_foreach(heur_dissector_lists, dissector_all_heur_tables_foreach_table_func, &info); + if (compare_key_func != NULL) + { + list = g_hash_table_get_keys(dissector_tables); + list = g_list_sort(list, compare_key_func); + g_list_foreach(list, dissector_all_heur_tables_foreach_list_func, &info); + g_list_free(list); + } + else + { + g_hash_table_foreach(heur_dissector_lists, dissector_all_heur_tables_foreach_table_func, &info); + } } /* @@ -2102,7 +2135,7 @@ dissector_all_heur_tables_foreach_table (DATFunc_heur_table func, void dissector_dump_heur_decodes(void) { - dissector_all_heur_tables_foreach_table(dissector_dump_heur_decodes_display, NULL); + dissector_all_heur_tables_foreach_table(dissector_dump_heur_decodes_display, NULL, NULL); } diff --git a/epan/packet.h b/epan/packet.h index 66cce73667..2ac0b8b82b 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -183,12 +183,12 @@ WS_DLL_PUBLIC void dissector_table_foreach_handle(const char *table_name, DATFun /** Iterate over all dissector tables. * - * Walk all dissector tables calling a user supplied function on each + * Walk the set of dissector tables calling a user supplied function on each * table. * @param[in] func The function to call for each table. * @param[in] user_data User data to pass to the function. - * @param[in] compare_key_func Function used to sort tables before calling - * the function. No sorting is done if NULL. */ + * @param[in] compare_key_func Function used to sort the set of tables before + * calling the function. No sorting is done if NULL. */ WS_DLL_PUBLIC void dissector_all_tables_foreach_table (DATFunc_table func, gpointer user_data, GCompareFunc compare_key_func); @@ -359,8 +359,16 @@ WS_DLL_PUBLIC void register_heur_dissector_list(const char *name, typedef void (*DATFunc_heur_table) (const gchar *table_name, heur_dissector_list_t *table, gpointer user_data); +/** Iterate over all heuristic dissector tables. + * + * Walk the set of heuristic dissector tables calling a user supplied function + * on each table. + * @param[in] func The function to call for each table. + * @param[in] user_data User data to pass to the function. + * @param[in] compare_key_func Function used to sort the set of tables before + * calling the function. No sorting is done if NULL. */ WS_DLL_PUBLIC void dissector_all_heur_tables_foreach_table (DATFunc_heur_table func, - gpointer user_data); + gpointer user_data, GCompareFunc compare_key_func); /* true if a heur_dissector list of that anme exists to be registered into */ WS_DLL_PUBLIC gboolean has_heur_dissector_list(const gchar *name); diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c index 66a90b066f..0ff0e651b0 100644 --- a/epan/wslua/wslua_proto.c +++ b/epan/wslua/wslua_proto.c @@ -2262,7 +2262,7 @@ WSLUA_CONSTRUCTOR DissectorTable_heuristic_list (lua_State *L) { lua_newtable(L); - dissector_all_heur_tables_foreach_table(heur_dissector_tables_list_func, (gpointer)&data); + dissector_all_heur_tables_foreach_table(heur_dissector_tables_list_func, (gpointer)&data, NULL); WSLUA_RETURN(1); /* The array table of registered heuristic list names */ } diff --git a/ui/gtk/dissector_tables_dlg.c b/ui/gtk/dissector_tables_dlg.c index e8db2c993a..f87dea7578 100644 --- a/ui/gtk/dissector_tables_dlg.c +++ b/ui/gtk/dissector_tables_dlg.c @@ -373,7 +373,7 @@ dissector_tables_dlg_init(void) /* Fill the table with data */ dissector_all_tables_foreach_table(display_dissector_table_names, (gpointer)&dis_tbl_trees, NULL); - dissector_all_heur_tables_foreach_table(display_heur_dissector_table_names, (gpointer)&dis_tbl_trees); + dissector_all_heur_tables_foreach_table(display_heur_dissector_table_names, (gpointer)&dis_tbl_trees, NULL); sortable = GTK_TREE_SORTABLE(gtk_tree_view_get_model(GTK_TREE_VIEW(dis_tbl_trees.str_tree_wgt))); gtk_tree_sortable_set_sort_column_id(sortable, TABLE_UI_NAME_COL, GTK_SORT_ASCENDING); |