Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use the function sg_platf_new_linkctn when parsing platform
authornavarro <navarro@caraja.(none)>
Fri, 3 Aug 2012 14:44:09 +0000 (16:44 +0200)
committernavarro <navarro@caraja.(none)>
Fri, 3 Aug 2012 14:46:51 +0000 (16:46 +0200)
include/simgrid/platf.h
src/include/simgrid/platf_interface.h
src/surf/sg_platf.c
src/surf/surf_routing.c
src/surf/surfxml_parse.c

index e517a94..aa0075d 100644 (file)
@@ -52,6 +52,12 @@ typedef enum {
   SURF_LINK_FATPIPE = 0
 } e_surf_link_sharing_policy_t;
 
   SURF_LINK_FATPIPE = 0
 } e_surf_link_sharing_policy_t;
 
+typedef enum {
+  SURF_LINK_DIRECTION_NONE = 2,
+  SURF_LINK_DIRECTION_UP = 1,
+  SURF_LINK_DIRECTION_DOWN = 0
+} e_surf_link_ctn_direction_t;
+
 /*
  * Platform creation functions. Instead of passing 123 arguments to the creation functions
  * (one for each possible XML attribute), we pass structures containing them all. It removes the
 /*
  * Platform creation functions. Instead of passing 123 arguments to the creation functions
  * (one for each possible XML attribute), we pass structures containing them all. It removes the
@@ -113,7 +119,7 @@ typedef struct s_sg_platf_peer_cbarg {
 typedef struct s_sg_platf_linkctn_cbarg *sg_platf_linkctn_cbarg_t;
 typedef struct s_sg_platf_linkctn_cbarg {
   const char *id;
 typedef struct s_sg_platf_linkctn_cbarg *sg_platf_linkctn_cbarg_t;
 typedef struct s_sg_platf_linkctn_cbarg {
   const char *id;
-  const char *direction;
+  e_surf_link_ctn_direction_t direction;
 } s_sg_platf_linkctn_cbarg_t;
 
 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
 } s_sg_platf_linkctn_cbarg_t;
 
 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
@@ -181,6 +187,7 @@ XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an
 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_host_link(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_router (sg_platf_router_cbarg_t router); // Add a router  to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_link   (sg_platf_link_cbarg_t link);     // Add a link    to the currently described AS
+XBT_PUBLIC(void) sg_platf_new_linkctn   (sg_platf_linkctn_cbarg_t linkctn);     // Add a linkctn
 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_peer   (sg_platf_peer_cbarg_t peer);     // Add a peer    to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
 XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
index 683ca3e..b230dc7 100644 (file)
@@ -22,6 +22,7 @@ typedef void (*sg_platf_host_cb_t)(sg_platf_host_cbarg_t);
 typedef void (*sg_platf_host_link_cb_t)(sg_platf_host_link_cbarg_t);
 typedef void (*sg_platf_router_cb_t)(sg_platf_router_cbarg_t);
 typedef void (*sg_platf_link_cb_t)(sg_platf_link_cbarg_t);
 typedef void (*sg_platf_host_link_cb_t)(sg_platf_host_link_cbarg_t);
 typedef void (*sg_platf_router_cb_t)(sg_platf_router_cbarg_t);
 typedef void (*sg_platf_link_cb_t)(sg_platf_link_cbarg_t);
+typedef void (*sg_platf_linkctn_cb_t)(sg_platf_linkctn_cbarg_t);
 typedef void (*sg_platf_peer_cb_t)(sg_platf_peer_cbarg_t);
 typedef void (*sg_platf_cluster_cb_t)(sg_platf_cluster_cbarg_t);
 typedef void (*sg_platf_cabinet_cb_t)(sg_platf_cabinet_cbarg_t);
 typedef void (*sg_platf_peer_cb_t)(sg_platf_peer_cbarg_t);
 typedef void (*sg_platf_cluster_cb_t)(sg_platf_cluster_cbarg_t);
 typedef void (*sg_platf_cabinet_cb_t)(sg_platf_cabinet_cbarg_t);
@@ -36,6 +37,7 @@ void sg_platf_host_add_cb(sg_platf_host_cb_t);
 void sg_platf_host_link_add_cb(sg_platf_host_link_cb_t);
 void sg_platf_router_add_cb(sg_platf_router_cb_t);
 void sg_platf_link_add_cb(sg_platf_link_cb_t);
 void sg_platf_host_link_add_cb(sg_platf_host_link_cb_t);
 void sg_platf_router_add_cb(sg_platf_router_cb_t);
 void sg_platf_link_add_cb(sg_platf_link_cb_t);
+void sg_platf_linkctn_add_cb(sg_platf_linkctn_cb_t fct);
 void sg_platf_peer_add_cb(sg_platf_peer_cb_t fct);
 void sg_platf_cluster_add_cb(sg_platf_cluster_cb_t fct);
 void sg_platf_cabinet_add_cb(sg_platf_cabinet_cb_t fct);
 void sg_platf_peer_add_cb(sg_platf_peer_cb_t fct);
 void sg_platf_cluster_add_cb(sg_platf_cluster_cb_t fct);
 void sg_platf_cabinet_add_cb(sg_platf_cabinet_cb_t fct);
index 0e4060f..e4480b1 100644 (file)
@@ -15,6 +15,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
 xbt_dynar_t sg_platf_host_cb_list = NULL;   // of sg_platf_host_cb_t
 xbt_dynar_t sg_platf_host_link_cb_list = NULL;   // of sg_platf_host_link_cb_t
 xbt_dynar_t sg_platf_link_cb_list = NULL;   // of sg_platf_link_cb_t
 xbt_dynar_t sg_platf_host_cb_list = NULL;   // of sg_platf_host_cb_t
 xbt_dynar_t sg_platf_host_link_cb_list = NULL;   // of sg_platf_host_link_cb_t
 xbt_dynar_t sg_platf_link_cb_list = NULL;   // of sg_platf_link_cb_t
+xbt_dynar_t sg_platf_linkctn_cb_list = NULL;   // of sg_platf_linkctn_cb_t
 xbt_dynar_t sg_platf_router_cb_list = NULL; // of sg_platf_router_cb_t
 xbt_dynar_t sg_platf_peer_cb_list = NULL; // of sg_platf_peer_cb_t
 xbt_dynar_t sg_platf_cluster_cb_list = NULL; // of sg_platf_cluster_cb_t
 xbt_dynar_t sg_platf_router_cb_list = NULL; // of sg_platf_router_cb_t
 xbt_dynar_t sg_platf_peer_cb_list = NULL; // of sg_platf_peer_cb_t
 xbt_dynar_t sg_platf_cluster_cb_list = NULL; // of sg_platf_cluster_cb_t
@@ -42,8 +43,9 @@ void sg_platf_init(void) {
 
   sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
   sg_platf_host_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_link_cb_t), NULL);
 
   sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
   sg_platf_host_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_link_cb_t), NULL);
-  sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
-  sg_platf_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
+  sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_router_cb_t), NULL);
+  sg_platf_link_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t), NULL);
+  sg_platf_linkctn_cb_list = xbt_dynar_new(sizeof(sg_platf_linkctn_cb_t), NULL);
   sg_platf_peer_cb_list = xbt_dynar_new(sizeof(sg_platf_peer_cb_t), NULL);
   sg_platf_cluster_cb_list = xbt_dynar_new(sizeof(sg_platf_cluster_cb_t), NULL);
   sg_platf_cabinet_cb_list = xbt_dynar_new(sizeof(sg_platf_cabinet_cb_t), NULL);
   sg_platf_peer_cb_list = xbt_dynar_new(sizeof(sg_platf_peer_cb_t), NULL);
   sg_platf_cluster_cb_list = xbt_dynar_new(sizeof(sg_platf_cluster_cb_t), NULL);
   sg_platf_cabinet_cb_list = xbt_dynar_new(sizeof(sg_platf_cabinet_cb_t), NULL);
@@ -62,6 +64,7 @@ void sg_platf_exit(void) {
   xbt_dynar_free(&sg_platf_host_link_cb_list);
   xbt_dynar_free(&sg_platf_router_cb_list);
   xbt_dynar_free(&sg_platf_link_cb_list);
   xbt_dynar_free(&sg_platf_host_link_cb_list);
   xbt_dynar_free(&sg_platf_router_cb_list);
   xbt_dynar_free(&sg_platf_link_cb_list);
+  xbt_dynar_free(&sg_platf_linkctn_cb_list);
   xbt_dynar_free(&sg_platf_postparse_cb_list);
   xbt_dynar_free(&sg_platf_peer_cb_list);
   xbt_dynar_free(&sg_platf_cluster_cb_list);
   xbt_dynar_free(&sg_platf_postparse_cb_list);
   xbt_dynar_free(&sg_platf_peer_cb_list);
   xbt_dynar_free(&sg_platf_cluster_cb_list);
@@ -106,6 +109,14 @@ void sg_platf_new_link(sg_platf_link_cbarg_t link){
     fun(link);
   }
 }
     fun(link);
   }
 }
+
+void sg_platf_new_linkctn(sg_platf_linkctn_cbarg_t linkctn){
+  unsigned int iterator;
+  sg_platf_linkctn_cb_t fun;
+  xbt_dynar_foreach(sg_platf_linkctn_cb_list, iterator, fun) {
+    fun(linkctn);
+  }
+}
 void sg_platf_new_peer(sg_platf_peer_cbarg_t peer){
   unsigned int iterator;
   sg_platf_peer_cb_t fun;
 void sg_platf_new_peer(sg_platf_peer_cbarg_t peer){
   unsigned int iterator;
   sg_platf_peer_cb_t fun;
@@ -212,6 +223,9 @@ void sg_platf_host_link_add_cb(sg_platf_host_link_cb_t fct) {
 void sg_platf_link_add_cb(sg_platf_link_cb_t fct) {
   xbt_dynar_push(sg_platf_link_cb_list, &fct);
 }
 void sg_platf_link_add_cb(sg_platf_link_cb_t fct) {
   xbt_dynar_push(sg_platf_link_cb_list, &fct);
 }
+void sg_platf_linkctn_add_cb(sg_platf_linkctn_cb_t fct) {
+  xbt_dynar_push(sg_platf_linkctn_cb_list, &fct);
+}
 void sg_platf_router_add_cb(sg_platf_router_cb_t fct) {
   xbt_dynar_push(sg_platf_router_cb_list, &fct);
 }
 void sg_platf_router_add_cb(sg_platf_router_cb_t fct) {
   xbt_dynar_push(sg_platf_router_cb_list, &fct);
 }
index f9c6dc4..50f6ddc 100644 (file)
@@ -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);
 }
              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
 
 /**
  * \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;
 }
   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
  */
 /**
  * \brief Store the bypass route by calling the set_bypassroute function of the current routing component
  */
