+/**
+ * add sub AS to the Parent AS
+ */
+static int AS_add(lua_State *L)
+{
+ unsigned int i;
+ p_AS_attr AS;
+ p_AS_attr super_as,p_as;
+ const char *super_AS_id;
+ const char *sub_AS_id = NULL;
+ const char *sub_AS_routing= NULL;
+ if(lua_istable(L, -1))
+ {
+ lua_pushstring(L, "AS");
+ lua_gettable(L, -2);
+ super_AS_id = lua_tostring(L, -1);
+ lua_pop(L,1);
+
+ lua_pushstring(L, "id");
+ lua_gettable(L, -2);
+ sub_AS_id = lua_tostring(L, -1);
+ lua_pop(L,1);
+
+ }
+
+ xbt_dynar_foreach(as_list_d, i, p_as){
+ if (p_as->id == super_AS_id){
+ super_as = p_as;
+ break;
+ }
+ }
+ AS = malloc(sizeof(AS_attr));
+ AS->id = sub_AS_id;
+ AS->mode = sub_AS_routing;
+ AS->host_list_d = xbt_dynar_new(sizeof(p_host_attr),&xbt_free_ref);
+ AS->link_list_d = xbt_dynar_new(sizeof(p_link_attr),&xbt_free_ref);
+ AS->route_list_d = xbt_dynar_new(sizeof(p_route_attr),&xbt_free_ref);
+ AS->sub_as_list_id = xbt_dynar_new(sizeof(p_AS_attr),&xbt_free_ref);
+ xbt_dynar_push(super_as->sub_as_list_id, &AS);
+
+ return 0;
+}
+
+