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_DOUBLE', 'Double-precision floating point',
29 'FT_ABSOLUTE_TIME', 'Date/Time stamp',
30 'FT_RELATIVE_TIME', 'Time duration',
31 'FT_STRING', 'String',
32 'FT_STRINGZ', 'String',
33 'FT_UINT_STRING', 'String',
34 'FT_ETHER', '6-byte Hardware (MAC) Address',
35 'FT_BYTES', 'Byte array',
36 'FT_IPv4', 'IPv4 address',
37 'FT_IPv6', 'IPv6 address',
38 'FT_IPXNET', 'IPX network or server name',
41 # Read all the data into memory
43 next unless (/^([PF])/);
51 # Store protocol information
52 if ($record_type eq 'P') {
53 ($junk, $name, $abbrev) = split(/\t+/, $_);
54 $proto_abbrev{$name} = $abbrev;
56 # Store header field information
58 ($junk, $name, $abbrev, $type, $parent, $blurb) =
60 push(@{$field_abbrev{$parent}}, $abbrev);
61 $field_info{$abbrev} = [ $name, $type, $blurb ];
65 # if there was no input on stdin, bail out
66 if ($record_type ne 'P' and $record_type ne 'F') {
70 $template = shift(@ARGV);
72 open(TEMPLATE, $template) || die "Can't open $template for reading: $!\n";
75 if (/=insert_dfilter_table/) {
76 &create_dfilter_table;
83 close(TEMPLATE) || die "Can't close $template: $!\n";
85 sub create_dfilter_table {
87 print "<appendix id=\"AppFiltFields\"><title>Wireshark Display Filter Fields</title>\n";
91 for $proto_name (sort keys %proto_abbrev) {
93 $ns_proto_name = $proto_name;
94 $ns_proto_name =~ s/\s//g;
95 $ns_proto_name =~ s/\)//g;
96 $ns_proto_name =~ s/\(//g;
97 $ns_proto_name =~ s/_//g;
98 $ns_proto_name =~ s/\+/plus/g;
99 $ns_proto_name =~ s/\//slash/g;
100 $ns_proto_name =~ s/,/comma/g;
101 $ns_proto_name =~ s/:/colon/g;
102 $ns_proto_name =~ s/'/apos/g;
104 # The maximum token name length is apparently 44 characters.
105 # That's what NAMELEN is defined as in docbook 4.1, at least.
107 if (length ($ns_proto_name) > 41) { # "SID" and "TID" are prepended below
108 $ns_proto_name = sprintf ("%s%04d", substr($ns_proto_name, 0,
113 print "<section id=\"SID$ns_proto_name\"><title>$proto_name ($proto_abbrev{$proto_name})</title>\n\n";
115 print "<table id=\"TID$ns_proto_name\"><title>$proto_name ($proto_abbrev{$proto_name})</title>\n";
116 print "<tgroup cols=\"4\">\n";
117 # print "<colspec colnum=\"1\" colwidth=\"80pt\">\n";
118 # print "<colspec colnum=\"2\" colwidth=\"80pt\"\n>";
119 print "<thead>\n <row>\n ";
120 print "<entry>Field</>\n <entry>Field Name</>\n <entry>Type</>\n <entry>Description</>\n\n";
122 print " </row>\n</thead>\n<tbody>\n";
124 # If this proto has children fields, print those
125 if ($field_abbrev{$proto_abbrev{$proto_name}}) {
127 for $field_abbrev (sort @{$field_abbrev{$proto_abbrev{$proto_name}}}) {
130 print " <entry>$field_abbrev</entry>\n";
131 print " <entry>", $field_info{$field_abbrev}[0], "</entry>\n";
132 print " <entry>", $ftenum_names{$field_info{$field_abbrev}[1]}, "</entry>\n";
133 print " <entry>", $field_info{$field_abbrev}[2], "</>\n";
141 print " <row>\n <entry></entry>\n <entry></entry>\n <entry></entry><entry></entry>\n";
146 print "</tbody></tgroup></table>\n";
147 print "</section>\n\n";
151 print "</appendix>\n";