Subject: bin/4141: netbsd's tcpdump doesn't DTRT with appletalk
To: None <gnats-bugs@gnats.netbsd.org>
From: Daniel Hagerty <hag@ai.mit.edu>
List: netbsd-bugs
Date: 09/23/1997 03:24:38
>Number:         4141
>Category:       bin
>Synopsis:       tcpdump doesn't cope with appletalk
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 23 00:35:01 1997
>Last-Modified:
>Originator:     Daniel Hagerty
>Organization:
MIT AI Lab
>Release:        19970914
>Environment:
System: NetBSD repo-man.ai.mit.edu 1.2G NetBSD 1.2G (REPO_MAN) #3: Fri Aug 8 16:26:49 EDT 1997 hag@repo-man.ai.mit.edu:/fs/repo/hag/work/hacking/os/netbsd/src/sys/arch/i386/compile/REPO_MAN i386


>Description:
    tcpdump doesn't do the right thing with standard ethertalk packets.

>How-To-Repeat:
	dump an ethertalk packet and see it print garbage
>Fix:
	

Index: print-atalk.c
===================================================================
RCS file: /home/repo/hag/work/hacking/os/netbsd/cvsroot/netbsd/usr.sbin/tcpdump/print-atalk.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 print-atalk.c
--- print-atalk.c	1997/07/23 04:05:13	1.1.1.1
+++ print-atalk.c	1997/09/23 06:06:18
@@ -95,11 +95,8 @@
 static void ddp_print(const u_char *, int, int, u_short, u_char, u_char);
 static const char *ddpskt_string(int);
 
-/*
- * Print AppleTalk Datagram Delivery Protocol packets.
- */
 void
-atalk_print(register const u_char *bp, int length)
+llap_print(register const u_char *bp, int length)
 {
 	register const struct LAP *lp;
 	register const struct atDDP *dp;
@@ -154,6 +151,31 @@
 		    lp->src, lp->dst, lp->type, length);
 		break;
 	}
+}
+
+/*
+ * Print AppleTalk Datagram Delivery Protocol packets.
+ */
+void
+atalk_print(register const u_char *bp, 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_SHORT(&dp->srcNet);
+	printf("%s.%s", ataddr_string(snet, dp->srcNode),
+	       ddpskt_string(dp->srcSkt));
+	printf(" > %s.%s:",
+	       ataddr_string(EXTRACT_SHORT(&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() */

Index: print-udp.c
===================================================================
RCS file: /home/repo/hag/work/hacking/os/netbsd/cvsroot/netbsd/usr.sbin/tcpdump/print-udp.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 print-udp.c
--- print-udp.c	1997/07/23 04:05:14	1.1.1.1
+++ print-udp.c	1997/09/23 06:46:35
@@ -221,7 +221,7 @@
 		    (atalk_port(sport) || atalk_port(dport))) {
 			if (vflag)
 				fputs("kip ", stdout);
-			atalk_print(cp, length);
+			llap_print(cp, length);
 			return;
 		}
 	}
>Audit-Trail:
>Unformatted: