| 688 | } |
| 689 | |
| 690 | uint32_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 | |
| 707 | Network CNetAddr::GetNetClass() const |
| 708 | { |