3 # Reads the display filter keyword dump produced by 'tshark -G' and
4 # formats it for a pod document. The pod document is then used to
7 # STDIN is the wireshark glossary
8 # arg1 is the pod template file. The =insert_dfilter_table token
9 # will be replaced by the pod-formatted glossary
10 # STDOUT is the output
17 'FT_NONE', 'No value',
18 'FT_PROTOCOL', 'Protocol',
19 'FT_BOOLEAN', 'Boolean',
20 'FT_UINT8', 'Unsigned 8-bit integer',
21 'FT_UINT16', 'Unsigned 16-bit integer',
22 'FT_UINT24', 'Unsigned 24-bit integer',
23 'FT_UINT32', 'Unsigned 32-bit integer',
24 'FT_UINT64', 'Unsigned 64-bit integer',
25 'FT_INT8', 'Signed 8-bit integer',
26 'FT_INT16', 'Signed 16-bit integer',
27 'FT_INT24', 'Signed 24-bit integer',
28 'FT_INT32', 'Signed 32-bit integer',
29 'FT_INT64', 'Signed 64-bit integer',
30 'FT_FLOAT', 'Single-precision floating point',
31 'FT_DOUBLE', 'Double-precision floating point',
32 'FT_ABSOLUTE_TIME', 'Date/Time stamp',
33 'FT_RELATIVE_TIME', 'Time duration',
34 'FT_STRING', 'String',
35 'FT_STRINGZ', 'NULL terminated string',
36 'FT_EBCDIC', 'EBCDIC string',
37 'FT_UINT_STRING', 'Length string pair',
38 'FT_ETHER', '6-byte Hardware (MAC) Address',
39 'FT_BYTES', 'Byte array',
40 'FT_UINT_BYTES', 'Length byte array pair',
41 'FT_IPv4', 'IPv4 address',
42 'FT_IPv6', 'IPv6 address',
43 'FT_IPXNET', 'IPX network or server name',
44 'FT_FRAMENUM', 'Frame number',
45 'FT_PCRE', 'Perl Compatible Regular Expression',
46 'FT_GUID', 'Globally Unique Identifier',
47 'FT_OID', 'Object Identifier',
53 $proto_abbrev{'Unable to generate filter documentation'} =
54 'Please refer to http://www.wireshark.org/docs/dfref/';
55 printf STDERR "Creating empty filter list.\n";
57 # Read all the data into memory
59 next unless (/^([PF])/);
62 # Strip the line from its line-end sequence
63 # chomp($_) won't work on Win32/CygWin as it leaves the '\r' character.
66 # Store protocol information
67 if ($record_type eq 'P') {
68 ($junk, $name, $abbrev) = split(/\t+/, $_);
69 $proto_abbrev{$name} = $abbrev;
71 # Store header field information
73 ($junk, $name, $abbrev, $type, $parent, $blurb) =
75 push(@{$field_abbrev{$parent}}, $abbrev);
76 $field_info{$abbrev} = [ $name, $type, $blurb ];
81 # if there was no input on stdin, bail out
82 if ($record_type ne 'P' and $record_type ne 'F' and !defined($opt_e)) {
86 $template = shift(@ARGV);
88 open(TEMPLATE, $template) || die "Can't open $template for reading: $!\n";
91 if (/=insert_dfilter_table/) {
92 &create_dfilter_table;
99 close(TEMPLATE) || die "Can't close $template: $!\n";
101 sub create_dfilter_table {
103 # Print each protocol
104 for $proto_name (sort keys %proto_abbrev) {
106 print "=head2 $proto_name ($proto_abbrev{$proto_name})\n\n";
108 # If this proto has children fields, print those
109 if ($field_abbrev{$proto_abbrev{$proto_name}}) {
111 for $field_abbrev (sort @{$field_abbrev{$proto_abbrev{$proto_name}}}) {
112 print " $field_abbrev ", $field_info{$field_abbrev}[0],"\n",
113 " ", $ftenum_names{$field_info{$field_abbrev}[1]},
115 print " ", $field_info{$field_abbrev}[2], "\n"
116 if $field_info{$field_abbrev}[2];