Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Implementation of function is router
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 6 Oct 2010 15:45:49 +0000 (15:45 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 6 Oct 2010 15:45:49 +0000 (15:45 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8364 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/surf/surf_private.h
src/surf/surf_routing.c
teshsuite/simdag/platforms/basic_parsing_test.c

index e083b1f..c7cbea8 100644 (file)
@@ -161,7 +161,7 @@ struct s_routing_component {
   xbt_dict_t routing_sons;
   route_extended_t (*get_route)(routing_component_t rc, const char* src, const char* dst);
   xbt_dynar_t (*get_onelink_routes)(routing_component_t rc);
-  int (*is_router)(const char *name);
+  int (*is_router)(routing_component_t rc, const char *name);
   route_extended_t (*get_bypass_route)(routing_component_t rc, const char* src, const char* dst);
   void (*finalize)(routing_component_t rc);
   void (*set_processing_unit)(routing_component_t rc, const char* name);
index ecc32d9..d633b7d 100644 (file)
@@ -99,7 +99,7 @@ static void generic_set_bypassroute(routing_component_t rc, const char* src, con
 /* *************** GENERIC BUSINESS METHODS (declarations) ****************** */
 
 static xbt_dynar_t generic_get_onelink_routes (routing_component_t rc);
-static int generic_is_router (const char *name);
+static int generic_is_router (routing_component_t rc, const char *name);
 static route_extended_t generic_get_bypassroute(routing_component_t rc, const char* src, const char* dst);
 
 /* ************************************************************************** */
@@ -719,7 +719,9 @@ static xbt_dynar_t get_onelink_routes(void)
 
 static int is_router(const char *name)
 {
-       xbt_die("global \"is_router\" function not implemented yet");
+       routing_component_t rc=NULL;
+       rc = xbt_dict_get(global_routing->where_network_elements,name);
+       return rc->is_router(rc, name);
 }
 
 /**
@@ -811,9 +813,14 @@ static xbt_dynar_t full_get_onelink_routes(routing_component_t rc)
   return ret;
 }
 
-static int full_is_router(const char *name)
+static int full_is_router(routing_component_t rc, const char *name)
 {
-  xbt_die("\"full_is_router\" function not implemented yet");
+  routing_component_full_t routing = (routing_component_full_t)rc;
+
+  if(SURF_NETWORK_ELEMENT_ROUTER == ( (network_element_t) xbt_dict_get(routing->to_index , name) )->type )
+         return 1;
+  else
+         return 0;
 }
 
 static route_extended_t full_get_route(routing_component_t rc, const char* src,const char* dst) {
@@ -1004,9 +1011,14 @@ static xbt_dynar_t floyd_get_onelink_routes(routing_component_t rc)
   return ret;
 }
 
-static int floyd_is_router(const char *name)
+static int floyd_is_router(routing_component_t rc, const char *name)
 {
-  xbt_die("\"floyd_is_router\" function not implemented yet");
+  routing_component_floyd_t routing = (routing_component_floyd_t)rc;
+
+  if(SURF_NETWORK_ELEMENT_ROUTER == ( (network_element_t) xbt_dict_get(routing->to_index , name) )->type )
+         return 1;
+  else
+         return 0;
 }
 
 static route_extended_t floyd_get_route(routing_component_t rc, const char* src,const char* dst) {
@@ -1363,9 +1375,14 @@ static xbt_dynar_t dijkstra_get_onelink_routes(routing_component_t rc)
   xbt_die("\"dijkstra_get_onelink_routes\" function not implemented yet");
 }
 
-static int dijkstra_is_router(const char *name)
+static int dijkstra_is_router(routing_component_t rc, const char *name)
 {
-  xbt_die("\"dijkstra_is_router\" function not implemented yet");
+  routing_component_dijkstra_t routing = (routing_component_dijkstra_t)rc;
+
+  if(SURF_NETWORK_ELEMENT_ROUTER == ( (network_element_t) xbt_dict_get(routing->to_index , name) )->type )
+         return 1;
+  else
+         return 0;
 }
 
 static route_extended_t dijkstra_get_route(routing_component_t rc, const char* src,const char* dst) {
@@ -1823,9 +1840,13 @@ static xbt_dynar_t rulebased_get_onelink_routes(routing_component_t rc)
   xbt_die("\"rulebased_get_onelink_routes\" function not implemented yet");
 }
 
-static int rulebased_is_router(const char *name)
+static int rulebased_is_router(routing_component_t rc, const char *name)
 {
-  xbt_die("\"rulebased_is_router\" function not implemented yet");
+         //routing_component_rulebased_t routing = (routing_component_rulebased_t)rc;
+
+//PIERRE FIXME
+
+       xbt_die("\"rulebased_is_router\" function not implemented yet");
 }
 
 /* Business methods */
@@ -1968,7 +1989,7 @@ typedef struct {
 static xbt_dynar_t none_get_onelink_routes(routing_component_t rc){
   return NULL;
 }
-static int none_is_router(const char *name){
+static int none_is_router(routing_component_t rc, const char *name){
   return -1;
 }
 static route_extended_t none_get_route(routing_component_t rc, const char* src,const char* dst){
@@ -2198,7 +2219,7 @@ static xbt_dynar_t generic_get_onelink_routes (routing_component_t rc)
   xbt_die("\"generic_get_onelink_routes\" not implemented yet");
 }
 
-static int generic_is_router (const char *name)
+static int generic_is_router (routing_component_t rc, const char *name)
 {
   xbt_die("\"generic_is_router\" not implemented yet");
 }
index ecd1df8..e8f99bb 100644 (file)
@@ -7,6 +7,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "simdag/simdag.h"
+#include "surf/surf_private.h"
+
+extern routing_global_t global_routing;
 
 int main(int argc, char **argv)
 {
@@ -49,6 +52,8 @@ if(argc == 3)
          printf("Route latency = %f, route bandwidth = %f\n",
                        SD_route_get_current_latency(w1, w2),
                        SD_route_get_current_bandwidth(w1, w2));
+
+         printf("%s is router : %d\n",name1,global_routing->is_router(name1));
        }
        if(!strcmp(argv[2],"FULL_LINK"))
        {