summaryrefslogtreecommitdiff
path: root/source/Host/common/SocketAddress.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-07-19 07:03:07 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-07-19 07:03:07 +0000
commita884e649599e13d58ce6d2b2a0ce8091ceb48dac (patch)
treef527514e113dd4f771eef3d39e5a5d2da36b8552 /source/Host/common/SocketAddress.cpp
parente75e363cb71a7339552b9d943e78ac62b737379b (diff)
Notes
Diffstat (limited to 'source/Host/common/SocketAddress.cpp')
-rw-r--r--source/Host/common/SocketAddress.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/Host/common/SocketAddress.cpp b/source/Host/common/SocketAddress.cpp
index 41150fa7fd74a..def3e0359f016 100644
--- a/source/Host/common/SocketAddress.cpp
+++ b/source/Host/common/SocketAddress.cpp
@@ -317,6 +317,13 @@ bool SocketAddress::IsAnyAddr() const {
: 0 == memcmp(&m_socket_addr.sa_ipv6.sin6_addr, &in6addr_any, 16);
}
+bool SocketAddress::IsLocalhost() const {
+ return (GetFamily() == AF_INET)
+ ? m_socket_addr.sa_ipv4.sin_addr.s_addr == htonl(INADDR_LOOPBACK)
+ : 0 == memcmp(&m_socket_addr.sa_ipv6.sin6_addr, &in6addr_loopback,
+ 16);
+}
+
bool SocketAddress::operator==(const SocketAddress &rhs) const {
if (GetFamily() != rhs.GetFamily())
return false;