]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_mysql.cpp
The IPV6 stuff compiles now, with compile-correct ipv6 code. I dont know if this...
[user/henk/code/inspircd.git] / src / modules / extra / m_mysql.cpp
index 035d0b49876a416286589be82912280f9e42017f..7f2b96227177b4786cacc98337e6ddd8ea94b23a 100644 (file)
@@ -660,14 +660,18 @@ void* DispatcherThread(void* arg);
 
 class Notifier : public InspSocket
 {
-       sockaddr_in sock_us;
+       insp_sockaddr sock_us;
        socklen_t uslen;
        Server* Srv;
 
  public:
 
        /* Create a socket on a random port. Let the tcp stack allocate us an available port */
+#ifdef IPV6
+       Notifier(Server* S) : InspSocket("::1", 0, true, 3000), Srv(S)
+#else
        Notifier(Server* S) : InspSocket("127.0.0.1", 0, true, 3000), Srv(S)
+#endif
        {
                uslen = sizeof(sock_us);
                if (getsockname(this->fd,(sockaddr*)&sock_us,&uslen))
@@ -684,7 +688,11 @@ class Notifier : public InspSocket
        /* Using getsockname and ntohs, we can determine which port number we were allocated */
        int GetPort()
        {
+#ifdef IPV6
+               return ntohs(sock_us.sin6_port);
+#else
                return ntohs(sock_us.sin_port);
+#endif
        }
 
        virtual int OnIncomingConnection(int newsock, char* ip)
@@ -832,7 +840,7 @@ void* DispatcherThread(void* arg)
 
        /* Connect back to the Notifier */
 
-       if ((QueueFD = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+       if ((QueueFD = socket(AF_FAMILY, SOCK_STREAM, 0)) == -1)
        {
                /* crap, we're out of sockets... */
                log(DEBUG,"QueueFD cant be created");
@@ -841,12 +849,19 @@ void* DispatcherThread(void* arg)
 
        log(DEBUG,"Initialize QueueFD to %d",QueueFD);
 
-       sockaddr_in addr;
-       in_addr ia;
-       inet_aton("127.0.0.1", &ia);
-       addr.sin_family = AF_INET;
+       insp_sockaddr addr;
+
+#ifdef IPV6
+       insp_aton("::1", &addr.sin6_addr);
+       addr.sin6_family = AF_FAMILY;
+       addr.sin6_port = htons(MessagePipe->GetPort());
+#else
+       insp_inaddr ia;
+       insp_aton("127.0.0.1", &ia);
+       addr.sin_family = AF_FAMILY;
        addr.sin_addr = ia;
        addr.sin_port = htons(MessagePipe->GetPort());
+#endif
 
        if (connect(QueueFD, (sockaddr*)&addr,sizeof(addr)) == -1)
        {