]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Get rid of socklen_t parameter to Bind, we are using C++ here and can do it other...
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 13 Nov 2009 20:23:11 +0000 (20:23 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 13 Nov 2009 20:23:11 +0000 (20:23 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12129 e03df62e-2008-0410-955e-edbf42e46eb7

include/socket.h
include/socketengine.h
src/inspsocket.cpp
src/listensocket.cpp
src/modules/m_ident.cpp
src/socket.cpp
src/socketengine.cpp

index 6a0cc88ad51acf0de2f94193f2a8a6177b926b5a..f79d9166e50d1450750c99cdb4510236df6f77dc 100644 (file)
@@ -34,7 +34,6 @@
 #endif
 
 #include <cerrno>
-#include "socketengine.h"
 
 /* Contains irc-specific definitions */
 namespace irc
@@ -124,6 +123,7 @@ namespace irc
        }
 }
 
+#include "socketengine.h"
 /** This class handles incoming connections on client ports.
  * It will create a new User for every valid connection
  * and assign it a file descriptor.
index b411b394a6cbc1e2f5c3af988c86d5b516e779b4..9240c3a435e38533b5bb9ce1421ee81fdbb7812d 100644 (file)
@@ -18,6 +18,7 @@
 #include <string>
 #include <map>
 #include "inspircd_config.h"
+#include "socket.h"
 #include "base.h"
 
 /** Types of event an EventHandler may receive.
@@ -439,7 +440,7 @@ public:
         * This function should emulate its namesake system call exactly.
         * @return This method should return exactly the same values as the system call it emulates.
         */
-       int Bind(int fd, const sockaddr *my_addr, socklen_t addrlen);
+       int Bind(int fd, const irc::sockets::sockaddrs& addr);
 
        /** Abstraction for BSD sockets listen(2).
         * This function should emulate its namesake system call exactly.
index 59f814cc915b4b9bceef7c504a3035c750a59e81..6b3583a6a006e4d5aa1e07eef8e63fd25ebe0214 100644 (file)
@@ -90,7 +90,7 @@ BufferedSocketError BufferedSocket::BeginConnect(const irc::sockets::sockaddrs&
 
        if (bind.sa.sa_family != 0)
        {
-               if (ServerInstance->SE->Bind(fd, &bind.sa, sa_size(bind)) < 0)
+               if (ServerInstance->SE->Bind(fd, bind) < 0)
                        return I_ERR_BIND;
        }
 
index 676898647847ff91cf5bcd9b06c1798d5d2b436a..f0daf8ef0cc549ba339dd97eb815a041810b5f6a 100644 (file)
@@ -36,7 +36,7 @@ ListenSocket::ListenSocket(ConfigTag* tag, const std::string& addr, int port)
        if (this->fd > -1)
        {
                ServerInstance->SE->SetReuse(fd);
-               int rv = ServerInstance->SE->Bind(this->fd, &bind_to.sa, sizeof(bind_to));
+               int rv = ServerInstance->SE->Bind(this->fd, bind_to);
                if (rv >= 0)
                        rv = ServerInstance->SE->Listen(this->fd, ServerInstance->Config->MaxConn);
 
index fbd7706fe7efd2a802887b0b456b0ade555e2e53..ad62c77f98a7761abb2c7bf562f0d8ca2a94ff95 100644 (file)
@@ -83,7 +83,6 @@ class IdentRequestSocket : public EventHandler
        IdentRequestSocket(LocalUser* u) : user(u), result(u->ident)
        {
                age = ServerInstance->Time();
-               socklen_t size = 0;
 
                SetFd(socket(user->server_sa.sa.sa_family, SOCK_STREAM, 0));
 
@@ -110,7 +109,7 @@ class IdentRequestSocket : public EventHandler
                }
 
                /* Attempt to bind (ident requests must come from the ip the query is referring to */
-               if (ServerInstance->SE->Bind(GetFd(), &bindaddr.sa, size) < 0)
+               if (ServerInstance->SE->Bind(GetFd(), bindaddr) < 0)
                {
                        this->Close();
                        throw ModuleException("failed to bind()");
@@ -119,7 +118,7 @@ class IdentRequestSocket : public EventHandler
                ServerInstance->SE->NonBlocking(GetFd());
 
                /* Attempt connection (nonblocking) */
-               if (ServerInstance->SE->Connect(this, &connaddr.sa, size) == -1 && errno != EINPROGRESS)
+               if (ServerInstance->SE->Connect(this, &connaddr.sa, connaddr.sa_size()) == -1 && errno != EINPROGRESS)
                {
                        this->Close();
                        throw ModuleException("connect() failed");
index eb47c9cc8286dea74331485bf66ae1129f4292c4..049d3a2379b6d81e91bb387e94f9d52a824a9574 100644 (file)
@@ -36,7 +36,7 @@ bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
        else if (!irc::sockets::aptosa(addr, port, servaddr))
                return false;
 
-       ret = SE->Bind(sockfd, &servaddr.sa, sa_size(servaddr));
+       ret = SE->Bind(sockfd, servaddr);
 
        if (ret < 0)
        {
index 478400d1bc178cc464b972e3314cbf95fd6387d4..b442732f5cc0af4fa9a65264c5a64bd913d0fdf8 100644 (file)
@@ -197,9 +197,9 @@ int SocketEngine::Shutdown(EventHandler* fd, int how)
        return shutdown(fd->GetFd(), how);
 }
 
-int SocketEngine::Bind(int fd, const sockaddr *my_addr, socklen_t addrlen)
+int SocketEngine::Bind(int fd, const irc::sockets::sockaddrs& addr)
 {
-       return bind(fd, my_addr, addrlen);
+       return bind(fd, &addr.sa, addr.sa_size());
 }
 
 int SocketEngine::Listen(int sockfd, int backlog)