Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.cpp
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | CNetAddr::CNetAddr(const struct in6_addr &ipv6Addr, const uint32_t scope) { | ||||
SetRaw(NET_IPV6, (const uint8_t *)&ipv6Addr); | SetRaw(NET_IPV6, (const uint8_t *)&ipv6Addr); | ||||
scopeId = scope; | scopeId = scope; | ||||
} | } | ||||
unsigned int CNetAddr::GetByte(int n) const { | unsigned int CNetAddr::GetByte(int n) const { | ||||
return ip[15 - n]; | 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 { | bool CNetAddr::IsIPv4() const { | ||||
return (memcmp(ip, pchIPv4, sizeof(pchIPv4)) == 0); | return (memcmp(ip, pchIPv4, sizeof(pchIPv4)) == 0); | ||||
} | } | ||||
bool CNetAddr::IsIPv6() const { | bool CNetAddr::IsIPv6() const { | ||||
return !IsIPv4() && !IsTor() && !IsInternal(); | return !IsIPv4() && !IsTor() && !IsInternal(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 650 Lines • Show Last 20 Lines |