Import 2.3.18pre1
[davej-history.git] / include / asm-sh / checksum.h
blobb2bbd8afb953d8e7b486102336d9152bd3a8ad83
1 #ifndef __ASM_SH_CHECKSUM_H
2 #define __ASM_SH_CHECKSUM_H
5 /*
6 * This is a version of ip_compute_csum() optimized for IP headers,
7 * which always checksum on 4 octet boundaries.
8 */
9 extern unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl);
12 * computes the checksum of the TCP/UDP pseudo-header
13 * returns a 16-bit checksum, already complemented
15 extern unsigned short int csum_tcpudp_magic(unsigned long saddr,
16 unsigned long daddr,
17 unsigned short len,
18 unsigned short proto,
19 unsigned int sum);
22 * computes the checksum of a memory block at buff, length len,
23 * and adds in "sum" (32-bit)
25 * returns a 32-bit number suitable for feeding into itself
26 * or csum_tcpudp_magic
28 * this function must be called with even lengths, except
29 * for the last fragment, which may be odd
31 * it's best to have buff aligned on a 32-bit boundary
33 extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
36 * the same as csum_partial, but copies from src while it
37 * checksums
39 * here even more important to align src and dst on a 32-bit (or even
40 * better 64-bit) boundary
42 unsigned int csum_partial_copy(const char *src, char *dst, int len, unsigned int sum);
45 * the same as csum_partial, but copies from user space (but on the alpha
46 * we have just one address space, so this is identical to the above)
48 * this is obsolete and will go away.
50 #define csum_partial_copy_fromuser csum_partial_copy
53 * this is a new version of the above that records errors it finds in *errp,
54 * but continues and zeros the rest of the buffer.
56 unsigned int csum_partial_copy_from_user(const char *src, char *dst, int len, unsigned int sum, int *errp);
59 * this routine is used for miscellaneous IP-like checksums, mainly
60 * in icmp.c
63 extern unsigned short ip_compute_csum(unsigned char * buff, int len);
66 * Fold a partial checksum without adding pseudo headers
69 static inline unsigned short csum_fold(unsigned int sum)
71 sum = (sum & 0xffff) + (sum >> 16);
72 sum = (sum & 0xffff) + (sum >> 16);
73 return ~sum;
76 #define _HAVE_ARCH_IPV6_CSUM
78 extern unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
79 struct in6_addr *daddr,
80 __u16 len,
81 unsigned short proto,
82 unsigned int sum);
84 #endif /* __ASM_SH_CHECKSUM_H */