- leaks
[oweals/gnunet.git] / src / mesh / mesh_tunnel_tree.h
index e946259dab1a13f8b89aff0f831c29fb0490b50c..84fd0acb22521e07cbe6f03671970274e697e354 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,61 +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);
 
 
 /**
- * Find the first peer whom to send a packet to go down this path
+ * Get the length of a path.
  *
- * @param t The tunnel tree to use
- * @param peer The peerinfo of the peer we are trying to reach
+ * @param path The path to measure, with the local peer at any point of it.
  *
- * @return peerinfo of the peer who is the first hop in the tunnel
- *         NULL on error
- */
-struct GNUNET_PeerIdentity *
-path_get_first_hop (struct MeshTunnelTree *t,
-                    GNUNET_PEER_Id peer);
-
-
-/**
- * Get the length of a path
- *
- * @param p 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);
-
-
-/**
- * Get the cost of the path relative to the already built tunnel tree
- *
- * @param t The tunnel tree to which compare
- * @param path The individual path to reach a peer
- *
- * @return Number of hops to reach destination, UINT_MAX in case the peer is not
- * in the path
- */
-unsigned int
-path_get_cost (struct MeshTunnelTree *t,
-               struct MeshPeerPath *path);
+path_get_length (struct MeshPeerPath *path);
 
 
 /**
@@ -159,8 +131,7 @@ path_destroy (struct MeshPeerPath *p);
  * @param cls Closure.
  * @param peer_id short ID of peer that is no longer reachable.
  */
-typedef void (*MeshTreeCallback) (void *cls,
-                                  GNUNET_PEER_Id peer_id);
+typedef void (*MeshTreeCallback) (void *cls, GNUNET_PEER_Id peer_id);
 
 
 /**
@@ -174,36 +145,15 @@ struct MeshTunnelTree *
 tree_new (GNUNET_PEER_Id peer);
 
 
-/**
- * Set own identity in the tree
- *
- * @param tree Tree.
- * @param peer A short peer id of local peer.
- */
-void
-tree_set_me (struct MeshTunnelTree *tree, GNUNET_PEER_Id peer);
-
-
-/**
- * Get the id of the local id of the tree.
- *
- * @param tree Tree whose local id we want to now.
- *
- * @return Short peer id of local peer.
- */
-GNUNET_PEER_Id
-tree_get_me (struct MeshTunnelTree *tree);
-
-
 /**
  * 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,
+tree_set_status (struct MeshTunnelTree *tree, GNUNET_PEER_Id peer,
                  enum MeshPeerState status);
 
 
@@ -211,6 +161,7 @@ tree_set_status (struct MeshTunnelTree *tree,
  * 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.
  */
@@ -229,11 +180,24 @@ GNUNET_PEER_Id
 tree_get_predecessor (struct MeshTunnelTree *tree);
 
 
+/**
+ * Find the first peer whom to send a packet to go down this path
+ *
+ * @param t The tunnel tree to use
+ * @param peer The peerinfo of the peer we are trying to reach
+ *
+ * @return peerinfo of the peer who is the first hop in the tunnel
+ *         NULL on error
+ */
+struct GNUNET_PeerIdentity *
+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.
  */
@@ -243,14 +207,13 @@ tree_find_peer (struct MeshTunnelTree *tree, GNUNET_PEER_Id peer_id);
 
 /**
  * Iterate over all children of the local node.
- * 
+ *
  * @param tree Tree to use. Must have "me" set.
  * @param cb Callback to call over each child.
  * @param cls Closure.
  */
 void
-tree_iterate_children (struct MeshTunnelTree *tree,
-                       MeshTreeCallback cb,
+tree_iterate_children (struct MeshTunnelTree *tree, MeshTreeCallback cb,
                        void *cls);
 
 
@@ -263,8 +226,7 @@ tree_iterate_children (struct MeshTunnelTree *tree,
  *            If not known, NULL to find out and pass on children.
  */
 void
-tree_update_first_hops (struct MeshTunnelTree *tree,
-                        GNUNET_PEER_Id parent_id,
+tree_update_first_hops (struct MeshTunnelTree *tree, GNUNET_PEER_Id parent_id,
                         struct GNUNET_PeerIdentity *hop);
 
 /**
@@ -273,7 +235,7 @@ tree_update_first_hops (struct MeshTunnelTree *tree,
  * 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.
@@ -282,10 +244,8 @@ tree_update_first_hops (struct MeshTunnelTree *tree,
  *         NULL when not found
  */
 struct MeshTunnelTreeNode *
-tree_del_path (struct MeshTunnelTree *t,
-               GNUNET_PEER_Id peer,
-               MeshTreeCallback cb,
-               void *cbcls);
+tree_del_path (struct MeshTunnelTree *t, GNUNET_PEER_Id peer_id,
+               MeshTreeCallback cb, void *cbcls);
 
 
 /**
@@ -299,8 +259,7 @@ tree_del_path (struct MeshTunnelTree *t,
  *         Path must be destroyed afterwards.
  */
 struct MeshPeerPath *
-tree_get_path_to_peer(struct MeshTunnelTree *t,
-                      GNUNET_PEER_Id peer);
+tree_get_path_to_peer (struct MeshTunnelTree *t, GNUNET_PEER_Id peer);
 
 
 /**
@@ -315,10 +274,8 @@ tree_get_path_to_peer(struct MeshTunnelTree *t,
  *         GNUNET_SYSERR in case of error.
  */
 int
-tree_add_path (struct MeshTunnelTree *t,
-               const struct MeshPeerPath *p,
-               MeshTreeCallback cb,
-               void *cbcls);
+tree_add_path (struct MeshTunnelTree *t, const struct MeshPeerPath *p,
+               MeshTreeCallback cb, void *cbcls);
 
 
 /**
@@ -334,10 +291,8 @@ tree_add_path (struct MeshTunnelTree *t,
  * @return Short ID of the first disconnected peer in the tree.
  */
 GNUNET_PEER_Id
-tree_notify_connection_broken (struct MeshTunnelTree *t,
-                               GNUNET_PEER_Id p1,
-                               GNUNET_PEER_Id p2,
-                               MeshTreeCallback cb,
+tree_notify_connection_broken (struct MeshTunnelTree *t, GNUNET_PEER_Id p1,
+                               GNUNET_PEER_Id p2, MeshTreeCallback cb,
                                void *cbcls);
 
 
@@ -355,10 +310,22 @@ tree_notify_connection_broken (struct MeshTunnelTree *t,
  * @return GNUNET_YES if the tunnel still has nodes
  */
 int
-tree_del_peer (struct MeshTunnelTree *t,
-               GNUNET_PEER_Id peer,
-               MeshTreeCallback cb,
-               void *cbcls);
+tree_del_peer (struct MeshTunnelTree *t, GNUNET_PEER_Id peer,
+               MeshTreeCallback cb, void *cbcls);
+
+
+/**
+ * Get the cost of the path relative to the already built tunnel tree
+ *
+ * @param t The tunnel tree to which compare
+ * @param path The individual path to reach a peer
+ *
+ * @return Number of hops to reach destination, UINT_MAX in case the peer is not
+ * in the path
+ */
+unsigned int
+tree_get_path_cost (struct MeshTunnelTree *t, struct MeshPeerPath *path);
+
 
 /**
  * Print the tree on stderr
@@ -366,7 +333,7 @@ tree_del_peer (struct MeshTunnelTree *t,
  * @param t The tree
  */
 void
-tree_debug(struct MeshTunnelTree *t);
+tree_debug (struct MeshTunnelTree *t);
 
 
 /**