aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ipv6.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2012-05-18 02:14:11 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-18 02:24:13 -0400
commit92113bfde2f0982daa5a372d67b62f3d55bbc88a (patch)
treeb5170e0f77f259c231cd105d7035203f1fa0bc1f /include/net/ipv6.h
parentcbc264cacd08e51fd4a64b5d5b1ba48f523990d1 (diff)
ipv6: bool conversions phase1
ipv6_opt_accepted() returns a bool, and can use const pointers ipv6_addr_equal(), ipv6_addr_any(), ipv6_addr_loopback(), ipv6_addr_orchid() return a bool. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ipv6.h')
-rw-r--r--include/net/ipv6.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 5f65e7c45266..1402139629e1 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -263,7 +263,7 @@ extern struct ipv6_txoptions * ipv6_renew_options(struct sock *sk, struct ipv6_t
263struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, 263struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
264 struct ipv6_txoptions *opt); 264 struct ipv6_txoptions *opt);
265 265
266extern int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb); 266extern bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb);
267 267
268int ip6_frag_nqueues(struct net *net); 268int ip6_frag_nqueues(struct net *net);
269int ip6_frag_mem(struct net *net); 269int ip6_frag_mem(struct net *net);
@@ -332,8 +332,8 @@ static inline void ipv6_addr_set(struct in6_addr *addr,
332 addr->s6_addr32[3] = w4; 332 addr->s6_addr32[3] = w4;
333} 333}
334 334
335static inline int ipv6_addr_equal(const struct in6_addr *a1, 335static inline bool ipv6_addr_equal(const struct in6_addr *a1,
336 const struct in6_addr *a2) 336 const struct in6_addr *a2)
337{ 337{
338 return ((a1->s6_addr32[0] ^ a2->s6_addr32[0]) | 338 return ((a1->s6_addr32[0] ^ a2->s6_addr32[0]) |
339 (a1->s6_addr32[1] ^ a2->s6_addr32[1]) | 339 (a1->s6_addr32[1] ^ a2->s6_addr32[1]) |
@@ -341,27 +341,27 @@ static inline int ipv6_addr_equal(const struct in6_addr *a1,
341 (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0; 341 (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0;
342} 342}
343 343
344static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2, 344static inline bool __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2,
345 unsigned int prefixlen) 345 unsigned int prefixlen)
346{ 346{
347 unsigned int pdw, pbi; 347 unsigned int pdw, pbi;
348 348
349 /* check complete u32 in prefix */ 349 /* check complete u32 in prefix */
350 pdw = prefixlen >> 5; 350 pdw = prefixlen >> 5;
351 if (pdw && memcmp(a1, a2, pdw << 2)) 351 if (pdw && memcmp(a1, a2, pdw << 2))
352 return 0; 352 return false;
353 353
354 /* check incomplete u32 in prefix */ 354 /* check incomplete u32 in prefix */
355 pbi = prefixlen & 0x1f; 355 pbi = prefixlen & 0x1f;
356 if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi)))) 356 if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi))))
357 return 0; 357 return false;
358 358
359 return 1; 359 return true;
360} 360}
361 361
362static inline int ipv6_prefix_equal(const struct in6_addr *a1, 362static inline bool ipv6_prefix_equal(const struct in6_addr *a1,
363 const struct in6_addr *a2, 363 const struct in6_addr *a2,
364 unsigned int prefixlen) 364 unsigned int prefixlen)
365{ 365{
366 return __ipv6_prefix_equal(a1->s6_addr32, a2->s6_addr32, 366 return __ipv6_prefix_equal(a1->s6_addr32, a2->s6_addr32,
367 prefixlen); 367 prefixlen);
@@ -389,19 +389,19 @@ struct ip6_create_arg {
389void ip6_frag_init(struct inet_frag_queue *q, void *a); 389void ip6_frag_init(struct inet_frag_queue *q, void *a);
390bool ip6_frag_match(struct inet_frag_queue *q, void *a); 390bool ip6_frag_match(struct inet_frag_queue *q, void *a);
391 391
392static inline int ipv6_addr_any(const struct in6_addr *a) 392static inline bool ipv6_addr_any(const struct in6_addr *a)
393{ 393{
394 return (a->s6_addr32[0] | a->s6_addr32[1] | 394 return (a->s6_addr32[0] | a->s6_addr32[1] |
395 a->s6_addr32[2] | a->s6_addr32[3]) == 0; 395 a->s6_addr32[2] | a->s6_addr32[3]) == 0;
396} 396}
397 397
398static inline int ipv6_addr_loopback(const struct in6_addr *a) 398static inline bool ipv6_addr_loopback(const struct in6_addr *a)
399{ 399{
400 return (a->s6_addr32[0] | a->s6_addr32[1] | 400 return (a->s6_addr32[0] | a->s6_addr32[1] |
401 a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0; 401 a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0;
402} 402}
403 403
404static inline int ipv6_addr_v4mapped(const struct in6_addr *a) 404static inline bool ipv6_addr_v4mapped(const struct in6_addr *a)
405{ 405{
406 return (a->s6_addr32[0] | a->s6_addr32[1] | 406 return (a->s6_addr32[0] | a->s6_addr32[1] |
407 (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0; 407 (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0;
@@ -411,7 +411,7 @@ static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
411 * Check for a RFC 4843 ORCHID address 411 * Check for a RFC 4843 ORCHID address
412 * (Overlay Routable Cryptographic Hash Identifiers) 412 * (Overlay Routable Cryptographic Hash Identifiers)
413 */ 413 */
414static inline int ipv6_addr_orchid(const struct in6_addr *a) 414static inline bool ipv6_addr_orchid(const struct in6_addr *a)
415{ 415{
416 return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010); 416 return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010);
417} 417}