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

Method GetLinkedIPv4

src/netaddress.cpp:657–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

655}
656
657uint32_t CNetAddr::GetLinkedIPv4() const
658{
659 if (IsIPv4()) {
660 return ReadBE32(m_addr.data());
661 } else if (IsRFC6052() || IsRFC6145()) {
662 // mapped IPv4, SIIT translated IPv4: the IPv4 address is the last 4 bytes of the address
663 return ReadBE32(std::span{m_addr}.last(ADDR_IPV4_SIZE).data());
664 } else if (IsRFC3964()) {
665 // 6to4 tunneled IPv4: the IPv4 address is in bytes 2-6
666 return ReadBE32(std::span{m_addr}.subspan(2, ADDR_IPV4_SIZE).data());
667 } else if (IsRFC4380()) {
668 // Teredo tunneled IPv4: the IPv4 address is in the last 4 bytes of the address, but bitflipped
669 return ~ReadBE32(std::span{m_addr}.last(ADDR_IPV4_SIZE).data());
670 }
671 assert(false);
672}
673
674Network CNetAddr::GetNetClass() const
675{

Callers 2

GetGroupMethod · 0.80
GetMappedASMethod · 0.80

Calls 3

IsIPv4Function · 0.85
ReadBE32Function · 0.85
dataMethod · 0.45

Tested by

no test coverage detected