Add tshark option '-G heuristic-decodes' to dump heuristic dissector tables.
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 28 Dec 2011 15:05:59 +0000 (15:05 +0000)
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 28 Dec 2011 15:05:59 +0000 (15:05 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@40309 f5534014-38df-0310-8fa8-9805f1628bb7

epan/libwireshark.def
epan/packet.c
epan/packet.h
tshark.c

index 82258be50a42b9e01ddf8600d7af49c6b4bb3f7b..acfd14b08f8e63ab935cf0b05294584eb1a776a0 100644 (file)
@@ -329,6 +329,7 @@ dissector_change_uint
 dissector_delete_string
 dissector_delete_uint
 dissector_dump_decodes
+dissector_dump_heur_decodes
 dissector_filter_list           DATA
 dissector_get_string_handle
 dissector_get_uint_handle
index 95a1e2286a31c21faeb406c4e8e21c8cb8c508bb..9759f969b6cc1975cf37bfae47c6303a54928e55 100644 (file)
@@ -1559,7 +1559,7 @@ get_dissector_table_base(const char *name)
 static GHashTable *heur_dissector_lists = NULL;
 
 
-/* Finds a heuristic dissector table by field name. */
+/* Finds a heuristic dissector table by table name. */
 static heur_dissector_list_t *
 find_heur_dissector_list(const char *name)
 {
@@ -1722,6 +1722,26 @@ typedef struct heur_dissector_foreach_table_info {
        DATFunc_heur_table caller_func;
 } heur_dissector_foreach_table_info_t;
 
+
+static void
+dissector_dump_heur_decodes_display(const gchar *table_name, const gpointer value, const gpointer user_data _U_)
+{
+       heur_dissector_list_t  sub_dissectors = *(heur_dissector_list_t *)value;
+       GSList                *entry;
+       heur_dtbl_entry_t     *dtbl_entry;
+
+       for (entry = sub_dissectors; entry != NULL; entry = g_slist_next(entry)) {
+               dtbl_entry = (heur_dtbl_entry_t *)entry->data;
+               if (dtbl_entry->protocol != NULL) {
+                       printf("%s\t%s\t%c\n",
+                              table_name,
+                              proto_get_protocol_filter_name(proto_get_id(dtbl_entry->protocol)),
+                              (proto_is_protocol_enabled(dtbl_entry->protocol) && dtbl_entry->enabled) ? 'T' : 'F');
+               }
+       }
+}
+
+
 static void
 dissector_all_heur_tables_foreach_table_func (gpointer key, const gpointer value, const gpointer user_data)
 {
@@ -1746,6 +1766,16 @@ dissector_all_heur_tables_foreach_table (DATFunc_heur_table func,
        g_hash_table_foreach(heur_dissector_lists, dissector_all_heur_tables_foreach_table_func, &info);
 }
 
+/*
+ * For each heuristic dissector table, dump list of dissectors (filter_names) for that table
+ */
+void
+dissector_dump_heur_decodes(void)
+{
+       dissector_all_heur_tables_foreach_table(dissector_dump_heur_decodes_display, NULL);
+}
+
+
 void
 register_heur_dissector_list(const char *name, heur_dissector_list_t *sub_dissectors)
 {
index f355ce5dbad9b884f44f6ad7b81ec8a092eeddfa..c3caf370c09cbacfa75ea6b042d537d0e34e2fc4 100644 (file)
@@ -457,6 +457,11 @@ extern void ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_ethertype,
  */
 extern void dissector_dump_decodes(void);
 
+/*
+ * For each heuristic dissector table, dump list of dissectors (filter_names) for that table
+ */
+extern void dissector_dump_heur_decodes(void);
+
 /*
  * post dissectors are to be called by packet-frame.c after every other
  * dissector has been called.
index d9d038d86462a778838f8866771485e099ac1f44..e1b11cef6fe33ef2ad9be436312f07080c2ebdb0 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -351,6 +351,7 @@ glossary_option_help(void)
   fprintf(output, "  -G values                dump value, range, true/false strings and exit\n");
   fprintf(output, "  -G ftypes                dump field type basic and descriptive names\n");
   fprintf(output, "  -G decodes               dump \"layer type\"/\"decode as\" associations and exit\n");
+  fprintf(output, "  -G heuristic-decodes     dump heuristic dissector tables\n");
   fprintf(output, "\n");
   fprintf(output, "Preference reports:\n");
   fprintf(output, "  -G defaultprefs          dump default preferences and exit\n");
@@ -998,6 +999,8 @@ main(int argc, char *argv[])
         proto_registrar_dump_ftypes();
       else if (strcmp(argv[2], "decodes") == 0)
         dissector_dump_decodes();
+      else if (strcmp(argv[2], "heuristic-decodes") == 0)
+        dissector_dump_heur_decodes();
       else if (strcmp(argv[2], "defaultprefs") == 0)
         write_prefs(NULL);
       else if (strcmp(argv[2], "plugins") == 0)