- debug
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_channel.h
index a06319c34bee19b59d64464098f290d0fa211bf5..82d85e5bed41583e08edd22f4818f10aa3c702c0 100644 (file)
@@ -41,6 +41,7 @@ extern "C"
 #include "gnunet_util_lib.h"
 
 #include "mesh_protocol_enc.h"
+#include "mesh_enc.h"
 
 /**
  * Struct containing all information regarding a channel to a remote client.
@@ -49,6 +50,7 @@ struct MeshChannel;
 
 
 #include "gnunet-service-mesh_tunnel.h"
+#include "gnunet-service-mesh_local.h"
 
 
 /**
@@ -104,17 +106,6 @@ GMCH_is_origin (struct MeshChannel *ch, int fwd);
 int
 GMCH_is_terminal (struct MeshChannel *ch, int fwd);
 
-/**
- * Send an end-to-end ACK message for the most recent in-sequence payload.
- *
- * If channel is not reliable, do nothing.
- *
- * @param ch Channel this is about.
- * @param fwd Is for FWD traffic? (ACK dest->owner)
- */
-void
-GMCH_send_ack (struct MeshChannel *ch, int fwd);
-
 /**
  * Send data on a channel.
  *
@@ -130,6 +121,17 @@ GMCH_send_data (struct MeshChannel *ch,
                 const struct GNUNET_MESH_Data *msg,
                 int fwd);
 
+/**
+ * Send an end-to-end ACK message for the most recent in-sequence payload.
+ *
+ * If channel is not reliable, do nothing.
+ *
+ * @param ch Channel this is about.
+ * @param fwd Is for FWD traffic? (ACK dest->owner)
+ */
+void
+GMCH_send_data_ack (struct MeshChannel *ch, int fwd);
+
 /**
  * Notify the destination client that a new incoming channel was created.
  *
@@ -138,7 +140,6 @@ GMCH_send_data (struct MeshChannel *ch,
 void
 GMCH_send_create (struct MeshChannel *ch);
 
-
 /**
  * Notify a client that the channel is no longer valid.
  *
@@ -147,7 +148,6 @@ GMCH_send_create (struct MeshChannel *ch);
 void
 GMCH_send_destroy (struct MeshChannel *ch);
 
-
 /**
  * Log channel info.
  *
@@ -156,6 +156,60 @@ GMCH_send_destroy (struct MeshChannel *ch);
 void
 GMCH_debug (struct MeshChannel *ch);
 
+/**
+ * Handle an ACK given by a client.
+ *
+ * Mark client as ready and send him any buffered data we could have for him.
+ *
+ * @param ch Channel.
+ * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by root and go BCK)
+ */
+void
+GMCH_handle_local_ack (struct MeshChannel *ch, int fwd);
+
+/**
+ * Handle data given by a client.
+ *
+ * Check whether the client is allowed to send in this tunnel, save if channel
+ * is reliable and send an ACK to the client if there is still buffer space
+ * in the tunnel.
+ *
+ * @param ch Channel.
+ * @param fwd Is this a FWD data?
+ *
+ * @return GNUNET_OK if everything goes well, GNUNET_SYSERR in case of en error.
+ */
+int
+GMCH_handle_local_data (struct MeshChannel *ch,
+                        struct MeshClient *c,
+                        struct GNUNET_MessageHeader *message,
+                        int fwd);
+
+/**
+ * Handle a channel destroy requested by a client.
+ *
+ * Destroy the channel and the tunnel in case this was the last channel.
+ *
+ * @param ch Channel.
+ * @param c Client that requested the destruction (to avoid notifying him).
+ */
+void
+GMCH_handle_local_destroy (struct MeshChannel *ch,
+                           struct MeshClient *c);
+
+/**
+ * Handle a channel create requested by a client.
+ *
+ * Create the channel and the tunnel in case this was the first0 channel.
+ *
+ * @param c Client that requested the creation (will be the root).
+ * @param msg Create Channel message.
+ *
+ * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise.
+ */
+int
+GMCH_handle_local_create (struct MeshClient *c,
+                          struct GNUNET_MESH_ChannelMessage *msg);
 
 /**
  * Handler for mesh network payload traffic.
@@ -169,7 +223,6 @@ GMCH_handle_data (struct MeshChannel *ch,
                   const struct GNUNET_MESH_Data *msg,
                   int fwd);
 
-
 /**
  * Handler for mesh network traffic end-to-end ACKs.
  *
@@ -182,19 +235,18 @@ GMCH_handle_data_ack (struct MeshChannel *ch,
                       const struct GNUNET_MESH_DataACK *msg,
                       int fwd);
 
-
 /**
  * Handler for channel create messages.
  *
- * @param t Tunnel this channel is to be created in.
+ * @param t Tunnel this channel will be in.
  * @param msg Message.
  * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO;
  */
 struct MeshChannel *
-GMCH_handle_create (const struct GNUNET_MESH_ChannelCreate *msg,
+GMCH_handle_create (struct MeshTunnel3 *t,
+                    const struct GNUNET_MESH_ChannelCreate *msg,
                     int fwd);
 
-
 /**
  * Handler for channel ack messages.
  *
@@ -207,7 +259,6 @@ GMCH_handle_ack (struct MeshChannel *ch,
                  const struct GNUNET_MESH_ChannelManage *msg,
                  int fwd);
 
-
 /**
  * Handler for channel destroy messages.
  *
@@ -220,11 +271,14 @@ GMCH_handle_destroy (struct MeshChannel *ch,
                      const struct GNUNET_MESH_ChannelManage *msg,
                      int fwd);
 
-
-
 /**
- * Sends an already built message on a channel, properly registering
- * all used resources and encrypting the message with the tunnel's key.
+ * Sends an already built message on a channel.
+ *
+ * If the channel is on a loopback tunnel, notifies the appropriate destination
+ * client locally.
+ *
+ * On a normal channel passes the message to the tunnel for encryption and
+ * sending on a connection.
  *
  * @param message Message to send. Function makes a copy of it.
  * @param ch Channel on which this message is transmitted.
@@ -234,6 +288,16 @@ void
 GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
                             struct MeshChannel *ch, int fwd);
 
+/**
+ * Get the static string for identification of the channel.
+ *
+ * @param ch Channel.
+ *
+ * @return Static string with the channel IDs.
+ */
+const char *
+GMCH_2s (const struct MeshChannel *ch);
+
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {