optimize mqm_head scans by avoiding constantly scanning over definitively non-ready...
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet_channel.h
index f5a89a4233016e7b48e8000c25beb1c9faea737b..9d4893269737b98cf3adbe9fa8aaaf27a4932545 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2013 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 
 /**
@@ -59,7 +59,7 @@ struct CadetChannel;
  * @param ch Channel to destroy.
  */
 void
-GMCH_destroy (struct CadetChannel *ch);
+GCCH_destroy (struct CadetChannel *ch);
 
 
 /**
@@ -69,8 +69,9 @@ GMCH_destroy (struct CadetChannel *ch);
  *
  * @return ID used to identify the channel with the remote peer.
  */
-CADET_ChannelNumber
-GMCH_get_id (const struct CadetChannel *ch);
+struct GNUNET_CADET_ChannelTunnelNumber
+GCCH_get_id (const struct CadetChannel *ch);
+
 
 /**
  * Get the channel tunnel.
@@ -79,8 +80,9 @@ GMCH_get_id (const struct CadetChannel *ch);
  *
  * @return tunnel of the channel.
  */
-struct CadetTunnel3 *
-GMCH_get_tunnel (const struct CadetChannel *ch);
+struct CadetTunnel *
+GCCH_get_tunnel (const struct CadetChannel *ch);
+
 
 /**
  * Get free buffer space towards the client on a specific channel.
@@ -91,7 +93,7 @@ GMCH_get_tunnel (const struct CadetChannel *ch);
  * @return Free buffer space [0 - 64]
  */
 unsigned int
-GMCH_get_buffer (struct CadetChannel *ch, int fwd);
+GCCH_get_buffer (struct CadetChannel *ch, int fwd);
 
 
 /**
@@ -103,7 +105,7 @@ GMCH_get_buffer (struct CadetChannel *ch, int fwd);
  * @return #GNUNET_YES if client is allowed to send us data.
  */
 int
-GMCH_get_allowed (struct CadetChannel *ch, int fwd);
+GCCH_get_allowed (struct CadetChannel *ch, int fwd);
 
 
 /**
@@ -115,7 +117,7 @@ GMCH_get_allowed (struct CadetChannel *ch, int fwd);
  * @return #GNUNET_YES in case it is.
  */
 int
-GMCH_is_origin (struct CadetChannel *ch, int fwd);
+GCCH_is_origin (struct CadetChannel *ch, int fwd);
 
 /**
  * Is the destination client for this channel on this peer?
@@ -126,7 +128,7 @@ GMCH_is_origin (struct CadetChannel *ch, int fwd);
  * @return #GNUNET_YES in case it is.
  */
 int
-GMCH_is_terminal (struct CadetChannel *ch, int fwd);
+GCCH_is_terminal (struct CadetChannel *ch, int fwd);
 
 /**
  * Send an end-to-end ACK message for the most recent in-sequence payload.
@@ -137,7 +139,7 @@ GMCH_is_terminal (struct CadetChannel *ch, int fwd);
  * @param fwd Is for FWD traffic? (ACK dest->owner)
  */
 void
-GMCH_send_data_ack (struct CadetChannel *ch, int fwd);
+GCCH_send_data_ack (struct CadetChannel *ch, int fwd);
 
 /**
  * Notify the destination client that a new incoming channel was created.
@@ -145,7 +147,7 @@ GMCH_send_data_ack (struct CadetChannel *ch, int fwd);
  * @param ch Channel that was created.
  */
 void
-GMCH_send_create (struct CadetChannel *ch);
+GCCH_send_create (struct CadetChannel *ch);
 
 /**
  * Allow a client to send us more data, in case it was choked.
@@ -154,15 +156,16 @@ GMCH_send_create (struct CadetChannel *ch);
  * @param fwd Is this about FWD traffic? (Root client).
  */
 void
-GMCH_allow_client (struct CadetChannel *ch, int fwd);
+GCCH_allow_client (struct CadetChannel *ch, int fwd);
 
 /**
  * Log channel info.
  *
  * @param ch Channel.
+ * @param level Debug level to use.
  */
 void
-GMCH_debug (struct CadetChannel *ch);
+GCCH_debug (struct CadetChannel *ch, enum GNUNET_ErrorType level);
 
 /**
  * Handle an ACK given by a client.
@@ -173,7 +176,7 @@ GMCH_debug (struct CadetChannel *ch);
  * @param fwd Is this a "FWD ACK"? (FWD ACKs are sent by root and go BCK)
  */
 void
-GMCH_handle_local_ack (struct CadetChannel *ch, int fwd);
+GCCH_handle_local_ack (struct CadetChannel *ch, int fwd);
 
 /**
  * Handle data given by a client.
@@ -184,16 +187,17 @@ GMCH_handle_local_ack (struct CadetChannel *ch, int fwd);
  *
  * @param ch Channel.
  * @param c Client which sent the data.
- * @param message Message.
  * @param fwd Is this a FWD data?
+ * @param message Data message.
+ * @param size Size of data.
  *
  * @return GNUNET_OK if everything goes well, GNUNET_SYSERR in case of en error.
  */
 int
