18 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
19 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
20 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
21 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
22 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
23 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
24 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
25 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
26 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
27 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
28 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
29 true,
true,
false,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
true
35 if (buffer.size() < 1 + 3 + 4)
return;
36 int asmap_size = 3 + (buffer[0] & 127);
37 bool ipv6 = buffer[0] & 128;
39 if (buffer.size() < size_t(1 + asmap_size + addr_size))
return;
41 asmap.reserve(asmap.size() + 8 * asmap_size);
42 for (
int i = 0; i < asmap_size; ++i) {
43 for (
int j = 0; j < 8; ++j) {
44 asmap.push_back((buffer[1 + i] >> j) & 1);
49 const uint8_t* addr_data = buffer.data() + 1 + asmap_size;
57 memcpy(&ipv4, addr_data, addr_size);
void SetIP(const CNetAddr &ip)
void SetLegacyIPv6(Span< const uint8_t > ipv6)
Set from a legacy IPv6 address.
uint32_t GetMappedAS(const CNetAddr &address) const
Get the autonomous system on the BGP path to address.
static constexpr size_t ADDR_IPV4_SIZE
Size of IPv4 address (in bytes).
static constexpr size_t ADDR_IPV6_SIZE
Size of IPv6 address (in bytes).
static const std::vector< bool > IPV4_PREFIX_ASMAP
asmap code that consumes the 96 prefix bits of ::ffff:0/96 (IPv4-in-IPv6 map)
static const std::vector< bool > IPV6_PREFIX_ASMAP
asmap code that consumes nothing
bool SanityCheckASMap(const std::vector< bool > &asmap, int bits)