Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Verification of model Vivaldi and no link_ctn for route and AS_route.
[simgrid.git] / src / surf / surf_routing.c
index 161f9ca..7890250 100644 (file)
@@ -564,14 +564,6 @@ static void parse_S_AS(char *AS_id, char *AS_routing)
 static void parse_S_AS_XML(void)
 {
   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);
-    xbt_lib_set(as_router_lib,A_surfxml_AS_id,COORD_ASR_LEVEL,(void *) ctn);
-  }
 }
 
 /*
@@ -1162,7 +1154,7 @@ void surf_parse_add_callback_config(void)
 {
        surfxml_add_callback(STag_surfxml_config_cb_list, &routing_parse_Sconfig);
        surfxml_add_callback(ETag_surfxml_config_cb_list, &routing_parse_Econfig);
-       surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
+       surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties_XML);
        surfxml_add_callback(STag_surfxml_AS_cb_list, &surf_parse_models_setup);
        surfxml_add_callback(STag_surfxml_random_cb_list, &routing_parse_Srandom);
 }
@@ -1413,10 +1405,10 @@ static void model_full_set_route(routing_component_t rc, const char *src,
        {
                if(route->dst_gateway && route->src_gateway)
                {
-                  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;
+                  char *gw_tmp ;
+                  gw_tmp = route->src_gateway;
+                  route->src_gateway = route->dst_gateway;
+                  route->dst_gateway = gw_tmp;
                }
                if(TO_ROUTE_FULL(*dst_id, *src_id))
                {
@@ -1446,8 +1438,10 @@ static void model_full_set_route(routing_component_t rc, const char *src,
                      TO_ROUTE_FULL(*dst_id, *src_id) = generic_new_extended_route(rc->hierarchy,route,0);
                      xbt_dynar_shrink(TO_ROUTE_FULL(*dst_id, *src_id)->generic_route.link_list, 0);
                }
-
        }
+
+       if (rc->hierarchy == SURF_ROUTING_BASE) generic_free_route((route_t)route) ;
+       else generic_free_extended_route((route_extended_t)route);
 }
 
 /* ************************************************************************** */
