From owner-freebsd-net Tue Apr 9 17:40:10 2002 Delivered-To: freebsd-net@freebsd.org Received: from rwcrmhc54.attbi.com (rwcrmhc54.attbi.com [216.148.227.87]) by hub.freebsd.org (Postfix) with ESMTP id 8F38A37B400 for ; Tue, 9 Apr 2002 17:40:07 -0700 (PDT) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc54.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020410004007.WYHM15826.rwcrmhc54.attbi.com@InterJet.elischer.org>; Wed, 10 Apr 2002 00:40:07 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id RAA58798; Tue, 9 Apr 2002 17:28:09 -0700 (PDT) Date: Tue, 9 Apr 2002 17:28:07 -0700 (PDT) From: Julian Elischer To: Bakul Shah Cc: net@freebsd.org Subject: Re: IP checksup update In-Reply-To: <200204100018.UAA13907@sheffield.cnchost.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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