[network-manager-openvpn] handle 'subnet' topology better
- From: Dan Williams <dcbw src gnome org>
- To: svn-commits-list gnome org
- Subject: [network-manager-openvpn] handle 'subnet' topology better
- Date: Tue, 14 Jul 2009 10:54:38 +0000 (UTC)
commit 98dcecdf70e2637a8e64fed7f650babc56f9c1de
Author: Dan Williams <dcbw redhat com>
Date: Tue Jul 14 06:52:31 2009 -0400
handle 'subnet' topology better
Since openvpn doesn't appear to actually pass topology to the
script, we have to infer it from the 'ifconfig' arguments. If the
second argument to ifconfig appears to be a netmask, then use it
as a netmask instead of the ptp address.
src/nm-openvpn-service-openvpn-helper.c | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/src/nm-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index d9a596e..9823d94 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -331,8 +331,22 @@ main (int argc, char *argv[])
/* PTP address; for vpnc PTP address == internal IP4 address */
val = addr_to_gvalue (getenv ("ifconfig_remote"));
- if (val)
- g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_PTP, val);
+ if (val) {
+ /* Sigh. Openvpn added 'topology' stuff in 2.1 that changes the meaning
+ * of the ifconfig bits without actually telling you what they are
+ * supposed to mean; basically relying on specific 'ifconfig' behavior.
+ */
+ tmp = getenv ("ifconfig_remote");
+ if (tmp && !strncmp (tmp, "255.", 4)) {
+ guint32 addr;
+
+ /* probably a netmask, not a PTP address; topology == subnet */
+ addr = g_value_get_uint (val);
+ g_value_set_uint (val, nm_utils_ip4_netmask_to_prefix (addr));
+ g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
+ } else
+ g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_PTP, val);
+ }
/* Netmask
*
@@ -348,10 +362,12 @@ main (int argc, char *argv[])
g_value_set_uint (val, nm_utils_ip4_netmask_to_prefix (temp_addr.s_addr));
g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
} else if (!tapdev) {
- val = g_slice_new0 (GValue);
- g_value_init (val, G_TYPE_UINT);
- g_value_set_uint (val, 32);
- g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
+ if (!g_hash_table_lookup (config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX)) {
+ val = g_slice_new0 (GValue);
+ g_value_init (val, G_TYPE_UINT);
+ g_value_set_uint (val, 32);
+ g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
+ }
} else
nm_warning ("No IP4 netmask/prefix (missing or invalid 'ifconfig_netmask')");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]