aboutsummaryrefslogtreecommitdiffstats
path: root/doc/dfilter2pod
blob: b4929f97b60e3390526254044b18028fc17af6ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/perl
#
# Reads the display filter keyword dump produced by 'ethereal -G' and
# formats it for a pod document. The pod document is then used to
# make a manpage
#
# STDIN is the ethereal glossary
# arg1 is the pod template file. The =insert_dfilter_table token
#	will be replaced by the pod-formatted glossary
# STDOUT is the output
#
# $Id: dfilter2pod,v 1.1 1999/07/15 15:33:07 gram Exp $

%ftenum_names = (
	'FT_NONE',	'No value',
	'FT_BOOLEAN',	'Boolean',
	'FT_UINT8',	'Unsigned 8-bit integer',
	'FT_UINT16',	'Unsigned 16-bit integer',
	'FT_UINT32',	'Unsigned 32-bit integer',
	'FT_ABSOLUTE_TIME',	'Date/Time stamp',
	'FT_RELATIVE_TIME',	'Time duration',
	'FT_STRING',		'String',
	'FT_ETHER',		'6-byte Hardware (MAC) Address',
	'FT_ETHER_VENDOR',	'3-byte MAC vendor',
	'FT_BYTES',		'Byte array',
	'FT_IPv4',		'IPv4 address',
	'FT_IPv6',		'IPv6 address',
	'FT_IPXSERVER',		'IPX network or server name',
	'FT_VALS_UINT8',		'Unsigned 8-bit integer',
	'FT_VALS_UINT16',		'Unsigned 16-bit integer',
	'FT_VALS_UINT24',		'Unsigned 24-bit integer',
	'FT_VALS_UINT32',		'Unsigned 32-bit integer',
	'FT_TEXT_ONLY',		'Text-only. Not filterable'
);

# Read all the data into memory
while (<STDIN>) {
	next unless (/^([PF])/);

	$record_type = $1;
	chomp($_);

	# Store protocol information
	if ($record_type eq 'P') {
		($junk, $name, $abbrev) = split(/\t+/, $_);
		$proto_abbrev{$name} = $abbrev;
	}
	# Store header field information
	else {
		($junk, $name, $abbrev, $type, $parent) =
			split(/\t+/, $_);
		push(@{$field_abbrev{$parent}}, $abbrev);
		$field_info{$abbrev} = [ $name, $type ];
	}
}

# if there was no input on stdin, bail out
if ($record_type ne 'P' and $record_type ne 'F') {
	exit;
}

$template = shift(@ARGV);

open(TEMPLATE, $template) || die "Can't open $template for reading: $!\n";

while (<TEMPLATE>) {
	if (/=insert_dfilter_table/) {
		&create_dfilter_table;
	}
	else {
		print;
	}
}

close(TEMPLATE) || die "Can't close $template: $!\n";

sub create_dfilter_table {

	# Print each protocol
	for $proto_name (sort keys %proto_abbrev) {

		if ($proto_name eq 'Text' && $proto_abbrev{$proto_name} eq 'text') {
			next;
		}

		print "=head2 $proto_name ($proto_abbrev{$proto_name})\n\n";

		# If this proto has children fields, print those
		if ($field_abbrev{$proto_abbrev{$proto_name}}) {
			print "=over 4\n\n";

			for $field_abbrev (sort @{$field_abbrev{$proto_abbrev{$proto_name}}}) {
				print "=item ", $field_info{$field_abbrev}[0]," ($field_abbrev)\n\n";
				print $ftenum_names{$field_info{$field_abbrev}[1]}, "\n\n";
			}
			print "=back\n\n";
		}
	}
}