typedef struct {
s_routing_component_t generic_routing;
xbt_dict_t parse_routes; /* store data during the parse process */
- xbt_dict_t to_index; /* char* -> network_element_t */
xbt_dict_t bypassRoutes;
route_extended_t *routing_table;
} s_routing_component_full_t, *routing_component_full_t;
xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
routing_component_full_t routing = (routing_component_full_t) rc;
- int table_size = xbt_dict_length(routing->to_index);
+ int table_size = xbt_dict_length(routing->generic_routing.to_index);
xbt_dict_cursor_t c1 = NULL, c2 = NULL;
char *k1, *d1, *k2, *d2;
- xbt_dict_foreach(routing->to_index, c1, k1, d1) {
- xbt_dict_foreach(routing->to_index, c2, k2, d2) {
- int *src_id = xbt_dict_get_or_null(routing->to_index, k1);
- int *dst_id = xbt_dict_get_or_null(routing->to_index, k2);
+ xbt_dict_foreach(routing->generic_routing.to_index, c1, k1, d1) {
+ xbt_dict_foreach(routing->generic_routing.to_index, c2, k2, d2) {
+ int *src_id = xbt_dict_get_or_null(routing->generic_routing.to_index, k1);
+ int *dst_id = xbt_dict_get_or_null(routing->generic_routing.to_index, k2);
xbt_assert2(src_id
&& dst_id,
"Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
/* set utils vars */
routing_component_full_t routing = (routing_component_full_t) rc;
- int table_size = xbt_dict_length(routing->to_index);
+ int table_size = xbt_dict_length(routing->generic_routing.to_index);
generic_src_dst_check(rc, src, dst);
- int *src_id = xbt_dict_get_or_null(routing->to_index, src);
- int *dst_id = xbt_dict_get_or_null(routing->to_index, dst);
+ int *src_id = xbt_dict_get_or_null(routing->generic_routing.to_index, src);
+ int *dst_id = xbt_dict_get_or_null(routing->generic_routing.to_index, dst);
xbt_assert2(src_id
&& dst_id,
"Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
static void full_finalize(routing_component_t rc)
{
routing_component_full_t routing = (routing_component_full_t) rc;
- int table_size = xbt_dict_length(routing->to_index);
+ int table_size = xbt_dict_length(routing->generic_routing.to_index);
int i, j;
if (routing) {
/* Delete routing table */
/* Delete bypass dict */
xbt_dict_free(&routing->bypassRoutes);
/* Delete index dict */
- xbt_dict_free(&(routing->to_index));
+ xbt_dict_free(&(routing->generic_routing.to_index));
/* Delete structure */
xbt_free(rc);
}
new_component->generic_routing.get_bypass_route =
generic_get_bypassroute;
new_component->generic_routing.finalize = full_finalize;
- new_component->to_index = xbt_dict_new();
+ new_component->generic_routing.to_index = xbt_dict_new();
new_component->bypassRoutes = xbt_dict_new();
new_component->parse_routes = xbt_dict_new();
return new_component;
/* set utils vars */
routing_component_full_t routing =
((routing_component_full_t) current_routing);
- int table_size = xbt_dict_length(routing->to_index);
+ int table_size = xbt_dict_length(routing->generic_routing.to_index);
/* Create the routing table */
routing->routing_table =
/* vars for calculate the floyd algorith. */
int *predecessor_table;
route_extended_t *link_table; /* char* -> int* */
- xbt_dict_t to_index;
xbt_dict_t bypassRoutes;
/* store data during the parse process */
xbt_dict_t parse_routes;
xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
routing_component_floyd_t routing = (routing_component_floyd_t) rc;
- //int table_size = xbt_dict_length(routing->to_index);
+ //int table_size = xbt_dict_length(routing->generic_routing.to_index);
xbt_dict_cursor_t c1 = NULL, c2 = NULL;
char *k1, *d1, *k2, *d2;
- xbt_dict_foreach(routing->to_index, c1, k1, d1) {
- xbt_dict_foreach(routing->to_index, c2, k2, d2) {
+ xbt_dict_foreach(routing->generic_routing.to_index, c1, k1, d1) {
+ xbt_dict_foreach(routing->generic_routing.to_index, c2, k2, d2) {
route_extended_t route = floyd_get_route(rc, k1, k2);
if (route) {
if (xbt_dynar_length(route->generic_route.link_list) == 1) {
/* set utils vars */
routing_component_floyd_t routing = (routing_component_floyd_t) rc;
- int table_size = xbt_dict_length(routing->to_index);
+ int table_size = xbt_dict_length(routing->generic_routing.to_index);
generic_src_dst_check(rc, src, dst);
- int *src_id = xbt_dict_get_or_null(routing->to_index, src);
- int *dst_id = xbt_dict_get_or_null(routing->to_index, dst);
+ int *src_id = xbt_dict_get_or_null(routing->generic_routing.to_index, src);
+ int *dst_id = xbt_dict_get_or_null(routing->generic_routing.to_index, dst);
xbt_assert2(src_id
&& dst_id,
"Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
routing_component_floyd_t routing = (routing_component_floyd_t) rc;
int i, j, table_size;
if (routing) {
- table_size = xbt_dict_length(routing->to_index);
+ table_size = xbt_dict_length(routing->generic_routing.to_index);
/* Delete link_table */
for (i = 0; i < table_size; i++)
for (j = 0; j < table_size; j++)
/* Delete bypass dict */
xbt_dict_free(&routing->bypassRoutes);
/* Delete index dict */
- xbt_dict_free(&(routing->to_index));
+ xbt_dict_free(&(routing->generic_routing.to_index));
/* Delete dictionary index dict, predecessor and links table */
xbt_free(routing->predecessor_table);
/* Delete structure */
new_component->generic_routing.get_bypass_route =
generic_get_bypassroute;
new_component->generic_routing.finalize = floyd_finalize;
- new_component->to_index = xbt_dict_new();
+ new_component->generic_routing.to_index = xbt_dict_new();
new_component->bypassRoutes = xbt_dict_new();
new_component->parse_routes = xbt_dict_new();
return new_component;
unsigned int i, j, a, b, c;
/* set the size of inicial table */
- int table_size = xbt_dict_length(routing->to_index);
+ int table_size = xbt_dict_length(routing->generic_routing.to_index);
/* Create Cost, Predecessor and Link tables */
cost_table = xbt_new0(double, table_size * table_size); /* link cost from host to host */
typedef struct {
s_routing_component_t generic_routing;
- xbt_dict_t to_index;
xbt_dict_t bypassRoutes;
xbt_graph_t route_graph; /* xbt_graph */
xbt_dict_t graph_node_map; /* map */
routing_component_dijkstra_t routing = (routing_component_dijkstra_t) rc;
generic_src_dst_check(rc, src, dst);
- int *src_id = xbt_dict_get_or_null(routing->to_index, src);
- int *dst_id = xbt_dict_get_or_null(routing->to_index, dst);
+ int *src_id = xbt_dict_get_or_null(routing->generic_routing.to_index, src);
+ int *dst_id = xbt_dict_get_or_null(routing->generic_routing.to_index, dst);
xbt_assert2(src_id
&& dst_id,
"Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
/* Delete bypass dict */
xbt_dict_free(&routing->bypassRoutes);
/* Delete index dict */
- xbt_dict_free(&(routing->to_index));
+ xbt_dict_free(&(routing->generic_routing.to_index));
/* Delete structure */
xbt_free(routing);
}
generic_get_bypassroute;
new_component->generic_routing.finalize = dijkstra_finalize;
new_component->cached = cached;
- new_component->to_index = xbt_dict_new();
+ new_component->generic_routing.to_index = xbt_dict_new();
new_component->bypassRoutes = xbt_dict_new();
new_component->parse_routes = xbt_dict_new();
return new_component;
return xbt_strdup(result_result);
}
+static route_extended_t rulebased_get_route(routing_component_t rc,
+ const char *src,
+ const char *dst);
static xbt_dynar_t rulebased_get_onelink_routes(routing_component_t rc)
{
- xbt_die("\"rulebased_get_onelink_routes\" function not implemented yet");
+ xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free);
+ routing_component_rulebased_t routing = (routing_component_rulebased_t)rc;
+
+ xbt_dict_cursor_t c1 = NULL;
+ char *k1, *d1;
+
+ //find router
+ char *router = NULL;
+ xbt_dict_foreach(routing->dict_processing_units, c1, k1, d1) {
+ if (strstr (k1, "router")){
+ router = k1;
+ }
+ }
+ if (!router){
+ xbt_die ("rulebased_get_onelink_routes works only if the AS is a cluster, sorry.");
+ }
+
+ xbt_dict_foreach(routing->dict_processing_units, c1, k1, d1) {
+ route_extended_t route = rulebased_get_route (rc, router, k1);
+
+ int number_of_links = xbt_dynar_length(route->generic_route.link_list);
+ if (number_of_links != 3) {
+ xbt_die ("rulebased_get_onelink_routes works only if the AS is a cluster, sorry.");
+ }
+
+ void *link_ptr;
+ xbt_dynar_get_cpy (route->generic_route.link_list, 2, &link_ptr);
+ onelink_t onelink = xbt_new0 (s_onelink_t, 1);
+ onelink->src = xbt_strdup (k1);
+ onelink->dst = xbt_strdup (router);
+ onelink->link_ptr = link_ptr;
+ xbt_dynar_push (ret, &onelink);
+ }
+ return ret;
}
/* Business methods */
const char *name)
{
DEBUG1("Load process unit \"%s\"", name);
- model_type_t modeltype = rc->routing;
int *id = xbt_new0(int, 1);
xbt_dict_t _to_index;
- if (modeltype == &routing_models[SURF_MODEL_FULL])
- _to_index = ((routing_component_full_t) rc)->to_index;
-
- else if (modeltype == &routing_models[SURF_MODEL_FLOYD])
- _to_index = ((routing_component_floyd_t) rc)->to_index;
-
- else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
- modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE])
- _to_index = ((routing_component_dijkstra_t) rc)->to_index;
-
- else
- xbt_die("\"generic_set_processing_unit\" not supported");
+ _to_index = current_routing->to_index;
*id = xbt_dict_length(_to_index);
xbt_dict_set(_to_index, name, id, xbt_free);
}
const char *name)
{
DEBUG1("Load Autonomous system \"%s\"", name);
- model_type_t modeltype = rc->routing;
int *id = xbt_new0(int, 1);
xbt_dict_t _to_index;
- if (modeltype == &routing_models[SURF_MODEL_FULL])
- _to_index = ((routing_component_full_t) rc)->to_index;
-
- else if (modeltype == &routing_models[SURF_MODEL_FLOYD])
- _to_index = ((routing_component_floyd_t) rc)->to_index;
-
- else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
- modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE])
- _to_index = ((routing_component_dijkstra_t) rc)->to_index;
-
- else
- xbt_die("\"generic_set_autonomous_system\" not supported");
+ _to_index = current_routing->to_index;
*id = xbt_dict_length(_to_index);
xbt_dict_set(_to_index, name, id, xbt_free);
}
xbt_dict_t _to_index;
char *route_name;
int *src_id, *dst_id;
+ _to_index = current_routing->to_index;
if (modeltype == &routing_models[SURF_MODEL_FULL]) {
_parse_routes = ((routing_component_full_t) rc)->parse_routes;
- _to_index = ((routing_component_full_t) rc)->to_index;
} else if (modeltype == &routing_models[SURF_MODEL_FLOYD]) {
_parse_routes = ((routing_component_floyd_t) rc)->parse_routes;
- _to_index = ((routing_component_floyd_t) rc)->to_index;
} else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE]) {
_parse_routes = ((routing_component_dijkstra_t) rc)->parse_routes;
- _to_index = ((routing_component_dijkstra_t) rc)->to_index;
} else
xbt_die("\"generic_set_route\" not supported");
xbt_dict_t _to_index;
char *route_name;
int *src_id, *dst_id;
+ _to_index = current_routing->to_index;
if (modeltype == &routing_models[SURF_MODEL_FULL]) {
_parse_routes = ((routing_component_full_t) rc)->parse_routes;
- _to_index = ((routing_component_full_t) rc)->to_index;
} else if (modeltype == &routing_models[SURF_MODEL_FLOYD]) {
_parse_routes = ((routing_component_floyd_t) rc)->parse_routes;
- _to_index = ((routing_component_floyd_t) rc)->to_index;
} else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE]) {
_parse_routes = ((routing_component_dijkstra_t) rc)->parse_routes;
- _to_index = ((routing_component_dijkstra_t) rc)->to_index;
} else
xbt_die("\"generic_set_route\" not supported");