X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/cf53dc05f1c854cc8cb94afd3409bbf033a055ed..4890d02f2cbdfd68f0dfb8ce7123fb61b4a591d4:/print-atalk.c diff --git a/print-atalk.c b/print-atalk.c index 94766961..19e43097 100644 --- a/print-atalk.c +++ b/print-atalk.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.59 2000-09-29 04:58:34 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.66 2001-06-18 08:52:53 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -34,23 +34,19 @@ static const char rcsid[] = #include #include -#if __STDC__ -struct mbuf; -struct rtentry; -#endif - #include #include #include #include +#include /* for MAXHOSTNAMELEN on some platforms */ +#include #include "interface.h" #include "addrtoname.h" #include "ethertype.h" #include "extract.h" /* must come after interface.h */ #include "appletalk.h" -#include "savestr.h" static struct tok type2str[] = { { ddpRTMP, "rtmp" }, @@ -88,10 +84,24 @@ 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 LLAP packets received on a physical LocalTalk interface. */ void -atalk_print(register const u_char *bp, u_int length) +ltalk_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +{ + snapend = p + h->caplen; + ts_print(&h->ts); + llap_print(p, h->caplen); + if(xflag) + default_print(p, h->caplen); + putchar('\n'); +} + +/* + * Print AppleTalk LLAP packets. + */ +void +llap_print(register const u_char *bp, u_int length) { register const struct LAP *lp; register const struct atDDP *dp; @@ -148,6 +158,33 @@ atalk_print(register const u_char *bp, u_int length) } } +/* + * Print EtherTalk/TokenTalk packets (or FDDITalk, or whatever it's called + * when it runs over FDDI; yes, I've seen FDDI captures with AppleTalk + * packets in them). + */ +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); +} + /* XXX should probably pass in the snap header and do checks like arp_print() */ void aarp_print(register const u_char *bp, u_int length) @@ -182,6 +219,9 @@ aarp_print(register const u_char *bp, u_int length) ap->halen, ap->palen); } +/* + * Print AppleTalk Datagram Delivery Protocol packets. + */ static void ddp_print(register const u_char *bp, register u_int length, register int t, register u_short snet, register u_char snode, u_char skt) @@ -484,7 +524,7 @@ ataddr_string(u_short atnet, u_char athost) { register struct hnamemem *tp, *tp2; register int i = (atnet << 8) | athost; - char nambuf[256]; + char nambuf[MAXHOSTNAMELEN + 20]; static int first = 1; FILE *fp; @@ -516,7 +556,7 @@ ataddr_string(u_short atnet, u_char athost) ; tp->addr = i3; tp->nxt = newhnamemem(); - tp->name = savestr(nambuf); + tp->name = strdup(nambuf); } fclose(fp); } @@ -533,7 +573,7 @@ ataddr_string(u_short atnet, u_char athost) tp->nxt = newhnamemem(); (void)snprintf(nambuf, sizeof(nambuf), "%s.%d", tp2->name, athost); - tp->name = savestr(nambuf); + tp->name = strdup(nambuf); return (tp->name); } @@ -545,7 +585,7 @@ ataddr_string(u_short atnet, u_char athost) else (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8, atnet & 0xff); - tp->name = savestr(nambuf); + tp->name = strdup(nambuf); return (tp->name); }