aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>1999-07-15 15:33:52 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>1999-07-15 15:33:52 +0000
commit0d36ec8de2e587337c8d8bc787e40de23cda644a (patch)
treef039dce320dbc82cf7724400ce75c8afc499f1c7
parentc1bfe4a1a84e4fdae4e28476a4fe23318f12a025 (diff)
Modified the proto_register_field_array usage again. Thanks to Guy's
suggestion, this new method using a static array should use less memory and be faster. It also has a nice side-effect of making the source-code more readble, IMHO. Changed the print routines to look for protocol proto_data instead of looking at the text label as they did before, hoping that the data hex dump field item starts with "Data (". Added the -G keyword to ethereal to make it dump a glossary of display filter keywords to stdout and exit. This data is then formatted with the doc/dfilter2pod perl program to pod format, which is combined with doc/ethereal.pod.template to create doc/ethereal.pod, from which the ethereal manpage is created. This way we can keep the manpage up-to-date with a list of fields that can be filtered on. svn path=/trunk/; revision=364
-rw-r--r--Makefile.am16
-rw-r--r--Makefile.in11
-rw-r--r--NEWS2
-rw-r--r--doc/Makefile4
-rwxr-xr-xdoc/dfilter2pod99
-rw-r--r--doc/ethereal.pod.template (renamed from doc/ethereal.pod)24
-rw-r--r--doc/proto_tree31
-rw-r--r--ethereal.c9
-rw-r--r--packet-eth.c31
-rw-r--r--packet-fddi.c26
-rw-r--r--packet-ip.c42
-rw-r--r--packet-llc.c23
-rw-r--r--packet-tr.c83
-rw-r--r--packet.c39
-rw-r--r--print.c13
-rw-r--r--proto.c138
-rw-r--r--proto.h21
-rw-r--r--wiretap/Makefile.am4
-rw-r--r--wiretap/Makefile.in3
19 files changed, 483 insertions, 136 deletions
diff --git a/Makefile.am b/Makefile.am
index 1e49358e8b..98ed3fe002 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -130,16 +130,21 @@ DISTCLEANFILES = \
ps.c \
*~
-EXTRA_DIST = \
+EXTRA_DIST = \
+ config.h.win32 \
doc/Makefile \
+ doc/dfilter2pod \
doc/ethereal.pod \
+ doc/ethereal.pod.template \
ethereal.1 \
ethereal.spec \
image/icon-excl.xpm \
image/icon-ethereal.xpm \
+ Makefile.nmake \
manuf \
print.ps \
README.tru64 \
+ README.win32 \
rdps.c \
ylwrap \
VERSION
@@ -148,7 +153,8 @@ SUBDIRS = wiretap @SUBDIRS@
ethereal.1: doc/ethereal.pod VERSION
(cd doc ; \
- pod2man ethereal.pod \
- --center="The Ethereal Network Analyzer" \
- --release=`cat ../VERSION` \
- > ../ethereal.1 )
+ make ../ethereal.1 )
+
+doc/ethereal.pod: doc/ethereal.pod.template ethereal
+ (cd doc ; \
+ make ethereal.pod )
diff --git a/Makefile.in b/Makefile.in
index f156f2236a..2f520c7b7b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -98,7 +98,7 @@ ethereal_LDADD = @SNMP_O@ @SNPRINTF_O@ @STRERROR_O@ wiretap/libwiretap.a @SNMP_A
DISTCLEANFILES = rdps ps.c *~
-EXTRA_DIST = doc/Makefile doc/ethereal.pod ethereal.1 ethereal.spec image/icon-excl.xpm image/icon-ethereal.xpm manuf print.ps README.tru64 rdps.c ylwrap VERSION
+EXTRA_DIST = config.h.win32 doc/Makefile doc/dfilter2pod doc/ethereal.pod doc/ethereal.pod.template ethereal.1 ethereal.spec image/icon-excl.xpm image/icon-ethereal.xpm Makefile.nmake manuf print.ps README.tru64 README.win32 rdps.c ylwrap VERSION
SUBDIRS = wiretap @SUBDIRS@
@@ -613,10 +613,11 @@ rdps: rdps.c
ethereal.1: doc/ethereal.pod VERSION
(cd doc ; \
- pod2man ethereal.pod \
- --center="The Ethereal Network Analyzer" \
- --release=`cat ../VERSION` \
- > ../ethereal.1 )
+ make ../ethereal.1 )
+
+doc/ethereal.pod: doc/ethereal.pod.template ethereal
+ (cd doc ; \
+ make ethereal.pod )
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/NEWS b/NEWS
index 85598eafcf..e8a9b74b98 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,9 @@ Overview of changes in Ethereal 0.7.0:
* New proto_tree and display filter system (Gilbert)
* Updated SMB suport (Richard)
* RADIUS dissector added (Johan)
+* Display filter text-entry does auto-reload (Guy)
* Now compiles on Win32 (Gilbert)
+* Removed support for GTK+-1.[01].x (Gilbert)
Overview of changes in Ethereal 0.6.3:
* Capture dialogue window data bug-fix (Guy)
diff --git a/doc/Makefile b/doc/Makefile
index 6105c9ca05..c9903a0ef6 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -3,3 +3,7 @@
--center="The Ethereal Network Analyzer" \
--release=`cat ../VERSION` \
> ../ethereal.1
+
+ethereal.pod: ethereal.pod.template
+ cat ../out | ./dfilter2pod ethereal.pod.template > ethereal.pod
+
diff --git a/doc/dfilter2pod b/doc/dfilter2pod
new file mode 100755
index 0000000000..b4929f97b6
--- /dev/null
+++ b/doc/dfilter2pod
@@ -0,0 +1,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";
+ }
+ }
+}
diff --git a/doc/ethereal.pod b/doc/ethereal.pod.template
index 119ad041eb..ff6d7c71e4 100644
--- a/doc/ethereal.pod
+++ b/doc/ethereal.pod.template
@@ -11,6 +11,7 @@ S<[ B<-b> bold font ]>
S<[ B<-c> count ]>
S<[ B<-F> ]>
S<[ B<-f> filter expression ]>
+S<[ B<-G> ]>
S<[ B<-h> ]>
S<[ B<-i> interface ]>
S<[ B<-k> ]>
@@ -29,8 +30,10 @@ S<[ B<-w> savefile]>
=head1 DESCRIPTION
B<Ethereal> is a network protocol analyzer based on the B<GTK+> GUI toolkit. It lets
-you interactively browse packet data from a live network or from a B<pcap>
-/ B<tcpdump()> formatted capture file.
+you interactively browse packet data from a live network or from a previously saved
+capture file. Ethereal nows how to read B<pcap> / B<tcpdump> formatted capture files,
+as well as those of B<snoop>, B<LanAlyzer>, uncompressed B<Sniffer>,
+Microsoft B<Network Monitor>, AIX's B<iptrace>, B<NetXray>, and B<Sniffer Pro>.
=head1 OPTIONS
@@ -58,6 +61,10 @@ packets actually captured.
Sets a filter expression.
+=item -G
+
+Dumps a glossary of display filter keywords to stdout and exits.
+
=item -h
Prints the version and options and exits.
@@ -202,9 +209,8 @@ The lowest pane contains a hex dump of the actual packet data.
Selecting a field in the I<protocol tree> highlights the corresponding
bytes in this section.
-A display filter can be entered into the strip at the bottom. (XXX -
-put in syntax of display filter here?). A filter for HTTP, HTTPS, and
-DNS traffic might look like this:
+A display filter can be entered into the strip at the bottom.
+A filter for HTTP, HTTPS, and DNS traffic might look like this:
tcp.port == 80 || tcp.port == 443 || tcp.port == 53
@@ -342,6 +348,13 @@ in the packet list. You can select "Time of day" for absolute time stamps,
=back
+=head1 DISPLAY FILTER SYNTAX
+
+The grammar used for B<Ethereal>'s display filter syntax is similar to
+the syntax of the C programming language.
+
+=insert_dfilter_table
+
=head1 SEE ALSO
L<tcpdump(1)>, L<pcap(3)>
@@ -386,3 +399,4 @@ permission to use his version of snprintf.c.
Dan Lasley <dlasley@promus.com> gave permission for his dumpit() hex-dump
routine to be used.
+
diff --git a/doc/proto_tree b/doc/proto_tree
index 550c1a47b2..3b61d3fa25 100644
--- a/doc/proto_tree
+++ b/doc/proto_tree
@@ -1,3 +1,5 @@
+$Id: proto_tree,v 1.3 1999/07/15 15:33:09 gram Exp $
+
The Ethereal Protocol Tree
==========================
@@ -102,18 +104,33 @@ during registration.
/* vals[] */ NULL );
Groups of header fields can be registered with one call to
-proto_register_field_array(). An const array of hf_register_info
+proto_register_field_array(). A static array of hf_register_info
structs is declared, then passed to proto_register_field_array, along
-with a count of the number of records. You can use the handy
-array_length() macro found in packet.h to have the compiler compute
-the array length for you at compile time:
+with a count of the number of records. Be sure that your array
+of hf_register_info structs is declared 'static', since the
+proto_register_field_array() function does not create a copy of
+the information in the array... it uses that static copy of the
+information that the compiler created inside your array. Here's
+the layout of the hf_register_info struct:
+
+typedef struct hf_register_info {
+ int *p_id; /* pointer to parent variable */
+ header_field_info hfinfo;
+} hf_register_info;
+
+You can use the handy array_length() macro found in packet.h
+to have the compiler compute the array length for you at compile time:
int hf_field_a = -1;
int hf_field_b = -1;
- const hf_register_info hf[] = {
- { "Field A", "proto.field_a", &hf_field_a, FT_UINT8, NULL },
- { "Field B", "proto.field_a", &hf_field_a, FT_VALS_UINT16, VALS(vs) },
+ static hf_register_info hf[] = {
+
+ { &hf_field_a,
+ { "Field A", "proto.field_a", FT_UINT8, NULL }},
+
+ { &hf_field_b,
+ { "Field B", "proto.field_a", FT_VALS_UINT16, VALS(vs) }}
};
proto_tr = proto_register_protocol("Token-Ring", "tr");
diff --git a/ethereal.c b/ethereal.c
index 636bdaf384..fcc4324d79 100644
--- a/ethereal.c
+++ b/ethereal.c
@@ -1,6 +1,6 @@
/* ethereal.c
*
- * $Id: ethereal.c,v 1.56 1999/07/13 07:14:18 guy Exp $
+ * $Id: ethereal.c,v 1.57 1999/07/15 15:32:39 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -32,7 +32,6 @@
* - Playback window
* - Multiple window support
* - Add cut/copy/paste
- * - Fix progress/status bar glitches? (GTK+ bug?)
* - Create header parsing routines
* - Check fopens, freads, fwrites
* - Make byte view scrollbars automatic?
@@ -751,7 +750,7 @@ main(int argc, char *argv[])
#ifndef WIN32
/* Now get our args */
- while ((opt = getopt(argc, argv, "b:B:c:f:Fhi:km:nP:Qr:Ss:t:T:w:v")) != EOF) {
+ while ((opt = getopt(argc, argv, "b:B:c:f:FGhi:km:nP:Qr:Ss:t:T:w:v")) != EOF) {
switch (opt) {
case 'b': /* Bold font */
bold_font = g_strdup(optarg);
@@ -770,6 +769,10 @@ main(int argc, char *argv[])
fork_mode = 1;
break;
#endif
+ case 'G': /* print glossary of display filter symbols */
+ ethereal_proto_init();
+ proto_registrar_dump();
+ exit(0);
case 'h': /* Print help and exit */
print_usage();
exit(0);
diff --git a/packet-eth.c b/packet-eth.c
index 3d3ce12550..af24e3bb88 100644
--- a/packet-eth.c
+++ b/packet-eth.c
@@ -1,7 +1,7 @@
/* packet-eth.c
* Routines for ethernet packet disassembly
*
- * $Id: packet-eth.c,v 1.11 1999/07/08 03:18:20 gram Exp $
+ * $Id: packet-eth.c,v 1.12 1999/07/15 15:32:40 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -195,15 +195,26 @@ dissect_eth(const u_char *pd, frame_data *fd, proto_tree *tree) {
void
proto_register_eth(void)
{
- const hf_register_info hf[] = {
- { "Destination", "eth.dst", &hf_eth_dst, FT_ETHER, NULL },
- { "Source", "eth.src", &hf_eth_src, FT_ETHER, NULL },
- { "Destination Hardware Vendor", "eth.dst_vendor", &hf_eth_dst_vendor, FT_ETHER, NULL },
- { "Source Hardware Vendor", "eth.src_vendor", &hf_eth_src_vendor, FT_ETHER, NULL },
- { "Length", "eth.len", &hf_eth_len, FT_UINT16, NULL },
-
- /* registered here but handled in ethertype.c */
- { "Type", "eth.type", &hf_eth_type, FT_VALS_UINT16, VALS(etype_vals) }
+ static hf_register_info hf[] = {
+
+ { &hf_eth_dst,
+ { "Destination", "eth.dst", FT_ETHER, NULL }},
+
+ { &hf_eth_src,
+ { "Source", "eth.src", FT_ETHER, NULL }},
+
+ { &hf_eth_dst_vendor,
+ { "Destination Hardware Vendor", "eth.dst_vendor", FT_ETHER, NULL }},
+
+ { &hf_eth_src_vendor,
+ { "Source Hardware Vendor", "eth.src_vendor", FT_ETHER, NULL }},
+
+ { &hf_eth_len,
+ { "Length", "eth.len", FT_UINT16, NULL }},
+
+ /* registered here but handled in ethertype.c */
+ { &hf_eth_type,
+ { "Type", "eth.type", FT_VALS_UINT16, VALS(etype_vals) }}
};
proto_eth = proto_register_protocol ("Ethernet", "eth" );
diff --git a/packet-fddi.c b/packet-fddi.c
index feb0cfd13c..32a4f1a1d4 100644
--- a/packet-fddi.c
+++ b/packet-fddi.c
@@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
- * $Id: packet-fddi.c,v 1.13 1999/07/08 03:18:19 gram Exp $
+ * $Id: packet-fddi.c,v 1.14 1999/07/15 15:32:41 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -279,14 +279,22 @@ void dissect_fddi(const u_char *pd, frame_data *fd, proto_tree *tree)
void
proto_register_fddi(void)
{
- const hf_register_info hf[] = {
- { "Frame Control", "fddi.fc", &hf_fddi_fc, FT_UINT8, NULL },
- { "Destination", "fddi.dst", &hf_fddi_dst, FT_ETHER, NULL },
- { "Source", "fddi.src", &hf_fddi_src, FT_ETHER, NULL },
- { "Destination Hardware Vendor",
- "fddi.dst_vendor", &hf_fddi_dst_vendor, FT_ETHER_VENDOR, NULL },
- { "Source Hardware Vendor",
- "fddi.src_vendor", &hf_fddi_src_vendor, FT_ETHER_VENDOR, NULL }
+ static hf_register_info hf[] = {
+
+ { &hf_fddi_fc,
+ { "Frame Control", "fddi.fc", FT_UINT8, NULL }},
+
+ { &hf_fddi_dst,
+ { "Destination", "fddi.dst", FT_ETHER, NULL }},
+
+ { &hf_fddi_src,
+ { "Source", "fddi.src", FT_ETHER, NULL }},
+
+ { &hf_fddi_dst_vendor,
+ { "Destination Hardware Vendor", "fddi.dst_vendor", FT_ETHER_VENDOR, NULL }},
+
+ { &hf_fddi_src_vendor,
+ { "Source Hardware Vendor", "fddi.src_vendor", FT_ETHER_VENDOR, NULL }}
};
proto_fddi = proto_register_protocol ("Fiber Distributed Data Interface", "fddi" );
diff --git a/packet-ip.c b/packet-ip.c
index 74a1d80307..2428294a0b 100644
--- a/packet-ip.c
+++ b/packet-ip.c
@@ -1,7 +1,7 @@
/* packet-ip.c
* Routines for IP and miscellaneous IP protocol packet disassembly
*
- * $Id: packet-ip.c,v 1.28 1999/07/08 04:23:03 gram Exp $
+ * $Id: packet-ip.c,v 1.29 1999/07/15 15:32:41 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -53,6 +53,8 @@ int hf_ip_version = -1;
int hf_ip_hdr_len = -1;
int hf_ip_tos = -1;
int hf_ip_tos_precedence = -1;
+int hf_ip_len = -1;
+int hf_ip_id = -1;
int hf_ip_dst = -1;
int hf_ip_src = -1;
@@ -681,9 +683,10 @@ dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_tree_add_text(field_tree, offset + 1, 1, "%s",
decode_boolean_bitfield(iph.ip_tos, IPTOS_LOWCOST,
sizeof (iph.ip_tos)*8, "low cost", "normal cost"));
- proto_tree_add_text(ip_tree, offset + 2, 2, "Total length: %d", iph.ip_len);
- proto_tree_add_text(ip_tree, offset + 4, 2, "Identification: 0x%04x",
+ proto_tree_add_item(ip_tree, hf_ip_len, offset + 2, 2, iph.ip_len);
+ proto_tree_add_item_format(ip_tree, hf_ip_id, offset + 4, 2, iph.ip_id, "Identification: 0x%04x",
iph.ip_id);
+
tf = proto_tree_add_text(ip_tree, offset + 6, 2, "Flags: 0x%x",
(iph.ip_off & (IP_DF|IP_MF)) >> 12);
field_tree = proto_item_add_subtree(tf, ETT_IP_OFF);
@@ -1066,14 +1069,31 @@ dissect_igmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
void
proto_register_ip(void)
{
- const hf_register_info hf[] = {
- { "Version", "ip.version", &hf_ip_version, FT_UINT8, NULL },
- { "Header Length", "ip.hdr_len", &hf_ip_hdr_len, FT_UINT8, NULL },
- { "Type of Service", "ip.tos", &hf_ip_tos, FT_UINT8, NULL },
- { "Precedence", "ip.tos_precedence",
- &hf_ip_tos_precedence, FT_VALS_UINT8, VALS(precedence_vals) },
- { "Destination", "ip.dst", &hf_ip_dst, FT_IPv4, NULL },
- { "Source", "ip.src", &hf_ip_src, FT_IPv4, NULL }
+ static hf_register_info hf[] = {
+
+ { &hf_ip_version,
+ { "Version", "ip.version", FT_UINT8, NULL }},
+
+ { &hf_ip_hdr_len,
+ { "Header Length", "ip.hdr_len", FT_UINT8, NULL }},
+
+ { &hf_ip_tos,
+ { "Type of Service", "ip.tos", FT_UINT8, NULL }},
+
+ { &hf_ip_tos_precedence,
+ { "Precedence", "ip.tos.precedence", FT_VALS_UINT8, VALS(precedence_vals) }},
+
+ { &hf_ip_len,
+ { "Total Length", "ip.len", FT_UINT16 }},
+
+ { &hf_ip_id,
+ { "Identification", "ip.id", FT_UINT32 }},
+
+ { &hf_ip_dst,
+ { "Destination", "ip.dst", FT_IPv4, NULL }},
+
+ { &hf_ip_src,
+ { "Source", "ip.src", FT_IPv4, NULL }}
};
proto_ip = proto_register_protocol ("Internet Protocol", "ip");
diff --git a/packet-llc.c b/packet-llc.c
index 3aba7cb71e..edbdf2c227 100644
--- a/packet-llc.c
+++ b/packet-llc.c
@@ -2,7 +2,7 @@
* Routines for IEEE 802.2 LLC layer
* Gilbert Ramirez <gramirez@tivoli.com>
*
- * $Id: packet-llc.c,v 1.15 1999/07/07 22:51:46 gram Exp $
+ * $Id: packet-llc.c,v 1.16 1999/07/15 15:32:42 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -247,15 +247,22 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
void
proto_register_llc(void)
{
- const hf_register_info hf[] = {
- { "DSAP", "llc.dsap", &hf_llc_dsap, FT_VALS_UINT8, VALS(sap_vals) },
- { "SSAP", "llc.ssap", &hf_llc_ssap, FT_VALS_UINT8, VALS(sap_vals) },
- { "Control", "llc.control", &hf_llc_ctrl, FT_VALS_UINT8, VALS(llc_ctrl_vals) },
+ static hf_register_info hf[] = {
+ { &hf_llc_dsap,
+ { "DSAP", "llc.dsap", FT_VALS_UINT8, VALS(sap_vals) }},
- /* registered here but handled in ethertype.c */
- { "Type", "llc.type", &hf_llc_type, FT_VALS_UINT16, VALS(etype_vals) },
+ { &hf_llc_ssap,
+ { "SSAP", "llc.ssap", FT_VALS_UINT8, VALS(sap_vals) }},
- { "Organization Code", "llc.oui", &hf_llc_oui, FT_VALS_UINT24, VALS(llc_oui_vals) }
+ { &hf_llc_ctrl,
+ { "Control", "llc.control", FT_VALS_UINT8, VALS(llc_ctrl_vals) }},
+
+ /* registered here but handled in ethertype.c */
+ { &hf_llc_type,
+ { "Type", "llc.type", FT_VALS_UINT16, VALS(etype_vals) }},
+
+ { &hf_llc_oui,
+ { "Organization Code", "llc.oui", FT_VALS_UINT24, VALS(llc_oui_vals) }}
};
proto_llc = proto_register_protocol ("Logical-Link Control", "llc" );
diff --git a/packet-tr.c b/packet-tr.c
index a7eca11f17..3aa811da3a 100644
--- a/packet-tr.c
+++ b/packet-tr.c
@@ -2,7 +2,7 @@
* Routines for Token-Ring packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
- * $Id: packet-tr.c,v 1.15 1999/07/07 22:51:56 gram Exp $
+ * $Id: packet-tr.c,v 1.16 1999/07/15 15:32:42 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -439,27 +439,66 @@ add_ring_bridge_pairs(int rcf_len, const u_char *pd, proto_tree *tree)
void
proto_register_tr(void)
{
- const hf_register_info hf[] = {
- { "Access Control", "tr.ac", &hf_tr_ac, FT_UINT8, NULL },
- { "Priority", "tr.priority", &hf_tr_priority, FT_UINT8, NULL },
- { "Frame", "tr.frame", &hf_tr_frame, FT_VALS_UINT8, VALS(ac_vals) },
- { "Monitor Count", "tr.monitor_cnt", &hf_tr_monitor_cnt, FT_UINT8, NULL },
- { "Priority Reservation","tr.priority_reservation", &hf_tr_priority_reservation, FT_UINT8, NULL },
- { "Frame Control", "tr.fc", &hf_tr_fc, FT_UINT8, NULL },
- { "Frame Type", "tr.frame_type", &hf_tr_fc_type, FT_VALS_UINT8, VALS(frame_vals) },
- { "Frame PCF", "tr.frame_pcf", &hf_tr_fc_pcf, FT_VALS_UINT8, VALS(pcf_vals) },
- { "Destination", "tr.dst", &hf_tr_dst, FT_ETHER, NULL },
- { "Source", "tr.src", &hf_tr_src, FT_ETHER, NULL },
- { "Destination Hardware Vendor", "tr.dst_vendor", &hf_tr_dst_vendor, FT_ETHER_VENDOR, NULL },
- { "Source Hardware Vendor", "tr.src_vendor", &hf_tr_src_vendor, FT_ETHER_VENDOR, NULL },
- { "Source Routed", "tr.sr", &hf_tr_sr, FT_BOOLEAN, NULL },
- { "RIF Bytes", "tr.rif_bytes", &hf_tr_rif_bytes, FT_UINT8, NULL },
- { "Broadcast Type", "tr.broadcast", &hf_tr_broadcast, FT_VALS_UINT8, VALS(broadcast_vals) },
- { "Maximum Frame Size", "tr.max_frame_size", &hf_tr_max_frame_size, FT_VALS_UINT8, VALS(max_frame_size_vals) },
- { "Direction", "tr.direction", &hf_tr_direction, FT_VALS_UINT8, VALS(direction_vals) },
- { "Ring-Bridge Pairs", "tr.rif", &hf_tr_rif, FT_STRING, NULL },
- { "RIF Ring", "tr.rif_ring", &hf_tr_rif_ring, FT_UINT16, NULL },
- { "RIF Bridge", "tr.rif_bridge", &hf_tr_rif_bridge, FT_UINT8, NULL },
+ static hf_register_info hf[] = {
+ { &hf_tr_ac,
+ { "Access Control", "tr.ac", FT_UINT8, NULL }},
+
+ { &hf_tr_priority,
+ { "Priority", "tr.priority", FT_UINT8, NULL }},
+
+ { &hf_tr_frame,
+ { "Frame", "tr.frame", FT_VALS_UINT8, VALS(ac_vals) }},
+
+ { &hf_tr_monitor_cnt,
+ { "Monitor Count", "tr.monitor_cnt", FT_UINT8, NULL }},
+
+ { &hf_tr_priority_reservation,
+ { "Priority Reservation","tr.priority_reservation", FT_UINT8, NULL }},
+
+ { &hf_tr_fc,
+ { "Frame Control", "tr.fc", FT_UINT8, NULL }},
+
+ { &hf_tr_fc_type,
+ { "Frame Type", "tr.frame_type", FT_VALS_UINT8, VALS(frame_vals) }},
+
+ { &hf_tr_fc_pcf,
+ { "Frame PCF", "tr.frame_pcf", FT_VALS_UINT8, VALS(pcf_vals) }},
+
+ { &hf_tr_dst,
+ { "Destination", "tr.dst", FT_ETHER, NULL }},
+
+ { &hf_tr_src,
+ { "Source", "tr.src", FT_ETHER, NULL }},
+
+ { &hf_tr_dst_vendor,
+ { "Destination Hardware Vendor", "tr.dst_vendor", FT_ETHER_VENDOR, NULL }},
+
+ { &hf_tr_src_vendor,
+ { "Source Hardware Vendor", "tr.src_vendor", FT_ETHER_VENDOR, NULL }},
+
+ { &hf_tr_sr,
+ { "Source Routed", "tr.sr", FT_BOOLEAN, NULL }},
+
+ { &hf_tr_rif_bytes,
+ { "RIF Bytes", "tr.rif_bytes", FT_UINT8, NULL }},
+
+ { &hf_tr_broadcast,
+ { "Broadcast Type", "tr.broadcast", FT_VALS_UINT8, VALS(broadcast_vals) }},
+
+ { &hf_tr_max_frame_size,
+ { "Maximum Frame Size", "tr.max_frame_size", FT_VALS_UINT8, VALS(max_frame_size_vals) }},
+
+ { &hf_tr_direction,
+ { "Direction", "tr.direction", FT_VALS_UINT8, VALS(direction_vals) }},
+
+ { &hf_tr_rif,
+ { "Ring-Bridge Pairs", "tr.rif", FT_STRING, NULL }},
+
+ { &hf_tr_rif_ring,
+ { "RIF Ring", "tr.rif.ring", FT_UINT16, NULL }},
+
+ { &hf_tr_rif_bridge,
+ { "RIF Bridge", "tr.rif.bridge", FT_UINT8, NULL }}
};
proto_tr = proto_register_protocol("Token-Ring", "tr");
diff --git a/packet.c b/packet.c
index ef38406de5..ed6613ea80 100644
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.30 1999/07/13 02:52:57 gram Exp $
+ * $Id: packet.c,v 1.31 1999/07/15 15:32:43 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -688,28 +688,17 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
void
proto_register_frame(void)
{
- proto_frame = proto_register_protocol (
- /* name */ "Frame",
- /* abbrev */ "frame");
-
- hf_frame_arrival_time = proto_register_field (
- /* name */ "Arrival Time",
- /* abbrev */ "frame.time",
- /* ftype */ FT_ABSOLUTE_TIME,
- /* parent */ proto_frame,
- /* vals[] */ NULL );
-
- hf_frame_packet_len = proto_register_field(
- /* name */ "Total Frame Length",
- /* abbrev */ "frame.frame_len",
- /* ftype */ FT_UINT32,
- /* parent */ proto_frame,
- /* vals[] */ NULL );
-
- hf_frame_capture_len = proto_register_field(
- /* name */ "Capture Frame Length",
- /* abbrev */ "frame.cap_len",
- /* ftype */ FT_UINT32,
- /* parent */ proto_frame,
- /* vals[] */ NULL );
+ static hf_register_info hf[] = {
+ { &hf_frame_arrival_time,
+ { "Arrival Time", "frame.time", FT_ABSOLUTE_TIME, NULL }},
+
+ { &hf_frame_packet_len,
+ { "Total Frame Length", "frame.pkt_len", FT_UINT32, NULL }},
+
+ { &hf_frame_capture_len,
+ { "Capture Frame Length", "frame.cap_len", FT_UINT32, NULL }}
+ };
+
+ proto_frame = proto_register_protocol("Frame", "frame");
+ proto_register_field_array(proto_frame, hf, array_length(hf));
}
diff --git a/print.c b/print.c
index 924d2dfe73..68ba00762f 100644
--- a/print.c
+++ b/print.c
@@ -1,7 +1,7 @@
/* print.c
* Routines for printing packet analysis trees.
*
- * $Id: print.c,v 1.12 1999/07/13 04:38:13 guy Exp $
+ * $Id: print.c,v 1.13 1999/07/15 15:32:43 gram Exp $
*
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
@@ -57,6 +57,7 @@ static void ps_clean_string(unsigned char *out, const unsigned char *in,
static void dumpit_ps (FILE *fh, register const u_char *cp, register u_int length);
extern e_prefs prefs;
+extern int proto_data; /* in packet-data.c */
/* #include "ps.c" */
@@ -343,9 +344,8 @@ void proto_tree_print_node_text(GNode *node, gpointer data)
/* Print the text */
fprintf(pdata->fh, "%s%s\n", space, label_ptr);
- /* If it's uninterpreted data, dump it.
- XXX - have a better way of doing this than looking for "Data (" */
- if (strncmp("Data (", label_ptr, 6) == 0)
+ /* If it's uninterpreted data, dump it. */
+ if (fi->hfinfo->id == proto_data)
dumpit(pdata->fh, &pdata->pd[fi->start], fi->length);
/* Recurse into the subtree, if it exists */
@@ -420,9 +420,8 @@ void proto_tree_print_node_ps(GNode *node, gpointer data)
ps_clean_string(psbuffer, label_ptr, MAX_LINE_LENGTH);
fprintf(pdata->fh, "%d (%s) putline\n", pdata->level, psbuffer);
- /* If it's uninterpreted data, dump it.
- XXX - have a better way of doing this than looking for "Data (" */
- if (strncmp("Data (", label_ptr, 6) == 0) {
+ /* If it's uninterpreted data, dump it. */
+ if (fi->hfinfo->id == proto_data) {
print_ps_hex(pdata->fh);
dumpit_ps(pdata->fh, &pdata->pd[fi->start], fi->length);
}
diff --git a/proto.c b/proto.c
index 7bdd2f54b4..70bd4da9e8 100644
--- a/proto.c
+++ b/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.1 1999/07/07 22:51:59 gram Exp $
+ * $Id: proto.c,v 1.2 1999/07/15 15:32:44 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -75,6 +75,8 @@ proto_tree_add_item_value(proto_tree *tree, int hfindex, gint start,
static gboolean proto_check_id(GNode *node, gpointer data);
+static int proto_register_field_init(header_field_info *hfinfo, int parent);
+
void dfilter_yacc_init(void);
/* centralization of registration functions */
@@ -87,6 +89,7 @@ void proto_register_llc(void);
void proto_register_null(void);
void proto_register_tr(void);
+/* special-case header field used within proto.c */
int hf_text_only = 1;
/* Contains information about protocols and header fields. Used when
@@ -362,20 +365,22 @@ proto_register_protocol(char *name, char *abbrev)
return proto_register_field(name, abbrev, FT_NONE, -1, NULL);
}
+/* for use with static arrays only, since we don't allocate our own copies
+of the header_field_info struct contained withing the hf_register_info struct */
void
-proto_register_field_array(int parent, const hf_register_info *hf, int num_records)
+proto_register_field_array(int parent, hf_register_info *hf, int num_records)
{
int field_id, i;
- const hf_register_info *ptr = hf;
+ hf_register_info *ptr = hf;
for (i = 0; i < num_records; i++, ptr++) {
- field_id = proto_register_field(ptr->name, ptr->abbrev,
- ptr->type, parent, ptr->vals);
+ field_id = proto_register_field_init(&ptr->hfinfo, parent);
*ptr->p_id = field_id;
}
}
+/* Here we do allocate a new header_field_info struct */
int
proto_register_field(char *name, char *abbrev, enum ftenum type, int parent,
struct value_string* vals)
@@ -386,11 +391,20 @@ proto_register_field(char *name, char *abbrev, enum ftenum type, int parent,
hfinfo->name = name; /* should I g_strdup? */
hfinfo->abbrev = abbrev; /* should I g_strdup? */
hfinfo->type = type;
- hfinfo->parent = parent; /* this field differentiates protos and fields */
hfinfo->vals = vals;
+ hfinfo->parent = parent; /* this field differentiates protos and fields */
+
+ return proto_register_field_init(hfinfo, parent);
+}
- g_assert((vals == NULL) || (type == FT_VALS_UINT8 || type == FT_VALS_UINT16 ||
- type == FT_VALS_UINT24 || type == FT_VALS_UINT32));
+static int
+proto_register_field_init(header_field_info *hfinfo, int parent)
+{
+ g_assert((hfinfo->vals == NULL) || (hfinfo->type == FT_VALS_UINT8 || hfinfo->type == FT_VALS_UINT16 ||
+ hfinfo->type == FT_VALS_UINT24 || hfinfo->type == FT_VALS_UINT32));
+
+ hfinfo->parent = parent;
+ hfinfo->color = 0;
/* if we always add and never delete, then id == len - 1 is correct */
g_ptr_array_add(gpa_hfinfo, hfinfo);
@@ -618,3 +632,111 @@ proto_get_field_values(proto_tree* subtree, GNodeTraverseFunc fill_array_func, p
{
g_node_traverse((GNode*)subtree, G_IN_ORDER, G_TRAVERSE_ALL, -1, fill_array_func, sinfo);
}
+
+/* Dumps the contents of the registration database to stdout. An indepedent program can take
+ * this output and format it into nice tables or HTML or whatever.
+ *
+ * There is one record per line. Each record is either a protocol or a header
+ * field, differentiated by the first field. The fields are tab-delimited.
+ *
+ * Protocols
+ * ---------
+ * Field 1 = 'P'
+ * Field 2 = protocol name
+ * Field 3 = protocol abbreviation
+ *
+ * Header Fields
+ * -------------
+ * Field 1 = 'F'
+ * Field 2 = field name
+ * Field 3 = field abbreviation
+ * Field 4 = type ( textual representation of the the ftenum type )
+ * Field 5 = parent protocol abbreviation
+ */
+void
+proto_registrar_dump(void)
+{
+ header_field_info *hfinfo, *parent_hfinfo;
+ int i, len;
+ const char *enum_name;
+
+ len = gpa_hfinfo->len;
+ for (i = 0; i < len ; i++) {
+ hfinfo = find_hfinfo_record(i);
+
+ /* format for protocols */
+ if (proto_registrar_is_protocol(i)) {
+ printf("P\t%s\t%s\n", hfinfo->name, hfinfo->abbrev);
+ }
+ /* format for header fields */
+ else {
+ parent_hfinfo = find_hfinfo_record(hfinfo->parent);
+ g_assert(parent_hfinfo);
+
+ switch(hfinfo->type) {
+ case FT_NONE:
+ enum_name = "FT_NONE";
+ break;
+ case FT_BOOLEAN:
+ enum_name = "FT_BOOLEAN";
+ break;
+ case FT_UINT8:
+ enum_name = "FT_UINT8";
+ break;
+ case FT_UINT16:
+ enum_name = "FT_UINT16";
+ break;
+ case FT_UINT32:
+ enum_name = "FT_UINT32";
+ break;
+ case FT_ABSOLUTE_TIME:
+ enum_name = "FT_ABSOLUTE_TIME";
+ break;
+ case FT_RELATIVE_TIME:
+ enum_name = "FT_RELATIVE_TIME";
+ break;
+ case FT_STRING:
+ enum_name = "FT_STRING";
+ break;
+ case FT_ETHER:
+ enum_name = "FT_ETHER";
+ break;
+ case FT_ETHER_VENDOR:
+ enum_name = "FT_ETHER_VENDOR";
+ break;
+ case FT_BYTES:
+ enum_name = "FT_BYTES";
+ break;
+ case FT_IPv4:
+ enum_name = "FT_IPv4";
+ break;
+ case FT_IPv6:
+ enum_name = "FT_IPv6";
+ break;
+ case FT_IPXSERVER:
+ enum_name = "FT_IPXSERVER";
+ break;
+ case FT_VALS_UINT8:
+ enum_name = "FT_VALS_UINT8";
+ break;
+ case FT_VALS_UINT16:
+ enum_name = "FT_VALS_UINT16";
+ break;
+ case FT_VALS_UINT24:
+ enum_name = "FT_VALS_UINT24";
+ break;
+ case FT_VALS_UINT32:
+ enum_name = "FT_VALS_UINT32";
+ break;
+ case FT_TEXT_ONLY:
+ enum_name = "FT_TEXT_ONLY";
+ break;
+ default:
+ enum_name = "UNKNOWN";
+ break;
+ }
+ printf("F\t%s\t%s\t%s\t%s\n", hfinfo->name, hfinfo->abbrev,
+ enum_name,parent_hfinfo->abbrev);
+ }
+ }
+}
diff --git a/proto.h b/proto.h
index bd1e562744..d4ce6d10bf 100644
--- a/proto.h
+++ b/proto.h
@@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
- * $Id: proto.h,v 1.3 1999/07/13 02:52:58 gram Exp $
+ * $Id: proto.h,v 1.4 1999/07/15 15:32:44 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -74,29 +74,25 @@ enum ftenum {
NUM_FIELD_TYPES /* last item number plus one */
};
-
+/* information describing a header field */
typedef struct header_field_info {
char *name;
char *abbrev;
enum ftenum type;
- int parent;
struct value_string *vals;
int id; /* assigned by order of registration */
-/* int color; for use by GUI code */
+ int parent; /* parent protocol */
+ int color; /* for use by GUI code */
} header_field_info;
-/*extern struct header_field_info hfinfo[];*/
-
/* Used when registering many fields at once */
typedef struct hf_register_info {
- char *name;
- char *abbrev;
int *p_id; /* pointer to int; written to by register() function */
- enum ftenum type;
- struct value_string *vals;
+ header_field_info hfinfo;
} hf_register_info;
#ifdef WIN32
+/* 'boolean' is a reserved word on win32 */
#define boolean truth_value
#endif
@@ -138,7 +134,7 @@ int
proto_register_protocol(char *name, char *abbrev);
void
-proto_register_field_array(int parent, const hf_register_info *hf, int num_records);
+proto_register_field_array(int parent, hf_register_info *hf, int num_records);
proto_item *
proto_tree_add_item(proto_tree *tree, int hfindex, gint start,
@@ -169,4 +165,7 @@ proto_item* proto_find_protocol(proto_tree* tree, int protocol_id);
void proto_get_field_values(proto_tree* subtree, GNodeTraverseFunc fill_array_func,
proto_tree_search_info *sinfo);
+/* Dumps a glossary of the protocol and field registrations to STDOUT */
+void proto_registrar_dump(void);
+
#endif /* proto.h */
diff --git a/wiretap/Makefile.am b/wiretap/Makefile.am
index 77c3e73398..5a0c014bcc 100644
--- a/wiretap/Makefile.am
+++ b/wiretap/Makefile.am
@@ -27,3 +27,7 @@ libwiretap_a_SOURCES = \
snoop.h \
wtap.c \
wtap.h
+
+EXTRA_DIST = \
+ config.h.win32 \
+ Makefile.nmake
diff --git a/wiretap/Makefile.in b/wiretap/Makefile.in
index 1159677f0a..8a47875499 100644
--- a/wiretap/Makefile.in
+++ b/wiretap/Makefile.in
@@ -80,6 +80,9 @@ CLEANFILES = libwiretap.a *~
libwiretap_a_SOURCES = buffer.c buffer.h config.h file.c iptrace.c iptrace.h lanalyzer.c lanalyzer.h libpcap.c libpcap.h netmon.c netmon.h netxray.c netxray.h ngsniffer.c ngsniffer.h snoop.c snoop.h wtap.c wtap.h
+
+EXTRA_DIST = config.h.win32 Makefile.nmake
+
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = config.h