[evolution-patches] [PATCH] Only use ipv6 address if ipv6 interface is available



Based on comments from Ulrich -- when using IPv6, you want to use the
AI_ADDRCONFIG flag in the hints argument to getaddrinfo() to avoid
connecting to an IPv6 address if you don't have an IPv6 interface
configured. 

Jeremy
Index: e-util//ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.398.2.8
diff -u -u -r1.398.2.8 ChangeLog
--- e-util//ChangeLog	8 Oct 2003 20:36:22 -0000	1.398.2.8
+++ e-util//ChangeLog	17 Oct 2003 19:38:07 -0000
@@ -1,3 +1,9 @@
+2003-10-16  Jeremy Katz  <katzj redhat com>
+
+	* e-host-utils.c (e_gethostbyname_r): use AI_ADDRCONFIG if
+	available to avoid returning IPv6 addresses to hosts without an
+	IPv6 interface.
+
 2003-09-19  Jeffrey Stedfast  <fejj ximian com>
 
 	* e-host-utils.c (e_gethostbyaddr_r): Work around a bug in glibc
Index: e-util//e-host-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-host-utils.c,v
retrieving revision 1.14.4.2
diff -u -u -r1.14.4.2 e-host-utils.c
--- e-util//e-host-utils.c	8 Oct 2003 20:36:22 -0000	1.14.4.2
+++ e-util//e-host-utils.c	17 Oct 2003 19:38:08 -0000
@@ -187,10 +187,21 @@
 	hints.ai_family = PF_UNSPEC;
 	hints.ai_socktype = 0;
 	hints.ai_protocol = 0;
-	
+
+#ifdef AI_ADDRCONFIG
+	hints.ai_flags |= AI_ADDRCONFIG;
+#endif
+
 	if ((retval = getaddrinfo (name, NULL, &hints, &res)) != 0) {
-		*herr = ai_to_herr (retval);
-		return -1;
+#ifdef AI_ADDRCONFIG
+		hints.ai_flags &= ~AI_ADDRCONFIG;
+		if ((retval != EAI_BADFLAGS) || (retval = getaddrinfo (name, NULL, &hints, &res)) != 0) {
+#endif
+			*herr = ai_to_herr (retval);
+			return -1;
+#ifdef AI_ADDRCONFIG
+		}
+#endif
 	}
 	
 	len = ALIGN (strlen (res->ai_canonname) + 1);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]