#include "gnunet-service-mesh_channel.h"
#include "gnunet-service-mesh_connection.h"
+#include "gnunet-service-mesh_peer.h"
/******************************************************************************/
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.
*
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 msgh 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.
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.
*
MESH_ChannelNumber
GMT_get_next_chid (struct MeshTunnel3 *t);
+/**
+ * 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, unsigned int buffer, int fwd);
+
/**
* Sends an already built message on a tunnel, encrypting it and
* choosing the best connection.
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.
*