X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2c5c14ffd2b2af540f201434bd4d32f9c197507f..5572adcb6316b36ca4c10a9b004232f84865592a:/src/surf/surf_routing.c diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 371019e056..50f6ddc9ac 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -206,7 +206,7 @@ static void parse_S_router(sg_platf_router_cbarg_t router) xbt_lib_set(as_router_lib, router->id, ROUTING_ASR_LEVEL, (void *) info); XBT_DEBUG("Having set name '%s' id '%d'",router->id,info->id); - if (strcmp(router->coord, "")) { + if (router->coord && strcmp(router->coord, "")) { unsigned int cursor; char*str; @@ -284,27 +284,6 @@ static void routing_parse_S_bypassASroute(void) src, dst,gw_src,gw_dst); parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref); } -/** - * \brief Set a new link on the actual list of link for a route or ASroute from XML - */ - -static void routing_parse_link_ctn(void) -{ - char *link_id; - switch (A_surfxml_link_ctn_direction) { - case AU_surfxml_link_ctn_direction: - case A_surfxml_link_ctn_direction_NONE: - link_id = xbt_strdup(A_surfxml_link_ctn_id); - break; - case A_surfxml_link_ctn_direction_UP: - link_id = bprintf("%s_UP", A_surfxml_link_ctn_id); - break; - case A_surfxml_link_ctn_direction_DOWN: - link_id = bprintf("%s_DOWN", A_surfxml_link_ctn_id); - break; - } - xbt_dynar_push(parsed_link_list, &link_id); -} /** * \brief Store the route by calling the set_route function of the current routing component @@ -373,6 +352,28 @@ static void routing_parse_E_bypassRoute(void) gw_src = NULL; gw_dst = NULL; } + +/** + * \brief Set a new link on the actual list of link for a route or ASroute from XML + */ + +static void routing_parse_link_ctn(sg_platf_linkctn_cbarg_t linkctn) +{ + char *link_id; + switch (linkctn->direction) { + case SURF_LINK_DIRECTION_NONE: + link_id = xbt_strdup(linkctn->id); + break; + case SURF_LINK_DIRECTION_UP: + link_id = bprintf("%s_UP", linkctn->id); + break; + case SURF_LINK_DIRECTION_DOWN: + link_id = bprintf("%s_DOWN", linkctn->id); + break; + } + xbt_dynar_push(parsed_link_list, &link_id); +} + /** * \brief Store the bypass route by calling the set_bypassroute function of the current routing component */ @@ -793,7 +794,6 @@ static void routing_parse_cabinet(sg_platf_cabinet_cbarg_t cabinet) xbt_dynar_t radical_elements; xbt_dynar_t radical_ends; - XBT_INFO("See cabinet: %s",cabinet->id); //Make all hosts radical_elements = xbt_str_split(cabinet->radical, ","); xbt_dynar_foreach(radical_elements, iter, groups) { @@ -868,8 +868,8 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) xbt_dynar_t radical_elements; xbt_dynar_t radical_ends; - if (strcmp(cluster->availability_trace, "") - || strcmp(cluster->state_trace, "")) { + if ((cluster->availability_trace && strcmp(cluster->availability_trace, "")) + || (cluster->state_trace && strcmp(cluster->state_trace, ""))) { patterns = xbt_dict_new_homogeneous(xbt_free_f); xbt_dict_set(patterns, "id", xbt_strdup(cluster->id), NULL); xbt_dict_set(patterns, "prefix", xbt_strdup(cluster->prefix), NULL); @@ -909,7 +909,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) memset(&host, 0, sizeof(host)); host.id = host_id; - if (strcmp(cluster->availability_trace, "")) { + if (cluster->availability_trace && strcmp(cluster->availability_trace, "")) { xbt_dict_set(patterns, "radical", bprintf("%d", i), NULL); char *avail_file = xbt_str_varsubst(cluster->availability_trace, patterns); XBT_DEBUG("\tavailability_file=\"%s\"", avail_file); @@ -919,7 +919,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) XBT_DEBUG("\tavailability_file=\"\""); } - if (strcmp(cluster->state_trace, "")) { + if (cluster->state_trace && strcmp(cluster->state_trace, "")) { char *avail_file = xbt_str_varsubst(cluster->state_trace, patterns); XBT_DEBUG("\tstate_file=\"%s\"", avail_file); host.state_trace = tmgr_trace_new_from_file(avail_file); @@ -1211,8 +1211,6 @@ void routing_register_callbacks() surfxml_add_callback(STag_surfxml_bypassASroute_cb_list, &routing_parse_S_bypassASroute); - surfxml_add_callback(ETag_surfxml_link_ctn_cb_list, &routing_parse_link_ctn); - surfxml_add_callback(ETag_surfxml_route_cb_list, &routing_parse_E_route); surfxml_add_callback(ETag_surfxml_ASroute_cb_list, &routing_parse_E_ASroute); surfxml_add_callback(ETag_surfxml_bypassRoute_cb_list, @@ -1226,6 +1224,8 @@ void routing_register_callbacks() sg_platf_peer_add_cb(routing_parse_peer); sg_platf_postparse_add_cb(routing_parse_postparse); + sg_platf_linkctn_add_cb(routing_parse_link_ctn); + /* we care about the ASes while parsing the platf. Incredible, isnt it? */ sg_platf_AS_end_add_cb(routing_AS_end); sg_platf_AS_begin_add_cb(routing_AS_begin);