]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Only do "-x" printing in the top-level interface print routine; don't do
authorguy <guy>
Wed, 29 May 2002 10:06:24 +0000 (10:06 +0000)
committerguy <guy>
Wed, 29 May 2002 10:06:24 +0000 (10:06 +0000)
it in the routines, called by the top-level routines, to dissect
Ethernet, FDDI, or Token Ring packets, as those routines might also be
called for bridged frames over ATM, and the interface print routine for
ATM will also do "-x" printing.

interface.h
print-ether.c
print-fddi.c
print-token.c

index a571d610876e9e379be70481379b443cce33cd5d..ab68aef2964dd3c24bd8637db491c56e75be5691 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.182 2002-04-25 04:31:42 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.183 2002-05-29 10:06:24 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -209,7 +209,7 @@ extern void arcnet_if_print(u_char *, const struct pcap_pkthdr *,
 extern void ether_print(const u_char *, u_int, u_int);
 extern void ether_if_print(u_char *, const struct pcap_pkthdr *,
        const u_char *);
-extern void token_print(const u_char *, u_int, u_int);
+extern u_int token_print(const u_char *, u_int, u_int);
 extern void token_if_print(u_char *, const struct pcap_pkthdr *,
        const u_char *);
 extern void fddi_print(const u_char *, u_int, u_int);
index a28f6652c6ae08492c76100e85df7b852612490e..e715049f412d0338e3ba54a9dfd44da2026a8211 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.67 2002-04-07 09:50:31 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.68 2002-05-29 10:06:26 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -76,7 +76,7 @@ ether_print(const u_char *p, u_int length, u_int caplen)
 
        if (caplen < ETHER_HDRLEN) {
                printf("[|ether]");
-               goto out;
+               return;
        }
 
        if (eflag)
@@ -123,10 +123,6 @@ ether_print(const u_char *p, u_int length, u_int caplen)
                if (!xflag && !qflag)
                        default_print(p, caplen);
        }
-       if (xflag)
-               default_print(p, caplen);
- out:
-       putchar('\n');
 }
 
 /*
@@ -146,6 +142,15 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
 
        ether_print(p, length, caplen);
 
+       /*
+        * If "-x" was specified, print stuff past the Ethernet header,
+        * if there's anything to print.
+        */
+       if (xflag && caplen > ETHER_HDRLEN)
+               default_print(p + ETHER_HDRLEN, caplen - ETHER_HDRLEN);
+
+       putchar('\n');
+
        --infodelay;
        if (infoprint)
                info(0);
index bf090d7ce97a4c225649790309c26dd8c42f9577..ffa43859eebff251e119821aac5c8fdf018fa055 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.54 2002-04-07 09:50:32 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.55 2002-05-29 10:06:27 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -255,7 +255,7 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
 
        if (caplen < FDDI_HDRLEN) {
                printf("[|fddi]");
-               goto out;
+               return;
        }
        /*
         * Get the FDDI addresses into a canonical form
@@ -313,10 +313,6 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
                if (!xflag && !qflag)
                        default_print(p, caplen);
        }
-       if (xflag)
-               default_print(p, caplen);
-out:
-       putchar('\n');
 }
 
 /*
@@ -337,6 +333,15 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
 
        fddi_print(p, length, caplen);
 
+       /*
+        * If "-x" was specified, print stuff past the FDDI header,
+        * if there's anything to print.
+        */
+       if (xflag && caplen > FDDI_HDRLEN)
+               default_print(p + FDDI_HDRLEN, caplen - FDDI_HDRLEN);
+
+       putchar('\n');
+
        --infodelay;
        if (infoprint)
                info(0);
index 0f4afedbd1725f93c5d99bb15a9801d831339b63..1690b3c9184ec43d89b28b28435487487f94e231 100644 (file)
@@ -25,7 +25,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.14 2002-04-07 09:50:33 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.15 2002-05-29 10:06:27 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -101,19 +101,19 @@ static const char *largest_frame[] = {
        "??"
 };
 
-void
+u_int
 token_print(const u_char *p, u_int length, u_int caplen)
 {
        const struct token_header *trp;
        u_short extracted_ethertype;
        struct ether_header ehdr;
-       u_int route_len = 0, seg;
+       u_int route_len = 0, hdr_len = TOKEN_HDRLEN, seg;
 
        trp = (const struct token_header *)p;
 
        if (caplen < TOKEN_HDRLEN) {
                printf("[|token-ring]");
-               goto out;
+               return hdr_len;
        }
        /*
         * Get the TR addresses into a canonical form
@@ -162,9 +162,10 @@ token_print(const u_char *p, u_int length, u_int caplen)
        }
 
        /* Skip over token ring MAC header and routing information */
-       length -= TOKEN_HDRLEN + route_len;
-       p += TOKEN_HDRLEN + route_len;
-       caplen -= TOKEN_HDRLEN + route_len;
+       hdr_len += route_len;
+       length -= hdr_len;
+       p += hdr_len;
+       caplen -= hdr_len;
 
        /* Frame Control field determines interpretation of packet */
        extracted_ethertype = 0;
@@ -193,10 +194,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
                if (!xflag && !qflag)
                        default_print(p, caplen);
        }
-       if (xflag)
-               default_print(p, caplen);
-out:
-       putchar('\n');
+       return (hdr_len);
 }
 
 /*
@@ -210,11 +208,21 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int caplen = h->caplen;
        u_int length = h->len;
+       u_int hdr_len;
 
        ++infodelay;
        ts_print(&h->ts);
 
-       token_print(p, length, caplen);
+       hdr_len = token_print(p, length, caplen);
+
+       /*
+        * If "-x" was specified, print stuff past the Token Ring header,
+        * if there's anything to print.
+        */
+       if (xflag && caplen > hdr_len)
+               default_print(p + hdr_len, caplen - hdr_len);
+
+       putchar('\n');
 
        --infodelay;
        if (infoprint)