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

Method GetLinkedIPv4

src/netaddress.cpp:690–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

688}
689
690uint32_t CNetAddr::GetLinkedIPv4() const
691{
692 if (IsIPv4()) {
693 return ReadBE32(m_addr.data());
694 } else if (IsRFC6052() || IsRFC6145()) {
695 // mapped IPv4, SIIT translated IPv4: the IPv4 address is the last 4 bytes of the address
696 return ReadBE32(Span{m_addr}.last(ADDR_IPV4_SIZE).data());
697 } else if (IsRFC3964()) {
698 // 6to4 tunneled IPv4: the IPv4 address is in bytes 2-6
699 return ReadBE32(Span{m_addr}.subspan(2, ADDR_IPV4_SIZE).data());
700 } else if (IsRFC4380()) {
701 // Teredo tunneled IPv4: the IPv4 address is in the last 4 bytes of the address, but bitflipped
702 return ~ReadBE32(Span{m_addr}.last(ADDR_IPV4_SIZE).data());
703 }
704 assert(false);
705}
706
707Network CNetAddr::GetNetClass() const
708{

Callers

nothing calls this directly

Calls 2

ReadBE32Function · 0.50
dataMethod · 0.45

Tested by

no test coverage detected