Remove unneeded #ifdef IPV6 lines

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11582 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
danieldg 2009-09-01 15:08:09 +00:00
parent 5ad936b13f
commit 248a14477c
10 changed files with 22 additions and 81 deletions

View File

@ -358,12 +358,11 @@ class CoreExport DNS : public EventHandler
*/
int socketfamily;
#ifdef IPV6
/**
* IPV6 server address
*/
in6_addr myserver6;
#endif
/**
* IPV4 server address
*/

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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)

View File

@ -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)
{

View File

@ -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,11 +47,12 @@ 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;
@ -60,6 +60,7 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
servaddr.in4.sin_port = htons(port);
#endif
}
}
ret = SE->Bind(sockfd, &servaddr.sa, sizeof(servaddr));
if (ret < 0)
@ -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;
}

View File

@ -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)
{

View File

@ -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))