Bitcoin Core  0.20.99
P2P Digital Currency
netaddress.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_NETADDRESS_H
6 #define BITCOIN_NETADDRESS_H
7 
8 #if defined(HAVE_CONFIG_H)
10 #endif
11 
12 #include <attributes.h>
13 #include <compat.h>
14 #include <prevector.h>
15 #include <serialize.h>
16 #include <tinyformat.h>
17 #include <util/strencodings.h>
18 #include <util/string.h>
19 
20 #include <array>
21 #include <cstdint>
22 #include <ios>
23 #include <string>
24 #include <vector>
25 
32 static const int ADDRV2_FORMAT = 0x20000000;
33 
43 enum Network
44 {
47 
50 
53 
56 
59 
62 
66 
69 };
70 
73 static const std::array<uint8_t, 12> IPV4_IN_IPV6_PREFIX{
74  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF
75 };
76 
81 static const std::array<uint8_t, 6> TORV2_IN_IPV6_PREFIX{
82  0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43
83 };
84 
90 static const std::array<uint8_t, 6> INTERNAL_IN_IPV6_PREFIX{
91  0xFD, 0x6B, 0x88, 0xC0, 0x87, 0x24 // 0xFD + sha256("bitcoin")[0:5].
92 };
93 
95 static constexpr size_t ADDR_IPV4_SIZE = 4;
96 
98 static constexpr size_t ADDR_IPV6_SIZE = 16;
99 
101 static constexpr size_t ADDR_TORV2_SIZE = 10;
102 
105 static constexpr size_t ADDR_TORV3_SIZE = 32;
106 
108 static constexpr size_t ADDR_I2P_SIZE = 32;
109 
111 static constexpr size_t ADDR_CJDNS_SIZE = 16;
112 
114 static constexpr size_t ADDR_INTERNAL_SIZE = 10;
115 
119 class CNetAddr
120 {
121  protected:
127 
132 
137  uint32_t m_scope_id{0};
138 
139  public:
140  CNetAddr();
141  explicit CNetAddr(const struct in_addr& ipv4Addr);
142  void SetIP(const CNetAddr& ip);
143 
151 
152  bool SetInternal(const std::string& name);
153 
154  bool SetSpecial(const std::string &strName); // for Tor addresses
155  bool IsBindAny() const; // INADDR_ANY equivalent
156  bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
157  bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor)
158  bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12)
159  bool IsRFC2544() const; // IPv4 inter-network communications (198.18.0.0/15)
160  bool IsRFC6598() const; // IPv4 ISP-level NAT (100.64.0.0/10)
161  bool IsRFC5737() const; // IPv4 documentation addresses (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24)
162  bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32)
163  bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16)
164  bool IsRFC3964() const; // IPv6 6to4 tunnelling (2002::/16)
165  bool IsRFC4193() const; // IPv6 unique local (FC00::/7)
166  bool IsRFC4380() const; // IPv6 Teredo tunnelling (2001::/32)
167  bool IsRFC4843() const; // IPv6 ORCHID (deprecated) (2001:10::/28)
168  bool IsRFC7343() const; // IPv6 ORCHIDv2 (2001:20::/28)
169  bool IsRFC4862() const; // IPv6 autoconfig (FE80::/64)
170  bool IsRFC6052() const; // IPv6 well-known prefix for IPv4-embedded address (64:FF9B::/96)
171  bool IsRFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96) (actually defined in RFC2765)
172  bool IsHeNet() const; // IPv6 Hurricane Electric - https://he.net (2001:0470::/36)
173  bool IsTor() const;
174  bool IsI2P() const;
175  bool IsCJDNS() const;
176  bool IsLocal() const;
177  bool IsRoutable() const;
178  bool IsInternal() const;
179  bool IsValid() const;
180 
184  bool IsAddrV1Compatible() const;
185 
186  enum Network GetNetwork() const;
187  std::string ToString() const;
188  std::string ToStringIP() const;
189  uint64_t GetHash() const;
190  bool GetInAddr(struct in_addr* pipv4Addr) const;
191  Network GetNetClass() const;
192 
194  uint32_t GetLinkedIPv4() const;
196  bool HasLinkedIPv4() const;
197 
198  // The AS on the BGP path to the node we use to diversify
199  // peers in AddrMan bucketing based on the AS infrastructure.
200  // The ip->AS mapping depends on how asmap is constructed.
201  uint32_t GetMappedAS(const std::vector<bool> &asmap) const;
202 
203  std::vector<unsigned char> GetGroup(const std::vector<bool> &asmap) const;
204  std::vector<unsigned char> GetAddrBytes() const;
205  int GetReachabilityFrom(const CNetAddr *paddrPartner = nullptr) const;
206 
207  explicit CNetAddr(const struct in6_addr& pipv6Addr, const uint32_t scope = 0);
208  bool GetIn6Addr(struct in6_addr* pipv6Addr) const;
209 
210  friend bool operator==(const CNetAddr& a, const CNetAddr& b);
211  friend bool operator!=(const CNetAddr& a, const CNetAddr& b) { return !(a == b); }
212  friend bool operator<(const CNetAddr& a, const CNetAddr& b);
213 
217  bool IsRelayable() const
218  {
219  return IsIPv4() || IsIPv6() || IsTor();
220  }
221 
225  template <typename Stream>
226  void Serialize(Stream& s) const
227  {
228  if (s.GetVersion() & ADDRV2_FORMAT) {
230  } else {
232  }
233  }
234 
238  template <typename Stream>
239  void Unserialize(Stream& s)
240  {
241  if (s.GetVersion() & ADDRV2_FORMAT) {
243  } else {
245  }
246  }
247 
248  friend class CSubNet;
249 
250  private:
254  enum BIP155Network : uint8_t {
255  IPV4 = 1,
256  IPV6 = 2,
257  TORV2 = 3,
258  TORV3 = 4,
259  I2P = 5,
260  CJDNS = 6,
261  };
262 
266  static constexpr size_t V1_SERIALIZATION_SIZE = ADDR_IPV6_SIZE;
267 
273  static constexpr size_t MAX_ADDRV2_SIZE = 512;
274 
281 
289  bool SetNetFromBIP155Network(uint8_t possible_bip155_net, size_t address_size);
290 
294  void SerializeV1Array(uint8_t (&arr)[V1_SERIALIZATION_SIZE]) const
295  {
296  size_t prefix_size;
297 
298  switch (m_net) {
299  case NET_IPV6:
300  assert(m_addr.size() == sizeof(arr));
301  memcpy(arr, m_addr.data(), m_addr.size());
302  return;
303  case NET_IPV4:
304  prefix_size = sizeof(IPV4_IN_IPV6_PREFIX);
305  assert(prefix_size + m_addr.size() == sizeof(arr));
306  memcpy(arr, IPV4_IN_IPV6_PREFIX.data(), prefix_size);
307  memcpy(arr + prefix_size, m_addr.data(), m_addr.size());
308  return;
309  case NET_ONION:
310  if (m_addr.size() == ADDR_TORV3_SIZE) {
311  break;
312  }
313  prefix_size = sizeof(TORV2_IN_IPV6_PREFIX);
314  assert(prefix_size + m_addr.size() == sizeof(arr));
315  memcpy(arr, TORV2_IN_IPV6_PREFIX.data(), prefix_size);
316  memcpy(arr + prefix_size, m_addr.data(), m_addr.size());
317  return;
318  case NET_INTERNAL:
319  prefix_size = sizeof(INTERNAL_IN_IPV6_PREFIX);
320  assert(prefix_size + m_addr.size() == sizeof(arr));
321  memcpy(arr, INTERNAL_IN_IPV6_PREFIX.data(), prefix_size);
322  memcpy(arr + prefix_size, m_addr.data(), m_addr.size());
323  return;
324  case NET_I2P:
325  break;
326  case NET_CJDNS:
327  break;
328  case NET_UNROUTABLE:
329  case NET_MAX:
330  assert(false);
331  } // no default case, so the compiler can warn about missing cases
332 
333  // Serialize TORv3, I2P and CJDNS as all-zeros.
334  memset(arr, 0x0, V1_SERIALIZATION_SIZE);
335  }
336 
340  template <typename Stream>
341  void SerializeV1Stream(Stream& s) const
342  {
343  uint8_t serialized[V1_SERIALIZATION_SIZE];
344 
345  SerializeV1Array(serialized);
346 
347  s << serialized;
348  }
349 
353  template <typename Stream>
354  void SerializeV2Stream(Stream& s) const
355  {
356  if (IsInternal()) {
357  // Serialize NET_INTERNAL as embedded in IPv6. We need to
358  // serialize such addresses from addrman.
359  s << static_cast<uint8_t>(BIP155Network::IPV6);
362  return;
363  }
364 
365  s << static_cast<uint8_t>(GetBIP155Network());
366  s << m_addr;
367  }
368 
372  void UnserializeV1Array(uint8_t (&arr)[V1_SERIALIZATION_SIZE])
373  {
374  // Use SetLegacyIPv6() so that m_net is set correctly. For example
375  // ::FFFF:0102:0304 should be set as m_net=NET_IPV4 (1.2.3.4).
376  SetLegacyIPv6(arr);
377  }
378 
382  template <typename Stream>
383  void UnserializeV1Stream(Stream& s)
384  {
385  uint8_t serialized[V1_SERIALIZATION_SIZE];
386 
387  s >> serialized;
388 
389  UnserializeV1Array(serialized);
390  }
391 
395  template <typename Stream>
396  void UnserializeV2Stream(Stream& s)
397  {
398  uint8_t bip155_net;
399  s >> bip155_net;
400 
401  size_t address_size;
402  s >> COMPACTSIZE(address_size);
403 
404  if (address_size > MAX_ADDRV2_SIZE) {
405  throw std::ios_base::failure(strprintf(
406  "Address too long: %u > %u", address_size, MAX_ADDRV2_SIZE));
407  }
408 
409  m_scope_id = 0;
410 
411  if (SetNetFromBIP155Network(bip155_net, address_size)) {
412  m_addr.resize(address_size);
413  s >> MakeSpan(m_addr);
414 
415  if (m_net != NET_IPV6) {
416  return;
417  }
418 
419  // Do some special checks on IPv6 addresses.
420 
421  // Recognize NET_INTERNAL embedded in IPv6, such addresses are not
422  // gossiped but could be coming from addrman, when unserializing from
423  // disk.
429  return;
430  }
431 
434  return;
435  }
436 
437  // IPv4 and TORv2 are not supposed to be embedded in IPv6 (like in V1
438  // encoding). Unserialize as !IsValid(), thus ignoring them.
439  } else {
440  // If we receive an unknown BIP155 network id (from the future?) then
441  // ignore the address - unserialize as !IsValid().
442  s.ignore(address_size);
443  }
444 
445  // Mimic a default-constructed CNetAddr object which is !IsValid() and thus
446  // will not be gossiped, but continue reading next addresses from the stream.
447  m_net = NET_IPV6;
449  }
450 };
451 
452 class CSubNet
453 {
454  protected:
458  uint8_t netmask[16];
460  bool valid;
461 
462  bool SanityCheck() const;
463 
464  public:
465  CSubNet();
466  CSubNet(const CNetAddr& addr, uint8_t mask);
467  CSubNet(const CNetAddr& addr, const CNetAddr& mask);
468 
469  //constructor for single ip subnet (<ipv4>/32 or <ipv6>/128)
470  explicit CSubNet(const CNetAddr& addr);
471 
472  bool Match(const CNetAddr &addr) const;
473 
474  std::string ToString() const;
475  bool IsValid() const;
476 
477  friend bool operator==(const CSubNet& a, const CSubNet& b);
478  friend bool operator!=(const CSubNet& a, const CSubNet& b) { return !(a == b); }
479  friend bool operator<(const CSubNet& a, const CSubNet& b);
480 
482  {
483  READWRITE(obj.network);
484  if (obj.network.IsIPv4()) {
485  // Before commit 102867c587f5f7954232fb8ed8e85cda78bb4d32, CSubNet used the last 4 bytes of netmask
486  // to store the relevant bytes for an IPv4 mask. For compatiblity reasons, keep doing so in
487  // serialized form.
488  unsigned char dummy[12] = {0};
489  READWRITE(dummy);
490  READWRITE(MakeSpan(obj.netmask).first(4));
491  } else {
492  READWRITE(obj.netmask);
493  }
494  READWRITE(obj.valid);
495  // Mark invalid if the result doesn't pass sanity checking.
496  SER_READ(obj, if (obj.valid) obj.valid = obj.SanityCheck());
497  }
498 };
499 
501 class CService : public CNetAddr
502 {
503  protected:
504  uint16_t port; // host order
505 
506  public:
507  CService();
508  CService(const CNetAddr& ip, uint16_t port);
509  CService(const struct in_addr& ipv4Addr, uint16_t port);
510  explicit CService(const struct sockaddr_in& addr);
511  uint16_t GetPort() const;
512  bool GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const;
513  bool SetSockAddr(const struct sockaddr* paddr);
514  friend bool operator==(const CService& a, const CService& b);
515  friend bool operator!=(const CService& a, const CService& b) { return !(a == b); }
516  friend bool operator<(const CService& a, const CService& b);
517  std::vector<unsigned char> GetKey() const;
518  std::string ToString() const;
519  std::string ToStringPort() const;
520  std::string ToStringIPPort() const;
521 
522  CService(const struct in6_addr& ipv6Addr, uint16_t port);
523  explicit CService(const struct sockaddr_in6& addr);
524 
526  {
527  READWRITEAS(CNetAddr, obj);
529  }
530 };
531 
532 bool SanityCheckASMap(const std::vector<bool>& asmap);
533 
534 #endif // BITCOIN_NETADDRESS_H
int GetReachabilityFrom(const CNetAddr *paddrPartner=nullptr) const
Calculates a metric for how reachable (*this) is from a given partner.
Definition: netaddress.cpp:797
std::vector< unsigned char > GetGroup(const std::vector< bool > &asmap) const
Get the canonical identifier of our network group.
Definition: netaddress.cpp:711
bool HasLinkedIPv4() const
Whether this address has a linked IPv4 address (see GetLinkedIPv4()).
Definition: netaddress.cpp:630
friend class CSubNet
Definition: netaddress.h:248
void resize(size_type new_size)
Definition: prevector.h:316
bool SetNetFromBIP155Network(uint8_t possible_bip155_net, size_t address_size)
Set m_net from the provided BIP155 network id and size after validation.
Definition: netaddress.cpp:56
void assign(size_type n, const T &val)
Definition: prevector.h:218
void Serialize(Stream &s) const
Serialize to a stream.
Definition: netaddress.h:226
bool IsLocal() const
Definition: netaddress.cpp:402
bool IsRFC4380() const
Definition: netaddress.cpp:346
A set of addresses that represent the hash of a string or FQDN.
Definition: netaddress.h:65
Dummy value to indicate the number of NET_* constants.
Definition: netaddress.h:68
void SetIP(const CNetAddr &ip)
Definition: netaddress.cpp:122
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
static constexpr size_t ADDR_TORV3_SIZE
Size of TORv3 address (in bytes).
Definition: netaddress.h:105
IPv4.
Definition: netaddress.h:49
static constexpr size_t MAX_ADDRV2_SIZE
Maximum size of an address as defined in BIP155 (in bytes).
Definition: netaddress.h:273
bool IsIPv6() const
Definition: netaddress.cpp:297
prevector< ADDR_IPV6_SIZE, uint8_t > m_addr
Raw representation of the network address.
Definition: netaddress.h:126
void Unserialize(Stream &s)
Unserialize from a stream.
Definition: netaddress.h:239
#define COMPACTSIZE(obj)
Definition: serialize.h:480
uint16_t port
Definition: netaddress.h:504
static constexpr size_t ADDR_IPV4_SIZE
Size of IPv4 address (in bytes).
Definition: netaddress.h:95
static const std::array< uint8_t, 6 > INTERNAL_IN_IPV6_PREFIX
Prefix of an IPv6 address when it contains an embedded "internal" address.
Definition: netaddress.h:90
bool IsInternal() const
Definition: netaddress.cpp:472
SERIALIZE_METHODS(CSubNet, obj)
Definition: netaddress.h:481
CNetAddr network
Network (base) address.
Definition: netaddress.h:456
bool IsBindAny() const
Definition: netaddress.cpp:287
bool GetInAddr(struct in_addr *pipv4Addr) const
Try to get our IPv4 address.
Definition: netaddress.cpp:601
std::string ToString() const
Definition: netaddress.cpp:576
void UnserializeV1Array(uint8_t(&arr)[V1_SERIALIZATION_SIZE])
Unserialize from a pre-ADDRv2/BIP155 format from an array.
Definition: netaddress.h:372
Network GetNetClass() const
Definition: netaddress.cpp:652
void UnserializeV2Stream(Stream &s)
Unserialize from a ADDRv2 / BIP155 format.
Definition: netaddress.h:396
#define READWRITEAS(type, obj)
Definition: serialize.h:176
bool SanityCheckASMap(const std::vector< bool > &asmap)
bool GetIn6Addr(struct in6_addr *pipv6Addr) const
Try to get our IPv6 address.
Definition: netaddress.cpp:620
enum Network GetNetwork() const
Definition: netaddress.cpp:497
static Wrapper< Formatter, T & > Using(T &&t)
Cause serialization/deserialization of an object to be done using a specified formatter class...
Definition: serialize.h:476
I2P.
Definition: netaddress.h:58
void UnserializeV1Stream(Stream &s)
Unserialize from a pre-ADDRv2/BIP155 format from a stream.
Definition: netaddress.h:383
bool IsRFC2544() const
Definition: netaddress.cpp:307
uint32_t m_scope_id
Scope id if scoped/link-local IPV6 address.
Definition: netaddress.h:137
bool IsRelayable() const
Whether this address should be relayed to other peers even if we can&#39;t reach it ourselves.
Definition: netaddress.h:217
value_type * data()
Definition: prevector.h:528
bool IsRFC4862() const
Definition: netaddress.cpp:351
uint32_t GetMappedAS(const std::vector< bool > &asmap) const
Definition: netaddress.cpp:670
bool IsValid() const
Definition: netaddress.cpp:428
static constexpr size_t ADDR_CJDNS_SIZE
Size of CJDNS address (in bytes).
Definition: netaddress.h:111
bool IsCJDNS() const
Check whether this object represents a CJDNS address.
Definition: netaddress.cpp:400
friend bool operator!=(const CNetAddr &a, const CNetAddr &b)
Definition: netaddress.h:211
friend bool operator!=(const CSubNet &a, const CSubNet &b)
Definition: netaddress.h:478
bool IsIPv4() const
Definition: netaddress.cpp:295
bool IsRFC5737() const
Definition: netaddress.cpp:322
bool IsI2P() const
Check whether this object represents an I2P address.
Definition: netaddress.cpp:395
static constexpr size_t ADDR_IPV6_SIZE
Size of IPv6 address (in bytes).
Definition: netaddress.h:98
static const int ADDRV2_FORMAT
A flag that is ORed into the protocol version to designate that addresses should be serialized in (un...
Definition: netaddress.h:32
bool IsRFC6145() const
Definition: netaddress.cpp:362
void SerializeV1Array(uint8_t(&arr)[V1_SERIALIZATION_SIZE]) const
Serialize in pre-ADDRv2/BIP155 format to an array.
Definition: netaddress.h:294
static constexpr size_t ADDR_I2P_SIZE
Size of I2P address (in bytes).
Definition: netaddress.h:108
bool IsRFC6052() const
Definition: netaddress.cpp:339
static constexpr size_t ADDR_TORV2_SIZE
Size of TORv2 address (in bytes).
Definition: netaddress.h:101
friend bool operator!=(const CService &a, const CService &b)
Definition: netaddress.h:515
std::string ToStringIP() const
Definition: netaddress.cpp:524
const char * name
Definition: rest.cpp:41
BIP155Network GetBIP155Network() const
Get the BIP155 network id of this address.
Definition: netaddress.cpp:27
BIP155Network
BIP155 network ids recognized by this software.
Definition: netaddress.h:254
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:501
void SerializeV1Stream(Stream &s) const
Serialize in pre-ADDRv2/BIP155 format to a stream.
Definition: netaddress.h:341
Network
A network type.
Definition: netaddress.h:43
bool IsRFC3849() const
Definition: netaddress.cpp:329
bool IsRoutable() const
Definition: netaddress.cpp:462
uint64_t GetHash() const
Definition: netaddress.cpp:775
bool valid
Is this value valid? (only used to signal parse errors)
Definition: netaddress.h:460
Network address.
Definition: netaddress.h:119
friend bool operator<(const CNetAddr &a, const CNetAddr &b)
Definition: netaddress.cpp:586
bool IsRFC1918() const
Definition: netaddress.cpp:299
bool IsRFC6598() const
Definition: netaddress.cpp:317
bool IsHeNet() const
Definition: netaddress.cpp:381
bool IsRFC3927() const
Definition: netaddress.cpp:312
friend bool operator==(const CNetAddr &a, const CNetAddr &b)
Definition: netaddress.cpp:581
static const std::array< uint8_t, 6 > TORV2_IN_IPV6_PREFIX
Prefix of an IPv6 address when it contains an embedded TORv2 address.
Definition: netaddress.h:81
void SerializeV2Stream(Stream &s) const
Serialize as ADDRv2 / BIP155.
Definition: netaddress.h:354
void * memcpy(void *a, const void *b, size_t c)
Serialization wrapper class for custom integers and enums.
Definition: serialize.h:508
IPv6.
Definition: netaddress.h:52
TOR (v2 or v3)
Definition: netaddress.h:55
NODISCARD bool HasPrefix(const T1 &obj, const std::array< uint8_t, PREFIX_LEN > &prefix)
Check whether a container begins with the given prefix.
Definition: string.h:83
bool SetSpecial(const std::string &strName)
Parse a TOR address and set this object to it.
Definition: netaddress.cpp:231
bool IsRFC7343() const
Definition: netaddress.cpp:375
size_type size() const
Definition: prevector.h:282
bool IsRFC4843() const
Definition: netaddress.cpp:369
static const std::array< uint8_t, 12 > IPV4_IN_IPV6_PREFIX
Prefix of an IPv6 address when it contains an embedded IPv4 address.
Definition: netaddress.h:73
static constexpr size_t ADDR_INTERNAL_SIZE
Size of "internal" (NET_INTERNAL) address (in bytes).
Definition: netaddress.h:114
#define SER_READ(obj, code)
Definition: serialize.h:177
A Span is an object that can refer to a contiguous sequence of objects.
Definition: span.h:82
uint32_t GetLinkedIPv4() const
For IPv4, mapped IPv4, SIIT translated IPv4, Teredo, 6to4 tunneled addresses, return the relevant IPv...
Definition: netaddress.cpp:635
bool SetInternal(const std::string &name)
Create an "internal" address that represents a name or FQDN.
Definition: netaddress.cpp:185
Network m_net
Network to which this address belongs.
Definition: netaddress.h:131
#define READWRITE(...)
Definition: serialize.h:175
bool IsRFC4193() const
Definition: netaddress.cpp:357
void * memmove(void *a, const void *b, size_t c)
bool IsAddrV1Compatible() const
Check if the current object can be serialized in pre-ADDRv2/BIP155 format.
Definition: netaddress.cpp:477
CJDNS.
Definition: netaddress.h:61
SERIALIZE_METHODS(CService, obj)
Definition: netaddress.h:525
bool IsTor() const
Check whether this object represents a TOR address.
Definition: netaddress.cpp:390
static constexpr size_t V1_SERIALIZATION_SIZE
Size of CNetAddr when serialized as ADDRv1 (pre-BIP155) (in bytes).
Definition: netaddress.h:266
void SetLegacyIPv6(Span< const uint8_t > ipv6)
Set from a legacy IPv6 address.
Definition: netaddress.cpp:153
std::vector< unsigned char > GetAddrBytes() const
Definition: netaddress.cpp:765
bool IsRFC3964() const
Definition: netaddress.cpp:334
Span< A > constexpr MakeSpan(A(&a)[N])
MakeSpan for arrays:
Definition: span.h:193
CNetAddr()
Construct an unspecified IPv6 network address (::/128).
Definition: netaddress.cpp:120
Addresses from these networks are not publicly routable on the global Internet.
Definition: netaddress.h:46