Exemplo n.º 1
0
void ETag_surfxml_zoneRoute()
{
  simgrid::kernel::routing::RouteCreationArgs ASroute;

  ASroute.src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_src); // tested to not be nullptr in start tag
  ASroute.dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_dst); // tested to not be nullptr in start tag

  ASroute.gw_src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___src); // tested to not be nullptr in start tag
  ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___dst); // tested to not be nullptr in start tag

  ASroute.link_list.swap(parsed_link_list);

  switch (A_surfxml_zoneRoute_symmetrical) {
  case AU_surfxml_zoneRoute_symmetrical:
  case A_surfxml_zoneRoute_symmetrical_YES:
    ASroute.symmetrical = true;
    break;
  case A_surfxml_zoneRoute_symmetrical_NO:
    ASroute.symmetrical = false;
    break;
  default:
    THROW_IMPOSSIBLE;
  }

  sg_platf_new_route(&ASroute);
}
Exemplo n.º 2
0
void ETag_surfxml_route(){
  simgrid::kernel::routing::RouteCreationArgs route;

  route.src         = sg_netpoint_by_name_or_null(A_surfxml_route_src); // tested to not be nullptr in start tag
  route.dst         = sg_netpoint_by_name_or_null(A_surfxml_route_dst); // tested to not be nullptr in start tag
  route.gw_src    = nullptr;
  route.gw_dst    = nullptr;
  route.symmetrical = (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES);

  route.link_list.swap(parsed_link_list);

  sg_platf_new_route(&route);
}
Exemplo n.º 3
0
int console_add_ASroute(lua_State *L) {
  s_sg_platf_route_cbarg_t ASroute;
  memset(&ASroute,0,sizeof(ASroute));

  lua_pushstring(L, "src");
  lua_gettable(L, -2);
  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);
  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=%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=%s' of AS route does not name a valid node", name);
  lua_pop(L, 1);

  lua_pushstring(L,"links");
  lua_gettable(L,-2);
  ASroute.link_list = new std::vector<Link*>();
  xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
  if (xbt_dynar_is_empty(names)) {
    /* unique name with no comma */
    ASroute.link_list->push_back(Link::byName(lua_tostring(L, -1)));
  } else {
    // Several names separated by , \t\r\n
    unsigned int cpt;
    char *name;
    xbt_dynar_foreach(names, cpt, name) {
      if (strlen(name)>0) {
        Link *link = Link::byName(name);
        ASroute.link_list->push_back(link);
      }
    }
  }
  lua_pop(L,1);

  lua_pushstring(L,"symmetrical");
  lua_gettable(L,-2);
  if (lua_isstring(L, -1)) {
    const char* value = lua_tostring(L, -1);
    if (strcmp("YES", value) == 0)
      ASroute.symmetrical = true;
    else
      ASroute.symmetrical = false;
  }
  else {
    ASroute.symmetrical = true;
  }
  lua_pop(L,1);

  sg_platf_new_route(&ASroute);

  return 0;
}
Exemplo n.º 4
0
int console_add_route(lua_State *L) {
  XBT_DEBUG("Adding route");
  s_sg_platf_route_cbarg_t route;
  memset(&route,0,sizeof(route));
  int type;

  /* allocating memory for the buffer, I think 2kB should be enough */
  surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size);

  lua_ensure(lua_istable(L, -1), "Bad Arguments to add a route. Should be a table with named arguments");

  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.");
  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.");
  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");
  type = lua_gettable(L,-2);
  lua_ensure(type == LUA_TSTRING,
      "Attribute 'links' must be specified for any route and must be a string (different links separated by commas or single spaces.");
  route.link_list = new std::vector<Link*>();
  xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
  if (xbt_dynar_is_empty(names)) {
    /* unique name */
    route.link_list->push_back(Link::byName(lua_tostring(L, -1)));
  } else {
    // Several names separated by , \t\r\n
    unsigned int cpt;
    char *name;
    xbt_dynar_foreach(names, cpt, name) {
      if (strlen(name)>0) {
        Link *link = Link::byName(name);
        route.link_list->push_back(link);
      }
    }
  }
  lua_pop(L,1);

  /* We are relying on the XML bypassing mechanism since the corresponding sg_platf does not exist yet.
   * Et ouais mon pote. That's the way it goes. F34R.
   *
   * (Note that above this function, there is a #include statement. Is this
   * comment related to that statement?)
   */
  lua_pushstring(L,"symmetrical");
  lua_gettable(L,-2);
  if (lua_isstring(L, -1)) {
    const char* value = lua_tostring(L, -1);
    if (strcmp("YES", value) == 0)
      route.symmetrical = true;
    else
      route.symmetrical = false;
  }
  else {
    route.symmetrical = true;
  }
  lua_pop(L,1);

  route.gw_src = nullptr;
  route.gw_dst = nullptr;

  sg_platf_new_route(&route);

  return 0;
}