ip6_block * convert_ip6_routes_block (gchar * conn_name) { gchar **ipset; guint length; guint i; gchar *ip, *tmp_addr; gchar *routes; ip6_block *start = NULL, *current = NULL, *iblock = NULL; struct in6_addr *tmp_ip6_addr; g_return_val_if_fail (conn_name != NULL, NULL); routes = ifnet_get_data (conn_name, "routes"); if (!routes) return NULL; ipset = g_strsplit (routes, "\" \"", 0); length = g_strv_length (ipset); for (i = 0; i < length; i++) { ip = ipset[i]; ip = strip_string (ip, '"'); if (ip[0] == '\0') continue; if ((tmp_addr = find_default_gateway_str (ip)) != NULL) { if (!is_ip6_address (tmp_addr)) continue; else { tmp_ip6_addr = g_slice_new0 (struct in6_addr); if (inet_pton (AF_INET6, "::", tmp_ip6_addr)) { iblock = g_slice_new0 (ip6_block); iblock->ip = tmp_ip6_addr; iblock->prefix = 128; } else { g_slice_free (struct in6_addr, tmp_ip6_addr); continue; } } } else iblock = create_ip6_block (ip); if (iblock == NULL) continue; iblock->next_hop = get_ip6_next_hop (ip); if (iblock->next_hop == NULL) { destroy_ip6_block (iblock); continue; } if (start == NULL) start = current = iblock; else { current->next = iblock; current = iblock; } }
ip_block * convert_ip6_routes_block (const char *conn_name) { gchar **ipset; guint length; guint i; gchar *ip, *tmp_addr; ip_block *start = NULL, *current = NULL, *iblock = NULL; g_return_val_if_fail (conn_name != NULL, NULL); ipset = split_routes (ifnet_get_data (conn_name, "routes")); length = ipset ? g_strv_length (ipset) : 0; for (i = 0; i < length; i++) { ip = ipset[i]; ip = strip_string (ip, '"'); if (ip[0] == '\0') continue; if ((tmp_addr = find_default_gateway_str (ip)) != NULL) { if (!is_ip6_address (tmp_addr)) continue; else { iblock = g_slice_new0 (ip_block); iblock->ip = g_strdup ("::"); iblock->prefix = 128; } } else iblock = create_ip_block (ip); if (iblock == NULL) continue; iblock->next_hop = get_ip6_next_hop (ip); if (iblock->next_hop == NULL) { destroy_ip_block (iblock); continue; } if (start == NULL) start = current = iblock; else { current->next = iblock; current = iblock; } } g_strfreev (ipset); return start; }