- routing_component_dijkstra_t routing = (routing_component_dijkstra_t) rc;
- int *src_id, *dst_id;
- 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);
- if(!routing->graph_node_map)
- routing->graph_node_map = xbt_dict_new();
-
- if (routing->cached && !routing->route_cache)
- routing->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(global_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(global_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(current_routing->hierarchy, route, 1);
- route_new_dijkstra(routing, *src_id, *dst_id, e_route);
+ int as_route = 0;
+ 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->name, dst, route->dst_gateway->name);
+ as_route = 1;
+ if(route->dst_gateway->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The dst_gateway '%s' does not exist!",route->dst_gateway->name);
+ if(route->src_gateway->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The src_gateway '%s' does not exist!",route->src_gateway->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);
+
+ route_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 ( (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES && as_route == 0)
+ || (A_surfxml_ASroute_symmetrical == A_surfxml_ASroute_symmetrical_YES && as_route == 1)
+ )
+ {
+ if(!route->dst_gateway && !route->src_gateway)
+ XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst, src);
+ else
+ XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst,
+ route->dst_gateway->name, src, route->src_gateway->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->dst_gateway && route->src_gateway) {
+ sg_routing_edge_t gw_tmp;
+ gw_tmp = route->src_gateway;
+ route->src_gateway = route->dst_gateway;
+ route->dst_gateway = gw_tmp;
+ }
+ route_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);
+ }