diff options
author | YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org> | 2013-01-14 02:10:24 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-14 13:17:01 -0500 |
commit | 5206c579da0f5b93c3ae17bd8010d8dbd9fcdbe9 (patch) | |
tree | 6fa0e4014f5224ed237b6c7baddadceaba54cfaa /include/net/ipv6.h | |
parent | a04d40b8956010d2a6a7abc9254792c8f8649242 (diff) |
ipv6: 64bit version of ipv6_addr_set().
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ipv6.h')
-rw-r--r-- | include/net/ipv6.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 77cef3321571..fb7f7c645e15 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -355,14 +355,32 @@ static inline void ipv6_addr_prefix(struct in6_addr *pfx, | |||
355 | pfx->s6_addr[o] = addr->s6_addr[o] & (0xff00 >> b); | 355 | pfx->s6_addr[o] = addr->s6_addr[o] & (0xff00 >> b); |
356 | } | 356 | } |
357 | 357 | ||
358 | static inline void __ipv6_addr_set_half(__be32 *addr, | ||
359 | __be32 wh, __be32 wl) | ||
360 | { | ||
361 | #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 | ||
362 | #if defined(__BIG_ENDIAN) | ||
363 | if (__builtin_constant_p(wh) && __builtin_constant_p(wl)) { | ||
364 | *(__force u64 *)addr = ((__force u64)(wh) << 32 | (__force u64)(wl)); | ||
365 | return; | ||
366 | } | ||
367 | #elif defined(__LITTLE_ENDIAN) | ||
368 | if (__builtin_constant_p(wl) && __builtin_constant_p(wh)) { | ||
369 | *(__force u64 *)addr = ((__force u64)(wl) << 32 | (__force u64)(wh)); | ||
370 | return; | ||
371 | } | ||
372 | #endif | ||
373 | #endif | ||
374 | addr[0] = wh; | ||
375 | addr[1] = wl; | ||
376 | } | ||
377 | |||
358 | static inline void ipv6_addr_set(struct in6_addr *addr, | 378 | static inline void ipv6_addr_set(struct in6_addr *addr, |
359 | __be32 w1, __be32 w2, | 379 | __be32 w1, __be32 w2, |
360 | __be32 w3, __be32 w4) | 380 | __be32 w3, __be32 w4) |
361 | { | 381 | { |
362 | addr->s6_addr32[0] = w1; | 382 | __ipv6_addr_set_half(&addr->s6_addr32[0], w1, w2); |
363 | addr->s6_addr32[1] = w2; | 383 | __ipv6_addr_set_half(&addr->s6_addr32[2], w3, w4); |
364 | addr->s6_addr32[2] = w3; | ||
365 | addr->s6_addr32[3] = w4; | ||
366 | } | 384 | } |
367 | 385 | ||
368 | static inline bool ipv6_addr_equal(const struct in6_addr *a1, | 386 | static inline bool ipv6_addr_equal(const struct in6_addr *a1, |