summaryrefslogtreecommitdiff
path: root/src/net/SocketAddress.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-05-17 12:22:59 +0200
committerMax Kellermann <max@musicpd.org>2017-05-17 12:22:59 +0200
commit3bcabad28c3ffbad9720c67f81e410f98c4d5377 (patch)
tree0d910b8fb44599066d71cf9cd80ac4aa54e01864 /src/net/SocketAddress.cxx
parentc629ac71681c507821660c588ab80affd0ff6525 (diff)
net/SocketAddress: add method IsV6Any()
Diffstat (limited to 'src/net/SocketAddress.cxx')
-rw-r--r--src/net/SocketAddress.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/net/SocketAddress.cxx b/src/net/SocketAddress.cxx
index bb86d0a04..615eb6303 100644
--- a/src/net/SocketAddress.cxx
+++ b/src/net/SocketAddress.cxx
@@ -48,6 +48,14 @@ SocketAddress::operator==(SocketAddress other) const noexcept
#ifdef HAVE_TCP
+bool
+SocketAddress::IsV6Any() const noexcept
+{
+ return GetFamily() == AF_INET6 &&
+ memcmp(&((const struct sockaddr_in6 *)(const void *)GetAddress())->sin6_addr,
+ &in6addr_any, sizeof(in6addr_any)) == 0;
+}
+
unsigned
SocketAddress::GetPort() const noexcept
{