diff options
author | Joachim Nilsson <troglobit@gmail.com> | 2019-10-09 06:44:22 +0200 |
---|---|---|
committer | Joachim Nilsson <troglobit@gmail.com> | 2019-10-09 06:44:22 +0200 |
commit | 047bc8b8a72109ad684a05f80913aebc87ba0a14 (patch) | |
tree | 5b4085ba8fb77f566745dd4fb28114d9cb16719f /src | |
parent | 152bd2f0a168343f66ad4eccb36af4e9e792b0b4 (diff) | |
download | libnet-047bc8b8a72109ad684a05f80913aebc87ba0a14.tar.gz |
libnet_in_cksum(): Clean up, remove unused DEBIAN code
This removes the last (unused) remnants of a Debian discussion about
checksumming odd sized packets.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=284729
The resulting code from this change is what we've had for several years
now, without any more bug reports. So I'm removing the unused code to
make it easier to read.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libnet_checksum.c | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/src/libnet_checksum.c b/src/libnet_checksum.c index 596bd19..16995de 100644 --- a/src/libnet_checksum.c +++ b/src/libnet_checksum.c @@ -32,53 +32,30 @@ #include "common.h" -/* FIXME - unit test these - 0 is debian's version, else is -RC1's */ -/* Note about aliasing warning: - * - * http://mail.opensolaris.org/pipermail/tools-gcc/2005-August/000047.html - * - * See RFC 1071, and: - * - * http://mathforum.org/library/drmath/view/54379.html - */ -#undef DEBIAN /* Note: len is in bytes, not 16-bit words! */ int libnet_in_cksum(uint16_t *addr, int len) { - int sum; -#ifdef DEBIAN - uint16_t last_byte; - - sum = 0; - last_byte = 0; -#else + int sum = 0; union { uint16_t s; uint8_t b[2]; - }pad; + } pad; sum = 0; -#endif while (len > 1) { sum += *addr++; len -= 2; } -#ifdef DEBIAN - if (len == 1) - { - *(uint8_t *)&last_byte = *(uint8_t *)addr; - sum += last_byte; -#else + if (len == 1) { pad.b[0] = *(uint8_t *)addr; pad.b[1] = 0; sum += pad.s; -#endif } return (sum); |