]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add a new routine "default_print_packet()", which takes a pointer to the
authorguy <guy>
Wed, 18 Dec 2002 09:41:13 +0000 (09:41 +0000)
committerguy <guy>
Wed, 18 Dec 2002 09:41:13 +0000 (09:41 +0000)
beginning of the raw packet data, the captured length of the raw packet
data, and the length of the link-layer header, and:

if "-e" was specified, prints all the raw packet data;

if "-e" was not specified, prints all the raw packet data past
the link-layer header, if there is any.

Use that routine in all the "xxx_if_print()" routines if "-x" was
specified.

Make "arcnet_encap_print()" static - it's not used outside
"print-arcnet.c".

Add missing info printing code to "atm_if_print()".

Print the packet data in "lane_if_print()", not in "lane_print()", as
"lane_print()" can be called from other "xxx_if_print()" routines, and
those routines will also print the packet data if "-x" was specified -
no need to print it twice.

19 files changed:
interface.h
print-802_11.c
print-arcnet.c
print-atm.c
print-chdlc.c
print-ether.c
print-fddi.c
print-fr.c
print-ipfc.c
print-lane.c
print-null.c
print-pflog.c
print-ppp.c
print-pppoe.c
print-sl.c
print-sll.c
print-token.c
tcpdump.1
tcpdump.c

index 36e9229c93d8eea21d1d8e2d8275bcda94e549bb..b42dac2da1c4de405746dfb20079ca2ecce1ebd2 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.201 2002-12-18 08:53:18 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.202 2002-12-18 09:41:13 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -213,6 +213,7 @@ extern void cnfp_print(const u_char *, const u_char *);
 extern void decnet_print(const u_char *, u_int, u_int);
 extern void default_print(const u_char *, u_int);
 extern void default_print_unaligned(const u_char *, u_int);
+extern void default_print_packet(const u_char *, u_int, u_int);
 extern void dvmrp_print(const u_char *, u_int);
 extern void egp_print(const u_char *);
 extern void pflog_if_print(u_char *, const struct pcap_pkthdr *,
index 1650912d8b836c7bb7f6836f1b2ab658bb492c61..b54b27f308c2ae6903b88fee67d75410e5e6859e 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.17 2002-12-18 08:53:19 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.18 2002-12-18 09:41:14 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -800,6 +800,8 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
 {
        u_int16_t fc;
        u_int HEADER_LENGTH;
+       const u_char *orig_p;
+       u_int orig_caplen;
        const u_int8_t *src, *dst;
        u_short extracted_ethertype;
 
@@ -825,6 +827,16 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
         */
        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 802.11 header.
+        */
        length -= HEADER_LENGTH;
        caplen -= HEADER_LENGTH;
        p += HEADER_LENGTH;
@@ -879,7 +891,7 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
        }
 
        if (xflag)
-               default_print(p, caplen);
+               default_print_packet(orig_p, orig_caplen, HEADER_LENGTH);
 }
 
 /*
index 30e42a814e3dca2b3cffef111122b5bbb1d41a05..7f1db3e3bf58b2fe2298c3947178e3c0a268360a 100644 (file)
@@ -22,7 +22,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.11 2002-12-18 08:53:19 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.12 2002-12-18 09:41:14 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -37,7 +37,7 @@ static const char rcsid[] =
 #include "interface.h"
 #include "arcnet.h"
 
-int arcnet_encap_print(u_char arctype, const u_char *p,
+static int arcnet_encap_print(u_char arctype, const u_char *p,
     u_int length, u_int caplen);
 
 struct tok arctypemap[] = {
@@ -111,6 +111,8 @@ arcnet_if_print(u_char *user _U_, 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;
@@ -174,6 +176,16 @@ arcnet_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
         */
        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;
        caplen -= archdrlen;
        p += archdrlen;
@@ -188,7 +200,7 @@ arcnet_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
 
  out2:
        if (xflag)
-               default_print(p, caplen);
+               default_print_packet(orig_p, orig_caplen, archdrlen);
 
  out:
        putchar('\n');
@@ -205,7 +217,7 @@ arcnet_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
  */
 
 
