Commit 94092f1f authored by Max Kellermann's avatar Max Kellermann

net/SocketAddress: reimplement IsV6Any() using IPv6Address::IsAny()

parent a84b83f2
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "config.h" #include "config.h"
#include "SocketAddress.hxx" #include "SocketAddress.hxx"
#include "IPv6Address.hxx"
#include "util/StringView.hxx" #include "util/StringView.hxx"
#include <string.h> #include <string.h>
...@@ -78,9 +79,7 @@ SocketAddress::GetLocalRaw() const noexcept ...@@ -78,9 +79,7 @@ SocketAddress::GetLocalRaw() const noexcept
bool bool
SocketAddress::IsV6Any() const noexcept SocketAddress::IsV6Any() const noexcept
{ {
return GetFamily() == AF_INET6 && return GetFamily() == AF_INET6 && IPv6Address(*this).IsAny();
memcmp(&((const struct sockaddr_in6 *)(const void *)GetAddress())->sin6_addr,
&in6addr_any, sizeof(in6addr_any)) == 0;
} }
unsigned unsigned
...@@ -94,7 +93,7 @@ SocketAddress::GetPort() const noexcept ...@@ -94,7 +93,7 @@ SocketAddress::GetPort() const noexcept
return ntohs(((const struct sockaddr_in *)(const void *)address)->sin_port); return ntohs(((const struct sockaddr_in *)(const void *)address)->sin_port);
case AF_INET6: case AF_INET6:
return ntohs(((const struct sockaddr_in6 *)(const void *)address)->sin6_port); return IPv6Address(*this).GetPort();
default: default:
return 0; return 0;
......
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