static GVariant *
ip6_routes_get (NMSetting  *setting,
                const char *property)
{
	GPtrArray *routes;
	GVariant *ret;

	g_object_get (setting, property, &routes, NULL);
	ret = nm_utils_ip6_routes_to_variant (routes);
	g_ptr_array_unref (routes);

	return ret;
}
static GVariant *
get_ip6_routes (void)
{
	GVariant *value = NULL;
	GPtrArray *routes;
	char *tmp;
	int i;

	routes = g_ptr_array_new_full (256, (GDestroyNotify) nm_ip_route_unref);

	for (i = 1; i < 256; i++) {
		NMIPRoute *route;
		char buf[BUFLEN];
		guint32 prefix;
		gchar **dest_prefix;
		GError *error = NULL;

		snprintf (buf, BUFLEN, "route_ipv6_network_%d", i);
		tmp = getenv (buf);
		if (!tmp || strlen (tmp) < 1)
			break;

		/* Split network string in "dest/prefix" format */
		dest_prefix = g_strsplit (tmp, "/", 2);

		tmp = dest_prefix[1];
		if (tmp) {
			long int tmp_prefix;

			errno = 0;
			tmp_prefix = strtol (tmp, NULL, 10);
			if (errno || tmp_prefix <= 0 || tmp_prefix > 128) {
				_LOGW ("Ignoring invalid static route prefix '%s'", tmp ? tmp : "NULL");
				g_strfreev (dest_prefix);
				continue;
			}
			prefix = (guint32) tmp_prefix;
		} else {
			_LOGW ("Ignoring static route %d with no prefix length", i);
			g_strfreev (dest_prefix);
			continue;
		}

		snprintf (buf, BUFLEN, "route_ipv6_gateway_%d", i);
		tmp = getenv (buf);

		route = nm_ip_route_new (AF_INET6, dest_prefix[0], prefix, tmp, -1, &error);
		g_strfreev (dest_prefix);
		if (!route) {
			_LOGW ("Ignoring a route: %s", error->message);
			g_error_free (error);
			continue;
		}
		g_ptr_array_add (routes, route);
	}

	if (routes->len)
		value = nm_utils_ip6_routes_to_variant (routes);
	g_ptr_array_unref (routes);

	return value;
}