Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
routing cleanup: symbol renaming
[simgrid.git] / src / surf / surf_routing_generic.cpp
index 4ecc89f..a83fb94 100644 (file)
@@ -149,7 +149,7 @@ void AsGeneric::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
           xbt_dynar_get_as(vertices_, dst, NetCard*);
 
       sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
-      route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+      route->link_list = xbt_dynar_new(sizeof(Link*), NULL);
 
       getRouteAndLatency(my_src, my_dst, route, NULL);
 
@@ -320,7 +320,7 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(NetCard *src,
     new_e_route->gw_src = e_route_bypass->gw_src;
     new_e_route->gw_dst = e_route_bypass->gw_dst;
     new_e_route->link_list =
-        xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+        xbt_dynar_new(sizeof(Link*), NULL);
     xbt_dynar_foreach(e_route_bypass->link_list, cpt, link) {
       xbt_dynar_push(new_e_route->link_list, &link);
       if (lat)
@@ -342,7 +342,7 @@ sg_platf_route_cbarg_t AsGeneric::newExtendedRoute(e_surf_routing_hierarchy_t hi
   unsigned int cpt;
 
   result = xbt_new0(s_sg_platf_route_cbarg_t, 1);
-  result->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+  result->link_list = xbt_dynar_new(sizeof(Link*), NULL);
 
   xbt_assert(hierarchy == SURF_ROUTING_BASE
       || hierarchy == SURF_ROUTING_RECURSIVE,
@@ -350,8 +350,7 @@ sg_platf_route_cbarg_t AsGeneric::newExtendedRoute(e_surf_routing_hierarchy_t hi
 
   if (hierarchy == SURF_ROUTING_RECURSIVE) {
 
-    xbt_assert(routearg->gw_src && routearg->gw_dst,
-        "NULL is obviously a bad gateway");
+    xbt_assert(routearg->gw_src && routearg->gw_dst, "NULL is obviously a deficient gateway");
 
     /* remember not erase the gateway names */
     result->gw_src = routearg->gw_src;
@@ -373,7 +372,7 @@ sg_platf_route_cbarg_t AsGeneric::newExtendedRoute(e_surf_routing_hierarchy_t hi
   return result;
 }
 
-void AsGeneric::srcDstCheck(NetCard *src, NetCard *dst)
+void AsGeneric::getRouteCheckParams(NetCard *src, NetCard *dst)
 {
   xbt_assert(src,"Cannot find a route from NULL to %s", dst->name());
   xbt_assert(dst,"Cannot find a route from %s to NULL", src->name());
@@ -388,6 +387,43 @@ void AsGeneric::srcDstCheck(NetCard *src, NetCard *dst)
       "Internal error: route destination %s@%s is not in AS %s as expected (route source: %s@%s). Please report that bug.",
         src->name(), dst->name(),  src_as->name_, dst_as->name_,  name_);
 }
+void AsGeneric::addRouteCheckParams(sg_platf_route_cbarg_t route) {
+  const char *srcName = route->src;
+  const char *dstName = route->dst;
+  NetCard *src = sg_netcard_by_name_or_null(srcName);
+  NetCard *dst = sg_netcard_by_name_or_null(dstName);
+
+  if(!route->gw_dst && !route->gw_src) {
+    XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName);
+    xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName);
+    xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName);
+    xbt_assert(!xbt_dynar_is_empty(route->link_list), "Empty route (between %s and %s) forbidden.", srcName, dstName);
+    xbt_assert(src->getRcType()==SURF_NETWORK_ELEMENT_HOST || src->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
+        "When defining a route, src must be an host or a router but '%s' is not. Did you meant to have an ASroute?", srcName);
+    xbt_assert(dst->getRcType()==SURF_NETWORK_ELEMENT_HOST || dst->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
+        "When defining a route, dst must be an host or a router but '%s' is not. Did you meant to have an ASroute?", dstName);
+  } else {
+    XBT_DEBUG("Load ASroute from %s@%s to %s@%s", srcName, route->gw_src->name(), dstName, route->gw_dst->name());
+    xbt_assert(src->getRcType()==SURF_NETWORK_ELEMENT_AS,
+        "When defining an ASroute, src must be an AS but '%s' is not", srcName);
+    xbt_assert(dst->getRcType()==SURF_NETWORK_ELEMENT_AS,
+        "When defining an ASroute, dst must be an AS but '%s' is not", dstName);
+
+    xbt_assert(route->gw_src->getRcType()==SURF_NETWORK_ELEMENT_HOST || route->gw_src->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
+        "When defining an ASroute, gw_src must be an host or a router but '%s' is not.", srcName);
+    xbt_assert(route->gw_dst->getRcType()==SURF_NETWORK_ELEMENT_HOST || route->gw_dst->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
+        "When defining an ASroute, gw_dst must be an host or a router but '%s' is not.", dstName);
+
+    xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself", route->gw_src->name());
+
+    xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.",
+        srcName,route->gw_src->name(), dstName,route->gw_dst->name(), srcName);
+    xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.",
+        srcName,route->gw_src->name(), dstName,route->gw_dst->name(), dstName);
+    xbt_assert(!xbt_dynar_is_empty(route->link_list), "Empty route (between %s@%s and %s@%s) forbidden.",
+        srcName,route->gw_src->name(), dstName,route->gw_dst->name());
+  }
+}
 
 }
 }