Date: Tue, 9 Apr 2002 16:02:01 -0700 (PDT) From: Julian Elischer <julian@elischer.org> To: net@freebsd.org Subject: IP checksup update Message-ID: <Pine.BSF.4.21.0204091557570.57350-100000@InterJet.elischer.org>
next in thread | raw e-mail | index | archive | help
Several years ago I wrte the following macro
to update a checksum when changing a word
in an IP packet.
here's the code...
#define FIXSUM16(c, op, np) \
do { \
(c) -= (u_int16_t) ~*((u_int16_t *) (op)); \
if ((c) < 0) { \
(c) += 0xffff; \
} \
(c) -= (u_int16_t) *((u_int16_t *) (np)); \
if ((c) < 0) { \
(c) += 0xffff; \
} \
} while (0)
The question is:
apparently there are several "tricks" with this checksum
and + and - 0. Does anyone know how to test if this macro gets it
right?
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0204091557570.57350-100000>
