Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96)) More...
#include <netaddress.h>
Public Member Functions | |
CNetAddr () | |
CNetAddr (const struct in_addr &ipv4Addr) | |
void | SetIP (const CNetAddr &ip) |
bool | SetInternal (const std::string &name) |
Transform an arbitrary string into a non-routable ipv6 address. More... | |
bool | SetSpecial (const std::string &strName) |
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 | IsRFC4862 () const |
bool | IsRFC6052 () const |
bool | IsRFC6145 () const |
bool | IsTor () const |
bool | IsLocal () const |
bool | IsRoutable () const |
bool | IsInternal () const |
bool | IsValid () const |
enum Network | GetNetwork () const |
std::string | ToString () const |
std::string | ToStringIP (bool fUseGetnameinfo=true) const |
unsigned int | GetByte (int n) const |
uint64_t | GetHash () const |
bool | GetInAddr (struct in_addr *pipv4Addr) const |
std::vector< unsigned char > | GetGroup () const |
int | GetReachabilityFrom (const CNetAddr *paddrPartner=nullptr) 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 |
template<typename Stream , typename Operation > | |
void | SerializationOp (Stream &s, Operation ser_action) |
Public Attributes | |
ADD_SERIALIZE_METHODS | |
Protected Attributes | |
unsigned char | ip [16] |
uint32_t | scopeId |
Private Member Functions | |
void | SetRaw (Network network, const uint8_t *data) |
Set raw IPv4 or IPv6 address (in network byte order) More... | |
Friends | |
class | CSubNet |
bool | operator== (const CNetAddr &a, const CNetAddr &b) |
bool | operator!= (const CNetAddr &a, const CNetAddr &b) |
bool | operator< (const CNetAddr &a, const CNetAddr &b) |
Detailed Description
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
Definition at line 33 of file netaddress.h.
Constructor & Destructor Documentation
◆ CNetAddr() [1/3]
CNetAddr::CNetAddr | ( | ) |
Definition at line 20 of file netaddress.cpp.
◆ CNetAddr() [2/3]
|
explicit |
Definition at line 73 of file netaddress.cpp.
◆ CNetAddr() [3/3]
|
explicit |
Definition at line 78 of file netaddress.cpp.
Member Function Documentation
◆ GetByte()
unsigned int CNetAddr::GetByte | ( | int | n | ) | const |
Definition at line 84 of file netaddress.cpp.
References ip.
Referenced by GetGroup(), IsLocal(), IsRFC1918(), IsRFC2544(), IsRFC3849(), IsRFC3927(), IsRFC3964(), IsRFC4193(), IsRFC4380(), IsRFC4843(), IsRFC5737(), IsRFC6598(), and ToStringIP().
◆ GetGroup()
std::vector< unsigned char > CNetAddr::GetGroup | ( | ) | const |
Definition at line 319 of file netaddress.cpp.
References g_internal_prefix, GetByte(), ip, IsInternal(), IsIPv4(), IsLocal(), IsRFC3964(), IsRFC4380(), IsRFC6052(), IsRFC6145(), IsRoutable(), IsTor(), NET_INTERNAL, NET_IPV4, NET_IPV6, NET_TOR, and NET_UNROUTABLE.
Referenced by CConnman::CalculateKeyedNetGroup(), CAddrInfo::GetNewBucket(), CAddrInfo::GetTriedBucket(), and CConnman::ThreadOpenConnections().
◆ GetHash()
uint64_t CNetAddr::GetHash | ( | ) | const |
Definition at line 392 of file netaddress.cpp.
References Hash(), ip, and memcpy().
Referenced by CAddrInfo::GetBucketPosition(), CAddrInfo::GetNewBucket(), CAddrInfo::GetTriedBucket(), and RelayAddress().
◆ GetIn6Addr()
bool CNetAddr::GetIn6Addr | ( | struct in6_addr * | pipv6Addr | ) | const |
Definition at line 311 of file netaddress.cpp.
Referenced by CService::GetSockAddr().
◆ GetInAddr()
bool CNetAddr::GetInAddr | ( | struct in_addr * | pipv4Addr | ) | const |
Definition at line 303 of file netaddress.cpp.
References ip, IsIPv4(), and memcpy().
Referenced by CService::GetSockAddr().
◆ GetNetwork()
enum Network CNetAddr::GetNetwork | ( | ) | const |
Definition at line 244 of file netaddress.cpp.
References IsInternal(), IsIPv4(), IsRoutable(), IsTor(), NET_INTERNAL, NET_IPV4, NET_IPV6, NET_TOR, and NET_UNROUTABLE.
Referenced by CConnman::ConnectNode(), GetExtNetwork(), IsLimited(), IsPeerAddrLocalGood(), and IsReachable().
◆ GetReachabilityFrom()
int CNetAddr::GetReachabilityFrom | ( | const CNetAddr * | paddrPartner = nullptr | ) | const |
Calculates a metric for how reachable (*this) is from a given partner.
Definition at line 414 of file netaddress.cpp.
References GetExtNetwork(), IsInternal(), IsRFC3964(), IsRFC6052(), IsRFC6145(), IsRoutable(), NET_IPV4, NET_IPV6, NET_TEREDO, NET_TOR, NET_UNKNOWN, and NET_UNROUTABLE.
◆ IsInternal()
bool CNetAddr::IsInternal | ( | ) | const |
Definition at line 239 of file netaddress.cpp.
References g_internal_prefix, and ip.
Referenced by GetGroup(), GetNetwork(), GetReachabilityFrom(), IsIPv6(), IsRoutable(), IsValid(), LookupIntern(), ToStringIP(), and CService::ToStringIPPort().
◆ IsIPv4()
bool CNetAddr::IsIPv4 | ( | ) | const |
Definition at line 89 of file netaddress.cpp.
Referenced by CSubNet::CSubNet(), GetGroup(), GetInAddr(), CActiveMasternodeManager::GetLocalAddress(), GetNetwork(), CService::GetSockAddr(), IsIPv6(), IsLocal(), IsRFC1918(), IsRFC2544(), IsRFC3927(), IsRFC5737(), IsRFC6598(), IsValid(), CActiveMasternodeManager::IsValidNetAddr(), CSubNet::ToString(), ToStringIP(), and CService::ToStringIPPort().
◆ IsIPv6()
bool CNetAddr::IsIPv6 | ( | ) | const |
Definition at line 94 of file netaddress.cpp.
References IsInternal(), IsIPv4(), and IsTor().
Referenced by CConnman::BindListenPort(), and CService::GetSockAddr().
◆ IsLocal()
bool CNetAddr::IsLocal | ( | ) | const |
Definition at line 177 of file netaddress.cpp.
References GetByte(), ip, and IsIPv4().
Referenced by GetGroup(), IsRoutable(), and SendRejectsAndCheckIfBanned().
◆ IsRFC1918()
bool CNetAddr::IsRFC1918 | ( | ) | const |
Definition at line 99 of file netaddress.cpp.
References GetByte(), and IsIPv4().
Referenced by IsRoutable().
◆ IsRFC2544()
bool CNetAddr::IsRFC2544 | ( | ) | const |
Definition at line 107 of file netaddress.cpp.
References GetByte(), and IsIPv4().
Referenced by IsRoutable().
◆ IsRFC3849()
bool CNetAddr::IsRFC3849 | ( | ) | const |
◆ IsRFC3927()
bool CNetAddr::IsRFC3927 | ( | ) | const |
Definition at line 112 of file netaddress.cpp.
References GetByte(), and IsIPv4().
Referenced by IsRoutable().
◆ IsRFC3964()
bool CNetAddr::IsRFC3964 | ( | ) | const |
Definition at line 134 of file netaddress.cpp.
References GetByte().
Referenced by GetGroup(), and GetReachabilityFrom().
◆ IsRFC4193()
bool CNetAddr::IsRFC4193 | ( | ) | const |
◆ IsRFC4380()
bool CNetAddr::IsRFC4380 | ( | ) | const |
Definition at line 145 of file netaddress.cpp.
References GetByte().
Referenced by GetExtNetwork(), and GetGroup().
◆ IsRFC4843()
bool CNetAddr::IsRFC4843 | ( | ) | const |
◆ IsRFC4862()
bool CNetAddr::IsRFC4862 | ( | ) | const |
◆ IsRFC5737()
bool CNetAddr::IsRFC5737 | ( | ) | const |
Definition at line 122 of file netaddress.cpp.
References GetByte(), and IsIPv4().
Referenced by IsRoutable().
◆ IsRFC6052()
bool CNetAddr::IsRFC6052 | ( | ) | const |
Definition at line 139 of file netaddress.cpp.
References ip.
Referenced by GetGroup(), and GetReachabilityFrom().
◆ IsRFC6145()
bool CNetAddr::IsRFC6145 | ( | ) | const |
Definition at line 161 of file netaddress.cpp.
References ip.
Referenced by GetGroup(), and GetReachabilityFrom().
◆ IsRFC6598()
bool CNetAddr::IsRFC6598 | ( | ) | const |
Definition at line 117 of file netaddress.cpp.
References GetByte(), and IsIPv4().
Referenced by IsRoutable().
◆ IsRoutable()
bool CNetAddr::IsRoutable | ( | ) | const |
Definition at line 230 of file netaddress.cpp.
References fAllowPrivateNet, IsInternal(), IsLocal(), IsRFC1918(), IsRFC2544(), IsRFC3927(), IsRFC4193(), IsRFC4843(), IsRFC4862(), IsRFC5737(), IsRFC6598(), IsTor(), and IsValid().
Referenced by CAddrMan::Add_(), AddLocal(), AdvertiseLocal(), CConnman::BindListenPort(), GetGroup(), GetNetwork(), GetReachabilityFrom(), IsPeerAddrLocalGood(), CActiveMasternodeManager::IsValidNetAddr(), and ProcessMessage().
◆ IsTor()
bool CNetAddr::IsTor | ( | ) | const |
Definition at line 172 of file netaddress.cpp.
References ip, and pchOnionCat.
Referenced by GetGroup(), GetNetwork(), IsIPv6(), IsRoutable(), ToStringIP(), and CService::ToStringIPPort().
◆ IsValid()
bool CNetAddr::IsValid | ( | ) | const |
Definition at line 191 of file netaddress.cpp.
References ip, IsInternal(), IsIPv4(), IsRFC3849(), and pchIPv4.
Referenced by AppInitMain(), ClientAllowed(), CConnman::ConnectNode(), CNode::copyStats(), TorController::disconnected_cb(), CConnman::GetAddedNodeInfo(), IsRoutable(), proxyType::IsValid(), CSubNet::Match(), CNode::PushAddress(), setban(), CConnman::ThreadOpenConnections(), and TorController::~TorController().
◆ SerializationOp()
|
inline |
Definition at line 98 of file netaddress.h.
◆ SetInternal()
bool CNetAddr::SetInternal | ( | const std::string & | name | ) |
Transform an arbitrary string into a non-routable ipv6 address.
Useful for mapping resolved addresses back to their source.
Definition at line 47 of file netaddress.cpp.
References g_internal_prefix, ip, memcpy(), name, and CSHA256::Write().
Referenced by CConnman::ThreadDNSAddressSeed(), and CConnman::ThreadOpenConnections().
◆ SetIP()
void CNetAddr::SetIP | ( | const CNetAddr & | ip | ) |
Definition at line 26 of file netaddress.cpp.
Referenced by AdvertiseLocal(), and ProcessMessage().
◆ SetRaw()
|
private |
Set raw IPv4 or IPv6 address (in network byte order)
- Note
- Only NET_IPV4 and NET_IPV6 are allowed for network.
Definition at line 31 of file netaddress.cpp.
References ip, memcpy(), NET_IPV4, NET_IPV6, and pchIPv4.
Referenced by CNetAddr().
◆ SetSpecial()
bool CNetAddr::SetSpecial | ( | const std::string & | strName | ) |
Definition at line 59 of file netaddress.cpp.
References DecodeBase32(), ip, memcpy(), and pchOnionCat.
Referenced by LookupIntern().
◆ ToString()
std::string CNetAddr::ToString | ( | ) | const |
Definition at line 288 of file netaddress.cpp.
References ToStringIP().
Referenced by CAddrMan::Add(), Discover(), and CSubNet::ToString().
◆ ToStringIP()
std::string CNetAddr::ToStringIP | ( | bool | fUseGetnameinfo = true | ) | const |
Definition at line 261 of file netaddress.cpp.
References EncodeBase32(), g_internal_prefix, GetByte(), CService::GetSockAddr(), ip, IsInternal(), IsIPv4(), IsTor(), name, and strprintf.
Referenced by CConnman::ConnectNode(), OptionsModel::getProxySettings(), ToString(), CService::ToStringIPPort(), and OptionsDialog::updateDefaultProxyNets().
Friends And Related Function Documentation
◆ CSubNet
|
friend |
Definition at line 102 of file netaddress.h.
◆ operator!=
Definition at line 92 of file netaddress.h.
◆ operator<
Definition at line 298 of file netaddress.cpp.
◆ operator==
Definition at line 293 of file netaddress.cpp.
Member Data Documentation
◆ ADD_SERIALIZE_METHODS
CNetAddr::ADD_SERIALIZE_METHODS |
Definition at line 95 of file netaddress.h.
◆ ip
|
protected |
Definition at line 36 of file netaddress.h.
Referenced by CNetAddr(), CSubNet::CSubNet(), GetByte(), GetGroup(), GetHash(), GetIn6Addr(), GetInAddr(), CService::GetKey(), IsInternal(), IsIPv4(), IsLocal(), IsRFC4862(), IsRFC6052(), IsRFC6145(), IsTor(), IsValid(), CSubNet::Match(), operator<(), operator==(), SerializationOp(), CService::SerializationOp(), SetInternal(), SetIP(), SetRaw(), SetSpecial(), and ToStringIP().
◆ scopeId
|
protected |
Definition at line 37 of file netaddress.h.
Referenced by CNetAddr(), and CService::GetSockAddr().
The documentation for this class was generated from the following files:
- src/netaddress.h
- src/netaddress.cpp