19 std::vector<unsigned char> vchRet;
25 for (
int i = 0; i < 4; i++) {
26 vchRet.push_back((asn >> (8 * i)) & 0xFF);
47 vchRet.push_back((ipv4 >> 24) & 0xFF);
48 vchRet.push_back((ipv4 >> 16) & 0xFF);
50 }
else if (address.
IsTor() || address.
IsI2P()) {
68 const size_t num_bytes = nBits / 8;
69 vchRet.insert(vchRet.end(), addr_bytes.begin() + nStartByte, addr_bytes.begin() + nStartByte + num_bytes);
73 assert(num_bytes < addr_bytes.size());
74 vchRet.push_back(addr_bytes[num_bytes + nStartByte] | ((1 << (8 - nBits)) - 1));
86 std::vector<bool> ip_bits(128);
89 for (int8_t byte_i = 0; byte_i < 12; ++byte_i) {
90 for (uint8_t bit_i = 0; bit_i < 8; ++bit_i) {
95 for (
int i = 0; i < 32; ++i) {
96 ip_bits[96 + i] = (ipv4 >> (31 - i)) & 1;
102 for (int8_t byte_i = 0; byte_i < 16; ++byte_i) {
103 uint8_t cur_byte = addr_bytes[byte_i];
104 for (uint8_t bit_i = 0; bit_i < 8; ++bit_i) {
105 ip_bits[byte_i * 8 + bit_i] = (cur_byte >> (7 - bit_i)) & 1;
Network GetNetClass() const
std::vector< unsigned char > GetAddrBytes() const
bool HasLinkedIPv4() const
Whether this address has a linked IPv4 address (see GetLinkedIPv4()).
uint32_t GetLinkedIPv4() const
For IPv4, mapped IPv4, SIIT translated IPv4, Teredo, 6to4 tunneled addresses, return the relevant IPv...
A writer stream (for serialization) that computes a 256-bit hash.
uint256 GetAsmapChecksum() const
Get a checksum identifying the asmap being used.
const std::vector< bool > m_asmap
Compressed IP->ASN mapping, loaded from a file when a node starts.
std::vector< unsigned char > GetGroup(const CNetAddr &address) const
Get the canonical identifier of the network group for address.
uint32_t GetMappedAS(const CNetAddr &address) const
Get the autonomous system on the BGP path to address.
static constexpr size_t ADDR_INTERNAL_SIZE
Size of "internal" (NET_INTERNAL) address (in bytes).
static const std::array< uint8_t, 6 > INTERNAL_IN_IPV6_PREFIX
Prefix of an IPv6 address when it contains an embedded "internal" address.
static const std::array< uint8_t, 12 > IPV4_IN_IPV6_PREFIX
Prefix of an IPv6 address when it contains an embedded IPv4 address.
uint32_t Interpret(const std::vector< bool > &asmap, const std::vector< bool > &ip)