diff options
author | wollman <wollman@FreeBSD.org> | 1996-05-23 20:11:48 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1996-05-23 20:11:48 +0000 |
commit | f54ae37a95112e2bfe75acccd5720f7292ea0abc (patch) | |
tree | 59ddc37ef87e336e25e2bdfb2bbcc6e5db8b0f05 /sys/i386 | |
parent | a6d22d5527b448bae8f777f96f703f4c78759ae4 (diff) | |
download | FreeBSD-src-f54ae37a95112e2bfe75acccd5720f7292ea0abc.zip FreeBSD-src-f54ae37a95112e2bfe75acccd5720f7292ea0abc.tar.gz |
Add an incremental checksum update routine. Perhaps some i386 assembly
guru out there can find a way to take advantage of little-endianness to
make this computation more efficient. (I am certain that it can be done,
but haven't managed to make it work myself.)
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/include/in_cksum.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/i386/include/in_cksum.h b/sys/i386/include/in_cksum.h index 8142e6f..929a588 100644 --- a/sys/i386/include/in_cksum.h +++ b/sys/i386/include/in_cksum.h @@ -33,7 +33,7 @@ * from tahoe: in_cksum.c 1.2 86/01/05 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp - * $Id$ + * $Id: in_cksum.h,v 1.1 1996/04/18 15:39:27 wollman Exp $ */ #ifndef _MACHINE_IN_CKSUM_H_ @@ -69,8 +69,24 @@ in_cksum_hdr(const struct ip *ip) return ~sum & 0xffff; } + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + #else u_int in_cksum_hdr __P((const struct ip *)); +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + #endif #endif /* _MACHINE_IN_CKSUM_H_ */ |