X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f7bbc27a9c71861263b01883617b2828e974bb68..346c06db41ebb088e88351d8381d0c232d2ddbb5:/src/surf/surf_routing.c diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 0d0408b21b..53a5d6223e 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -54,7 +54,7 @@ sg_routing_edge_t sg_routing_edge_by_name_or_null(const char *name) { } /* Global vars */ -routing_global_t global_routing = NULL; +routing_platf_t routing_platf = NULL; AS_t current_routing = NULL; /* global parse functions */ @@ -199,13 +199,10 @@ static void parse_S_router(sg_platf_router_cbarg_t router) */ static void routing_parse_S_route(void) { - if (src != NULL && dst != NULL && parsed_link_list != NULL) - THROWF(arg_error, 0, "Route between %s to %s can not be defined", - A_surfxml_route_src, A_surfxml_route_dst); src = A_surfxml_route_src; dst = A_surfxml_route_dst; xbt_assert(strlen(src) > 0 || strlen(dst) > 0, - "Some limits are null in the route between \"%s\" and \"%s\"", + "Missing end-points while defining route \"%s\"->\"%s\"", src, dst); parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } @@ -215,17 +212,13 @@ static void routing_parse_S_route(void) */ static void routing_parse_S_ASroute(void) { - if (src != NULL && dst != NULL && parsed_link_list != NULL) - THROWF(arg_error, 0, "Route between %s to %s can not be defined", - A_surfxml_ASroute_src, A_surfxml_ASroute_dst); src = A_surfxml_ASroute_src; dst = A_surfxml_ASroute_dst; gw_src = A_surfxml_ASroute_gw_src; gw_dst = A_surfxml_ASroute_gw_dst; - xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0 - || strlen(gw_dst) > 0, - "Some limits are null in the route between \"%s\" and \"%s\"", - src, dst); + xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0 || strlen(gw_dst) > 0, + "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)", + src, dst,gw_src,gw_dst); parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } @@ -234,18 +227,13 @@ static void routing_parse_S_ASroute(void) */ static void routing_parse_S_bypassRoute(void) { - if (src != NULL && dst != NULL && parsed_link_list != NULL) - THROWF(arg_error, 0, - "Bypass Route between %s to %s can not be defined", - A_surfxml_bypassRoute_src, A_surfxml_bypassRoute_dst); src = A_surfxml_bypassRoute_src; dst = A_surfxml_bypassRoute_dst; gw_src = NULL; gw_dst = NULL; - xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0 - || strlen(gw_dst) > 0, - "Some limits are null in the route between \"%s\" and \"%s\"", - src, dst); + xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0 || strlen(gw_dst) > 0, + "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)", + src, dst,gw_src,gw_dst); parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } @@ -254,18 +242,13 @@ static void routing_parse_S_bypassRoute(void) */ static void routing_parse_S_bypassASroute(void) { - if (src != NULL && dst != NULL && parsed_link_list != NULL) - THROWF(arg_error, 0, - "Bypass AS Route between %s to %s can not be defined", - A_surfxml_bypassASroute_src, A_surfxml_bypassASroute_dst); src = A_surfxml_bypassASroute_src; dst = A_surfxml_bypassASroute_dst; gw_src = A_surfxml_bypassASroute_gw_src; gw_dst = A_surfxml_bypassASroute_gw_dst; - xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0 - || strlen(gw_dst) > 0, - "Some limits are null in the route between \"%s\" and \"%s\"", - src, dst); + xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0 || strlen(gw_dst) > 0, + "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)", + src, dst,gw_src,gw_dst); parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } /** @@ -316,8 +299,12 @@ static void routing_parse_E_ASroute(void) e_route->link_list = parsed_link_list; if (!strcmp(current_routing->model_desc->name,"RuleBased")) { - e_route->src_gateway = (sg_routing_edge_t) gw_src; // DIRTY HACK possible only FIXME - e_route->dst_gateway = (sg_routing_edge_t) gw_dst; // because of what is in routing_parse_E_ASroute + // DIRTY PERL HACK AHEAD: with the rulebased routing, the {src,dst}_gateway fields + // store the provided name instead of the entity directly (model_rulebased_parse_ASroute knows) + // + // This is because the user will provide something like "^AS_(.*)$" instead of the proper name of a given entity + e_route->src_gateway = (sg_routing_edge_t) gw_src; + e_route->dst_gateway = (sg_routing_edge_t) gw_dst; } else { e_route->src_gateway = sg_routing_edge_by_name_or_null(gw_src); e_route->dst_gateway = sg_routing_edge_by_name_or_null(gw_dst); @@ -419,13 +406,13 @@ void routing_AS_begin(const char *AS_id, const char *wanted_routing_type) sg_routing_edge_t info = NULL; info = xbt_new0(s_network_element_t, 1); - if (current_routing == NULL && global_routing->root == NULL) { + if (current_routing == NULL && routing_platf->root == NULL) { /* it is the first one */ new_as->routing_father = NULL; - global_routing->root = new_as; + routing_platf->root = new_as; info->id = -1; - } else if (current_routing != NULL && global_routing->root != NULL) { + } else if (current_routing != NULL && routing_platf->root != NULL) { xbt_assert(!xbt_dict_get_or_null (current_routing->routing_sons, AS_id), @@ -652,8 +639,8 @@ void routing_get_route_and_latency(sg_routing_edge_t src, { XBT_DEBUG("routing_get_route_and_latency from %s to %s",src->name,dst->name); if (!*route) { - xbt_dynar_reset(global_routing->last_route); - *route = global_routing->last_route; + xbt_dynar_reset(routing_platf->last_route); + *route = routing_platf->last_route; } _get_route_and_latency(src, dst, route, latency); @@ -685,7 +672,7 @@ static xbt_dynar_t recursive_get_onelink_routes(AS_t rc) static xbt_dynar_t get_onelink_routes(void) { - return recursive_get_onelink_routes(global_routing->root); + return recursive_get_onelink_routes(routing_platf->root); } e_surf_network_element_type_t routing_get_network_element_type(const char *name) @@ -705,11 +692,11 @@ e_surf_network_element_type_t routing_get_network_element_type(const char *name) void routing_model_create( void *loopback) { /* config the uniq global routing */ - global_routing = xbt_new0(s_routing_global_t, 1); - global_routing->root = NULL; - global_routing->get_onelink_routes = get_onelink_routes; - global_routing->loopback = loopback; - global_routing->last_route = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); + routing_platf = xbt_new0(s_routing_platf_t, 1); + routing_platf->root = NULL; + routing_platf->get_onelink_routes = get_onelink_routes; + routing_platf->loopback = loopback; + routing_platf->last_route = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); /* no current routing at moment */ current_routing = NULL; } @@ -1216,9 +1203,9 @@ static void finalize_rec(AS_t as) { /** \brief Frees all memory allocated by the routing module */ void routing_exit(void) { - if (!global_routing) + if (!routing_platf) return; - xbt_dynar_free(&global_routing->last_route); - finalize_rec(global_routing->root); - xbt_free(global_routing); + xbt_dynar_free(&routing_platf->last_route); + finalize_rec(routing_platf->root); + xbt_free(routing_platf); }