X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6f0020b4128661d1e48c3313eac227f0b769ed0e..cf703c9202818f2d52477ff7dd89d9374e04d842:/src/surf/surf_routing_full.c diff --git a/src/surf/surf_routing_full.c b/src/surf/surf_routing_full.c index 464b4b2bac..3c2c05d233 100644 --- a/src/surf/surf_routing_full.c +++ b/src/surf/surf_routing_full.c @@ -8,6 +8,7 @@ /* Global vars */ extern routing_global_t global_routing; +extern int surf_parse_lineno; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf"); @@ -61,13 +62,10 @@ static xbt_dynar_t full_get_onelink_routes(AS_t rc) return ret; } -static route_t full_get_route(AS_t rc, - const char *src, const char *dst) +static void full_get_route_and_latency(AS_t rc, + const char *src, const char *dst, + route_t res,double *lat) { - xbt_assert(rc && src - && dst, - "Invalid params for \"get_route\" function at AS \"%s\"", - rc->name); /* set utils vars */ routing_component_full_t routing = (routing_component_full_t) rc; @@ -75,29 +73,25 @@ static route_t full_get_route(AS_t rc, int *src_id = xbt_dict_get_or_null(routing->generic_routing.to_index, src); int *dst_id = xbt_dict_get_or_null(routing->generic_routing.to_index, dst); - xbt_assert(src_id - && dst_id, - "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table", - src, dst); + + if (!src_id || !dst_id) + THROWF(arg_error,0,"No route from '%s' to '%s'",src,dst); route_t e_route = NULL; - route_t new_e_route = NULL; void *link; unsigned int cpt = 0; e_route = TO_ROUTE_FULL(*src_id, *dst_id); if (e_route) { - new_e_route = xbt_new0(s_route_t, 1); - new_e_route->src_gateway = xbt_strdup(e_route->src_gateway); - new_e_route->dst_gateway = xbt_strdup(e_route->dst_gateway); - new_e_route->link_list = - xbt_dynar_new(global_routing->size_of_link, NULL); + res->src_gateway = xbt_strdup(e_route->src_gateway); + res->dst_gateway = xbt_strdup(e_route->dst_gateway); xbt_dynar_foreach(e_route->link_list, cpt, link) { - xbt_dynar_push(new_e_route->link_list, &link); + xbt_dynar_push(res->link_list, &link); + if (lat) + *lat += surf_network_model->extension.network.get_link_latency(link); } } - return new_e_route; } static void full_finalize(AS_t rc) @@ -124,7 +118,7 @@ AS_t model_full_create(void) new_component->generic_routing.parse_route = model_full_set_route; new_component->generic_routing.parse_ASroute = model_full_set_route; - new_component->generic_routing.get_route = full_get_route; + new_component->generic_routing.get_route_and_latency = full_get_route_and_latency; new_component->generic_routing.get_onelink_routes = full_get_onelink_routes; new_component->generic_routing.finalize = full_finalize; @@ -163,7 +157,7 @@ void model_full_end(AS_t current_routing) } } -static int surf_pointer_resource_cmp(const void *a, const void *b) { +static int full_pointer_resource_cmp(const void *a, const void *b) { return a != b; } @@ -197,17 +191,37 @@ void model_full_set_route(AS_t rc, const char *src, xbt_assert(link,"Link : '%s' doesn't exists.",link_name); xbt_dynar_push(link_route_to_test,&link); } - xbt_assert(!xbt_dynar_compare( - (void*)TO_ROUTE_FULL(*src_id, *dst_id)->link_list, - (void*)link_route_to_test, - (int_f_cpvoid_cpvoid_t) surf_pointer_resource_cmp), - "The route between \"%s\" and \"%s\" already exists. If you are trying to define a reverse route, you must set the symmetrical=no attribute to your routes tags.", src,dst); + if (xbt_dynar_compare((void*)TO_ROUTE_FULL(*src_id, *dst_id)->link_list, + (void*)link_route_to_test, + (int_f_cpvoid_cpvoid_t) full_pointer_resource_cmp)) { + surf_parse_error("A route between \"%s\" and \"%s\" already exists with a different content. " + "If you are trying to define a reverse route, you must set the symmetrical=no " + "attribute to your routes tags.", src,dst); + } else { + surf_parse_warn("Ignoring the identical redefinition of the route between \"%s\" and \"%s\"",src,dst); + } } else { if(!route->dst_gateway && !route->src_gateway) XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst); else{ + AS_t subas = xbt_dict_get_or_null(rc->routing_sons, src); + if (subas==NULL) + surf_parse_error("The source of an ASroute must be a sub-AS declared within the current AS, but '%s' is not an AS within '%s'", + src,rc->name); + if (xbt_dict_get_or_null(subas->to_index, route->src_gateway) == NULL) + surf_parse_error("In an ASroute, source gateway must be part of the source sub-AS (in particular, being in a sub-sub-AS is not allowed), but '%s' is not in '%s'.", + route->src_gateway,subas->name); + + subas = xbt_dict_get_or_null(rc->routing_sons, dst); + if (subas==NULL) + surf_parse_error("The destination of an ASroute must be a sub-AS declared within the current AS, but '%s' is not an AS within '%s'", + dst,rc->name); + if (xbt_dict_get_or_null(subas->to_index, route->dst_gateway) == NULL) + surf_parse_error("In an ASroute, destination gateway must be part of the destination sub-AS (in particular, in a sub-sub-AS is not allowed), but '%s' is not in '%s'.", + route->dst_gateway,subas->name); + 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) @@ -244,7 +258,7 @@ void model_full_set_route(AS_t rc, const char *src, xbt_assert(!xbt_dynar_compare( (void*)TO_ROUTE_FULL(*dst_id, *src_id)->link_list, (void*)link_route_to_test, - (int_f_cpvoid_cpvoid_t) surf_pointer_resource_cmp), + (int_f_cpvoid_cpvoid_t) full_pointer_resource_cmp), "The route between \"%s\" and \"%s\" already exists", src,dst); } else @@ -258,6 +272,4 @@ void model_full_set_route(AS_t rc, const char *src, xbt_dynar_shrink(TO_ROUTE_FULL(*dst_id, *src_id)->link_list, 0); } } - - generic_free_route((route_t)route) ; }