diff options
author | guy <guy> | 2000-09-18 05:11:43 +0000 |
---|---|---|
committer | guy <guy> | 2000-09-18 05:11:43 +0000 |
commit | 6bd49d02af518be352e9e1f34ccaa8d2bde2db09 (patch) | |
tree | ef1f40ff1becbe765080cf6d61764cbf69652a9f | |
parent | 4ab25244f490af0abefee72c185969b124d7df0f (diff) | |
download | tcpdump-6bd49d02af518be352e9e1f34ccaa8d2bde2db09.tar.gz |
Add support for NetBSD DLT_PPP_SERIAL (PPP in HDLC-like framing, as per
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.
-rw-r--r-- | FILES | 1 | ||||
-rw-r--r-- | chdlc.h | 27 | ||||
-rw-r--r-- | interface.h | 4 | ||||
-rw-r--r-- | print-chdlc.c | 10 | ||||
-rw-r--r-- | print-ppp.c | 85 | ||||
-rw-r--r-- | tcpdump.c | 9 |
6 files changed, 124 insertions, 12 deletions
@@ -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 index 00000000..d1172633 --- /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 diff --git a/interface.h b/interface.h index e9d10220..1254b785 100644 --- a/interface.h +++ b/interface.h @@ -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); diff --git a/print-chdlc.c b/print-chdlc.c index d6766989..41582c50 100644 --- a/print-chdlc.c +++ b/print-chdlc.c @@ -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); diff --git a/print-ppp.c b/print-ppp.c index 3beb0220..f184d092 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -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[] = { @@ -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 }, }; |