MCPcopy Create free account
hub / github.com/ElementsProject/elements / IsValid

Method IsValid

src/netaddress.cpp:451–479  ·  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

449 * @see CNetAddr::IsRoutable()
450 */
451bool CNetAddr::IsValid() const
452{
453 // unspecified IPv6 address (::/128)
454 unsigned char ipNone6[16] = {};
455 if (IsIPv6() && memcmp(m_addr.data(), ipNone6, sizeof(ipNone6)) == 0) {
456 return false;
457 }
458
459 // CJDNS addresses always start with 0xfc
460 if (IsCJDNS() && (m_addr[0] != 0xFC)) {
461 return false;
462 }
463
464 // documentation IPv6 address
465 if (IsRFC3849())
466 return false;
467
468 if (IsInternal())
469 return false;
470
471 if (IsIPv4()) {
472 const uint32_t addr = ReadBE32(m_addr.data());
473 if (addr == INADDR_ANY || addr == INADDR_NONE) {
474 return false;
475 }
476 }
477
478 return true;
479}
480
481/**
482 * @returns Whether or not this network address is publicly routable on the

Callers 1

MatchMethod · 0.45

Calls 2

ReadBE32Function · 0.50
dataMethod · 0.45

Tested by

no test coverage detected