1129198Scognet/*- 2129198Scognet * Copyright (c) 1990 The Regents of the University of California. 3129198Scognet * All rights reserved. 4129198Scognet * 5129198Scognet * Redistribution and use in source and binary forms, with or without 6129198Scognet * modification, are permitted provided that the following conditions 7129198Scognet * are met: 8129198Scognet * 1. Redistributions of source code must retain the above copyright 9129198Scognet * notice, this list of conditions and the following disclaimer. 10129198Scognet * 2. Redistributions in binary form must reproduce the above copyright 11129198Scognet * notice, this list of conditions and the following disclaimer in the 12129198Scognet * documentation and/or other materials provided with the distribution. 13279944Semaste * 3. Neither the name of the University nor the names of its contributors 14129198Scognet * may be used to endorse or promote products derived from this software 15129198Scognet * without specific prior written permission. 16129198Scognet * 17129198Scognet * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18129198Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19129198Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20129198Scognet * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21129198Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22129198Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23129198Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24129198Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25129198Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26129198Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27129198Scognet * SUCH DAMAGE. 28129198Scognet * 29129198Scognet * from tahoe: in_cksum.c 1.2 86/01/05 30129198Scognet * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 31129198Scognet * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp 32129198Scognet * $FreeBSD$ 33129198Scognet */ 34129198Scognet 35129198Scognet#ifndef _MACHINE_IN_CKSUM_H_ 36129198Scognet#define _MACHINE_IN_CKSUM_H_ 1 37129198Scognet 38129198Scognet#include <sys/cdefs.h> 39129198Scognet 40129198Scognet#ifdef _KERNEL 41129198Scognetu_short in_cksum(struct mbuf *m, int len); 42129198Scognetu_short in_addword(u_short sum, u_short b); 43129198Scognetu_short in_cksum_skip(struct mbuf *m, int len, int skip); 44146594Scognetu_int do_cksum(const void *, int); 45235941Sbz#if defined(IPVERSION) && (IPVERSION == 4) 46156520Scognetu_int in_cksum_hdr(const struct ip *); 47235941Sbz#endif 48146594Scognet 49150858Scognetstatic __inline u_short 50150858Scognetin_pseudo(u_int sum, u_int b, u_int c) 51150858Scognet{ 52150858Scognet __asm __volatile("adds %0, %0, %1\n" 53150858Scognet "adcs %0, %0, %2\n" 54150858Scognet "adc %0, %0, #0\n" 55236992Simp : "+r" (sum) 56150858Scognet : "r" (b), "r" (c)); 57150858Scognet sum = (sum & 0xffff) + (sum >> 16); 58150858Scognet if (sum > 0xffff) 59150858Scognet sum -= 0xffff; 60150858Scognet return (sum); 61150858Scognet} 62150858Scognet 63129198Scognet#endif /* _KERNEL */ 64129198Scognet#endif /* _MACHINE_IN_CKSUM_H_ */ 65