+/* ************************************************************************** */
+/* ************************* GENERIC PARSE FUNCTIONS ************************ */
+
+static void generic_set_processing_units(routing_component_t rc, const char* name) {
+ DEBUG1("Full - Load process unit \"%s\"",name);
+ model_type_t modeltype = rc->routing;
+ int *id = xbt_new0(int,1); // xbt_malloc(sizeof(int)); ?
+ xbt_dict_t index;
+ if(modeltype==&routing_models[SURF_MODEL_FULL])
+ index = ((routing_component_full_t)current_routing)->to_index;
+ else if(modeltype==&routing_models[SURF_MODEL_FLOYD])
+ index = ((routing_component_floyd_t)current_routing)->to_index;
+ else xbt_die("\"generic_set_processing_units\" not support");
+ *id = xbt_dict_length(index);
+ xbt_dict_set(index,name,id,xbt_free);
+}
+
+static void generic_set_autonomous_system(routing_component_t rc, const char* name) {
+ DEBUG1("Full - Load Autonomous system \"%s\"",name);
+ model_type_t modeltype = rc->routing;
+ int *id = xbt_new0(int,1); // xbt_malloc(sizeof(int)); ?
+ xbt_dict_t index;
+ if(modeltype==&routing_models[SURF_MODEL_FULL])
+ index = ((routing_component_full_t)current_routing)->to_index;
+ else if(modeltype==&routing_models[SURF_MODEL_FLOYD])
+ index = ((routing_component_floyd_t)current_routing)->to_index;
+ else xbt_die("\"generic_set_autonomous_system\" not support");
+ *id = xbt_dict_length(index);
+ xbt_dict_set(index,name,id,xbt_free);
+}
+
+static void generic_set_route(routing_component_t rc, const char* src, const char* dst, route_t route) {
+ DEBUG2("Full - Load Route from \"%s\" to \"%s\"",src,dst);
+ model_type_t modeltype = rc->routing;
+ xbt_dict_t parseroutes;
+ if(modeltype==&routing_models[SURF_MODEL_FULL])
+ parseroutes = ((routing_component_full_t)current_routing)->parse_routes;
+ else if(modeltype==&routing_models[SURF_MODEL_FLOYD])
+ parseroutes = ((routing_component_floyd_t)current_routing)->parse_routes;
+ else xbt_die("\"generic_set_autonomous_system\" not support");
+ char *route_name;
+ route_name = bprintf("%s#%s",src,dst);
+ xbt_assert2(xbt_dynar_length(link_list)>0, "Invalid count of links, must be greater than zero (%s,%s)",src,dst);
+ xbt_assert2(!xbt_dict_get_or_null(parseroutes,route_name),
+ "The route between \"%s\" and \"%s\" already exist",src,dst);
+ xbt_dict_set(parseroutes, route_name, route, NULL);
+ free(route_name);
+}
+
+static void generic_set_ASroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route) {
+ DEBUG4("Full - Load ASroute from \"%s(%s)\" to \"%s(%s)\"",src,e_route->src_gateway,dst,e_route->dst_gateway);
+ model_type_t modeltype = rc->routing;
+ xbt_dict_t parseroutes;
+ if(modeltype==&routing_models[SURF_MODEL_FULL])
+ parseroutes = ((routing_component_full_t)current_routing)->parse_routes;
+ else if(modeltype==&routing_models[SURF_MODEL_FLOYD])
+ parseroutes = ((routing_component_floyd_t)current_routing)->parse_routes;
+ else xbt_die("\"generic_set_autonomous_system\" not support");
+ char *route_name;
+ route_name = bprintf("%s#%s",src,dst);
+ xbt_assert2(xbt_dynar_length(link_list)>0, "Invalid count of links, must be greater than zero (%s,%s)",src,dst);
+ xbt_assert4(!xbt_dict_get_or_null(parseroutes,route_name),
+ "The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",src,e_route->src_gateway,dst,e_route->dst_gateway);
+ xbt_dict_set(parseroutes, route_name, e_route, NULL);
+ free(route_name);
+}
+
+/* ************************************************************************** */
+/* ************************* GENERIC AUX FUNCTIONS ************************** */
+
+static route_extended_t generic_new_extended_route(routing_component_t rc, void* data) {
+
+ char *link_name;
+ route_extended_t e_route, new_e_route;
+ route_t route;
+ unsigned int cpt;
+ xbt_dynar_t links, links_id;
+
+ new_e_route = xbt_new0(s_route_extended_t,1);
+ new_e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+ new_e_route->src_gateway = NULL;
+ new_e_route->dst_gateway = NULL;
+
+ xbt_assert0(rc->hierarchy == SURF_ROUTING_BASE || rc->hierarchy == SURF_ROUTING_RECURSIVE,
+ "the hierarchy type is not defined");
+
+ if(rc->hierarchy == SURF_ROUTING_BASE ) {
+
+ route = (route_t)data;
+ links = route->link_list;
+
+ } else if(rc->hierarchy == SURF_ROUTING_RECURSIVE ) {
+
+ e_route = (route_extended_t)data;
+
+ // FIXME: HERE CHECK THE GATEWAY!!!!!!!!!
+ xbt_assert0(e_route->src_gateway&&e_route->dst_gateway,"bad gateway, is null");
+
+ links = e_route->generic_route.link_list;
+
+ /* remeber not erase the gateway names */
+ new_e_route->src_gateway = e_route->src_gateway;
+ new_e_route->dst_gateway = e_route->dst_gateway;
+ }
+
+ links_id = new_e_route->generic_route.link_list;
+
+ xbt_dynar_foreach(links, cpt, link_name) {
+
+ void* link = xbt_dict_get_or_null(surf_network_model->resource_set, link_name);
+ if (link)
+ xbt_dynar_push(links_id,&link);
+ else
+ THROW1(mismatch_error,0,"Link %s not found", link_name);
+ }
+
+ return new_e_route;
+}