X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5a148272eff516debc28acb5d13fa97c5afe20ab..2489210b4ea8d03fbece8db288ef9e3ff6725723:/src/surf/surf_routing_rulebased.c diff --git a/src/surf/surf_routing_rulebased.c b/src/surf/surf_routing_rulebased.c index 0f0d8eba75..2c69fc9d81 100644 --- a/src/surf/surf_routing_rulebased.c +++ b/src/surf/surf_routing_rulebased.c @@ -64,21 +64,22 @@ static void rule_route_extended_free(void *e) static int model_rulebased_parse_PU(AS_t rc, sg_routing_edge_t elm) { AS_rulebased_t routing = (AS_rulebased_t) rc; - xbt_dynar_push(routing->generic_routing.index_network_elm,(void *)elm); + xbt_dynar_push(routing->generic_routing.index_network_elm,&elm); return -1; } static int model_rulebased_parse_AS(AS_t rc, sg_routing_edge_t elm) { AS_rulebased_t routing = (AS_rulebased_t) rc; - xbt_dynar_push(routing->generic_routing.index_network_elm,(void *)elm); + xbt_dynar_push(routing->generic_routing.index_network_elm,&elm); return -1; } -static void model_rulebased_parse_route(AS_t rc, - const char *src, const char *dst, - route_t route) +static void model_rulebased_parse_route(AS_t rc, sg_platf_route_cbarg_t route) { + char *src = (char*)(route->src); + char *dst = (char*)(route->dst); + AS_rulebased_t routing = (AS_rulebased_t) rc; rule_route_t ruleroute = xbt_new0(s_rule_route_t, 1); const char *error; @@ -104,10 +105,11 @@ static void model_rulebased_parse_route(AS_t rc, xbt_dynar_push(routing->list_route, &ruleroute); } -static void model_rulebased_parse_ASroute(AS_t rc, - const char *src, const char *dst, - route_t route) +static void model_rulebased_parse_ASroute(AS_t rc, sg_platf_route_cbarg_t route) { + char *src = (char*)(route->src); + char *dst = (char*)(route->dst); + AS_rulebased_t routing = (AS_rulebased_t) rc; rule_route_extended_t ruleroute_e = xbt_new0(s_rule_route_extended_t, 1); const char *error; @@ -125,29 +127,26 @@ static void model_rulebased_parse_ASroute(AS_t rc, erroffset, src, error); ruleroute_e->generic_rule_route.re_dst = pcre_compile(dst, 0, &error, &erroffset, NULL); - xbt_assert(ruleroute_e->generic_rule_route.re_src, + xbt_assert(ruleroute_e->generic_rule_route.re_dst, "PCRE compilation failed at offset %d (\"%s\"): %s\n", erroffset, dst, error); - ruleroute_e->generic_rule_route.re_str_link = - route->link_list; + + ruleroute_e->generic_rule_route.re_str_link = route->link_list; // DIRTY PERL HACK AHEAD: with the rulebased routing, the {src,dst}_gateway fields // store the provided name instead of the entity directly (routing_parse_E_ASroute knows) // // This is because the user will provide something like "^AS_(.*)$" instead of the proper name of a given entity - ruleroute_e->re_src_gateway = xbt_strdup((char *)route->src_gateway); - ruleroute_e->re_dst_gateway = xbt_strdup((char *)route->dst_gateway); + ruleroute_e->re_src_gateway = xbt_strdup((char *)route->gw_src); + ruleroute_e->re_dst_gateway = xbt_strdup((char *)route->gw_dst); xbt_dynar_push(routing->list_ASroute, &ruleroute_e); /* make sure that they don't get freed */ route->link_list = NULL; - route->src_gateway = route->dst_gateway = NULL; + route->gw_src = route->gw_dst = NULL; } -static void model_rulebased_parse_bypassroute(AS_t rc, - const char *src, - const char *dst, - route_t e_route) +static void model_rulebased_parse_bypassroute(AS_t rc, sg_platf_route_cbarg_t e_route) { xbt_die("bypass routing not supported for Route-Based model"); } @@ -212,7 +211,7 @@ static char *remplace(char *value, const char **src_list, int src_size, static void rulebased_get_route_and_latency(AS_t rc, sg_routing_edge_t src, sg_routing_edge_t dst, - route_t res,double*lat); + sg_platf_route_cbarg_t res,double*lat); static xbt_dynar_t rulebased_get_onelink_routes(AS_t rc) { xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free); @@ -237,7 +236,7 @@ static xbt_dynar_t rulebased_get_onelink_routes(AS_t rc) sg_routing_edge_t host = NULL; xbt_lib_foreach(as_router_lib, cursor, k1, host){ void *link_ptr; - route_t route = xbt_new0(s_route_t,1); + sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1); route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); rulebased_get_route_and_latency (rc, router, host, route,NULL); @@ -264,7 +263,7 @@ static xbt_dynar_t rulebased_get_onelink_routes(AS_t rc) /* Business methods */ static void rulebased_get_route_and_latency(AS_t rc, sg_routing_edge_t src, sg_routing_edge_t dst, - route_t route, double *lat) + sg_platf_route_cbarg_t route, double *lat) { XBT_DEBUG("rulebased_get_route_and_latency from '%s' to '%s'",src->name,dst->name); xbt_assert(rc && src @@ -351,12 +350,12 @@ static void rulebased_get_route_and_latency(AS_t rc, (rule_route_extended_t) ruleroute; char *gw_src_name = remplace(ruleroute_extended->re_src_gateway, list_src, rc_src, list_dst, rc_dst); - route->src_gateway = sg_routing_edge_by_name_or_null(gw_src_name); + route->gw_src = sg_routing_edge_by_name_or_null(gw_src_name); xbt_free(gw_src_name); char *gw_dst_name = remplace(ruleroute_extended->re_dst_gateway, list_src, rc_src, list_dst, rc_dst); - route->dst_gateway = sg_routing_edge_by_name_or_null(gw_dst_name); + route->gw_dst = sg_routing_edge_by_name_or_null(gw_dst_name); xbt_free(gw_dst_name); } @@ -366,7 +365,7 @@ static void rulebased_get_route_and_latency(AS_t rc, pcre_free_substring_list(list_dst); } -static route_t rulebased_get_bypass_route(AS_t rc, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat) { +static sg_platf_route_cbarg_t rulebased_get_bypass_route(AS_t rc, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat) { return NULL; } @@ -395,6 +394,7 @@ AS_t model_rulebased_create(void) { new_component->generic_routing.get_onelink_routes = rulebased_get_onelink_routes; new_component->generic_routing.get_route_and_latency = rulebased_get_route_and_latency; new_component->generic_routing.get_bypass_route = rulebased_get_bypass_route; + new_component->generic_routing.get_graph = generic_get_graph; new_component->generic_routing.finalize = rulebased_finalize; /* initialization of internal structures */ new_component->list_route = xbt_dynar_new(sizeof(rule_route_t), &rule_route_free);