mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
CNetAddr: Add IsBindAny method to check for INADDR_ANY
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user