diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2014-04-20 16:48:23 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2014-04-20 16:48:23 +0000 |
commit | 3d6ad47a2d10491393e8ac81552dcb696a228aec (patch) | |
tree | 304719aa913845fa43af67fe37cf9bdf6198d0b7 /sys | |
parent | f56d2a77de87d6c6c8084d18333b3f9f288b8c4b (diff) |
move in6_cksum_phdr from in6.h to ip6_output.c to mirror in_cksum_phdr
ok henning@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet6/in6.h | 51 | ||||
-rw-r--r-- | sys/netinet6/ip6_output.c | 42 |
2 files changed, 42 insertions, 51 deletions
diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 7a17a3e9c8f..78cd3e32a72 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.h,v 1.70 2014/01/22 14:27:20 naddy Exp $ */ +/* $OpenBSD: in6.h,v 1.71 2014/04/20 16:48:22 naddy Exp $ */ /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */ /* @@ -416,55 +416,6 @@ typedef __socklen_t socklen_t; /* length type for network syscalls */ #endif /* __BSD_VISIBLE */ #ifdef _KERNEL -/* - * in6_cksum_phdr: - * - * Compute significant parts of the IPv6 checksum pseudo-header - * for use in a delayed TCP/UDP checksum calculation. - * - * Args: - * - * src Source IPv6 address - * dst Destination IPv6 address - * len htonl(proto-hdr-len) - * nxt htonl(next-proto-number) - * - * NOTE: We expect the src and dst addresses to be 16-bit - * aligned! - */ -static __inline u_int16_t __attribute__((__unused__)) -in6_cksum_phdr(const struct in6_addr *src, const struct in6_addr *dst, - u_int32_t len, u_int32_t nxt) -{ - u_int32_t sum = 0; - const u_int16_t *w; - - w = (const u_int16_t *) src; - sum += w[0]; - if (!IN6_IS_SCOPE_EMBED(src)) - sum += w[1]; - sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; - sum += w[6]; sum += w[7]; - - w = (const u_int16_t *) dst; - sum += w[0]; - if (!IN6_IS_SCOPE_EMBED(dst)) - sum += w[1]; - sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; - sum += w[6]; sum += w[7]; - - sum += (u_int16_t)(len >> 16) + (u_int16_t)(len /*& 0xffff*/); - - sum += (u_int16_t)(nxt >> 16) + (u_int16_t)(nxt /*& 0xffff*/); - - sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/); - - if (sum > 0xffff) - sum -= 0xffff; - - return (sum); -} - extern u_char inet6ctlerrmap[]; extern struct ifqueue ip6intrq; /* IP6 packet input queue */ extern struct in6_addr zeroin6_addr; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index edf128a252b..6e38cb1a8c1 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.154 2014/04/14 09:06:42 mpi Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.155 2014/04/20 16:48:22 naddy Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -132,6 +132,9 @@ int ip6_splithdr(struct mbuf *, struct ip6_exthdrs *); int ip6_getpmtu(struct route_in6 *, struct route_in6 *, struct ifnet *, struct in6_addr *, u_long *, int *); int copypktopts(struct ip6_pktopts *, struct ip6_pktopts *, int); +static __inline u_int16_t __attribute__((__unused__)) + in6_cksum_phdr(const struct in6_addr *, const struct in6_addr *, + u_int32_t, u_int32_t); void in6_delayed_cksum(struct mbuf *, u_int8_t); /* Context for non-repeating IDs */ @@ -3203,6 +3206,43 @@ ip6_randomid_init(void) } /* + * Compute significant parts of the IPv6 checksum pseudo-header + * for use in a delayed TCP/UDP checksum calculation. + */ +static __inline u_int16_t __attribute__((__unused__)) +in6_cksum_phdr(const struct in6_addr *src, const struct in6_addr *dst, + u_int32_t len, u_int32_t nxt) +{ + u_int32_t sum = 0; + const u_int16_t *w; + + w = (const u_int16_t *) src; + sum += w[0]; + if (!IN6_IS_SCOPE_EMBED(src)) + sum += w[1]; + sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; + sum += w[6]; sum += w[7]; + + w = (const u_int16_t *) dst; + sum += w[0]; + if (!IN6_IS_SCOPE_EMBED(dst)) + sum += w[1]; + sum += w[2]; sum += w[3]; sum += w[4]; sum += w[5]; + sum += w[6]; sum += w[7]; + + sum += (u_int16_t)(len >> 16) + (u_int16_t)(len /*& 0xffff*/); + + sum += (u_int16_t)(nxt >> 16) + (u_int16_t)(nxt /*& 0xffff*/); + + sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/); + + if (sum > 0xffff) + sum -= 0xffff; + + return (sum); +} + +/* * Process a delayed payload checksum calculation. */ void |