X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fmesh%2Fmesh_tunnel_tree.h;h=e5d65921df0c71a97050c3c0c1ed5b603f681879;hb=1ef7f26b7579ae2a6256751a3f5ebfbf60afbb2f;hp=615a5a8d0dd1a140fc26e6a41d88c5ba0a54b6af;hpb=4649d3d4a4190e27a42d571c7d7ee7e17792dc51;p=oweals%2Fgnunet.git diff --git a/src/mesh/mesh_tunnel_tree.h b/src/mesh/mesh_tunnel_tree.h index 615a5a8d0..e5d65921d 100644 --- a/src/mesh/mesh_tunnel_tree.h +++ b/src/mesh/mesh_tunnel_tree.h @@ -126,14 +126,25 @@ path_destroy (struct MeshPeerPath *p); /******************************************************************************/ /** - * Method called whenever a node has been marked as disconnected. + * Iterator over all children of a node. * * @param cls Closure. - * @param peer_id short ID of peer that is no longer reachable. + * @param peer_id Short ID of the peer. */ typedef void (*MeshTreeCallback) (void *cls, GNUNET_PEER_Id peer_id); +/** + * Iterator over all nodes in a tree. + * + * @param cls Closure. + * @param peer_id Short ID of the peer. + * @param peer_id Short ID of the parent of the peer. + */ +typedef void (*MeshWholeTreeCallback) (void *cls, + GNUNET_PEER_Id peer_id, + GNUNET_PEER_Id parent_id); + /** * Create a new tunnel tree associated to a tunnel * @@ -197,7 +208,7 @@ tree_get_first_hop (struct MeshTunnelTree *t, GNUNET_PEER_Id peer); * Find the given peer in the tree. * * @param tree Tree where to look for the peer. - * @param peer Peer to find. + * @param peer_id Peer to find. * * @return Pointer to the node of the peer. NULL if not found. */ @@ -210,11 +221,35 @@ tree_find_peer (struct MeshTunnelTree *tree, GNUNET_PEER_Id peer_id); * * @param tree Tree to use. Must have "me" set. * @param cb Callback to call over each child. - * @param cls Closure. + * @param cb_cls Closure for @c cb. */ void -tree_iterate_children (struct MeshTunnelTree *tree, MeshTreeCallback cb, - void *cls); +tree_iterate_children (struct MeshTunnelTree *tree, + MeshTreeCallback cb, + void *cb_cls); + + +/** + * Iterate over all nodes in the tree. + * + * @param tree Tree to use.. + * @param cb Callback to call over each child. + * @param cb_cls Closure for @c cb. + * + * TODO: recursive implementation? (s/heap/stack/g) + */ +void +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); /** @@ -302,6 +337,8 @@ tree_notify_connection_broken (struct MeshTunnelTree *t, GNUNET_PEER_Id p1, * If the tree is not local and no longer has any paths, the root node will be * destroyed and marked as NULL. * + * FIXME: dont destroy the root + * * @param t Tunnel tree to use. * @param peer Short ID of the peer to remove from the tunnel tree. * @param cb Callback to notify client of disconnected peers.