X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/65f020ece2b5a393e49f4a8a7bdb4dc392d2ff32..a8b5faafecff77b1540810d84fc0b387f85952a5:/src/surf/surf_routing.cpp diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index a4bbe30144..5c6e4509ba 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -401,7 +401,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS) /* add to the father element list */ info->setId(current_routing->parseAS(info)); } else { - THROWF(arg_error, 0, "All defined components must be belong to a AS"); + THROWF(arg_error, 0, "All defined components must belong to a AS"); } xbt_lib_set(as_router_lib, info->getName(), ROUTING_ASR_LEVEL, @@ -1325,6 +1325,32 @@ const char *surf_AS_get_name(AsPtr as) { return as->p_name; } +static AsPtr surf_AS_recursive_get_by_name(AsPtr current, const char * name) { + xbt_dict_cursor_t cursor = NULL; + char *key; + AS_t elem; + AsPtr tmp = NULL; + + if(!strcmp(current->p_name, name)) + return current; + + xbt_dict_foreach(current->p_routingSons, cursor, key, elem) { + tmp = surf_AS_recursive_get_by_name(elem, name); + if(tmp != NULL ) { + break; + } + } + return tmp; +} + + +AsPtr surf_AS_get_by_name(const char * name) { + AsPtr as = surf_AS_recursive_get_by_name(routing_platf->p_root, name); + if(as == NULL) + XBT_WARN("Impossible to find an AS with name %s, please check your input", name); + return as; +} + xbt_dict_t surf_AS_get_routing_sons(AsPtr as) { return as->p_routingSons; }