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

Method SetLegacyIPv6

src/netaddress.cpp:138–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138void CNetAddr::SetLegacyIPv6(Span<const uint8_t> ipv6)
139{
140 assert(ipv6.size() == ADDR_IPV6_SIZE);
141
142 size_t skip{0};
143
144 if (HasPrefix(ipv6, IPV4_IN_IPV6_PREFIX)) {
145 // IPv4-in-IPv6
146 m_net = NET_IPV4;
147 skip = sizeof(IPV4_IN_IPV6_PREFIX);
148 } else if (HasPrefix(ipv6, TORV2_IN_IPV6_PREFIX)) {
149 // TORv2-in-IPv6 (unsupported). Unserialize as !IsValid(), thus ignoring them.
150 // Mimic a default-constructed CNetAddr object which is !IsValid() and thus
151 // will not be gossiped, but continue reading next addresses from the stream.
152 m_net = NET_IPV6;
153 m_addr.assign(ADDR_IPV6_SIZE, 0x0);
154 return;
155 } else if (HasPrefix(ipv6, INTERNAL_IN_IPV6_PREFIX)) {
156 // Internal-in-IPv6
157 m_net = NET_INTERNAL;
158 skip = sizeof(INTERNAL_IN_IPV6_PREFIX);
159 } else {
160 // IPv6
161 m_net = NET_IPV6;
162 }
163
164 m_addr.assign(ipv6.begin() + skip, ipv6.end());
165}
166
167/**
168 * Create an "internal" address that represents a name or FQDN. AddrMan uses

Callers 1

FUZZ_TARGETFunction · 0.80

Calls 5

HasPrefixFunction · 0.85
sizeMethod · 0.45
assignMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

FUZZ_TARGETFunction · 0.64