MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / IsValid

Method IsValid

src/netbase.cpp:811–845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

809}
810
811bool CNetAddr::IsValid() const
812{
813 // Cleanup 3-byte shifted addresses caused by garbage in size field
814 // of addr messages from versions before 0.2.9 checksum.
815 // Two consecutive addr messages look like this:
816 // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26...
817 // so if the first length field is garbled, it reads the second batch
818 // of addr misaligned by 3 bytes.
819 if (memcmp(ip, pchIPv4+3, sizeof(pchIPv4)-3) == 0)
820 return false;
821
822 // unspecified IPv6 address (::/128)
823 unsigned char ipNone[16] = {};
824 if (memcmp(ip, ipNone, 16) == 0)
825 return false;
826
827 // documentation IPv6 address
828 if (IsRFC3849())
829 return false;
830
831 if (IsIPv4())
832 {
833 // INADDR_NONE
834 uint32_t ipNone = INADDR_NONE;
835 if (memcmp(ip+12, &ipNone, 4) == 0)
836 return false;
837
838 // 0
839 ipNone = 0;
840 if (memcmp(ip+12, &ipNone, 4) == 0)
841 return false;
842 }
843
844 return true;
845}
846
847bool CNetAddr::IsRoutable() const
848{

Callers 7

SetProxyFunction · 0.45
GetProxyFunction · 0.45
SetNameProxyFunction · 0.45
GetNameProxyFunction · 0.45
HaveNameProxyFunction · 0.45
ConnectSocketByNameFunction · 0.45
MatchMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected