Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ALPHA_CHECKSUM_H
0003 #define _ALPHA_CHECKSUM_H
0004 
0005 #include <linux/in6.h>
0006 
0007 /*
0008  *  This is a version of ip_compute_csum() optimized for IP headers,
0009  *  which always checksum on 4 octet boundaries.
0010  */
0011 extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
0012 
0013 /*
0014  * computes the checksum of the TCP/UDP pseudo-header
0015  * returns a 16-bit checksum, already complemented
0016  */
0017 __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
0018               __u32 len, __u8 proto, __wsum sum);
0019 
0020 __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
0021               __u32 len, __u8 proto, __wsum sum);
0022 
0023 /*
0024  * computes the checksum of a memory block at buff, length len,
0025  * and adds in "sum" (32-bit)
0026  *
0027  * returns a 32-bit number suitable for feeding into itself
0028  * or csum_tcpudp_magic
0029  *
0030  * this function must be called with even lengths, except
0031  * for the last fragment, which may be odd
0032  *
0033  * it's best to have buff aligned on a 32-bit boundary
0034  */
0035 extern __wsum csum_partial(const void *buff, int len, __wsum sum);
0036 
0037 /*
0038  * the same as csum_partial, but copies from src while it
0039  * checksums
0040  *
0041  * here even more important to align src and dst on a 32-bit (or even
0042  * better 64-bit) boundary
0043  */
0044 #define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
0045 #define _HAVE_ARCH_CSUM_AND_COPY
0046 __wsum csum_and_copy_from_user(const void __user *src, void *dst, int len);
0047 
0048 __wsum csum_partial_copy_nocheck(const void *src, void *dst, int len);
0049 
0050 
0051 /*
0052  * this routine is used for miscellaneous IP-like checksums, mainly
0053  * in icmp.c
0054  */
0055 
0056 extern __sum16 ip_compute_csum(const void *buff, int len);
0057 
0058 /*
0059  *  Fold a partial checksum without adding pseudo headers
0060  */
0061 
0062 static inline __sum16 csum_fold(__wsum csum)
0063 {
0064     u32 sum = (__force u32)csum;
0065     sum = (sum & 0xffff) + (sum >> 16);
0066     sum = (sum & 0xffff) + (sum >> 16);
0067     return (__force __sum16)~sum;
0068 }
0069 
0070 #define _HAVE_ARCH_IPV6_CSUM
0071 extern __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
0072                    const struct in6_addr *daddr,
0073                    __u32 len, __u8 proto, __wsum sum);
0074 #endif