summaryrefslogtreecommitdiff
path: root/src/inspsocket.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-05-30 17:37:13 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-05-30 17:37:13 +0000
commit2779810ff0d1b66f0fca1a62d6164d70f5c86d06 (patch)
tree101caa8c28e64e6580d6674eb93e8d349673df21 /src/inspsocket.cpp
parentc9235e50f471e5071c0601dde62bb741d9b6f05c (diff)
Apply ipv6 #ifdef tidyup patch from djGrrr, thanks :)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7190 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspsocket.cpp')
-rw-r--r--src/inspsocket.cpp50
1 files changed, 5 insertions, 45 deletions
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 2e8d6fd68..80e916c00 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -107,16 +107,12 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool
ipvalid = false;
}
else
+#endif
{
in_addr n;
if (inet_aton(host,&n) < 1)
ipvalid = false;
}
-#else
- in_addr n;
- if (inet_aton(host,&n) < 1)
- ipvalid = false;
-#endif
if (!ipvalid)
{
this->Instance->Log(DEBUG,"BUG: Hostname passed to InspSocket, rather than an IP address!");
@@ -203,6 +199,7 @@ bool InspSocket::BindAddr(const std::string &ip)
}
}
else
+#endif
{
in_addr n;
if (inet_aton(IP.c_str(), &n) > 0)
@@ -218,21 +215,6 @@ bool InspSocket::BindAddr(const std::string &ip)
continue;
}
}
-#else
- in_addr n;
- if (insp_aton(IP.c_str(), &n) > 0)
- {
- ((sockaddr_in*)s)->sin_addr = n;
- ((sockaddr_in*)s)->sin_port = 0;
- ((sockaddr_in*)s)->sin_family = AF_INET;
- }
- else
- {
- delete[] s;
- j++;
- continue;
- }
-#endif
if (bind(this->fd, s, size) < 0)
{
@@ -274,6 +256,7 @@ bool InspSocket::DoConnect()
}
}
else
+#endif
{
this->fd = socket(AF_INET, SOCK_STREAM, 0);
if (this->fd > -1)
@@ -285,17 +268,6 @@ bool InspSocket::DoConnect()
}
}
}
-#else
- this->fd = socket(AF_INET, SOCK_STREAM, 0);
- if (this->fd > -1)
- {
- if (!this->BindAddr(this->cbindip))
- {
- delete[] addr;
- return false;
- }
- }
-#endif
if (this->fd == -1)
{
@@ -318,6 +290,7 @@ bool InspSocket::DoConnect()
}
}
else
+#endif
{
in_addr addy;
if (inet_aton(this->host, &addy) > 0)
@@ -327,15 +300,6 @@ bool InspSocket::DoConnect()
((sockaddr_in*)addr)->sin_port = htons(this->port);
}
}
-#else
- in_addr addy;
- if (inet_aton(this->host, &addy) > 0)
- {
- ((sockaddr_in*)addr)->sin_family = AF_INET;
- ((sockaddr_in*)addr)->sin_addr = addy;
- ((sockaddr_in*)addr)->sin_port = htons(this->port);
- }
-#endif
#ifndef WIN32
int flags = fcntl(this->fd, F_GETFL, 0);
fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
@@ -661,12 +625,8 @@ bool InspSocket::Poll()
recvip = inet_ntop(AF_INET6, &((sockaddr_in6*)client)->sin6_addr, buf, sizeof(buf));
}
else
- {
- recvip = inet_ntoa(((sockaddr_in*)client)->sin_addr);
- }
-#else
- recvip = inet_ntoa(((sockaddr_in*)client)->sin_addr);
#endif
+ recvip = inet_ntoa(((sockaddr_in*)client)->sin_addr);
this->OnIncomingConnection(incoming, (char*)recvip.c_str());
if (this->IsIOHooked)