]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add support for NetBSD DLT_PPP_SERIAL (PPP in HDLC-like framing, as per
authorguy <guy>
Mon, 18 Sep 2000 05:11:43 +0000 (05:11 +0000)
committerguy <guy>
Mon, 18 Sep 2000 05:11:43 +0000 (05:11 +0000)
RFC 1662, or Cisco point-to-point with HDLC framing, as per seciont
4.3.1 of RFC 1547; there's always an address and control octet at the
beginning of these packets, but they're not necessarily 0xff 0x03),
which we map to PCAP_ENCAP_PPP_HDLC.

FILES
chdlc.h [new file with mode: 0644]
interface.h
print-chdlc.c
print-ppp.c
tcpdump.c

diff --git a/FILES b/FILES
index 4cd4588ea2980bba49a7f6da2de1f71245d3e525..99d5598fba28162e9f3333855a37bb35559e7d92 100644 (file)
--- a/FILES
+++ b/FILES
@@ -12,6 +12,7 @@ addrtoname.h
 appletalk.h
 atime.awk
 bootp.h
+chdlc.h
 config.guess
 config.h.in
 config.sub
diff --git a/chdlc.h b/chdlc.h
new file mode 100644 (file)
index 0000000..d117263
--- /dev/null
+++ b/chdlc.h
@@ -0,0 +1,27 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/chdlc.h,v 1.1 2000-09-18 05:11:43 guy Exp $ (LBL) */
+/*
+ * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#define CHDLC_HDRLEN           4
+#define CHDLC_UNICAST          0x0f
+#define CHDLC_BCAST            0x8f
+#define CHDLC_TYPE_SLARP       0x8035
+#define CHDLC_TYPE_CDP         0x2000
index e9d10220f2d4ec2090ebf44f87b94b9881001f2e..1254b7859223396612e313274a193cfddfec0f08 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.134 2000-07-25 05:28:11 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.135 2000-09-18 05:11:43 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -263,6 +263,8 @@ extern void mobile_print(const u_char *, u_int);
 extern void pim_print(const u_char *, u_int);
 extern void pppoe_print(const u_char *, u_int);
 extern void ppp_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
+extern void ppp_hdlc_if_print(u_char *, const struct pcap_pkthdr *,
+       const u_char *);
 extern void ppp_bsdos_if_print(u_char *, const struct pcap_pkthdr *,
        const u_char *);
 extern int vjc_print(register const char *, register u_int, u_short);
index d6766989bd45dcff49379fb522d871f19b09b72f..41582c50f6594c079d2e1751e84c62c90cf3d1d5 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.4 2000-07-01 03:39:01 assar Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.5 2000-09-18 05:11:44 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -56,13 +56,7 @@ struct rtentry;
 #include "interface.h"
 #include "addrtoname.h"
 #include "ppp.h"
-
-/* XXX This goes somewhere else. */
-#define CHDLC_HDRLEN 4
-#define CHDLC_UNICAST  0x0f
-#define CHDLC_BCAST    0x8f
-#define CHDLC_TYPE_SLARP       0x8035
-#define CHDLC_TYPE_CDP         0x2000
+#include "chdlc.h"
 
 static void chdlc_slarp_print(const u_char *, u_int);
 
index 3beb022023ff8d217f23c8f7d0cab03dfeb4ccf9..f184d09225891cacf3890768c08da1f2a5e228d3 100644 (file)
@@ -31,7 +31,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.43 2000-09-09 07:06:17 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.44 2000-09-18 05:11:44 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -66,6 +66,7 @@ struct rtentry;
 #include "extract.h"
 #include "addrtoname.h"
 #include "ppp.h"
+#include "chdlc.h"
 
 /* XXX This goes somewhere else. */
 #define PPP_HDRLEN 4
@@ -1113,6 +1114,88 @@ out:
        putchar('\n');
 }
 
+/*
+ * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
+ * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
+ * is being used (i.e., we don't check for PPP_ADDRESS and PPP_CONTROL,
+ * discard them *if* those are the first two octets, and parse the remaining
+ * packet as a PPP packet, as "ppp_print()" does).
+ *
+ * This handles, for example, DLT_PPP_SERIAL in NetBSD.
+ */
+void
+ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
+            register const u_char *p)
+{
+       register u_int length = h->len;
+       register u_int caplen = h->caplen;
+       u_int proto;
+
+       if (caplen < 2) {
+               printf("[|ppp]");
+               goto out;
+       }
+
+       /*
+        * Some printers want to get back at the link level addresses,
+        * and/or check that they're not walking off the end of the packet.
+        * Rather than pass them all the way down, we set these globals.
+        */
+       packetp = p;
+       snapend = p + caplen;
+
+       switch (p[0]) {
+
+       case PPP_ADDRESS:
+               if (caplen < 4) {
+                       printf("[|ppp]");
+                       goto out;
+               }
+
+               ts_print(&h->ts);
+               if (eflag)
+                       printf("%02x %02x %d ", p[0], p[1], length);
+               p += 2;
+               length -= 2;
+
+               proto = EXTRACT_16BITS(p);
+               p += 2;
+               length -= 2;
+               printf("%s: ", ppp_protoname(proto));
+
+               handle_ppp(proto, p, length);
+               break;
+
+       case CHDLC_UNICAST:
+       case CHDLC_BCAST:
+               /*
+                * Have the Cisco HDLC print routine do all the work.
+                */
+               chdlc_if_print(user, h, p);
+               return;
+
+       default:
+               ts_print(&h->ts);
+               if (eflag)
+                       printf("%02x %02x %d ", p[0], p[1], length);
+               p += 2;
+               length -= 2;
+
+               /*
+                * XXX - NetBSD's "ppp_netbsd_serial_if_print()" treats
+                * the next two octets as an Ethernet type; does that
+                * ever happen?
+                */
+               printf("unknown addr %02x; ctrl %02x", p[0], p[1]);
+               break;
+       }
+
+       if (xflag)
+               default_print(p, caplen);
+out:
+       putchar('\n');
+}
+
 
 
 struct tok ppptype2str[] = {
index be9e031b2a314586a796859725d7e0039def243c..bc07a1abb5d62ef1e627d1f5965cfb0d0d40289d 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -24,7 +24,7 @@ static const char copyright[] =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.151 2000-09-17 04:13:13 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.152 2000-09-18 05:11:44 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -125,7 +125,8 @@ static struct printer printers[] = {
        { fddi_if_print,        PCAP_ENCAP_FDDI },
 
        /*
-        * DLT_* codes that aren't the same on all platforms.
+        * DLT_* codes that aren't the same on all platforms, or that
+        * aren't present on all platforms.
         */
 #ifdef DLT_ATM_RFC1483
        { atm_if_print,         DLT_ATM_RFC1483 },
@@ -148,6 +149,9 @@ static struct printer printers[] = {
 #ifdef DLT_LANE8023
        { lane_if_print,        DLT_LANE8023 },
 #endif
+#ifdef DLT_PPP_SERIAL
+       { ppp_hdlc_if_print,    DLT_PPP_SERIAL },
+#endif
 
        /*
         * PCAP_ENCAP_* codes corresponding to DLT_* codes that aren't
@@ -160,6 +164,7 @@ static struct printer printers[] = {
        { ppp_bsdos_if_print,   PCAP_ENCAP_PPP_BSDOS },
        { chdlc_if_print,       PCAP_ENCAP_C_HDLC },
        { cip_if_print,         PCAP_ENCAP_ATM_CLIP },
+       { ppp_hdlc_if_print,    PCAP_ENCAP_PPP_HDLC },
        { NULL,                 0 },
 };