> to update a checksum when changing a word
>
> #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?
Looks like a straight forward implementation of rfc1624 eqn 4.
"if (c < 0) c += 0xffff;" is needed to turn two's complement
subtraction to one's complement.
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message