diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-06-13 14:08:51 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-06-13 14:08:51 -0700 |
commit | 94a4b4608009a96bf791ff24b2d019f40a120085 (patch) | |
tree | 41899d9a56ee613b9d6b754401bdb2de36c9fee8 /print-mobile.c | |
parent | 26d81cbe26f0dd73e32ea615b2576dfdca71cfb7 (diff) | |
download | tcpdump-94a4b4608009a96bf791ff24b2d019f40a120085.tar.gz |
Go with Wireshark's Internet checksum routine.
The Wireshark routine is based on the BSD in-kernel portable checksum
routine (thus BSD-licensed); it takes a vector of pointers and lengths
and checksums the concatenation of the buffers in question (just as the
BSD in-kernel routine checksums a chain of mbufs).
This simplifies the "with a pseudo-header" checksums; hopefully it'll
fix up the problems being seen on some big-endian platforms, which might
be due to hand-calculating some or all of the checksum and doing so
incorrectly. It also gets rid of some code that might be dereferencing
unaligned pointers.
Diffstat (limited to 'print-mobile.c')
-rw-r--r-- | print-mobile.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/print-mobile.c b/print-mobile.c index 816ffd6e..de4eab1d 100644 --- a/print-mobile.c +++ b/print-mobile.c @@ -72,6 +72,7 @@ mobile_print(const u_char *bp, u_int length) { const u_char *cp = bp +8 ; const struct mobile_ip *mob; + struct cksum_vec vec[1]; u_short proto,crc; u_char osp =0; /* old source address present */ @@ -101,7 +102,9 @@ mobile_print(const u_char *bp, u_int length) (void)printf("> %s ",ipaddr_string(&mob->odst)); (void)printf("(oproto=%d)",proto>>8); } - if (in_cksum((u_short *)mob, osp ? 12 : 8, 0)!=0) { + vec[0].ptr = (const u_int8_t *)(void *)mob; + vec[0].len = osp ? 12 : 8; + if (in_cksum(vec, 1)!=0) { (void)printf(" (bad checksum %d)",crc); } |