4 #ifndef BITCOIN_NETBASE_H
5 #define BITCOIN_NETBASE_H
41 CNetAddr(
const struct in_addr& ipv4Addr);
42 explicit CNetAddr(
const char *pszIp,
bool fAllowLookup =
false);
43 explicit CNetAddr(
const std::string &strIp,
bool fAllowLookup =
false);
67 unsigned int GetByte(
int n)
const;
69 bool GetInAddr(
struct in_addr* pipv4Addr)
const;
70 std::vector<unsigned char>
GetGroup()
const;
75 CNetAddr(
const struct in6_addr& pipv6Addr);
76 bool GetIn6Addr(
struct in6_addr* pipv6Addr)
const;
98 CService(
const struct in_addr& ipv4Addr,
unsigned short port);
99 CService(
const struct sockaddr_in& addr);
100 explicit CService(
const char *pszIpPort,
int portDefault,
bool fAllowLookup =
false);
101 explicit CService(
const char *pszIpPort,
bool fAllowLookup =
false);
102 explicit CService(
const std::string& strIpPort,
int portDefault,
bool fAllowLookup =
false);
103 explicit CService(
const std::string& strIpPort,
bool fAllowLookup =
false);
105 void SetPort(
unsigned short portIn);
106 unsigned short GetPort()
const;
107 bool GetSockAddr(
struct sockaddr* paddr, socklen_t *addrlen)
const;
108 bool SetSockAddr(
const struct sockaddr* paddr);
112 std::vector<unsigned char> GetKey()
const;
114 std::string ToStringPort()
const;
115 std::string ToStringIPPort()
const;
119 CService(
const struct in6_addr& ipv6Addr,
unsigned short port);
120 CService(
const struct sockaddr_in6& addr);
125 CService* pthis = const_cast<CService*>(
this);
127 unsigned short portN = htons(port);
130 pthis->port = ntohs(portN);
137 void SplitHostPort(std::string in,
int &portOut, std::string &hostOut);
143 bool LookupHost(
const char *pszName, std::vector<CNetAddr>& vIP,
unsigned int nMaxSolutions = 0,
bool fAllowLookup =
true);
144 bool LookupHostNumeric(
const char *pszName, std::vector<CNetAddr>& vIP,
unsigned int nMaxSolutions = 0);
145 bool Lookup(
const char *pszName,
CService& addr,
int portDefault = 0,
bool fAllowLookup =
true);
146 bool Lookup(
const char *pszName, std::vector<CService>& vAddr,
int portDefault = 0,
bool fAllowLookup =
true,
unsigned int nMaxSolutions = 0);
void SetIP(const CNetAddr &ip)
bool Lookup(const char *pszName, CService &addr, int portDefault=0, bool fAllowLookup=true)
std::string ToStringIP() const
enum Network ParseNetwork(std::string net)
bool LookupNumeric(const char *pszName, CService &addr, int portDefault=0)
#define IMPLEMENT_SERIALIZE(statements)
unsigned long long uint64
unsigned int GetByte(int n) const
bool IsProxy(const CNetAddr &addr)
friend bool operator!=(const CNetAddr &a, const CNetAddr &b)
bool LookupHostNumeric(const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions=0)
int GetReachabilityFrom(const CNetAddr *paddrPartner=NULL) const
Calculates a metric for how reachable (*this) is from a given partner.
void SplitHostPort(std::string in, int &portOut, std::string &hostOut)
bool SetProxy(enum Network net, CService addrProxy, int nSocksVersion=5)
A combination of a network address (CNetAddr) and a (TCP) port.
bool ConnectSocketByName(CService &addr, SOCKET &hSocketRet, const char *pszDest, int portDefault=0, int nTimeout=nConnectTimeout)
bool GetInAddr(struct in_addr *pipv4Addr) const
std::vector< unsigned char > GetGroup() const
bool SetNameProxy(CService addrProxy, int nSocksVersion=5)
bool ConnectSocket(const CService &addr, SOCKET &hSocketRet, int nTimeout=nConnectTimeout)
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
friend bool operator<(const CNetAddr &a, const CNetAddr &b)
friend bool operator==(const CNetAddr &a, const CNetAddr &b)
std::pair< CService, int > proxyType
bool SetSpecial(const std::string &strName)
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
bool LookupHost(const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions=0, bool fAllowLookup=true)
std::string ToString() const
enum Network GetNetwork() const