Added dissector_delete_all() to remove all entries from a dissector table.
authorStig Bjørlykke <stig@bjorlykke.org>
Mon, 9 Sep 2013 05:36:45 +0000 (05:36 -0000)
committerStig Bjørlykke <stig@bjorlykke.org>
Mon, 9 Sep 2013 05:36:45 +0000 (05:36 -0000)
svn path=/trunk/; revision=51859

epan/packet.c
epan/packet.h

index bbe2f409510404cbd1bd2f2a94c5249c3f3a3075..9d1a48046dcde8aa6cf4c3a0ebf28406621ca79a 100644 (file)
@@ -894,6 +894,24 @@ void dissector_delete_uint_range(const char *abbrev, range_t *range,
        }
 }
 
+static gboolean
+dissector_delete_all_check (gpointer key _U_, gpointer value, gpointer user_data)
+{
+       dtbl_entry_t *dtbl_entry = value;
+       dissector_handle_t handle = user_data;
+
+       return (proto_get_id (dtbl_entry->current->protocol) == proto_get_id (handle->protocol));
+}
+
+/* Delete all entries from a dissector table. */
+void dissector_delete_all(const char *name, dissector_handle_t handle)
+{
+       dissector_table_t sub_dissectors = find_dissector_table(name);
+       g_assert (sub_dissectors);
+
+       g_hash_table_foreach_remove (sub_dissectors->hash_table, dissector_delete_all_check, handle);
+}
+
 /* Change the entry for a dissector in a uint dissector table
    with a particular pattern to use a new dissector handle. */
 void
index 212b20c7d82480aac252d01e45b889c54b1ac6e7..09bc726d02923fbc3a30beb5ad6dc7445ceb486d 100644 (file)
@@ -188,6 +188,9 @@ WS_DLL_PUBLIC void dissector_delete_uint(const char *name, const guint32 pattern
 WS_DLL_PUBLIC void dissector_delete_uint_range(const char *abbrev, range_t *range,
     dissector_handle_t handle);
 
+/* Delete all entries from a dissector table. */
+WS_DLL_PUBLIC void dissector_delete_all(const char *name, dissector_handle_t handle);
+
 /* Change the entry for a dissector in a uint dissector table
    with a particular pattern to use a new dissector handle. */
 WS_DLL_PUBLIC void dissector_change_uint(const char *abbrev, const guint32 pattern,