Changeset View
Changeset View
Standalone View
Standalone View
sys/i386/include/in_cksum.h
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
#define in_cksum(m, len) in_cksum_skip(m, len, 0) | #define in_cksum(m, len) in_cksum_skip(m, len, 0) | ||||
/* | /* | ||||
* It it useful to have an Internet checksum routine which is inlineable | * It it useful to have an Internet checksum routine which is inlineable | ||||
* and optimized specifically for the task of computing IP header checksums | * and optimized specifically for the task of computing IP header checksums | ||||
* in the normal case (where there are no options and the header length is | * in the normal case (where there are no options and the header length is | ||||
* therefore always exactly five 32-bit words. | * therefore always exactly five 32-bit words. | ||||
*/ | */ | ||||
#if defined(__GNUCLIKE_ASM) | |||||
#if defined(IPVERSION) && (IPVERSION == 4) | #if defined(IPVERSION) && (IPVERSION == 4) | ||||
static __inline u_int | static __inline u_int | ||||
in_cksum_hdr(const struct ip *ip) | in_cksum_hdr(const struct ip *ip) | ||||
{ | { | ||||
u_int sum = 0; | u_int sum = 0; | ||||
__asm( | __asm( | ||||
"addl %1, %0\n" | "addl %1, %0\n" | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | : "g" (b), | ||||
"g" (c) | "g" (c) | ||||
: "cc" | : "cc" | ||||
); | ); | ||||
sum = (sum & 0xffff) + (sum >> 16); | sum = (sum & 0xffff) + (sum >> 16); | ||||
if (sum > 0xffff) | if (sum > 0xffff) | ||||
sum -= 0xffff; | sum -= 0xffff; | ||||
return (sum); | return (sum); | ||||
} | } | ||||
#endif | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#define HAVE_MD_IN_CKSUM | #define HAVE_MD_IN_CKSUM | ||||
#if !defined(__GNUCLIKE_ASM) | |||||
#if defined(IPVERSION) && (IPVERSION == 4) | |||||
u_int in_cksum_hdr(const struct ip *ip); | |||||
#endif | |||||
u_short in_addword(u_short sum, u_short b); | |||||
u_short in_pseudo(u_int sum, u_int b, u_int c); | |||||
#endif | |||||
u_short in_cksum_skip(struct mbuf *m, int len, int skip); | u_short in_cksum_skip(struct mbuf *m, int len, int skip); | ||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
#endif /* _MACHINE_IN_CKSUM_H_ */ | #endif /* _MACHINE_IN_CKSUM_H_ */ |