@@ -1210,8 +1211,6 @@ void routing_register_callbacks()
   surfxml_add_callback(STag_surfxml_bypassASroute_cb_list,
                        &routing_parse_S_bypassASroute);
 
   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,
   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,
@@ -1225,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_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);
   /* 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);
index ce491e3..4e0804f 100644 (file)
@@ -66,7 +66,6 @@ int surf_parse_get_int(const char *string) {
 /* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
 xbt_dynar_t STag_surfxml_route_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_route_cb_list = NULL;
 /* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
 xbt_dynar_t STag_surfxml_route_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_route_cb_list = NULL;
-xbt_dynar_t STag_surfxml_link_ctn_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_link_ctn_cb_list = NULL;
 xbt_dynar_t STag_surfxml_process_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_process_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_link_ctn_cb_list = NULL;
 xbt_dynar_t STag_surfxml_process_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_process_cb_list = NULL;
@@ -245,10 +244,6 @@ void surf_parse_init_callbacks(void)
 
     STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
     ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
 
     STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
     ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    STag_surfxml_link_ctn_cb_list =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    ETag_surfxml_link_ctn_cb_list =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
     STag_surfxml_process_cb_list =
         xbt_dynar_new(sizeof(void_f_void_t), NULL);
     ETag_surfxml_process_cb_list =
     STag_surfxml_process_cb_list =
         xbt_dynar_new(sizeof(void_f_void_t), NULL);
     ETag_surfxml_process_cb_list =
@@ -310,8 +305,6 @@ void surf_parse_free_callbacks(void)
 
   xbt_dynar_free(&STag_surfxml_route_cb_list);
   xbt_dynar_free(&ETag_surfxml_route_cb_list);
 
   xbt_dynar_free(&STag_surfxml_route_cb_list);
   xbt_dynar_free(&ETag_surfxml_route_cb_list);
-  xbt_dynar_free(&STag_surfxml_link_ctn_cb_list);
-  xbt_dynar_free(&ETag_surfxml_link_ctn_cb_list);
   xbt_dynar_free(&STag_surfxml_process_cb_list);
   xbt_dynar_free(&ETag_surfxml_process_cb_list);
   xbt_dynar_free(&STag_surfxml_argument_cb_list);
   xbt_dynar_free(&STag_surfxml_process_cb_list);
   xbt_dynar_free(&ETag_surfxml_process_cb_list);
   xbt_dynar_free(&STag_surfxml_argument_cb_list);
@@ -570,6 +563,31 @@ void ETag_surfxml_link(void){
   current_property_set = NULL;
 }
 
   current_property_set = NULL;
 }
 
+void STag_surfxml_link_ctn(void){
+  s_sg_platf_linkctn_cbarg_t linkctn;
+  memset(&linkctn,0,sizeof(linkctn));
+
+  linkctn.id = A_surfxml_link_ctn_id;
+
+  switch (A_surfxml_link_ctn_direction) {
+  case AU_surfxml_link_ctn_direction:
+  case A_surfxml_link_ctn_direction_NONE:
+    linkctn.direction = SURF_LINK_DIRECTION_NONE;
+    break;
+  case A_surfxml_link_ctn_direction_UP:
+    linkctn.direction = SURF_LINK_DIRECTION_UP;
+    break;
+  case A_surfxml_link_ctn_direction_DOWN:
+    linkctn.direction = SURF_LINK_DIRECTION_DOWN;
+    break;
+  }
+  sg_platf_new_linkctn(&linkctn);
+
+}
+
+void ETag_surfxml_link_ctn(void){
+ // NOTHING TO DO
+}
 void ETag_surfxml_backbone(void){
   s_sg_platf_link_cbarg_t link;
   memset(&link,0,sizeof(link));
 void ETag_surfxml_backbone(void){
   s_sg_platf_link_cbarg_t link;
   memset(&link,0,sizeof(link));
@@ -590,9 +608,6 @@ void ETag_surfxml_backbone(void){
 void STag_surfxml_route(void){
   surfxml_call_cb_functions(STag_surfxml_route_cb_list);
 }
 void STag_surfxml_route(void){
   surfxml_call_cb_functions(STag_surfxml_route_cb_list);
 }
-void STag_surfxml_link_ctn(void){
-  surfxml_call_cb_functions(STag_surfxml_link_ctn_cb_list);
-}
 void STag_surfxml_process(void){
   surfxml_call_cb_functions(STag_surfxml_process_cb_list);
 }
 void STag_surfxml_process(void){
   surfxml_call_cb_functions(STag_surfxml_process_cb_list);
 }
@@ -653,7 +668,6 @@ void STag_surfxml_random(void){
   void type##Tag_surfxml_##name(void)
 
 parse_method(E, route);
   void type##Tag_surfxml_##name(void)
 
 parse_method(E, route);
-parse_method(E, link_ctn);
 parse_method(E, process);
 parse_method(E, argument);
 parse_method(E, prop);
 parse_method(E, process);
 parse_method(E, argument);
 parse_method(E, prop);