/* ************************************************************************** */
/* *************** GENERIC BUSINESS METHODS (declarations) ****************** */
-static xbt_dict_t generic_get_onelink_routes (void);
+static xbt_dynar_t generic_get_onelink_routes (routing_component_t rc);
static int generic_is_router (const char *name);
static route_extended_t generic_get_bypassroute(routing_component_t rc, const char* src, const char* dst);
xbt_free(global_routing);
}
-static xbt_dict_t get_onelink_routes(void)
+static xbt_dynar_t recursive_get_onelink_routes (routing_component_t rc)
{
- xbt_die("global \"get_onelink_routes\" function not implemented yet");
+ xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free);
+
+ //adding my one link routes
+ unsigned int cpt;
+ void *link;
+ xbt_dynar_t onelink_mine = rc->get_onelink_routes (rc);
+ if (onelink_mine){
+ xbt_dynar_foreach(onelink_mine, cpt, link) {
+ xbt_dynar_push(ret,&link);
+ }
+ }
+
+ //recursing
+ char *key;
+ xbt_dict_cursor_t cursor=NULL;
+ routing_component_t rc_child;
+ xbt_dict_foreach(rc->routing_sons, cursor, key, rc_child) {
+ xbt_dynar_t onelink_child = recursive_get_onelink_routes (rc_child);//->get_onelink_routes (rc_child);
+ if (onelink_child){
+ xbt_dynar_foreach(onelink_child, cpt, link) {
+ xbt_dynar_push(ret,&link);
+ }
+ }
+ }
+ return ret;
+}
+
+static xbt_dynar_t get_onelink_routes(void)
+{
+ return recursive_get_onelink_routes (global_routing->root);
}
static int is_router(const char *name)
} s_routing_component_full_t,*routing_component_full_t;
/* Business methods */
-static xbt_dict_t full_get_onelink_routes(void)
+static xbt_dynar_t full_get_onelink_routes(routing_component_t rc)
{
- xbt_die("\"full_get_onelink_routes\" function not implemented yet");
+ 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);
+ 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_assert2(src_id && dst_id, "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",src,dst);
+ route_extended_t route = TO_ROUTE_FULL(*src_id,*dst_id);
+ if (route){
+ if (xbt_dynar_length(route->generic_route.link_list) == 1){
+ void *link = *(void**)xbt_dynar_get_ptr(route->generic_route.link_list,0);
+
+ onelink_t onelink = xbt_new0 (s_onelink_t, 1);
+ onelink->src = xbt_strdup (k1);
+ onelink->dst = xbt_strdup (k2);
+ onelink->link_ptr = link;
+ xbt_dynar_push (ret, &onelink);
+ }
+ }
+ }
+ }
+ return ret;
}
static int full_is_router(const char *name)
} s_routing_component_floyd_t,*routing_component_floyd_t;
/* Business methods */
-static xbt_dict_t floyd_get_onelink_routes(void)
+static xbt_dynar_t floyd_get_onelink_routes(routing_component_t rc)
{
xbt_die("\"floyd_get_onelink_routes\" function not implemented yet");
}
}
/* Business methods */
-static xbt_dict_t dijkstra_get_onelink_routes(void)
+static xbt_dynar_t dijkstra_get_onelink_routes(routing_component_t rc)
{
xbt_die("\"dijkstra_get_onelink_routes\" function not implemented yet");
}
return xbt_strdup(result_result);
}
-static xbt_dict_t rulebased_get_onelink_routes(void)
+static xbt_dynar_t rulebased_get_onelink_routes(routing_component_t rc)
{
xbt_die("\"rulebased_get_onelink_routes\" function not implemented yet");
}
} s_routing_component_none_t,*routing_component_none_t;
/* Business methods */
-static xbt_dict_t none_get_onelink_routes(void){
+static xbt_dynar_t none_get_onelink_routes(routing_component_t rc){
return NULL;
}
static int none_is_router(const char *name){
/* ************************************************************************** */
/* *********************** GENERIC BUSINESS METHODS ************************* */
-static xbt_dict_t generic_get_onelink_routes (void)
+static xbt_dynar_t generic_get_onelink_routes (routing_component_t rc)
{
xbt_die("\"generic_get_onelink_routes\" not implemented yet");
}