@@ -2436,6 +2430,12 @@ static void model_rulebased_set_route(routing_component_t rc,
   rule_route_t ruleroute = xbt_new0(s_rule_route_t, 1);
   const char *error;
   int erroffset;
+
+  if(!strcmp(rc->routing->name,"Vivaldi")){
+         if(xbt_dynar_length(route->generic_route.link_list) != 0)
+                 xbt_die("You can't have link_ctn with Model Vivaldi.");
+  }
+
   ruleroute->re_src = pcre_compile(src, 0, &error, &erroffset, NULL);
   xbt_assert(ruleroute->re_src,
               "PCRE compilation failed at offset %d (\"%s\"): %s\n",
@@ -2458,6 +2458,12 @@ static void model_rulebased_set_ASroute(routing_component_t rc,
   rule_route_extended_t ruleroute_e = xbt_new0(s_rule_route_extended_t, 1);
   const char *error;
   int erroffset;
+
+  if(!strcmp(rc->routing->name,"Vivaldi")){
+         if(xbt_dynar_length(route->generic_route.link_list) != 0)
+                 xbt_die("You can't have link_ctn with Model Vivaldi.");
+  }
+
   ruleroute_e->generic_rule_route.re_src =
       pcre_compile(src, 0, &error, &erroffset, NULL);
   xbt_assert(ruleroute_e->generic_rule_route.re_src,
@@ -3187,8 +3193,8 @@ generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
     links = e_route->generic_route.link_list;
 
     /* remeber not erase the gateway names */
-    new_e_route->src_gateway = e_route->src_gateway;
-    new_e_route->dst_gateway = e_route->dst_gateway;
+    new_e_route->src_gateway = strdup(e_route->src_gateway);
+    new_e_route->dst_gateway = strdup(e_route->dst_gateway);
   }
 
   links_id = new_e_route->generic_route.link_list;
@@ -3306,8 +3312,8 @@ static void generic_src_dst_check(routing_component_t rc, const char *src,
          xbt_die("The src(%s in %s) and dst(%s in %s) are in differents AS",
               src, src_as->name, dst, dst_as->name);
   if(rc != dst_as)
-        xbt_die("The routing component of src and dst is not the same as the network elements belong (%s==%s)",
-     rc->name, dst_as->name);
+        xbt_die("The routing component of src'%s' and dst'%s' is not the same as the network elements belong (%s?=%s?=%s)",
+     src,dst,src_as->name, dst_as->name,rc->name);
 }
 
 static void routing_parse_Sconfig(void)
@@ -3389,11 +3395,9 @@ static void routing_parse_Scluster(void)
   SURFXML_BUFFER_SET(AS_id, cluster_id);
 #ifdef HAVE_PCRE_LIB
   SURFXML_BUFFER_SET(AS_routing, "RuleBased");
-  SURFXML_BUFFER_SET(AS_coordinates, "");
   XBT_DEBUG("<AS id=\"%s\"\trouting=\"RuleBased\">", cluster_id);
 #else
   SURFXML_BUFFER_SET(AS_routing, "Full");
-  SURFXML_BUFFER_SET(AS_coordinates, "");
   XBT_DEBUG("<AS id=\"%s\"\trouting=\"Full\">", cluster_id);
 #endif
   SURFXML_START_TAG(AS);
@@ -3754,7 +3758,6 @@ static char* replace_random_parameter(char * string)
 
 static void clean_dict_random(void)
 {
-       XBT_DEBUG("Clean dict for random");
        xbt_dict_free(&random_value);
        xbt_dict_free(&patterns);
 }
@@ -3775,18 +3778,6 @@ static void routing_parse_Speer(void)
   char *host_id = NULL;
   char *router_id, *link_router, *link_backbone, *link_id_up, *link_id_down;
 
-#ifdef HAVE_PCRE_LIB
-
-#endif
-
-  int peer_sharing_policy = AX_surfxml_peer_sharing_policy;
-
-#ifndef HAVE_PCRE_LIB
-  //xbt_dynar_t tab_elements_num = xbt_dynar_new(sizeof(int), NULL);
-  //char *route_src, *route_dst;
-  //int j;
-#endif
-
   static unsigned int surfxml_buffer_stack_stack_ptr = 1;
   static unsigned int surfxml_buffer_stack_stack[1024];
 
@@ -3795,14 +3786,10 @@ static void routing_parse_Speer(void)
   surfxml_bufferstack_push(1);
 
   SURFXML_BUFFER_SET(AS_id, peer_id);
-  SURFXML_BUFFER_SET(AS_coordinates, peer_coord);
-#ifdef HAVE_PCRE_LIB
-  SURFXML_BUFFER_SET(AS_routing, "RuleBased");
-  XBT_DEBUG("<AS id=\"%s\"\trouting=\"RuleBased\">", peer_id);
-#else
+
   SURFXML_BUFFER_SET(AS_routing, "Full");
   XBT_DEBUG("<AS id=\"%s\"\trouting=\"Full\">", peer_id);
-#endif
+
   SURFXML_START_TAG(AS);
 
   XBT_DEBUG(" ");
@@ -3834,8 +3821,6 @@ static void routing_parse_Speer(void)
   XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_id_up, peer_bw_in, peer_lat);
   A_surfxml_link_state = A_surfxml_link_state_ON;
   A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
-  if(peer_sharing_policy == A_surfxml_peer_sharing_policy_FULLDUPLEX)
-{A_surfxml_link_sharing_policy =  A_surfxml_link_sharing_policy_FULLDUPLEX;}
   SURFXML_BUFFER_SET(link_id, link_id_up);
   SURFXML_BUFFER_SET(link_bandwidth, peer_bw_in);
   SURFXML_BUFFER_SET(link_latency, peer_lat);
@@ -3848,8 +3833,6 @@ static void routing_parse_Speer(void)
   XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_id_down, peer_bw_out, peer_lat);
   A_surfxml_link_state = A_surfxml_link_state_ON;
   A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
-  if(peer_sharing_policy == A_surfxml_cluster_sharing_policy_FULLDUPLEX)
-{A_surfxml_link_sharing_policy =  A_surfxml_link_sharing_policy_FULLDUPLEX;}
   SURFXML_BUFFER_SET(link_id, link_id_down);
   SURFXML_BUFFER_SET(link_bandwidth, peer_bw_out);
   SURFXML_BUFFER_SET(link_latency, peer_lat);
@@ -3862,9 +3845,9 @@ static void routing_parse_Speer(void)
   XBT_DEBUG(" ");
 
   // begin here
-  XBT_DEBUG("<route\tsrc=\"%s\"\tdst=\"%s\"", peer_id, router_id);
+  XBT_DEBUG("<route\tsrc=\"%s\"\tdst=\"%s\"", host_id, router_id);
   XBT_DEBUG("symmetrical=\"NO\">");
-  SURFXML_BUFFER_SET(route_src, peer_id);
+  SURFXML_BUFFER_SET(route_src, host_id);
   SURFXML_BUFFER_SET(route_dst, router_id);
   A_surfxml_route_symmetrical = A_surfxml_route_symmetrical_NO;
   SURFXML_START_TAG(route);
@@ -3872,8 +3855,6 @@ static void routing_parse_Speer(void)
   XBT_DEBUG("<link_ctn\tid=\"%s\"/>", link_id_up);
   SURFXML_BUFFER_SET(link_ctn_id, link_id_up);
   A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_NONE;
-  if(peer_sharing_policy == A_surfxml_peer_sharing_policy_FULLDUPLEX)
-  {A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_UP;}
   SURFXML_START_TAG(link_ctn);
   SURFXML_END_TAG(link_ctn);
 
@@ -3881,18 +3862,16 @@ static void routing_parse_Speer(void)
   SURFXML_END_TAG(route);
 
   //Opposite Route
-  XBT_DEBUG("<route\tsrc=\"%s\"\tdst=\"%s\"", router_id, peer_id);
+  XBT_DEBUG("<route\tsrc=\"%s\"\tdst=\"%s\"", router_id, host_id);
   XBT_DEBUG("symmetrical=\"NO\">");
   SURFXML_BUFFER_SET(route_src, router_id);
-  SURFXML_BUFFER_SET(route_dst, peer_id);
+  SURFXML_BUFFER_SET(route_dst, host_id);
   A_surfxml_route_symmetrical = A_surfxml_route_symmetrical_NO;
   SURFXML_START_TAG(route);
 
   XBT_DEBUG("<link_ctn\tid=\"%s\"/>", link_id_down);
   SURFXML_BUFFER_SET(link_ctn_id, link_id_down);
   A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_NONE;
-  if(peer_sharing_policy == A_surfxml_peer_sharing_policy_FULLDUPLEX)
-  {A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_DOWN;}
   SURFXML_START_TAG(link_ctn);
   SURFXML_END_TAG(link_ctn);