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



commit 2ad771b18b1e602c9bd70f6ba012cfc2dc9fce13
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 84e82f7..197f176 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]