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

Method IsValid

src/netaddress.cpp:424–451  ·  view source on GitHub ↗

* @returns Whether or not this network address is a valid address that @a could * be used to refer to an actual host. * * @note A valid address may or may not be publicly routable on the global * internet. As in, the set of valid addresses is a superset of the set of * publicly routable addresses. * * @see CNetAddr::IsRoutable() */

Source from the content-addressed store, hash-verified

422 * @see CNetAddr::IsRoutable()
423 */
424bool CNetAddr::IsValid() const
425{
426 // unspecified IPv6 address (::/128)
427 unsigned char ipNone6[16] = {};
428 if (IsIPv6() && memcmp(m_addr.data(), ipNone6, sizeof(ipNone6)) == 0) {
429 return false;
430 }
431
432 if (IsCJDNS() && !HasCJDNSPrefix()) {
433 return false;
434 }
435
436 // documentation IPv6 address
437 if (IsRFC3849())
438 return false;
439
440 if (IsInternal())
441 return false;
442
443 if (IsIPv4()) {
444 const uint32_t addr = ReadBE32(m_addr.data());
445 if (addr == INADDR_ANY || addr == INADDR_NONE) {
446 return false;
447 }
448 }
449
450 return true;
451}
452
453/**
454 * @returns Whether or not this network address is publicly routable on the

Callers 1

MatchMethod · 0.45

Calls 6

IsIPv6Function · 0.85
IsCJDNSFunction · 0.85
HasCJDNSPrefixFunction · 0.85
IsIPv4Function · 0.85
ReadBE32Function · 0.85
dataMethod · 0.45

Tested by

no test coverage detected