| 655 | } |
| 656 | |
| 657 | uint32_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 | |
| 674 | Network CNetAddr::GetNetClass() const |
| 675 | { |
no test coverage detected