-int
+static int
 arcnet_encap_print(u_char arctype, const u_char *p,
     u_int length, u_int caplen)
 {
index 77977b256c19a27eb635ae5489c63793567b15f7..5b41cc784397eee8694cf590fa8f1b356910274b 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.31 2002-12-18 08:53:19 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.32 2002-12-18 09:41:14 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -139,6 +139,9 @@ atm_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
                default_print(p, caplen);
  out:
        putchar('\n');
+       --infodelay;
+       if (infoprint)
+               info(0);
 }
 
 /*
index 41a4d521beff38aaf156a0ca387dec3c64ff5b2c..5bd4bdb0b077b36868e3dd5e01dce77e7cf0cca3 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.25 2002-12-18 08:53:20 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.26 2002-12-18 09:41:15 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -132,7 +132,7 @@ chdlc_print(register const u_char *p, u_int length, u_int caplen)
                 break;
        }
        if (xflag)
-               default_print((const u_char *)ip, caplen - CHDLC_HDRLEN);
+               default_print_packet(p, caplen, CHDLC_HDRLEN);
 }
 
 struct cisco_slarp {
index 2d39273006aed43d557b5339e28e73b01632c075..fdd79642e84dbc1dc5469fafc72f027fe0f6f96f 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.74 2002-12-18 08:53:21 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.75 2002-12-18 09:41:15 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -134,11 +134,10 @@ ether_if_print(u_char *user _U_, 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 "-x" was specified, print packet data in hex.
         */
-       if (xflag && caplen > ETHER_HDRLEN)
-               default_print(p + ETHER_HDRLEN, caplen - ETHER_HDRLEN);
+       if (xflag)
+               default_print_packet(p, caplen, ETHER_HDRLEN);
 
        putchar('\n');
 
index 762feaca9f380648e90ef90d5be4c6752e62317d..0bd439ac92b5c3420551e5b8adc44cbd79a601c0 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.59 2002-12-18 08:53:21 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.60 2002-12-18 09:41:15 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -321,11 +321,10 @@ fddi_if_print(u_char *pcap _U_, 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 "-x" was specified, print packet data in hex.
         */
-       if (xflag && caplen > FDDI_HDRLEN)
-               default_print(p + FDDI_HDRLEN, caplen - FDDI_HDRLEN);
+       if (xflag)
+               default_print_packet(p, caplen, FDDI_HDRLEN);
 
        putchar('\n');
 
index f639dc620541e34f0b0e0f4f05b35d3d61c29507..8c27fc21084dc9399b0a17b75c72e1471cc6acfa 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.9 2002-12-18 08:53:21 guy Exp $ (LBL)";
+       "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.10 2002-12-18 09:41:16 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -217,6 +217,8 @@ fr_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
 {
        register u_int length = h->len;
        register u_int caplen = h->caplen;
+       const u_char *orig_p;
+       u_int orig_caplen;
        u_char protocol;
        int layer2_len;
        u_short extracted_ethertype;
@@ -240,6 +242,13 @@ fr_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
        if (eflag)
                fr_hdr_print(p, length);
 
+       /*
+        * 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;
+
        protocol = FR_PROTOCOL(p);
        layer2_len = LAYER2_LEN(p);
        p += layer2_len;
@@ -288,7 +297,7 @@ fr_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
        }
 
        if (xflag)
-               default_print(p, caplen);
+               default_print_packet(orig_p, orig_caplen, layer2_len);
 out:
        putchar('\n');
 }
index a33cfbdf49444bf13311cdbc76f99abaf847f998..3da01d65fb1ee31d4842704b838d77e9034aa31b 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.2 2002-12-18 08:53:21 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.3 2002-12-18 09:41:16 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -148,11 +148,10 @@ ipfc_if_print(u_char *pcap _U_, const struct pcap_pkthdr *h,
        ipfc_print(p, length, caplen);
 
        /*
-        * If "-x" was specified, print stuff past the Network_Header,
-        * if there's anything to print.
+        * If "-x" was specified, print packet data in hex.
         */
-       if (xflag && caplen > IPFC_HDRLEN)
-               default_print(p + IPFC_HDRLEN, caplen - IPFC_HDRLEN);
+       if (xflag)
+               default_print_packet(p, caplen, IPFC_HDRLEN);
 
        putchar('\n');
 
index fe0afb4b718ec8d425a3b0e11c4d1125d367be66..c727b9ffc7baaefe5ebebfb755136b26bdd58c1f 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.18 2002-12-18 08:53:22 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.19 2002-12-18 09:41:16 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -128,6 +128,9 @@ lane_print(const u_char *p, u_int length, u_int caplen)
         */
        snapend = p + caplen;
 
+       /*
+        * Go past the LANE header.
+        */
        length -= sizeof(struct lecdatahdr_8023);
        caplen -= sizeof(struct lecdatahdr_8023);
        ep = (struct lecdatahdr_8023 *)p;
@@ -161,8 +164,6 @@ lane_print(const u_char *p, u_int length, u_int caplen)
                if (!xflag && !qflag)
                        default_print(p, caplen);
        }
-       if (xflag)
-               default_print(p, caplen);
 }
 
 void
@@ -176,6 +177,13 @@ lane_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
 
        lane_print(p, length, caplen);
 
