- debug
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_peer.h
index 4cd108b3095d9838dbb16088df089d36d55fdf68..7cc48fb663f948fabb991910c77773e2e49d0a4b 100644 (file)
@@ -45,20 +45,23 @@ extern "C"
  */
 struct MeshPeer;
 
+#include "gnunet-service-mesh_connection.h"
+
 /**
  * Callback called when a queued message is sent.
  *
  * @param cls Closure.
  * @param c Connection this message was on.
+ * @param type Type of message sent.
+ * @param fwd Was this a FWD going message?
+ * @param size Size of the message.
  * @param wait Time spent waiting for core (only the time for THIS message)
  */
 typedef void (*GMP_sent) (void *cls,
-                          struct MeshConnection *c,
+                          struct MeshConnection *c, uint16_t type,
+                          int fwd, size_t size,
                           struct GNUNET_TIME_Relative wait);
 
-#include "gnunet-service-mesh_connection.h"
-
-
 /******************************************************************************/
 /********************************    API    ***********************************/
 /******************************************************************************/
@@ -101,9 +104,20 @@ GMP_get (const struct GNUNET_PeerIdentity *peer_id);
 struct MeshPeer *
 GMP_get_short (const GNUNET_PEER_Id peer);
 
+/**
+ * Try to establish a new connection to this peer (in its tunnel).
+ * If the peer doesn't have any path to it yet, try to get one.
+ * If the peer already has some path, send a CREATE CONNECTION towards it.
+ *
+ * @param peer Peer to connect to.
+ */
+void
+GMP_connect (struct MeshPeer *peer);
+
 /**
  * @brief Queue and pass message to core when possible.
  *
+ * @param peer Peer towards which to queue the message.
  * @param cls Closure (@c type dependant). It will be used by queue_send to
  *            build the message to be sent if not already prebuilt.
  * @param type Type of the message, 0 for a raw message.
@@ -111,15 +125,13 @@ GMP_get_short (const GNUNET_PEER_Id peer);
  * @param c Connection this message belongs to (cannot be NULL).
  * @param ch Channel this message belongs to, if applicable (otherwise NULL).
  * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
- * @param callback Function to be called once CORE has taken the message.
- * @param callback_cls Closure for @c callback.
+ * @param cont Continuation to be called once CORE has taken the message.
+ * @param cont_cls Closure for @c cont.
  */
 void
-GMP_queue_add (void *cls, uint16_t type, size_t size,
-               struct MeshConnection *c,
-               struct MeshChannel *ch,
-               int fwd,
-               GMP_sent callback, void *callback_cls);
+GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, size_t size,
+               struct MeshConnection *c, struct MeshChannel *ch, int fwd,
+               GMP_sent cont, void *cont_cls);
 
 /**
  * Cancel all queued messages to a peer that belong to a certain connection.
@@ -175,7 +187,7 @@ GMP_add_tunnel (struct MeshPeer *peer);
  * @return GNUNET_OK on success.
  */
 int
-GMP_add_connection (struct MeshPeer *peer, const struct MeshConnection *c);
+GMP_add_connection (struct MeshPeer *peer, struct MeshConnection *c);
 
 /**
  * Add the path to the peer and update the path used to reach it in case this
@@ -212,7 +224,7 @@ GMP_add_path_to_origin (struct MeshPeer *peer_info,
  * @param confirmed Whether we know if the path works or not.
  */
 void
-GMP_add_path_to_all (struct MeshPeerPath *p, int confirmed);
+GMP_add_path_to_all (const struct MeshPeerPath *p, int confirmed);
 
 /**
  * Remove a connection from a neighboring peer.
@@ -223,11 +235,23 @@ GMP_add_path_to_all (struct MeshPeerPath *p, int confirmed);
  * @return GNUNET_OK on success.
  */
 int
-GMP_remove_connection (struct MeshPeer *peer, struct MeshConnection *c);
+GMP_remove_connection (struct MeshPeer *peer, const struct MeshConnection *c);
 
+/**
+ * Start the DHT search for new paths towards the peer: we don't have
+ * enough good connections.
+ *
+ * @param peer Destination peer.
+ */
 void
 GMP_start_search (struct MeshPeer *peer);
 
+/**
+ * Stop the DHT search for new paths towards the peer: we already have
+ * enough good connections.
+ *
+ * @param peer Destination peer.
+ */
 void
 GMP_stop_search (struct MeshPeer *peer);
 
@@ -238,7 +262,7 @@ GMP_stop_search (struct MeshPeer *peer);
  *
  * @return Full ID of peer.
  */
-struct GNUNET_PeerIdentity *
+const struct GNUNET_PeerIdentity *
 GMP_get_id (const struct MeshPeer *peer);
 
 /**
@@ -251,6 +275,16 @@ GMP_get_id (const struct MeshPeer *peer);
 GNUNET_PEER_Id
 GMP_get_short_id (const struct MeshPeer *peer);
 
+/**
+ * Get the tunnel towards a peer.
+ *
+ * @param peer Peer to get from.
+ *
+ * @return Tunnel towards peer.
+ */
+struct MeshTunnel3 *
+GMP_get_tunnel (const struct MeshPeer *peer);
+
 /**
  * Get the static string for a peer ID.
  *