static char *gw_src = NULL; /* temporary store the gateway source name of a route */
static char *gw_dst = NULL; /* temporary store the gateway destination name of a route */
static xbt_dynar_t link_list = NULL; /* temporary store of current list link of a route */
+
+static xbt_dict_t coordinates = NULL;
+
/**
* \brief Add a "host" to the network element list
*/
-static void parse_S_host(char *host_id)
+static void parse_S_host(char *host_id, char* coord)
{
network_element_info_t info = NULL;
if (current_routing->hierarchy == SURF_ROUTING_NULL)
info->rc_type = SURF_NETWORK_ELEMENT_HOST;
xbt_dict_set(global_routing->where_network_elements, host_id,
(void *) info, NULL);
+
+ if (strcmp(coord,"")) {
+ xbt_dynar_t ctn = xbt_str_split_str(coord, " ");
+ xbt_dynar_shrink(ctn,0);
+ xbt_dict_set (coordinates,host_id,ctn,NULL);
+ }
}
/*
*/
static void parse_S_host_XML(void)
{
- parse_S_host(A_surfxml_host_id);
+ parse_S_host(A_surfxml_host_id, A_surfxml_host_coordinates);
}
/*
* \brief Add a host to the network element list from lua script
*/
-static void parse_S_host_lua(char *host_id)
+static void parse_S_host_lua(char *host_id, char *coord)
{
- parse_S_host(host_id);
+ parse_S_host(host_id, coord);
}
static void parse_E_link_ctn_new_elem_XML(void)
{
- if( A_surfxml_link_ctn_direction == A_surfxml_link_ctn_direction_NONE)
- parse_E_link_ctn_new_elem(A_surfxml_link_ctn_id);
- if( A_surfxml_link_ctn_direction == A_surfxml_link_ctn_direction_UP)
- parse_E_link_ctn_new_elem(bprintf("%s_UP",A_surfxml_link_ctn_id));
- if( A_surfxml_link_ctn_direction == A_surfxml_link_ctn_direction_DOWN)
- parse_E_link_ctn_new_elem(bprintf("%s_DOWN",A_surfxml_link_ctn_id));
+ if (A_surfxml_link_ctn_direction == A_surfxml_link_ctn_direction_NONE)
+ parse_E_link_ctn_new_elem(A_surfxml_link_ctn_id);
+ if (A_surfxml_link_ctn_direction == A_surfxml_link_ctn_direction_UP) {
+ char *link_id = bprintf("%s_UP", A_surfxml_link_ctn_id);
+ parse_E_link_ctn_new_elem(link_id);
+ free(link_id);
+ }
+ if (A_surfxml_link_ctn_direction == A_surfxml_link_ctn_direction_DOWN) {
+ char *link_id = bprintf("%s_DOWN", A_surfxml_link_ctn_id);
+ parse_E_link_ctn_new_elem(link_id);
+ free(link_id);
+ }
}
/**
_finalize(global_routing->root);
/* delete "where" dict */
xbt_dict_free(&(global_routing->where_network_elements));
+ xbt_dict_free(&(coordinates));
/* delete last_route */
xbt_dynar_free(&(global_routing->last_route));
/* delete global routing structure */
/* no current routing at moment */
current_routing = NULL;
+ coordinates = xbt_dict_new();
+
/* parse generic elements */
surfxml_add_callback(STag_surfxml_host_cb_list, &parse_S_host_XML);
surfxml_add_callback(STag_surfxml_router_cb_list, &parse_S_router);
{
if(route->dst_gateway && route->src_gateway)
{
- char * gw_src = bprintf("%s",route->src_gateway);
- char * gw_dst = bprintf("%s",route->dst_gateway);
- route->src_gateway = bprintf("%s",gw_dst);
- route->dst_gateway = bprintf("%s",gw_src);
+ char *gw_src = xbt_strdup(route->src_gateway);
+ char *gw_dst = xbt_strdup(route->dst_gateway);
+ route->src_gateway = gw_dst;
+ route->dst_gateway = gw_src;
}
if(TO_ROUTE_FULL(*dst_id, *src_id))
{
{
if(route->dst_gateway && route->src_gateway)
{
- char * gw_src = bprintf("%s",route->src_gateway);
- char * gw_dst = bprintf("%s",route->dst_gateway);
- route->src_gateway = bprintf("%s",gw_dst);
- route->dst_gateway = bprintf("%s",gw_src);
+ char *gw_src = xbt_strdup(route->src_gateway);
+ char *gw_dst = xbt_strdup(route->dst_gateway);
+ route->src_gateway = gw_dst;
+ route->dst_gateway = gw_src;
}
if(!route->dst_gateway && !route->src_gateway)
SURFXML_START_TAG(link);
SURFXML_END_TAG(link);
+ free(link_id);
+ free(host_id);
break;
case 2:
SURFXML_BUFFER_SET(link_state_file, "");
SURFXML_START_TAG(link);
SURFXML_END_TAG(link);
+
+ free(link_id);
+ free(host_id);
}
break;
xbt_dynar_free(&radical_ends);
}
+ xbt_dynar_free(&radical_elements);
DEBUG0(" ");
router_id =
DEBUG0(" ");
#ifdef HAVE_PCRE_LIB
- char *new_suffix = bprintf("%s", "");
+ char *new_suffix = xbt_strdup("");
radical_elements = xbt_str_split(cluster_suffix, ".");
xbt_dynar_foreach(radical_elements, iter, groups) {
if (strcmp(groups, "")) {
- new_suffix = bprintf("%s\\.%s", new_suffix, groups);
+ char *old_suffix = new_suffix;
+ new_suffix = bprintf("%s\\.%s", old_suffix, groups);
+ free(old_suffix);
}
}
route_src_dst = bprintf("%s(.*)%s", cluster_prefix, new_suffix);
+ xbt_dynar_free(&radical_elements);
+ free(new_suffix);
+
+ char *pcre_link_src = bprintf("%s_link_$1src", cluster_id);
+ char *pcre_link_backbone = bprintf("%s_backbone", cluster_id);
+ char *pcre_link_dst = bprintf("%s_link_$1dst", cluster_id);
DEBUG2("<route\tsrc=\"%s\"\tdst=\"%s\"", route_src_dst, route_src_dst);
DEBUG0("symmetrical=\"NO\">");
A_surfxml_route_symmetrical = A_surfxml_route_symmetrical_NO;
SURFXML_START_TAG(route);
- DEBUG1("<link_ctn\tid=\"%s_link_$1src\"/>", cluster_id);
- SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_$1src", cluster_id));
+ DEBUG1("<link_ctn\tid=\"%s\"/>", pcre_link_src);
+ SURFXML_BUFFER_SET(link_ctn_id, pcre_link_src);
A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_NONE;
if(cluster_sharing_policy == A_surfxml_cluster_sharing_policy_FULLDUPLEX)
{A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_UP;}
SURFXML_START_TAG(link_ctn);
SURFXML_END_TAG(link_ctn);
- DEBUG1("<link_ctn\tid=\"%s_backbone\"/>", cluster_id);
- SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_backbone", cluster_id));
+ DEBUG1("<link_ctn\tid=\"%s\"/>", pcre_link_backbone);
+ SURFXML_BUFFER_SET(link_ctn_id, pcre_link_backbone);
A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_NONE;
SURFXML_START_TAG(link_ctn);
SURFXML_END_TAG(link_ctn);
- DEBUG1("<link_ctn\tid=\"%s_link_$1dst\"/>", cluster_id);
- SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_$1dst", cluster_id));
+ DEBUG1("<link_ctn\tid=\"%s\"/>", pcre_link_dst);
+ SURFXML_BUFFER_SET(link_ctn_id, pcre_link_dst);
A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_NONE;
if(cluster_sharing_policy == A_surfxml_cluster_sharing_policy_FULLDUPLEX)
{A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_DOWN;}
DEBUG0("</route>");
SURFXML_END_TAG(route);
+
+ free(pcre_link_dst);
+ free(pcre_link_backbone);
+ free(pcre_link_src);
+ free(route_src_dst);
#else
for (i = 0; i <= xbt_dynar_length(tab_elements_num); i++) {
for (j = 0; j <= xbt_dynar_length(tab_elements_num); j++) {
}
}
xbt_dynar_free(&tab_elements_num);
+ free(router_id);
+
#endif
+ free(link_backbone);
+ free(link_router);
+
DEBUG0("</AS>");
SURFXML_END_TAG(AS);
DEBUG0(" ");
void routing_add_host(const char *host_id)
{
- parse_S_host_lua((char *) host_id);
+ parse_S_host_lua((char *) host_id, (char*)""); // FIXME propagate coordinate system to lua
}
/*