]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix sockaddr length argument, BSD will complain if it doesn't exactly match the expec...
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 16 Jun 2009 04:02:21 +0000 (04:02 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 16 Jun 2009 04:02:21 +0000 (04:02 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11414 e03df62e-2008-0410-955e-edbf42e46eb7

include/socket.h
src/inspsocket.cpp

index c7b87d583b862984f78ca9750681ebad69961493..ddd453ac3f6280caa6a5b853a32ad120b4964bbd 100644 (file)
@@ -143,6 +143,12 @@ namespace irc
                 */
                CoreExport int OpenTCPSocket(const char* addr, int socktype = SOCK_STREAM);
 
+               /** Return the size of the structure for syscall passing */
+               int sa_size(irc::sockets::sockaddrs& sa)
+               {
+                       return sa.sa.sa_family == AF_INET ? sizeof(sa.in4) : sizeof(sa.in6);
+               }
+
                /** Convert an address-port pair into a binary sockaddr
                 * @param addr The IP address, IPv4 or IPv6
                 * @param port The port, 0 for unspecified
index 41bce84a73292bf0839c030a93b953052b2bdc46..7718fe70ae31bc7a5f054fdfacbe5953161d606b 100644 (file)
@@ -238,7 +238,7 @@ bool BufferedSocket::DoConnect(unsigned long maxtime)
 
        ServerInstance->SE->NonBlocking(this->fd);
 
-       if (ServerInstance->SE->Connect(this, &addr.sa, sizeof(addr)) == -1)
+       if (ServerInstance->SE->Connect(this, &addr.sa, sa_size(addr)) == -1)
        {
                if (errno != EINPROGRESS)
                {