]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Handle ICMP6 checksums more like TCP checksums.
authorGuy Harris <[email protected]>
Fri, 17 Jun 2011 08:17:47 +0000 (01:17 -0700)
committerGuy Harris <[email protected]>
Fri, 17 Jun 2011 08:17:47 +0000 (01:17 -0700)
Instead of printing the result of icmp6_cksum() if it's non-zero, print
the checksum field value and the value it should have had.  That means
that what we print is the same regardless of whether we're running on a
big-endian or little-endian machine.

print-icmp6.c

index be362bbf1dddbc2427cacb1a3182b513391e1ef4..ce1046ed2ea7493185e1a3baae6694bb4ae97e0a 100644 (file)
@@ -319,12 +319,15 @@ icmp6_print(netdissect_options *ndo,
        TCHECK(dp->icmp6_cksum);
 
        if (vflag && !fragmented) {
-               int sum = dp->icmp6_cksum;
+               u_int16_t sum, udp_sum;
 
                if (TTEST2(bp[0], length)) {
+                       udp_sum = EXTRACT_16BITS(&dp->icmp6_cksum);
                        sum = icmp6_cksum(ip, dp, length);
                        if (sum != 0)
-                               (void)printf("[bad icmp6 cksum %x!] ", sum);
+                               (void)printf("[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
+                                   udp_sum,
+                                   in_cksum_shouldbe(udp_sum, sum));
                        else
                                (void)printf("[icmp6 sum ok] ");
                }