[#CNetAddr] = CNetAddr :mrdocs: Network address. == Synopsis Declared in `<netaddress.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class CNetAddr; ---- == Types [cols="1,4"] |=== | Name| Description | xref:CNetAddr/SerParams.adoc[`SerParams`] | Serialization parameters selecting the address wire encoding. |=== == Enums [cols="1,4"] |=== | Name| Description | xref:CNetAddr/BIP155Network.adoc[`BIP155Network`] | BIP155 network ids recognized by this software. | xref:CNetAddr/Encoding.adoc[`Encoding`] | Wire encoding used when (un)serializing an address. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:CNetAddr/2constructor-08.adoc[`CNetAddr`] [.small]#[constructor]# | Constructors | xref:CNetAddr/GetAddrBytes.adoc[`GetAddrBytes`] | Get the raw address bytes. | xref:CNetAddr/GetIn6Addr.adoc[`GetIn6Addr`] | Fill an in6_addr with this address's IPv6 value. | xref:CNetAddr/GetInAddr.adoc[`GetInAddr`] | Fill an in_addr with this address's IPv4 value. | xref:CNetAddr/GetLinkedIPv4.adoc[`GetLinkedIPv4`] | For IPv4, mapped IPv4, SIIT translated IPv4, Teredo, 6to4 tunneled addresses, return the relevant IPv4 address as a uint32. | xref:CNetAddr/GetNetClass.adoc[`GetNetClass`] | Get the network class used for grouping this address. | xref:CNetAddr/GetNetwork.adoc[`GetNetwork`] | Get the network this address belongs to. | xref:CNetAddr/GetReachabilityFrom.adoc[`GetReachabilityFrom`] | Calculate how reachable this address is from a given peer address. | xref:CNetAddr/HasCJDNSPrefix.adoc[`HasCJDNSPrefix`] | Whether the raw address begins with the CJDNS prefix byte. | xref:CNetAddr/HasLinkedIPv4.adoc[`HasLinkedIPv4`] | Whether this address has a linked IPv4 address (see GetLinkedIPv4()). | xref:CNetAddr/IsAddrV1Compatible.adoc[`IsAddrV1Compatible`] | Check if the current object can be serialized in pre‐ADDRv2/BIP155 format. | xref:CNetAddr/IsBindAny.adoc[`IsBindAny`] | Whether this address is the INADDR_ANY / "bind any" wildcard address. | xref:CNetAddr/IsCJDNS.adoc[`IsCJDNS`] | Whether this is a CJDNS address. | xref:CNetAddr/IsHeNet.adoc[`IsHeNet`] | Whether this is an IPv6 Hurricane Electric address (2001:0470::/36). | xref:CNetAddr/IsI2P.adoc[`IsI2P`] | Whether this is an I2P address. | xref:CNetAddr/IsIPv4.adoc[`IsIPv4`] | Whether this is an IPv4 address (::FFFF:0:0/96, 0.0.0.0/0). | xref:CNetAddr/IsIPv6.adoc[`IsIPv6`] | Whether this is a native IPv6 address (not mapped IPv4, not Tor). | xref:CNetAddr/IsInternal.adoc[`IsInternal`] | Whether this is an internal (NET_INTERNAL) address. | xref:CNetAddr/IsLocal.adoc[`IsLocal`] | Whether this is a local (loopback) address. | xref:CNetAddr/IsPrivacyNet.adoc[`IsPrivacyNet`] | Whether this object is a privacy network. TODO: consider adding IsCJDNS() here when more peers adopt CJDNS, see: https://github.com/bitcoin/bitcoin/pull/27411#issuecomment‐1497176155 | xref:CNetAddr/IsRFC1918.adoc[`IsRFC1918`] | Whether this is an IPv4 private‐network address (10/8, 192.168/16, 172.16/12). | xref:CNetAddr/IsRFC2544.adoc[`IsRFC2544`] | Whether this is an IPv4 inter‐network benchmarking address (198.18.0.0/15). | xref:CNetAddr/IsRFC3849.adoc[`IsRFC3849`] | Whether this is an IPv6 documentation address (2001:0DB8::/32). | xref:CNetAddr/IsRFC3927.adoc[`IsRFC3927`] | Whether this is an IPv4 link‐local autoconfig address (169.254.0.0/16). | xref:CNetAddr/IsRFC3964.adoc[`IsRFC3964`] | Whether this is an IPv6 6to4 tunnelling address (2002::/16). | xref:CNetAddr/IsRFC4193.adoc[`IsRFC4193`] | Whether this is an IPv6 unique‐local address (FC00::/7). | xref:CNetAddr/IsRFC4380.adoc[`IsRFC4380`] | Whether this is an IPv6 Teredo tunnelling address (2001::/32). | xref:CNetAddr/IsRFC4843.adoc[`IsRFC4843`] | Whether this is an IPv6 ORCHID (deprecated) address (2001:10::/28). | xref:CNetAddr/IsRFC4862.adoc[`IsRFC4862`] | Whether this is an IPv6 link‐local autoconfig address (FE80::/64). | xref:CNetAddr/IsRFC5737.adoc[`IsRFC5737`] | Whether this is an IPv4 documentation address (192.0.2/24, 198.51.100/24, 203.0.113/24). | xref:CNetAddr/IsRFC6052.adoc[`IsRFC6052`] | Whether this is an IPv6 well‐known prefix for IPv4‐embedded addresses (64:FF9B::/96). | xref:CNetAddr/IsRFC6145.adoc[`IsRFC6145`] | Whether this is an IPv6 IPv4‐translated address (::FFFF:0:0:0/96). | xref:CNetAddr/IsRFC6598.adoc[`IsRFC6598`] | Whether this is an IPv4 ISP‐level NAT (shared) address (100.64.0.0/10). | xref:CNetAddr/IsRFC7343.adoc[`IsRFC7343`] | Whether this is an IPv6 ORCHIDv2 address (2001:20::/28). | xref:CNetAddr/IsRelayable.adoc[`IsRelayable`] | Whether this address should be relayed to other peers even if we can't reach it ourselves. | xref:CNetAddr/IsRoutable.adoc[`IsRoutable`] | Whether this address is publicly routable. | xref:CNetAddr/IsTor.adoc[`IsTor`] | Whether this is a Tor onion address. | xref:CNetAddr/IsValid.adoc[`IsValid`] | Whether this address is valid. | xref:CNetAddr/Serialize.adoc[`Serialize`] | Serialize to a stream. | xref:CNetAddr/SetIP.adoc[`SetIP`] | Copy the address value from another CNetAddr. | xref:CNetAddr/SetInternal.adoc[`SetInternal`] | Set this address to an internal address derived from a string or FQDN. | xref:CNetAddr/SetLegacyIPv6.adoc[`SetLegacyIPv6`] | 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. | xref:CNetAddr/SetSpecial.adoc[`SetSpecial`] | Parse a Tor or I2P address and set this object to it. | xref:CNetAddr/ToStringAddr.adoc[`ToStringAddr`] | Get the address as a human‐readable string, without a port. | xref:CNetAddr/Unserialize.adoc[`Unserialize`] | Unserialize from a stream. |=== == Static Data Members [cols="1,4"] |=== | Name| Description | xref:CNetAddr/V1.adoc[`V1`] | Serialization parameters for the legacy ADDRv1 encoding. | xref:CNetAddr/V2.adoc[`V2`] | Serialization parameters for the BIP155 ADDRv2 encoding. |=== == Protected Data Members [cols="1,4"] |=== | Name| Description | xref:CNetAddr/m_addr.adoc[`m_addr`] | Raw representation of the network address. In network byte order (big endian) for IPv4 and IPv6. | xref:CNetAddr/m_net.adoc[`m_net`] | Network to which this address belongs. | xref:CNetAddr/m_scope_id.adoc[`m_scope_id`] | Scope id if scoped/link‐local IPV6 address. See https://tools.ietf.org/html/rfc4007 |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:CSubNet.adoc[CSubNet]` | A subnet: a network base address together with a netmask. | `xref:operator_lt-0c.adoc[operator<]` | Order two addresses. | `xref:operator_eq-0d.adoc[operator==]` | Compare two addresses for equality. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:AddLocal-0ab.adoc[`AddLocal`] | Record a local address that we may advertise, scored by nScore. | xref:GetLocalAddresses.adoc[`GetLocalAddresses`] | Return all local non‐loopback IPv4 and IPv6 network addresses. | xref:IsProxy.adoc[`IsProxy`] | Check whether an address is one of the configured proxies. | xref:LookupHost-09.adoc[`LookupHost`] | Resolve a host string to its first corresponding network address. | xref:LookupHost-0b.adoc[`LookupHost`] | Resolve a host string to its corresponding network addresses. | xref:NATPMPRequestPortMap.adoc[`NATPMPRequestPortMap`] | Try to open a port using RFC 6886 NAT‐PMP. IPv4 only. | xref:QueryDefaultGateway.adoc[`QueryDefaultGateway`] | Query the OS for the default gateway for `network`. This only makes sense for NET_IPV4 and NET_IPV6. Returns std::nullopt if it cannot be found, or there is no support for this OS. | xref:WrappedGetAddrInfo.adoc[`WrappedGetAddrInfo`] | Wrapper for getaddrinfo(3). Do not use directly: call Lookup/LookupHost/LookupNumeric/LookupSubNet. |=== == Derived Classes [cols="1,4"] |=== | Name| Description | xref:CService.adoc[`CService`] | A combination of a network address (CNetAddr) and a (TCP) port |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#