diff options
author | guy <guy> | 2002-12-19 09:39:10 +0000 |
---|---|---|
committer | guy <guy> | 2002-12-19 09:39:10 +0000 |
commit | 4bec97f457e593be925e92fa28d73af6a57d81cf (patch) | |
tree | fcb53f0e4e3a5749d84858f128e7f6c7e352c23e /print-arcnet.c | |
parent | 60761585472a90c34d7de7bdf50475f0d7261b2d (diff) | |
download | tcpdump-4bec97f457e593be925e92fa28d73af6a57d81cf.tar.gz |
Hoist a bunch of stuff that should be done by all if_print routines into
tcpdump.c. Have if_print routines return the length of the link-layer
header, so that the common code knows how to skip the link-layer header
when printing the packet in hex/ASCII.
Diffstat (limited to 'print-arcnet.c')
-rw-r--r-- | print-arcnet.c | 47 |
1 files changed, 9 insertions, 38 deletions
diff --git a/print-arcnet.c b/print-arcnet.c index 7f1db3e3..50d7bf83 100644 --- a/print-arcnet.c +++ b/print-arcnet.c @@ -22,7 +22,7 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.12 2002-12-18 09:41:14 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.13 2002-12-19 09:39:10 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -106,25 +106,20 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid) * 'h->length' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ -void -arcnet_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p) +u_int +arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; - const u_char *orig_p; - u_int orig_caplen; const struct arc_header *ap; int phds, flag = 0, archdrlen = 0; u_int seqid = 0; u_char arc_type; - ++infodelay; - ts_print(&h->ts); - if (caplen < ARC_HDRLEN) { printf("[|arcnet]"); - goto out; + return (caplen); } ap = (const struct arc_header *)p; @@ -146,14 +141,14 @@ arcnet_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p) if (caplen < ARC_HDRNEWLEN) { arcnet_print(p, length, 0, 0, 0); printf("[|phds]"); - goto out; + return (caplen); } if (ap->arc_flag == 0xff) { if (caplen < ARC_HDRNEWLEN_EXC) { arcnet_print(p, length, 0, 0, 0); printf("[|phds extended]"); - goto out; + return (caplen); } flag = ap->arc_flag2; seqid = ap->arc_seqid2; @@ -170,20 +165,6 @@ arcnet_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p) arcnet_print(p, length, phds, flag, seqid); /* - * Some printers want to check that they're not walking off the - * end of the packet. - * Rather than pass it all the way down, we set this global. - */ - snapend = p + caplen; - - /* - * Save the information for the full packet, so we can print - * everything if "-e" and "-x" are both specified. - */ - orig_p = p; - orig_caplen = caplen; - - /* * Go past the ARCNET header. */ length -= archdrlen; @@ -191,22 +172,12 @@ arcnet_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p) p += archdrlen; if (phds && flag && (flag & 1) == 0) - goto out2; + return (archdrlen); - if (!arcnet_encap_print(arc_type, p, length, caplen)) { + if (!arcnet_encap_print(arc_type, p, length, caplen)) default_print(p, caplen); - goto out; - } - - out2: - if (xflag) - default_print_packet(orig_p, orig_caplen, archdrlen); - out: - putchar('\n'); - --infodelay; - if (infoprint) - info(0); + return (archdrlen); } /* |