Linux-2.6.12-rc2
[cascardo/linux.git] / include / asm-ia64 / checksum.h
1 #ifndef _ASM_IA64_CHECKSUM_H
2 #define _ASM_IA64_CHECKSUM_H
3
4 /*
5  * Modified 1998, 1999
6  *      David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
7  */
8
9 /*
10  * This is a version of ip_compute_csum() optimized for IP headers,
11  * which always checksum on 4 octet boundaries.
12  */
13 extern unsigned short ip_fast_csum (unsigned char * iph, unsigned int ihl);
14
15 /*
16  * Computes the checksum of the TCP/UDP pseudo-header returns a 16-bit
17  * checksum, already complemented
18  */
19 extern unsigned short int csum_tcpudp_magic (unsigned long saddr,
20                                              unsigned long daddr,
21                                              unsigned short len,
22                                              unsigned short proto,
23                                              unsigned int sum);
24
25 extern unsigned int csum_tcpudp_nofold (unsigned long saddr,
26                                         unsigned long daddr,
27                                         unsigned short len,
28                                         unsigned short proto,
29                                         unsigned int sum);
30
31 /*
32  * Computes the checksum of a memory block at buff, length len,
33  * and adds in "sum" (32-bit)
34  *
35  * returns a 32-bit number suitable for feeding into itself
36  * or csum_tcpudp_magic
37  *
38  * this function must be called with even lengths, except
39  * for the last fragment, which may be odd
40  *
41  * it's best to have buff aligned on a 32-bit boundary
42  */
43 extern unsigned int csum_partial (const unsigned char * buff, int len,
44                                   unsigned int sum);
45
46 /*
47  * Same as csum_partial, but copies from src while it checksums.
48  *
49  * Here it is even more important to align src and dst on a 32-bit (or
50  * even better 64-bit) boundary.
51  */
52 extern unsigned int csum_partial_copy_from_user (const char *src, char *dst,
53                                                  int len, unsigned int sum,
54                                                  int *errp);
55
56 extern unsigned int csum_partial_copy_nocheck (const char *src, char *dst,
57                                                int len, unsigned int sum);
58
59 /*
60  * This routine is used for miscellaneous IP-like checksums, mainly in
61  * icmp.c
62  */
63 extern unsigned short ip_compute_csum (unsigned char *buff, int len);
64
65 /*
66  * Fold a partial checksum without adding pseudo headers.
67  */
68 static inline unsigned short
69 csum_fold (unsigned int sum)
70 {
71         sum = (sum & 0xffff) + (sum >> 16);
72         sum = (sum & 0xffff) + (sum >> 16);
73         return ~sum;
74 }
75
76 #endif /* _ASM_IA64_CHECKSUM_H */