6 #ifndef ANONCOIN_NETBASE_H
7 #define ANONCOIN_NETBASE_H
9 #if defined(HAVE_CONFIG_H)
54 CNetAddr(
const struct in_addr& ipv4Addr);
55 explicit CNetAddr(
const char *pszIp,
bool fAllowLookup =
false);
56 explicit CNetAddr(
const std::string &strIp,
bool fAllowLookup =
false);
80 unsigned int GetByte(
int n)
const;
82 bool GetInAddr(
struct in_addr* pipv4Addr)
const;
83 std::vector<unsigned char>
GetGroup()
const;
87 bool IsNativeI2P()
const;
88 std::string GetI2PDestination()
const;
90 CNetAddr(
const struct in6_addr& pipv6Addr);
91 bool GetIn6Addr(
struct in6_addr* pipv6Addr)
const;
101 if (!(nType & SER_IPADDRONLY)) {
117 CService(
const struct in_addr& ipv4Addr,
unsigned short port);
118 CService(
const struct sockaddr_in& addr);
119 explicit CService(
const char *pszIpPort,
int portDefault,
bool fAllowLookup =
false);
120 explicit CService(
const char *pszIpPort,
bool fAllowLookup =
false);
121 explicit CService(
const std::string& strIpPort,
int portDefault,
bool fAllowLookup =
false);
122 explicit CService(
const std::string& strIpPort,
bool fAllowLookup =
false);
124 void SetPort(
unsigned short portIn);
125 unsigned short GetPort()
const;
126 bool GetSockAddr(
struct sockaddr* paddr, socklen_t *addrlen)
const;
127 bool SetSockAddr(
const struct sockaddr* paddr);
131 std::vector<unsigned char> GetKey()
const;
133 std::string ToStringPort()
const;
134 std::string ToStringIPPort()
const;
136 std::string ToStringI2pPort()
const;
140 CService(
const struct in6_addr& ipv6Addr,
unsigned short port);
141 CService(
const struct sockaddr_in6& addr);
145 CService* pthis = const_cast<CService*>(
this);
148 if (!(nType & SER_IPADDRONLY)) {
152 unsigned short portN = htons(port);
155 pthis->port = ntohs(portN);
163 void SplitHostPort(std::string in,
int &portOut, std::string &hostOut);
169 bool LookupHost(
const char *pszName, std::vector<CNetAddr>& vIP,
unsigned int nMaxSolutions = 0,
bool fAllowLookup =
true);
170 bool LookupHostNumeric(
const char *pszName, std::vector<CNetAddr>& vIP,
unsigned int nMaxSolutions = 0);
171 bool Lookup(
const char *pszName,
CService& addr,
int portDefault = 0,
bool fAllowLookup =
true);
172 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
bool GetIn6Addr(struct in6_addr *pipv6Addr) const
enum Network ParseNetwork(std::string net)
bool LookupNumeric(const char *pszName, CService &addr, int portDefault=0)
#define IMPLEMENT_SERIALIZE(statements)
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)
A combination of a network address (CNetAddr) and a (TCP) port.
#define NATIVE_I2P_DESTINATION_SIZE
bool ConnectSocketByName(CService &addr, SOCKET &hSocketRet, const char *pszDest, int portDefault=0, int nTimeout=nConnectTimeout)
bool SetProxy(enum Network net, CService addrProxy)
bool GetInAddr(struct in_addr *pipv4Addr) const
std::vector< unsigned char > GetGroup() const
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)
bool SetNameProxy(CService addrProxy)
friend bool operator==(const CNetAddr &a, const CNetAddr &b)
std::string GetNetworkName(enum Network net)
bool SetSpecial(const std::string &strName)
Returns TRUE if the address name can be looked up and resolved.
std::string NetworkErrorString(int err)
Return readable error string for a network error code.
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