From 74214a6669ee21beba3e799a78b95f4e56c3b692 Mon Sep 17 00:00:00 2001 From: schnorr Date: Mon, 4 Oct 2010 15:55:54 +0000 Subject: [PATCH] implementing recursive call to get_onelink_routes git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8346 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/surf/surf_routing.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 7334b26168..a0b74ee2ae 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -677,9 +677,38 @@ static void finalize(void) { xbt_free(global_routing); } +static xbt_dynar_t recursive_get_onelink_routes (routing_component_t rc) +{ + 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) { - xbt_die("global \"get_onelink_routes\" function not implemented yet"); + return recursive_get_onelink_routes (global_routing->root); } static int is_router(const char *name) -- 2.20.1