while (g_variant_iter_loop(sub_iter, "{sv}", &sub_key, &variant)) {
if (g_strcmp0(sub_key, "Address") == 0) {
value = g_variant_get_string(variant, NULL);
- preferred_address6 = g_strdup(value);
+ if (!preferred_address6)
+ preferred_address6 = g_strdup(value);
}
}
g_variant_iter_free(sub_iter);
while (g_variant_iter_loop(next, "{sv}", &key1, &variant)) {
if (g_strcmp0(key1, "Interface") == 0) {
value = g_variant_get_string(variant, NULL);
- ifname = g_strdup(value);
+ if (!ifname)
+ ifname = g_strdup(value);
g_free(key1);
g_variant_unref(variant);
break;
gchar *const args[] = { "/sbin/route", "add", "-net", ip_addr, gw_str,
"netmask", netmask, "dev", interface, NULL };
gchar *const envs[] = { NULL };
- const gchar* buf = NULL;
- gchar* ch = NULL;
- int prefix_len = 0;
- int pos = 0;
DBG("ip_addr(%s), netmask(%s), interface(%s), gateway(%s)", ip_addr, netmask, interface, gateway);
return TRUE;
}
- buf = ip_addr;
- ch = strchr(buf, '/');
- pos = ch - buf + 1;
- if (ch) {
- prefix_len = atoi(ch + 1);
- ip_addr[pos-1] = '\0';
- } else {
- prefix_len = 128;
- }
-
- if (netconfig_add_route_ipv6(ip_addr, interface, gateway, prefix_len) < 0) {
+ if (netconfig_add_route_ipv6(interface, gateway) < 0) {
DBG("Failed to add a new route");
netconfig_error_permission_denied(context);
return TRUE;
gchar *const args[] = { "/sbin/route", "del", "-net", ip_addr, gw_str,
"netmask", netmask, "dev", interface, NULL };
char *const envs[] = { NULL };
- const char* buf = NULL;
- char* ch = NULL;
- int prefix_len = 0;
- int pos = 0;
DBG("ip_addr(%s), netmask(%s), interface(%s), gateway(%s)", ip_addr, netmask, interface, gateway);
return TRUE;
}
- buf = ip_addr;
- ch = strchr(buf, '/');
- pos = ch - buf + 1;
- if (ch) {
- prefix_len = atoi(ch + 1);
- ip_addr[pos-1] = '\0';
- } else {
- prefix_len = 128;
- }
-
- if (netconfig_del_route_ipv6(ip_addr, interface, gateway, prefix_len) < 0) {
+ if (netconfig_del_route_ipv6(interface, gateway) < 0) {
DBG("Failed to remove the route");
netconfig_error_permission_denied(context);
return TRUE;