- doxygen
[oweals/gnunet.git] / src / mesh / mesh_tunnel_tree.h
index dd31661ac40f2aea350c29e49f131366773d5eda..e5d65921df0c71a97050c3c0c1ed5b603f681879 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file mesh/mesh_tree_tree.h
+ * @file mesh/mesh_tunnel_tree.h
  * @brief Tunnel tree handling functions
  * @author Bartlomiej Polot
  */
@@ -72,9 +72,9 @@ struct MeshTunnelTree;
 /******************************************************************************/
 
 /**
- * Create a new path
+ * Create a new path.
  *
- * @param lenght How many hops will the path have.
+ * @param length How many hops will the path have.
  *
  * @return A newly allocated path with a peer array of the specified length.
  */
@@ -83,33 +83,33 @@ path_new (unsigned int length);
 
 
 /**
- * Invert the path
+ * Invert the path.
  *
- * @param p the path to invert
+ * @param path The path to invert.
  */
 void
-path_invert (struct MeshPeerPath *p);
+path_invert (struct MeshPeerPath *path);
 
 
 /**
  * Duplicate a path, incrementing short peer's rc.
  *
- * @param p The path to duplicate.
+ * @param path The path to duplicate.
  */
 struct MeshPeerPath *
 path_duplicate (struct MeshPeerPath *path);
 
 
 /**
- * Get the length of a path
+ * Get the length of a path.
  *
- * @param p The path to measure, with the local peer at any point of it
+ * @param path The path to measure, with the local peer at any point of it.
  *
- * @return Number of hops to reach destination
- *         UINT_MAX in case the peer is not in the path
+ * @return Number of hops to reach destination.
+ *         UINT_MAX in case the peer is not in the path.
  */
 unsigned int
-path_get_length (struct MeshPeerPath *p);
+path_get_length (struct MeshPeerPath *path);
 
 
 /**
@@ -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
  *
@@ -149,7 +160,8 @@ tree_new (GNUNET_PEER_Id peer);
  * Set the status of a node.
  *
  * @param tree Tree.
- * @param peer A short peer id of local peer.
+ * @param peer A short peer id of the node.
+ * @param status New status to set.
  */
 void
 tree_set_status (struct MeshTunnelTree *tree, GNUNET_PEER_Id peer,
@@ -160,6 +172,7 @@ tree_set_status (struct MeshTunnelTree *tree, GNUNET_PEER_Id peer,
  * Get the status of a node.
  *
  * @param tree Tree whose local id we want to now.
+ * @param peer A short peer id of the node.
  *
  * @return Short peer id of local peer.
  */
@@ -195,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.
  */
@@ -208,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);
 
 
 /**
@@ -233,7 +270,7 @@ tree_update_first_hops (struct MeshTunnelTree *tree, GNUNET_PEER_Id parent_id,
  * a new path to it or destroy it explicitly, taking care of it's child nodes.
  *
  * @param t Tunnel tree where to delete the path from.
- * @param peer Destination peer whose path we want to remove.
+ * @param peer_id Short ID of the destination peer whose path we want to remove.
  * @param cb Callback to use to notify about which peers are going to be
  *           disconnected.
  * @param cbcls Closure for cb.
@@ -242,7 +279,7 @@ tree_update_first_hops (struct MeshTunnelTree *tree, GNUNET_PEER_Id parent_id,
  *         NULL when not found
  */
 struct MeshTunnelTreeNode *
-tree_del_path (struct MeshTunnelTree *t, GNUNET_PEER_Id peer,
+tree_del_path (struct MeshTunnelTree *t, GNUNET_PEER_Id peer_id,
                MeshTreeCallback cb, void *cbcls);
 
 
@@ -300,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.