#include "platform.h"
#include "gnunet_util_lib.h"
-#include "gnunet-service-mesh_channel.h"
-
/**
* Struct containing information about a client of the service
*/
struct MeshClient;
+#include "gnunet-service-mesh_channel.h"
+
/******************************************************************************/
/******************************** API ***********************************/
/******************************************************************************/
void
GML_shutdown (void);
+/**
+ * Get a channel from a client.
+ *
+ * @param c Client to check.
+ * @param chid Channel ID, must be local (> 0x800...).
+ *
+ * @return non-NULL if channel exists in the clients lists
+ */
+struct MeshChannel *
+GML_channel_get (struct MeshClient *c, uint32_t chid);
+
+/**
+ * Add a channel to a client
+ *
+ * @param client Client.
+ * @param chid Channel ID.
+ * @param ch Channel.
+ */
+void
+GML_channel_add (struct MeshClient *client,
+ uint32_t chid,
+ struct MeshChannel *ch);
+
+/**
+ * Remove a channel from a client
+ *
+ * @param client Client.
+ * @param chid Channel ID.
+ * @param ch Channel.
+ */
+void
+GML_channel_remove (struct MeshClient *client,
+ uint32_t chid,
+ struct MeshChannel *ch);
+
+/**
+ * Get the tunnel's next free local channel ID.
+ *
+ * @param c Client.
+ *
+ * @return LID of a channel free to use.
+ */
+MESH_ChannelNumber
+GML_get_next_chid (struct MeshClient *c);
+
/**
* Check if client has registered with the service and has not disconnected
*
struct MeshClient *
GML_client_get (struct GNUNET_SERVER_Client *client);
+/**
+ * Find a client that has opened a port
+ *
+ * @param port Port to check.
+ *
+ * @return non-NULL if a client has the port.
+ */
+struct MeshClient *
+GML_client_get_by_port (uint32_t port);
+
/**
* Deletes a tunnel from a client (either owner or destination).
*
* @param c Client whose tunnel to delete.
* @param ch Channel which should be deleted.
+ * @param id Channel ID.
*/
void
-GML_client_delete_channel (struct MeshClient *c, struct MeshChannel *ch);
+GML_client_delete_channel (struct MeshClient *c,
+ struct MeshChannel *ch,
+ MESH_ChannelNumber id);
/**
* Build a local ACK message and send it to a local client, if needed.
*
* If the client was already allowed to send data, do nothing.
*
- * @param ch Channel on which to send the ACK.
* @param c Client to whom send the ACK.
- * @param fwd Set to GNUNET_YES for FWD ACK (dest->root)
+ * @param id Channel ID to use
*/
void
-GML_send_ack (struct MeshChannel *ch, int fwd);
+GML_send_ack (struct MeshClient *c, MESH_ChannelNumber id);
/**
* Notify the appropriate client that a new incoming channel was created.
*
- * @param ch Channel that was created.
+ * @param c Client to notify.
+ * @param id Channel ID.
+ * @param port Channel's destination port.
+ * @param opt Options (bit array).
+ * @param peer Origin peer.
*/
void
GML_send_channel_create (struct MeshClient *c,
uint32_t id, uint32_t port, uint32_t opt,
- struct GNUNET_PeerIdentity *peer);
+ const struct GNUNET_PeerIdentity *peer);
+
+/**
+ * Build a local channel NACK message and send it to a local client.
+ *
+ * @param c Client to whom send the NACK.
+ * @param id Channel ID to use
+ */
+void
+GML_send_channel_nack (struct MeshClient *c, MESH_ChannelNumber id);
/**
* Notify a client that a channel is no longer valid.
GML_send_channel_destroy (struct MeshClient *c, uint32_t id);
/**
- * Modify the mesh message TID from global to local and send to client.
+ * Modify the mesh message ID from global to local and send to client.
*
- * @param ch Channel on which to send the message.
- * @param msg Message to modify and send.
* @param c Client to send to.
- * @param tid Tunnel ID to use (c can be both owner and client).
+ * @param msg Message to modify and send.
+ * @param id Channel ID to use (c can be both owner and client).
*/
void
-GML_send_data (struct MeshChannel *ch,
+GML_send_data (struct MeshClient *c,
const struct GNUNET_MESH_Data *msg,
- struct MeshClient *c, MESH_ChannelNumber id);
+ MESH_ChannelNumber id);
+
+/**
+ * Get the static string to represent a client.
+ *
+ * @param c Client.
+ *
+ * @return Static string for the client.
+ */
+const char *
+GML_2s (const struct MeshClient *c);
#if 0 /* keep Emacsens' auto-indent happy */
/* ifndef GNUNET_MESH_SERVICE_LOCAL_H */
#endif
-/* end of gnunet-mesh-service_LOCAL.h */
\ No newline at end of file
+/* end of gnunet-mesh-service_LOCAL.h */