From owner-freebsd-net Tue Oct 24 9:32:20 2000 Delivered-To: freebsd-net@freebsd.org Received: from mailman.packetdesign.com (dns.PACKETDESIGN.NET [216.15.46.10]) by hub.freebsd.org (Postfix) with ESMTP id 0281D37B4D7 for ; Tue, 24 Oct 2000 09:32:17 -0700 (PDT) Received: from bubba.packetdesign.com (bubba.packetdesign.com [192.168.0.223]) by mailman.packetdesign.com (8.11.0/8.11.0) with ESMTP id e9OGWGQ08072 for ; Tue, 24 Oct 2000 09:32:16 -0700 (PDT) (envelope-from archie@packetdesign.com) Received: (from archie@localhost) by bubba.packetdesign.com (8.11.1/8.11.1) id e9OGTe426654 for freebsd-net@freebsd.org; Tue, 24 Oct 2000 09:29:40 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200010241629.e9OGTe426654@bubba.packetdesign.com> Subject: tcpdump patch To: freebsd-net@freebsd.org Date: Tue, 24 Oct 2000 09:29:40 -0700 (PDT) Reply-To: archie@freebsd.org X-Mailer: ELM [version 2.4ME+ PL82 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Anyone care to review this patch? It prints a message if a TCP packet with a bad checksum is seen. Thanks, -Archie __________________________________________________________________________ Archie Cobbs * Packet Design, Inc. * http://www.packetdesign.com Index: src/contrib/tcpdump/interface.h =================================================================== RCS file: /home/ncvs/src/contrib/tcpdump/interface.h,v retrieving revision 1.4 diff -u -r1.4 interface.h --- interface.h 2000/01/30 01:00:50 1.4 +++ interface.h 2000/07/20 00:03:17 @@ -263,4 +263,4 @@ extern void ospf6_print(const u_char *, u_int); extern void dhcp6_print(const u_char *, u_int, u_short, u_short); #endif /*INET6*/ -extern u_short in_cksum(const u_short *addr, register int len, u_short csum); +extern u_short in_cksum(const u_short *addr, register int len, u_int csum); Index: src/contrib/tcpdump/print-ip.c =================================================================== RCS file: /home/ncvs/src/contrib/tcpdump/print-ip.c,v retrieving revision 1.7 diff -u -r1.7 print-ip.c --- print-ip.c 2000/01/30 01:00:53 1.7 +++ print-ip.c 2000/07/20 00:03:18 @@ -379,12 +379,11 @@ * don't modifiy the packet. */ u_short -in_cksum(const u_short *addr, register int len, u_short csum) +in_cksum(const u_short *addr, register int len, u_int sum) { int nleft = len; const u_short *w = addr; u_short answer; - int sum = csum; /* * Our algorithm is simple, using a 32 bit accumulator (sum), Index: src/contrib/tcpdump/print-tcp.c =================================================================== RCS file: /home/ncvs/src/contrib/tcpdump/print-tcp.c,v retrieving revision 1.1.1.4 diff -u -r1.1.1.4 print-tcp.c --- print-tcp.c 2000/01/30 00:45:48 1.1.1.4 +++ print-tcp.c 2000/07/20 00:03:18 @@ -494,6 +494,25 @@ * Decode payload if necessary. */ bp += (tp->th_off * 4); + + /* + * Verify the checksum if the full packet was captured + */ + if (vflag && TTEST2(*bp, length)) { + u_short tlen = (tp->th_off * 4) + length; + u_int sum = 0; + + sum += ((u_short *)&ip->ip_src)[0]; + sum += ((u_short *)&ip->ip_src)[1]; + sum += ((u_short *)&ip->ip_src)[2]; + sum += ((u_short *)&ip->ip_src)[3]; + sum += htons(IPPROTO_TCP); + sum += (u_short)htons(tlen); + sum = in_cksum((u_short *)tp, tlen, sum); + if (sum != 0) + (void)printf(" bad tcp cksum %x!", ntohs(tp->th_sum)); + } + if (!qflag && vflag && length > 0 && (sport == TELNET_PORT || dport == TELNET_PORT)) telnet_print(bp, length); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message