[network-manager-vpnc] core: look for NETMASKLEN before NETMASK for IPv4 prefix
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-vpnc] core: look for NETMASKLEN before NETMASK for IPv4 prefix
- Date: Thu, 28 Jul 2011 22:01:43 +0000 (UTC)
commit c80ef34136f849b69ec7743996bc26c99c1f74ec
Author: Dan Williams <dcbw redhat com>
Date: Thu Jul 28 16:51:34 2011 -0500
core: look for NETMASKLEN before NETMASK for IPv4 prefix
src/nm-vpnc-service-vpnc-helper.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/src/nm-vpnc-service-vpnc-helper.c b/src/nm-vpnc-service-vpnc-helper.c
index d8e7a19..907881d 100644
--- a/src/nm-vpnc-service-vpnc-helper.c
+++ b/src/nm-vpnc-service-vpnc-helper.c
@@ -297,6 +297,7 @@ main (int argc, char *argv[])
GError *err = NULL;
struct in_addr temp_addr;
long int mtu = 1412;
+ guint32 prefix = 0;
g_type_init ();
@@ -343,16 +344,27 @@ main (int argc, char *argv[])
else
helper_failed (connection, "IP4 PTP Address");
- /* Netmask */
- tmp = getenv ("INTERNAL_IP4_NETMASK");
- if (tmp && inet_pton (AF_INET, tmp, &temp_addr) > 0) {
- GValue *value;
+ /* Netmask / Prefix */
+ tmp = getenv ("INTERNAL_IP4_NETMASKLEN");
+ if (tmp) {
+ unsigned long pfx;
- value = g_slice_new0 (GValue);
- g_value_init (value, G_TYPE_UINT);
- g_value_set_uint (value, nm_utils_ip4_netmask_to_prefix (temp_addr.s_addr));
+ errno = 0;
+ pfx = strtoul (tmp, NULL, 10);
+ if (pfx >= 0 && pfx <= 32 && errno == 0)
+ prefix = (guint32) pfx;
+ }
+
+ 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);
+ }
- g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, value);
+ if (prefix) {
+ val = uint_to_gvalue (prefix);
+ if (val)
+ g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
}
/* DNS */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]