info->rc_type = SURF_NETWORK_ELEMENT_HOST;
xbt_lib_set(host_lib,host_id,ROUTING_HOST_LEVEL,(void *) info);
if (strcmp(coord,"")) {
+ if(!COORD_HOST_LEVEL) xbt_die("To use coordinates, you must set configuration 'coordinates' to 'yes'");
xbt_dynar_t ctn = xbt_str_split_str(coord, " ");
xbt_dynar_shrink(ctn, 0);
xbt_lib_set(host_lib,host_id,COORD_HOST_LEVEL,(void *) ctn);
xbt_lib_set(as_router_lib,router_id,ROUTING_ASR_LEVEL,(void *) info);
if (strcmp(A_surfxml_router_coordinates,"")) {
- xbt_dynar_t ctn = xbt_str_split_str(A_surfxml_router_coordinates, " ");
- xbt_dynar_shrink(ctn, 0);
- xbt_lib_set(as_router_lib,router_id,COORD_ASR_LEVEL,(void *) ctn);
+ if(!COORD_ASR_LEVEL) xbt_die("To use coordinates, you must set configuration 'coordinates' to 'yes'");
+ xbt_dynar_t ctn = xbt_str_split_str(A_surfxml_router_coordinates, " ");
+ xbt_dynar_shrink(ctn, 0);
+ xbt_lib_set(as_router_lib,router_id,COORD_ASR_LEVEL,(void *) ctn);
}
}
parse_S_AS(A_surfxml_AS_id, A_surfxml_AS_routing);
if (strcmp(A_surfxml_AS_coordinates,"")) {
+ if(!COORD_ASR_LEVEL) xbt_die("To use coordinates, you must set configuration 'coordinates' to 'yes'");
XBT_DEBUG("%s coordinates : %s", A_surfxml_AS_id, A_surfxml_AS_coordinates);
xbt_dynar_t ctn = xbt_str_split_str(A_surfxml_AS_coordinates, " ");
xbt_dynar_shrink(ctn, 0);
routing_component_t *current_dst = NULL;
/* (1) find the as where the src and dst are located */
- src_as = ((network_element_info_t)
- xbt_lib_get_or_null(host_lib, src, ROUTING_HOST_LEVEL))->rc_component;
- dst_as = ((network_element_info_t)
- xbt_lib_get_or_null(host_lib, dst, ROUTING_HOST_LEVEL))->rc_component;
- xbt_assert2(src_as
- && dst_as,
- "Ask for route \"from\"(%s) or \"to\"(%s) no found", src,
- dst);
+ void * src_data = xbt_lib_get_or_null(host_lib,src, ROUTING_HOST_LEVEL);
+ void * dst_data = xbt_lib_get_or_null(host_lib,dst, ROUTING_HOST_LEVEL);
+ if(!src_data) src_data = xbt_lib_get_or_null(as_router_lib,src, ROUTING_ASR_LEVEL);
+ if(!dst_data) dst_data = xbt_lib_get_or_null(as_router_lib,dst, ROUTING_ASR_LEVEL);
+
+ if(src_data == NULL || dst_data == NULL)
+ xbt_die("Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"",
+ src, dst, rc->name);
+
+ src_as = ((network_element_info_t)src_data)->rc_component;
+ dst_as = ((network_element_info_t)dst_data)->rc_component;
/* (2) find the path to the root routing component */
path_src = xbt_dynar_new(sizeof(routing_component_t), NULL);
char *cluster_state_file = A_surfxml_cluster_state_file;
char *host_id, *groups, *link_id = NULL;
char *router_id, *link_router, *link_backbone;
- char *availability_file = bprintf("%s",cluster_availability_file);
- char *state_file = bprintf("%s",cluster_state_file);
+ char *availability_file = xbt_strdup(cluster_availability_file);
+ char *state_file = xbt_strdup(cluster_state_file);
if(xbt_dict_size(patterns)==0)
patterns = xbt_dict_new();
link_id = bprintf("%s_link_%d", cluster_id, start);
xbt_dict_set(patterns, "radical", bprintf("%d", start), xbt_free);
- temp_cluster_power = bprintf("%s",cluster_power);
+ temp_cluster_power = xbt_strdup(cluster_power);
temp_cluster_power = replace_random_parameter(temp_cluster_power);
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%s\">", host_id, temp_cluster_power);
A_surfxml_host_state = A_surfxml_host_state_ON;
SURFXML_BUFFER_SET(host_availability, "1.0");
SURFXML_BUFFER_SET(host_coordinates, "");
xbt_free(availability_file);
- availability_file = bprintf("%s",cluster_availability_file);
+ availability_file = xbt_strdup(cluster_availability_file);
xbt_free(state_file);
- state_file = bprintf("%s",cluster_state_file);
+ state_file = xbt_strdup(cluster_state_file);
XBT_DEBUG("\tavailability_file=\"%s\"",xbt_str_varsubst(availability_file,patterns));
XBT_DEBUG("\tstate_file=\"%s\"",xbt_str_varsubst(state_file,patterns));
SURFXML_BUFFER_SET(host_availability_file, xbt_str_varsubst(availability_file,patterns));
SURFXML_END_TAG(host);
- temp_cluster_bw = bprintf("%s",cluster_bw);
+ temp_cluster_bw = xbt_strdup(cluster_bw);
temp_cluster_bw = replace_random_parameter(temp_cluster_bw);
- temp_cluster_lat = bprintf("%s",cluster_lat);
+ temp_cluster_lat = xbt_strdup(cluster_lat);
temp_cluster_lat = replace_random_parameter(temp_cluster_lat);
XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_id,temp_cluster_bw, cluster_lat);
A_surfxml_link_state = A_surfxml_link_state_ON;
link_id = bprintf("%s_link_%d", cluster_id, i);
xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free);
- temp_cluster_power = bprintf("%s",cluster_power);
+ temp_cluster_power = xbt_strdup(cluster_power);
temp_cluster_power = replace_random_parameter(temp_cluster_power);
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%s\">", host_id, temp_cluster_power);
A_surfxml_host_state = A_surfxml_host_state_ON;
SURFXML_BUFFER_SET(host_availability, "1.0");
SURFXML_BUFFER_SET(host_coordinates, "");
xbt_free(availability_file);
- availability_file = bprintf("%s",cluster_availability_file);
+ availability_file = xbt_strdup(cluster_availability_file);
xbt_free(state_file);
- state_file = bprintf("%s",cluster_state_file);
+ state_file = xbt_strdup(cluster_state_file);
XBT_DEBUG("\tavailability_file=\"%s\"",xbt_str_varsubst(availability_file,patterns));
XBT_DEBUG("\tstate_file=\"%s\"",xbt_str_varsubst(state_file,patterns));
SURFXML_BUFFER_SET(host_availability_file, xbt_str_varsubst(availability_file,patterns));
xbt_free(temp_cluster_power);
- temp_cluster_bw = bprintf("%s",cluster_bw);
+ temp_cluster_bw = xbt_strdup(cluster_bw);
temp_cluster_bw = replace_random_parameter(temp_cluster_bw);
- temp_cluster_lat = bprintf("%s",cluster_lat);
+ temp_cluster_lat = xbt_strdup(cluster_lat);
temp_cluster_lat = replace_random_parameter(temp_cluster_lat);
XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_id,temp_cluster_bw, cluster_lat);
A_surfxml_link_state = A_surfxml_link_state_ON;
SURFXML_END_TAG(router);
//TODO
- xbt_dict_set(patterns, "radical", bprintf("_router"), xbt_free);
- temp_cluster_bw = bprintf("%s",cluster_bw);
+ xbt_dict_set(patterns, "radical", xbt_strdup("_router"), xbt_free);
+ temp_cluster_bw = xbt_strdup(cluster_bw);
temp_cluster_bw = replace_random_parameter(temp_cluster_bw);
- temp_cluster_lat = bprintf("%s",cluster_lat);
+ temp_cluster_lat = xbt_strdup(cluster_lat);
temp_cluster_lat = replace_random_parameter(temp_cluster_lat);
XBT_DEBUG("<link\tid=\"%s\" bw=\"%s\" lat=\"%s\"/>", link_router,temp_cluster_bw, temp_cluster_lat);
A_surfxml_link_state = A_surfxml_link_state_ON;
XBT_DEBUG(" ");
//xbt_dynar_free(&tab_elements_num);
-
+ free(host_id);
+ free(router_id);
+ free(link_router);
+ free(link_backbone);
+ free(link_id_up);
+ free(link_id_down);
surfxml_bufferstack_pop(1);
}