-GMCH_handle_local_data (struct CadetChannel *ch,
-                        struct CadetClient *c,
-                        struct GNUNET_MessageHeader *message,
-                        int fwd);
+GCCH_handle_local_data (struct CadetChannel *ch,
+                        struct CadetClient *c, int fwd,
+                        const struct GNUNET_MessageHeader *message,
+                        size_t size);
 
 /**
  * Handle a channel destroy requested by a client.
@@ -205,10 +209,11 @@ GMCH_handle_local_data (struct CadetChannel *ch,
  * @param is_root Is the request coming from root?
  */
 void
-GMCH_handle_local_destroy (struct CadetChannel *ch,
+GCCH_handle_local_destroy (struct CadetChannel *ch,
                            struct CadetClient *c,
                            int is_root);
 
+
 /**
  * Handle a channel create requested by a client.
  *
@@ -217,11 +222,11 @@ GMCH_handle_local_destroy (struct CadetChannel *ch,
  * @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.
+ * @return #GNUNET_OK if everything went fine, #GNUNET_SYSERR otherwise.
  */
 int
-GMCH_handle_local_create (struct CadetClient *c,
-                          struct GNUNET_CADET_ChannelMessage *msg);
+GCCH_handle_local_create (struct CadetClient *c,
+                          struct GNUNET_CADET_LocalChannelCreateMessage *msg);
 
 /**
  * Handler for cadet network payload traffic.
@@ -234,10 +239,11 @@ GMCH_handle_local_create (struct CadetClient *c,
  *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
-GMCH_handle_data (struct CadetChannel *ch,
-                  const struct GNUNET_CADET_Data *msg,
+GCCH_handle_data (struct CadetChannel *ch,
+                  const struct GNUNET_CADET_ChannelAppDataMessage *msg,
                   int fwd);
 
+
 /**
  * Handler for cadet network traffic end-to-end ACKs.
  *
@@ -249,10 +255,11 @@ GMCH_handle_data (struct CadetChannel *ch,
  *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
-GMCH_handle_data_ack (struct CadetChannel *ch,
-                      const struct GNUNET_CADET_DataACK *msg,
+GCCH_handle_data_ack (struct CadetChannel *ch,
+                      const struct GNUNET_CADET_ChannelDataAckMessage *msg,
                       int fwd);
 
+
 /**
  * Handler for channel create messages.
  *
@@ -262,8 +269,9 @@ GMCH_handle_data_ack (struct CadetChannel *ch,
  * @param msg Channel crate message.
  */
 struct CadetChannel *
-GMCH_handle_create (struct CadetTunnel3 *t,
-                    const struct GNUNET_CADET_ChannelCreate *msg);
+GCCH_handle_create (struct CadetTunnel *t,
+                    const struct GNUNET_CADET_ChannelOpenMessage *msg);
+
 
 /**
  * Handler for channel NACK messages.
@@ -273,7 +281,8 @@ GMCH_handle_create (struct CadetTunnel3 *t,
  * @param ch Channel.
  */
 void
-GMCH_handle_nack (struct CadetChannel *ch);
+GCCH_handle_nack (struct CadetChannel *ch);
+
 
 /**
  * Handler for channel ack messages.
@@ -286,10 +295,11 @@ GMCH_handle_nack (struct CadetChannel *ch);
  *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
-GMCH_handle_ack (struct CadetChannel *ch,
-                 const struct GNUNET_CADET_ChannelManage *msg,
+GCCH_handle_ack (struct CadetChannel *ch,
+                 const struct GNUNET_CADET_ChannelManageMessage *msg,
                  int fwd);
 
+
 /**
  * Handler for channel destroy messages.
  *
@@ -301,10 +311,11 @@ GMCH_handle_ack (struct CadetChannel *ch,
  *            #GNUNET_SYSERR if message on a one-ended channel (remote)
  */
 void
-GMCH_handle_destroy (struct CadetChannel *ch,
-                     const struct GNUNET_CADET_ChannelManage *msg,
+GCCH_handle_destroy (struct CadetChannel *ch,
+                     const struct GNUNET_CADET_ChannelManageMessage *msg,
                      int fwd);
 
+
 /**
  * Sends an already built message on a channel.
  *
@@ -322,10 +333,11 @@ GMCH_handle_destroy (struct CadetChannel *ch,
  * @param existing_copy This is a retransmission, don't save a copy.
  */
 void
-GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
+GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
                             struct CadetChannel *ch, int fwd,
                             void *existing_copy);
 
+
 /**
  * Get the static string for identification of the channel.
  *
@@ -334,7 +346,9 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
  * @return Static string with the channel IDs.
  */
 const char *
-GMCH_2s (const struct CadetChannel *ch);
+GCCH_2s (const struct CadetChannel *ch);
+
+
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */