From fa550434502bd4a20bc9e8dabb39295f1bb79fde Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 18 Feb 2021 02:17:08 +0900 Subject: [PATCH] in-addr-util: introduce in6_addr_equal() --- src/basic/in-addr-util.c | 9 ++++++++- src/basic/in-addr-util.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/basic/in-addr-util.c b/src/basic/in-addr-util.c index 06632b846d2..f7a7252f1af 100644 --- a/src/basic/in-addr-util.c +++ b/src/basic/in-addr-util.c @@ -128,6 +128,13 @@ bool in4_addr_equal(const struct in_addr *a, const struct in_addr *b) { return a->s_addr == b->s_addr; } +bool in6_addr_equal(const struct in6_addr *a, const struct in6_addr *b) { + assert(a); + assert(b); + + return IN6_ARE_ADDR_EQUAL(a, b); +} + int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b) { assert(a); assert(b); @@ -136,7 +143,7 @@ int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_ return in4_addr_equal(&a->in, &b->in); if (family == AF_INET6) - return IN6_ARE_ADDR_EQUAL(&a->in6, &b->in6); + return in6_addr_equal(&a->in6, &b->in6); return -EAFNOSUPPORT; } diff --git a/src/basic/in-addr-util.h b/src/basic/in-addr-util.h index 7494358d423..519ee53b3a4 100644 --- a/src/basic/in-addr-util.h +++ b/src/basic/in-addr-util.h @@ -54,6 +54,7 @@ bool in4_addr_is_local_multicast(const struct in_addr *a); bool in4_addr_is_non_local(const struct in_addr *a); bool in4_addr_equal(const struct in_addr *a, const struct in_addr *b); +bool in6_addr_equal(const struct in6_addr *a, const struct in6_addr *b); int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b); int in_addr_prefix_intersect(int family, const union in_addr_union *a, unsigned aprefixlen, const union in_addr_union *b, unsigned bprefixlen); int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen);