child2->kind == INSTR_AS &&
strcmp(child1_name, child2_name) != 0){
- route_extended_t route = rc->get_route (rc, child1_name, child2_name);
+ route_t route = rc->get_route (rc, child1_name, child2_name);
unsigned int cpt;
void *link;
container_t previous = getContainerByName(route->src_gateway);
- xbt_dynar_foreach (route->generic_route.link_list, cpt, link) {
+ xbt_dynar_foreach (route->link_list, cpt, link) {
char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
container_t current = getContainerByName(link_name);
linkContainers (container, previous, current, filter);
child2->kind == INSTR_AS &&
strcmp(child1_name, child2_name) != 0){
- route_extended_t route = rc->get_route (rc, child1_name, child2_name);
+ route_t route = rc->get_route (rc, child1_name, child2_name);
unsigned int cpt;
void *link;
xbt_node_t current, previous = new_xbt_graph_node(graph, route->src_gateway, nodes);
- xbt_dynar_foreach (route->generic_route.link_list, cpt, link) {
+ xbt_dynar_foreach (route->link_list, cpt, link) {
char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
current = new_xbt_graph_node(graph, link_name, nodes);
//previous -> current
typedef struct s_route {
xbt_dynar_t link_list;
-} s_route_t, *route_t;
-
-typedef struct s_route_extended {
- s_route_t generic_route;
char *src_gateway;
char *dst_gateway;
-} s_route_extended_t, *route_extended_t;
+} s_route_t, *route_t;
/* This enum used in the routing structure helps knowing in which situation we are. */
typedef enum {
struct s_as *routing_father;
xbt_dict_t routing_sons;
- route_extended_t(*get_route) (AS_t as,
+ route_t(*get_route) (AS_t as,
const char *src, const char *dst);
double(*get_latency) (AS_t as,
const char *src, const char *dst,
- route_extended_t e_route);
+ route_t e_route);
xbt_dynar_t(*get_onelink_routes) (AS_t as);
- route_extended_t(*get_bypass_route) (AS_t as,
- const char *src, const char *dst);
+ route_t(*get_bypass_route) (AS_t as, const char *src, const char *dst);
void (*finalize) (AS_t as);
void (*parse_PU) (AS_t as, const char *name); /* A host or a router, whatever */
void (*parse_AS) (AS_t as, const char *name);
void (*parse_route) (AS_t as, const char *src,
- const char *dst, route_extended_t route);
+ const char *dst, route_t route);
void (*parse_ASroute) (AS_t as, const char *src,
- const char *dst, route_extended_t route);
+ const char *dst, route_t route);
void (*parse_bypassroute) (AS_t as, const char *src,
- const char *dst, route_extended_t e_route);
+ const char *dst, route_t e_route);
} s_as_t;
typedef struct s_network_element_info {
*/
static void routing_parse_E_route(void)
{
- route_extended_t route = xbt_new0(s_route_extended_t, 1);
- route->generic_route.link_list = link_list;
+ route_t route = xbt_new0(s_route_t, 1);
+ route->link_list = link_list;
xbt_assert(current_routing->parse_route,
"no defined method \"set_route\" in \"%s\"",
current_routing->name);
*/
static void routing_parse_E_ASroute(void)
{
- route_extended_t e_route = xbt_new0(s_route_extended_t, 1);
- e_route->generic_route.link_list = link_list;
+ route_t e_route = xbt_new0(s_route_t, 1);
+ e_route->link_list = link_list;
e_route->src_gateway = xbt_strdup(gw_src);
e_route->dst_gateway = xbt_strdup(gw_dst);
xbt_assert(current_routing->parse_ASroute,
*/
static void routing_parse_E_bypassRoute(void)
{
- route_extended_t e_route = xbt_new0(s_route_extended_t, 1);
- e_route->generic_route.link_list = link_list;
+ route_t e_route = xbt_new0(s_route_t, 1);
+ e_route->link_list = link_list;
e_route->src_gateway = xbt_strdup(gw_src);
e_route->dst_gateway = xbt_strdup(gw_dst);
xbt_assert(current_routing->parse_bypassroute,
if (src_father == dst_father) { /* SURF_ROUTING_BASE */
- route_extended_t e_route = NULL;
+ route_t e_route = NULL;
if (route) {
e_route = common_father->get_route(common_father, src, dst);
xbt_assert(e_route, "no route between \"%s\" and \"%s\"", src, dst);
- *route = e_route->generic_route.link_list;
+ *route = e_route->link_list;
}
if (latency) {
*latency = common_father->get_latency(common_father, src, dst, e_route);
} else { /* SURF_ROUTING_RECURSIVE */
- route_extended_t e_route_bypass = NULL;
+ route_t e_route_bypass = NULL;
if (common_father->get_bypass_route)
e_route_bypass = common_father->get_bypass_route(common_father, src, dst);
xbt_assert(!latency || !e_route_bypass,
"Bypass cannot work yet with get_latency");
- route_extended_t e_route_cnt = e_route_bypass
+ route_t e_route_cnt = e_route_bypass
? e_route_bypass : common_father->get_route(common_father,
src_father->name,
dst_father->name);
}
if (route) {
- xbt_dynar_foreach(e_route_cnt->generic_route.link_list, cpt, link) {
+ xbt_dynar_foreach(e_route_cnt->link_list, cpt, link) {
xbt_dynar_push(*route, &link);
}
}
}
}
- generic_free_extended_route(e_route_cnt);
+ generic_free_route(e_route_cnt);
}
}
static xbt_dict_t cluster_host_link = NULL;
/* Business methods */
-static route_extended_t cluster_get_route(AS_t as,
+static route_t cluster_get_route(AS_t as,
const char *src,
const char *dst) {
info = xbt_dict_get_or_null(cluster_host_link,dst);
if(info) xbt_dynar_push_as(links_list,void*,info->link_down); //link_down
- route_extended_t new_e_route = NULL;
- new_e_route = xbt_new0(s_route_extended_t, 1);
- new_e_route->generic_route.link_list = links_list;
+ route_t new_e_route = NULL;
+ new_e_route = xbt_new0(s_route_t, 1);
+ new_e_route->link_list = links_list;
return new_e_route;
}
xbt_free(elm);
}
-static void graph_edge_data_free(void *e)
+static void graph_edge_data_free(void *e) // FIXME: useless code dupplication
{
- route_extended_t e_route = (route_extended_t) e;
+ route_t e_route = (route_t) e;
if (e_route) {
- xbt_dynar_free(&(e_route->generic_route.link_list));
+ xbt_dynar_free(&(e_route->link_list));
xbt_free(e_route->src_gateway);
xbt_free(e_route->dst_gateway);
xbt_free(e_route);
/* Parsing */
static void route_new_dijkstra(as_dijkstra_t as, int src_id,
- int dst_id, route_extended_t e_route)
+ int dst_id, route_t e_route)
{
XBT_DEBUG("Load Route from \"%d\" to \"%d\"", src_id, dst_id);
xbt_node_t src = NULL;
}
if (!found) {
- route_extended_t e_route = xbt_new0(s_route_extended_t, 1);
- e_route->src_gateway = NULL;
- e_route->dst_gateway = NULL;
- e_route->generic_route.link_list =
- xbt_dynar_new(global_routing->size_of_link, NULL);
- xbt_dynar_push(e_route->generic_route.link_list,
+ route_t e_route = xbt_new0(s_route_t, 1);
+ e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
+ xbt_dynar_push(e_route->link_list,
&global_routing->loopback);
xbt_graph_new_edge(as->route_graph, node, node, e_route);
}
}
}
-static route_extended_t dijkstra_get_route(AS_t as_generic,
+static route_t dijkstra_get_route(AS_t as_generic,
const char *src,
const char *dst);
char *k1, *d1, *k2, *d2;
xbt_dict_foreach(as->to_index, c1, k1, d1) {
xbt_dict_foreach(as->to_index, c2, k2, d2) {
- route_extended_t route = dijkstra_get_route(as, k1, k2);
+ route_t route = dijkstra_get_route(as, k1, k2);
if (route) {
- if (xbt_dynar_length(route->generic_route.link_list) == 1) {
+ if (xbt_dynar_length(route->link_list) == 1) {
void *link =
- *(void **) xbt_dynar_get_ptr(route->generic_route.link_list,
- 0);
+ *(void **) xbt_dynar_get_ptr(route->link_list, 0);
onelink_t onelink = xbt_new0(s_onelink_t, 1);
onelink->link_ptr = link;
if (as->hierarchy == SURF_ROUTING_BASE) {
return ret;
}
-static route_extended_t dijkstra_get_route(AS_t asg,
+static route_t dijkstra_get_route(AS_t asg,
const char *src,
const char *dst)
{
src, dst);
/* create a result route */
- route_extended_t 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);
+ route_t new_e_route = xbt_new0(s_route_t, 1);
+ new_e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
new_e_route->src_gateway = NULL;
new_e_route->dst_gateway = NULL;
int dst_node_id = 0;
int *nodeid = NULL;
int v;
- route_extended_t e_route;
+ route_t e_route;
int size = 0;
unsigned int cpt;
void *link;
xbt_assert(edge != NULL, "no route between host %d and %d", *src_id,
*dst_id);
- e_route = (route_extended_t) xbt_graph_edge_get_data(edge);
+ e_route = (route_t) xbt_graph_edge_get_data(edge);
- links = e_route->generic_route.link_list;
+ links = e_route->link_list;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_unshift(new_e_route->generic_route.link_list, &link);
+ xbt_dynar_unshift(new_e_route->link_list, &link);
}
return new_e_route;
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_extended_t tmp_e_route =
- (route_extended_t) xbt_graph_edge_get_data(edge);
- int cost_v_u = (tmp_e_route->generic_route.link_list)->used; /* count of links, old model assume 1 */
+ route_t tmp_e_route = (route_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]) {
pred_arr[u_id] = *v_id;
prev_gw_src = gw_src;
- e_route = (route_extended_t) xbt_graph_edge_get_data(edge);
+ e_route = (route_t) xbt_graph_edge_get_data(edge);
gw_src = e_route->src_gateway;
gw_dst = e_route->dst_gateway;
links = e_route_as_to_as;
int pos = 0;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_insert_at(new_e_route->generic_route.link_list, pos,
- &link);
+ xbt_dynar_insert_at(new_e_route->link_list, pos, &link);
pos++;
}
}
- links = e_route->generic_route.link_list;
+ links = e_route->link_list;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_unshift(new_e_route->generic_route.link_list, &link);
+ xbt_dynar_unshift(new_e_route->link_list, &link);
}
size++;
}
}
void model_dijkstra_both_parse_route (AS_t asg, const char *src,
- const char *dst, route_extended_t route)
+ const char *dst, route_t route)
{
as_dijkstra_t as = (as_dijkstra_t) asg;
int *src_id, *dst_id;
xbt_die("The src_gateway '%s' does not exist!",route->src_gateway);
}
- route_extended_t e_route =
- generic_new_extended_route(asg->hierarchy, route, 1);
+ route_t e_route = generic_new_extended_route(asg->hierarchy, route, 1);
route_new_dijkstra(as, *src_id, *dst_id, e_route);
}
/* vars for calculate the floyd algorith. */
int *predecessor_table;
double *cost_table;
- route_extended_t *link_table;
+ route_t *link_table;
} s_as_floyd_t, *as_floyd_t;
-static route_extended_t floyd_get_route(AS_t asg,
- const char *src, const char *dst);
+static route_t floyd_get_route(AS_t asg, const char *src, const char *dst);
/* Business methods */
static xbt_dynar_t floyd_get_onelink_routes(AS_t asg)
char *k1, *d1, *k2, *d2;
xbt_dict_foreach(asg->to_index, c1, k1, d1) {
xbt_dict_foreach(asg->to_index, c2, k2, d2) {
- route_extended_t route = floyd_get_route(asg, k1, k2);
+ route_t route = floyd_get_route(asg, k1, k2);
if (route) {
- if (xbt_dynar_length(route->generic_route.link_list) == 1) {
+ if (xbt_dynar_length(route->link_list) == 1) {
void *link =
- *(void **) xbt_dynar_get_ptr(route->generic_route.link_list,
- 0);
+ *(void **) xbt_dynar_get_ptr(route->link_list, 0);
onelink_t onelink = xbt_new0(s_onelink_t, 1);
onelink->link_ptr = link;
if (asg->hierarchy == SURF_ROUTING_BASE) {
return ret;
}
-static route_extended_t floyd_get_route(AS_t asg,
- const char *src, const char *dst)
+static route_t floyd_get_route(AS_t asg, const char *src, const char *dst)
{
xbt_assert(asg && src
&& dst,
src, dst);
/* create a result route */
- route_extended_t 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;
+ route_t new_e_route = xbt_new0(s_route_t, 1);
+ new_e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
int first = 1;
int pred = *dst_id;
prev_gw_src = gw_src;
- route_extended_t e_route = TO_FLOYD_LINK(pred, prev_pred);
+ route_t e_route = TO_FLOYD_LINK(pred, prev_pred);
gw_src = e_route->src_gateway;
gw_dst = e_route->dst_gateway;
links = e_route_as_to_as;
int pos = 0;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_insert_at(new_e_route->generic_route.link_list, pos,
- &link);
+ xbt_dynar_insert_at(new_e_route->link_list, pos, &link);
pos++;
}
}
- links = e_route->generic_route.link_list;
+ links = e_route->link_list;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_unshift(new_e_route->generic_route.link_list, &link);
+ xbt_dynar_unshift(new_e_route->link_list, &link);
}
first = 0;
/* Delete link_table */
for (i = 0; i < table_size; i++)
for (j = 0; j < table_size; j++)
- generic_free_extended_route(TO_FLOYD_LINK(i, j));
+ generic_free_route(TO_FLOYD_LINK(i, j));
xbt_free(as->link_table);
/* Delete bypass dict */
xbt_dict_free(&as->generic_routing.bypassRoutes);
/* 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_extended_t, table_size * table_size); /* actual link between src and dst */
+ as->link_table = xbt_new0(route_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 (current_routing->hierarchy == SURF_ROUTING_BASE) {
for (i = 0; i < table_size; i++) {
- route_extended_t e_route = TO_FLOYD_LINK(i, i);
+ route_t e_route = TO_FLOYD_LINK(i, i);
if (!e_route) {
- e_route = xbt_new0(s_route_extended_t, 1);
+ e_route = xbt_new0(s_route_t, 1);
e_route->src_gateway = NULL;
e_route->dst_gateway = NULL;
- e_route->generic_route.link_list =
+ e_route->link_list =
xbt_dynar_new(global_routing->size_of_link, NULL);
- xbt_dynar_push(e_route->generic_route.link_list,
- &global_routing->loopback);
+ xbt_dynar_push(e_route->link_list, &global_routing->loopback);
TO_FLOYD_LINK(i, i) = e_route;
TO_FLOYD_PRED(i, i) = i;
TO_FLOYD_COST(i, i) = 1;
//FIXME: kill dupplicates in next function with full routing
void model_floyd_parse_route(AS_t rc, const char *src,
- const char *dst, route_extended_t route)
+ const char *dst, route_t route)
{
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_extended_t, table_size * table_size); /* actual link between src and dst */
+ as->link_table = xbt_new0(route_t, table_size * table_size); /* actual link between src and dst */
/* Initialize costs and predecessors */
for (i = 0; i < table_size; i++)
char * link_name;
unsigned int cpt;
xbt_dynar_t link_route_to_test = xbt_dynar_new(global_routing->size_of_link, NULL);
- xbt_dynar_foreach(route->generic_route.link_list,cpt,link_name)
+ xbt_dynar_foreach(route->link_list,cpt,link_name)
{
void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
xbt_assert(link,"Link : '%s' doesn't exists.",link_name);
xbt_dynar_push(link_route_to_test,&link);
}
xbt_assert(!xbt_dynar_compare(
- (void*)TO_FLOYD_LINK(*src_id, *dst_id)->generic_route.link_list,
+ (void*)TO_FLOYD_LINK(*src_id, *dst_id)->link_list,
(void*)link_route_to_test,
(int_f_cpvoid_cpvoid_t) surf_pointer_resource_cmp),
"The route between \"%s\" and \"%s\" already exists", src,dst);
generic_new_extended_route(rc->hierarchy, route, 1);
TO_FLOYD_PRED(*src_id, *dst_id) = *src_id;
TO_FLOYD_COST(*src_id, *dst_id) =
- ((TO_FLOYD_LINK(*src_id, *dst_id))->generic_route.link_list)->used; /* count of links, old model assume 1 */
+ ((TO_FLOYD_LINK(*src_id, *dst_id))->link_list)->used; /* count of links, old model assume 1 */
}
if( A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES
char * link_name;
unsigned int i;
xbt_dynar_t link_route_to_test = xbt_dynar_new(global_routing->size_of_link, NULL);
- for(i=xbt_dynar_length(route->generic_route.link_list) ;i>0 ;i--)
+ for(i=xbt_dynar_length(route->link_list) ;i>0 ;i--)
{
- link_name = xbt_dynar_get_as(route->generic_route.link_list,i-1,void *);
+ link_name = xbt_dynar_get_as(route->link_list,i-1,void *);
void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
xbt_assert(link,"Link : '%s' doesn't exists.",link_name);
xbt_dynar_push(link_route_to_test,&link);
}
xbt_assert(!xbt_dynar_compare(
- (void*)TO_FLOYD_LINK(*dst_id, *src_id)->generic_route.link_list,
+ (void*)TO_FLOYD_LINK(*dst_id, *src_id)->link_list,
(void*)link_route_to_test,
(int_f_cpvoid_cpvoid_t) surf_pointer_resource_cmp),
"The route between \"%s\" and \"%s\" already exists", src,dst);
generic_new_extended_route(rc->hierarchy, route, 0);
TO_FLOYD_PRED(*dst_id, *src_id) = *dst_id;
TO_FLOYD_COST(*dst_id, *src_id) =
- ((TO_FLOYD_LINK(*dst_id, *src_id))->generic_route.link_list)->used; /* count of links, old model assume 1 */
+ ((TO_FLOYD_LINK(*dst_id, *src_id))->link_list)->used; /* count of links, old model assume 1 */
}
}
}
typedef struct s_routing_component_full {
s_as_t generic_routing;
- route_extended_t *routing_table;
+ route_t *routing_table;
} s_routing_component_full_t, *routing_component_full_t;
/* Business methods */
&& dst_id,
"Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
k1, k2);
- route_extended_t route = TO_ROUTE_FULL(*src_id, *dst_id);
+ route_t route = TO_ROUTE_FULL(*src_id, *dst_id);
if (route) {
- if (xbt_dynar_length(route->generic_route.link_list) == 1) {
+ if (xbt_dynar_length(route->link_list) == 1) {
void *link =
- *(void **) xbt_dynar_get_ptr(route->generic_route.link_list,
+ *(void **) xbt_dynar_get_ptr(route->link_list,
0);
onelink_t onelink = xbt_new0(s_onelink_t, 1);
onelink->link_ptr = link;
return ret;
}
-static route_extended_t full_get_route(AS_t rc,
+static route_t full_get_route(AS_t rc,
const char *src, const char *dst)
{
xbt_assert(rc && src
"Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
src, dst);
- route_extended_t e_route = NULL;
- route_extended_t new_e_route = NULL;
+ route_t e_route = NULL;
+ route_t new_e_route = NULL;
void *link;
unsigned int cpt = 0;
e_route = TO_ROUTE_FULL(*src_id, *dst_id);
if (e_route) {
- new_e_route = xbt_new0(s_route_extended_t, 1);
+ new_e_route = xbt_new0(s_route_t, 1);
new_e_route->src_gateway = xbt_strdup(e_route->src_gateway);
new_e_route->dst_gateway = xbt_strdup(e_route->dst_gateway);
- new_e_route->generic_route.link_list =
+ new_e_route->link_list =
xbt_dynar_new(global_routing->size_of_link, NULL);
- xbt_dynar_foreach(e_route->generic_route.link_list, cpt, link) {
- xbt_dynar_push(new_e_route->generic_route.link_list, &link);
+ xbt_dynar_foreach(e_route->link_list, cpt, link) {
+ xbt_dynar_push(new_e_route->link_list, &link);
}
}
return new_e_route;
/* Delete routing table */
for (i = 0; i < table_size; i++)
for (j = 0; j < table_size; j++)
- generic_free_extended_route(TO_ROUTE_FULL(i, j));
+ generic_free_route(TO_ROUTE_FULL(i, j));
xbt_free(routing->routing_table);
model_generic_finalize(rc);
}
void model_full_end(AS_t current_routing)
{
unsigned int i;
- route_extended_t e_route;
+ route_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_extended_t, table_size * table_size);
+ routing->routing_table = xbt_new0(route_t, table_size * table_size);
/* Add the loopback if needed */
if (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_extended_t, 1);
+ e_route = xbt_new0(s_route_t, 1);
e_route->src_gateway = NULL;
e_route->dst_gateway = NULL;
- e_route->generic_route.link_list =
- xbt_dynar_new(global_routing->size_of_link, NULL);
- xbt_dynar_push(e_route->generic_route.link_list,
+ e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
+ xbt_dynar_push(e_route->link_list,
&global_routing->loopback);
TO_ROUTE_FULL(i, i) = e_route;
}
}
void model_full_set_route(AS_t rc, const char *src,
- const char *dst, route_extended_t route)
+ const char *dst, route_t route)
{
int *src_id, *dst_id;
src_id = xbt_dict_get_or_null(rc->to_index, src);
xbt_assert(src_id, "Network elements %s not found", src);
xbt_assert(dst_id, "Network elements %s not found", dst);
- xbt_assert(!xbt_dynar_is_empty(route->generic_route.link_list),
+ xbt_assert(!xbt_dynar_is_empty(route->link_list),
"Invalid count of links, must be greater than zero (%s,%s)",
src, dst);
if(!routing->routing_table)
- routing->routing_table = xbt_new0(route_extended_t, table_size * table_size);
+ routing->routing_table = xbt_new0(route_t, table_size * table_size);
if(TO_ROUTE_FULL(*src_id, *dst_id))
{
char * link_name;
unsigned int i;
xbt_dynar_t link_route_to_test = xbt_dynar_new(global_routing->size_of_link, NULL);
- xbt_dynar_foreach(route->generic_route.link_list,i,link_name)
+ xbt_dynar_foreach(route->link_list,i,link_name)
{
void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
xbt_assert(link,"Link : '%s' doesn't exists.",link_name);
xbt_dynar_push(link_route_to_test,&link);
}
xbt_assert(!xbt_dynar_compare(
- (void*)TO_ROUTE_FULL(*src_id, *dst_id)->generic_route.link_list,
+ (void*)TO_ROUTE_FULL(*src_id, *dst_id)->link_list,
(void*)link_route_to_test,
(int_f_cpvoid_cpvoid_t) surf_pointer_resource_cmp),
"The route between \"%s\" and \"%s\" already exists. If you are trying to define a reverse route, you must set the symmetrical=no attribute to your routes tags.", src,dst);
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);
- xbt_dynar_shrink(TO_ROUTE_FULL(*src_id, *dst_id)->generic_route.link_list, 0);
+ xbt_dynar_shrink(TO_ROUTE_FULL(*src_id, *dst_id)->link_list, 0);
}
if( A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES
char * link_name;
unsigned int i;
xbt_dynar_t link_route_to_test = xbt_dynar_new(global_routing->size_of_link, NULL);
- for(i=xbt_dynar_length(route->generic_route.link_list) ;i>0 ;i--)
+ for(i=xbt_dynar_length(route->link_list) ;i>0 ;i--)
{
- link_name = xbt_dynar_get_as(route->generic_route.link_list,i-1,void *);
+ link_name = xbt_dynar_get_as(route->link_list,i-1,void *);
void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
xbt_assert(link,"Link : '%s' doesn't exists.",link_name);
xbt_dynar_push(link_route_to_test,&link);
}
xbt_assert(!xbt_dynar_compare(
- (void*)TO_ROUTE_FULL(*dst_id, *src_id)->generic_route.link_list,
+ (void*)TO_ROUTE_FULL(*dst_id, *src_id)->link_list,
(void*)link_route_to_test,
(int_f_cpvoid_cpvoid_t) surf_pointer_resource_cmp),
"The route between \"%s\" and \"%s\" already exists", src,dst);
XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst,
route->src_gateway, src, route->dst_gateway);
TO_ROUTE_FULL(*dst_id, *src_id) = generic_new_extended_route(rc->hierarchy,route,0);
- xbt_dynar_shrink(TO_ROUTE_FULL(*dst_id, *src_id)->generic_route.link_list, 0);
+ xbt_dynar_shrink(TO_ROUTE_FULL(*dst_id, *src_id)->link_list, 0);
}
}
- if (rc->hierarchy == SURF_ROUTING_BASE) generic_free_route((route_t)route) ;
- else generic_free_extended_route((route_extended_t)route);
+ generic_free_route((route_t)route) ;
}
void generic_parse_bypassroute(AS_t rc,
const char *src, const char *dst,
- route_extended_t e_route)
+ route_t e_route)
{
XBT_DEBUG("Load bypassRoute from \"%s\" to \"%s\"", src, dst);
xbt_dict_t dict_bypassRoutes = rc->bypassRoutes;
char *route_name;
route_name = bprintf("%s#%s", src, dst);
- xbt_assert(!xbt_dynar_is_empty(e_route->generic_route.link_list),
+ xbt_assert(!xbt_dynar_is_empty(e_route->link_list),
"Invalid count of links, must be greater than zero (%s,%s)",
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, dst, e_route->dst_gateway);
- route_extended_t new_e_route =
+ route_t new_e_route =
generic_new_extended_route(SURF_ROUTING_RECURSIVE, e_route, 0);
- xbt_dynar_free(&(e_route->generic_route.link_list));
+ xbt_dynar_free(&(e_route->link_list));
xbt_free(e_route);
xbt_dict_set(dict_bypassRoutes, route_name, new_e_route,
- (void (*)(void *)) generic_free_extended_route);
+ (void (*)(void *)) generic_free_route);
xbt_free(route_name);
}
double generic_get_link_latency(AS_t rc,
const char *src, const char *dst,
- route_extended_t route)
+ route_t route)
{
int need_to_clean = route ? 0 : 1;
void *link;
route = route ? route : rc->get_route(rc, src, dst);
- xbt_dynar_foreach(route->generic_route.link_list, i, link) {
+ xbt_dynar_foreach(route->link_list, i, link) {
latency += surf_network_model->extension.network.get_link_latency(link);
}
if (need_to_clean)
- generic_free_extended_route(route);
+ generic_free_route(route);
return latency;
}
xbt_die("\"generic_get_onelink_routes\" not implemented yet");
}
-route_extended_t generic_get_bypassroute(AS_t rc,
+route_t generic_get_bypassroute(AS_t rc,
const char *src, const char *dst)
{
xbt_dict_t dict_bypassRoutes = rc->bypassRoutes;
int max_index = max(max_index_src, max_index_dst);
int i, max;
- route_extended_t e_route_bypass = NULL;
+ route_t e_route_bypass = NULL;
for (max = 0; max <= max_index; max++) {
for (i = 0; i < max; i++) {
xbt_dynar_free(&path_src);
xbt_dynar_free(&path_dst);
- route_extended_t new_e_route = NULL;
+ route_t new_e_route = NULL;
if (e_route_bypass) {
void *link;
unsigned int cpt = 0;
- new_e_route = xbt_new0(s_route_extended_t, 1);
+ new_e_route = xbt_new0(s_route_t, 1);
new_e_route->src_gateway = xbt_strdup(e_route_bypass->src_gateway);
new_e_route->dst_gateway = xbt_strdup(e_route_bypass->dst_gateway);
- new_e_route->generic_route.link_list =
+ new_e_route->link_list =
xbt_dynar_new(global_routing->size_of_link, NULL);
- xbt_dynar_foreach(e_route_bypass->generic_route.link_list, cpt, link) {
- xbt_dynar_push(new_e_route->generic_route.link_list, &link);
+ xbt_dynar_foreach(e_route_bypass->link_list, cpt, link) {
+ xbt_dynar_push(new_e_route->link_list, &link);
}
}
return new_route;
}
-route_extended_t
+route_t
generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
void *data, int order)
{
char *link_name;
- route_extended_t e_route, new_e_route;
+ route_t e_route, new_e_route;
route_t route;
unsigned int cpt;
xbt_dynar_t links = NULL, links_id = NULL;
- 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;
+ new_e_route = xbt_new0(s_route_t, 1);
+ new_e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
xbt_assert(hierarchy == SURF_ROUTING_BASE
|| hierarchy == SURF_ROUTING_RECURSIVE,
} else if (hierarchy == SURF_ROUTING_RECURSIVE) {
- e_route = (route_extended_t) data;
+ e_route = (route_t) data;
xbt_assert(e_route->src_gateway
&& e_route->dst_gateway, "bad gateway, is null");
- links = e_route->generic_route.link_list;
+ links = e_route->link_list;
/* remeber not erase the gateway names */
new_e_route->src_gateway = strdup(e_route->src_gateway);
new_e_route->dst_gateway = strdup(e_route->dst_gateway);
}
- links_id = new_e_route->generic_route.link_list;
+ links_id = new_e_route->link_list;
xbt_dynar_foreach(links, cpt, link_name) {
{
if (route) {
xbt_dynar_free(&(route->link_list));
+ xbt_free(route->src_gateway);
+ xbt_free(route->dst_gateway);
xbt_free(route);
}
}
-void generic_free_extended_route(route_extended_t e_route)
-{
- if (e_route) {
- xbt_dynar_free(&(e_route->generic_route.link_list));
- xbt_free(e_route->src_gateway);
- xbt_free(e_route->dst_gateway);
- xbt_free(e_route);
- }
-}
-
static AS_t generic_as_exist(AS_t find_from,
AS_t to_find)
{
return NULL;
}
-static route_extended_t none_get_route(AS_t rc,
+static route_t none_get_route(AS_t rc,
const char *src, const char *dst)
{
return NULL;
}
-static route_extended_t none_get_bypass_route(AS_t rc,
+static route_t none_get_bypass_route(AS_t rc,
const char *src,
const char *dst) {
return NULL;
void generic_parse_PU(AS_t rc, const char *name);
void generic_parse_AS(AS_t rc, const char *name);
void generic_parse_bypassroute(AS_t rc, const char *src, const char *dst,
- route_extended_t e_route);
+ route_t e_route);
/* ************************************************************************** */
/* *************** GENERIC BUSINESS METHODS (declarations) ****************** */
double generic_get_link_latency(AS_t rc, const char *src, const char *dst,
- route_extended_t e_route);
+ route_t e_route);
xbt_dynar_t generic_get_onelink_routes(AS_t rc);
-route_extended_t generic_get_bypassroute(AS_t rc,
+route_t generic_get_bypassroute(AS_t rc,
const char *src,
const char *dst);
/* ************************************************************************** */
/* ****************** GENERIC AUX FUNCTIONS (declarations) ****************** */
-route_extended_t
+route_t
generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
void *data, int order);
route_t
generic_new_route(e_surf_routing_hierarchy_t hierarchy,
void *data, int order);
void generic_free_route(route_t route);
-void generic_free_extended_route(route_extended_t e_route);
AS_t
generic_autonomous_system_exist(AS_t rc, char *element);
AS_t
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_extended_t route);
+ const char *dst, route_t route);
/* ************************************************** */
/* ************** RULE-BASED ROUTING **************** */
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_extended_t route);
+ const char *dst, route_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_extended_t route);
+ AS_t rc, const char *src, const char *dst, route_t route);
#endif /* _SURF_SURF_ROUTING_PRIVATE_H */
static void model_rulebased_parse_route(AS_t rc,
const char *src, const char *dst,
- route_extended_t route)
+ route_t route)
{
routing_component_rulebased_t routing =
(routing_component_rulebased_t) rc;
int erroffset;
if(!strcmp(rc->model_desc->name,"Vivaldi")){
- if(!xbt_dynar_is_empty(route->generic_route.link_list))
+ if(!xbt_dynar_is_empty(route->link_list))
xbt_die("You can't have link_ctn with Model Vivaldi.");
}
xbt_assert(ruleroute->re_src,
"PCRE compilation failed at offset %d (\"%s\"): %s\n",
erroffset, dst, error);
- ruleroute->re_str_link = route->generic_route.link_list;
+ ruleroute->re_str_link = route->link_list;
xbt_dynar_push(routing->list_route, &ruleroute);
xbt_free(route);
}
static void model_rulebased_parse_ASroute(AS_t rc,
const char *src, const char *dst,
- route_extended_t route)
+ route_t route)
{
routing_component_rulebased_t routing =
(routing_component_rulebased_t) rc;
int erroffset;
if(!strcmp(rc->model_desc->name,"Vivaldi")){
- if(!xbt_dynar_is_empty(route->generic_route.link_list))
+ if(!xbt_dynar_is_empty(route->link_list))
xbt_die("You can't have link_ctn with Model Vivaldi.");
}
"PCRE compilation failed at offset %d (\"%s\"): %s\n",
erroffset, dst, error);
ruleroute_e->generic_rule_route.re_str_link =
- route->generic_route.link_list;
+ route->link_list;
ruleroute_e->re_src_gateway = route->src_gateway;
ruleroute_e->re_dst_gateway = route->dst_gateway;
xbt_dynar_push(routing->list_ASroute, &ruleroute_e);
static void model_rulebased_parse_bypassroute(AS_t rc,
const char *src,
const char *dst,
- route_extended_t e_route)
+ route_t e_route)
{
xbt_die("bypass routing not supported for Route-Based model");
}
return memcpy(res, result, i_res);
}
-static route_extended_t rulebased_get_route(AS_t rc,
+static route_t rulebased_get_route(AS_t rc,
const char *src,
const char *dst);
static xbt_dynar_t rulebased_get_onelink_routes(AS_t rc)
}
xbt_dict_foreach(routing->dict_processing_units, c1, k1, d1) {
- route_extended_t route = rulebased_get_route (rc, router, k1);
+ route_t route = rulebased_get_route (rc, router, k1);
- int number_of_links = xbt_dynar_length(route->generic_route.link_list);
+ int number_of_links = xbt_dynar_length(route->link_list);
if(number_of_links == 1) {
//loopback
}
void *link_ptr;
- xbt_dynar_get_cpy (route->generic_route.link_list, 1, &link_ptr);
+ xbt_dynar_get_cpy (route->link_list, 1, &link_ptr);
onelink_t onelink = xbt_new0 (s_onelink_t, 1);
onelink->src = xbt_strdup (k1);
onelink->dst = xbt_strdup (router);
}
/* Business methods */
-static route_extended_t rulebased_get_route(AS_t rc,
+static route_t rulebased_get_route(AS_t rc,
const char *src,
const char *dst)
{
break;
}
- route_extended_t new_e_route = NULL;
+ route_t new_e_route = NULL;
if (rc_src >= 0 && rc_dst >= 0) {
- new_e_route = xbt_new0(s_route_extended_t, 1);
- new_e_route->generic_route.link_list = links_list;
+ new_e_route = xbt_new0(s_route_t, 1);
+ new_e_route->link_list = links_list;
} else if (!strcmp(src, dst) && are_processing_units) {
- new_e_route = xbt_new0(s_route_extended_t, 1);
+ new_e_route = xbt_new0(s_route_t, 1);
xbt_dynar_push(links_list, &(global_routing->loopback));
- new_e_route->generic_route.link_list = links_list;
+ new_e_route->link_list = links_list;
} else {
xbt_dynar_free(&link_list);
}
return new_e_route;
}
-static route_extended_t rulebased_get_bypass_route(AS_t rc,
- const char *src,
- const char *dst)
-{
+static route_t rulebased_get_bypass_route(AS_t rc, const char *src, const char *dst) {
return NULL;
}
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_vivaldi, surf, "Routing part of surf");
/* Business methods */
-static route_extended_t vivaldi_get_route(AS_t rc,
- const char *src,
- const char *dst)
+static route_t vivaldi_get_route(AS_t rc, const char *src, const char *dst)
{
xbt_assert(rc && src
&& dst,
"Invalid params for \"get_route\" function at AS \"%s\"",
rc->name);
- route_extended_t new_e_route = xbt_new0(s_route_extended_t, 1);
+ route_t new_e_route = xbt_new0(s_route_t, 1);
new_e_route->src_gateway = ROUTER_PEER(src);
new_e_route->dst_gateway = ROUTER_PEER(dst);
- new_e_route->generic_route.link_list = xbt_dynar_new(0, NULL);
+ new_e_route->link_list = xbt_dynar_new(0, NULL);
return new_e_route;
}
return euclidean_dist / 1000;
}
-static double vivaldi_get_link_latency (AS_t rc,const char *src, const char *dst, route_extended_t e_route)
+static double vivaldi_get_link_latency (AS_t rc,const char *src, const char *dst, route_t e_route)
{
if(routing_get_network_element_type(src) == SURF_NETWORK_ELEMENT_AS) {
int need_to_clean = e_route?0:1;
double latency;
e_route = e_route ? e_route : rc->get_route(rc, src, dst);
latency = base_vivaldi_get_latency(e_route->src_gateway,e_route->dst_gateway);
- if(need_to_clean) generic_free_extended_route(e_route);
+ if(need_to_clean) generic_free_route(e_route);
return latency;
} else {
return base_vivaldi_get_latency(src,dst);