From: Yu Watanabe Date: Tue, 18 May 2021 03:56:23 +0000 (+0900) Subject: in-addr-util: introduce in6_addr_is_ipv4_mapped_address() X-Git-Tag: v249-rc1~76^2~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c3e960883fe9de98c8a0d6a876d222a7156c33bb;p=thirdparty%2Fsystemd.git in-addr-util: introduce in6_addr_is_ipv4_mapped_address() --- diff --git a/src/basic/in-addr-util.c b/src/basic/in-addr-util.c index 9d7e51f8fd7..9cc92a1c767 100644 --- a/src/basic/in-addr-util.c +++ b/src/basic/in-addr-util.c @@ -121,6 +121,12 @@ int in_addr_is_localhost(int family, const union in_addr_union *u) { return -EAFNOSUPPORT; } +bool in6_addr_is_ipv4_mapped_address(const struct in6_addr *a) { + return a->s6_addr32[0] == 0 && + a->s6_addr32[1] == 0 && + a->s6_addr32[2] == htobe32(UINT32_C(0x0000ffff)); +} + bool in4_addr_equal(const struct in_addr *a, const struct in_addr *b) { assert(a); assert(b); diff --git a/src/basic/in-addr-util.h b/src/basic/in-addr-util.h index 906b3fe97e5..f3ead919623 100644 --- a/src/basic/in-addr-util.h +++ b/src/basic/in-addr-util.h @@ -58,6 +58,7 @@ int in_addr_is_localhost(int family, const union in_addr_union *u); bool in4_addr_is_local_multicast(const struct in_addr *a); bool in4_addr_is_non_local(const struct in_addr *a); +bool in6_addr_is_ipv4_mapped_address(const struct in6_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);