+       /*
+        * If "-x" was specified, print packet data in hex.
+        */
+       if (xflag)
+               default_print_packet(p, caplen,
+                   sizeof(struct lecdatahdr_8023));
+
        putchar('\n');
        --infodelay;
        if (infoprint)
index cdbb3734bcd02428a9251a29dbba0e8158785319..064408a05538f89927243656af3911bc66c51f18 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.45 2002-12-18 08:53:22 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.46 2002-12-18 09:41:16 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -149,7 +149,7 @@ null_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
        }
 
        if (xflag)
-               default_print((const u_char *)ip, caplen - NULL_HDRLEN);
+               default_print_packet(p, caplen, NULL_HDRLEN);
        putchar('\n');
        --infodelay;
        if (infoprint)
index f122a5a33c72371261790deb68a1a6d782fb752f..61d5dc920af6241bcaafbaff434de65e4fdea62f 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.5 2002-12-18 08:53:22 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.6 2002-12-18 09:41:17 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -102,6 +102,8 @@ pflog_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
 {
        u_int length = h->len;
        u_int caplen = h->caplen;
+       const u_char *orig_p;
+       u_int orig_caplen;
        const struct pfloghdr *hdr;
        u_int8_t af;
 
@@ -119,6 +121,13 @@ pflog_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
         */
        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;
+
        hdr = (const struct pfloghdr *)p;
        if (eflag)
                pflog_print(hdr);
@@ -147,7 +156,7 @@ pflog_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
        }
 
        if (xflag)
-               default_print(p, caplen);
+               default_print_packet(orig_p, orig_caplen, PFLOG_HDRLEN);
 out:
        putchar('\n');
        --infodelay;
