Handle ICMP6 checksums more like TCP checksums.

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.
This commit is contained in:
Guy Harris 2011-06-17 01:17:47 -07:00
parent d9b4befd18
commit 879217e502

View 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] ");
}