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

Method IsValid

src/netbase.cpp:667–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

665bool CNetAddr::IsMulticast() const { return (IsIPv4() && (GetByte(3) & 0xF0) == 0xE0) || (GetByte(15) == 0xFF); }
666
667bool CNetAddr::IsValid() const {
668 // Cleanup 3-byte shifted addresses caused by garbage in size field
669 // of addr messages from versions before 0.2.9 checksum.
670 // Two consecutive addr messages look like this:
671 // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26...
672 // so if the first length field is garbled, it reads the second batch
673 // of addr misaligned by 3 bytes.
674 if (memcmp(ip, pchIPv4 + 3, sizeof(pchIPv4) - 3) == 0)
675 return false;
676
677 // unspecified IPv6 address (::/128)
678 uint8_t ipNone[16] = {};
679 if (memcmp(ip, ipNone, 16) == 0)
680 return false;
681
682 // documentation IPv6 address
683 if (IsRFC3849())
684 return false;
685
686 if (IsIPv4()) {
687 // INADDR_NONE
688 uint32_t ipNone = INADDR_NONE;
689 if (memcmp(ip + 12, &ipNone, 4) == 0)
690 return false;
691
692 // 0
693 ipNone = 0;
694 if (memcmp(ip + 12, &ipNone, 4) == 0)
695 return false;
696 }
697
698 return true;
699}
700
701bool CNetAddr::IsRoutable() const {
702 return IsValid() &&

Callers 10

SetProxyFunction · 0.45
SetNameProxyFunction · 0.45
ConnectSocketByNameFunction · 0.45
LookupSubNetFunction · 0.45
CSubNetMethod · 0.45
MatchMethod · 0.45
AppInitFunction · 0.45
GetMyPublicIPFunction · 0.45
PostNodeInfoFunction · 0.45
ThreadOpenConnectionsFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected