]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Put the LINUX_SLL_P_ definitions back, and check for at least some of
authorguy <guy>
Fri, 22 Dec 2000 22:45:09 +0000 (22:45 +0000)
committerguy <guy>
Fri, 22 Dec 2000 22:45:09 +0000 (22:45 +0000)
them in "print-sll.c" - as a cooked-mode capture may be reading from
non-Ethernet, non-802.x devices, it may well see some
ETH_P_/LINUX_SLL_P_ types that don't mean "this is an 802.2 LLC frame".

We currently assume that the ETH_P_ values won't change in the kernel,
so we don't have to explicitly map them.

In various link-layer packet printers, if we don't handle the next layer
up of packet type, and are printing the link-layer header, use the
correct pointer to that header (i.e., if we've stepped "p" past the
link-layer header, don't use "p", use a pointer to the beginning of the
packet), and use the correct length (i.e., if we've subtracted the
length of the link-layer header, add it back in, so that we always print
the full packet length).

print-atm.c
print-cip.c
print-ether.c
print-fddi.c
print-lane.c
print-sll.c
print-token.c
sll.h

index 2407b48000a91e069f1be3b2f6601ef711ccff1f..7458116ffa2ee272ebef85d98058f911806c492e 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.19 2000-10-06 04:23:10 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.20 2000-12-22 22:45:09 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -131,8 +131,8 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                /* ether_type not known, print raw packet */
                if (!eflag)
                        printf("%02x %02x %02x %02x-%02x-%02x %04x: ",
-                              p[0], p[1], p[2], /* dsap/ssap/ctrl */
-                              p[3], p[4], p[5], /* manufacturer's code */
+                              packetp[0], packetp[1], packetp[2], /* dsap/ssap/ctrl */
+                              packetp[3], packetp[4], packetp[5], /* manufacturer's code */
                               ethertype);
                if (!xflag && !qflag)
                        default_print(p, caplen);
