+ if(xbt_dynar_is_empty(link_list_d))
+ link_list_d = xbt_dynar_new(sizeof(p_link_attr), &xbt_free_ref);
+
+ const char* id;
+ double bandwidth,latency;
+ const char* bandwidth_trace;
+ const char* latency_trace;
+ const char* state_trace;
+ int state_initial,policy;
+
+ //get values from the table passed as argument
+ if (lua_istable(L,-1)) {
+ // get Id Value
+ lua_pushstring(L,"id");
+ lua_gettable(L, -2 );
+ id = lua_tostring(L,-1);
+ lua_pop(L,1);
+
+ // get bandwidth value
+ lua_pushstring(L,"bandwidth");
+ lua_gettable(L, -2 );
+ bandwidth = lua_tonumber(L,-1);
+ lua_pop(L,1);
+
+ //get latency value
+ lua_pushstring(L,"latency");
+ lua_gettable(L, -2 );
+ latency = lua_tonumber(L,-1);
+ lua_pop(L,1);
+
+ /*Optional Arguments */
+
+ //get bandwidth_trace value
+ lua_pushstring(L,"bandwidth_trace");
+ lua_gettable(L, -2 );
+ bandwidth_trace = lua_tostring(L,-1);
+ lua_pop(L,1);
+
+ //get latency_trace value
+ lua_pushstring(L,"latency_trace");
+ lua_gettable(L, -2 );
+ latency_trace = lua_tostring(L,-1);
+ lua_pop(L,1);
+
+ //get state_trace value
+ lua_pushstring(L,"state_trace");
+ lua_gettable(L, -2 );
+ state_trace = lua_tostring(L,-1);
+ lua_pop(L,1);
+
+ //get state_initial value
+ lua_pushstring(L,"state_initial");
+ lua_gettable(L, -2 );
+ state_initial = lua_tonumber(L,-1);
+ lua_pop(L,1);
+
+
+ //get policy value
+ lua_pushstring(L,"policy");
+ lua_gettable(L, -2 );
+ policy = lua_tonumber(L,-1);
+ lua_pop(L,1);
+
+ } else {
+ ERROR0("Bad Arguments to create link, Should be a table with named arguments");
+ return -1;
+ }