- doxygen
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_tunnel.h
index dfddae4d17a5caf13b4f1a18e31782aab2fb4b5f..369713e660a86d5856c94d6403ede42e4cf60f97 100644 (file)
@@ -48,27 +48,27 @@ enum MeshTunnel3State
     /**
      * Uninitialized status, should never appear in operation.
      */
-  MESH_TUNNEL_NEW,
+  MESH_TUNNEL3_NEW,
 
     /**
      * Path to the peer not known yet
      */
-  MESH_TUNNEL_SEARCHING,
+  MESH_TUNNEL3_SEARCHING,
 
     /**
      * Request sent, not yet answered.
      */
-  MESH_TUNNEL_WAITING,
+  MESH_TUNNEL3_WAITING,
 
     /**
      * Peer connected and ready to accept data
      */
-  MESH_TUNNEL_READY,
+  MESH_TUNNEL3_READY,
 
     /**
      * Peer connected previosly but not responding
      */
-  MESH_TUNNEL_RECONNECTING
+  MESH_TUNNEL3_RECONNECTING
 };
 
 /**
@@ -79,6 +79,7 @@ struct MeshTunnel3;
 
 #include "gnunet-service-mesh_channel.h"
 #include "gnunet-service-mesh_connection.h"
+#include "gnunet-service-mesh_peer.h"
 
 
 /******************************************************************************/
@@ -89,13 +90,11 @@ struct MeshTunnel3;
  * Initialize tunnel subsystem.
  *
  * @param c Configuration handle.
- * @param id Peer identity.
  * @param key ECC private key, to derive all other keys and do crypto.
  */
 void
 GMT_init (const struct GNUNET_CONFIGURATION_Handle *c,
-          const struct GNUNET_PeerIdentity *id,
-          const struct GNUNET_CRYPTO_EccPrivateKey *key);
+          const struct GNUNET_CRYPTO_EddsaPrivateKey *key);
 
 /**
  * Shut down the tunnel subsystem.
@@ -103,6 +102,14 @@ GMT_init (const struct GNUNET_CONFIGURATION_Handle *c,
 void
 GMT_shutdown (void);
 
+/**
+ * Create a tunnel.
+ *
+ * @param destination Peer this tunnel is towards.
+ */
+struct MeshTunnel3 *
+GMT_new (struct MeshPeer *destination);
+
 /**
  * Tunnel is empty: destroy it.
  *
@@ -191,6 +198,19 @@ GMT_remove_channel (struct MeshTunnel3 *t, struct MeshChannel *ch);
 struct MeshChannel *
 GMT_get_channel (struct MeshTunnel3 *t, MESH_ChannelNumber chid);
 
+/**
+ * Decrypt and demultiplex by message type. Call appropriate handler
+ * for a message
+ * towards a channel of a local tunnel.
+ *
+ * @param t Tunnel this message came on.
+ * @param msg Message header.
+ * @param fwd Is this message fwd?
+ */
+void
+GMT_handle_encrypted (struct MeshTunnel3 *t,
+                      const struct GNUNET_MESH_Encrypted *msg,
+                      int fwd);
 
 /**
  * Cache a message to be sent once tunnel is online.
@@ -215,6 +235,19 @@ GMT_queue_data (struct MeshTunnel3 *t,
 void
 GMT_send_queued_data (struct MeshTunnel3 *t, int fwd);
 
+/**
+ * @brief Use the given path for the tunnel.
+ * Update the next and prev hops (and RCs).
+ * (Re)start the path refresh in case the tunnel is locally owned.
+ *
+ * @param t Tunnel to update.
+ * @param p Path to use.
+ *
+ * @return Connection created.
+ */
+struct MeshConnection *
+GMT_use_path (struct MeshTunnel3 *t, struct MeshPeerPath *p);
+
 /**
  * Count established (ready) connections of a tunnel.
  *
@@ -247,6 +280,8 @@ GMT_get_state (struct MeshTunnel3 *t);
 
 /**
  * Get the total buffer space for a tunnel.
+ * 
+ * FIXME get a ch parameter in case of loopback tunnels
  *
  * @param t Tunnel.
  * @param fwd Is this for FWD traffic?
@@ -276,6 +311,26 @@ GMT_get_destination (struct MeshTunnel3 *t);
 MESH_ChannelNumber
 GMT_get_next_chid (struct MeshTunnel3 *t);
 
+/**
+ * Send ACK on one or more channels due to buffer in connections..
+ *
+ * @param t Channel which has some free buffer space.
+ * @param fwd Is this for FWD traffic? (ACK goes to root)
+ */
+void
+GMT_unchoke_channels (struct MeshTunnel3 *t, int fwd);
+
+/**
+ * Send ACK on one or more connections due to buffer space to the client.
+ *
+ * Iterates all connections of the tunnel and sends ACKs appropriately.
+ *
+ * @param ch Channel which has some free buffer space.
+ * @param fwd Is this in for FWD traffic? (ACK goes dest->root)
+ */
+void
+GMT_send_acks (struct MeshTunnel3 *t, int fwd);
+
 /**
  * Sends an already built message on a tunnel, encrypting it and
  * choosing the best connection.
@@ -301,6 +356,29 @@ GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
 int
 GMT_is_loopback (const struct MeshTunnel3 *t);
 
+/**
+ * Is the tunnel using this path already?
+ *
+ * @param t Tunnel.
+ * @param p Path.
+ *
+ * @return GNUNET_YES a connection uses this path.
+ */
+int
+GMT_is_path_used (const struct MeshTunnel3 *t, const struct MeshPeerPath *p);
+
+/**
+ * Get a cost of a path for a tunnel considering existing connections.
+ *
+ * @param t Tunnel.
+ * @param path Candidate path.
+ *
+ * @return Cost of the path (path length + number of overlapping nodes)
+ */
+unsigned int
+GMT_get_path_cost (const struct MeshTunnel3 *t,
+                   const struct MeshPeerPath *path);
+
 /**
  * Get the static string for the peer this tunnel is directed.
  *