aboutsummaryrefslogtreecommitdiff
path: root/src/netaddress.cpp
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2018-10-20 14:48:29 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2018-11-22 01:44:59 +0000
commitd6a1287481428d982dc03be3a6d9aeef8398f468 (patch)
treec9523b290b7c1714a4cc6d0e829cf9033ccf2c19 /src/netaddress.cpp
parent3615003952ffbc814bdb53d9d0e45790f152bd2f (diff)
CNetAddr: Add IsBindAny method to check for INADDR_ANY
Diffstat (limited to 'src/netaddress.cpp')
-rw-r--r--src/netaddress.cpp10
1 files changed, 10 insertions, 0 deletions
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);