Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.cpp
Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | bool CNetAddr::IsRFC6145() const { | ||||
return (memcmp(ip, pchRFC6145, sizeof(pchRFC6145)) == 0); | return (memcmp(ip, pchRFC6145, sizeof(pchRFC6145)) == 0); | ||||
} | } | ||||
bool CNetAddr::IsRFC4843() const { | bool CNetAddr::IsRFC4843() const { | ||||
return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && | return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && | ||||
(GetByte(12) & 0xF0) == 0x10); | (GetByte(12) & 0xF0) == 0x10); | ||||
} | } | ||||
bool CNetAddr::IsRFC7343() const { | |||||
return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && | |||||
(GetByte(12) & 0xF0) == 0x20); | |||||
} | |||||
bool CNetAddr::IsTor() const { | bool CNetAddr::IsTor() const { | ||||
return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0); | return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0); | ||||
} | } | ||||
bool CNetAddr::IsLocal() const { | bool CNetAddr::IsLocal() const { | ||||
// IPv4 loopback | // IPv4 loopback | ||||
if (IsIPv4() && (GetByte(3) == 127 || GetByte(3) == 0)) { | if (IsIPv4() && (GetByte(3) == 127 || GetByte(3) == 0)) { | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | bool CNetAddr::IsValid() const { | ||||
return true; | return true; | ||||
} | } | ||||
bool CNetAddr::IsRoutable() const { | bool CNetAddr::IsRoutable() const { | ||||
return IsValid() && | return IsValid() && | ||||
!(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || | !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || | ||||
IsRFC6598() || IsRFC5737() || (IsRFC4193() && !IsTor()) || | IsRFC6598() || IsRFC5737() || (IsRFC4193() && !IsTor()) || | ||||
IsRFC4843() || IsLocal() || IsInternal()); | IsRFC4843() || IsRFC7343() || IsLocal() || IsInternal()); | ||||
} | } | ||||
bool CNetAddr::IsInternal() const { | bool CNetAddr::IsInternal() const { | ||||
return memcmp(ip, g_internal_prefix, sizeof(g_internal_prefix)) == 0; | return memcmp(ip, g_internal_prefix, sizeof(g_internal_prefix)) == 0; | ||||
} | } | ||||
enum Network CNetAddr::GetNetwork() const { | enum Network CNetAddr::GetNetwork() const { | ||||
if (IsInternal()) { | if (IsInternal()) { | ||||
▲ Show 20 Lines • Show All 507 Lines • Show Last 20 Lines |