Commit 3bcabad2 authored by Max Kellermann's avatar Max Kellermann

net/SocketAddress: add method IsV6Any()

parent c629ac71
...@@ -48,6 +48,14 @@ SocketAddress::operator==(SocketAddress other) const noexcept ...@@ -48,6 +48,14 @@ SocketAddress::operator==(SocketAddress other) const noexcept
#ifdef HAVE_TCP #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 unsigned
SocketAddress::GetPort() const noexcept SocketAddress::GetPort() const noexcept
{ {
......
...@@ -96,6 +96,12 @@ public: ...@@ -96,6 +96,12 @@ public:
#ifdef HAVE_TCP #ifdef HAVE_TCP
/** /**
* Is this the IPv6 wildcard address (in6addr_any)?
*/
gcc_pure
bool IsV6Any() const noexcept;
/**
* Extract the port number. Returns 0 if not applicable. * Extract the port number. Returns 0 if not applicable.
*/ */
gcc_pure gcc_pure
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment