[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tcpdump-patches
Subject:    Calculate ICMP checksum
From:       volf () oasis ! IAEhv ! nl (Frank Volf)
Date:       2000-09-02 15:49:34
[Download RAW message or body]


Hi,

This patch calulcates and prints the ICMP checksum. If the checksum fails,
then it does not just print "wrong icmp csum" but will now print the
incorrect value and calculate the correct cksum for yo.

Frank

Index: print-icmp.c
===================================================================
RCS file: /tcpdump/master/tcpdump/print-icmp.c,v
retrieving revision 1.48
diff -u -r1.48 print-icmp.c
--- print-icmp.c	2000/07/01 03:39:03	1.48
+++ print-icmp.c	2000/09/02 15:43:23
@@ -377,8 +377,13 @@
         (void)printf("icmp: %s", str);
 	if (vflag) {
 		if (TTEST2(*bp, plen)) {
-			if (in_cksum((u_short*)dp, plen, 0))
-				printf(" (wrong icmp csum)");
+			if (in_cksum((u_short*)dp, plen, 0)) {
+				
+				int goodsum = in_cksum((const u_short *)dp, plen, ~dp->icmp_cksum);
+				
+				printf(" (wrong icmp csum %x should be %x)", ntohs(dp->icmp_cksum), ntohs(goodsum));
+			
+			};
 		}
 	}
  	if (vflag > 1 && !ICMP_INFOTYPE(dp->icmp_type)) {

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic