]> git.pond.sub.org Git - empserver/commitdiff
Use IPv4 and v6 only when suitable interfaces are configured
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 11 Feb 2009 20:09:18 +0000 (21:09 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 12 Feb 2009 06:41:13 +0000 (07:41 +0100)
Only on systems supporting AI_ADDRCONFIG.

src/client/host.c
src/lib/gen/tcp_listen.c

index 68df7e21f8d43c71efdfcc105dede145687916d4..6687f71ab4aa9c028b295f613de902438f4d6f9a 100644 (file)
 #endif
 #include "misc.h"
 
+/* Portability cruft, should become unnecessary eventually */
+#ifndef AI_ADDRCONFIG
+#define AI_ADDRCONFIG 0
+#endif
+
 #ifdef HAVE_GETADDRINFO
 /*
  * Inspired by example code from W. Richard Stevens: UNIX Network
@@ -65,6 +70,7 @@ tcp_connect(char *host, char *serv)
     struct addrinfo hints, *res, *ressave;
 
     memset(&hints, 0, sizeof(struct addrinfo));
+    hints.ai_flags = AI_ADDRCONFIG;
     hints.ai_family = AF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;
 
index 29c227d3a5040697e6891294cdab2f321ca67c83..fa494c40d2c41ddaa9a0caa136d9f9b864d8d3e0 100644 (file)
 #include <unistd.h>
 #include "prototypes.h"
 
+/* Portability cruft, should become unnecessary eventually */
+#ifndef AI_ADDRCONFIG
+#define AI_ADDRCONFIG 0
+#endif
+
 static void cant_listen(char *, char *, const char *);
 
 int
@@ -62,7 +67,7 @@ tcp_listen(char *host, char *serv, size_t *addrlenp)
     struct addrinfo hints, *res, *ressave;
 
     memset(&hints, 0, sizeof(struct addrinfo));
-    hints.ai_flags = AI_PASSIVE;
+    hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
     hints.ai_family = AF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;