- fix makefile
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_channel.h
index c6e051356a5d7504cc6f00acf878b0bd1c3c0c07..f5a89a4233016e7b48e8000c25beb1c9faea737b 100644 (file)
 */
 
 /**
- * @file mesh/gnunet-service-mesh_channel.h
- * @brief mesh service; dealing with end-to-end channels
+ * @file cadet/gnunet-service-cadet_channel.h
+ * @brief cadet service; dealing with end-to-end channels
  * @author Bartlomiej Polot
  *
- * All functions in this file should use the prefix GMCH (Gnunet Mesh CHannel)
+ * All functions in this file should use the prefix GMCH (Gnunet Cadet CHannel)
  */
 
-#ifndef GNUNET_SERVICE_MESH_CHANNEL_H
-#define GNUNET_SERVICE_MESH_CHANNEL_H
+#ifndef GNUNET_SERVICE_CADET_CHANNEL_H
+#define GNUNET_SERVICE_CADET_CHANNEL_H
 
 #ifdef __cplusplus
 extern "C"
@@ -40,28 +40,37 @@ extern "C"
 #include "platform.h"
 #include "gnunet_util_lib.h"
 
-#include "mesh_protocol.h"
-#include "mesh.h"
+#include "cadet_protocol.h"
+#include "cadet.h"
 
 /**
  * Struct containing all information regarding a channel to a remote client.
  */
-struct MeshChannel;
+struct CadetChannel;
 
 
-#include "gnunet-service-mesh_tunnel.h"
-#include "gnunet-service-mesh_local.h"
+#include "gnunet-service-cadet_tunnel.h"
+#include "gnunet-service-cadet_local.h"
 
 
 /**
- * Get channel ID.
+ * Destroy a channel and free all resources.
+ *
+ * @param ch Channel to destroy.
+ */
+void
+GMCH_destroy (struct CadetChannel *ch);
+
+
+/**
+ * Get the channel's public ID.
  *
  * @param ch Channel.
  *
- * @return ID
+ * @return ID used to identify the channel with the remote peer.
  */
-MESH_ChannelNumber
-GMCH_get_id (const struct MeshChannel *ch);
+CADET_ChannelNumber
+GMCH_get_id (const struct CadetChannel *ch);
 
 /**
  * Get the channel tunnel.
@@ -70,8 +79,8 @@ GMCH_get_id (const struct MeshChannel *ch);
  *
  * @return tunnel of the channel.
  */
-struct MeshTunnel3 *
-GMCH_get_tunnel (const struct MeshChannel *ch);
+struct CadetTunnel3 *
+GMCH_get_tunnel (const struct CadetChannel *ch);
 
 /**
  * Get free buffer space towards the client on a specific channel.
@@ -82,7 +91,7 @@ GMCH_get_tunnel (const struct MeshChannel *ch);
  * @return Free buffer space [0 - 64]
  */
 unsigned int
-GMCH_get_buffer (struct MeshChannel *ch, int fwd);
+GMCH_get_buffer (struct CadetChannel *ch, int fwd);
 
 
 /**
@@ -94,7 +103,7 @@ GMCH_get_buffer (struct MeshChannel *ch, int fwd);
  * @return #GNUNET_YES if client is allowed to send us data.
  */
 int
-GMCH_get_allowed (struct MeshChannel *ch, int fwd);
+GMCH_get_allowed (struct CadetChannel *ch, int fwd);
 
 
 /**
@@ -106,7 +115,7 @@ GMCH_get_allowed (struct MeshChannel *ch, int fwd);
  * @return #GNUNET_YES in case it is.
  */
 int
-GMCH_is_origin (struct MeshChannel *ch, int fwd);
+GMCH_is_origin (struct CadetChannel *ch, int fwd);
 
 /**
  * Is the destination client for this channel on this peer?
@@ -117,22 +126,7 @@ GMCH_is_origin (struct MeshChannel *ch, int fwd);
  * @return #GNUNET_YES in case it is.
  */
 int
