From d6a1287481428d982dc03be3a6d9aeef8398f468 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 20 Oct 2018 14:48:29 +0000 Subject: CNetAddr: Add IsBindAny method to check for INADDR_ANY --- src/netaddress.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/netaddress.cpp') diff --git a/src/netaddress.cpp b/src/netaddress.cpp index e1af4eff62..72be77dfd9 100644 --- a/src/netaddress.cpp +++ b/src/netaddress.cpp @@ -83,6 +83,16 @@ unsigned int CNetAddr::GetByte(int n) const return ip[15-n]; } +bool CNetAddr::IsBindAny() const +{ + const int cmplen = IsIPv4() ? 4 : 16; + for (int i = 0; i < cmplen; ++i) { + if (GetByte(i)) return false; + } + + return true; +} + bool CNetAddr::IsIPv4() const { return (memcmp(ip, pchIPv4, sizeof(pchIPv4)) == 0); -- cgit v1.2.3