6e869e402d
- All three functions are included in the kernel by default. They call a backend function cpu_in_cksum after possibly computing the checksum of the pseudo header. - cpu_in_cksum is the core to implement the one-complement sum. The default implementation is moderate fast on most platforms and provides a 32bit accumulator with 16bit addends for L32 platforms and a 64bit accumulator with 32bit addends for L64 platforms. It handles edge cases like very large mbuf chains (could happen with native IPv6 in the future) and provides a good base for new native implementations. - Modify i386 and amd64 assembly to use the new interface. This disables the MD implementations on !x86 until the conversion is done. For Alpha, the portable version is faster.
47 lines
1.9 KiB
C
47 lines
1.9 KiB
C
/* $NetBSD: in_cksum.c,v 1.22 2008/01/25 21:12:15 joerg Exp $ */
|
|
|
|
/*
|
|
* Copyright (c) 1988, 1992, 1993
|
|
* The Regents of the University of California. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
* @(#)in_cksum.c 8.1 (Berkeley) 6/10/93
|
|
*/
|
|
|
|
#include <sys/cdefs.h>
|
|
__KERNEL_RCSID(0, "$NetBSD: in_cksum.c,v 1.22 2008/01/25 21:12:15 joerg Exp $");
|
|
|
|
#include <sys/param.h>
|
|
#include <netinet/in.h>
|
|
|
|
int
|
|
in_cksum(struct mbuf *m, int len)
|
|
{
|
|
KASSERT(len >= 0);
|
|
|
|
return cpu_in_cksum(m, len, 0, 0);
|
|
}
|