-GMCH_is_terminal (struct MeshChannel *ch, int fwd);
-
-/**
- * Send data on a channel.
- *
- * If the destination is local, send it to client, otherwise encrypt and
- * send to next hop.
- *
- * @param ch Channel
- * @param msg Message.
- * @param fwd Is this a fwd (root->dest) message?
- */
-void
-GMCH_send_data (struct MeshChannel *ch,
-                const struct GNUNET_MESH_Data *msg,
-                int fwd);
+GMCH_is_terminal (struct CadetChannel *ch, int fwd);
 
 /**
  * Send an end-to-end ACK message for the most recent in-sequence payload.
@@ -143,7 +137,7 @@ GMCH_send_data (struct MeshChannel *ch,
  * @param fwd Is for FWD traffic? (ACK dest->owner)
  */
 void
-GMCH_send_data_ack (struct MeshChannel *ch, int fwd);
+GMCH_send_data_ack (struct CadetChannel *ch, int fwd);
 
 /**
  * Notify the destination client that a new incoming channel was created.
@@ -151,15 +145,7 @@ GMCH_send_data_ack (struct MeshChannel *ch, int fwd);
  * @param ch Channel that was created.
  */
 void
-GMCH_send_create (struct MeshChannel *ch);
-
-/**
- * Notify a client that the channel is no longer valid.
- *
- * @param ch Channel that is destroyed.
- */
-void
-GMCH_send_destroy (struct MeshChannel *ch);
+GMCH_send_create (struct CadetChannel *ch);
 
 /**
  * Allow a client to send us more data, in case it was choked.
@@ -168,7 +154,7 @@ GMCH_send_destroy (struct MeshChannel *ch);
  * @param fwd Is this about FWD traffic? (Root client).
  */
 void
-GMCH_allow_client (struct MeshChannel *ch, int fwd);
+GMCH_allow_client (struct CadetChannel *ch, int fwd);
 
 /**
  * Log channel info.
@@ -176,7 +162,7 @@ GMCH_allow_client (struct MeshChannel *ch, int fwd);
  * @param ch Channel.
  */
 void
-GMCH_debug (struct MeshChannel *ch);
+GMCH_debug (struct CadetChannel *ch);
 
 /**
  * Handle an ACK given by a client.
@@ -187,7 +173,7 @@ GMCH_debug (struct MeshChannel *ch);
  * @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);
+GMCH_handle_local_ack (struct CadetChannel *ch, int fwd);
 
 /**
  * Handle data given by a client.
@@ -204,8 +190,8 @@ GMCH_handle_local_ack (struct MeshChannel *ch, int fwd);
  * @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,
+GMCH_handle_local_data (struct CadetChannel *ch,
+                        struct CadetClient *c,
                         struct GNUNET_MessageHeader *message,
                         int fwd);
 
@@ -216,10 +202,12 @@ GMCH_handle_local_data (struct MeshChannel *ch,
  *
  * @param ch Channel.
  * @param c Client that requested the destruction (to avoid notifying him).
+ * @param is_root Is the request coming from root?
  */
 void
-GMCH_handle_local_destroy (struct MeshChannel *ch,
-                           struct MeshClient *c);
+GMCH_handle_local_destroy (struct CadetChannel *ch,
+                           struct CadetClient *c,
+                           int is_root);
 
 /**
  * Handle a channel create requested by a client.
@@ -232,11 +220,11 @@ GMCH_handle_local_destroy (struct MeshChannel *ch,
  * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise.
  */
 int
