]> The Tcpdump Group git mirrors - tcpdump/commitdiff
For packets with a bad TCP checksum, show the value from the header, and
authorguy <guy>
Sun, 21 Jul 2002 20:56:24 +0000 (20:56 +0000)
committerguy <guy>
Sun, 21 Jul 2002 20:56:24 +0000 (20:56 +0000)
the value it should have had, as we do for packets with a bad IP
checksum, rather than showing the non-zero computed checksum.

print-tcp.c

index cd1299d9947e8a70775b4af4dcbef79fed2484ad..1f57dfcf46e7388d53b083d0241d4c0f50d39f00 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.95 2001-12-10 08:21:24 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.96 2002-07-21 20:56:24 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -393,12 +393,14 @@ tcp_print(register const u_char *bp, register u_int length,
        }
 
        if (IP_V(ip) == 4 && vflag && !fragmented) {
-               int sum;
+               u_int16_t sum, tcp_sum;
                if (TTEST2(tp->th_sport, length)) {
                        sum = tcp_cksum(ip, tp, length);
-                       if (sum != 0)
-                               (void)printf(" [bad tcp cksum %x!]", sum);
-                       else
+                       if (sum != 0) {
+                               tcp_sum = ntohs(tp->th_sum);
+                               (void)printf(" [bad tcp cksum %x (->%x)!]",
+                                   tcp_sum, in_cksum_shouldbe(tcp_sum, sum));
+                       } else
                                (void)printf(" [tcp sum ok]");
                }
        }