- fix coverity
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet_tunnel.h
index b2c6f05bcbb267d70f4ab1d270be2224ab387f34..e836e4b24e9caa663f4f3cf67ad50862402b05dd 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (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
@@ -90,10 +90,19 @@ enum CadetTunnelEState
   CADET_TUNNEL_KEY_SENT,
 
   /**
-   * New ephemeral key and ping sent, waiting for pong.
+   * In OTR: New ephemeral key and ping sent, waiting for pong.
+   *
    * This means that we DO have the peer's ephemeral key, otherwise the
    * state would be KEY_SENT. We DO NOT have a valid session key (either no
    * previous key or previous key expired).
+   *
+   *
+   * In Axolotl: Key sent and received but no deciphered traffic yet.
+   *
+   * This means that we can send traffic (otherwise we would never complete
+   * the handshake), but we don't have complete confirmation. Since the first
+   * traffic MUST be a complete channel creation 3-way handshake, no payload
+   * will be sent before confirmation.
    */
   CADET_TUNNEL_KEY_PING,
 
@@ -156,12 +165,14 @@ void
 GCT_init (const struct GNUNET_CONFIGURATION_Handle *c,
           const struct GNUNET_CRYPTO_EddsaPrivateKey *key);
 
+
 /**
  * Shut down the tunnel subsystem.
  */
 void
 GCT_shutdown (void);
 
+
 /**
  * Create a tunnel.
  *
@@ -170,6 +181,7 @@ GCT_shutdown (void);
 struct CadetTunnel *
 GCT_new (struct CadetPeer *destination);
 
+
 /**
  * Tunnel is empty: destroy it.
  *
@@ -180,6 +192,7 @@ GCT_new (struct CadetPeer *destination);
 void
 GCT_destroy_empty (struct CadetTunnel *t);
 
+
 /**
  * Destroy tunnel if empty (no more channels).
  *
@@ -188,6 +201,7 @@ GCT_destroy_empty (struct CadetTunnel *t);
 void
 GCT_destroy_if_empty (struct CadetTunnel *t);
 
+
 /**
  * Destroy the tunnel.
  *
@@ -222,6 +236,7 @@ GCT_change_cstate (struct CadetTunnel* t, enum CadetTunnelCState cstate);
 void
 GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state);
 
+
 /**
  * Add a connection to a tunnel.
  *
@@ -231,6 +246,7 @@ GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state);
 void
 GCT_add_connection (struct CadetTunnel *t, struct CadetConnection *c);
 
+
 /**
  * Remove a connection from a tunnel.
  *
@@ -240,6 +256,7 @@ GCT_add_connection (struct CadetTunnel *t, struct CadetConnection *c);
 void
 GCT_remove_connection (struct CadetTunnel *t, struct CadetConnection *c);
 
+
 /**
  * Add a channel to a tunnel.
  *
@@ -249,6 +266,7 @@ GCT_remove_connection (struct CadetTunnel *t, struct CadetConnection *c);
 void
 GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch);
 
+
 /**
  * Remove a channel from a tunnel.
  *
@@ -258,6 +276,7 @@ GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch);
 void
 GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch);
 
+
 /**
  * Search for a channel by global ID.
  *
@@ -269,6 +288,7 @@ GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch);
 struct CadetChannel *
 GCT_get_channel (struct CadetTunnel *t, CADET_ChannelNumber chid);
 
+
 /**
  * Decrypt and demultiplex by message type. Call appropriate handler
  * for a message towards a channel of a local tunnel.
@@ -291,6 +311,7 @@ void
 GCT_handle_kx (struct CadetTunnel *t,
                const struct GNUNET_MessageHeader *message);
 
+
 /**
  * @brief Use the given path for the tunnel.
  * Update the next and prev hops (and RCs).
@@ -304,6 +325,7 @@ GCT_handle_kx (struct CadetTunnel *t,
 struct CadetConnection *
 GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p);
 
+
 /**
  * Count all created connections of a tunnel. Not necessarily ready connections!
  *
@@ -314,6 +336,7 @@ GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p);
 unsigned int
 GCT_count_any_connections (struct CadetTunnel *t);
 
+
 /**
  * Count established (ready) connections of a tunnel.
  *
@@ -324,6 +347,7 @@ GCT_count_any_connections (struct CadetTunnel *t);
 unsigned int
 GCT_count_connections (struct CadetTunnel *t);
 
+
 /**
  * Count channels of a tunnel.
  *
@@ -334,6 +358,7 @@ GCT_count_connections (struct CadetTunnel *t);
 unsigned int
 GCT_count_channels (struct CadetTunnel *t);
 
+
 /**
  * Get the connectivity state of a tunnel.
  *
@@ -344,6 +369,7 @@ GCT_count_channels (struct CadetTunnel *t);
 enum CadetTunnelCState
 GCT_get_cstate (struct CadetTunnel *t);
 
+
 /**
  * Get the encryption state of a tunnel.
  *
@@ -354,6 +380,7 @@ GCT_get_cstate (struct CadetTunnel *t);
 enum CadetTunnelEState
 GCT_get_estate (struct CadetTunnel *t);
 
+
 /**
  * Get the maximum buffer space for a tunnel towards a local client.
  *
@@ -364,6 +391,7 @@ GCT_get_estate (struct CadetTunnel *t);
 unsigned int
 GCT_get_channels_buffer (struct CadetTunnel *t);
 
+
 /**
  * Get the total buffer space for a tunnel for P2P traffic.
  *
@@ -374,6 +402,7 @@ GCT_get_channels_buffer (struct CadetTunnel *t);
 unsigned int
 GCT_get_connections_buffer (struct CadetTunnel *t);
 
+
 /**
  * Get the tunnel's destination.
  *
@@ -384,6 +413,7 @@ GCT_get_connections_buffer (struct CadetTunnel *t);
 const struct GNUNET_PeerIdentity *
 GCT_get_destination (struct CadetTunnel *t);
 
+
 /**
  * Get the tunnel's next free Channel ID.
  *
@@ -394,6 +424,7 @@ GCT_get_destination (struct CadetTunnel *t);
 CADET_ChannelNumber
 GCT_get_next_chid (struct CadetTunnel *t);
 
+
 /**
  * Send ACK on one or more channels due to buffer in connections.
  *
@@ -402,6 +433,7 @@ GCT_get_next_chid (struct CadetTunnel *t);
 void
 GCT_unchoke_channels (struct CadetTunnel *t);
 
+
 /**
  * Send ACK on one or more connections due to buffer space to the client.
  *
@@ -412,6 +444,7 @@ GCT_unchoke_channels (struct CadetTunnel *t);
 void
 GCT_send_connection_acks (struct CadetTunnel *t);
 
+
 /**
  * Cancel a previously sent message while it's in the queue.
  *
@@ -424,6 +457,18 @@ GCT_send_connection_acks (struct CadetTunnel *t);
 void
 GCT_cancel (struct CadetTunnelQueue *q);
 
+
+/**
+ * Check if the tunnel has queued traffic.
+ *
+ * @param t Tunnel to check.
+ *
+ * @return #GNUNET_YES if there is queued traffic
+ *         #GNUNET_NO otherwise
+ */
+int
+GCT_has_queued_traffic (struct CadetTunnel *t);
+
 /**
  * Sends an already built message on a tunnel, encrypting it and
  * choosing the best connection.
@@ -442,6 +487,7 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
                            struct CadetTunnel *t, struct CadetConnection *c,
                            int force, GCT_sent cont, void *cont_cls);
 
+
 /**
  * Send an Axolotl KX message.
  *
@@ -451,6 +497,7 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
 void
 GCT_send_ax_kx (struct CadetTunnel *t, int force_reply);
 
+
 /**
  * Sends an already built and encrypted message on a tunnel, choosing the best
  * connection. Useful for re-queueing messages queued on a destroyed connection.
@@ -462,6 +509,7 @@ void
 GCT_resend_message (const struct GNUNET_MessageHeader *message,
                     struct CadetTunnel *t);
 
+
 /**
  * Is the tunnel directed towards the local peer?
  *
@@ -472,6 +520,7 @@ GCT_resend_message (const struct GNUNET_MessageHeader *message,
 int
 GCT_is_loopback (const struct CadetTunnel *t);
 
+
 /**
  * Is the tunnel using this path already?
  *
@@ -483,6 +532,7 @@ GCT_is_loopback (const struct CadetTunnel *t);
 int
 GCT_is_path_used (const struct CadetTunnel *t, const struct CadetPeerPath *p);
 
+
 /**
  * Get a cost of a path for a tunnel considering existing connections.
  *
@@ -495,6 +545,7 @@ unsigned int
 GCT_get_path_cost (const struct CadetTunnel *t,
                    const struct CadetPeerPath *path);
 
+
 /**
  * Get the static string for the peer this tunnel is directed.
  *
@@ -505,6 +556,7 @@ GCT_get_path_cost (const struct CadetTunnel *t,
 const char *
 GCT_2s (const struct CadetTunnel *t);
 
+
 /**
  * Log all possible info about the tunnel state.
  *
@@ -514,6 +566,7 @@ GCT_2s (const struct CadetTunnel *t);
 void
 GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level);
 
+
 /**
  * Iterate all tunnels.
  *
@@ -523,6 +576,7 @@ GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level);
 void
 GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls);
 
+
 /**
  * Count all tunnels.
  *
@@ -531,6 +585,7 @@ GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls);
 unsigned int
 GCT_count_all (void);
 
+
 /**
  * Iterate all connections of a tunnel.
  *
@@ -541,6 +596,7 @@ GCT_count_all (void);
 void
 GCT_iterate_connections (struct CadetTunnel *t, GCT_conn_iter iter, void *cls);
 
+
 /**
  * Iterate all channels of a tunnel.
  *
@@ -549,7 +605,10 @@ GCT_iterate_connections (struct CadetTunnel *t, GCT_conn_iter iter, void *cls);
  * @param cls Closure for @c iter.
  */
 void
-GCT_iterate_channels (struct CadetTunnel *t, GCT_chan_iter iter, void *cls);
+GCT_iterate_channels (struct CadetTunnel *t,
+                      GCT_chan_iter iter,
+                      void *cls);
+
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {