summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-01 15:08:09 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-01 15:08:09 +0000
commit248a14477c435ef28b71df42080ec931b1003e3f (patch)
tree0a774b72a92e2fe3581e75db2173a72151023bbe
parent5ad936b13f317cb277bf03c19e9734d931b1bd00 (diff)
Remove unneeded #ifdef IPV6 lines
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11582 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/dns.h3
-rw-r--r--include/inspsocket.h2
-rw-r--r--include/modules.h14
-rw-r--r--src/dns.cpp8
-rw-r--r--src/inspsocket.cpp20
-rw-r--r--src/modules/m_spanningtree/main.cpp2
-rw-r--r--src/modules/m_spanningtree/utils.cpp8
-rw-r--r--src/socket.cpp22
-rw-r--r--src/threadengines/threadengine_win32.cpp17
-rw-r--r--src/user_resolver.cpp7
10 files changed, 22 insertions, 81 deletions
diff --git a/include/dns.h b/include/dns.h
index 3682bbe1d..a780505d0 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -358,12 +358,11 @@ class CoreExport DNS : public EventHandler
*/
int socketfamily;
-#ifdef IPV6
/**
* IPV6 server address
*/
in6_addr myserver6;
-#endif
+
/**
* IPV4 server address
*/
diff --git a/include/inspsocket.h b/include/inspsocket.h
index 66ea48eb3..32f2dab1a 100644
--- a/include/inspsocket.h
+++ b/include/inspsocket.h
@@ -173,7 +173,7 @@ class CoreExport BufferedSocket : public EventHandler
/** (really) Try bind to a given IP setup. For internal use only.
*/
- bool DoBindMagic(const std::string &current_ip, bool v6);
+ bool DoBindMagic(const std::string &current_ip);
/**
* The default constructor does nothing
diff --git a/include/modules.h b/include/modules.h
index 932ef3d19..f6678e931 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -76,18 +76,8 @@ enum MessageType {
MSG_NOTICE = 1
};
-/** If you change the module API, change this value.
- * If you have enabled ipv6, the sizes of structs is
- * different, and modules will be incompatible with
- * ipv4 servers, so this value will be ten times as
- * high on ipv6 servers.
- */
-#define NATIVE_API_VERSION 12000
-#ifdef IPV6
-#define API_VERSION (NATIVE_API_VERSION * 10)
-#else
-#define API_VERSION (NATIVE_API_VERSION * 1)
-#endif
+/** If you change the module API, change this value. */
+#define API_VERSION 13000
class ServerConfig;
diff --git a/src/dns.cpp b/src/dns.cpp
index 396cc56df..5af3fd198 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -217,7 +217,6 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp
DNS::EmptyHeader(payload,header,length);
-#ifdef IPV6
if (this->dnsobj->socketfamily == AF_INET6)
{
sockaddr_in6 addr;
@@ -229,7 +228,6 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp
return -1;
}
else
-#endif
{
sockaddr_in addr;
memset(&addr,0,sizeof(addr));
@@ -334,7 +332,6 @@ void DNS::Rehash()
}
this->socketfamily = AF_INET;
-#ifdef IPV6
if (strchr(ServerInstance->Config->DNSServer,':'))
{
this->socketfamily = AF_INET6;
@@ -345,9 +342,6 @@ void DNS::Rehash()
inet_aton(ServerInstance->Config->DNSServer, &this->myserver4);
portpass = -1;
}
-#else
- inet_aton(ServerInstance->Config->DNSServer, &this->myserver4);
-#endif
/* Initialize mastersocket */
int s = irc::sockets::OpenTCPSocket(ServerInstance->Config->DNSServer, SOCK_DGRAM);
@@ -602,7 +596,6 @@ DNSResult DNS::GetResult()
*
* -- Thanks jilles for pointing this one out.
*/
-#ifdef IPV6
char nbuf[MAXBUF];
if (this->socketfamily == AF_INET6)
{
@@ -610,7 +603,6 @@ DNSResult DNS::GetResult()
port_from = ntohs(from.in6.sin6_port);
}
else
-#endif
{
ipaddr_from = inet_ntoa(from.in4.sin_addr);
port_from = ntohs(from.in4.sin_port);
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index e42990a74..258dd4472 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -89,7 +89,7 @@ void BufferedSocket::SetQueues()
}
}
-bool BufferedSocket::DoBindMagic(const std::string &current_ip, bool v6)
+bool BufferedSocket::DoBindMagic(const std::string &current_ip)
{
irc::sockets::sockaddrs s;
if (!irc::sockets::aptosa(current_ip.c_str(), 0, &s))
@@ -119,18 +119,12 @@ bool BufferedSocket::DoBindMagic(const std::string &current_ip, bool v6)
bool BufferedSocket::BindAddr(const std::string &ip_to_bind)
{
ConfigReader Conf(this->ServerInstance);
- bool v6 = false;
// Case one: If they provided an IP, try bind it
if (!ip_to_bind.empty())
{
-#ifdef IPV6
- // Check whether or not they are binding to an IPv6 IP..
- if (ip_to_bind.find(':') != std::string::npos)
- v6 = true;
-#endif
// And if it fails, don't do anything.
- return this->DoBindMagic(ip_to_bind, v6);
+ return this->DoBindMagic(ip_to_bind);
}
for (int j = 0; j < Conf.Enumerate("bind"); j++)
@@ -142,20 +136,12 @@ bool BufferedSocket::BindAddr(const std::string &ip_to_bind)
// set current IP to the <bind> tag
std::string current_ip = Conf.ReadValue("bind","address",j);
-#ifdef IPV6
- // Check whether this <bind> is for an ipv6 address
- if (current_ip.find(':') != std::string::npos)
- v6 = true;
- else
- v6 = false;
-#endif
-
// Make sure IP is nothing local
if (current_ip == "*" || current_ip == "127.0.0.1" || current_ip.empty() || current_ip == "::1")
continue;
// Try bind, don't fail if it doesn't bind though.
- if (this->DoBindMagic(current_ip, v6))
+ if (this->DoBindMagic(current_ip))
return true;
}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 94f084125..9e8fa7035 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -259,7 +259,6 @@ void ModuleSpanningTree::ConnectServer(Link* x)
}
QueryType start_type = DNS_QUERY_A;
-#ifdef IPV6
start_type = DNS_QUERY_AAAA;
if (strchr(x->IPAddr.c_str(),':'))
{
@@ -268,7 +267,6 @@ void ModuleSpanningTree::ConnectServer(Link* x)
ipvalid = false;
}
else
-#endif
{
in_addr n;
if (inet_aton(x->IPAddr.c_str(),&n) < 1)
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index ee12712b8..e527cd2da 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -405,7 +405,6 @@ void SpanningTreeUtilities::RefreshIPCache()
/* Needs resolving */
bool ipvalid = true;
QueryType start_type = DNS_QUERY_A;
-#ifdef IPV6
start_type = DNS_QUERY_AAAA;
if (strchr(L->IPAddr.c_str(),':'))
{
@@ -414,7 +413,6 @@ void SpanningTreeUtilities::RefreshIPCache()
ipvalid = false;
}
else
-#endif
{
in_addr n;
if (inet_aton(L->IPAddr.c_str(),&n) < 1)
@@ -571,7 +569,6 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
/* Needs resolving */
bool ipvalid = true;
QueryType start_type = DNS_QUERY_A;
-#ifdef IPV6
start_type = DNS_QUERY_AAAA;
if (strchr(L.IPAddr.c_str(),':'))
{
@@ -585,11 +582,6 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
if (inet_aton(L.IPAddr.c_str(),&n) < 1)
ipvalid = false;
}
-#else
- in_addr n;
- if (inet_aton(L.IPAddr.c_str(),&n) < 1)
- ipvalid = false;
-#endif
if (!ipvalid)
{
diff --git a/src/socket.cpp b/src/socket.cpp
index 4d3509836..3b0c63931 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -36,7 +36,6 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
}
else
{
-#ifdef IPV6
if (port == -1)
{
/* Port -1: Means UDP IPV4 port binding - Special case
@@ -48,17 +47,19 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
}
else
{
- /* There's no address here, default to ipv6 bind to all */
+ /* No address */
+#ifdef IPV6
+ /* Default to ipv6 bind to all */
servaddr.in6.sin6_family = AF_INET6;
servaddr.in6.sin6_port = htons(port);
memset(&servaddr.in6.sin6_addr, 0, sizeof(servaddr.in6.sin6_addr));
- }
#else
- /* Bind ipv4 to all */
- servaddr.in4.sin_family = AF_INET;
- servaddr.in4.sin_addr.s_addr = htonl(INADDR_ANY);
- servaddr.in4.sin_port = htons(port);
+ /* Bind ipv4 to all */
+ servaddr.in4.sin_family = AF_INET;
+ servaddr.in4.sin_addr.s_addr = htonl(INADDR_ANY);
+ servaddr.in4.sin_port = htons(port);
#endif
+ }
}
ret = SE->Bind(sockfd, &servaddr.sa, sizeof(servaddr));
@@ -97,21 +98,20 @@ int irc::sockets::OpenTCPSocket(const char* addr, int socktype)
int on = 1;
addr = addr;
struct linger linger = { 0, 0 };
-#ifdef IPV6
if (!*addr)
{
+#ifdef IPV6
sockfd = socket (PF_INET6, socktype, 0);
if (sockfd < 0)
+#endif
sockfd = socket (PF_INET, socktype, 0);
}
else if (strchr(addr,':'))
sockfd = socket (PF_INET6, socktype, 0);
else
sockfd = socket (PF_INET, socktype, 0);
+
if (sockfd < 0)
-#else
- if ((sockfd = socket (PF_INET, socktype, 0)) < 0)
-#endif
{
return ERROR;
}
diff --git a/src/threadengines/threadengine_win32.cpp b/src/threadengines/threadengine_win32.cpp
index 361d25cc4..2676bc6f6 100644
--- a/src/threadengines/threadengine_win32.cpp
+++ b/src/threadengines/threadengine_win32.cpp
@@ -75,7 +75,7 @@ class ThreadSignalSocket : public BufferedSocket
class ThreadSignalListener : public ListenSocketBase
{
SocketThread* parent;
- irc::sockets::insp_sockaddr sock_us;
+ sockaddr_in sock_us;
public:
ThreadSignalListener(SocketThread* t, InspIRCd* Instance, int port, const std::string &addr) : ListenSocketBase(Instance, port, addr), parent(t)
{
@@ -94,11 +94,7 @@ class ThreadSignalListener : public ListenSocketBase
/* Using getsockname and ntohs, we can determine which port number we were allocated */
int GetPort()
{
-#ifdef IPV6
- return ntohs(sock_us.sin6_port);
-#else
return ntohs(sock_us.sin_port);
-#endif
}
};
@@ -111,17 +107,10 @@ SocketThread::SocketThread(InspIRCd* SI)
if (connFD == -1)
throw CoreException("Could not create ITC pipe");
- irc::sockets::insp_sockaddr addr;
-
-#ifdef IPV6
- irc::sockets::insp_aton("::1", &addr.sin6_addr);
- addr.sin6_family = AF_INET6;
- addr.sin6_port = htons(listener->GetPort());
-#else
- irc::sockets::insp_aton("127.0.0.1", &addr.sin_addr);
+ struct sockaddr_in addr;
+ inet_aton("127.0.0.1", &addr.sin_addr);
addr.sin_family = AF_INET;
addr.sin_port = htons(listener->GetPort());
-#endif
if (connect(connFD, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) == -1)
{
diff --git a/src/user_resolver.cpp b/src/user_resolver.cpp
index d0270f7d8..b37d112fe 100644
--- a/src/user_resolver.cpp
+++ b/src/user_resolver.cpp
@@ -34,17 +34,14 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
if (this->bound_user->registered != REG_ALL)
{
bool lcached = false;
-#ifdef IPV6
if (this->bound_user->client_sa.sa.sa_family == AF_INET6)
{
/* IPV6 forward lookup */
res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, DNS_QUERY_AAAA, lcached);
}
else
- /* IPV4 lookup (mixed protocol mode) */
-#endif
{
- /* IPV4 lookup (ipv4 only mode) */
+ /* IPV4 lookup */
res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, DNS_QUERY_A, lcached);
}
this->ServerInstance->AddResolver(res_forward, lcached);
@@ -61,7 +58,6 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
irc::sockets::sockaddrs* user_ip = &this->bound_user->client_sa;
bool rev_match = false;
-#ifdef IPV6
if (user_ip->sa.sa_family == AF_INET6)
{
struct in6_addr res_bin;
@@ -71,7 +67,6 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
}
}
else
-#endif
{
struct in_addr res_bin;
if (inet_pton(AF_INET, result.c_str(), &res_bin))