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
12 # Gilbert Ramirez <gram [AT] alumni.rice.edu>
14 # Wireshark - Network traffic analyzer
15 # By Gerald Combs <gerald@wireshark.org>
16 # Copyright 1998 Gerald Combs
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License
20 # as published by the Free Software Foundation; either version 2
21 # of the License, or (at your option) any later version.
23 # This program is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 # GNU General Public License for more details.
28 # You should have received a copy of the GNU General Public License
29 # along with this program; if not, write to the Free Software
30 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 'FT_NONE', 'No value',
34 'FT_PROTOCOL', 'Protocol',
35 'FT_BOOLEAN', 'Boolean',
36 'FT_UINT8', 'Unsigned 8-bit integer',
37 'FT_UINT16', 'Unsigned 16-bit integer',
38 'FT_UINT24', 'Unsigned 24-bit integer',
39 'FT_UINT32', 'Unsigned 32-bit integer',
40 'FT_UINT64', 'Unsigned 64-bit integer',
41 'FT_INT8', 'Signed 8-bit integer',
42 'FT_INT16', 'Signed 16-bit integer',
43 'FT_INT24', 'Signed 24-bit integer',
44 'FT_INT32', 'Signed 32-bit integer',
45 'FT_INT64', 'Signed 64-bit integer',
46 'FT_FLOAT', 'Single-precision floating point',
47 'FT_DOUBLE', 'Double-precision floating point',
48 'FT_ABSOLUTE_TIME', 'Date/Time stamp',
49 'FT_RELATIVE_TIME', 'Time duration',
50 'FT_STRING', 'String',
51 'FT_STRINGZ', 'NULL terminated string',
52 'FT_EBCDIC', 'EBCDIC string',
53 'FT_UINT_STRING', 'Length string pair',
54 'FT_ETHER', '6-byte Hardware (MAC) Address',
55 'FT_BYTES', 'Byte array',
56 'FT_UINT_BYTES', 'Length byte array pair',
57 'FT_IPv4', 'IPv4 address',
58 'FT_IPv6', 'IPv6 address',
59 'FT_IPXNET', 'IPX network or server name',
60 'FT_FRAMENUM', 'Frame number',
61 'FT_PCRE', 'Perl Compatible Regular Expression',
62 'FT_GUID', 'Globally Unique Identifier',
63 'FT_OID', 'Object Identifier',
64 'FT_REL_OID', 'Relative Object Identifier',
67 # Read all the data into memory
69 next unless (/^([PF])/);
72 # Strip the line from its line-end sequence
73 # chomp($_) won't work on Win32/CygWin as it leaves the '\r' character.
79 # Store protocol information
80 if ($record_type eq 'P') {
81 ($junk, $name, $abbrev) = split(/\t+/, $_);
82 $proto_abbrev{$name} = $abbrev;
84 # Store header field information
86 ($junk, $name, $abbrev, $type, $parent, $blurb) =
88 push(@{$field_abbrev{$parent}}, $abbrev);
89 $field_info{$abbrev} = [ $name, $type, $blurb ];
93 # if there was no input on stdin, bail out
94 if ($record_type ne 'P' and $record_type ne 'F') {
98 $template = shift(@ARGV);
100 open(TEMPLATE, $template) || die "Can't open $template for reading: $!\n";
103 if (/=insert_dfilter_table/) {
104 &create_dfilter_table;
111 close(TEMPLATE) || die "Can't close $template: $!\n";
113 sub create_dfilter_table {
115 print "<appendix id=\"AppFiltFields\"><title>Wireshark Display Filter Fields</title>\n";
118 # Print each protocol
119 for $proto_name (sort keys %proto_abbrev) {
121 $ns_proto_name = $proto_name;
122 $ns_proto_name =~ s/\s//g;
123 $ns_proto_name =~ s/\)//g;
124 $ns_proto_name =~ s/\(//g;
125 $ns_proto_name =~ s/_//g;
126 $ns_proto_name =~ s/\+/plus/g;
127 $ns_proto_name =~ s/\//slash/g;
128 $ns_proto_name =~ s/,/comma/g;
129 $ns_proto_name =~ s/:/colon/g;
130 $ns_proto_name =~ s/'/apos/g;
132 # The maximum token name length is apparently 44 characters.
133 # That's what NAMELEN is defined as in docbook 4.1, at least.
135 if (length ($ns_proto_name) > 41) { # "SID" and "TID" are prepended below
136 $ns_proto_name = sprintf ("%s%04d", substr($ns_proto_name, 0,
141 print "<section id=\"SID$ns_proto_name\"><title>$proto_name ($proto_abbrev{$proto_name})</title>\n\n";
143 print "<table id=\"TID$ns_proto_name\"><title>$proto_name ($proto_abbrev{$proto_name})</title>\n";
144 print "<tgroup cols=\"4\">\n";
145 # print "<colspec colnum=\"1\" colwidth=\"80pt\">\n";
146 # print "<colspec colnum=\"2\" colwidth=\"80pt\"\n>";
147 print "<thead>\n <row>\n ";
148 print "<entry>Field</>\n <entry>Field Name</>\n <entry>Type</>\n <entry>Description</>\n\n";
150 print " </row>\n</thead>\n<tbody>\n";
152 # If this proto has children fields, print those
153 if ($field_abbrev{$proto_abbrev{$proto_name}}) {
155 for $field_abbrev (sort @{$field_abbrev{$proto_abbrev{$proto_name}}}) {
158 print " <entry>$field_abbrev</entry>\n";
159 print " <entry>", $field_info{$field_abbrev}[0], "</entry>\n";
160 print " <entry>", $ftenum_names{$field_info{$field_abbrev}[1]}, "</entry>\n";
161 print " <entry>", $field_info{$field_abbrev}[2], "</>\n";
169 print " <row>\n <entry></entry>\n <entry></entry>\n <entry></entry><entry></entry>\n";
174 print "</tbody></tgroup></table>\n";
175 print "</section>\n\n";
179 print "</appendix>\n";