Bitcoin ABC  0.28.12
P2P Digital Currency
Classes | Enumerations | Variables
netaddress.h File Reference
#include <compat.h>
#include <crypto/siphash.h>
#include <prevector.h>
#include <random.h>
#include <serialize.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <tinyformat.h>
#include <array>
#include <cstdint>
#include <ios>
#include <string>
#include <vector>
Include dependency graph for netaddress.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CNetAddr
 Network address. More...
 
class  CSubNet
 
class  CService
 A combination of a network address (CNetAddr) and a (TCP) port. More...
 
class  CServiceHash
 

Enumerations

enum  Network {
  NET_UNROUTABLE = 0 , NET_IPV4 , NET_IPV6 , NET_ONION ,
  NET_I2P , NET_CJDNS , NET_INTERNAL , NET_MAX
}
 A network type. More...
 

Variables

static constexpr int ADDRV2_FORMAT = 0x20000000
 A flag that is ORed into the protocol version to designate that addresses should be serialized in (unserialized from) v2 format (BIP155). More...
 
static const std::array< uint8_t, 12 > IPV4_IN_IPV6_PREFIX
 Prefix of an IPv6 address when it contains an embedded IPv4 address. More...
 
static const std::array< uint8_t, 6 > TORV2_IN_IPV6_PREFIX
 Prefix of an IPv6 address when it contains an embedded TORv2 address. More...
 
static const std::array< uint8_t, 6 > INTERNAL_IN_IPV6_PREFIX
 Prefix of an IPv6 address when it contains an embedded "internal" address. More...
 
static constexpr size_t ADDR_IPV4_SIZE = 4
 Size of IPv4 address (in bytes). More...
 
static constexpr size_t ADDR_IPV6_SIZE = 16
 Size of IPv6 address (in bytes). More...
 
static constexpr size_t ADDR_TORV2_SIZE = 10
 Size of TORv2 address (in bytes). More...
 
static constexpr size_t ADDR_TORV3_SIZE = 32
 Size of TORv3 address (in bytes). More...
 
static constexpr size_t ADDR_I2P_SIZE = 32
 Size of I2P address (in bytes). More...
 
static constexpr size_t ADDR_CJDNS_SIZE = 16
 Size of CJDNS address (in bytes). More...
 
static constexpr size_t ADDR_INTERNAL_SIZE = 10
 Size of "internal" (NET_INTERNAL) address (in bytes). More...
 
static constexpr uint16_t I2P_SAM31_PORT {0}
 SAM 3.1 and earlier do not support specifying ports and force the port to 0. More...
 

Enumeration Type Documentation

◆ Network

enum Network

A network type.

Note
An address may belong to more than one network, for example 10.0.0.1 belongs to both NET_UNROUTABLE and NET_IPV4. Keep these sequential starting from 0 and NET_MAX as the last entry. We have loops like for (int i = 0; i < NET_MAX; ++i) that expect to iterate over all enum values and also GetExtNetwork() "extends" this enum by introducing standalone constants starting from NET_MAX.
Enumerator
NET_UNROUTABLE 

Addresses from these networks are not publicly routable on the global Internet.

NET_IPV4 

IPv4.

NET_IPV6 

IPv6.

NET_ONION 

TOR (v2 or v3)

NET_I2P 

I2P.

NET_CJDNS 

CJDNS.

NET_INTERNAL 

A set of addresses that represent the hash of a string or FQDN.

We use them in AddrMan to keep track of which DNS seeds were used.

NET_MAX 

Dummy value to indicate the number of NET_* constants.

Definition at line 44 of file netaddress.h.

Variable Documentation

◆ ADDR_CJDNS_SIZE

constexpr size_t ADDR_CJDNS_SIZE = 16
staticconstexpr

Size of CJDNS address (in bytes).

Definition at line 110 of file netaddress.h.

◆ ADDR_I2P_SIZE

constexpr size_t ADDR_I2P_SIZE = 32
staticconstexpr

Size of I2P address (in bytes).

Definition at line 107 of file netaddress.h.

◆ ADDR_INTERNAL_SIZE

constexpr size_t ADDR_INTERNAL_SIZE = 10
staticconstexpr

Size of "internal" (NET_INTERNAL) address (in bytes).

Definition at line 113 of file netaddress.h.

◆ ADDR_IPV4_SIZE

constexpr size_t ADDR_IPV4_SIZE = 4
staticconstexpr

Size of IPv4 address (in bytes).

Definition at line 94 of file netaddress.h.

◆ ADDR_IPV6_SIZE

constexpr size_t ADDR_IPV6_SIZE = 16
staticconstexpr

Size of IPv6 address (in bytes).

Definition at line 97 of file netaddress.h.

◆ ADDR_TORV2_SIZE

constexpr size_t ADDR_TORV2_SIZE = 10
staticconstexpr

Size of TORv2 address (in bytes).

Definition at line 100 of file netaddress.h.

◆ ADDR_TORV3_SIZE

constexpr size_t ADDR_TORV3_SIZE = 32
staticconstexpr

Size of TORv3 address (in bytes).

This is the length of just the address as used in BIP155, without the checksum and the version byte.

Definition at line 104 of file netaddress.h.

◆ ADDRV2_FORMAT

constexpr int ADDRV2_FORMAT = 0x20000000
staticconstexpr

A flag that is ORed into the protocol version to designate that addresses should be serialized in (unserialized from) v2 format (BIP155).

Make sure that this does not collide with any of the values in version.h.

Definition at line 33 of file netaddress.h.

◆ I2P_SAM31_PORT

constexpr uint16_t I2P_SAM31_PORT {0}
staticconstexpr

SAM 3.1 and earlier do not support specifying ports and force the port to 0.

Definition at line 116 of file netaddress.h.

◆ INTERNAL_IN_IPV6_PREFIX

const std::array<uint8_t, 6> INTERNAL_IN_IPV6_PREFIX
static
Initial value:
{
{0xFD, 0x6B, 0x88, 0xC0, 0x87, 0x24}}

Prefix of an IPv6 address when it contains an embedded "internal" address.

Used when (un)serializing addresses in ADDRv1 format (pre-BIP155). The prefix comes from 0xFD + SHA256("bitcoin")[0:5]. Such dummy IPv6 addresses are guaranteed to not be publicly routable as they fall under RFC4193's fc00::/7 subnet allocated to unique-local addresses.

Definition at line 89 of file netaddress.h.

◆ IPV4_IN_IPV6_PREFIX

const std::array<uint8_t, 12> IPV4_IN_IPV6_PREFIX
static
Initial value:
{
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF}}

Prefix of an IPv6 address when it contains an embedded IPv4 address.

Used when (un)serializing addresses in ADDRv1 format (pre-BIP155).

Definition at line 74 of file netaddress.h.

◆ TORV2_IN_IPV6_PREFIX

const std::array<uint8_t, 6> TORV2_IN_IPV6_PREFIX
static
Initial value:
{
{0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43}}

Prefix of an IPv6 address when it contains an embedded TORv2 address.

Used when (un)serializing addresses in ADDRv1 format (pre-BIP155). Such dummy IPv6 addresses are guaranteed to not be publicly routable as they fall under RFC4193's fc00::/7 subnet allocated to unique-local addresses.

Definition at line 81 of file netaddress.h.