index 7a2de818c1a3f8ee6b634669abdd4cb5e5cba296..58fec126d15012a99cdac23274f5795eafd58569 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.10 2000-12-18 05:41:58 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.11 2000-12-22 22:45:10 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -136,7 +136,7 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                    &extracted_ethertype)==0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
-                               cip_print((u_char *)bp, length);
+                               cip_print((u_char *)bp, length + RFC1483LLC_LEN);
                        if (extracted_ethertype) {
                                printf("(LLC %s) ",
                               etherproto_string(htons(extracted_ethertype)));
index 0711cca9651dac52593238d27d7a50b2789095b3..e6d6b09ca9d3b5b3332b745689c267e3ce69cdc9 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.60 2000-12-18 05:41:59 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.61 2000-12-22 22:45:10 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -117,7 +117,7 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                    &extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
-                               ether_print((u_char *)ep, length);
+                               ether_print((u_char *)ep, length + ETHER_HDRLEN);
                        if (extracted_ethertype) {
                                printf("(LLC %s) ",
                               etherproto_string(htons(extracted_ethertype)));
index 6763ad4bde82d827e1024124a3d54b823773928e..f8a2ffdd7f6972194b406a22027aa1bc6c920d1d 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.48 2000-12-18 05:41:59 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.49 2000-12-22 22:45:11 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -305,7 +305,7 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
                         * handle intelligently
                         */
                        if (!eflag)
-                               fddi_print(fddip, length,
+                               fddi_print(fddip, length + FDDI_HDRLEN,
                                    ESRC(&ehdr), EDST(&ehdr));
                        if (extracted_ethertype) {
                                printf("(LLC %s) ",
@@ -319,7 +319,8 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
        else {
                /* Some kinds of FDDI packet we cannot handle intelligently */
                if (!eflag)
-                       fddi_print(fddip, length, ESRC(&ehdr), EDST(&ehdr));
+                       fddi_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
+                           EDST(&ehdr));
                if (!xflag && !qflag)
                        default_print(p, caplen);
        }
index 149a5aed9f2d72f89304fe8250a3cccc28cda2fd..6aadad46bc1b054af42d11d11e0a6c2dbccf996b 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.10 2000-12-18 05:42:00 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.11 2000-12-22 22:45:11 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -116,7 +116,7 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                    &extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
-                               lane_print((u_char *)ep, length);
+                               lane_print((u_char *)ep, length + sizeof(*ep));
                        if (extracted_ethertype) {
                                printf("(LLC %s) ",
                               etherproto_string(htons(extracted_ethertype)));
index ad3b19cb59f454f968448c384aff0bed23f83dcc..fcb223e308a9d32e24d63d1781ee849003b72aab 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.1 2000-12-21 10:43:22 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.2 2000-12-22 22:45:11 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -187,28 +187,44 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
        ether_type = ntohs(sllp->sll_protocol);
 
        /*
-        * Is it (gag) an 802.3 encapsulation?
+        * Is it (gag) an 802.3 encapsulation, or some non-Ethernet
+        * packet type?
         */
        extracted_ethertype = 0;
        if (ether_type <= ETHERMTU) {
-               /* Try to print the LLC-layer header & higher layers */
-               if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
-                   &extracted_ethertype) == 0) {
+               /*
+                * Yes - what type is it?
+                */
+               switch (ether_type) {
+
+               case LINUX_SLL_P_802_2:
+                       /*
+                        * 802.2.
+                        * Try to print the LLC-layer header & higher layers.
+                        */
+                       if (llc_print(p, length, caplen, ESRC(&ehdr),
+                           EDST(&ehdr), &extracted_ethertype) == 0)
+                               goto unknown;   /* unknown LLC type */
+                       break;
+
+               default:
+               unknown:
                        /* ether_type not known, print raw packet */
                        if (!eflag)
-                               sll_print(packetp, length);
+                               sll_print(packetp, length + SLL_HDR_LEN);
                        if (extracted_ethertype) {
                                printf("(LLC %s) ",
                               etherproto_string(htons(extracted_ethertype)));
                        }
                        if (!xflag && !qflag)
                                default_print(p, caplen);
+                       break;
                }
        } else if (ether_encap_print(ether_type, p, length, caplen,
            &extracted_ethertype) == 0) {
                /* ether_type not known, print raw packet */
                if (!eflag)
-                       sll_print(p - SLL_HDR_LEN, length + SLL_HDR_LEN);
+                       sll_print(packetp, length + SLL_HDR_LEN);
                if (!xflag && !qflag)
                        default_print(p, caplen);
        }
index 9fa0b63b0b2906abf7aafa6f5c9d102e62bc153f..1a0cc69328b3ad33352c8cd15f0dc37141421619 100644 (file)
@@ -25,7 +25,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.9 2000-12-18 05:42:00 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.10 2000-12-22 22:45:12 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -184,7 +184,8 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                    &extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
-                               token_print(trp, length,
+                               token_print(trp,
+                                   length + TOKEN_HDRLEN + route_len,
                                    ESRC(&ehdr), EDST(&ehdr));
                        if (extracted_ethertype) {
                                printf("(LLC %s) ",
@@ -197,7 +198,8 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                /* Some kinds of TR packet we cannot handle intelligently */
                /* XXX - dissect MAC packets if frame type is 0 */
                if (!eflag)
-                       token_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+                       token_print(trp, length + TOKEN_HDRLEN + route_len,
+                           ESRC(&ehdr), EDST(&ehdr));
                if (!xflag && !qflag)
                        default_print(p, caplen);
        }
diff --git a/sll.h b/sll.h
index dc0ebb8270ec187927b04816ae2ccc7ad366c08e..f6c38263c9e42b5019259effcf7327ee175cefc3 100644 (file)
--- a/sll.h
+++ b/sll.h
@@ -35,7 +35,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.2 2000-12-22 12:18:32 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.3 2000-12-22 22:45:12 guy Exp $ (LBL)
  */
 
 /*
@@ -87,3 +87,27 @@ struct sll_header {
 #define LINUX_SLL_MULTICAST    2
 #define LINUX_SLL_OTHERHOST    3
 #define LINUX_SLL_OUTGOING     4
+
+/*
+ * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
+ * ETH_P_ values on Linux, but are defined here so that they're
+ * available even on systems other than Linux.  We assume, for now,
+ * that the ETH_P_ values won't change in Linux; if they do, then:
+ *
+ *     if we don't translate them in "pcap-linux.c", capture files
+ *     won't necessarily be readable if captured on a system that
+ *     defines ETH_P_ values that don't match these values;
+ *
+ *     if we do translate them in "pcap-linux.c", that makes life
+ *     unpleasant for the BPF code generator, as the values you test
+ *     for in the kernel aren't the values that you test for when
+ *     reading a capture file, so the fixup code run on BPF programs
+ *     handed to the kernel ends up having to do more work.
+ *
+ * Add other values here as necessary, for handling packet types that
+ * might show up on non-Ethernet, non-802.x networks.  (Not all the ones
+ * in the Linux "if_ether.h" will, I suspect, actually show up in
+ * captures.)
+ */
+#define LINUX_SLL_P_802_3      0x0001  /* Novell 802.3 frames without 802.2 LLC header */
+#define LINUX_SLL_P_802_2      0x0004  /* 802.2 frames (not D/I/X Ethernet) */