#endif
#include <cerrno>
-#include "socketengine.h"
/* Contains irc-specific definitions */
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.
#include <string>
#include <map>
#include "inspircd_config.h"
+#include "socket.h"
#include "base.h"
/** Types of event an EventHandler may receive.
* 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.
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;
}
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);
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));
}
/* 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()");
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");
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)
{
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)