Bitcoin Core  0.18.99
P2P Digital Currency
Public Member Functions | Public Attributes | Protected Attributes | Friends | List of all members
CService Class Reference

A combination of a network address (CNetAddr) and a (TCP) port. More...

#include <netaddress.h>

Inheritance diagram for CService:
[legend]
Collaboration diagram for CService:
[legend]

Public Member Functions

 CService ()
 
 CService (const CNetAddr &ip, unsigned short port)
 
 CService (const struct in_addr &ipv4Addr, unsigned short port)
 
 CService (const struct sockaddr_in &addr)
 
unsigned short 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)
 
std::vector< unsigned char > GetKey () const
 
std::string ToString () const
 
std::string ToStringPort () const
 
std::string ToStringIPPort () const
 
 CService (const struct in6_addr &ipv6Addr, unsigned short port)
 
 CService (const struct sockaddr_in6 &addr)
 
template<typename Stream , typename Operation >
void SerializationOp (Stream &s, Operation ser_action)
 
- 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)
 
bool SetInternal (const std::string &name)
 Try to make this a dummy address that maps the specified name into IPv6 like so: (0xFD + sha256("bitcoin")[0:5]) + sha256(name)[0:10]. More...
 
bool SetSpecial (const std::string &strName)
 Try to make this a dummy address that maps the specified onion address into IPv6 using OnionCat's range and encoding. 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 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 () const
 
unsigned int GetByte (int n) const
 
uint64_t GetHash () const
 
bool GetInAddr (struct in_addr *pipv4Addr) const
 Try to get our IPv4 address. More...
 
std::vector< unsigned char > GetGroup () const
 Get the canonical identifier of our network group. More...
 
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
 Try to get our IPv6 address. More...
 
template<typename Stream , typename Operation >
void SerializationOp (Stream &s, Operation ser_action)
 

Public Attributes

 ADD_SERIALIZE_METHODS
 
- Public Attributes inherited from CNetAddr
 ADD_SERIALIZE_METHODS
 

Protected Attributes

uint16_t port
 
- Protected Attributes inherited from CNetAddr
unsigned char ip [16]
 
uint32_t scopeId {0}
 

Friends

bool operator== (const CService &a, const CService &b)
 
bool operator!= (const CService &a, const CService &b)
 
bool operator< (const CService &a, const CService &b)
 

Detailed Description

A combination of a network address (CNetAddr) and a (TCP) port.

Definition at line 140 of file netaddress.h.

Constructor & Destructor Documentation

◆ CService() [1/6]

CService::CService ( )

Definition at line 569 of file netaddress.cpp.

Here is the caller graph for this function:

◆ CService() [2/6]

CService::CService ( const CNetAddr ip,
unsigned short  port 
)

Definition at line 573 of file netaddress.cpp.

◆ CService() [3/6]

CService::CService ( const struct in_addr &  ipv4Addr,
unsigned short  port 
)

Definition at line 577 of file netaddress.cpp.

◆ CService() [4/6]

CService::CService ( const struct sockaddr_in &  addr)
explicit

Definition at line 585 of file netaddress.cpp.

◆ CService() [5/6]

CService::CService ( const struct in6_addr &  ipv6Addr,
unsigned short  port 
)

Definition at line 581 of file netaddress.cpp.

◆ CService() [6/6]

CService::CService ( const struct sockaddr_in6 &  addr)
explicit

Definition at line 590 of file netaddress.cpp.

Member Function Documentation

◆ GetKey()

std::vector< unsigned char > CService::GetKey ( ) const
Returns
An identifier unique to this service's address and port number.

Definition at line 669 of file netaddress.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPort()

unsigned short CService::GetPort ( ) const

Definition at line 609 of file netaddress.cpp.

Here is the caller graph for this function:

◆ GetSockAddr()

bool CService::GetSockAddr ( struct sockaddr *  paddr,
socklen_t *  addrlen 
) const

Obtain the IPv4/6 socket address this represents.

Parameters
[out]paddrThe obtained socket address.
[in,out]addrlenThe 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.
Returns
Whether or not the operation was successful.

Definition at line 636 of file netaddress.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SerializationOp()

template<typename Stream , typename Operation >
void CService::SerializationOp ( Stream &  s,
Operation  ser_action 
)
inline

Definition at line 167 of file netaddress.h.

Here is the call graph for this function:

◆ SetSockAddr()

bool CService::SetSockAddr ( const struct sockaddr *  paddr)

Definition at line 595 of file netaddress.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToString()

std::string CService::ToString ( ) const

Definition at line 693 of file netaddress.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToStringIPPort()

std::string CService::ToStringIPPort ( ) const

Definition at line 684 of file netaddress.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToStringPort()

std::string CService::ToStringPort ( ) const

Definition at line 679 of file netaddress.cpp.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const CService a,
const CService b 
)
friend

Definition at line 154 of file netaddress.h.

◆ operator<

bool operator< ( const CService a,
const CService b 
)
friend

Definition at line 619 of file netaddress.cpp.

◆ operator==

bool operator== ( const CService a,
const CService b 
)
friend

Definition at line 614 of file netaddress.cpp.

Member Data Documentation

◆ ADD_SERIALIZE_METHODS

CService::ADD_SERIALIZE_METHODS

Definition at line 164 of file netaddress.h.

◆ port

uint16_t CService::port
protected

Definition at line 143 of file netaddress.h.


The documentation for this class was generated from the following files: