gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r38234 - in gnunet/src: cadet include


From: gnunet
Subject: [GNUnet-SVN] r38234 - in gnunet/src: cadet include
Date: Sun, 30 Oct 2016 01:46:44 +0200

Author: bartpolot
Date: 2016-10-30 01:46:44 +0200 (Sun, 30 Oct 2016)
New Revision: 38234

Modified:
   gnunet/src/cadet/cadet_common.c
   gnunet/src/cadet/cadet_protocol.h
   gnunet/src/cadet/gnunet-service-cadet_connection.c
   gnunet/src/cadet/gnunet-service-cadet_connection.h
   gnunet/src/cadet/gnunet-service-cadet_peer.c
   gnunet/src/cadet/gnunet-service-cadet_tunnel.c
   gnunet/src/cadet/gnunet-service-cadet_tunnel.h
   gnunet/src/include/gnunet_constants.h
   gnunet/src/include/gnunet_protocols.h
Log:
Refactor encrypted traffic handling

- eliminate encapsulation for KX/DATA
- simplify cases
- remove dead code
- Organize message types

Modified: gnunet/src/cadet/cadet_common.c
===================================================================
--- gnunet/src/cadet/cadet_common.c     2016-10-29 14:56:53 UTC (rev 38233)
+++ gnunet/src/cadet/cadet_common.c     2016-10-29 23:46:44 UTC (rev 38234)
@@ -192,7 +192,7 @@
       break;
 
       /**
-       * Key exchange encapsulation.
+       * Key exchange message.
        */
     case GNUNET_MESSAGE_TYPE_CADET_KX:
       s = "KX";
@@ -199,10 +199,10 @@
       break;
 
       /**
-       * Axolotl key exchange message.
+       * Encrypted.
        */
-    case GNUNET_MESSAGE_TYPE_CADET_AX_KX:
-      s = "AX_KX";
+    case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
+      s = "ENCRYPTED";
       break;
 
       /**
@@ -276,13 +276,6 @@
       break;
 
       /**
-       * Axolotl encrypted payload.
-       */
-    case GNUNET_MESSAGE_TYPE_CADET_AX:
-      s = "AX";
-      break;
-
-      /**
        * Local payload traffic
        */
     case GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA:

Modified: gnunet/src/cadet/cadet_protocol.h
===================================================================
--- gnunet/src/cadet/cadet_protocol.h   2016-10-29 14:56:53 UTC (rev 38233)
+++ gnunet/src/cadet/cadet_protocol.h   2016-10-29 23:46:44 UTC (rev 38234)
@@ -47,6 +47,12 @@
 
 GNUNET_NETWORK_STRUCT_BEGIN
 
+
+/******************************************************************************/
+/*****************************   CONNECTION  
**********************************/
+/******************************************************************************/
+
+
 /**
  * Message for cadet connection creation.
  */
@@ -102,15 +108,15 @@
 
 
 /**
- * Message for encapsulation of a Key eXchange message in a connection.
+ * Message for notifying a disconnection in a path
  */
-struct GNUNET_CADET_KX
+struct GNUNET_CADET_ConnectionBroken
 {
   /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_KX.
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
    */
   struct GNUNET_MessageHeader header;
-  
+
   /**
    * For alignment.
    */
@@ -121,44 +127,129 @@
    */
   struct GNUNET_CADET_Hash cid;
 
-  /* Specific KX message follows. */
+  /**
+   * ID of the endpoint
+   */
+  struct GNUNET_PeerIdentity peer1;
+
+  /**
+   * ID of the endpoint
+   */
+  struct GNUNET_PeerIdentity peer2;
 };
 
 
 /**
- * Flags to be used in GNUNET_CADET_AX_KX.
+ * Message to destroy a connection.
  */
-enum GNUNET_CADET_AX_KX_Flags {
+struct GNUNET_CADET_ConnectionDestroy
+{
+  /**
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
+   */
+  struct GNUNET_MessageHeader header;
 
   /**
+   * For alignment.
+   */
+  uint32_t reserved GNUNET_PACKED;
+
+  /**
+   * ID of the connection.
+   */
+  struct GNUNET_CADET_Hash cid;
+};
+
+
+/**
+ * Message to acknowledge cadet encrypted traffic.
+ */
+struct GNUNET_CADET_ACK
+{
+  /**
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_ACK
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Maximum packet ID authorized.
+   */
+  uint32_t ack GNUNET_PACKED;
+
+  /**
+   * ID of the connection.
+   */
+  struct GNUNET_CADET_Hash cid;
+};
+
+
+/**
+ * Message to query a peer about its Flow Control status regarding a tunnel.
+ */
+struct GNUNET_CADET_Poll
+{
+  /**
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_POLL
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Last packet sent.
+   */
+  uint32_t pid GNUNET_PACKED;
+
+  /**
+   * ID of the connection.
+   */
+  struct GNUNET_CADET_Hash cid;
+
+};
+
+
+
+/******************************************************************************/
+/*******************************   TUNNEL   
***********************************/
+/******************************************************************************/
+
+/**
+ * Flags to be used in GNUNET_CADET_KX.
+ */
+enum GNUNET_CADET_KX_Flags {
+
+  /**
    * Should the peer reply with its KX details?
    */
-  GNUNET_CADET_AX_KX_FLAG_NONE = 0,
+  GNUNET_CADET_KX_FLAG_NONE = 0,
 
   /**
    * The peer should reply with its KX details?
    */
-  GNUNET_CADET_AX_KX_FLAG_FORCE_REPLY = 1
+  GNUNET_CADET_KX_FLAG_FORCE_REPLY = 1
 };
 
 
 /**
- * Message for encapsulation of a Key eXchange message in a connection.
+ * Message for a Key eXchange for a tunnel.
  */
-struct GNUNET_CADET_AX_KX
+struct GNUNET_CADET_KX
 {
   /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_AX_KX.
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_KX.
    */
   struct GNUNET_MessageHeader header;
 
   /**
    * Flags for the key exchange in NBO, based on
-   * `enum GNUNET_CADET_AX_KX_Flags`.
+   * `enum GNUNET_CADET_KX_Flags`.
    */
   uint32_t flags GNUNET_PACKED;
 
   /**
+   * ID of the connection.
+   */
+  struct GNUNET_CADET_Hash cid;
+
+  /**
    * Sender's ephemeral public ECC key encoded in a
    * format suitable for network transmission, as created
    * using 'gcry_sexp_sprint'.
@@ -177,10 +268,10 @@
 /**
  * Axolotl tunnel message.
  */
-struct GNUNET_CADET_AX
+struct GNUNET_CADET_Encrypted
 {
   /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_AXOLOTL_DATA
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED
    */
   struct GNUNET_MessageHeader header;
 
@@ -226,6 +317,11 @@
 };
 
 
+
+/******************************************************************************/
+/*******************************   CHANNEL  
***********************************/
+/******************************************************************************/
+
 /**
  * Message to create a Channel.
  */
@@ -326,105 +422,7 @@
 };
 
 
-/**
- * Message to acknowledge cadet encrypted traffic.
- */
-struct GNUNET_CADET_ACK
-{
-  /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_ACK
-   */
-  struct GNUNET_MessageHeader header;
 
-  /**
-   * Maximum packet ID authorized.
-   */
-  uint32_t ack GNUNET_PACKED;
-
-  /**
-   * ID of the connection.
-   */
-  struct GNUNET_CADET_Hash cid;
-};
-
-
-/**
- * Message to query a peer about its Flow Control status regarding a tunnel.
- */
-struct GNUNET_CADET_Poll
-{
-  /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_POLL
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * Last packet sent.
-   */
-  uint32_t pid GNUNET_PACKED;
-
-  /**
-   * ID of the connection.
-   */
-  struct GNUNET_CADET_Hash cid;
-
-};
-
-
-/**
- * Message for notifying a disconnection in a path
- */
-struct GNUNET_CADET_ConnectionBroken
-{
-  /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * For alignment.
-   */
-  uint32_t reserved GNUNET_PACKED;
-
-  /**
-   * ID of the connection.
-   */
-  struct GNUNET_CADET_Hash cid;
-
-  /**
-   * ID of the endpoint
-   */
-  struct GNUNET_PeerIdentity peer1;
-
-  /**
-   * ID of the endpoint
-   */
-  struct GNUNET_PeerIdentity peer2;
-};
-
-
-/**
- * Message to destroy a connection.
- */
-struct GNUNET_CADET_ConnectionDestroy
-{
-  /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * For alignment.
-   */
-  uint32_t reserved GNUNET_PACKED;
-
-  /**
-   * ID of the connection.
-   */
-  struct GNUNET_CADET_Hash cid;
-};
-
-
 GNUNET_NETWORK_STRUCT_END
 
 #if 0                           /* keep Emacsens' auto-indent happy */

Modified: gnunet/src/cadet/gnunet-service-cadet_connection.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_connection.c  2016-10-29 14:56:53 UTC 
(rev 38233)
+++ gnunet/src/cadet/gnunet-service-cadet_connection.c  2016-10-29 23:46:44 UTC 
(rev 38234)
@@ -736,7 +736,7 @@
     }
     GNUNET_free (q);
   }
-  else if (type == GNUNET_MESSAGE_TYPE_CADET_AX)
+  else if (type == GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED)
   {
     /* SHOULD NO LONGER HAPPEN FIXME: REMOVE CASE */
     // If NULL == q and ENCRYPTED == type, message must have been ch_mngmnt
@@ -771,7 +771,7 @@
         schedule_next_keepalive (c, fwd);
       break;
 
-    case GNUNET_MESSAGE_TYPE_CADET_AX:
+    case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
       if (GNUNET_YES == sent)
       {
         GNUNET_assert (NULL != q);
@@ -2517,7 +2517,7 @@
 
   /* Check PID for payload messages */
   type = ntohs (message->type);
-  if (GNUNET_MESSAGE_TYPE_CADET_AX == type)
+  if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == type)
   {
     fc = fwd ? &c->bck_fc : &c->fwd_fc;
     LOG (GNUNET_ERROR_TYPE_DEBUG, " PID %u (expected %u - %u)\n",
@@ -2611,7 +2611,7 @@
       GNUNET_break (0);
       return;
     }
-    GCT_handle_kx (c->t, &msg[1].header);
+    GCT_handle_kx (c->t, msg);
     GCC_check_connections ();
     return;
   }
@@ -2633,7 +2633,7 @@
  */
 void
 GCC_handle_encrypted (struct CadetPeer *peer,
-                      const struct GNUNET_CADET_AX *msg)
+                      const struct GNUNET_CADET_Encrypted *msg)
 {
   const struct GNUNET_CADET_Hash* cid;
   struct CadetConnection *c;
@@ -2670,7 +2670,7 @@
       GNUNET_break (GNUNET_NO != c->destroy);
       return;
     }
-    GCT_handle_encrypted (c->t, &msg->header);
+    GCT_handle_encrypted (c->t, msg);
     GCC_send_ack (c, fwd, GNUNET_NO);
     GCC_check_connections ();
     return;
@@ -3275,7 +3275,7 @@
        GC_f2s(fwd), size);
   switch (type)
   {
-    case GNUNET_MESSAGE_TYPE_CADET_AX:
+    case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
       LOG (GNUNET_ERROR_TYPE_DEBUG, "  Q_N+ %p %u\n", fc, fc->queue_n);
       LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid sent %u\n", fc->last_pid_sent);
       LOG (GNUNET_ERROR_TYPE_DEBUG, "     ack recv %u\n", fc->last_ack_recv);
@@ -3312,7 +3312,7 @@
     GNUNET_break (0);
     LOG (GNUNET_ERROR_TYPE_DEBUG, "queue full: %u/%u\n",
          fc->queue_n, fc->queue_max);
-    if (GNUNET_MESSAGE_TYPE_CADET_AX == type)
+    if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == type)
     {
       fc->queue_n--;
     }

Modified: gnunet/src/cadet/gnunet-service-cadet_connection.h
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_connection.h  2016-10-29 14:56:53 UTC 
(rev 38233)
+++ gnunet/src/cadet/gnunet-service-cadet_connection.h  2016-10-29 23:46:44 UTC 
(rev 38234)
@@ -197,7 +197,7 @@
  */
 void
 GCC_handle_encrypted (struct CadetPeer *peer,
-                      const struct GNUNET_CADET_AX *msg);
+                      const struct GNUNET_CADET_Encrypted *msg);
 
 /**
  * Core handler for axolotl key exchange traffic.

Modified: gnunet/src/cadet/gnunet-service-cadet_peer.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_peer.c        2016-10-29 14:56:53 UTC 
(rev 38233)
+++ gnunet/src/cadet/gnunet-service-cadet_peer.c        2016-10-29 23:46:44 UTC 
(rev 38234)
@@ -548,32 +548,6 @@
 
 
 /**
- * Check if the Key eXchange message has the appropriate size.
- *
- * @param cls Closure (unused).
- * @param msg Message to check.
- *
- * @return #GNUNET_YES if size is correct, #GNUNET_NO otherwise.
- */
-static int
-check_kx (void *cls, const struct GNUNET_CADET_KX *msg)
-{
-    uint16_t size;
-    uint16_t expected_size;
-
-    size = ntohs (msg->header.size);
-    expected_size = sizeof (struct GNUNET_CADET_KX)
-                    + sizeof (struct GNUNET_MessageHeader);
-
-    if (size < expected_size)
-    {
-        GNUNET_break_op (0);
-        return GNUNET_NO;
-    }
-    return GNUNET_YES;
-}
-
-/**
  * Handle for #GNUNET_MESSAGE_TYPE_CADET_KX
  *
  * @param cls Closure (CadetPeer for neighbor that sent the message).
@@ -596,13 +570,13 @@
  * @return #GNUNET_YES if size is correct, #GNUNET_NO otherwise.
  */
 static int
-check_encrypted (void *cls, const struct GNUNET_CADET_AX *msg)
+check_encrypted (void *cls, const struct GNUNET_CADET_Encrypted *msg)
 {
     uint16_t size;
     uint16_t minimum_size;
 
     size = ntohs (msg->header.size);
-    minimum_size = sizeof (struct GNUNET_CADET_AX)
+    minimum_size = sizeof (struct GNUNET_CADET_Encrypted)
                    + sizeof (struct GNUNET_MessageHeader);
 
     if (size < minimum_size)
@@ -614,13 +588,13 @@
 }
 
 /**
- * Handle for #GNUNET_MESSAGE_TYPE_CADET_AX (AXolotl encrypted traffic).
+ * Handle for #GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED.
  *
  * @param cls Closure (CadetPeer for neighbor that sent the message).
  * @param msg Message itself.
  */
 static void
-handle_encrypted (void *cls, const struct GNUNET_CADET_AX *msg)
+handle_encrypted (void *cls, const struct GNUNET_CADET_Encrypted *msg)
 {
     struct CadetPeer *peer = cls;
     GCC_handle_encrypted (peer, msg);
@@ -643,37 +617,37 @@
 {
     struct GNUNET_MQ_MessageHandler core_handlers[] = {
         GNUNET_MQ_hd_var_size (create,
-        GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE,
-        struct GNUNET_CADET_ConnectionCreate,
-        NULL),
+                               GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE,
+                               struct GNUNET_CADET_ConnectionCreate,
+                               NULL),
         GNUNET_MQ_hd_fixed_size (confirm,
-        GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK,
-        struct GNUNET_CADET_ConnectionACK,
-        NULL),
+                                 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK,
+                                 struct GNUNET_CADET_ConnectionACK,
+                                 NULL),
         GNUNET_MQ_hd_fixed_size (broken,
-        GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN,
-        struct GNUNET_CADET_ConnectionBroken,
-        NULL),
+                                GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN,
+                                struct GNUNET_CADET_ConnectionBroken,
+                                NULL),
         GNUNET_MQ_hd_fixed_size (destroy,
-        GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY,
-        struct GNUNET_CADET_ConnectionDestroy,
-        NULL),
+                                 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY,
+                                 struct GNUNET_CADET_ConnectionDestroy,
+                                 NULL),
         GNUNET_MQ_hd_fixed_size (ack,
-        GNUNET_MESSAGE_TYPE_CADET_ACK,
-        struct GNUNET_CADET_ACK,
-        NULL),
+                                 GNUNET_MESSAGE_TYPE_CADET_ACK,
+                                 struct GNUNET_CADET_ACK,
+                                 NULL),
         GNUNET_MQ_hd_fixed_size (poll,
-        GNUNET_MESSAGE_TYPE_CADET_POLL,
-        struct GNUNET_CADET_Poll,
-        NULL),
-        GNUNET_MQ_hd_var_size (kx,
-        GNUNET_MESSAGE_TYPE_CADET_KX,
-        struct GNUNET_CADET_KX,
-        NULL),
+                                 GNUNET_MESSAGE_TYPE_CADET_POLL,
+                                 struct GNUNET_CADET_Poll,
+                                 NULL),
+        GNUNET_MQ_hd_fixed_size (kx,
+                                 GNUNET_MESSAGE_TYPE_CADET_KX,
+                                 struct GNUNET_CADET_KX,
+                                 NULL),
         GNUNET_MQ_hd_var_size (encrypted,
-        GNUNET_MESSAGE_TYPE_CADET_AX,
-        struct GNUNET_CADET_AX,
-        NULL),
+                               GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED,
+                               struct GNUNET_CADET_Encrypted,
+                               NULL),
         GNUNET_MQ_handler_end ()
     };
     core_handle = GNUNET_CORE_connecT (c, NULL,
@@ -755,7 +729,7 @@
     }
 
     /* Bulky payload has lower priority, control traffic has higher. */
-    if (GNUNET_MESSAGE_TYPE_CADET_AX == q->type)
+    if (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED == q->type)
         return low;
     return high;
 }

Modified: gnunet/src/cadet/gnunet-service-cadet_tunnel.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_tunnel.c      2016-10-29 14:56:53 UTC 
(rev 38233)
+++ gnunet/src/cadet/gnunet-service-cadet_tunnel.c      2016-10-29 23:46:44 UTC 
(rev 38234)
@@ -96,18 +96,6 @@
 
 
 /**
- * Encryption systems possible.
- */
-enum CadetTunnelEncryption
-{
-  /**
-   * Default Axolotl system.
-   */
-  CADET_Axolotl
-
-};
-
-/**
  * Struct to old keys for skipped messages while advancing the Axolotl ratchet.
  */
 struct CadetTunnelSkippedKey
@@ -267,11 +255,6 @@
   struct CadetPeer *peer;
 
   /**
-   * Type of encryption used in the tunnel.
-   */
-  enum CadetTunnelEncryption enc_type;
-
-  /**
    * Axolotl info.
    */
   struct CadetTunnelAxolotl *ax;
@@ -550,8 +533,7 @@
   conn_ok = CADET_TUNNEL_READY == t->cstate;
   enc_ok = CADET_TUNNEL_KEY_OK == t->estate
            || CADET_TUNNEL_KEY_REKEY == t->estate
-           || (CADET_TUNNEL_KEY_PING == t->estate
-               && CADET_Axolotl == t->enc_type);
+           || CADET_TUNNEL_KEY_PING == t->estate;
   ready = conn_ok && enc_ok;
   ready = ready || GCT_is_loopback (t);
   return ready;
@@ -869,7 +851,7 @@
  * @param msg Message whose header to encrypt.
  */
 static void
-t_h_encrypt (struct CadetTunnel *t, struct GNUNET_CADET_AX *msg)
+t_h_encrypt (struct CadetTunnel *t, struct GNUNET_CADET_Encrypted *msg)
 {
   struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
   struct CadetTunnelAxolotl *ax;
@@ -902,8 +884,8 @@
  * @param dst Where to decrypt header to.
  */
 static void
-t_h_decrypt (struct CadetTunnel *t, const struct GNUNET_CADET_AX *src,
-             struct GNUNET_CADET_AX *dst)
+t_h_decrypt (struct CadetTunnel *t, const struct GNUNET_CADET_Encrypted *src,
+             struct GNUNET_CADET_Encrypted *dst)
 {
   struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
   struct CadetTunnelAxolotl *ax;
@@ -941,12 +923,12 @@
  */
 static int
 try_old_ax_keys (struct CadetTunnel *t, void *dst,
-                 const struct GNUNET_CADET_AX *src, size_t size)
+                 const struct GNUNET_CADET_Encrypted *src, size_t size)
 {
   struct CadetTunnelSkippedKey *key;
   struct GNUNET_CADET_Hash *hmac;
   struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
-  struct GNUNET_CADET_AX plaintext_header;
+  struct GNUNET_CADET_Encrypted plaintext_header;
   struct GNUNET_CRYPTO_SymmetricSessionKey *valid_HK;
   size_t esize;
   size_t res;
@@ -955,7 +937,7 @@
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying old keys\n");
   hmac = &plaintext_header.hmac;
-  esize = size - sizeof (struct GNUNET_CADET_AX);
+  esize = size - sizeof (struct GNUNET_CADET_Encrypted);
 
   /* Find a correct Header Key */
   for (key = t->ax->skipped_head; NULL != key; key = key->next)
@@ -976,8 +958,8 @@
     return -1;
 
   /* Should've been checked in -cadet_connection.c handle_cadet_encrypted. */
-  GNUNET_assert (size > sizeof (struct GNUNET_CADET_AX));
-  len = size - sizeof (struct GNUNET_CADET_AX);
+  GNUNET_assert (size > sizeof (struct GNUNET_CADET_Encrypted));
+  len = size - sizeof (struct GNUNET_CADET_Encrypted);
   GNUNET_assert (len >= sizeof (struct GNUNET_MessageHeader));
 
   /* Decrypt header */
@@ -1120,20 +1102,20 @@
  */
 static int
 t_ax_decrypt_and_validate (struct CadetTunnel *t, void *dst,
-                           const struct GNUNET_CADET_AX *src, size_t size)
+                           const struct GNUNET_CADET_Encrypted *src,
+                           size_t size)
 {
   struct CadetTunnelAxolotl *ax;
   struct GNUNET_CADET_Hash msg_hmac;
   struct GNUNET_HashCode hmac;
-  struct GNUNET_CADET_AX plaintext_header;
+  struct GNUNET_CADET_Encrypted plaintext_header;
   uint32_t Np;
   uint32_t PNp;
-  size_t esize;
-  size_t osize;
+  size_t esize; /* Size of encryped payload */
+  size_t osize; /* Size of output (decrypted payload) */
 
+  esize = size - sizeof (struct GNUNET_CADET_Encrypted);
   ax = t->ax;
-  esize = size - sizeof (struct GNUNET_CADET_AX);
-
   if (NULL == ax)
     return -1;
 
@@ -1350,10 +1332,10 @@
                        struct CadetTunnelQueue *existing_q)
 {
   struct GNUNET_MessageHeader *msg;
-  struct GNUNET_CADET_AX *ax_msg;
+  struct GNUNET_CADET_Encrypted *ax_msg;
   struct CadetTunnelQueue *tq;
   size_t size = ntohs (message->size);
-  char cbuf[sizeof (struct GNUNET_CADET_AX) + size] GNUNET_ALIGN;
+  char cbuf[sizeof (struct GNUNET_CADET_Encrypted) + size] GNUNET_ALIGN;
   size_t esize;
   uint32_t mid;
   uint16_t type;
@@ -1381,11 +1363,10 @@
 
   GNUNET_assert (GNUNET_NO == GCT_is_loopback (t));
 
-  GNUNET_assert (CADET_Axolotl == t->enc_type);
-  ax_msg = (struct GNUNET_CADET_AX *) cbuf;
+  ax_msg = (struct GNUNET_CADET_Encrypted *) cbuf;
   msg = &ax_msg->header;
-  msg->size = htons (sizeof (struct GNUNET_CADET_AX) + size);
-  msg->type = htons (GNUNET_MESSAGE_TYPE_CADET_AX);
+  msg->size = htons (sizeof (struct GNUNET_CADET_Encrypted) + size);
+  msg->type = htons (GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED);
   esize = t_ax_encrypt (t, &ax_msg[1], message, size);
   ax_msg->Ns = htonl (t->ax->Ns++);
   ax_msg->PNs = htonl (t->ax->PNs);
@@ -1505,12 +1486,12 @@
 
 
 /**
- * @brief Resend the AX KX until we complete the handshake.
+ * @brief Resend the KX until we complete the handshake.
  *
  * @param cls Closure (tunnel).
  */
 static void
-ax_kx_resend (void *cls)
+kx_resend (void *cls)
 {
   struct CadetTunnel *t = cls;
 
@@ -1522,7 +1503,7 @@
     return;
   }
 
-  GCT_send_ax_kx (t, CADET_TUNNEL_KEY_SENT >= t->estate);
+  GCT_send_kx (t, CADET_TUNNEL_KEY_SENT >= t->estate);
 }
 
 
@@ -1549,98 +1530,15 @@
   if (CADET_TUNNEL_KEY_OK == t->estate)
     return;
 
-  if (CADET_Axolotl == t->enc_type)
+  if (NULL != t->rekey_task)
   {
-    if (NULL != t->rekey_task)
-    {
-      GNUNET_break (0);
-      GCT_debug (t, GNUNET_ERROR_TYPE_WARNING);
-      GNUNET_SCHEDULER_cancel (t->rekey_task);
-    }
-    t->rekey_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-                                                  &ax_kx_resend, t);
-  }
-}
-
-
-/**
- * Sends key exchange message on a tunnel, choosing the best connection.
- * Should not be called on loopback tunnels.
- *
- * @param t Tunnel on which this message is transmitted.
- * @param message Message to send. Function modifies it.
- *
- * @return Handle to the message in the connection queue.
- */
-static struct CadetConnectionQueue *
-send_kx (struct CadetTunnel *t,
-         const struct GNUNET_MessageHeader *message)
-{
-  struct CadetConnection *c;
-  struct GNUNET_CADET_KX *msg;
-  size_t size = ntohs (message->size);
-  char cbuf[sizeof (struct GNUNET_CADET_KX) + size];
-  uint16_t type;
-  int fwd;
-
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT KX on Tunnel %s\n", GCT_2s (t));
-
-  /* Avoid loopback. */
-  if (GCT_is_loopback (t))
-  {
     GNUNET_break (0);
-    return NULL;
+    GCT_debug (t, GNUNET_ERROR_TYPE_WARNING);
+    GNUNET_SCHEDULER_cancel (t->rekey_task);
   }
-  type = ntohs (message->type);
+  t->rekey_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                                &kx_resend, t);
 
-  /* Even if tunnel is "being destroyed", send anyway.
-   * Could be a response to a rekey initiated by remote peer,
-   * who is trying to create a new channel!
-   */
-
-  /* Must have a connection, or be looking for one. */
-  if (NULL == t->connection_head)
-  {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "%s with no connection\n", GC_m2s (type));
-    if (CADET_TUNNEL_SEARCHING != t->cstate)
-    {
-      GNUNET_break (0);
-      GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
-    }
-    return NULL;
-  }
-
-  msg = (struct GNUNET_CADET_KX *) cbuf;
-  msg->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX);
-  msg->header.size = htons (sizeof (struct GNUNET_CADET_KX) + size);
-  msg->reserved = htonl (0);
-  c = tunnel_get_connection (t);
-  if (NULL == c)
-  {
-    if (NULL == t->destroy_task && CADET_TUNNEL_READY == t->cstate)
-    {
-      GNUNET_break (0);
-      GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
-    }
-    return NULL;
-  }
-  msg->cid = *GCC_get_id (c);
-  switch (type)
-  {
-    case GNUNET_MESSAGE_TYPE_CADET_AX_KX:
-      GNUNET_assert (NULL == t->ephm_h);
-      break;
-    default:
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n", GC_m2s (type));
-      GNUNET_assert (0);
-  }
-  GNUNET_memcpy (&msg[1], message, size);
-
-  fwd = GCC_is_origin (c, GNUNET_YES);
-
-  return GCC_send_prebuilt_message (&msg->header, type, 0, c,
-                                    fwd, GNUNET_YES,
-                                    &ephm_sent, t);
 }
 
 
@@ -1965,148 +1863,6 @@
 
 
 /**
- * Handle Axolotl handshake.
- *
- * @param t Tunnel this message came on.
- * @param msg Key eXchange Pong message.
- */
-static void
-handle_kx_ax (struct CadetTunnel *t, const struct GNUNET_CADET_AX_KX *msg)
-{
-  struct CadetTunnelAxolotl *ax;
-  struct GNUNET_HashCode key_material[3];
-  struct GNUNET_CRYPTO_SymmetricSessionKey keys[5];
-  const char salt[] = "CADET Axolotl salt";
-  const struct GNUNET_PeerIdentity *pid;
-  int am_I_alice;
-
-  LOG (GNUNET_ERROR_TYPE_INFO, "<== {     AX_KX} on %s\n", GCT_2s (t));
-
-  if (NULL == t->ax)
-  {
-    /* Something is wrong if ax is NULL. Whose fault it is? */
-    GNUNET_break (CADET_Axolotl == t->enc_type);
-    return;
-  }
-  ax = t->ax;
-
-  pid = GCT_get_destination (t);
-  if (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, pid))
-    am_I_alice = GNUNET_YES;
-  else if (0 < GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, pid))
-    am_I_alice = GNUNET_NO;
-  else
-  {
-    GNUNET_break_op (0);
-    return;
-  }
-
-  if (0 != (GNUNET_CADET_AX_KX_FLAG_FORCE_REPLY & ntohl (msg->flags)))
-  {
-    if (NULL != t->rekey_task)
-    {
-      GNUNET_SCHEDULER_cancel (t->rekey_task);
-      t->rekey_task = NULL;
-    }
-    GCT_send_ax_kx (t, GNUNET_NO);
-  }
-
-  if (0 == memcmp (&ax->DHRr, &msg->ratchet_key, sizeof(msg->ratchet_key)))
-  {
-    LOG (GNUNET_ERROR_TYPE_INFO, " known ratchet key, exit\n");
-    return;
-  }
-
-  LOG (GNUNET_ERROR_TYPE_INFO, " is Alice? %s\n", am_I_alice ? "YES" : "NO");
-
-  ax->DHRr = msg->ratchet_key;
-
-  /* ECDH A B0 */
-  if (GNUNET_YES == am_I_alice)
-  {
-    GNUNET_CRYPTO_eddsa_ecdh (id_key,              /* A */
-                              &msg->ephemeral_key, /* B0 */
-                              &key_material[0]);
-  }
-  else
-  {
-    GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0,            /* B0 */
-                              &pid->public_key,    /* A */
-                              &key_material[0]);
-  }
-
-  /* ECDH A0 B */
-  if (GNUNET_YES == am_I_alice)
-  {
-    GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0,            /* A0 */
-                              &pid->public_key,    /* B */
-                              &key_material[1]);
-  }
-  else
-  {
-    GNUNET_CRYPTO_eddsa_ecdh (id_key,              /* A */
-                              &msg->ephemeral_key, /* B0 */
-                              &key_material[1]);
-
-
-  }
-
-  /* ECDH A0 B0 */
-  /* (This is the triple-DH, we could probably safely skip this,
-     as A0/B0 are already in the key material.) */
-  GNUNET_CRYPTO_ecc_ecdh (ax->kx_0,             /* A0 or B0 */
-                          &msg->ephemeral_key,  /* B0 or A0 */
-                          &key_material[2]);
-
-  #if DUMP_KEYS_TO_STDERR
-  {
-    unsigned int i;
-    for (i = 0; i < 3; i++)
-      LOG (GNUNET_ERROR_TYPE_INFO, "km[%u]: %s\n",
-           i, GNUNET_h2s (&key_material[i]));
-  }
-  #endif
-
-  /* KDF */
-  GNUNET_CRYPTO_kdf (keys, sizeof (keys),
-                     salt, sizeof (salt),
-                     &key_material, sizeof (key_material), NULL);
-
-  if (0 == memcmp (&ax->RK, &keys[0], sizeof(ax->RK)))
-  {
-    LOG (GNUNET_ERROR_TYPE_INFO, " known handshake key, exit\n");
-    return;
-  }
-  ax->RK = keys[0];
-  if (GNUNET_YES == am_I_alice)
-  {
-    ax->HKr = keys[1];
-    ax->NHKs = keys[2];
-    ax->NHKr = keys[3];
-    ax->CKr = keys[4];
-    ax->ratchet_flag = GNUNET_YES;
-  }
-  else
-  {
-    ax->HKs = keys[1];
-    ax->NHKr = keys[2];
-    ax->NHKs = keys[3];
-    ax->CKs = keys[4];
-    ax->ratchet_flag = GNUNET_NO;
-    ax->ratchet_allowed = GNUNET_NO;
-    ax->ratchet_counter = 0;
-    ax->ratchet_expiration =
-      GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), ratchet_time);
-  }
-  ax->PNs = 0;
-  ax->Nr = 0;
-  ax->Ns = 0;
-  GCT_change_estate (t, CADET_TUNNEL_KEY_PING);
-  send_queued_data (t);
-}
-
-
-/**
  * Demultiplex by message type and call appropriate handler for a message
  * towards a channel of a local tunnel.
  *
@@ -2175,40 +1931,28 @@
 
/******************************************************************************/
 /********************************    API    
***********************************/
 
/******************************************************************************/
+
 /**
- * Decrypt old format and demultiplex by message type. Call appropriate handler
- * for a message towards a channel of a local tunnel.
+ * Decrypt and process an encrypted message.
  *
+ * Calls the appropriate handler for a message in a channel of a local tunnel.
+ *
  * @param t Tunnel this message came on.
  * @param msg Message header.
  */
 void
 GCT_handle_encrypted (struct CadetTunnel *t,
-                      const struct GNUNET_MessageHeader *msg)
+                      const struct GNUNET_CADET_Encrypted *msg)
 {
-  uint16_t size = ntohs (msg->size);
+  uint16_t size = ntohs (msg->header.size);
   char cbuf [size];
   int decrypted_size;
-  uint16_t type;
   const struct GNUNET_MessageHeader *msgh;
   unsigned int off;
 
-  type = ntohs (msg->type);
-  switch (type)
-  {
-  case GNUNET_MESSAGE_TYPE_CADET_AX:
-    {
-      const struct GNUNET_CADET_AX *emsg;
+  GNUNET_STATISTICS_update (stats, "# received encrypted", 1, GNUNET_NO);
 
-      GNUNET_STATISTICS_update (stats, "# received Axolotl", 1, GNUNET_NO);
-      emsg = (const struct GNUNET_CADET_AX *) msg;
-      decrypted_size = t_ax_decrypt_and_validate (t, cbuf, emsg, size);
-    }
-    break;
-  default:
-    GNUNET_break_op (0);
-    return;
-  }
+  decrypted_size = t_ax_decrypt_and_validate (t, cbuf, msg, size);
 
   if (-1 == decrypted_size)
   {
@@ -2250,35 +1994,144 @@
 
 
 /**
- * Demultiplex an encapsulated KX message by message type.
+ * Handle a Key eXchange message.
  *
  * @param t Tunnel on which the message came.
- * @param message Payload of KX message.
- *
- * FIXME: not needed anymore
- *  - substitute with call to kx_ax
- *  - eliminate encapsulation
+ * @param msg KX message itself.
  */
 void
 GCT_handle_kx (struct CadetTunnel *t,
-               const struct GNUNET_MessageHeader *message)
+               const struct GNUNET_CADET_KX *msg)
 {
-  uint16_t type;
-  char buf[256];
+  struct CadetTunnelAxolotl *ax;
+  struct GNUNET_HashCode key_material[3];
+  struct GNUNET_CRYPTO_SymmetricSessionKey keys[5];
+  const char salt[] = "CADET Axolotl salt";
+  const struct GNUNET_PeerIdentity *pid;
+  int am_I_alice;
 
-  type = ntohs (message->type);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "kx message received: %s\n", GC_m2s (type));
-  sprintf (buf, "# received KX of type %hu (%s)", type, GC_m2s (type));
-  GNUNET_STATISTICS_update (stats, buf, 1, GNUNET_NO);
-  switch (type)
+  LOG (GNUNET_ERROR_TYPE_INFO, "<== {        KX} on %s\n", GCT_2s (t));
+
+  if (NULL == t->ax)
   {
-    case GNUNET_MESSAGE_TYPE_CADET_AX_KX:
-      handle_kx_ax (t, (const struct GNUNET_CADET_AX_KX *) message);
-      break;
-    default:
-      GNUNET_break_op (0);
-      LOG (GNUNET_ERROR_TYPE_WARNING, "kx message %s unknown\n", GC_m2s 
(type));
+    /* Something is wrong if ax is NULL. Whose fault it is? */
+    return;
   }
+  ax = t->ax;
+
+  pid = GCT_get_destination (t);
+  if (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, pid))
+    am_I_alice = GNUNET_YES;
+  else if (0 < GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, pid))
+    am_I_alice = GNUNET_NO;
+  else
+  {
+    GNUNET_break_op (0);
+    return;
+  }
+
+  if (0 != (GNUNET_CADET_KX_FLAG_FORCE_REPLY & ntohl (msg->flags)))
+  {
+    if (NULL != t->rekey_task)
+    {
+      GNUNET_SCHEDULER_cancel (t->rekey_task);
+      t->rekey_task = NULL;
+    }
+    GCT_send_kx (t, GNUNET_NO);
+  }
+
+  if (0 == memcmp (&ax->DHRr, &msg->ratchet_key, sizeof(msg->ratchet_key)))
+  {
+    LOG (GNUNET_ERROR_TYPE_INFO, " known ratchet key, exit\n");
+    return;
+  }
+
+  LOG (GNUNET_ERROR_TYPE_INFO, " is Alice? %s\n", am_I_alice ? "YES" : "NO");
+
+  ax->DHRr = msg->ratchet_key;
+
+  /* ECDH A B0 */
+  if (GNUNET_YES == am_I_alice)
+  {
+    GNUNET_CRYPTO_eddsa_ecdh (id_key,              /* A */
+                              &msg->ephemeral_key, /* B0 */
+                              &key_material[0]);
+  }
+  else
+  {
+    GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0,            /* B0 */
+                              &pid->public_key,    /* A */
+                              &key_material[0]);
+  }
+
+  /* ECDH A0 B */
+  if (GNUNET_YES == am_I_alice)
+  {
+    GNUNET_CRYPTO_ecdh_eddsa (ax->kx_0,            /* A0 */
+                              &pid->public_key,    /* B */
+                              &key_material[1]);
+  }
+  else
+  {
+    GNUNET_CRYPTO_eddsa_ecdh (id_key,              /* A */
+                              &msg->ephemeral_key, /* B0 */
+                              &key_material[1]);
+
+
+  }
+
+  /* ECDH A0 B0 */
+  /* (This is the triple-DH, we could probably safely skip this,
+     as A0/B0 are already in the key material.) */
+  GNUNET_CRYPTO_ecc_ecdh (ax->kx_0,             /* A0 or B0 */
+                          &msg->ephemeral_key,  /* B0 or A0 */
+                          &key_material[2]);
+
+  #if DUMP_KEYS_TO_STDERR
+  {
+    unsigned int i;
+    for (i = 0; i < 3; i++)
+      LOG (GNUNET_ERROR_TYPE_INFO, "km[%u]: %s\n",
+           i, GNUNET_h2s (&key_material[i]));
+  }
+  #endif
+
+  /* KDF */
+  GNUNET_CRYPTO_kdf (keys, sizeof (keys),
+                     salt, sizeof (salt),
+                     &key_material, sizeof (key_material), NULL);
+
+  if (0 == memcmp (&ax->RK, &keys[0], sizeof(ax->RK)))
+  {
+    LOG (GNUNET_ERROR_TYPE_INFO, " known handshake key, exit\n");
+    return;
+  }
+  ax->RK = keys[0];
+  if (GNUNET_YES == am_I_alice)
+  {
+    ax->HKr = keys[1];
+    ax->NHKs = keys[2];
+    ax->NHKr = keys[3];
+    ax->CKr = keys[4];
+    ax->ratchet_flag = GNUNET_YES;
+  }
+  else
+  {
+    ax->HKs = keys[1];
+    ax->NHKr = keys[2];
+    ax->NHKs = keys[3];
+    ax->CKs = keys[4];
+    ax->ratchet_flag = GNUNET_NO;
+    ax->ratchet_allowed = GNUNET_NO;
+    ax->ratchet_counter = 0;
+    ax->ratchet_expiration =
+      GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), ratchet_time);
+  }
+  ax->PNs = 0;
+  ax->Nr = 0;
+  ax->Ns = 0;
+  GCT_change_estate (t, CADET_TUNNEL_KEY_PING);
+  send_queued_data (t);
 }
 
 /**
@@ -2296,7 +2149,7 @@
   LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
 
   expected_overhead = 0;
-  expected_overhead += sizeof (struct GNUNET_CADET_AX);
+  expected_overhead += sizeof (struct GNUNET_CADET_Encrypted);
   expected_overhead += sizeof (struct GNUNET_CADET_Data);
   expected_overhead += sizeof (struct GNUNET_CADET_ACK);
   GNUNET_assert (GNUNET_CONSTANTS_CADET_P2P_OVERHEAD == expected_overhead);
@@ -2396,8 +2249,8 @@
     }
     else if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate)
     {
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "  cstate triggered kx\n");
-      GCT_send_ax_kx (t, GNUNET_NO);
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "  cstate triggered KX\n");
+      GCT_send_kx (t, GNUNET_NO);
     }
     else
     {
@@ -3346,34 +3199,55 @@
 
 
 /**
- * Send an Axolotl KX message.
+ * Send a KX message.
  *
  * @param t Tunnel on which to send it.
  * @param force_reply Force the other peer to reply with a KX message.
  */
 void
-GCT_send_ax_kx (struct CadetTunnel *t, int force_reply)
+GCT_send_kx (struct CadetTunnel *t, int force_reply)
 {
-  struct GNUNET_CADET_AX_KX msg;
-  enum GNUNET_CADET_AX_KX_Flags flags;
+  struct CadetConnection *c;
+  struct GNUNET_CADET_KX msg;
+  enum GNUNET_CADET_KX_Flags flags;
 
-  LOG (GNUNET_ERROR_TYPE_INFO, "==> {     AX_KX} on %s\n", GCT_2s (t));
+  LOG (GNUNET_ERROR_TYPE_INFO, "==> {        KX} on %s\n", GCT_2s (t));
   if (NULL != t->ephm_h)
   {
-    LOG (GNUNET_ERROR_TYPE_INFO, "     already queued\n");
+    LOG (GNUNET_ERROR_TYPE_INFO, "     already queued, nop\n");
     return;
   }
 
+  /* Avoid loopback. */
+  if (GCT_is_loopback (t))
+  {
+    GNUNET_break (0);
+    return;
+  }
+  c = tunnel_get_connection (t);
+  if (NULL == c)
+  {
+    if (NULL == t->destroy_task && CADET_TUNNEL_READY == t->cstate)
+    {
+      GNUNET_break (0);
+      GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
+    }
+    return;
+  }
+
   msg.header.size = htons (sizeof (msg));
-  msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_AX_KX);
-  flags = GNUNET_CADET_AX_KX_FLAG_NONE;
-  if (force_reply)
-    flags |= GNUNET_CADET_AX_KX_FLAG_FORCE_REPLY;
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_KX);
+  flags = GNUNET_CADET_KX_FLAG_NONE;
+  if (GNUNET_YES == force_reply)
+    flags |= GNUNET_CADET_KX_FLAG_FORCE_REPLY;
   msg.flags = htonl (flags);
+  msg.cid = *GCC_get_id (c);
   GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->kx_0, &msg.ephemeral_key);
   GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->DHRs, &msg.ratchet_key);
 
-  t->ephm_h = send_kx (t, &msg.header);
+  t->ephm_h = GCC_send_prebuilt_message (&msg.header, 0, 0,
+                                         c, GCC_is_origin (c, GNUNET_YES),
+                                         GNUNET_YES, &ephm_sent, t);
   if (CADET_TUNNEL_KEY_UNINITIALIZED == t->estate)
     GCT_change_estate (t, CADET_TUNNEL_KEY_SENT);
 }
@@ -3532,8 +3406,8 @@
 void
 GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level)
 {
-  struct CadetTChannel *iterch;
-  struct CadetTConnection *iterc;
+  struct CadetTChannel *iter_ch;
+  struct CadetTConnection *iter_c;
   int do_log;
 
   do_log = GNUNET_get_log_call_status (level & (~GNUNET_ERROR_TYPE_BULK),
@@ -3546,33 +3420,20 @@
   LOG2 (level, "TTT  cstate %s, estate %s\n",
        cstate2s (t->cstate), estate2s (t->estate));
 #if DUMP_KEYS_TO_STDERR
-  if (CADET_Axolotl == t->enc_type)
-  {
-    ax_debug (t->ax, level);
-  }
-  else
-  {
-    LOG2 (level, "TTT  peers EPHM:\t %s\n",
-          GNUNET_i2s ((struct GNUNET_PeerIdentity *) &t->peers_ephemeral_key));
-    LOG2 (level, "TTT  ENC key:\t %s\n",
-          GNUNET_i2s ((struct GNUNET_PeerIdentity *) &t->e_key));
-    LOG2 (level, "TTT  DEC key:\t %s\n",
-          GNUNET_i2s ((struct GNUNET_PeerIdentity *) &t->d_key));
-  }
+  ax_debug (t->ax, level);
 #endif
   LOG2 (level, "TTT  tq_head %p, tq_tail %p\n", t->tq_head, t->tq_tail);
   LOG2 (level, "TTT  destroy %p\n", t->destroy_task);
-
   LOG2 (level, "TTT  channels:\n");
-  for (iterch = t->channel_head; NULL != iterch; iterch = iterch->next)
+  for (iter_ch = t->channel_head; NULL != iter_ch; iter_ch = iter_ch->next)
   {
-    GCCH_debug (iterch->ch, level);
+    GCCH_debug (iter_ch->ch, level);
   }
 
   LOG2 (level, "TTT  connections:\n");
-  for (iterc = t->connection_head; NULL != iterc; iterc = iterc->next)
+  for (iter_c = t->connection_head; NULL != iter_c; iter_c = iter_c->next)
   {
-    GCC_debug (iterc->c, level);
+    GCC_debug (iter_c->c, level);
   }
 
   LOG2 (level, "TTT DEBUG TUNNEL END\n");
@@ -3636,3 +3497,4 @@
   for (cht = t->channel_head; NULL != cht; cht = cht->next)
     iter (cls, cht->ch);
 }
+

Modified: gnunet/src/cadet/gnunet-service-cadet_tunnel.h
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_tunnel.h      2016-10-29 14:56:53 UTC 
(rev 38233)
+++ gnunet/src/cadet/gnunet-service-cadet_tunnel.h      2016-10-29 23:46:44 UTC 
(rev 38234)
@@ -295,26 +295,27 @@
 
 
 /**
- * Decrypt and demultiplex by message type. Call appropriate handler
- * for a message towards a channel of a local tunnel.
+ * Decrypt and process an encrypted message.
  *
+ * Calls the appropriate handler for a message in a channel of a local tunnel.
+ *
  * @param t Tunnel this message came on.
  * @param msg Message header.
  */
 void
 GCT_handle_encrypted (struct CadetTunnel *t,
-                      const struct GNUNET_MessageHeader *msg);
+                      const struct GNUNET_CADET_Encrypted *msg);
 
 
 /**
- * Demultiplex an encapsulated KX message by message type.
+ * Handle a Key eXchange message.
  *
  * @param t Tunnel on which the message came.
- * @param message KX message itself.
+ * @param msg KX message itself.
  */
 void
 GCT_handle_kx (struct CadetTunnel *t,
-               const struct GNUNET_MessageHeader *message);
+               const struct GNUNET_CADET_KX *msg);
 
 
 /**
@@ -494,13 +495,13 @@
 
 
 /**
- * Send an Axolotl KX message.
+ * Send a KX message.
  *
  * @param t Tunnel on which to send it.
  * @param force_reply Force the other peer to reply with a KX message.
  */
 void
-GCT_send_ax_kx (struct CadetTunnel *t, int force_reply);
+GCT_send_kx (struct CadetTunnel *t, int force_reply);
 
 
 /**

Modified: gnunet/src/include/gnunet_constants.h
===================================================================
--- gnunet/src/include/gnunet_constants.h       2016-10-29 14:56:53 UTC (rev 
38233)
+++ gnunet/src/include/gnunet_constants.h       2016-10-29 23:46:44 UTC (rev 
38234)
@@ -127,7 +127,7 @@
 
 /**
  * Size of the CADET message overhead:
- * + sizeof (struct GNUNET_CADET_AX)
+ * = sizeof (struct GNUNET_CADET_Encrypted)
  * + sizeof (struct GNUNET_CADET_Data)
  * + sizeof (struct GNUNET_CADET_ACK))
  *

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2016-10-29 14:56:53 UTC (rev 
38233)
+++ gnunet/src/include/gnunet_protocols.h       2016-10-29 23:46:44 UTC (rev 
38234)
@@ -2610,70 +2610,76 @@
 
/*******************************************************************************/
 
 
-/*******************************************************************************
- * CADET message types
- 
******************************************************************************/
-
-/**
- * Type of message used to transport messages throug a CADET-tunnel (LEGACY)
+/******************************************************************************/
+/***********************************  CADET  
**********************************/
+/******************************************************************************/
+/* CADET: message types 1000-1059
+ * 1000-1009 Connection-level Messages
+ * 1010-1019 Channel-level Messages
+ * 1020-1029 Local Client-Service
+ * 1030-1039 Local Service Monitoring
+ * 1040-1049 Application Data
+ * 1050-1059 Reserved
  */
-#define GNUNET_MESSAGE_TYPE_CADET 1000
 
-/**
- * Type of message used to send another peer which messages we want to receive
- * through a cadet-tunnel (LEGACY)
- */
-#define GNUNET_MESSAGE_TYPE_CADET_HELLO 1001
+/********************************  Connection  
********************************/
 
 /**
  * Request the creation of a connection
  */
-#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE 1002
+#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE 1000
 
 /**
  * Send origin an ACK that the connection is complete
  */
-#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK 1003
+#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK 1001
 
 /**
  * Notify that a connection is no longer valid
  */
-#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN 1004
+#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN 1002
 
 /**
+ * Request the destuction of a connection
+ */
+#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY 1003
+
+/**
  * At some point, the route will spontaneously change TODO
  */
-#define GNUNET_MESSAGE_TYPE_CADET_PATH_CHANGED 1005
+#define GNUNET_MESSAGE_TYPE_CADET_PATH_CHANGED 1004
 
 /**
- * Payload data (usually inside a encrypted tunnel).
+ * Hop-by-hop, connection dependent ACK.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_DATA 1006
+#define GNUNET_MESSAGE_TYPE_CADET_ACK 1005
 
 /**
- * Confirm payload data end-to-end.
+ * Poll for a hop-by-hop ACK.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_DATA_ACK 1007
+#define GNUNET_MESSAGE_TYPE_CADET_POLL 1006
 
 /**
  * Key exchange encapsulation.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_KX 1008
+#define GNUNET_MESSAGE_TYPE_CADET_KX 1007
 
 /**
- * Request the destuction of a connection
+ * Axolotl encrypted data.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY 1009
+#define GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED 1008
 
+/**********************************  Channel  
*********************************/
+
 /**
- * Hop-by-hop, connection dependent ACK.
+ * Payload data (inside an encrypted tunnel).
  */
-#define GNUNET_MESSAGE_TYPE_CADET_ACK 1010
+#define GNUNET_MESSAGE_TYPE_CADET_DATA 1010
 
 /**
- * Poll for a hop-by-hop ACK.
+ * Confirm payload data end-to-end.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_POLL 1011
+#define GNUNET_MESSAGE_TYPE_CADET_DATA_ACK 1011
 
 /**
  * Announce connection is still alive (direction sensitive).
@@ -2680,7 +2686,6 @@
  */
 #define GNUNET_MESSAGE_TYPE_CADET_KEEPALIVE 1012
 
-
 /**
  * Ask the cadet service to create a new channel.
  */
@@ -2701,87 +2706,90 @@
  */
 #define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK 1016
 
-/**
- * Axolotl key exchange.
- */
-#define GNUNET_MESSAGE_TYPE_CADET_AX_KX 1017
+/***********************************  Local  
**********************************/
 
 /**
- * Axolotl encrypted data.
- */
-#define GNUNET_MESSAGE_TYPE_CADET_AX 1018
-
-/**
  * Payload client <-> service
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA 1019
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA 1020
 
 /**
  * Local ACK for data.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK 1020
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK 1021
 
 /**
  * Start listening on a port.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN 1021
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN 1022
 
 /**
  * Stop listening on a port.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE 1022
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE 1023
 
+/**********************************  Monitor  
*********************************/
+
+
 /**
  * Local information about all channels of service.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNELS 1023
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNELS 1030
 
 /**
  * Local information of service about a specific channel.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL 1024
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL 1031
 
 /**
  * Local information about all tunnels of service.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS 1025
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS 1032
 
 /**
  * Local information of service about a specific tunnel.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL 1026
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL 1033
 
 /**
  * Local information about all connections of service.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CONNECTIONS 1027
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CONNECTIONS 1034
 
 /**
  * Local information of service about a specific connection.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CONNECTION 1028
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CONNECTION 1035
 
 /**
  * Local information about all peers known to the service.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS 1029
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS 1036
 
 /**
  * Local information of service about a specific peer.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER 1030
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER 1037
 
 /**
- * Traffic (net-cat style) used by the Command Line Interface.
+ * Debug request.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_CLI 1031
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP 1038
 
+/********************************  Application  
*******************************/
+
 /**
- * Debug request.
+ * Traffic (net-cat style) used by the Command Line Interface.
  */
-#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP 1032
+#define GNUNET_MESSAGE_TYPE_CADET_CLI 1040
 
+/******************************************************************************/
 
+
+/******************************************************************************/
+/*************************************  NAT  
**********************************/
+/******************************************************************************/
+
 /**
  * Message to ask NAT service to register a client.
  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]