-GMCH_handle_local_create (struct MeshClient *c,
-                          struct GNUNET_MESH_ChannelMessage *msg);
+GMCH_handle_local_create (struct CadetClient *c,
+                          struct GNUNET_CADET_ChannelMessage *msg);
 
 /**
- * Handler for mesh network payload traffic.
+ * Handler for cadet network payload traffic.
  *
  * @param ch Channel for the message.
  * @param msg Unencryted data message.
@@ -246,12 +234,12 @@ GMCH_handle_local_create (struct MeshClient *c,
  *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
-GMCH_handle_data (struct MeshChannel *ch,
-                  const struct GNUNET_MESH_Data *msg,
+GMCH_handle_data (struct CadetChannel *ch,
+                  const struct GNUNET_CADET_Data *msg,
                   int fwd);
 
 /**
- * Handler for mesh network traffic end-to-end ACKs.
+ * Handler for cadet network traffic end-to-end ACKs.
  *
  * @param ch Channel on which we got this message.
  * @param msg Data message.
@@ -261,8 +249,8 @@ GMCH_handle_data (struct MeshChannel *ch,
  *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
-GMCH_handle_data_ack (struct MeshChannel *ch,
-                      const struct GNUNET_MESH_DataACK *msg,
+GMCH_handle_data_ack (struct CadetChannel *ch,
+                      const struct GNUNET_CADET_DataACK *msg,
                       int fwd);
 
 /**
@@ -273,9 +261,9 @@ GMCH_handle_data_ack (struct MeshChannel *ch,
  * @param t Tunnel this channel will be in.
  * @param msg Channel crate message.
  */
-struct MeshChannel *
-GMCH_handle_create (struct MeshTunnel3 *t,
-                    const struct GNUNET_MESH_ChannelCreate *msg);
+struct CadetChannel *
+GMCH_handle_create (struct CadetTunnel3 *t,
+                    const struct GNUNET_CADET_ChannelCreate *msg);
 
 /**
  * Handler for channel NACK messages.
@@ -285,7 +273,7 @@ GMCH_handle_create (struct MeshTunnel3 *t,
  * @param ch Channel.
  */
 void
-GMCH_handle_nack (struct MeshChannel *ch);
+GMCH_handle_nack (struct CadetChannel *ch);
 
 /**
  * Handler for channel ack messages.
@@ -298,8 +286,8 @@ GMCH_handle_nack (struct MeshChannel *ch);
  *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
-GMCH_handle_ack (struct MeshChannel *ch,
-                 const struct GNUNET_MESH_ChannelManage *msg,
+GMCH_handle_ack (struct CadetChannel *ch,
+                 const struct GNUNET_CADET_ChannelManage *msg,
                  int fwd);
 
 /**
@@ -313,8 +301,8 @@ GMCH_handle_ack (struct MeshChannel *ch,
  *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
-GMCH_handle_destroy (struct MeshChannel *ch,
-                     const struct GNUNET_MESH_ChannelManage *msg,
+GMCH_handle_destroy (struct CadetChannel *ch,
+                     const struct GNUNET_CADET_ChannelManage *msg,
                      int fwd);
 
 /**
@@ -326,23 +314,27 @@ GMCH_handle_destroy (struct MeshChannel *ch,
  * On a normal channel passes the message to the tunnel for encryption and
  * sending on a connection.
  *
+ * This function DOES NOT save the message for retransmission.
+ *
  * @param message Message to send. Function makes a copy of it.
  * @param ch Channel on which this message is transmitted.
  * @param fwd Is this a fwd message?
+ * @param existing_copy This is a retransmission, don't save a copy.
  */
 void
 GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
-                            struct MeshChannel *ch, int fwd);
+                            struct CadetChannel *ch, int fwd,
+                            void *existing_copy);
 
 /**
  * Get the static string for identification of the channel.
  *
- * @param ch Channel.
+ * @param ch Channel.i
  *
  * @return Static string with the channel IDs.
  */
 const char *
-GMCH_2s (const struct MeshChannel *ch);
+GMCH_2s (const struct CadetChannel *ch);
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */
@@ -352,6 +344,6 @@ GMCH_2s (const struct MeshChannel *ch);
 }
 #endif
 
-/* ifndef GNUNET_SERVICE_MESH_CHANNEL_H */
+/* ifndef GNUNET_SERVICE_CADET_CHANNEL_H */
 #endif
-/* end of gnunet-service-mesh_channel.h */
+/* end of gnunet-service-cadet_channel.h */