diff options
Diffstat (limited to 'usr.sbin/tcpdump')
-rw-r--r-- | usr.sbin/tcpdump/appletalk.h | 8 | ||||
-rw-r--r-- | usr.sbin/tcpdump/interface.h | 3 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-atalk.c | 64 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-llc.c | 22 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-null.c | 26 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-udp.c | 4 |
6 files changed, 105 insertions, 22 deletions
diff --git a/usr.sbin/tcpdump/appletalk.h b/usr.sbin/tcpdump/appletalk.h index 4fb30df9840..5e65043f8e0 100644 --- a/usr.sbin/tcpdump/appletalk.h +++ b/usr.sbin/tcpdump/appletalk.h @@ -20,7 +20,7 @@ * * AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX). * - * @(#) $Header: /home/cvs/src/usr.sbin/tcpdump/appletalk.h,v 1.5 1996/12/12 16:22:59 bitblt Exp $ (LBL) + * @(#) $Header: /home/cvs/src/usr.sbin/tcpdump/appletalk.h,v 1.6 1997/07/23 02:59:00 denny Exp $ (LBL) */ struct LAP { @@ -121,6 +121,12 @@ struct atNBPtuple { #define nbpBrRq 0x10 #define nbpLkUp 0x20 #define nbpLkUpReply 0x30 +#define nbpFwd 0x40 +/* The following are not standard, but netatalk uses them. */ +#define nbpNATLKrgstr 0xc0 +#define nbpNATLKunrgstr 0xd0 +#define nbpNATLKok 0xe0 +#define nbpNATLKerr 0xf0 #define nbpNIS 2 #define nbpTupleMax 15 diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h index 492c4bec55c..3fabbed209d 100644 --- a/usr.sbin/tcpdump/interface.h +++ b/usr.sbin/tcpdump/interface.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /home/cvs/src/usr.sbin/tcpdump/interface.h,v 1.5 1996/12/12 16:22:53 bitblt Exp $ (LBL) + * @(#) $Header: /home/cvs/src/usr.sbin/tcpdump/interface.h,v 1.6 1997/07/23 02:59:01 denny Exp $ (LBL) */ #ifndef tcpdump_interface_h @@ -167,6 +167,7 @@ extern int llc_print(const u_char *, u_int, u_int, const u_char *, extern void aarp_print(const u_char *, u_int); extern void arp_print(const u_char *, u_int, u_int); extern void atalk_print(const u_char *, u_int); +extern void atalk_print_llap(const u_char *, u_int); extern void atm_if_print(u_char *, const struct pcap_pkthdr *, const u_char *); extern void bootp_print(const u_char *, u_int, u_short, u_short); extern void decnet_print(const u_char *, u_int, u_int); diff --git a/usr.sbin/tcpdump/print-atalk.c b/usr.sbin/tcpdump/print-atalk.c index 42394ee9276..1883e4e5499 100644 --- a/usr.sbin/tcpdump/print-atalk.c +++ b/usr.sbin/tcpdump/print-atalk.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-atalk.c,v 1.5 1996/12/12 16:22:43 bitblt Exp $ (LBL)"; + "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-atalk.c,v 1.6 1997/07/23 02:59:01 denny Exp $ (LBL)"; #endif #include <sys/param.h> @@ -92,11 +92,41 @@ static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char); static const char *ddpskt_string(int); /* - * Print AppleTalk Datagram Delivery Protocol packets. + * Print AppleTalk Datagram Delivery Protocol packets + * without the LLAP encapsulating header (i.e. + * from Ethertalk) */ void atalk_print(register const u_char *bp, u_int length) { + register const struct atDDP *dp; + u_short snet; + + if (length < ddpSize) { + (void)printf(" [|ddp %d]", length); + return; + } + dp = (const struct atDDP *)bp; + snet = EXTRACT_16BITS(&dp->srcNet); + printf("%s.%s", ataddr_string(snet, dp->srcNode), + ddpskt_string(dp->srcSkt)); + printf(" > %s.%s:", + ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode), + ddpskt_string(dp->dstSkt)); + bp += ddpSize; + length -= ddpSize; + ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt); +} + +/* + * Print AppleTalk Datagram Delivery Protocol packets + * from localtalk (i.e. the 230 Kbps net built into + * every Macintosh). We can get these from a localtalk + * interface if we have one, or from UDP encapsulated tunnels. + */ +void +atalk_print_llap(register const u_char *bp, u_int length) +{ register const struct LAP *lp; register const struct atDDP *dp; register const struct atShortDDP *sdp; @@ -338,10 +368,23 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet, int i; const u_char *ep; + if (length < nbpHeaderSize) { + (void)printf(" truncated-nbp %d", length); + return; + } + length -= nbpHeaderSize; if (length < 8) { /* must be room for at least one tuple */ - (void)printf(" truncated-nbp %d", length + nbpHeaderSize); + if (np->control == nbpNATLKerr) { + (void)printf(" nbp-netatalk_err"); + return; + } else if (np->control == nbpNATLKok) { + (void)printf(" nbp-netatalk_ok"); + return; + } + (void)printf(" truncated-nbp nbp-0x%x %d (%d)", + np->control, np->id, length + nbpHeaderSize); return; } /* ep points to end of available data */ @@ -385,6 +428,16 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet, tp = nbp_tuple_print(tp, ep, snet, snode, skt); break; + case nbpNATLKrgstr: + case nbpNATLKunrgstr: + (void)printf((i == nbpNATLKrgstr) ? + " nbp-netatalk_rgstr %d:" : + " nbp-netatalk_unrgstr %d:", + np->id); + for (i = np->control & 0xf; --i >= 0 && tp; ) + tp = nbp_tuple_print(tp, ep, snet, snode, skt); + break; + default: (void)printf(" nbp-0x%x %d (%d)", np->control, np->id, length); @@ -542,10 +595,9 @@ ataddr_string(u_short atnet, u_char athost) tp->addr = (atnet << 8) | athost; tp->nxt = newhnamemem(); if (athost != 255) - (void)sprintf(nambuf, "%d.%d.%d", - atnet >> 8, atnet & 0xff, athost); + (void)sprintf(nambuf, "%d.%d", atnet, athost); else - (void)sprintf(nambuf, "%d.%d", atnet >> 8, atnet & 0xff); + (void)sprintf(nambuf, "%d", atnet); tp->name = savestr(nambuf); return (tp->name); diff --git a/usr.sbin/tcpdump/print-llc.c b/usr.sbin/tcpdump/print-llc.c index 6be6cfe92d1..c61d5d0d05c 100644 --- a/usr.sbin/tcpdump/print-llc.c +++ b/usr.sbin/tcpdump/print-llc.c @@ -24,7 +24,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-llc.c,v 1.5 1996/12/12 16:22:33 bitblt Exp $"; + "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-llc.c,v 1.6 1997/07/23 02:59:02 denny Exp $"; #endif #include <sys/param.h> @@ -41,6 +41,7 @@ static const char rcsid[] = #include "interface.h" #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ +#include "ethertype.h" #include "llc.h" @@ -106,7 +107,24 @@ llc_print(const u_char *p, u_int length, u_int caplen, /* This is an encapsulated Ethernet packet */ et = EXTRACT_16BITS(&llc.ethertype[0]); - ret = ether_encap_print(et, p, length, caplen); + + /* + * Some protocols have special handling if they are 802.3 + * SNAP encapsulated vs vers II encapsulated. Handle + * those special protocols here, and hand the rest to + * print-ether.c so we don't have to duplicate + * all that code here. + */ + switch (et) { + case ETHERTYPE_ATALK: + atalk_print(p, length); + ret = 1; + break; + default: + ret = ether_encap_print(et, p, length, caplen); + break; + } + if (ret) return (ret); } diff --git a/usr.sbin/tcpdump/print-null.c b/usr.sbin/tcpdump/print-null.c index f79d04a611d..ec4c572636d 100644 --- a/usr.sbin/tcpdump/print-null.c +++ b/usr.sbin/tcpdump/print-null.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-null.c,v 1.5 1996/12/12 16:22:30 bitblt Exp $ (LBL)"; + "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-null.c,v 1.6 1997/07/23 02:59:02 denny Exp $ (LBL)"; #endif #include <sys/param.h> @@ -60,11 +60,8 @@ struct rtentry; #endif static void -null_print(const u_char *p, const struct ip *ip, u_int length) +null_print(const u_char *p, u_int length, u_int family) { - u_int family; - - memcpy((char *)&family, (char *)p, sizeof(family)); if (nflag) { /* XXX just dump the header */ @@ -91,7 +88,8 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { u_int length = h->len; u_int caplen = h->caplen; - const struct ip *ip; + u_int family; + const u_char *pkt; ts_print(&h->ts); @@ -103,17 +101,25 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) packetp = p; snapend = p + caplen; + pkt = p + NULL_HDRLEN; length -= NULL_HDRLEN; - ip = (struct ip *)(p + NULL_HDRLEN); + memcpy((char *)&family, (char *)p, sizeof(family)); if (eflag) - null_print(p, ip, length); + null_print(p, length, family); - ip_print((const u_char *)ip, length); + switch (family) { + case AF_INET: + ip_print(pkt, length); + break; + case AF_APPLETALK: + atalk_print(pkt, length); + break; + } if (xflag) - default_print((const u_char *)ip, caplen - NULL_HDRLEN); + default_print(pkt, caplen - NULL_HDRLEN); putchar('\n'); } diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c index bff2f4e7c74..0fe844408bd 100644 --- a/usr.sbin/tcpdump/print-udp.c +++ b/usr.sbin/tcpdump/print-udp.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-udp.c,v 1.5 1996/12/12 16:22:24 bitblt Exp $ (LBL)"; + "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-udp.c,v 1.6 1997/07/23 02:59:02 denny Exp $ (LBL)"; #endif #include <sys/param.h> @@ -400,7 +400,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2) (atalk_port(sport) || atalk_port(dport))) { if (vflag) fputs("kip ", stdout); - atalk_print(cp, length); + atalk_print_llap(cp, length); return; } } |