X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fmesh%2Fgnunet-service-mesh_tunnel.h;h=369713e660a86d5856c94d6403ede42e4cf60f97;hb=1ef7f26b7579ae2a6256751a3f5ebfbf60afbb2f;hp=b80f7dff151dbf42ab1def1909f9e78644a1e546;hpb=9351b1e9bdf2b067b6db06562c26ba658cff42b8;p=oweals%2Fgnunet.git diff --git a/src/mesh/gnunet-service-mesh_tunnel.h b/src/mesh/gnunet-service-mesh_tunnel.h index b80f7dff1..369713e66 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.h +++ b/src/mesh/gnunet-service-mesh_tunnel.h @@ -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,12 +90,10 @@ 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_EddsaPrivateKey *key); /** @@ -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. *