#include <string.h>
#include <epan/proto.h>
+#include <epan/packet.h>
#include "clopts_common.h"
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]);
}
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);
+}
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 */