summaryrefslogtreecommitdiff
path: root/src/net/ToString.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-08-21 10:43:36 +0200
committerMax Kellermann <max@musicpd.org>2018-08-21 10:48:37 +0200
commitdfc1f6342ada8bf581fda1c97b00ff5e3941f58d (patch)
treea202d809aaa11e83babd39ef37894c1853d1a193 /src/net/ToString.cxx
parent94092f1f9050576aa1326fcae97e3da1d5e6a0ed (diff)
net/SocketAddress: add IsV4Mapped()
Diffstat (limited to 'src/net/ToString.cxx')
-rw-r--r--src/net/ToString.cxx15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/net/ToString.cxx b/src/net/ToString.cxx
index 5dfd8abe9..abfbd88d5 100644
--- a/src/net/ToString.cxx
+++ b/src/net/ToString.cxx
@@ -81,24 +81,13 @@ LocalAddressToString(const struct sockaddr_un &s_un, size_t size) noexcept
#if defined(HAVE_IPV6) && defined(IN6_IS_ADDR_V4MAPPED)
-gcc_pure
-static bool
-IsV4Mapped(SocketAddress address) noexcept
-{
- if (address.GetFamily() != AF_INET6)
- return false;
-
- const auto &a6 = *(const struct sockaddr_in6 *)address.GetAddress();
- return IN6_IS_ADDR_V4MAPPED(&a6.sin6_addr);
-}
-
/**
* Convert "::ffff:127.0.0.1" to "127.0.0.1".
*/
static SocketAddress
UnmapV4(SocketAddress src, struct sockaddr_in &buffer) noexcept
{
- assert(IsV4Mapped(src));
+ assert(src.IsV4Mapped());
const auto &src6 = *(const struct sockaddr_in6 *)src.GetAddress();
memset(&buffer, 0, sizeof(buffer));
@@ -124,7 +113,7 @@ ToString(SocketAddress address) noexcept
#if defined(HAVE_IPV6) && defined(IN6_IS_ADDR_V4MAPPED)
struct sockaddr_in in_buffer;
- if (IsV4Mapped(address))
+ if (address.IsV4Mapped())
address = UnmapV4(address, in_buffer);
#endif