in_cksum.c (84221) | in_cksum.c (92913) |
---|---|
1/* $NetBSD: in_cksum.c,v 1.3 1995/04/22 13:53:48 cgd Exp $ */ 2 3/* 4 * Copyright (c) 1992 Regents of the University of California. 5 * All rights reserved. 6 * 7 * This software was developed by the Computer Systems Engineering group 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and --- 26 unchanged lines hidden (view full) --- 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#) Header: in_cksum.c,v 1.1 92/09/11 01:15:55 leres Exp (LBL) 40 */ 41 42#include <sys/cdefs.h> | 1/* $NetBSD: in_cksum.c,v 1.3 1995/04/22 13:53:48 cgd Exp $ */ 2 3/* 4 * Copyright (c) 1992 Regents of the University of California. 5 * All rights reserved. 6 * 7 * This software was developed by the Computer Systems Engineering group 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and --- 26 unchanged lines hidden (view full) --- 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#) Header: in_cksum.c,v 1.1 92/09/11 01:15:55 leres Exp (LBL) 40 */ 41 42#include <sys/cdefs.h> |
43__FBSDID("$FreeBSD: head/lib/libstand/in_cksum.c 84221 2001-09-30 22:28:01Z dillon $"); | 43__FBSDID("$FreeBSD: head/lib/libstand/in_cksum.c 92913 2002-03-21 23:39:28Z obrien $"); |
44 45#include <sys/types.h> 46 47/* 48 * Checksum routine for Internet Protocol family headers. 49 * This routine is very heavily used in the network 50 * code and should be modified for each CPU to be as fast as possible. 51 * In particular, it should not be this one. 52 */ 53int 54in_cksum(p, len) | 44 45#include <sys/types.h> 46 47/* 48 * Checksum routine for Internet Protocol family headers. 49 * This routine is very heavily used in the network 50 * code and should be modified for each CPU to be as fast as possible. 51 * In particular, it should not be this one. 52 */ 53int 54in_cksum(p, len) |
55 register void *p; 56 register int len; | 55 void *p; 56 int len; |
57{ | 57{ |
58 register int sum = 0, oddbyte = 0, v = 0; 59 register u_char *cp = p; | 58 int sum = 0, oddbyte = 0, v = 0; 59 u_char *cp = p; |
60 61 /* we assume < 2^16 bytes being summed */ 62 while (len > 0) { 63 if (oddbyte) { 64 sum += v + *cp++; 65 len--; 66 } 67 if (((long)cp & 1) == 0) { --- 19 unchanged lines hidden --- | 60 61 /* we assume < 2^16 bytes being summed */ 62 while (len > 0) { 63 if (oddbyte) { 64 sum += v + *cp++; 65 len--; 66 } 67 if (((long)cp & 1) == 0) { --- 19 unchanged lines hidden --- |