X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/73cac04c5ce217e495a7584c98a6dbd940552e9c..f57edc1d5b4f497883b451fc85d2d653d27a8247:/src/surf/surf_routing_dijkstra.c diff --git a/src/surf/surf_routing_dijkstra.c b/src/surf/surf_routing_dijkstra.c index ab9e58ff2c..6a89c34957 100644 --- a/src/surf/surf_routing_dijkstra.c +++ b/src/surf/surf_routing_dijkstra.c @@ -180,10 +180,43 @@ static void add_loopback_dijkstra(routing_component_dijkstra_t rc) } } -/* Business methods */ +static route_extended_t dijkstra_get_route(routing_component_t rc, + const char *src, + const char *dst); + static xbt_dynar_t dijkstra_get_onelink_routes(routing_component_t rc) { - xbt_die("\"dijkstra_get_onelink_routes\" function not implemented yet"); + // xbt_die("\"dijkstra_get_onelink_routes\" function not implemented yet"); + xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free); + + routing_component_dijkstra_t routing = (routing_component_dijkstra_t) rc; + //size_t table_size = xbt_dict_length(routing->generic_routing.to_index); + xbt_dict_cursor_t c1 = NULL, c2 = NULL; + char *k1, *d1, *k2, *d2; + xbt_dict_foreach(routing->generic_routing.to_index, c1, k1, d1) { + xbt_dict_foreach(routing->generic_routing.to_index, c2, k2, d2) { + route_extended_t route = dijkstra_get_route(rc, k1, k2); + if (route) { + if (xbt_dynar_length(route->generic_route.link_list) == 1) { + void *link = + *(void **) xbt_dynar_get_ptr(route->generic_route.link_list, + 0); + onelink_t onelink = xbt_new0(s_onelink_t, 1); + onelink->link_ptr = link; + if (routing->generic_routing.hierarchy == SURF_ROUTING_BASE) { + onelink->src = xbt_strdup(k1); + onelink->dst = xbt_strdup(k2); + } else if (routing->generic_routing.hierarchy == + SURF_ROUTING_RECURSIVE) { + onelink->src = xbt_strdup(route->src_gateway); + onelink->dst = xbt_strdup(route->dst_gateway); + } + xbt_dynar_push(ret, &onelink); + } + } + } + } + return ret; } static route_extended_t dijkstra_get_route(routing_component_t rc, @@ -330,8 +363,7 @@ static route_extended_t dijkstra_get_route(routing_component_t rc, } /* compose route path with links */ - char *gw_src = NULL, *gw_dst = - NULL, *prev_gw_src, *prev_gw_dst, *first_gw = NULL; + char *gw_src = NULL, *gw_dst = NULL, *prev_gw_src, *first_gw = NULL; for (v = dst_node_id; v != src_node_id; v = pred_arr[v]) { xbt_node_t node_pred_v = @@ -344,7 +376,6 @@ static route_extended_t dijkstra_get_route(routing_component_t rc, *dst_id); prev_gw_src = gw_src; - prev_gw_dst = gw_dst; e_route = (route_extended_t) xbt_graph_edge_get_data(edge); gw_src = e_route->src_gateway; @@ -500,6 +531,9 @@ void model_dijkstra_both_set_route (routing_component_t rc, const char *src, src_id = xbt_dict_get_or_null(rc->to_index, src); dst_id = xbt_dict_get_or_null(rc->to_index, dst); + xbt_assert(src_id, "Network elements %s not found", src); + xbt_assert(dst_id, "Network elements %s not found", dst); + /* Create the topology graph */ if(!routing->route_graph) routing->route_graph = xbt_graph_new_graph(1, NULL);