Add a "-G decodes" option to ethereal and tethereal which shows the
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. svn path=/trunk/; revision=13721
This commit is contained in:
parent
abe1feed27
commit
76ba06d767
|
@ -30,6 +30,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <epan/proto.h>
|
#include <epan/proto.h>
|
||||||
|
#include <epan/packet.h>
|
||||||
|
|
||||||
#include "clopts_common.h"
|
#include "clopts_common.h"
|
||||||
|
|
||||||
|
@ -52,6 +53,8 @@ handle_dashG_option(int argc, char **argv, char *progname)
|
||||||
proto_registrar_dump_protocols();
|
proto_registrar_dump_protocols();
|
||||||
else if (strcmp(argv[2], "values") == 0)
|
else if (strcmp(argv[2], "values") == 0)
|
||||||
proto_registrar_dump_values();
|
proto_registrar_dump_values();
|
||||||
|
else if (strcmp(argv[2], "decodes") == 0)
|
||||||
|
dissector_dump_decodes();
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "%s: Invalid \"%s\" option for -G flag\n", progname,
|
fprintf(stderr, "%s: Invalid \"%s\" option for -G flag\n", progname,
|
||||||
argv[2]);
|
argv[2]);
|
||||||
|
|
|
@ -1696,3 +1696,58 @@ call_dissector(dissector_handle_t handle, tvbuff_t *tvb,
|
||||||
}
|
}
|
||||||
return ret;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -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,
|
packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,
|
||||||
int etype_id, int trailer_id, int fcs_len);
|
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 */
|
#endif /* packet.h */
|
||||||
|
|
Loading…
Reference in New Issue