]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ipaddr/ng_ipaddr.c
make Listen parameter a comma-seperated list of addresses.
[ngircd-alex.git] / src / ipaddr / ng_ipaddr.c
index bbfb5a73741f3eab1d0eb69ec31a406770322eed..b412cc83af6e2789b03b2e34f7b74b4c962f8f1c 100644 (file)
@@ -14,9 +14,6 @@
 #include <netdb.h>
 #include <sys/types.h>
 #endif
-#include <sys/socket.h>
-
-#include <netinet/in.h>
 
 #include "ng_ipaddr.h"
 
@@ -27,18 +24,19 @@ ng_ipaddr_init(ng_ipaddr_t *addr, const char *ip_str, UINT16 port)
        int ret;
        char portstr[64];
        struct addrinfo *res0;
-       struct addrinfo hints = {
-#ifndef WANT_IPV6      /* only accept v4 addresses */
-               .ai_family = AF_INET,
-#endif
-               .ai_flags = AI_NUMERICHOST
-       };
+       struct addrinfo hints;
+
+       assert(ip_str);
 
-       if (ip_str == NULL)
-               hints.ai_flags |= AI_PASSIVE;
+       memset(&hints, 0, sizeof(hints));
+       hints.ai_flags = AI_NUMERICHOST;
+
+       /* some getaddrinfo implementations require that ai_socktype is set. */
+       hints.ai_socktype = SOCK_STREAM;
 
        /* silly, but ngircd stores UINT16 in server config, not string */
        snprintf(portstr, sizeof(portstr), "%u", (unsigned int) port);
+
        ret = getaddrinfo(ip_str, portstr, &hints, &res0);
        assert(ret == 0);
        if (ret != 0)
@@ -52,8 +50,7 @@ ng_ipaddr_init(ng_ipaddr_t *addr, const char *ip_str, UINT16 port)
        freeaddrinfo(res0);
        return ret == 0;
 #else /* HAVE_GETADDRINFO */
-       if (ip_str == NULL)
-               ip_str = "0.0.0.0";
+       assert(ip_str);
        addr->sin4.sin_family = AF_INET;
 # ifdef HAVE_INET_ATON
        if (inet_aton(ip_str, &addr->sin4.sin_addr) == 0)