[gnome-nettool] portability fix for systems that configure an ipv6 address by default, but use the ipv4 address for



commit 7cdd757b1d74a1c3b662d4c04e34b77a19af072e
Author: Jasper Lievisse Adriaanse <jasper humppa nl>
Date:   Thu May 19 18:45:05 2011 +0200

    portability fix for systems that configure an ipv6 address by default, but use the ipv4 address for actual traffic.
    
    tweak decision logic for deciding if we should use the ipv4 or ipv6 tools.
    it would default to ipv6 as most interfaces have an unused ipv6 address, while
    actually using the ipv4 address. this fixes ping/traceroute functionality when
    using hostnames instead of ip addresses.
    
    Signed-off-by: GermÃn PÃo-CaamaÃo <gpoo gnome org>

 src/nettool.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/nettool.c b/src/nettool.c
index b227500..90b9bd2 100644
--- a/src/nettool.c
+++ b/src/nettool.c
@@ -28,6 +28,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <netinet/in.h>
 #include <signal.h>
 #include <errno.h>
 #include <sys/wait.h>
@@ -141,21 +142,21 @@ netinfo_get_ip_version (Netinfo * netinfo)
 				   (GTK_BIN (netinfo->host)))));
 
 	if (strlen (ip) > 0) {
-		host = gethostbyname2 (ip, AF_INET6);
+		host = gethostbyname2 (ip, AF_INET);
 		if (host == NULL) {
-			host = gethostbyname2 (ip, AF_INET);
+			host = gethostbyname2 (ip, AF_INET6);
 			if (host == NULL)
 				return -1;
 			else {
 				g_free (ip);
-				return IPV4;
+				return IPV6;
 			}
 			
 			return -1;
 		}
 		else {
 			g_free (ip);
-			return IPV6;
+			return IPV4;
 		}
 
 	}



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