]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspsocket.cpp
Extra stuff so that freebsd 4 may work (needs someone with this OS to test!)
[user/henk/code/inspircd.git] / src / inspsocket.cpp
index c0a77a28ddbf4bde85ecc7b212510bf0569106b7..2cfa6fd677f66ab06d6b3e030abcb1fae17136e1 100644 (file)
@@ -179,6 +179,7 @@ bool InspSocket::BindAddr(const std::string &ip)
                {
                        if (!ip.empty() || ((IP != "*") && (IP != "127.0.0.1") && (!IP.empty()) && (IP != "::1")))
                        {
+                               /* The [2] is required because we may write a sockaddr_in6 here, and sockaddr_in6 is larger than sockaddr, where sockaddr_in4 is not. */
                                sockaddr* s = new sockaddr[2];
 #ifdef IPV6
                                if (v6)
@@ -186,7 +187,7 @@ bool InspSocket::BindAddr(const std::string &ip)
                                        in6_addr n;
                                        if (inet_pton(AF_INET6, IP.c_str(), &n) > 0)
                                        {
-                                               memcpy(&((sockaddr_in6*)s)->sin6_addr, &n, sizeof(n));
+                                               memcpy(&((sockaddr_in6*)s)->sin6_addr, &n, sizeof(sockaddr_in6));
                                                ((sockaddr_in6*)s)->sin6_port = 0;
                                                ((sockaddr_in6*)s)->sin6_family = AF_INET6;
                                                size = sizeof(sockaddr_in6);
@@ -236,6 +237,7 @@ bool InspSocket::BindAddr(const std::string &ip)
 
 bool InspSocket::DoConnect()
 {
+       /* The [2] is required because we may write a sockaddr_in6 here, and sockaddr_in6 is larger than sockaddr, where sockaddr_in4 is not. */
        sockaddr* addr = new sockaddr[2];
        socklen_t size = sizeof(sockaddr_in);
 #ifdef IPV6
@@ -594,6 +596,7 @@ bool InspSocket::Poll()
                break;
                case I_LISTENING:
                {
+                       /* The [2] is required because we may write a sockaddr_in6 here, and sockaddr_in6 is larger than sockaddr, where sockaddr_in4 is not. */
                        sockaddr* client = new sockaddr[2];
                        length = sizeof (sockaddr_in);
                        std::string recvip;
@@ -601,6 +604,8 @@ bool InspSocket::Poll()
                        if ((!*this->host) || strchr(this->host, ':'))
                                length = sizeof(sockaddr_in6);
 #endif
+                       void* m_acceptEvent = NULL;
+                       GetExt("windows_acceptevent", m_acceptEvent);
                        incoming = _accept (this->fd, client, &length);
 #ifdef IPV6
                        if ((!*this->host) || strchr(this->host, ':'))