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
15 'FT_NONE', 'No value',
16 'FT_PROTOCOL', 'Protocol',
17 'FT_BOOLEAN', 'Boolean',
18 'FT_UINT8', 'Unsigned 8-bit integer',
19 'FT_UINT16', 'Unsigned 16-bit integer',
20 'FT_UINT24', 'Unsigned 24-bit integer',
21 'FT_UINT32', 'Unsigned 32-bit integer',
22 'FT_UINT64', 'Unsigned 64-bit integer',
23 'FT_INT8', 'Signed 8-bit integer',
24 'FT_INT16', 'Signed 16-bit integer',
25 'FT_INT24', 'Signed 24-bit integer',
26 'FT_INT32', 'Signed 32-bit integer',
27 'FT_INT64', 'Signed 64-bit integer',
28 'FT_FLOAT', 'Single-precision floating point',
29 'FT_DOUBLE', 'Double-precision floating point',
30 'FT_ABSOLUTE_TIME', 'Date/Time stamp',
31 'FT_RELATIVE_TIME', 'Time duration',
32 'FT_STRING', 'String',
33 'FT_STRINGZ', 'NULL terminated string',
34 'FT_EBCDIC', 'EBCDIC string',
35 'FT_UINT_STRING', 'Length string pair',
36 'FT_ETHER', '6-byte Hardware (MAC) Address',
37 'FT_BYTES', 'Byte array',
38 'FT_UINT_BYTES', 'Length byte array pair',
39 'FT_IPv4', 'IPv4 address',
40 'FT_IPv6', 'IPv6 address',
41 'FT_IPXNET', 'IPX network or server name',
42 'FT_FRAMENUM', 'Frame number',
43 'FT_PCRE', 'Perl Compatible Regular Expression',
44 'FT_GUID', 'Globally Unique Identifier',
45 'FT_OID', 'Object Identifier',
48 # Read all the data into memory
50 next unless (/^([PF])/);
53 # Strip the line from its line-end sequence
54 # chomp($_) won't work on Win32/CygWin as it leaves the '\r' character.
60 # Store protocol information
61 if ($record_type eq 'P') {
62 ($junk, $name, $abbrev) = split(/\t+/, $_);
63 $proto_abbrev{$name} = $abbrev;
65 # Store header field information
67 ($junk, $name, $abbrev, $type, $parent, $blurb) =
69 push(@{$field_abbrev{$parent}}, $abbrev);
70 $field_info{$abbrev} = [ $name, $type, $blurb ];
74 # if there was no input on stdin, bail out
75 if ($record_type ne 'P' and $record_type ne 'F') {
79 $template = shift(@ARGV);
81 open(TEMPLATE, $template) || die "Can't open $template for reading: $!\n";
84 if (/=insert_dfilter_table/) {
85 &create_dfilter_table;
92 close(TEMPLATE) || die "Can't close $template: $!\n";
94 sub create_dfilter_table {
96 print "<appendix id=\"AppFiltFields\"><title>Wireshark Display Filter Fields</title>\n";
100 for $proto_name (sort keys %proto_abbrev) {
102 $ns_proto_name = $proto_name;
103 $ns_proto_name =~ s/\s//g;
104 $ns_proto_name =~ s/\)//g;
105 $ns_proto_name =~ s/\(//g;
106 $ns_proto_name =~ s/_//g;
107 $ns_proto_name =~ s/\+/plus/g;
108 $ns_proto_name =~ s/\//slash/g;
109 $ns_proto_name =~ s/,/comma/g;
110 $ns_proto_name =~ s/:/colon/g;
111 $ns_proto_name =~ s/'/apos/g;
113 # The maximum token name length is apparently 44 characters.
114 # That's what NAMELEN is defined as in docbook 4.1, at least.
116 if (length ($ns_proto_name) > 41) { # "SID" and "TID" are prepended below
117 $ns_proto_name = sprintf ("%s%04d", substr($ns_proto_name, 0,
122 print "<section id=\"SID$ns_proto_name\"><title>$proto_name ($proto_abbrev{$proto_name})</title>\n\n";
124 print "<table id=\"TID$ns_proto_name\"><title>$proto_name ($proto_abbrev{$proto_name})</title>\n";
125 print "<tgroup cols=\"4\">\n";
126 # print "<colspec colnum=\"1\" colwidth=\"80pt\">\n";
127 # print "<colspec colnum=\"2\" colwidth=\"80pt\"\n>";
128 print "<thead>\n <row>\n ";
129 print "<entry>Field</>\n <entry>Field Name</>\n <entry>Type</>\n <entry>Description</>\n\n";
131 print " </row>\n</thead>\n<tbody>\n";
133 # If this proto has children fields, print those
134 if ($field_abbrev{$proto_abbrev{$proto_name}}) {
136 for $field_abbrev (sort @{$field_abbrev{$proto_abbrev{$proto_name}}}) {
139 print " <entry>$field_abbrev</entry>\n";
140 print " <entry>", $field_info{$field_abbrev}[0], "</entry>\n";
141 print " <entry>", $ftenum_names{$field_info{$field_abbrev}[1]}, "</entry>\n";
142 print " <entry>", $field_info{$field_abbrev}[2], "</>\n";
150 print " <row>\n <entry></entry>\n <entry></entry>\n <entry></entry><entry></entry>\n";
155 print "</tbody></tgroup></table>\n";
156 print "</section>\n\n";
160 print "</appendix>\n";