+static double _get_latency(const char *src, const char *dst)
+{
+
+ double latency, latency_src, latency_dst = 0.0;
+
+ DEBUG2("Solve route \"%s\" to \"%s\"", src, dst);
+
+ xbt_assert0(src && dst, "bad parameters for \"_get_route\" method");
+
+ route_extended_t e_route, 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);
+
+ e_route = xbt_new0(s_route_extended_t, 1);
+ e_route->src_gateway = NULL;
+ e_route->dst_gateway = NULL;
+ e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
+
+ if (src_father == dst_father) { /* SURF_ROUTING_BASE */
+
+ if (strcmp(src, dst)) {
+ latency =
+ (*(common_father->get_latency)) (common_father, src, dst);
+ xbt_assert2(latency>=0, "no route between \"%s\" and \"%s\"", src,
+ dst);
+ } else latency = 0;
+ } 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_assert0(!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_assert2(e_route_cnt, "no route between \"%s\" and \"%s\"",
+ src_father->name, dst_father->name);
+
+ xbt_assert2((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);
+ xbt_assert2(latency>=0, "no route between \"%s\" and \"%s\"",
+ src_father->name, dst_father->name);
+
+
+ if (src != e_route_cnt->src_gateway) {
+ /*
+ e_route_src = _get_route(src, e_route_cnt->src_gateway);
+ xbt_assert2(e_route_src, "no route between \"%s\" and \"%s\"", src,
+ e_route_cnt->src_gateway);
+ xbt_dynar_foreach(e_route_src->generic_route.link_list, cpt, link) {
+ xbt_dynar_push(e_route->generic_route.link_list, &link);
+ }
+ */
+ latency_src = _get_latency(src, e_route_cnt->src_gateway);
+ xbt_assert2(latency_src>=0, "no route between \"%s\" and \"%s\"", src,
+ e_route_cnt->src_gateway);
+ latency += latency_src;
+ }
+
+ /*
+ xbt_dynar_foreach(e_route_cnt->generic_route.link_list, cpt, link) {
+ xbt_dynar_push(e_route->generic_route.link_list, &link);
+ }
+ */
+
+ if (e_route_cnt->dst_gateway != dst) {
+ /*
+ e_route_dst = _get_route(e_route_cnt->dst_gateway, dst);
+ xbt_assert2(e_route_dst, "no route between \"%s\" and \"%s\"",
+ e_route_cnt->dst_gateway, dst);
+ xbt_dynar_foreach(e_route_dst->generic_route.link_list, cpt, link) {
+ xbt_dynar_push(e_route->generic_route.link_list, &link);
+ }
+ */
+ latency_dst = _get_latency(e_route_cnt->dst_gateway, dst);
+ xbt_assert2(latency_dst>=0, "no route between \"%s\" and \"%s\"",
+ e_route_cnt->dst_gateway, dst);
+ latency += latency_dst;
+ }
+
+ /*
+ e_route->src_gateway = xbt_strdup(e_route_cnt->src_gateway);
+ e_route->dst_gateway = xbt_strdup(e_route_cnt->dst_gateway);
+
+ generic_free_extended_route(e_route_src);
+ generic_free_extended_route(e_route_cnt);
+ generic_free_extended_route(e_route_dst);
+ */
+ }
+
+ xbt_dynar_free(&elem_father_list);
+
+ return latency;
+}
+