@@ -222,7+222,7 @@ static int Host_new(lua_State * L)
{
p_host_attr host;
unsigned int i;
- p_AS_attr p_as,current_as;
+ p_AS_attr p_as,current_as = NULL;
const char *AS_id;
const char *id;
const char *power_trace;
@@ -317,7+317,7 @@ static int Link_new(lua_State * L) // (id,bandwidth,latency)
{
const char *AS_id;
unsigned int i;
- p_AS_attr p_as,current_as;
+ p_AS_attr p_as,current_as = NULL;
const char* id;
double bandwidth, latency;
const char *bandwidth_trace;
@@ -428,7+428,7 @@ static int Route_new(lua_State * L) // (src_id,dest_id,links_number,link_tab
p_route_attr route = malloc(sizeof(route_attr));
- if (!lua_istable(L, 3)) { // if Route.new is declared as an indexed table (FIXME : we check the third arg if it's not a table)
+ if (!lua_istable(L, 4)) { // if Route.new is declared as an indexed table (FIXME : we check the third arg if it's not a table)
//get AS_id
lua_pushstring(L, "AS");
@@ -476,18+476,27 @@ static int Route_new(lua_State * L) // (src_id,dest_id,links_number,link_tab
link_id = strtok(NULL,","); //Alternatively, a null pointer may be specified, in which case the function continues scanning where a previous successful call to the function ended.
}
xbt_dynar_push(current_as->route_list_d, &route);
-
-
return 0;
-
}
else { // Route.new is declared as a function
- //const char* link_id;
- route->src_id = luaL_checkstring(L, 1);
- route->dest_id = luaL_checkstring(L, 2);
+ AS_id = luaL_checkstring(L, 1);
+ xbt_dynar_foreach(as_list_d, i, p_as){
+ if (p_as->id == AS_id){
+ current_as = p_as;
+ break;
+ }
+ }
+
+ if (!current_as)
+ {
+ XBT_ERROR("addRoute: No AS_id :%s found",AS_id);