- namespace kernel {
- namespace routing {
-
- class BypassRoute {
- public:
- explicit BypassRoute(NetCard* gwSrc, NetCard* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
- const NetCard* gw_src;
- const NetCard* gw_dst;
- std::vector<Link*> links;
- };
-
- AsImpl::AsImpl(As* father, const char* name) : As(father, name)
- {
- xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL),
- "Refusing to create a second AS called '%s'.", name);
-
- netcard_ = new NetCard(name, NetCard::Type::As, static_cast<AsImpl*>(father));
- xbt_lib_set(as_router_lib, name, ROUTING_ASR_LEVEL, static_cast<void*>(netcard_));
- XBT_DEBUG("AS '%s' created with the id '%d'", name, netcard_->id());
- }
- AsImpl::~AsImpl()
- {
- for (auto& kv : bypassRoutes_)
- delete kv.second;
+namespace kernel {
+namespace routing {
+
+class BypassRoute {
+public:
+ explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
+ const NetPoint* gw_src;
+ const NetPoint* gw_dst;
+ std::vector<surf::LinkImpl*> links;
+};
+
+NetZoneImpl::NetZoneImpl(NetZone* father, const char* name) : NetZone(father, name)
+{
+ xbt_assert(nullptr == simgrid::s4u::Engine::instance()->netpointByNameOrNull(name),
+ "Refusing to create a second NetZone called '%s'.", name);
+
+ netpoint_ = new NetPoint(name, NetPoint::Type::NetZone, static_cast<NetZoneImpl*>(father));
+ XBT_DEBUG("NetZone '%s' created with the id '%d'", name, netpoint_->id());
+}
+NetZoneImpl::~NetZoneImpl()
+{
+ for (auto& kv : bypassRoutes_)
+ delete kv.second;
+
+ simgrid::s4u::Engine::instance()->netpointUnregister(netpoint_);
+}
+
+simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount,
+ std::unordered_map<std::string, std::string>* props)
+{
+ simgrid::s4u::Host* res = new simgrid::s4u::Host(name);
+
+ if (hierarchy_ == RoutingMode::unset)
+ hierarchy_ = RoutingMode::base;
+
+ res->pimpl_netpoint = new NetPoint(name, NetPoint::Type::Host, this);
+
+ surf_cpu_model_pm->createCpu(res, speedPerPstate, coreAmount);
+
+ if (props != nullptr)
+ for (auto kv : *props)
+ res->setProperty(kv.first.c_str(), kv.second.c_str());
+
+ simgrid::s4u::Host::onCreation(*res);
+
+ return res;
+}
+
+void NetZoneImpl::addBypassRoute(sg_platf_route_cbarg_t e_route)
+{
+ /* Argument validity checks */
+ if (e_route->gw_dst) {
+ XBT_DEBUG("Load bypassNetzoneRoute from %s@%s to %s@%s", e_route->src->cname(), e_route->gw_src->cname(),
+ e_route->dst->cname(), e_route->gw_dst->cname());
+ xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
+ e_route->src->cname(), e_route->gw_src->cname(), e_route->dst->cname(), e_route->gw_dst->cname());
+ xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
+ "The bypass route between %s@%s and %s@%s already exists.", e_route->src->cname(),
+ e_route->gw_src->cname(), e_route->dst->cname(), e_route->gw_dst->cname());
+ } else {
+ XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->cname(), e_route->dst->cname());
+ xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", e_route->src->cname(),
+ e_route->dst->cname());
+ xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
+ "The bypass route between %s and %s already exists.", e_route->src->cname(), e_route->dst->cname());