X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/73cac04c5ce217e495a7584c98a6dbd940552e9c..3432ea9894c66b049be0b2ad1465d3677e739e19:/src/surf/surf_routing_full.c diff --git a/src/surf/surf_routing_full.c b/src/surf/surf_routing_full.c index 926b6ad815..bfc4e41db2 100644 --- a/src/surf/surf_routing_full.c +++ b/src/surf/surf_routing_full.c @@ -8,8 +8,6 @@ /* Global vars */ extern routing_global_t global_routing; -extern routing_component_t current_routing; -extern model_type_t current_routing_model; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf"); @@ -17,13 +15,13 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf"); /* Routing model structure */ -typedef struct { - s_routing_component_t generic_routing; +typedef struct s_routing_component_full { + s_as_t generic_routing; route_extended_t *routing_table; } s_routing_component_full_t, *routing_component_full_t; /* Business methods */ -static xbt_dynar_t full_get_onelink_routes(routing_component_t rc) +static xbt_dynar_t full_get_onelink_routes(AS_t rc) { xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free); @@ -63,7 +61,7 @@ static xbt_dynar_t full_get_onelink_routes(routing_component_t rc) return ret; } -static route_extended_t full_get_route(routing_component_t rc, +static route_extended_t full_get_route(AS_t rc, const char *src, const char *dst) { xbt_assert(rc && src @@ -102,7 +100,7 @@ static route_extended_t full_get_route(routing_component_t rc, return new_e_route; } -static void full_finalize(routing_component_t rc) +static void full_finalize(AS_t rc) { routing_component_full_t routing = (routing_component_full_t) rc; size_t table_size = xbt_dict_length(routing->generic_routing.to_index); @@ -113,52 +111,28 @@ static void full_finalize(routing_component_t rc) for (j = 0; j < table_size; j++) generic_free_extended_route(TO_ROUTE_FULL(i, j)); xbt_free(routing->routing_table); - /* Delete bypass dict */ - xbt_dict_free(&rc->bypassRoutes); - /* Delete index dict */ - xbt_dict_free(&rc->to_index); - /* Delete structure */ - xbt_free(rc); + model_generic_finalize(rc); } } /* Creation routing model functions */ -void *model_full_create(void) +AS_t model_full_create(void) { - routing_component_full_t new_component = - xbt_new0(s_routing_component_full_t, 1); - new_component->generic_routing.set_processing_unit = - generic_set_processing_unit; - new_component->generic_routing.set_autonomous_system = - generic_set_autonomous_system; - new_component->generic_routing.set_route = model_full_set_route; - new_component->generic_routing.set_ASroute = model_full_set_route; - new_component->generic_routing.set_bypassroute = generic_set_bypassroute; + routing_component_full_t new_component = (routing_component_full_t) + model_generic_create_sized(sizeof(s_routing_component_full_t)); + + new_component->generic_routing.parse_route = model_full_set_route; + new_component->generic_routing.parse_ASroute = model_full_set_route; new_component->generic_routing.get_route = full_get_route; - new_component->generic_routing.get_latency = generic_get_link_latency; new_component->generic_routing.get_onelink_routes = full_get_onelink_routes; - new_component->generic_routing.get_bypass_route = - generic_get_bypassroute; new_component->generic_routing.finalize = full_finalize; - new_component->generic_routing.to_index = xbt_dict_new(); - new_component->generic_routing.bypassRoutes = xbt_dict_new(); - new_component->generic_routing.get_network_element_type = get_network_element_type; - return new_component; -} - -void model_full_load(void) -{ - /* use "surfxml_add_callback" to add a parse function call */ -} -void model_full_unload(void) -{ - /* use "surfxml_del_callback" to remove a parse function call */ + return (AS_t) new_component; } -void model_full_end(void) +void model_full_end(AS_t current_routing) { unsigned int i; route_extended_t e_route; @@ -190,8 +164,12 @@ void model_full_end(void) } } -void model_full_set_route(routing_component_t rc, const char *src, - const char *dst, name_route_extended_t route) +static int surf_pointer_resource_cmp(const void *a, const void *b) { + return a != b; +} + +void model_full_set_route(AS_t rc, const char *src, + const char *dst, route_extended_t route) { int *src_id, *dst_id; src_id = xbt_dict_get_or_null(rc->to_index, src); @@ -199,8 +177,8 @@ void model_full_set_route(routing_component_t rc, const char *src, routing_component_full_t routing = ((routing_component_full_t) rc); size_t table_size = xbt_dict_length(routing->generic_routing.to_index); - xbt_assert(src_id - && dst_id, "Network elements %s or %s not found", src, dst); + xbt_assert(src_id, "Network elements %s not found", src); + xbt_assert(dst_id, "Network elements %s not found", dst); xbt_assert(xbt_dynar_length(route->generic_route.link_list) > 0, "Invalid count of links, must be greater than zero (%s,%s)", @@ -233,9 +211,9 @@ void model_full_set_route(routing_component_t rc, const char *src, else{ XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src, route->src_gateway, dst, route->dst_gateway); - if(global_routing->get_network_element_type((const char*)route->dst_gateway) == SURF_NETWORK_ELEMENT_NULL) + if(routing_get_network_element_type((const char*)route->dst_gateway) == SURF_NETWORK_ELEMENT_NULL) xbt_die("The dst_gateway '%s' does not exist!",route->dst_gateway); - if(global_routing->get_network_element_type((const char*)route->src_gateway) == SURF_NETWORK_ELEMENT_NULL) + if(routing_get_network_element_type((const char*)route->src_gateway) == SURF_NETWORK_ELEMENT_NULL) xbt_die("The src_gateway '%s' does not exist!",route->src_gateway); } TO_ROUTE_FULL(*src_id, *dst_id) = generic_new_extended_route(rc->hierarchy,route,1);