From ab24f0dca4050e6bd11ace131b7ac7bb53d42bae Mon Sep 17 00:00:00 2001 From: nenolod Date: Sat, 8 Apr 2006 01:35:02 +0000 Subject: - first steps towards a working IPv6 port. I'll work more on this tomorrow. :-P git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3845 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/inspircd_io.h | 2 +- include/socket.h | 22 ++++++++++++++++++---- src/inspircd.cpp | 6 ++++-- src/inspircd_io.cpp | 6 +++--- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/include/inspircd_io.h b/include/inspircd_io.h index aac40337d..158acfa79 100644 --- a/include/inspircd_io.h +++ b/include/inspircd_io.h @@ -398,7 +398,7 @@ void SetSignals(); bool DaemonSeed(); bool FileExists(const char* file); int OpenTCPSocket(); -bool BindSocket(int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr); +bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr); void WritePID(const std::string &filename); int BindPorts(bool bail); char* CleanFilename(char* name); diff --git a/include/socket.h b/include/socket.h index f8b15ae53..caa1490b5 100644 --- a/include/socket.h +++ b/include/socket.h @@ -24,6 +24,20 @@ #include #include #include "dns.h" +#include "inspircd_config.h" + +/* macros to the relevant system address description structs */ +#ifdef IPV6 + +typedef struct sockaddr_in6 insp_sockaddr; +typedef struct in6_addr insp_inaddr; + +#else + +typedef struct sockaddr_in insp_sockaddr; +typedef struct in_addr insp_inaddr; + +#endif /** * States which a socket may be in @@ -84,13 +98,13 @@ private: * The host being connected to, * in sockaddr form */ - sockaddr_in addr; + insp_sockaddr addr; /** * The host being connected to, * in in_addr form */ - in_addr addy; + insp_inaddr addy; /** * When this time is reached, @@ -125,13 +139,13 @@ private: * Client sockaddr structure used * by accept() */ - sockaddr_in client; + insp_sockaddr client; /** * Server sockaddr structure used * by accept() */ - sockaddr_in server; + insp_sockaddr server; /** * Used by accept() to indicate the diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 79a6f1976..bdb1812c3 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -77,7 +77,9 @@ extern char LOG_FILE[MAXBUF]; int openSockfd[MAX_DESCRIPTORS]; int yield_depth; int iterations = 0; -sockaddr_in client,server; + +insp_sockaddr client, server; + socklen_t length; extern InspSocket* socket_ref[MAX_DESCRIPTORS]; @@ -598,7 +600,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets) InspSocket* s = NULL; InspSocket* s_del = NULL; unsigned int numberactive; - sockaddr_in sock_us; // our port number + insp_sockaddr sock_us; // our port number socklen_t uslen; // length of our port number if (yield_depth > 100) diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp index ddad3d388..723e5a48a 100644 --- a/src/inspircd_io.cpp +++ b/src/inspircd_io.cpp @@ -1365,10 +1365,10 @@ int ServerConfig::ConfVarEnum(ConfigDataHash &target, const std::string &tag, in * a maximum of one second before it times out, using the DNS * server specified in the configuration file. */ -bool BindSocket(int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr) +bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr) { memset(&server,0,sizeof(server)); - struct in_addr addy; + insp_inaddr addy; bool resolved = false; char resolved_addr[128]; @@ -1463,7 +1463,7 @@ bool HasPort(int port, char* addr) int BindPorts(bool bail) { char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF]; - sockaddr_in client,server; + insp_sockaddr client, server; int clientportcount = 0; int BoundPortCount = 0; -- cgit v1.2.3