summary refs log tree commit diff
path: root/src/ipaddr/ng_ipaddr.c
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2008-05-19 00:12:41 +0200
committerFlorian Westphal <fw@strlen.de>2008-05-19 14:27:35 +0200
commit4ed2cb1a0248130f476ff9afd4fd4ed887fee376 (patch)
treecc36b59cd11ae640e10a827ab5b5c2a0456fed3b /src/ipaddr/ng_ipaddr.c
parent818a206a4261f3d4153b0ab5c2025d77002290f5 (diff)
downloadngircd-4ed2cb1a0248130f476ff9afd4fd4ed887fee376.tar.gz
ngircd-4ed2cb1a0248130f476ff9afd4fd4ed887fee376.zip
make Listen parameter a comma-seperated list of addresses.
this also obsoletes ListenIPv4 and ListenIPv6 options.
If Listen is unset, it is treated as Listen="::,0.0.0.0".

Note: ListenIPv4 and ListenIPv6 options are still recognized,
but ngircd will print a warning if they are used in the config file.

Also, some plattforms require that ai_socktype
is set in the getaddrinfo() hints structure.
Diffstat (limited to 'src/ipaddr/ng_ipaddr.c')
-rw-r--r--src/ipaddr/ng_ipaddr.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/ipaddr/ng_ipaddr.c b/src/ipaddr/ng_ipaddr.c
index 3b0595d7..b412cc83 100644
--- a/src/ipaddr/ng_ipaddr.c
+++ b/src/ipaddr/ng_ipaddr.c
@@ -24,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)
@@ -49,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)