Add tshark -G dissector-tables to dump a list of dissector tables.

That list doesn't show the entries in the dissector tables, just
information about the tables themselves.

Clean up some tshark man page issues while we're at it.

Change-Id: I70beee34110f5c0d58105944dd71105a8400f5ca
Reviewed-on: https://code.wireshark.org/review/5360
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-11-16 18:25:56 -08:00
parent 57b72275b7
commit 25f950eca9
5 changed files with 99 additions and 3 deletions

View File

@ -54,7 +54,7 @@ S<[ B<--capture-comment> E<lt>commentE<gt> ]>
S<[ E<lt>capture filterE<gt> ]>
B<tshark>
B<-G> [column-formats|currentprefs|decodes|defaultprefs|fields|ftypes|heuristic-decodes|plugins|protocols|values]
B<-G> [ E<lt>report typeE<gt> ]
=head1 DESCRIPTION
@ -355,7 +355,7 @@ This option causes the output file(s) to be created with group-read permission
(meaning that the output file(s) can be read by other members of the calling
user's group).
=item -G [column-formats|currentprefs|decodes|defaultprefs|fields|ftypes|heuristic-decodes|plugins|protocols|values]
=item -G [ E<lt>report typeE<gt> ]
The B<-G> option will cause B<Tshark> to dump one of several types of glossaries
and then exit. If no specific glossary type is specified, then the B<fields> report will be generated by default.
@ -379,6 +379,14 @@ There is one record per line. The fields are tab-delimited.
B<defaultprefs> Dumps a default preferences file to stdout.
B<dissector-tables> Dumps a list of dissector tables to stdout. There
is one record per line. The fields are tab-delimited.
* Field 1 = dissector table name, e.g. "tcp.port"
* Field 2 = name used for the dissector table in the GUI
* Field 3 = type (textual representation of the ftenum type)
* Field 4 = base for display (for integer types)
B<fields> Dumps the contents of the registration database to
stdout. An independent program can take this output and format it into nice
tables or HTML or whatever. There is one record per line. Each record is
@ -396,7 +404,7 @@ The fields are tab-delimited.
* Field 1 = 'F'
* Field 2 = descriptive field name
* Field 3 = field abbreviation
* Field 4 = type ( textual representation of the ftenum type )
* Field 4 = type (textual representation of the ftenum type)
* Field 5 = parent protocol abbreviation
* Field 6 = base for display (for integer types); "parent bitfield width" for FT_BOOLEAN
* Field 7 = bitmask: format: hex: 0x....

View File

@ -2362,6 +2362,7 @@ void call_heur_dissector_direct(heur_dtbl_entry_t *heur_dtbl_entry, tvbuff_t *tv
pinfo->heur_list_name = saved_heur_list_name;
}
/*
* Dumps the "layer type"/"decode as" associations to stdout, similar
* to the proto_registrar_dump_*() routines.
@ -2419,6 +2420,83 @@ dissector_dump_decodes(void)
dissector_all_tables_foreach(dissector_dump_decodes_display, NULL);
}
/*
* 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_dissector_tables_display (gpointer key, gpointer user_data _U_)
{
const char *table_name = (const char *)key;
dissector_table_t table;
table = (dissector_table_t)g_hash_table_lookup(dissector_tables, key);
printf("%s\t%s\t%s", table_name, table->ui_name, ftype_name(table->type));
switch (table->type) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
switch(table->base) {
case BASE_NONE:
printf("\tBASE_NONE");
break;
case BASE_DEC:
printf("\tBASE_DEC");
break;
case BASE_HEX:
printf("\tBASE_HEX");
break;
case BASE_DEC_HEX:
printf("\tBASE_DEC_HEX");
break;
case BASE_HEX_DEC:
printf("\tBASE_HEX_DEC");
break;
default:
printf("\t%d", table->base);
break;
}
break;
default:
break;
}
printf("\n");
}
static gint
compare_dissector_key_name(gconstpointer dissector_a, gconstpointer dissector_b)
{
return strcmp((const char*)dissector_a, (const char*)dissector_b);
}
void
dissector_dump_dissector_tables(void)
{
GList *list;
list = g_hash_table_get_keys(dissector_tables);
list = g_list_sort(list, compare_dissector_key_name);
g_list_foreach(list, dissector_dump_dissector_tables_display, NULL);
g_list_free(list);
}
static GPtrArray* post_dissectors = NULL;
static guint num_of_postdissectors = 0;

View File

@ -214,6 +214,10 @@ WS_DLL_PUBLIC ftenum_t get_dissector_table_selector_type(const char *name);
sub-dissector table, given the table's internal name */
WS_DLL_PUBLIC int get_dissector_table_base(const char *name);
/* Dump all dissector tables to the standard output (not the entries,
just the information about the tables) */
WS_DLL_PUBLIC void dissector_dump_dissector_tables(void);
/* Add an entry to a uint dissector table. */
WS_DLL_PUBLIC void dissector_add_uint(const char *abbrev, const guint32 pattern,
dissector_handle_t handle);

View File

@ -269,6 +269,7 @@ glossary_option_help(void)
fprintf(output, "Glossary table reports:\n");
fprintf(output, " -G column-formats dump column format codes and exit\n");
fprintf(output, " -G decodes dump \"layer type\"/\"decode as\" associations and exit\n");
fprintf(output, " -G dissector-tables dump dissector table names, types, and properties\n");
fprintf(output, " -G fields dump fields glossary and exit\n");
fprintf(output, " -G ftypes dump field type basic and descriptive names\n");
fprintf(output, " -G heuristic-decodes dump heuristic dissector tables\n");
@ -998,6 +999,8 @@ main(int argc, char *argv[])
dissector_dump_decodes();
else if (strcmp(argv[2], "defaultprefs") == 0)
write_prefs(NULL);
else if (strcmp(argv[2], "dissector-tables") == 0)
dissector_dump_dissector_tables();
else if (strcmp(argv[2], "fields") == 0)
proto_registrar_dump_fields();
else if (strcmp(argv[2], "ftypes") == 0)

View File

@ -417,6 +417,7 @@ glossary_option_help(void)
fprintf(output, "Glossary table reports:\n");
fprintf(output, " -G column-formats dump column format codes and exit\n");
fprintf(output, " -G decodes dump \"layer type\"/\"decode as\" associations and exit\n");
fprintf(output, " -G dissector-tables dump dissector table names, types, and properties\n");
fprintf(output, " -G fields dump fields glossary and exit\n");
fprintf(output, " -G ftypes dump field type basic and descriptive names\n");
fprintf(output, " -G heuristic-decodes dump heuristic dissector tables\n");
@ -1227,6 +1228,8 @@ main(int argc, char *argv[])
dissector_dump_decodes();
else if (strcmp(argv[2], "defaultprefs") == 0)
write_prefs(NULL);
else if (strcmp(argv[2], "dissector-tables") == 0)
dissector_dump_dissector_tables();
else if (strcmp(argv[2], "fields") == 0)
proto_registrar_dump_fields();
else if (strcmp(argv[2], "ftypes") == 0)