aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp26
1 files changed, 0 insertions, 26 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 2b300e5dd3..ec275f738c 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -78,11 +78,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
aiHint.ai_socktype = SOCK_STREAM;
aiHint.ai_protocol = IPPROTO_TCP;
-#ifdef USE_IPV6
aiHint.ai_family = AF_UNSPEC;
-#else
- aiHint.ai_family = AF_INET;
-#endif
#ifdef WIN32
aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST;
#else
@@ -102,13 +98,11 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
vIP.push_back(CNetAddr(((struct sockaddr_in*)(aiTrav->ai_addr))->sin_addr));
}
-#ifdef USE_IPV6
if (aiTrav->ai_family == AF_INET6)
{
assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in6));
vIP.push_back(CNetAddr(((struct sockaddr_in6*)(aiTrav->ai_addr))->sin6_addr));
}
-#endif
aiTrav = aiTrav->ai_next;
}
@@ -321,11 +315,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
{
hSocketRet = INVALID_SOCKET;
-#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
-#else
- struct sockaddr sockaddr;
-#endif
socklen_t len = sizeof(sockaddr);
if (!addrConnect.GetSockAddr((struct sockaddr*)&sockaddr, &len)) {
LogPrintf("Cannot connect to %s: unsupported network\n", addrConnect.ToString());
@@ -585,12 +575,10 @@ CNetAddr::CNetAddr(const struct in_addr& ipv4Addr)
memcpy(ip+12, &ipv4Addr, 4);
}
-#ifdef USE_IPV6
CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr)
{
memcpy(ip, &ipv6Addr, 16);
}
-#endif
CNetAddr::CNetAddr(const char *pszIp, bool fAllowLookup)
{
@@ -764,11 +752,7 @@ std::string CNetAddr::ToStringIP() const
if (IsTor())
return EncodeBase32(&ip[6], 10) + ".onion";
CService serv(*this, 0);
-#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
-#else
- struct sockaddr sockaddr;
-#endif
socklen_t socklen = sizeof(sockaddr);
if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) {
char name[1025] = "";
@@ -813,13 +797,11 @@ bool CNetAddr::GetInAddr(struct in_addr* pipv4Addr) const
return true;
}
-#ifdef USE_IPV6
bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const
{
memcpy(pipv6Addr, ip, 16);
return true;
}
-#endif
// get canonical identifier of an address' group
// no two connections will be attempted to addresses with the same group
@@ -993,23 +975,19 @@ CService::CService(const struct in_addr& ipv4Addr, unsigned short portIn) : CNet
{
}
-#ifdef USE_IPV6
CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn)
{
}
-#endif
CService::CService(const struct sockaddr_in& addr) : CNetAddr(addr.sin_addr), port(ntohs(addr.sin_port))
{
assert(addr.sin_family == AF_INET);
}
-#ifdef USE_IPV6
CService::CService(const struct sockaddr_in6 &addr) : CNetAddr(addr.sin6_addr), port(ntohs(addr.sin6_port))
{
assert(addr.sin6_family == AF_INET6);
}
-#endif
bool CService::SetSockAddr(const struct sockaddr *paddr)
{
@@ -1017,11 +995,9 @@ bool CService::SetSockAddr(const struct sockaddr *paddr)
case AF_INET:
*this = CService(*(const struct sockaddr_in*)paddr);
return true;
-#ifdef USE_IPV6
case AF_INET6:
*this = CService(*(const struct sockaddr_in6*)paddr);
return true;
-#endif
default:
return false;
}
@@ -1093,7 +1069,6 @@ bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const
paddrin->sin_port = htons(port);
return true;
}
-#ifdef USE_IPV6
if (IsIPv6()) {
if (*addrlen < (socklen_t)sizeof(struct sockaddr_in6))
return false;
@@ -1106,7 +1081,6 @@ bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const
paddrin6->sin6_port = htons(port);
return true;
}
-#endif
return false;
}