From 1732a8b82b81649ec917b8574d4827120dba0320 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Mon, 10 Dec 2012 17:44:05 +0000 Subject: [PATCH] - add children count api call --- src/mesh/mesh_tunnel_tree.c | 28 ++++++++++++++++++++++++++++ src/mesh/mesh_tunnel_tree.h | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c index a881f7107..b2cc2d9a7 100644 --- a/src/mesh/mesh_tunnel_tree.c +++ b/src/mesh/mesh_tunnel_tree.c @@ -671,6 +671,34 @@ tree_iterate_all (struct MeshTunnelTree *tree, } +/** + * Iterator to count the children in a tree. + */ +static void +count_children_cb (void *cls, GNUNET_PEER_Id peer) +{ + unsigned int *i = cls; + + (*i)++; +} + + +/** + * Count how many children does the local node have in the tree. + * + * @param tree Tree to use. Must have "me" set. + */ +unsigned int +tree_count_children (struct MeshTunnelTree *tree) +{ + unsigned int i; + + i = 0; + tree_iterate_children(tree, &count_children_cb, &i); + return i; +} + + /** * Recusively update the info about what is the first hop to reach the node * diff --git a/src/mesh/mesh_tunnel_tree.h b/src/mesh/mesh_tunnel_tree.h index b1d89d6ff..94dcf13bf 100644 --- a/src/mesh/mesh_tunnel_tree.h +++ b/src/mesh/mesh_tunnel_tree.h @@ -243,6 +243,14 @@ tree_iterate_all (struct MeshTunnelTree *tree, MeshWholeTreeCallback cb, void *cb_cls); +/** + * Count how many children does the local node have in the tree. + * + * @param tree Tree to use. Must have "me" set. + */ +unsigned int +tree_count_children (struct MeshTunnelTree *tree); + /** * Recusively update the info about what is the first hop to reach the node -- 2.25.1