Bitcoin Core 28.99.0
P2P Digital Currency
|
A combination of a network address (CNetAddr) and a (TCP) port. More...
#include <netaddress.h>
Public Member Functions | |
CService () | |
CService (const CNetAddr &ip, uint16_t port) | |
CService (const struct in_addr &ipv4Addr, uint16_t port) | |
CService (const struct sockaddr_in &addr) | |
uint16_t | GetPort () const |
bool | GetSockAddr (struct sockaddr *paddr, socklen_t *addrlen) const |
Obtain the IPv4/6 socket address this represents. More... | |
bool | SetSockAddr (const struct sockaddr *paddr) |
sa_family_t | GetSAFamily () const |
Get the address family. More... | |
std::vector< unsigned char > | GetKey () const |
std::string | ToStringAddrPort () const |
CService (const struct in6_addr &ipv6Addr, uint16_t port) | |
CService (const struct sockaddr_in6 &addr) | |
SERIALIZE_METHODS (CService, obj) | |
Public Member Functions inherited from CNetAddr | |
CNetAddr () | |
Construct an unspecified IPv6 network address (::/128). More... | |
CNetAddr (const struct in_addr &ipv4Addr) | |
void | SetIP (const CNetAddr &ip) |
void | SetLegacyIPv6 (Span< const uint8_t > ipv6) |
Set from a legacy IPv6 address. More... | |
bool | SetInternal (const std::string &name) |
Create an "internal" address that represents a name or FQDN. More... | |
bool | SetSpecial (const std::string &addr) |
Parse a Tor or I2P address and set this object to it. More... | |
bool | IsBindAny () const |
bool | IsIPv4 () const |
bool | IsIPv6 () const |
bool | IsRFC1918 () const |
bool | IsRFC2544 () const |
bool | IsRFC6598 () const |
bool | IsRFC5737 () const |
bool | IsRFC3849 () const |
bool | IsRFC3927 () const |
bool | IsRFC3964 () const |
bool | IsRFC4193 () const |
bool | IsRFC4380 () const |
bool | IsRFC4843 () const |
bool | IsRFC7343 () const |
bool | IsRFC4862 () const |
bool | IsRFC6052 () const |
bool | IsRFC6145 () const |
bool | IsHeNet () const |
bool | IsTor () const |
bool | IsI2P () const |
bool | IsCJDNS () const |
bool | HasCJDNSPrefix () const |
bool | IsLocal () const |
bool | IsRoutable () const |
bool | IsInternal () const |
bool | IsValid () const |
bool | IsPrivacyNet () const |
Whether this object is a privacy network. More... | |
bool | IsAddrV1Compatible () const |
Check if the current object can be serialized in pre-ADDRv2/BIP155 format. More... | |
enum Network | GetNetwork () const |
std::string | ToStringAddr () const |
bool | GetInAddr (struct in_addr *pipv4Addr) const |
Try to get our IPv4 address. More... | |
Network | GetNetClass () const |
uint32_t | GetLinkedIPv4 () const |
For IPv4, mapped IPv4, SIIT translated IPv4, Teredo, 6to4 tunneled addresses, return the relevant IPv4 address as a uint32. More... | |
bool | HasLinkedIPv4 () const |
Whether this address has a linked IPv4 address (see GetLinkedIPv4()). More... | |
std::vector< unsigned char > | GetAddrBytes () const |
int | GetReachabilityFrom (const CNetAddr &paddrPartner) const |
Calculates a metric for how reachable (*this) is from a given partner. More... | |
CNetAddr (const struct in6_addr &pipv6Addr, const uint32_t scope=0) | |
bool | GetIn6Addr (struct in6_addr *pipv6Addr) const |
Try to get our IPv6 (or CJDNS) address. More... | |
bool | IsRelayable () const |
Whether this address should be relayed to other peers even if we can't reach it ourselves. More... | |
template<typename Stream > | |
void | Serialize (Stream &s) const |
Serialize to a stream. More... | |
template<typename Stream > | |
void | Unserialize (Stream &s) |
Unserialize from a stream. More... | |
Protected Attributes | |
uint16_t | port |
Protected Attributes inherited from CNetAddr | |
prevector< ADDR_IPV6_SIZE, uint8_t > | m_addr {ADDR_IPV6_SIZE, 0x0} |
Raw representation of the network address. More... | |
Network | m_net {NET_IPV6} |
Network to which this address belongs. More... | |
uint32_t | m_scope_id {0} |
Scope id if scoped/link-local IPV6 address. More... | |
Friends | |
class | CServiceHash |
bool | operator== (const CService &a, const CService &b) |
bool | operator!= (const CService &a, const CService &b) |
bool | operator< (const CService &a, const CService &b) |
CService | MaybeFlipIPv6toCJDNS (const CService &service) |
If an IPv6 address belongs to the address range used by the CJDNS network and the CJDNS network is reachable (-cjdnsreachable config is set), then change the type from NET_IPV6 to NET_CJDNS. More... | |
Additional Inherited Members | |
Public Types inherited from CNetAddr | |
enum class | Encoding { V1 , V2 } |
enum | BIP155Network : uint8_t { IPV4 = 1 , IPV6 = 2 , TORV2 = 3 , TORV3 = 4 , I2P = 5 , CJDNS = 6 } |
BIP155 network ids recognized by this software. More... | |
Static Public Attributes inherited from CNetAddr | |
static constexpr SerParams | V1 {Encoding::V1} |
static constexpr SerParams | V2 {Encoding::V2} |
A combination of a network address (CNetAddr) and a (TCP) port.
Definition at line 530 of file netaddress.h.
CService::CService | ( | ) |
CService::CService | ( | const CNetAddr & | ip, |
uint16_t | port | ||
) |
Definition at line 788 of file netaddress.cpp.
CService::CService | ( | const struct in_addr & | ipv4Addr, |
uint16_t | port | ||
) |
Definition at line 792 of file netaddress.cpp.
|
explicit |
CService::CService | ( | const struct in6_addr & | ipv6Addr, |
uint16_t | port | ||
) |
Definition at line 796 of file netaddress.cpp.
|
explicit |
std::vector< unsigned char > CService::GetKey | ( | ) | const |
Definition at line 897 of file netaddress.cpp.
uint16_t CService::GetPort | ( | ) | const |
sa_family_t CService::GetSAFamily | ( | ) | const |
Get the address family.
Definition at line 824 of file netaddress.cpp.
bool CService::GetSockAddr | ( | struct sockaddr * | paddr, |
socklen_t * | addrlen | ||
) | const |
Obtain the IPv4/6 socket address this represents.
[out] | paddr | The obtained socket address. |
[in,out] | addrlen | The size, in bytes, of the address structure pointed to by paddr. The value that's pointed to by this parameter might change after calling this function if the size of the corresponding address structure changed. |
Definition at line 864 of file netaddress.cpp.
|
inline |
bool CService::SetSockAddr | ( | const struct sockaddr * | paddr | ) |
Definition at line 810 of file netaddress.cpp.
std::string CService::ToStringAddrPort | ( | ) | const |
Definition at line 905 of file netaddress.cpp.
|
friend |
Definition at line 562 of file netaddress.h.
If an IPv6 address belongs to the address range used by the CJDNS network and the CJDNS network is reachable (-cjdnsreachable config is set), then change the type from NET_IPV6 to NET_CJDNS.
[in] | service | Address to potentially convert. |
service
either unmodified or changed to CJDNS. Definition at line 882 of file netbase.cpp.
Definition at line 549 of file netaddress.h.
Definition at line 847 of file netaddress.cpp.
Definition at line 842 of file netaddress.cpp.
|
protected |
Definition at line 533 of file netaddress.h.