35 #include <linux/module.h>
37 static inline unsigned short from32to16(
unsigned long x)
40 x = (x & 0xffff) + (x >> 16);
42 x = (x & 0xffff) + (x >> 16);
46 static unsigned long do_csum(
const unsigned char * buff,
int len)
53 odd = 1 & (
unsigned long) buff;
61 if (2 & (
unsigned long) buff) {
62 result += *(
unsigned short *) buff;
69 unsigned long carry = 0;
71 unsigned long w = *(
unsigned long *) buff;
79 result = (result & 0xffff) + (result >> 16);
82 result += *(
unsigned short *) buff;
87 result += (*buff << 8);
88 result = from32to16(result);
90 result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
122 unsigned int result =
do_csum(buff, len);
127 result = (result & 0xffff) + (result >> 16);
150 if (csum_err) *csum_err = 0;