if (strcmp (child1_name, child2_name) == 0) continue;
//get the route
- 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);
rc->get_route_and_latency(rc, child1->net_elm, child2->net_elm,
route, NULL);
unsigned int cpt;
void *link;
container_t current, previous;
- if (route->src_gateway){
- previous = PJ_container_get(route->src_gateway->name);
+ if (route->gw_src){
+ previous = PJ_container_get(route->gw_src->name);
}else{
previous = child1;
}
linkContainers(previous, current, filter);
previous = current;
}
- if (route->dst_gateway){
- current = PJ_container_get(route->dst_gateway->name);
+ if (route->gw_dst){
+ current = PJ_container_get(route->gw_dst->name);
}else{
current = child2;
}
if (strcmp (child1_name, child2_name) == 0) continue;
//get the route
- 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);
rc->get_route_and_latency(rc, child1->net_elm, child2->net_elm,
route, NULL);
unsigned int cpt;
void *link;
xbt_node_t current, previous;
- if (route->src_gateway){
- previous = new_xbt_graph_node(graph, route->src_gateway->name, nodes);
+ if (route->gw_src){
+ previous = new_xbt_graph_node(graph, route->gw_src->name, nodes);
}else{
previous = new_xbt_graph_node(graph, child1_name, nodes);
}
//previous -> current
previous = current;
}
- if (route->dst_gateway){
- current = new_xbt_graph_node(graph, route->dst_gateway->name, nodes);
+ if (route->gw_dst){
+ current = new_xbt_graph_node(graph, route->gw_dst->name, nodes);
}else{
current = new_xbt_graph_node(graph, child2_name, nodes);
}
void (*end) (AS_t as);
} s_routing_model_description_t, *routing_model_description_t;
-typedef struct s_route {
- xbt_dynar_t link_list;
- sg_routing_edge_t src_gateway;
- sg_routing_edge_t dst_gateway;
-} s_route_t, *route_t;
-
/* This enum used in the routing structure helps knowing in which situation we are. */
typedef enum {
SURF_ROUTING_NULL = 0, /**< Undefined type */
sg_routing_edge_t net_elem;
xbt_dynar_t link_up_down_list;
- void (*get_route_and_latency) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, route_t into, double *latency);
+ void (*get_route_and_latency) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, sg_platf_route_cbarg_t into, double *latency);
xbt_dynar_t(*get_onelink_routes) (AS_t as);
- route_t(*get_bypass_route) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat);
+ sg_platf_route_cbarg_t(*get_bypass_route) (AS_t as, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat);
void (*finalize) (AS_t as);
* Of course, only the routing model of this AS is informed, not every ones */
int (*parse_PU) (AS_t as, sg_routing_edge_t elm); /* A host or a router, whatever */
int (*parse_AS) (AS_t as, sg_routing_edge_t elm);
- void (*parse_route) (AS_t as, const char *src,
- const char *dst, route_t route);
- void (*parse_ASroute) (AS_t as, const char *src,
- const char *dst, route_t route);
- void (*parse_bypassroute) (AS_t as, const char *src,
- const char *dst, route_t e_route);
+ void (*parse_route) (AS_t as, sg_platf_route_cbarg_t route);
+ void (*parse_ASroute) (AS_t as, sg_platf_route_cbarg_t route);
+ void (*parse_bypassroute) (AS_t as, sg_platf_route_cbarg_t e_route);
} s_as_t;
struct s_routing_platf {
XBT_PUBLIC(void) routing_exit(void);
XBT_PUBLIC(void) storage_register_callbacks(void);
XBT_PUBLIC(void) routing_register_callbacks(void);
-XBT_PUBLIC(void) generic_free_route(route_t route); // FIXME rename to routing_route_free
+XBT_PUBLIC(void) generic_free_route(sg_platf_route_cbarg_t route); // FIXME rename to routing_route_free
// FIXME: make previous function private to routing again?
*/
static void parse_E_route(sg_platf_route_cbarg_t route)
{
- route_t created_route = xbt_new0(s_route_t, 1);
- created_route->link_list = route->link_list;
-
xbt_assert(current_routing->parse_route,
"no defined method \"set_route\" in \"%s\"",
current_routing->name);
- current_routing->parse_route(current_routing,
- route->src, route->dst, created_route);
- generic_free_route(created_route);
+ current_routing->parse_route(current_routing, route);
}
/**
*/
static void parse_E_ASroute(sg_platf_route_cbarg_t ASroute)
{
- route_t e_route = xbt_new0(s_route_t, 1);
- e_route->link_list = ASroute->link_list;
- e_route->src_gateway = ASroute->gw_src;
- e_route->dst_gateway = ASroute->gw_dst;
-
xbt_assert(current_routing->parse_ASroute,
"no defined method \"set_ASroute\" in \"%s\"",
current_routing->name);
- current_routing->parse_ASroute(current_routing, ASroute->src, ASroute->dst, e_route);
- generic_free_route(e_route);
+ current_routing->parse_ASroute(current_routing, ASroute);
}
/**
*/
static void parse_E_bypassRoute(sg_platf_route_cbarg_t route)
{
- route_t e_route = xbt_new0(s_route_t, 1);
- e_route->link_list = route->link_list;
-
xbt_assert(current_routing->parse_bypassroute,
"Bypassing mechanism not implemented by routing '%s'",
current_routing->name);
- current_routing->parse_bypassroute(current_routing, route->src, route->dst, e_route);
+ current_routing->parse_bypassroute(current_routing, route);
}
/**
*/
static void parse_E_bypassASroute(sg_platf_route_cbarg_t ASroute)
{
- route_t e_route = xbt_new0(s_route_t, 1);
- e_route->link_list = ASroute->link_list;
- e_route->src_gateway = ASroute->gw_src;
- e_route->dst_gateway = ASroute->gw_dst;
xbt_assert(current_routing->parse_bypassroute,
"Bypassing mechanism not implemented by routing '%s'",
current_routing->name);
- current_routing->parse_bypassroute(current_routing, ASroute->src, ASroute->dst, e_route);
+ current_routing->parse_bypassroute(current_routing, ASroute);
}
static void routing_parse_trace(sg_platf_trace_cbarg_t trace)
static void _get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
xbt_dynar_t * links, double *latency)
{
- s_route_t route;
+ s_sg_platf_route_cbarg_t route;
memset(&route,0,sizeof(route));
XBT_DEBUG("Solve route/latency \"%s\" to \"%s\"", src->name, dst->name);
common_father->name,src_father->name,dst_father->name);
/* Check whether a direct bypass is defined */
- route_t e_route_bypass = NULL;
+ sg_platf_route_cbarg_t e_route_bypass = NULL;
if (common_father->get_bypass_route)
e_route_bypass = common_father->get_bypass_route(common_father, src, dst, latency);
src_father_net_elm, dst_father_net_elm,
&route, latency);
- xbt_assert((route.src_gateway != NULL) && (route.dst_gateway != NULL),
+ xbt_assert((route.gw_src != NULL) && (route.gw_dst != NULL),
"bad gateways for route from \"%s\" to \"%s\"", src->name, dst->name);
- sg_routing_edge_t src_gateway_net_elm = route.src_gateway;
- sg_routing_edge_t dst_gateway_net_elm = route.dst_gateway;
+ sg_routing_edge_t src_gateway_net_elm = route.gw_src;
+ sg_routing_edge_t dst_gateway_net_elm = route.gw_dst;
/* If source gateway is not our source, we have to recursively find our way up to this point */
if (src != src_gateway_net_elm)
/* Business methods */
static void cluster_get_route_and_latency(AS_t as,
sg_routing_edge_t src, sg_routing_edge_t dst,
- route_t route, double *lat) {
+ sg_platf_route_cbarg_t route, double *lat) {
s_surf_parsing_link_up_down_t info;
XBT_DEBUG("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
static void graph_edge_data_free(void *e) // FIXME: useless code dupplication
{
- route_t e_route = (route_t) e;
+ sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t) e;
if (e_route) {
xbt_dynar_free(&(e_route->link_list));
xbt_free(e_route);
/* Parsing */
static void route_new_dijkstra(as_dijkstra_t as, int src_id,
- int dst_id, route_t e_route)
+ int dst_id, sg_platf_route_cbarg_t e_route)
{
XBT_DEBUG("Load Route from \"%d\" to \"%d\"", src_id, dst_id);
xbt_node_t src = NULL;
}
if (!found) {
- route_t e_route = xbt_new0(s_route_t, 1);
+ sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
xbt_dynar_push(e_route->link_list,
&routing_platf->loopback);
}
static void dijkstra_get_route_and_latency(AS_t as_generic,
- sg_routing_edge_t src, sg_routing_edge_t dst, route_t route, double *lat);
+ sg_routing_edge_t src, sg_routing_edge_t dst, sg_platf_route_cbarg_t route, double *lat);
static xbt_dynar_t dijkstra_get_onelink_routes(AS_t as)
{
xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
- 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);
int src,dst;
onelink->src = src_elm;
onelink->dst = dst_elm;
} else if (as->hierarchy == SURF_ROUTING_RECURSIVE) {
- onelink->src = route->src_gateway;
- onelink->dst = route->dst_gateway;
+ onelink->src = route->gw_src;
+ onelink->dst = route->gw_dst;
}
xbt_dynar_push(ret, &onelink);
}
static void dijkstra_get_route_and_latency(AS_t asg,
sg_routing_edge_t src, sg_routing_edge_t dst,
- route_t route, double *lat)
+ sg_platf_route_cbarg_t route, double *lat)
{
/* set utils vars */
int dst_node_id = 0;
int *nodeid = NULL;
int v;
- route_t e_route;
+ sg_platf_route_cbarg_t e_route;
int size = 0;
unsigned int cpt;
void *link;
if (edge == NULL)
THROWF(arg_error,0,"No route from '%s' to '%s'",src->name,dst->name);
- e_route = (route_t) xbt_graph_edge_get_data(edge);
+ e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge);
links = e_route->link_list;
xbt_dynar_foreach(links, cpt, link) {
xbt_node_t u_node = xbt_graph_edge_get_target(edge);
graph_node_data_t data = xbt_graph_node_get_data(u_node);
int u_id = data->graph_id;
- route_t tmp_e_route = (route_t) xbt_graph_edge_get_data(edge);
+ sg_platf_route_cbarg_t tmp_e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge);
int cost_v_u = (tmp_e_route->link_list)->used; /* count of links, old model assume 1 */
if (cost_v_u + cost_arr[*v_id] < cost_arr[u_id]) {
prev_gw_src = gw_src;
- e_route = (route_t) xbt_graph_edge_get_data(edge);
- gw_src = e_route->src_gateway;
- gw_dst = e_route->dst_gateway;
+ e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge);
+ gw_src = e_route->gw_src;
+ gw_dst = e_route->gw_dst;
if (v == dst_node_id)
first_gw = gw_dst;
}
if (asg->hierarchy == SURF_ROUTING_RECURSIVE) {
- route->src_gateway = gw_src;
- route->dst_gateway = first_gw;
+ route->gw_src = gw_src;
+ route->gw_dst = first_gw;
}
if (as->cached && elm == NULL) {
}
}
-void model_dijkstra_both_parse_route (AS_t asg, const char *src,
- const char *dst, route_t route)
+void model_dijkstra_both_parse_route (AS_t asg, sg_platf_route_cbarg_t route)
{
+ char *src = (char*)(route->src);
+ char *dst = (char*)(route->dst);
+
int as_route = 0;
- if(!route->dst_gateway && !route->src_gateway)
+ if(!route->gw_dst && !route->gw_src)
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst);
else{
XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src,
- route->src_gateway->name, dst, route->dst_gateway->name);
+ route->gw_src->name, dst, route->gw_dst->name);
as_route = 1;
- if(route->dst_gateway->rc_type == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The dst_gateway '%s' does not exist!",route->dst_gateway->name);
- if(route->src_gateway->rc_type == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The src_gateway '%s' does not exist!",route->src_gateway->name);
+ if(route->gw_dst->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The gw_dst '%s' does not exist!",route->gw_dst->name);
+ if(route->gw_src->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The gw_src '%s' does not exist!",route->gw_src->name);
}
as_dijkstra_t as = (as_dijkstra_t) asg;
if (as->cached && !as->route_cache)
as->route_cache = xbt_dict_new_homogeneous(&route_cache_elem_free);
- route_t e_route = generic_new_extended_route(asg->hierarchy, route, 1);
+ sg_platf_route_cbarg_t e_route = generic_new_extended_route(asg->hierarchy, route, 1);
route_new_dijkstra(as, src_net_elm->id, dst_net_elm->id, e_route);
// Symmetrical YES
- if ( (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES && as_route == 0)
- || (A_surfxml_ASroute_symmetrical == A_surfxml_ASroute_symmetrical_YES && as_route == 1)
+ if ( (route->symmetrical == TRUE && as_route == 0)
+ || (route->symmetrical == TRUE && as_route == 1)
)
{
- if(!route->dst_gateway && !route->src_gateway)
+ if(!route->gw_dst && !route->gw_src)
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst, src);
else
XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst,
- route->dst_gateway->name, src, route->src_gateway->name);
+ route->gw_dst->name, src, route->gw_src->name);
xbt_dynar_t nodes = xbt_graph_get_nodes(as->route_graph);
xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_net_elm->id, xbt_node_t);
if (edge)
THROWF(arg_error,0,"(AS)Route from '%s' to '%s' already exists",src,dst);
- if (route->dst_gateway && route->src_gateway) {
+ if (route->gw_dst && route->gw_src) {
sg_routing_edge_t gw_tmp;
- gw_tmp = route->src_gateway;
- route->src_gateway = route->dst_gateway;
- route->dst_gateway = gw_tmp;
+ gw_tmp = route->gw_src;
+ route->gw_src = route->gw_dst;
+ route->gw_dst = gw_tmp;
}
- route_t link_route_back = generic_new_extended_route(asg->hierarchy, route, 0);
+ sg_platf_route_cbarg_t link_route_back = generic_new_extended_route(asg->hierarchy, route, 0);
route_new_dijkstra(as, dst_net_elm->id, src_net_elm->id, link_route_back);
}
+ xbt_dynar_free(&route->link_list);
}
/* vars for calculate the floyd algorith. */
int *predecessor_table;
double *cost_table;
- route_t *link_table;
+ sg_platf_route_cbarg_t *link_table;
} s_as_floyd_t, *as_floyd_t;
static void floyd_get_route_and_latency(AS_t asg, sg_routing_edge_t src, sg_routing_edge_t dst,
- route_t res, double *lat);
+ sg_platf_route_cbarg_t res, double *lat);
/* Business methods */
static xbt_dynar_t floyd_get_onelink_routes(AS_t asg)
{
xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
- 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);
int src,dst;
onelink->src = src_elm;
onelink->dst = dst_elm;
} else if (asg->hierarchy == SURF_ROUTING_RECURSIVE) {
- onelink->src = route->src_gateway;
- onelink->dst = route->dst_gateway;
+ onelink->src = route->gw_src;
+ onelink->dst = route->gw_dst;
}
xbt_dynar_push(ret, &onelink);
}
}
static void floyd_get_route_and_latency(AS_t asg, sg_routing_edge_t src, sg_routing_edge_t dst,
- route_t res, double *lat)
+ sg_platf_route_cbarg_t res, double *lat)
{
/* set utils vars */
generic_src_dst_check(asg, src, dst);
/* create a result route */
- xbt_dynar_t route_stack = xbt_dynar_new(sizeof(route_t), NULL);
+ xbt_dynar_t route_stack = xbt_dynar_new(sizeof(sg_platf_route_cbarg_t), NULL);
int pred;
int cur = dst->id;
do {
pred = TO_FLOYD_PRED(src->id, cur);
if (pred == -1)
THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name, dst->name);
- xbt_dynar_push_as(route_stack, route_t, TO_FLOYD_LINK(pred, cur));
+ xbt_dynar_push_as(route_stack, sg_platf_route_cbarg_t, TO_FLOYD_LINK(pred, cur));
cur = pred;
} while (cur != src->id);
if (asg->hierarchy == SURF_ROUTING_RECURSIVE) {
- res->src_gateway = xbt_dynar_getlast_as(route_stack, route_t)->src_gateway;
- res->dst_gateway = xbt_dynar_getfirst_as(route_stack, route_t)->dst_gateway;
+ res->gw_src = xbt_dynar_getlast_as(route_stack, sg_platf_route_cbarg_t)->gw_src;
+ res->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst;
}
sg_routing_edge_t prev_dst_gw = NULL;
while (!xbt_dynar_is_empty(route_stack)) {
- route_t e_route = xbt_dynar_pop_as(route_stack, route_t);
+ sg_platf_route_cbarg_t e_route = xbt_dynar_pop_as(route_stack, sg_platf_route_cbarg_t);
xbt_dynar_t links;
sg_routing_link_t link;
unsigned int cpt;
if (asg->hierarchy == SURF_ROUTING_RECURSIVE && prev_dst_gw != NULL
- && strcmp(prev_dst_gw->name, e_route->src_gateway->name)) {
- routing_get_route_and_latency(prev_dst_gw, e_route->src_gateway,
+ && strcmp(prev_dst_gw->name, e_route->gw_src->name)) {
+ routing_get_route_and_latency(prev_dst_gw, e_route->gw_src,
&res->link_list, lat);
}
*lat += surf_network_model->extension.network.get_link_latency(link);
}
- prev_dst_gw = e_route->dst_gateway;
+ prev_dst_gw = e_route->gw_dst;
}
xbt_dynar_free(&route_stack);
}
/* Create Cost, Predecessor and Link tables */
as->cost_table = xbt_new0(double, table_size * table_size); /* link cost from host to host */
as->predecessor_table = xbt_new0(int, table_size * table_size); /* predecessor host numbers */
- as->link_table = xbt_new0(route_t, table_size * table_size); /* actual link between src and dst */
+ as->link_table = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); /* actual link between src and dst */
/* Initialize costs and predecessors */
for (i = 0; i < table_size; i++)
/* Add the loopback if needed */
if (routing_platf->loopback && current_routing->hierarchy == SURF_ROUTING_BASE) {
for (i = 0; i < table_size; i++) {
- route_t e_route = TO_FLOYD_LINK(i, i);
+ sg_platf_route_cbarg_t e_route = TO_FLOYD_LINK(i, i);
if (!e_route) {
- e_route = xbt_new0(s_route_t, 1);
- e_route->src_gateway = NULL;
- e_route->dst_gateway = NULL;
+ e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+ e_route->gw_src = NULL;
+ e_route->gw_dst = NULL;
e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
xbt_dynar_push(e_route->link_list, &routing_platf->loopback);
TO_FLOYD_LINK(i, i) = e_route;
//FIXME: kill dupplicates in next function with full routing
-void model_floyd_parse_route(AS_t rc, const char *src,
- const char *dst, route_t route)
+void model_floyd_parse_route(AS_t rc, sg_platf_route_cbarg_t route)
{
+ char *src = (char*)(route->src);
+ char *dst = (char*)(route->dst);
+
int as_route = 0;
as_floyd_t as = (as_floyd_t) rc;
/* Create Cost, Predecessor and Link tables */
as->cost_table = xbt_new0(double, table_size * table_size); /* link cost from host to host */
as->predecessor_table = xbt_new0(int, table_size * table_size); /* predecessor host numbers */
- as->link_table = xbt_new0(route_t, table_size * table_size); /* actual link between src and dst */
+ as->link_table = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); /* actual link between src and dst */
/* Initialize costs and predecessors */
for (i = 0; i < table_size; i++)
TO_FLOYD_LINK(i, j) = NULL; /* fixed, missing in the previous version */
}
}
- if(!route->dst_gateway && !route->src_gateway)
+ if(!route->gw_dst && !route->gw_src)
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst);
else{
as_route = 1;
XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src,
- route->src_gateway->name, dst, route->dst_gateway->name);
- if(route->dst_gateway->rc_type == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The dst_gateway '%s' does not exist!",route->dst_gateway->name);
- if(route->src_gateway->rc_type == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The src_gateway '%s' does not exist!",route->src_gateway->name);
+ route->gw_src->name, dst, route->gw_dst->name);
+ if(route->gw_dst->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The dst_gateway '%s' does not exist!",route->gw_dst->name);
+ if(route->gw_src->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The src_gateway '%s' does not exist!",route->gw_src->name);
}
if(TO_FLOYD_LINK(src_net_elm->id, dst_net_elm->id))
((TO_FLOYD_LINK(src_net_elm->id, dst_net_elm->id))->link_list)->used; /* count of links, old model assume 1 */
}
- if ( (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES && as_route == 0)
- || (A_surfxml_ASroute_symmetrical == A_surfxml_ASroute_symmetrical_YES && as_route == 1)
+ if ( (route->symmetrical == TRUE && as_route == 0)
+ || (route->symmetrical == TRUE && as_route == 1)
)
{
if(TO_FLOYD_LINK(dst_net_elm->id, src_net_elm->id))
{
- if(!route->dst_gateway && !route->src_gateway)
+ if(!route->gw_dst && !route->gw_src)
XBT_DEBUG("See Route from \"%s\" to \"%s\"", dst, src);
else
XBT_DEBUG("See ASroute from \"%s(%s)\" to \"%s(%s)\"", dst,
- route->src_gateway->name, src, route->dst_gateway->name);
+ route->gw_src->name, src, route->gw_dst->name);
char * link_name;
unsigned int i;
xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
}
else
{
- if(route->dst_gateway && route->src_gateway)
+ if(route->gw_dst && route->gw_src)
{
- sg_routing_edge_t gw_src = route->src_gateway;
- sg_routing_edge_t gw_dst = route->dst_gateway;
- route->src_gateway = gw_dst;
- route->dst_gateway = gw_src;
+ sg_routing_edge_t gw_src = route->gw_src;
+ sg_routing_edge_t gw_dst = route->gw_dst;
+ route->gw_src = gw_dst;
+ route->gw_dst = gw_src;
}
- if(!route->dst_gateway && !route->src_gateway)
+ if(!route->gw_src && !route->gw_dst)
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst, src);
else
XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst,
- route->src_gateway->name, src, route->dst_gateway->name);
+ route->gw_src->name, src, route->gw_dst->name);
TO_FLOYD_LINK(dst_net_elm->id, src_net_elm->id) =
generic_new_extended_route(rc->hierarchy, route, 0);
((TO_FLOYD_LINK(dst_net_elm->id, src_net_elm->id))->link_list)->used; /* count of links, old model assume 1 */
}
}
+ xbt_dynar_free(&route->link_list);
}
typedef struct s_routing_component_full {
s_as_t generic_routing;
- route_t *routing_table;
+ sg_platf_route_cbarg_t *routing_table;
} s_routing_component_full_t, *routing_component_full_t;
/* Business methods */
for(src=0; src < table_size; src++) {
for(dst=0; dst< table_size; dst++) {
- route_t route = TO_ROUTE_FULL(src, dst);
+ sg_platf_route_cbarg_t route = TO_ROUTE_FULL(src, dst);
if (route) {
if (xbt_dynar_length(route->link_list) == 1) {
void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
onelink->dst = xbt_dynar_get_as(rc->index_network_elm,dst,sg_routing_edge_t);
onelink->dst->id = dst;
} else if (rc->hierarchy == SURF_ROUTING_RECURSIVE) {
- onelink->src = route->src_gateway;
- onelink->dst = route->dst_gateway;
+ onelink->src = route->gw_src;
+ onelink->dst = route->gw_dst;
}
xbt_dynar_push(ret, &onelink);
XBT_DEBUG("Push route from '%d' to '%d'",
static void full_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)
{
XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]",
src->name,
routing_component_full_t routing = (routing_component_full_t) rc;
size_t table_size = xbt_dynar_length(routing->generic_routing.index_network_elm);
- route_t e_route = NULL;
+ sg_platf_route_cbarg_t e_route = NULL;
void *link;
unsigned int cpt = 0;
e_route = TO_ROUTE_FULL(src->id, dst->id);
if (e_route) {
- res->src_gateway = e_route->src_gateway;
- res->dst_gateway = e_route->dst_gateway;
+ res->gw_src = e_route->gw_src;
+ res->gw_dst = e_route->gw_dst;
xbt_dynar_foreach(e_route->link_list, cpt, link) {
xbt_dynar_push(res->link_list, &link);
if (lat)
void model_full_end(AS_t current_routing)
{
unsigned int i;
- route_t e_route;
+ sg_platf_route_cbarg_t e_route;
/* set utils vars */
routing_component_full_t routing =
/* Create table if necessary */
if (!routing->routing_table)
- routing->routing_table = xbt_new0(route_t, table_size * table_size);
+ routing->routing_table = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
/* Add the loopback if needed */
if (routing_platf->loopback && current_routing->hierarchy == SURF_ROUTING_BASE) {
for (i = 0; i < table_size; i++) {
e_route = TO_ROUTE_FULL(i, i);
if (!e_route) {
- e_route = xbt_new0(s_route_t, 1);
- e_route->src_gateway = NULL;
- e_route->dst_gateway = NULL;
+ e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+ e_route->gw_src = NULL;
+ e_route->gw_dst = NULL;
e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
xbt_dynar_push(e_route->link_list, &routing_platf->loopback);
TO_ROUTE_FULL(i, i) = e_route;
return a != b;
}
-void model_full_set_route(AS_t rc, const char *src,
- const char *dst, route_t route)
+void model_full_set_route(AS_t rc, sg_platf_route_cbarg_t route)
{
- sg_routing_edge_t src_net_elm, dst_net_elm;
int as_route = 0;
+ char *src = (char*)(route->src);
+ char *dst = (char*)(route->dst);
+ sg_routing_edge_t src_net_elm, dst_net_elm;
src_net_elm = sg_routing_edge_by_name_or_null(src);
dst_net_elm = sg_routing_edge_by_name_or_null(dst);
src, dst);
if (!routing->routing_table)
- routing->routing_table = xbt_new0(route_t, table_size * table_size);
+ routing->routing_table = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
if (TO_ROUTE_FULL(src_net_elm->id, dst_net_elm->id)) {
char *link_name;
"between \"%s\" and \"%s\"", src, dst);
}
} else {
- if (!route->dst_gateway && !route->src_gateway)
+ if (!route->gw_dst && !route->gw_dst)
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst);
else {
// FIXME We can call a gw which is down the current AS (cf g5k.xml) but not upper.
// route->dst_gateway, subas->name);
as_route = 1;
XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",
- src, route->src_gateway->name, dst, route->dst_gateway->name);
- if (route->dst_gateway->rc_type == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The dst_gateway '%s' does not exist!", route->dst_gateway->name);
- if (route->src_gateway->rc_type == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The src_gateway '%s' does not exist!", route->src_gateway->name);
+ src, route->gw_src->name, dst, route->gw_dst->name);
+ if (route->gw_dst->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The dst_gateway '%s' does not exist!", route->gw_dst->name);
+ if (route->gw_src->rc_type == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The src_gateway '%s' does not exist!", route->gw_src->name);
}
TO_ROUTE_FULL(src_net_elm->id, dst_net_elm->id) =
generic_new_extended_route(rc->hierarchy, route, 1);
if ( (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES && as_route == 0)
|| (A_surfxml_ASroute_symmetrical == A_surfxml_ASroute_symmetrical_YES && as_route == 1)
) {
- if (route->dst_gateway && route->src_gateway) {
+ if (route->gw_dst && route->gw_src) {
sg_routing_edge_t gw_tmp;
- gw_tmp = route->src_gateway;
- route->src_gateway = route->dst_gateway;
- route->dst_gateway = gw_tmp;
+ gw_tmp = route->gw_src;
+ route->gw_src = route->gw_dst;
+ route->gw_dst = gw_tmp;
}
if (TO_ROUTE_FULL(dst_net_elm->id, src_net_elm->id)) {
char *link_name;
"The route between \"%s\" and \"%s\" already exists", src,
dst);
} else {
- if (!route->dst_gateway && !route->src_gateway)
+ if (!route->gw_dst && !route->gw_src)
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst, src);
else
XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",
- dst, route->src_gateway->name, src, route->dst_gateway->name);
+ dst, route->gw_src->name, src, route->gw_dst->name);
TO_ROUTE_FULL(dst_net_elm->id, src_net_elm->id) =
generic_new_extended_route(rc->hierarchy, route, 0);
xbt_dynar_shrink(TO_ROUTE_FULL(dst_net_elm->id, src_net_elm->id)->link_list, 0);
}
}
+ xbt_dynar_free(&route->link_list);
}
return xbt_dynar_length(as->index_network_elm)-1;
}
-void generic_parse_bypassroute(AS_t rc,
- const char *src, const char *dst,
- route_t e_route)
+void generic_parse_bypassroute(AS_t rc, sg_platf_route_cbarg_t e_route)
{
- if(e_route->dst_gateway)
+ char *src = (char*)(e_route->src);
+ char *dst = (char*)(e_route->dst);
+
+ if(e_route->gw_dst)
XBT_DEBUG("Load bypassASroute from \"%s\" to \"%s\"", src, dst);
else
XBT_DEBUG("Load bypassRoute from \"%s\" to \"%s\"", src, dst);
src, dst);
xbt_assert(!xbt_dict_get_or_null(dict_bypassRoutes, route_name),
"The bypass route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exists",
- src, e_route->src_gateway->name, dst, e_route->dst_gateway->name);
+ src, e_route->gw_src->name, dst, e_route->gw_dst->name);
- route_t new_e_route = NULL;
- if(e_route->dst_gateway)
+ sg_platf_route_cbarg_t new_e_route = NULL;
+ if(e_route->gw_dst)
new_e_route = generic_new_extended_route(SURF_ROUTING_RECURSIVE, e_route, 1);
else
new_e_route = generic_new_extended_route(SURF_ROUTING_BASE, e_route, 1);
xbt_dynar_free(&(e_route->link_list));
- xbt_free(e_route);
xbt_dict_set(dict_bypassRoutes, route_name, new_e_route, NULL);
no_bypassroute_declared = 0;
return NULL;
}
-route_t generic_get_bypassroute(AS_t rc, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat)
+sg_platf_route_cbarg_t generic_get_bypassroute(AS_t rc, sg_routing_edge_t src, sg_routing_edge_t dst, double *lat)
{
// If never set a bypass route return NULL without any further computations
XBT_DEBUG("generic_get_bypassroute from %s to %s",src->name,dst->name);
if(no_bypassroute_declared)
return NULL;
- route_t e_route_bypass = NULL;
+ sg_platf_route_cbarg_t e_route_bypass = NULL;
xbt_dict_t dict_bypassRoutes = rc->bypassRoutes;
if(dst->rc_component == rc && src->rc_component == rc ){
xbt_dynar_free(&path_dst);
}
- route_t new_e_route = NULL;
+ sg_platf_route_cbarg_t new_e_route = NULL;
if (e_route_bypass) {
void *link;
unsigned int cpt = 0;
- new_e_route = xbt_new0(s_route_t, 1);
- new_e_route->src_gateway = e_route_bypass->src_gateway;
- new_e_route->dst_gateway = e_route_bypass->dst_gateway;
+ new_e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+ new_e_route->gw_src = e_route_bypass->gw_src;
+ new_e_route->gw_dst = e_route_bypass->gw_dst;
new_e_route->link_list =
xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
xbt_dynar_foreach(e_route_bypass->link_list, cpt, link) {
/* ************************************************************************** */
/* ************************* GENERIC AUX FUNCTIONS ************************** */
/* change a route containing link names into a route containing link entities */
-route_t
+sg_platf_route_cbarg_t
generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
- route_t routearg, int change_order) {
+ sg_platf_route_cbarg_t routearg, int change_order) {
- route_t result;
+ sg_platf_route_cbarg_t result;
char *link_name;
unsigned int cpt;
- result = xbt_new0(s_route_t, 1);
+ result = xbt_new0(s_sg_platf_route_cbarg_t, 1);
result->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
xbt_assert(hierarchy == SURF_ROUTING_BASE
if (hierarchy == SURF_ROUTING_RECURSIVE) {
- xbt_assert(routearg->src_gateway && routearg->dst_gateway,
+ xbt_assert(routearg->gw_src && routearg->gw_dst,
"NULL is obviously a bad gateway");
/* remeber not erase the gateway names */
- result->src_gateway = routearg->src_gateway;
- result->dst_gateway = routearg->dst_gateway;
+ result->gw_src = routearg->gw_src;
+ result->gw_dst = routearg->gw_dst;
}
xbt_dynar_foreach(routearg->link_list, cpt, link_name) {
return result;
}
-void generic_free_route(route_t route)
+void generic_free_route(sg_platf_route_cbarg_t route)
{
if (route) {
xbt_dynar_free(&route->link_list);
}
static void none_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)
{
*lat = 0.0;
}
-static route_t none_get_bypass_route(AS_t rc,
+static sg_platf_route_cbarg_t none_get_bypass_route(AS_t rc,
sg_routing_edge_t src,
sg_routing_edge_t dst, double *lat) {
return NULL;
int generic_parse_PU(AS_t rc, sg_routing_edge_t elm);
int generic_parse_AS(AS_t rc, sg_routing_edge_t elm);
-void generic_parse_bypassroute(AS_t rc, const char *src, const char *dst,
- route_t e_route);
+void generic_parse_bypassroute(AS_t rc, sg_platf_route_cbarg_t e_route);
/* ************************************************************************** */
/* *************** GENERIC BUSINESS METHODS (declarations) ****************** */
xbt_dynar_t generic_get_onelink_routes(AS_t rc);
-route_t generic_get_bypassroute(AS_t rc,
+sg_platf_route_cbarg_t generic_get_bypassroute(AS_t rc,
sg_routing_edge_t src,
sg_routing_edge_t dst,
double *lat);
/* change a route containing link names into a route containing link entities.
* If change_order is true, the links are put in reverse order in the
* produced route */
-route_t generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
- route_t data, int preserve_order);
+sg_platf_route_cbarg_t generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
+ sg_platf_route_cbarg_t data, int preserve_order);
AS_t
generic_autonomous_system_exist(AS_t rc, char *element);
AS_t
/* *************************** FLOYD ROUTING ******************************** */
AS_t model_floyd_create(void); /* create structures for floyd routing model */
void model_floyd_end(AS_t as); /* finalize the creation of floyd routing model */
-void model_floyd_parse_route(AS_t rc, const char *src,
- const char *dst, route_t route);
+void model_floyd_parse_route(AS_t rc, sg_platf_route_cbarg_t route);
/* ************************************************** */
/* ************** RULE-BASED ROUTING **************** */
AS_t model_dijkstra_create(void); /* create structures for dijkstra routing model */
AS_t model_dijkstracache_create(void); /* create structures for dijkstracache routing model */
void model_dijkstra_both_end(AS_t as); /* finalize the creation of dijkstra routing model */
-void model_dijkstra_both_parse_route (AS_t rc, const char *src,
- const char *dst, route_t route);
+void model_dijkstra_both_parse_route (AS_t rc, sg_platf_route_cbarg_t route);
/* ************************************************************************** */
/* *************************** FULL ROUTING ********************************* */
AS_t model_full_create(void); /* create structures for full routing model */
void model_full_end(AS_t as); /* finalize the creation of full routing model */
void model_full_set_route( /* Set the route and ASroute between src and dst */
- AS_t rc, const char *src, const char *dst, route_t route);
+ AS_t rc, sg_platf_route_cbarg_t route);
#endif /* _SURF_SURF_ROUTING_PRIVATE_H */
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;
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;
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");
}
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);
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);
/* 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
(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);
}
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;
}
static void vivaldi_get_route_and_latency(
AS_t rc, sg_routing_edge_t src_p, sg_routing_edge_t dst_p,
- route_t route, double *lat)
+ sg_platf_route_cbarg_t route, double *lat)
{
s_surf_parsing_link_up_down_t info;
char *dst = (char*)dst_p->name;
if(src_p->rc_type == SURF_NETWORK_ELEMENT_AS) {
- route->src_gateway = xbt_lib_get_or_null(as_router_lib,ROUTER_PEER(src),ROUTING_ASR_LEVEL);
- route->dst_gateway = xbt_lib_get_or_null(as_router_lib,ROUTER_PEER(dst),ROUTING_ASR_LEVEL);
+ route->gw_src = xbt_lib_get_or_null(as_router_lib,ROUTER_PEER(src),ROUTING_ASR_LEVEL);
+ route->gw_dst = xbt_lib_get_or_null(as_router_lib,ROUTER_PEER(dst),ROUTING_ASR_LEVEL);
}
double euclidean_dist;
A_surfxml_route_src, A_surfxml_route_dst);
parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
+
void STag_surfxml_ASroute(void){
xbt_assert(strlen(A_surfxml_ASroute_src) > 0 || strlen(A_surfxml_ASroute_dst) > 0
|| strlen(A_surfxml_ASroute_gw_src) > 0 || strlen(A_surfxml_ASroute_gw_dst) > 0,
A_surfxml_ASroute_gw_src,A_surfxml_ASroute_gw_dst);
parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
+
void STag_surfxml_bypassRoute(void){
xbt_assert(strlen(A_surfxml_bypassRoute_src) > 0 || strlen(A_surfxml_bypassRoute_dst) > 0,
"Missing end-points while defining bupass route \"%s\"->\"%s\"",
A_surfxml_bypassRoute_src, A_surfxml_bypassRoute_dst);
parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
+
void STag_surfxml_bypassASroute(void){
xbt_assert(strlen(A_surfxml_bypassASroute_src) > 0 || strlen(A_surfxml_bypassASroute_dst) > 0
|| strlen(A_surfxml_bypassASroute_gw_src) > 0 || strlen(A_surfxml_bypassASroute_gw_dst) > 0,