lua_pushstring(L,"src");
type = lua_gettable(L,-2);
lua_ensure(type == LUA_TSTRING, "Attribute 'src' must be specified for any route and must be a string.");
- route.src = lua_tostring(L, -1);
+ const char *srcName = lua_tostring(L, -1);
+ route.src = sg_netcard_by_name_or_null(srcName);
+ lua_ensure(route.src != nullptr, "Attribute 'src=%s' of route does not name a node.", srcName);
lua_pop(L,1);
lua_pushstring(L,"dest");
type = lua_gettable(L,-2);
lua_ensure(type == LUA_TSTRING, "Attribute 'dest' must be specified for any route and must be a string.");
- route.dst = lua_tostring(L, -1);
+ const char *dstName = lua_tostring(L, -1);
+ route.dst = sg_netcard_by_name_or_null(dstName);
+ lua_ensure(route.dst != nullptr, "Attribute 'dst=%s' of route does not name a node.", dstName);
lua_pop(L,1);
lua_pushstring(L,"links");
lua_pushstring(L, "src");
lua_gettable(L, -2);
- ASroute.src = lua_tostring(L, -1);
+ const char *srcName = lua_tostring(L, -1);
+ ASroute.src = sg_netcard_by_name_or_null(srcName);
+ lua_ensure(ASroute.src != nullptr, "Attribute 'src=%s' of AS route does not name a node.", srcName);
lua_pop(L, 1);
lua_pushstring(L, "dst");
lua_gettable(L, -2);
- ASroute.dst = lua_tostring(L, -1);
+ const char *dstName = lua_tostring(L, -1);
+ ASroute.dst = sg_netcard_by_name_or_null(dstName);
+ lua_ensure(ASroute.dst != nullptr, "Attribute 'dst=%s' of AS route does not name a node.", dstName);
lua_pop(L, 1);
lua_pushstring(L, "gw_src");
lua_gettable(L, -2);
const char *name = lua_tostring(L, -1);
ASroute.gw_src = sg_netcard_by_name_or_null(name);
- lua_ensure(ASroute.gw_src, "Attribute 'gw_src' of AS route does not name a valid machine: %s", name);
+ lua_ensure(ASroute.gw_src, "Attribute 'gw_src=%s' of AS route does not name a valid node", name);
lua_pop(L, 1);
lua_pushstring(L, "gw_dst");
lua_gettable(L, -2);
name = lua_tostring(L, -1);
ASroute.gw_dst = sg_netcard_by_name_or_null(name);
- lua_ensure(ASroute.gw_dst, "Attribute 'gw_dst' of AS route does not name a valid machine: %s", name);
+ lua_ensure(ASroute.gw_dst, "Attribute 'gw_dst=%s' of AS route does not name a valid node", name);
lua_pop(L, 1);
lua_pushstring(L,"links");
}
void As::addBypassRoute(sg_platf_route_cbarg_t e_route){
- const char *src = e_route->src;
- const char *dst = e_route->dst;
-
/* Argument validity checks */
if (e_route->gw_dst) {
XBT_DEBUG("Load bypassASroute from %s@%s to %s@%s",
- src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
+ e_route->src->name(), e_route->gw_src->name(),
+ e_route->dst->name(), e_route->gw_dst->name());
xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
- src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
- xbt_assert(bypassRoutes_.find({src,dst}) == bypassRoutes_.end(), "The bypass route between %s@%s and %s@%s already exists.",
- src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
+ e_route->src->name(), e_route->gw_src->name(),
+ e_route->dst->name(), e_route->gw_dst->name());
+ xbt_assert(bypassRoutes_.find({e_route->src->name(),e_route->dst->name()}) == bypassRoutes_.end(),
+ "The bypass route between %s@%s and %s@%s already exists.",
+ e_route->src->name(), e_route->gw_src->name(), e_route->dst->name(), e_route->gw_dst->name());
} else {
- XBT_DEBUG("Load bypassRoute from %s to %s", src, dst);
- xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", src, dst);
- xbt_assert(bypassRoutes_.find({src,dst}) == bypassRoutes_.end(), "The bypass route between %s and %s already exists.", src, dst);
+ XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->name(), e_route->dst->name());
+ xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.",
+ e_route->src->name(), e_route->dst->name());
+ xbt_assert(bypassRoutes_.find({e_route->src->name(),e_route->dst->name()}) == bypassRoutes_.end(),
+ "The bypass route between %s and %s already exists.",
+ e_route->src->name(), e_route->dst->name());
}
/* Build a copy that will be stored in the dict */
newRoute->push_back(link);
/* Store it */
- bypassRoutes_.insert({{src,dst}, newRoute});
+ bypassRoutes_.insert({{e_route->src->name(),e_route->dst->name()}, newRoute});
}
} }; // namespace simgrid::s4u
void AsDijkstra::addRoute(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);
+ NetCard *src = route->src;
+ NetCard *dst = route->dst;
+ const char *srcName = src->name();
+ const char *dstName = dst->name();
addRouteCheckParams(route);
/* set the size of table routing */
int table_size = (int)xbt_dynar_length(vertices_);
- NetCard *src = sg_netcard_by_name_or_null(route->src);
- NetCard *dst = sg_netcard_by_name_or_null(route->dst);
-
addRouteCheckParams(route);
if(!linkTable_) {
/* Check that the route does not already exist */
if (route->gw_dst) // AS route (to adapt the error message, if any)
- xbt_assert(nullptr == TO_FLOYD_LINK(src->id(), dst->id()),
+ xbt_assert(nullptr == TO_FLOYD_LINK(route->src->id(), route->dst->id()),
"The route between %s@%s and %s@%s already exists (Rq: routes are symmetrical by default).",
- src->name(),route->gw_src->name(),dst->name(),route->gw_dst->name());
+ route->src->name(),route->gw_src->name(),route->dst->name(),route->gw_dst->name());
else
- xbt_assert(nullptr == TO_FLOYD_LINK(src->id(), dst->id()),
- "The route between %s and %s already exists (Rq: routes are symmetrical by default).", src->name(),dst->name());
+ xbt_assert(nullptr == TO_FLOYD_LINK(route->src->id(), route->dst->id()),
+ "The route between %s and %s already exists (Rq: routes are symmetrical by default).", route->src->name(),route->dst->name());
- TO_FLOYD_LINK(src->id(), dst->id()) = newExtendedRoute(hierarchy_, route, 1);
- TO_FLOYD_PRED(src->id(), dst->id()) = src->id();
- TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list->size();
+ TO_FLOYD_LINK(route->src->id(), route->dst->id()) = newExtendedRoute(hierarchy_, route, 1);
+ TO_FLOYD_PRED(route->src->id(), route->dst->id()) = route->src->id();
+ TO_FLOYD_COST(route->src->id(), route->dst->id()) = (TO_FLOYD_LINK(route->src->id(), route->dst->id()))->link_list->size();
if (route->symmetrical == true) {
if (route->gw_dst) // AS route (to adapt the error message, if any)
- xbt_assert(nullptr == TO_FLOYD_LINK(dst->id(), src->id()),
+ xbt_assert(nullptr == TO_FLOYD_LINK(route->dst->id(), route->src->id()),
"The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.",
- dst->name(),route->gw_dst->name(),src->name(),route->gw_src->name());
+ route->dst->name(),route->gw_dst->name(),route->src->name(),route->gw_src->name());
else
- xbt_assert(nullptr == TO_FLOYD_LINK(dst->id(), src->id()),
+ xbt_assert(nullptr == TO_FLOYD_LINK(route->dst->id(), route->src->id()),
"The route between %s and %s already exists. You should not declare the reverse path as symmetrical.",
- dst->name(),src->name());
+ route->dst->name(),route->src->name());
if(route->gw_dst && route->gw_src) {
NetCard* gw_tmp = route->gw_src;
}
if(!route->gw_src && !route->gw_dst)
- XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst->name(), src->name());
+ XBT_DEBUG("Load Route from \"%s\" to \"%s\"", route->dst->name(), route->src->name());
else
- XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst->name(),
- route->gw_src->name(), src->name(), route->gw_dst->name());
+ XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", route->dst->name(),
+ route->gw_src->name(), route->src->name(), route->gw_dst->name());
- TO_FLOYD_LINK(dst->id(), src->id()) = newExtendedRoute(hierarchy_, route, 0);
- TO_FLOYD_PRED(dst->id(), src->id()) = dst->id();
- TO_FLOYD_COST(dst->id(), src->id()) = (TO_FLOYD_LINK(dst->id(), src->id()))->link_list->size(); /* count of links, old model assume 1 */
+ TO_FLOYD_LINK(route->dst->id(), route->src->id()) = newExtendedRoute(hierarchy_, route, 0);
+ TO_FLOYD_PRED(route->dst->id(), route->src->id()) = route->dst->id();
+ TO_FLOYD_COST(route->dst->id(), route->src->id()) = (TO_FLOYD_LINK(route->dst->id(), route->src->id()))->link_list->size(); /* count of links, old model assume 1 */
}
}
void AsFull::addRoute(sg_platf_route_cbarg_t route)
{
- const char *src = route->src;
- const char *dst = route->dst;
- NetCard *src_net_elm = sg_netcard_by_name_or_null(src);
- NetCard *dst_net_elm = sg_netcard_by_name_or_null(dst);
+ NetCard *src_net_elm = route->src;
+ NetCard *dst_net_elm = route->dst;
+ const char *src = src_net_elm->name();
+ const char *dst = dst_net_elm->name();
addRouteCheckParams(route);
src->name(), dst->name(), src_as->name(), dst_as->name(), name());
}
void AsRoutedGraph::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);
+ NetCard *src = route->src;
+ NetCard *dst = route->dst;
+ const char *srcName = src->name();
+ const char *dstName = dst->name();
if(!route->gw_dst && !route->gw_src) {
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName);
typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
typedef struct s_sg_platf_route_cbarg {
bool symmetrical;
- const char *src;
- const char *dst;
+ sg_netcard_t src;
+ sg_netcard_t dst;
sg_netcard_t gw_src;
sg_netcard_t gw_dst;
std::vector<Link*> *link_list;
s_sg_platf_route_cbarg_t route;
memset(&route,0,sizeof(route));
- route.src = A_surfxml_route_src;
- route.dst = A_surfxml_route_dst;
+
+ route.src = sg_netcard_by_name_or_null(A_surfxml_route_src); // tested to not be NULL in start tag
+ route.dst = sg_netcard_by_name_or_null(A_surfxml_route_dst); // tested to not be NULL in start tag
route.gw_src = nullptr;
route.gw_dst = nullptr;
route.link_list = new std::vector<Link*>();
s_sg_platf_route_cbarg_t ASroute;
memset(&ASroute,0,sizeof(ASroute));
- ASroute.src = A_surfxml_ASroute_src;
- ASroute.dst = A_surfxml_ASroute_dst;
-
- ASroute.gw_src = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___src);
- ASroute.gw_dst = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___dst);
+ ASroute.src = sg_netcard_by_name_or_null(A_surfxml_ASroute_src); // tested to not be NULL in start tag
+ ASroute.dst = sg_netcard_by_name_or_null(A_surfxml_ASroute_dst); // tested to not be NULL in start tag
- if (A_surfxml_ASroute_gw___src && !ASroute.gw_src)
- surf_parse_error("gw_src=\"%s\" not found for ASroute from \"%s\" to \"%s\"",
- A_surfxml_ASroute_gw___src, ASroute.src, ASroute.dst);
- if (A_surfxml_ASroute_gw___dst && !ASroute.gw_dst)
- surf_parse_error("gw_dst=\"%s\" not found for ASroute from \"%s\" to \"%s\"",
- A_surfxml_ASroute_gw___dst, ASroute.src, ASroute.dst);
+ ASroute.gw_src = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___src); // tested to not be NULL in start tag
+ ASroute.gw_dst = sg_netcard_by_name_or_null(A_surfxml_ASroute_gw___dst); // tested to not be NULL in start tag
ASroute.link_list = new std::vector<Link*>();
s_sg_platf_route_cbarg_t route;
memset(&route,0,sizeof(route));
- route.src = A_surfxml_bypassRoute_src;
- route.dst = A_surfxml_bypassRoute_dst;
+ route.src = sg_netcard_by_name_or_null(A_surfxml_bypassRoute_src); // tested to not be NULL in start tag
+ route.dst = sg_netcard_by_name_or_null(A_surfxml_bypassRoute_dst); // tested to not be NULL in start tag
route.gw_src = nullptr;
route.gw_dst = nullptr;
route.symmetrical = false;
s_sg_platf_route_cbarg_t ASroute;
memset(&ASroute,0,sizeof(ASroute));
- ASroute.src = A_surfxml_bypassASroute_src;
- ASroute.dst = A_surfxml_bypassASroute_dst;
- ASroute.link_list = new std::vector<Link*>();
+ ASroute.src = sg_netcard_by_name_or_null(A_surfxml_bypassASroute_src);
+ ASroute.dst = sg_netcard_by_name_or_null(A_surfxml_bypassASroute_dst);
+ ASroute.link_list = new std::vector<Link*>();
unsigned int cpt;
char *link_name;
xbt_dynar_foreach(parsed_link_list, cpt, link_name) {