2008-08-06 Dan Williams <dcbw@redhat.com>

* src/nm-vpnc-service-vpnc-helper.c
		- (get_routes): fixup for NM route metric changes

	* properties/nm-vpnc.c
		- (get_routes, export): fixup for NM route metric changes



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3900 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-08-06 22:27:16 +00:00
parent 92cc4a0bee
commit 3c51abb50c
3 changed files with 29 additions and 21 deletions

View file

@ -1,3 +1,11 @@
2008-08-06 Dan Williams <dcbw@redhat.com>
* src/nm-vpnc-service-vpnc-helper.c
- (get_routes): fixup for NM route metric changes
* properties/nm-vpnc.c
- (get_routes, export): fixup for NM route metric changes
2008-07-27 Dan Williams <dcbw@redhat.com>
Patch from Michael Biebl <biebl@debian.org>

View file

@ -547,39 +547,38 @@ get_routes (const char *routelist)
substrs = g_strsplit (routelist, " ", 0);
for (i = 0; substrs[i] != NULL; i++) {
struct in_addr tmp;
char *p, *route;
char *p, *str_route;
long int prefix = 32;
route = g_strdup (substrs[i]);
p = strchr (route, '/');
str_route = g_strdup (substrs[i]);
p = strchr (str_route, '/');
if (!p || !(*(p + 1))) {
g_warning ("Ignoring invalid route '%s'", route);
g_warning ("Ignoring invalid route '%s'", str_route);
goto next;
}
errno = 0;
prefix = strtol (p + 1, NULL, 10);
if (errno || prefix <= 0 || prefix > 32) {
g_warning ("Ignoring invalid route '%s'", route);
g_warning ("Ignoring invalid route '%s'", str_route);
goto next;
}
/* don't pass the prefix to inet_pton() */
*p = '\0';
if (inet_pton (AF_INET, route, &tmp) > 0) {
NMSettingIP4Address *addr;
if (inet_pton (AF_INET, str_route, &tmp) > 0) {
NMSettingIP4Route *route;
addr = g_new0 (NMSettingIP4Address, 1);
addr->address = tmp.s_addr;
addr->prefix = (guint32) prefix;
addr->gateway = 0;
route = g_new0 (NMSettingIP4Route, 1);
route->address = tmp.s_addr;
route->prefix = (guint32) prefix;
routes = g_slist_append (routes, addr);
routes = g_slist_append (routes, route);
} else
g_warning ("Ignoring invalid route '%s'", route);
g_warning ("Ignoring invalid route '%s'", str_route);
next:
g_free (route);
g_free (str_route);
}
g_strfreev (substrs);
@ -788,16 +787,16 @@ export (NMVpnPluginUiInterface *iface,
GSList *iter;
for (iter = s_ip4->routes; iter; iter = g_slist_next (iter)) {
NMSettingIP4Address *addr = (NMSettingIP4Address *) iter->data;
NMSettingIP4Route *route = (NMSettingIP4Route *) iter->data;
char str_addr[INET_ADDRSTRLEN + 1];
struct in_addr num_addr;
if (routes->len)
g_string_append_c (routes, ' ');
num_addr.s_addr = addr->address;
num_addr.s_addr = route->address;
if (inet_ntop (AF_INET, &num_addr, &str_addr[0], INET_ADDRSTRLEN + 1))
g_string_append_printf (routes, "%s/%d", str_addr, addr->prefix);
g_string_append_printf (routes, "%s/%d", str_addr, route->prefix);
}
}

View file

@ -211,8 +211,8 @@ get_routes (void)
GArray *array;
char buf[BUFLEN];
struct in_addr network;
guint32 gateway = 0; /* no gateway */
guint32 prefix;
guint32 next_hop = 0; /* no next hop */
guint32 prefix, metric = 0;
snprintf (buf, BUFLEN, "CISCO_SPLIT_INC_%d_ADDR", i);
tmp = getenv (buf);
@ -245,10 +245,11 @@ get_routes (void)
prefix = nm_utils_ip4_netmask_to_prefix (netmask.s_addr);
}
array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 4);
g_array_append_val (array, network.s_addr);
g_array_append_val (array, prefix);
g_array_append_val (array, gateway);
g_array_append_val (array, next_hop);
g_array_append_val (array, metric);
g_ptr_array_add (routes, array);
}