From owner-freebsd-net Tue Apr 9 16:20:17 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 63D9237B405 for ; Tue, 9 Apr 2002 16:20:12 -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 <20020409232007.UFWS15826.rwcrmhc54.attbi.com@InterJet.elischer.org> for ; Tue, 9 Apr 2002 23:20: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 QAA58521 for ; Tue, 9 Apr 2002 16:02:02 -0700 (PDT) Date: Tue, 9 Apr 2002 16:02:01 -0700 (PDT) From: Julian Elischer To: net@freebsd.org Subject: IP checksup update 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 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