Add a "-G decodes" option to ethereal and tethereal which shows the
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 11 Mar 2005 16:17:41 +0000 (16:17 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 11 Mar 2005 16:17:41 +0000 (16:17 +0000)
filter/selector/protocol associations for each dissector.  This will be
used to improve our automated tests, but someone with time on their
hands could probably use it to generate a protocol poster using Graphviz.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@13721 f5534014-38df-0310-8fa8-9805f1628bb7

clopts_common.c
epan/packet.c
epan/packet.h

index 12227c44850b434adb07931c7b919efec8f24c11..31aa75a8b87209649c768ded504dfa74fcceca7f 100644 (file)
@@ -30,6 +30,7 @@
 #include <string.h>
 
 #include <epan/proto.h>
+#include <epan/packet.h>
 
 #include "clopts_common.h"
 
@@ -52,6 +53,8 @@ handle_dashG_option(int argc, char **argv, char *progname)
         proto_registrar_dump_protocols();
       else if (strcmp(argv[2], "values") == 0)
         proto_registrar_dump_values();
+      else if (strcmp(argv[2], "decodes") == 0)
+        dissector_dump_decodes();
       else {
         fprintf(stderr, "%s: Invalid \"%s\" option for -G flag\n", progname,
                 argv[2]);
index a9e2a0814bfd4a67941e983d24462db4230f5a61..2b3bc50c78c5f65e909ea896a8a536536d1d0a91 100644 (file)
@@ -1696,3 +1696,58 @@ call_dissector(dissector_handle_t handle, tvbuff_t *tvb,
        }
        return ret;
 }
+
+/*
+ * Dumps the "layer type"/"decode as" associations to stdout, similar
+ * to the proto_registrar_dump_*() routines.
+ *
+ * There is one record per line. The fields are tab-delimited.
+ *
+ * Field 1 = layer type, e.g. "tcp.port"
+ * Field 2 = selector in decimal
+ * Field 3 = "decode as" name, e.g. "http"
+ */
+
+
+static void
+dissector_dump_decodes_display(gchar *table_name, ftenum_t selector_type _U_,
+    gpointer key, gpointer value, gpointer user_data _U_)
+{
+       guint32 selector = (guint32) key;
+       dissector_table_t sub_dissectors = find_dissector_table(table_name);
+       dtbl_entry_t *dtbl_entry;
+       dissector_handle_t handle;
+       gint proto_id;
+       gchar *decode_as;
+
+       g_assert(sub_dissectors);
+       switch (sub_dissectors->type) {
+
+               case FT_UINT8:
+               case FT_UINT16:
+               case FT_UINT24:
+               case FT_UINT32:
+                       dtbl_entry = value;
+                       g_assert(dtbl_entry);
+
+                       handle = dtbl_entry->current;
+                       g_assert(handle);
+
+                       proto_id = dissector_handle_get_protocol_index(handle);
+
+                       if (proto_id != -1) {
+                               decode_as = proto_get_protocol_filter_name(proto_id);
+                               g_assert(decode_as != NULL);
+                               printf("%s\t%d\t%s\n", table_name, selector, decode_as);
+                       }
+                       break;
+
+       default:
+               break;
+       }
+}
+
+void
+dissector_dump_decodes() {
+       dissector_all_tables_foreach(dissector_dump_decodes_display, NULL);
+}
index 7fcc67c9294cf45ed794f3ca2ba5d236ed4f23e9..5d16892b7d13a78d77d6d70dd9e0be350175b4b7 100644 (file)
@@ -367,4 +367,10 @@ extern void ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_ethertype,
                packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,
                int etype_id, int trailer_id, int fcs_len);
 
+/*
+ * Dump layer/selector/dissector records in a fashion similar to the
+ * proto_registrar_dump_* routines.
+ */
+extern void dissector_dump_decodes();
+
 #endif /* packet.h */