Network address.
More...
#include <netaddress.h>
Network address.
Definition at line 111 of file netaddress.h.
◆ BIP155Network
BIP155 network ids recognized by this software.
Enumerator |
---|
IPV4 | |
IPV6 | |
TORV2 | |
TORV3 | |
I2P | |
CJDNS | |
Definition at line 263 of file netaddress.h.
◆ Encoding
Enumerator |
---|
V1 | |
V2 | BIP155 encoding.
|
Definition at line 223 of file netaddress.h.
◆ CNetAddr() [1/3]
Construct an unspecified IPv6 network address (::/128).
- Note
- This address is considered invalid by CNetAddr::IsValid()
◆ CNetAddr() [2/3]
CNetAddr::CNetAddr |
( |
const struct in_addr & |
ipv4Addr | ) |
|
|
explicit |
◆ CNetAddr() [3/3]
CNetAddr::CNetAddr |
( |
const struct in6_addr & |
pipv6Addr, |
|
|
const uint32_t |
scope = 0 |
|
) |
| |
|
explicit |
◆ GetAddrBytes()
std::vector< unsigned char > CNetAddr::GetAddrBytes |
( |
| ) |
const |
◆ GetBIP155Network()
Get the BIP155 network id of this address.
Must not be called for IsInternal() objects.
- Returns
- BIP155 network id, except TORV2 which is no longer supported.
Definition at line 26 of file netaddress.cpp.
◆ GetIn6Addr()
bool CNetAddr::GetIn6Addr |
( |
struct in6_addr * |
pipv6Addr | ) |
const |
Try to get our IPv6 (or CJDNS) address.
- Parameters
-
[out] | pipv6Addr | The in6_addr struct to which to copy. |
- Returns
- Whether or not the operation was successful, in particular, whether or not our address was an IPv6 address.
- See also
- CNetAddr::IsIPv6()
Definition at line 646 of file netaddress.cpp.
◆ GetInAddr()
bool CNetAddr::GetInAddr |
( |
struct in_addr * |
pipv4Addr | ) |
const |
Try to get our IPv4 address.
- Parameters
-
[out] | pipv4Addr | The in_addr struct to which to copy. |
- Returns
- Whether or not the operation was successful, in particular, whether or not our address was an IPv4 address.
- See also
- CNetAddr::IsIPv4()
Definition at line 627 of file netaddress.cpp.
◆ GetLinkedIPv4()
uint32_t CNetAddr::GetLinkedIPv4 |
( |
| ) |
const |
For IPv4, mapped IPv4, SIIT translated IPv4, Teredo, 6to4 tunneled addresses, return the relevant IPv4 address as a uint32.
Definition at line 661 of file netaddress.cpp.
◆ GetNetClass()
Network CNetAddr::GetNetClass |
( |
| ) |
const |
◆ GetNetwork()
enum Network CNetAddr::GetNetwork |
( |
| ) |
const |
◆ GetReachabilityFrom()
int CNetAddr::GetReachabilityFrom |
( |
const CNetAddr & |
paddrPartner | ) |
const |
Calculates a metric for how reachable (*this) is from a given partner.
Definition at line 717 of file netaddress.cpp.
◆ HasCJDNSPrefix()
bool CNetAddr::HasCJDNSPrefix |
( |
| ) |
const |
|
inline |
◆ HasLinkedIPv4()
bool CNetAddr::HasLinkedIPv4 |
( |
| ) |
const |
◆ IsAddrV1Compatible()
bool CNetAddr::IsAddrV1Compatible |
( |
| ) |
const |
Check if the current object can be serialized in pre-ADDRv2/BIP155 format.
Definition at line 481 of file netaddress.cpp.
◆ IsBindAny()
bool CNetAddr::IsBindAny |
( |
| ) |
const |
◆ IsCJDNS()
bool CNetAddr::IsCJDNS |
( |
| ) |
const |
|
inline |
◆ IsHeNet()
bool CNetAddr::IsHeNet |
( |
| ) |
const |
◆ IsI2P()
bool CNetAddr::IsI2P |
( |
| ) |
const |
|
inline |
◆ IsInternal()
bool CNetAddr::IsInternal |
( |
| ) |
const |
◆ IsIPv4()
bool CNetAddr::IsIPv4 |
( |
| ) |
const |
|
inline |
◆ IsIPv6()
bool CNetAddr::IsIPv6 |
( |
| ) |
const |
|
inline |
◆ IsLocal()
bool CNetAddr::IsLocal |
( |
| ) |
const |
◆ IsPrivacyNet()
bool CNetAddr::IsPrivacyNet |
( |
| ) |
const |
|
inline |
◆ IsRelayable()
bool CNetAddr::IsRelayable |
( |
| ) |
const |
|
inline |
Whether this address should be relayed to other peers even if we can't reach it ourselves.
Definition at line 218 of file netaddress.h.
◆ IsRFC1918()
bool CNetAddr::IsRFC1918 |
( |
| ) |
const |
◆ IsRFC2544()
bool CNetAddr::IsRFC2544 |
( |
| ) |
const |
◆ IsRFC3849()
bool CNetAddr::IsRFC3849 |
( |
| ) |
const |
◆ IsRFC3927()
bool CNetAddr::IsRFC3927 |
( |
| ) |
const |
◆ IsRFC3964()
bool CNetAddr::IsRFC3964 |
( |
| ) |
const |
◆ IsRFC4193()
bool CNetAddr::IsRFC4193 |
( |
| ) |
const |
◆ IsRFC4380()
bool CNetAddr::IsRFC4380 |
( |
| ) |
const |
◆ IsRFC4843()
bool CNetAddr::IsRFC4843 |
( |
| ) |
const |
◆ IsRFC4862()
bool CNetAddr::IsRFC4862 |
( |
| ) |
const |
◆ IsRFC5737()
bool CNetAddr::IsRFC5737 |
( |
| ) |
const |
◆ IsRFC6052()
bool CNetAddr::IsRFC6052 |
( |
| ) |
const |
◆ IsRFC6145()
bool CNetAddr::IsRFC6145 |
( |
| ) |
const |
◆ IsRFC6598()
bool CNetAddr::IsRFC6598 |
( |
| ) |
const |
◆ IsRFC7343()
bool CNetAddr::IsRFC7343 |
( |
| ) |
const |
◆ IsRoutable()
bool CNetAddr::IsRoutable |
( |
| ) |
const |
- Returns
- Whether or not this network address is publicly routable on the global internet.
- Note
- A routable address is always valid. As in, the set of routable addresses is a subset of the set of valid addresses.
- See also
- CNetAddr::IsValid()
Definition at line 466 of file netaddress.cpp.
◆ IsTor()
bool CNetAddr::IsTor |
( |
| ) |
const |
|
inline |
◆ IsValid()
bool CNetAddr::IsValid |
( |
| ) |
const |
- Returns
- Whether or not this network address is a valid address that could be used to refer to an actual host.
- Note
- A valid address may or may not be publicly routable on the global internet. As in, the set of valid addresses is a superset of the set of publicly routable addresses.
- See also
- CNetAddr::IsRoutable()
Definition at line 428 of file netaddress.cpp.
◆ Serialize()
template<typename Stream >
void CNetAddr::Serialize |
( |
Stream & |
s | ) |
const |
|
inline |
◆ SerializeV1Array()
void CNetAddr::SerializeV1Array |
( |
uint8_t(&) |
arr[V1_SERIALIZATION_SIZE] | ) |
const |
|
inlineprivate |
Serialize in pre-ADDRv2/BIP155 format to an array.
Definition at line 324 of file netaddress.h.
◆ SerializeV1Stream()
template<typename Stream >
void CNetAddr::SerializeV1Stream |
( |
Stream & |
s | ) |
const |
|
inlineprivate |
Serialize in pre-ADDRv2/BIP155 format to a stream.
Definition at line 362 of file netaddress.h.
◆ SerializeV2Stream()
template<typename Stream >
void CNetAddr::SerializeV2Stream |
( |
Stream & |
s | ) |
const |
|
inlineprivate |
◆ SetI2P()
bool CNetAddr::SetI2P |
( |
const std::string & |
addr | ) |
|
|
private |
Parse an I2P address and set this object to it.
- Parameters
-
[in] | addr | Address to parse, must be a valid C string, for example ukeu3k5oycgaauneqgtnvselmt4yemvoilkln7jpvamvfx7dnkdq.b32.i2p. |
- Returns
- Whether the operation was successful.
- See also
- CNetAddr::IsI2P()
Definition at line 267 of file netaddress.cpp.
◆ SetInternal()
bool CNetAddr::SetInternal |
( |
const std::string & |
name | ) |
|
◆ SetIP()
void CNetAddr::SetIP |
( |
const CNetAddr & |
ip | ) |
|
◆ SetLegacyIPv6()
void CNetAddr::SetLegacyIPv6 |
( |
Span< const uint8_t > |
ipv6 | ) |
|
Set from a legacy IPv6 address.
Legacy IPv6 address may be a normal IPv6 address, or another address (e.g. IPv4) disguised as IPv6. This encoding is used in the legacy addr
encoding.
Definition at line 137 of file netaddress.cpp.
◆ SetNetFromBIP155Network()
bool CNetAddr::SetNetFromBIP155Network |
( |
uint8_t |
possible_bip155_net, |
|
|
size_t |
address_size |
|
) |
| |
|
private |
Set m_net
from the provided BIP155 network id and size after validation.
- Return values
-
true | the network was recognized, is valid and m_net was set |
false | not recognised (from future?) and should be silently ignored |
- Exceptions
-
std::ios_base::failure | if the network is one of the BIP155 founding networks (id 1..6) with wrong address size. |
Definition at line 48 of file netaddress.cpp.
◆ SetSpecial()
bool CNetAddr::SetSpecial |
( |
const std::string & |
addr | ) |
|
Parse a Tor or I2P address and set this object to it.
- Parameters
-
[in] | addr | Address to parse, for example pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion or ukeu3k5oycgaauneqgtnvselmt4yemvoilkln7jpvamvfx7dnkdq.b32.i2p. |
- Returns
- Whether the operation was successful.
- See also
- CNetAddr::IsTor(), CNetAddr::IsI2P()
Definition at line 211 of file netaddress.cpp.
◆ SetTor()
bool CNetAddr::SetTor |
( |
const std::string & |
addr | ) |
|
|
private |
Parse a Tor address and set this object to it.
- Parameters
-
[in] | addr | Address to parse, must be a valid C string, for example pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion. |
- Returns
- Whether the operation was successful.
- See also
- CNetAddr::IsTor()
Definition at line 228 of file netaddress.cpp.
◆ ToStringAddr()
std::string CNetAddr::ToStringAddr |
( |
| ) |
const |
◆ Unserialize()
template<typename Stream >
void CNetAddr::Unserialize |
( |
Stream & |
s | ) |
|
|
inline |
◆ UnserializeV1Array()
void CNetAddr::UnserializeV1Array |
( |
uint8_t(&) |
arr[V1_SERIALIZATION_SIZE] | ) |
|
|
inlineprivate |
Unserialize from a pre-ADDRv2/BIP155 format from an array.
This function is only called from UnserializeV1Stream() and is a wrapper for SetLegacyIPv6(); however, we keep it for symmetry with SerializeV1Array() to have pairs of ser/unser functions and to make clear that if one is altered, a corresponding reverse modification should be applied to the other.
Definition at line 399 of file netaddress.h.
◆ UnserializeV1Stream()
template<typename Stream >
void CNetAddr::UnserializeV1Stream |
( |
Stream & |
s | ) |
|
|
inlineprivate |
Unserialize from a pre-ADDRv2/BIP155 format from a stream.
Definition at line 410 of file netaddress.h.
◆ UnserializeV2Stream()
template<typename Stream >
void CNetAddr::UnserializeV2Stream |
( |
Stream & |
s | ) |
|
|
inlineprivate |
Unserialize from a ADDRv2 / BIP155 format.
Definition at line 423 of file netaddress.h.
◆ CSubNet
◆ operator!=
◆ operator<
◆ operator==
◆ m_addr
Raw representation of the network address.
In network byte order (big endian) for IPv4 and IPv6.
Definition at line 118 of file netaddress.h.
◆ m_net
Network to which this address belongs.
Definition at line 123 of file netaddress.h.
◆ m_scope_id
uint32_t CNetAddr::m_scope_id {0} |
|
protected |
◆ MAX_ADDRV2_SIZE
constexpr size_t CNetAddr::MAX_ADDRV2_SIZE = 512 |
|
staticconstexprprivate |
Maximum size of an address as defined in BIP155 (in bytes).
This is only the size of the address, not the entire CNetAddr object when serialized.
Definition at line 303 of file netaddress.h.
◆ V1
constexpr SerParams CNetAddr::V1 {Encoding::V1} |
|
staticconstexpr |
◆ V1_SERIALIZATION_SIZE
◆ V2
constexpr SerParams CNetAddr::V2 {Encoding::V2} |
|
staticconstexpr |
The documentation for this class was generated from the following files: