- fix coverity
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet_connection.h
index 5d12ce7b3ef0621aedd861ef00cb8301c87d0a1d..261dd106708aa3d9b084e563c2d1b3e6afbedd15 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.
 */
 
 /**
@@ -69,6 +69,11 @@ enum CadetConnectionState
    * Connection to be destroyed, just waiting to empty queues.
    */
   CADET_CONNECTION_DESTROYED,
+
+  /**
+   * Connection to be destroyed because of a distant peer, same as DESTROYED.
+   */
+  CADET_CONNECTION_BROKEN,
 };
 
 
@@ -87,6 +92,12 @@ struct CadetConnectionQueue;
 #include "gnunet-service-cadet_peer.h"
 
 
+/**
+ * Check invariants for all connections using #check_neighbours().
+ */
+void
+GCC_check_connections ();
+
 
 /**
  * Callback called when a queued message is sent.
@@ -97,10 +108,14 @@ struct CadetConnectionQueue;
  * @param fwd Was this a FWD going message?
  * @param size Size of the message.
  */
-typedef void (*GCC_sent) (void *cls,
-                          struct CadetConnection *c,
-                          struct CadetConnectionQueue *q,
-                          uint16_t type, int fwd, size_t size);
+typedef void
+(*GCC_sent) (void *cls,
+             struct CadetConnection *c,
+             struct CadetConnectionQueue *q,
+             uint16_t type,
+             int fwd,
+             size_t size);
+
 
 /**
  * Core handler for connection creation.
@@ -108,37 +123,38 @@ typedef void (*GCC_sent) (void *cls,
  * @param cls Closure (unused).
  * @param peer Sender (neighbor).
  * @param message Message.
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ *         #GNUNET_SYSERR to close it (signal serious error)
  */
 int
-GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
+GCC_handle_create (void *cls,
+                   const struct GNUNET_PeerIdentity *peer,
                    const struct GNUNET_MessageHeader *message);
 
+
 /**
  * Core handler for path confirmations.
  *
  * @param cls closure
  * @param message message
  * @param peer peer identity this notification is about
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ *         #GNUNET_SYSERR to close it (signal serious error)
  */
 int
-GCC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
+GCC_handle_confirm (void *cls,
+                    const struct GNUNET_PeerIdentity *peer,
                     const struct GNUNET_MessageHeader *message);
 
+
 /**
  * Core handler for notifications of broken paths
  *
  * @param cls Closure (unused).
  * @param id Peer identity of sending neighbor.
  * @param message Message.
- *
- * @return GNUNET_OK to keep the connection open,
- *         GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ *         #GNUNET_SYSERR to close it (signal serious error)
  */
 int
 GCC_handle_broken (void* cls,
@@ -160,7 +176,7 @@ GCC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
                     const struct GNUNET_MessageHeader *message);
 
 /**
- * Core handler for encrypted cadet network traffic (channel mgmt, data).
+ * Core handler for key exchange traffic (ephemeral key, ping, pong).
  *
  * @param cls Closure (unused).
  * @param message Message received.
@@ -170,11 +186,11 @@ GCC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
  *         GNUNET_SYSERR to close it (signal serious error)
  */
 int
-GCC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
-                      const struct GNUNET_MessageHeader *message);
+GCC_handle_kx (void *cls, const struct GNUNET_PeerIdentity *peer,
+               const struct GNUNET_MessageHeader *message);
 
 /**
- * Core handler for key exchange traffic (ephemeral key, ping, pong).
+ * Core handler for encrypted cadet network traffic (channel mgmt, data).
  *
  * @param cls Closure (unused).
  * @param message Message received.
@@ -184,8 +200,34 @@ GCC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
  *         GNUNET_SYSERR to close it (signal serious error)
  */
 int
-GCC_handle_kx (void *cls, const struct GNUNET_PeerIdentity *peer,
-               const struct GNUNET_MessageHeader *message);
+GCC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
+                      const struct GNUNET_MessageHeader *message);
+
+/**
+ * Core handler for axolotl key exchange traffic.
+ *
+ * @param cls Closure (unused).
+ * @param message Message received.
+ * @param peer Neighbor who sent the message.
+ *
+ * @return GNUNET_OK, to keep the connection open.
+ */
+int
+GCC_handle_ax_kx (void *cls, const struct GNUNET_PeerIdentity *peer,
+                  const struct GNUNET_MessageHeader *message);
+
+/**
+ * Core handler for axolotl encrypted cadet network traffic.
+ *
+ * @param cls Closure (unused).
+ * @param message Message received.
+ * @param peer Neighbor who sent the message.
+ *
+ * @return GNUNET_OK, to keep the connection open.
+ */
+int
+GCC_handle_ax (void *cls, const struct GNUNET_PeerIdentity *peer,
+               struct GNUNET_MessageHeader *message);
 
 /**
  * Core handler for cadet network traffic point-to-point acks.
@@ -260,15 +302,15 @@ GCC_shutdown (void);
  *
  * @param cid Connection ID (either created locally or imposed remotely).
  * @param t Tunnel this connection belongs to (or NULL);
- * @param p Path this connection has to use.
- * @param own_pos Own position in the @c p path.
+ * @param path Path this connection has to use (copy is made).
+ * @param own_pos Own position in the @c path path.
  *
  * @return Newly created connection, NULL in case of error (own id not in path).
  */
 struct CadetConnection *
 GCC_new (const struct GNUNET_CADET_Hash *cid,
          struct CadetTunnel *t,
-         struct CadetPeerPath *p,
+         struct CadetPeerPath *path,
          unsigned int own_pos);
 
 /**
@@ -418,8 +460,7 @@ GCC_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
  * @param peer Peer that disconnected.
  */
 void
-GCC_notify_broken (struct CadetConnection *c,
-                   struct CadetPeer *peer);
+GCC_neighbor_disconnected (struct CadetConnection *c, struct CadetPeer *peer);
 
 /**
  * Is this peer the first one on the connection?
@@ -554,6 +595,15 @@ GCC_stop_poll (struct CadetConnection *c, int fwd);
 const char *
 GCC_2s (const struct CadetConnection *c);
 
+/**
+ * Log all possible info about the connection state.
+ *
+ * @param c Connection to debug.
+ * @param level Debug level to use.
+ */
+void
+GCC_debug (const struct CadetConnection *c, enum GNUNET_ErrorType level);
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif