Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Apr 2002 17:28:07 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        Bakul Shah <bakul@bitblocks.com>
Cc:        net@freebsd.org
Subject:   Re: IP checksup update 
Message-ID:  <Pine.BSF.4.21.0204091727110.57350-100000@InterJet.elischer.org>
In-Reply-To: <200204100018.UAA13907@sheffield.cnchost.com>

next in thread | previous in thread | raw e-mail | index | archive | help
just looking at this.... (it's been a while....)

On Tue, 9 Apr 2002, Bakul Shah wrote:

> > 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));              \
             ^^ hmm should that be "+=" ?
> >       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 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.0204091727110.57350-100000>