[network-manager-vpnc] core: use right prefix for point-to-point tunnels



commit 1dfc754c9b629ed3443e763ca280caf419b4abc7
Author: Juliano F. Ravasi <dev juliano info>
Date:   Sun Jul 24 20:42:14 2011 -0300

    core: use right prefix for point-to-point tunnels
    
    When VPNC calls the helper script with INTERNAL_IP4_NETMASK unset, it
    should be assumed that the address is standalone, not in a subnet (prefix
    should be /32). NetworkManager assumes a different prefix if omitted, causing
    problems.

 src/nm-vpnc-service-vpnc-helper.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/nm-vpnc-service-vpnc-helper.c b/src/nm-vpnc-service-vpnc-helper.c
index 907881d..21942f6 100644
--- a/src/nm-vpnc-service-vpnc-helper.c
+++ b/src/nm-vpnc-service-vpnc-helper.c
@@ -298,6 +298,7 @@ main (int argc, char *argv[])
 	struct in_addr temp_addr;
 	long int mtu = 1412;
 	guint32 prefix = 0;
+	gboolean netmask_found = FALSE;
 
 	g_type_init ();
 
@@ -353,14 +354,20 @@ main (int argc, char *argv[])
 		pfx = strtoul (tmp, NULL, 10);
 		if (pfx >= 0 && pfx <= 32 && errno == 0)
 			prefix = (guint32) pfx;
+		netmask_found = TRUE;
 	}
 
 	if (!prefix) {
 		tmp = getenv ("INTERNAL_IP4_NETMASK");
 		if (tmp && inet_pton (AF_INET, tmp, &temp_addr) > 0)
 			prefix = nm_utils_ip4_netmask_to_prefix (temp_addr.s_addr);
+		netmask_found = TRUE;
 	}
 
+	/* If no netmask was given, that means point-to-point, ie /32 */
+	if (netmask_found == FALSE)
+		prefix = 32;
+
 	if (prefix) {
 		val = uint_to_gvalue (prefix);
 		if (val)



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