- as_dijkstra_t as = (as_dijkstra_t) asg;
- int *src_id, *dst_id;
- src_id = xbt_dict_get_or_null(asg->to_index, src);
- dst_id = xbt_dict_get_or_null(asg->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(!as->route_graph)
- as->route_graph = xbt_graph_new_graph(1, NULL);
- if(!as->graph_node_map)
- as->graph_node_map = xbt_dict_new();
-
- if (as->cached && !as->route_cache)
- as->route_cache = xbt_dict_new();
-
- if( A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES
- || A_surfxml_ASroute_symmetrical == A_surfxml_ASroute_symmetrical_YES )
- xbt_die("Route symmetrical not supported on model dijkstra");
-
- if(!route->dst_gateway && !route->src_gateway)
- XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst);
- else{
- XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src,
- route->src_gateway, dst, route->dst_gateway);
- if(routing_get_network_element_type((const char*)route->dst_gateway) == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The dst_gateway '%s' does not exist!",route->dst_gateway);
- if(routing_get_network_element_type((const char*)route->src_gateway) == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The src_gateway '%s' does not exist!",route->src_gateway);
- }
-
- route_extended_t e_route =
- generic_new_extended_route(asg->hierarchy, route, 1);
- route_new_dijkstra(as, *src_id, *dst_id, e_route);
+ char *src = (char*)(route->src);
+ char *dst = (char*)(route->dst);
+
+ int as_route = 0;
+ if(!route->gw_dst && !route->gw_src)
+ XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst);
+ else{
+ XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src,
+ route->gw_src->name, dst, route->gw_dst->name);
+ as_route = 1;
+ if(route->gw_dst->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The gw_dst '%s' does not exist!",route->gw_dst->name);
+ if(route->gw_src->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The gw_src '%s' does not exist!",route->gw_src->name);
+ }
+
+ as_dijkstra_t as = (as_dijkstra_t) asg;
+ sg_routing_edge_t src_net_elm, dst_net_elm;
+
+ src_net_elm = sg_routing_edge_by_name_or_null(src);
+ dst_net_elm = sg_routing_edge_by_name_or_null(dst);
+
+ xbt_assert(src_net_elm, "Network elements %s not found", src);
+ xbt_assert(dst_net_elm, "Network elements %s not found", dst);
+
+ /* Create the topology graph */
+ if(!as->route_graph)
+ as->route_graph = xbt_graph_new_graph(1, NULL);
+ if(!as->graph_node_map)
+ as->graph_node_map = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
+
+ if (as->cached && !as->route_cache)
+ as->route_cache = xbt_dict_new_homogeneous(&route_cache_elem_free);
+
+ sg_platf_route_cbarg_t e_route = generic_new_extended_route(asg->hierarchy, route, 1);
+ route_new_dijkstra(as, src_net_elm->id, dst_net_elm->id, e_route);
+
+ // Symmetrical YES
+ if ( (route->symmetrical == TRUE && as_route == 0)
+ || (route->symmetrical == TRUE && as_route == 1)
+ )
+ {
+ if(!route->gw_dst && !route->gw_src)
+ XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst, src);
+ else
+ XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst,
+ route->gw_dst->name, src, route->gw_src->name);
+
+ xbt_dynar_t nodes = xbt_graph_get_nodes(as->route_graph);
+ xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_net_elm->id, xbt_node_t);
+ xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst_net_elm->id, xbt_node_t);
+ xbt_edge_t edge =
+ xbt_graph_get_edge(as->route_graph, node_e_v, node_s_v);
+
+ if (edge)
+ THROWF(arg_error,0,"(AS)Route from '%s' to '%s' already exists",src,dst);
+
+ if (route->gw_dst && route->gw_src) {
+ sg_routing_edge_t gw_tmp;
+ gw_tmp = route->gw_src;
+ route->gw_src = route->gw_dst;
+ route->gw_dst = gw_tmp;
+ }
+ sg_platf_route_cbarg_t link_route_back = generic_new_extended_route(asg->hierarchy, route, 0);
+ route_new_dijkstra(as, dst_net_elm->id, src_net_elm->id, link_route_back);
+ }
+ xbt_dynar_free(&route->link_list);