index 6103be4b5830707f7c51b21c67675a95f22d5823..f7be51d50c4b65cd4c033cb1beb5f3fed60914e4 100644 (file)
@@ -31,7 +31,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.78 2002-12-18 08:53:23 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.79 2002-12-18 09:41:17 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -1129,6 +1129,8 @@ ppp_hdlc_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
 {
        register u_int length = h->len;
        register u_int caplen = h->caplen;
+       const u_char *orig_p;
+       u_int orig_caplen;
        u_int proto;
 
        ++infodelay;
@@ -1146,6 +1148,13 @@ ppp_hdlc_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
         */
        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;
+
        switch (p[0]) {
 
        case PPP_ADDRESS:
@@ -1188,7 +1197,7 @@ ppp_hdlc_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
        }
 
        if (xflag)
-               default_print(p, caplen);
+               default_print_packet(orig_p, orig_caplen, p - orig_p);
 out:
        putchar('\n');
        --infodelay;
@@ -1206,6 +1215,7 @@ ppp_bsdos_if_print(u_char *user _U_, const struct pcap_pkthdr *h _U_,
 #ifdef __bsdi__
        register u_int length = h->len;
        register u_int caplen = h->caplen;
+       const u_char *orig_p;
        register int hdrlength;
        u_int16_t ptype;
        const u_char *q;
@@ -1227,6 +1237,12 @@ ppp_bsdos_if_print(u_char *user _U_, const struct pcap_pkthdr *h _U_,
        snapend = p + caplen;
        hdrlength = 0;
 
+       /*
+        * Save the information for the full packet, so we can print
+        * everything if "-e" and "-x" are both specified.
+        */
+       orig_p = p;
+
 #if 0
        if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
                if (eflag)
@@ -1361,7 +1377,7 @@ ppp_bsdos_if_print(u_char *user _U_, const struct pcap_pkthdr *h _U_,
 
 printx:
        if (xflag)
-               default_print((const u_char *)p, caplen - hdrlength);
+               default_print_packet(orig_p, caplen, hdrlength);
 out:
        putchar('\n');
        --infodelay;
index 3d78f4ceb9ba44f50ca662a203319a9bad8eeebe..d6bafcf618093297b45e3ce2e91cdeb272a3682f 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.19 2002-12-18 08:53:23 guy Exp $ (LBL)";
+"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.20 2002-12-18 09:41:17 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -110,11 +110,10 @@ pppoe_if_print(u_char *user _U_, const struct pcap_pkthdr *h,
        hdr_len = pppoe_print(p, length);
 
        /*
-        * If "-x" was specified, print stuff past the PPPoE and PPP headers,
-        * if there's anything to print.
+        * If "-x" was specified, print packet data in hex.
         */
-       if (xflag && caplen > hdr_len)
-               default_print(p + hdr_len, caplen - hdr_len);
+       if (xflag)
+               default_print_packet(p, caplen, hdr_len);
 
        putchar('\n');
 
index 7505646270da3e8174fa88c1c237d2f1c0a9fd55..fa6fa0f1330a19738ee19638b71aa148b69f3a42 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.60 2002-12-18 08:53:24 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.61 2002-12-18 09:41:17 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -91,7 +91,7 @@ sl_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
        }
 
        if (xflag)
-               default_print((u_char *)ip, caplen - SLIP_HDRLEN);
+               default_print_packet(p, caplen, SLIP_HDRLEN);
  out:
        putchar('\n');
        --infodelay;
@@ -134,7 +134,7 @@ sl_bsdos_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p
        ip_print((u_char *)ip, length);
 
        if (xflag)
-               default_print((u_char *)ip, caplen - SLIP_HDRLEN);
+               default_print_packet(p, caplen, SLIP_HDRLEN);
  out:
        putchar('\n');
        --infodelay;
index 2cd90f72ace1673f2f37230236bdcaac21c974bc..ccb94fb53cc850a4a19ac3a1d08c0b13f28b46d8 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.10 2002-12-18 08:53:24 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.11 2002-12-18 09:41:18 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -97,6 +97,8 @@ sll_if_print(u_char *user _U_, 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;
        register const struct sll_header *sllp;
        u_short ether_type;
        u_short extracted_ethertype;
@@ -126,6 +128,16 @@ sll_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
         */
        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 cooked-mode header.
+        */
        length -= SLL_HDR_LEN;
        caplen -= SLL_HDR_LEN;
        p += SLL_HDR_LEN;
@@ -182,7 +194,7 @@ sll_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
                        default_print(p, caplen);
        }
        if (xflag)
-               default_print(p, caplen);
+               default_print_packet(orig_p, orig_caplen, SLL_HDR_LEN);
  out:
        putchar('\n');
        --infodelay;
index 5070e5b97ca6aa1acdcdae63737473593dcbf3ae..74dc536bdcc0e24724a71590115f574c81cb5a4f 100644 (file)
@@ -25,7 +25,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.20 2002-12-18 08:53:24 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.21 2002-12-18 09:41:18 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -208,11 +208,10 @@ token_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
        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 "-x" was specified, print packet data in hex.
         */
-       if (xflag && caplen > hdr_len)
-               default_print(p + hdr_len, caplen - hdr_len);
+       if (xflag)
+               default_print_packet(p, caplen, hdr_len);
 
        putchar('\n');
 
index ed8c2da7e2dd64c58a512879975760b789082ade..af1b1e45c2ca2e18500cc01bcbf12c504801a061 100644 (file)
--- a/tcpdump.1
+++ b/tcpdump.1
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.131 2002-12-05 23:59:42 hannes Exp $ (LBL)
+.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.132 2002-12-18 09:41:18 guy Exp $ (LBL)
 .\"
 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
 .\"    The Regents of the University of California.  All rights reserved.
@@ -446,7 +446,10 @@ They can later be printed with the \-r option.
 Standard output is used if \fIfile\fR is ``-''.
 .TP
 .B \-x
-Print each packet (minus its link level header) in hex.
+Print each packet (minus its link level header, unless
+.B \-e
+is specified)
+in hex.
 The smaller of the entire packet or
 .I snaplen
 bytes will be printed.  Note that this is the entire link-layer
index 6b02404ae2aaacf54de8173313392b09020ca3e3..59eae3faccdea4cb57a8e87fb6c8beeeb8d37c5a 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.189 2002-12-12 07:28:36 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.190 2002-12-18 09:41:19 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -795,7 +795,7 @@ default_print_unaligned(register const u_char *cp, register u_int length)
 #endif
 
 /*
- * By default, print the packet out in hex.
+ * By default, print the specified data out in hex.
  */
 void
 default_print(register const u_char *bp, register u_int length)
@@ -803,6 +803,31 @@ default_print(register const u_char *bp, register u_int length)
        default_print_unaligned(bp, length);
 }
 
+/*
+ * By default, print the packet out in hex; if eflag is set, print
+ * everything, otherwise print everything except for the link-layer
+ * header.
+ */
+void
+default_print_packet(register const u_char *bp, register u_int length,
+    u_int hdr_length)
+{
+       if (eflag) {
+               /*
+                * Include the link-layer header.
+                */
+               default_print_unaligned(bp, length);
+       } else {
+               /*
+                * Don't include the link-layer header - and if we have
+                * nothing past the link-layer header, print nothing.
+                */
+               if (length > hdr_length)
+                       default_print_unaligned(bp + hdr_length,
+                           length - hdr_length);
+       }
+}
+
 #ifdef SIGINFO
 RETSIGTYPE requestinfo(int signo _U_)
 {