- double latency, latency_src, latency_dst = 0.0;
-
- XBT_DEBUG("Solve route \"%s\" to \"%s\"", src, dst);
- xbt_assert(src && dst, "bad parameters for \"_get_route\" method");
-
- route_extended_t e_route_cnt;
-
- xbt_dynar_t elem_father_list = elements_father(src, dst);
-
- routing_component_t common_father =
- xbt_dynar_get_as(elem_father_list, 0, routing_component_t);
- routing_component_t src_father =
- xbt_dynar_get_as(elem_father_list, 1, routing_component_t);
- routing_component_t dst_father =
- xbt_dynar_get_as(elem_father_list, 2, routing_component_t);
-
- if (src_father == dst_father) { /* SURF_ROUTING_BASE */
-
- latency =
- (*(common_father->get_latency)) (common_father, src, dst, NULL);
- xbt_assert(latency>=0, "no route between \"%s\" and \"%s\"", src,
- dst);
-
- } else { /* SURF_ROUTING_RECURSIVE */
- route_extended_t e_route_bypass = NULL;
- if (common_father->get_bypass_route)
- e_route_bypass =
- (*(common_father->get_bypass_route)) (common_father, src, dst);
-
- xbt_assert(!e_route_bypass,"Bypass cannot work yet with get_latency");
-
- e_route_cnt =
- (*(common_father->get_route)) (common_father, src_father->name,
- dst_father->name);
-
- xbt_assert(e_route_cnt, "no route between \"%s\" and \"%s\"",
- src_father->name, dst_father->name);
-
- xbt_assert((e_route_cnt->src_gateway == NULL) ==
- (e_route_cnt->dst_gateway == NULL),
- "bad gateway for route between \"%s\" and \"%s\"", src,
- dst);
-
- latency = (*(common_father->get_latency)) (common_father, src_father->name, dst_father->name, e_route_cnt);
-
- xbt_assert(latency>=0, "no route between \"%s\" and \"%s\"",
- src_father->name, dst_father->name);
-
- if (strcmp(src,e_route_cnt->src_gateway)) {
-
- latency_src = _get_latency(src, e_route_cnt->src_gateway);
- xbt_assert(latency_src>=0, "no route between \"%s\" and \"%s\"", src,
- e_route_cnt->src_gateway);
- latency += latency_src;
- }
-
- if (strcmp(e_route_cnt->dst_gateway,dst)) {
-
- latency_dst = _get_latency(e_route_cnt->dst_gateway, dst);
- xbt_assert(latency_dst>=0, "no route between \"%s\" and \"%s\"",
- e_route_cnt->dst_gateway, dst);
- latency += latency_dst;
- }
-
+ _get_route_latency(src, dst, route, latency);
+ xbt_assert(!route || *route, "no route between \"%s\" and \"%s\"", src, dst);
+ xbt_assert(!latency || *latency >= 0.0,
+ "latency error on route between \"%s\" and \"%s\"", src, dst);
+ if (route) {
+ xbt_dynar_free(&global_routing->last_route);
+ global_routing->last_route = cleanup ? *route : NULL;