Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Die on unwanted function calls.
[simgrid.git] / src / kernel / routing / StarZone.cpp
index 3d27937..7072a01 100644 (file)
@@ -7,9 +7,6 @@
 #include "simgrid/kernel/routing/NetPoint.hpp"
 #include "simgrid/kernel/routing/RoutedZone.hpp"
 #include "src/surf/network_interface.hpp"
-#if SIMGRID_HAVE_NS3
-#include "src/surf/network_ns3.hpp"
-#endif
 #include "xbt/string.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_star, surf, "Routing part of surf");
@@ -32,7 +29,7 @@ void StarZone::add_links_to_route(const std::vector<resource::LinkImpl*>& links,
   }
 }
 
-void StarZone::get_local_route(NetPoint* src, NetPoint* dst, Route* route, double* latency)
+void StarZone::get_local_route(const NetPoint* src, const NetPoint* dst, Route* route, double* latency)
 {
   XBT_VERB("StarZone getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(),
            dst->id());
@@ -89,8 +86,8 @@ void StarZone::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_n
   }
 }
 
-void StarZone::check_add_route_param(const NetPoint* src, const NetPoint* dst, const NetPoint* gw_src,
-                                     const NetPoint* gw_dst, bool symmetrical) const
+void StarZone::check_add_route_param(const NetPoint* src, const NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
+                                     bool symmetrical) const
 {
   const char* src_name = src ? src->get_cname() : "nullptr";
   const char* dst_name = dst ? dst->get_cname() : "nullptr";
@@ -114,6 +111,12 @@ void StarZone::check_add_route_param(const NetPoint* src, const NetPoint* dst, c
       throw std::invalid_argument(
           xbt::string_printf("StarZone::add_route(): src(%s) is a netzone, gw_src(%s) cannot be a netzone",
                              src->get_cname(), gw_src->get_cname()));
+
+    const auto* netzone_src = get_netzone_recursive(src);
+    if (not netzone_src->is_component_recursive(gw_src))
+      throw std::invalid_argument(xbt::string_printf(
+          "Invalid NetzoneRoute from %s@%s to %s: gw_src %s belongs to %s, not to %s.", src_name, gw_src->get_cname(),
+          dst_name, gw_src->get_cname(), gw_src->get_englobing_zone()->get_cname(), src_name));
   }
 
   if (dst && dst->is_netzone()) {
@@ -124,6 +127,12 @@ void StarZone::check_add_route_param(const NetPoint* src, const NetPoint* dst, c
       throw std::invalid_argument(
           xbt::string_printf("StarZone::add_route(): dst(%s) is a netzone, gw_dst(%s) cannot be a netzone",
                              dst->get_cname(), gw_dst->get_cname()));
+
+    const auto* netzone_dst = get_netzone_recursive(dst);
+    if (not netzone_dst->is_component_recursive(gw_dst))
+      throw std::invalid_argument(xbt::string_printf(
+          "Invalid NetzoneRoute from %s@%s to %s: gw_dst %s belongs to %s, not to %s.", dst_name, gw_dst->get_cname(),
+          src_name, gw_dst->get_cname(), gw_dst->get_englobing_zone()->get_cname(), dst_name));
   }
 }
 
@@ -162,10 +171,6 @@ void StarZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoin
 
 void StarZone::do_seal()
 {
-#if SIMGRID_HAVE_NS3
-  xbt_assert(not dynamic_cast<resource::NetworkNS3Model*>(get_network_model().get()),
-             "StarZone are not supported by NS-3 right now");
-#endif
   /* add default empty links if nothing was configured by user */
   for (auto const& node : get_vertices()) {
     auto route = routes_.emplace(node->id(), StarRoute());