+static void generic_set_ASroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route) {
+ DEBUG4("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",src,e_route->src_gateway,dst,e_route->dst_gateway);
+ model_type_t modeltype = rc->routing;
+ xbt_dict_t _parse_routes;
+ xbt_dict_t _to_index;
+ char *route_name;
+ int *src_id, *dst_id;
+
+ if(modeltype==&routing_models[SURF_MODEL_FULL]) {
+ _parse_routes = ((routing_component_full_t)rc)->parse_routes;
+ _to_index = ((routing_component_full_t)rc)->to_index;
+
+ } else if(modeltype==&routing_models[SURF_MODEL_FLOYD]) {
+ _parse_routes = ((routing_component_floyd_t)rc)->parse_routes;
+ _to_index = ((routing_component_floyd_t)rc)->to_index;
+
+ } else if(modeltype==&routing_models[SURF_MODEL_DIJKSTRA]||
+ modeltype==&routing_models[SURF_MODEL_DIJKSTRACACHE]) {
+ _parse_routes = ((routing_component_dijkstra_t)rc)->parse_routes;
+ _to_index = ((routing_component_dijkstra_t)rc)->to_index;
+
+ } else xbt_die("\"generic_set_route\" not support");
+
+ src_id = xbt_dict_get_or_null(_to_index, src);
+ dst_id = xbt_dict_get_or_null(_to_index, dst);
+
+ xbt_assert2(src_id&&dst_id,"Network elements %s or %s not found", src, dst);
+ route_name = bprintf("%d#%d",*src_id,*dst_id);
+
+ xbt_assert2(xbt_dynar_length(e_route->generic_route.link_list)>0, "Invalid count of links, must be greater than zero (%s,%s)",src,dst);
+ xbt_assert4(!xbt_dict_get_or_null(_parse_routes,route_name),
+ "The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",src,e_route->src_gateway,dst,e_route->dst_gateway);
+
+ xbt_dict_set(_parse_routes, route_name, e_route, NULL);
+ xbt_free(route_name);
+}
+
+static void generic_set_bypassroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route) {
+ DEBUG2("Load bypassRoute from \"%s\" to \"%s\"",src,dst);
+ model_type_t modeltype = rc->routing;
+ xbt_dict_t dict_bypassRoutes;
+ char *route_name;
+ if(modeltype==&routing_models[SURF_MODEL_FULL]) {
+ dict_bypassRoutes = ((routing_component_full_t)rc)->bypassRoutes;
+ } else if(modeltype==&routing_models[SURF_MODEL_FLOYD]) {
+ dict_bypassRoutes = ((routing_component_floyd_t)rc)->bypassRoutes;
+ } else if(modeltype==&routing_models[SURF_MODEL_DIJKSTRA]||
+ modeltype==&routing_models[SURF_MODEL_DIJKSTRACACHE]) {
+ dict_bypassRoutes = ((routing_component_dijkstra_t)rc)->bypassRoutes;
+ } else xbt_die("\"generic_set_bypassroute\" not support");
+ route_name = bprintf("%s#%s",src,dst);
+ xbt_assert2(xbt_dynar_length(e_route->generic_route.link_list)>0, "Invalid count of links, must be greater than zero (%s,%s)",src,dst);
+ xbt_assert4(!xbt_dict_get_or_null(dict_bypassRoutes,route_name),
+ "The bypass route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",src,e_route->src_gateway,dst,e_route->dst_gateway);
+
+ route_extended_t new_e_route = generic_new_extended_route(SURF_ROUTING_RECURSIVE,e_route,0);
+ xbt_dynar_free( &(e_route->generic_route.link_list) );
+ xbt_free(e_route);
+
+ xbt_dict_set(dict_bypassRoutes, route_name, new_e_route, (void(*)(void*))generic_free_extended_route );
+ xbt_free(route_name);
+}
+
+/* ************************************************************************** */
+/* *********************** GENERIC BUSINESS METHODS ************************* */
+
+static route_extended_t generic_get_bypassroute(routing_component_t rc, const char* src, const char* dst) {
+ model_type_t modeltype = rc->routing;
+ xbt_dict_t dict_bypassRoutes;
+
+ if(modeltype==&routing_models[SURF_MODEL_FULL]) {
+ dict_bypassRoutes = ((routing_component_full_t)rc)->bypassRoutes;
+ } else if(modeltype==&routing_models[SURF_MODEL_FLOYD]) {
+ dict_bypassRoutes = ((routing_component_floyd_t)rc)->bypassRoutes;
+ } else if(modeltype==&routing_models[SURF_MODEL_DIJKSTRA]||
+ modeltype==&routing_models[SURF_MODEL_DIJKSTRACACHE]) {
+ dict_bypassRoutes = ((routing_component_dijkstra_t)rc)->bypassRoutes;
+ } else xbt_die("\"generic_set_bypassroute\" not support");
+
+
+ routing_component_t src_as, dst_as;
+ int index_src, index_dst;
+ xbt_dynar_t path_src = NULL;
+ xbt_dynar_t path_dst = NULL;
+ routing_component_t current = NULL;
+ routing_component_t* current_src = NULL;
+ routing_component_t* current_dst = NULL;
+
+ /* (1) find the as where the src and dst are located */
+ src_as = xbt_dict_get_or_null(global_routing->where_network_elements,src);
+ dst_as = xbt_dict_get_or_null(global_routing->where_network_elements,dst);
+ xbt_assert2(src_as&&dst_as, "Ask for route \"from\"(%s) or \"to\"(%s) no found",src,dst);
+
+ /* (2) find the path to the root routing component */
+ path_src = xbt_dynar_new(sizeof(routing_component_t), NULL);
+ current = src_as;
+ while( current != NULL ) {
+ xbt_dynar_push(path_src,¤t);
+ current = current->routing_father;
+ }
+ path_dst = xbt_dynar_new(sizeof(routing_component_t), NULL);
+ current = dst_as;
+ while( current != NULL ) {
+ xbt_dynar_push(path_dst,¤t);
+ current = current->routing_father;