- debug
[oweals/gnunet.git] / src / mesh / mesh_protocol_enc.h
index 547ae89fcd89d9ab137c6149665d17bfb98930ec..78c3666b148b764ce980def80616e4a12a7003c3 100644 (file)
 #ifndef MESH_PROTOCOL_ENC_H_
 #define MESH_PROTOCOL_ENC_H_
 
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "mesh_enc.h"
+
 #ifdef __cplusplus
+
+struct GNUNET_MESH_TunnelMessage;
 extern "C"
 {
 #if 0
@@ -56,9 +62,9 @@ struct GNUNET_MESH_ConnectionCreate
   struct GNUNET_MessageHeader header;
 
     /**
-     * ID of the connection for that tunnel.
+     * ID of the connection
      */
-  uint32_t cid GNUNET_PACKED;
+  struct GNUNET_HashCode cid;
 
     /**
      * path_length structs defining the *whole* path from the origin [0] to the
@@ -78,18 +84,93 @@ struct GNUNET_MESH_ConnectionACK
   struct GNUNET_MessageHeader header;
 
     /**
-     * CID of the connection
+     * Always 0.
      */
-  uint32_t cid GNUNET_PACKED;
+  uint32_t reserved GNUNET_PACKED;
 
     /**
-     * TID of the tunnel
+     * ID of the connection.
      */
-  struct GNUNET_PeerIdentity tid;
+  struct GNUNET_HashCode cid;
 
   /* TODO: signature */
 };
 
+/**
+ * Tunnel(ed) message.
+ */
+struct GNUNET_MESH_Encrypted
+{
+  /**
+   * Type: GNUNET_MESSAGE_TYPE_MESH_{FWD,BCK}
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * ID of the packet (hop by hop).
+   */
+  uint32_t pid GNUNET_PACKED;
+
+  /**
+   * ID of the connection.
+   */
+  struct GNUNET_HashCode cid;
+
+  /**
+   * Initialization Vector for payload encryption.
+   */
+  uint64_t iv GNUNET_PACKED;
+
+  /**
+   * Number of hops to live.
+   */
+  uint32_t ttl GNUNET_PACKED;
+
+  /**
+   * Always 0.
+   */
+  uint32_t reserved GNUNET_PACKED;
+
+  /**
+   * Encrypted content follows.
+   */
+};
+
+struct GNUNET_MESH_ChannelCreate
+{
+  /**
+   * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * ID of the channel
+   */
+  MESH_ChannelNumber chid GNUNET_PACKED;
+
+  /**
+   * Destination port.
+   */
+  uint32_t port GNUNET_PACKED;
+
+  /**
+   * Channel options.
+   */
+  uint32_t opt GNUNET_PACKED;
+};
+
+struct GNUNET_MESH_ChannelManage
+{
+  /**
+   * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_{ACK|DESTROY}
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * ID of the channel
+   */
+  MESH_ChannelNumber chid GNUNET_PACKED;
+};
 
 /**
  * Message for mesh data traffic.
@@ -103,29 +184,14 @@ struct GNUNET_MESH_Data
   struct GNUNET_MessageHeader header;
 
     /**
-     * TID of the tunnel
+     * Unique ID of the payload message
      */
-  uint32_t tid GNUNET_PACKED;
-
-    /**
-     * Number of hops to live
-     */
-  uint32_t ttl GNUNET_PACKED;
-
-    /**
-     * ID of the packet
-     */
-  uint32_t pid GNUNET_PACKED;
+  uint32_t mid GNUNET_PACKED;
 
     /**
-     * OID of the tunnel
+     * ID of the channel
      */
-  struct GNUNET_PeerIdentity oid;
-
-  /**
-   * Unique ID of the payload message
-   */
-  uint32_t mid GNUNET_PACKED;
+  MESH_ChannelNumber chid GNUNET_PACKED;
 
     /**
      * Payload follows
@@ -146,7 +212,7 @@ struct GNUNET_MESH_DataACK
   /**
    * ID of the channel
    */
-  uint32_t id GNUNET_PACKED;
+  MESH_ChannelNumber chid GNUNET_PACKED;
 
   /**
    * Bitfield of already-received newer messages
@@ -163,7 +229,7 @@ struct GNUNET_MESH_DataACK
 
 
 /**
- * Message to acknowledge mesh data traffic.
+ * Message to acknowledge mesh encrypted traffic.
  */
 struct GNUNET_MESH_ACK
 {
@@ -178,10 +244,9 @@ struct GNUNET_MESH_ACK
   uint32_t ack GNUNET_PACKED;
 
     /**
-     * OID of the tunnel
+     * ID of the connection.
      */
-  struct GNUNET_PeerIdentity oid;
-
+  struct GNUNET_HashCode cid;
 };
 
 
@@ -199,6 +264,12 @@ struct GNUNET_MESH_Poll
    * Last packet sent.
    */
   uint32_t pid GNUNET_PACKED;
+
+    /**
+     * ID of the connection.
+     */
+  struct GNUNET_HashCode cid;
+
 };
 
 
@@ -213,14 +284,14 @@ struct GNUNET_MESH_ConnectionBroken
   struct GNUNET_MessageHeader header;
 
     /**
-     * TID of the tunnel
+     * Always 0.
      */
-  uint32_t tid GNUNET_PACKED;
+  uint32_t reserved GNUNET_PACKED;
 
     /**
-     * OID of the tunnel
+     * ID of the connection.
      */
-  struct GNUNET_PeerIdentity oid;
+  struct GNUNET_HashCode cid;
 
     /**
      * ID of the endpoint
@@ -237,7 +308,7 @@ struct GNUNET_MESH_ConnectionBroken
 
 
 /**
- * Message to destroy a tunnel
+ * Message to destroy a connection.
  */
 struct GNUNET_MESH_ConnectionDestroy
 {
@@ -247,21 +318,21 @@ struct GNUNET_MESH_ConnectionDestroy
   struct GNUNET_MessageHeader header;
 
     /**
-     * TID of the tunnel
+     * Always 0.
      */
-  uint32_t tid GNUNET_PACKED;
+  uint32_t reserved GNUNET_PACKED;
 
     /**
-     * OID of the tunnel
+     * ID of the connection.
      */
-  struct GNUNET_PeerIdentity oid;
+  struct GNUNET_HashCode cid;
 
   /* TODO: signature */
 };
 
 
 /**
- * Message to destroy a tunnel
+ * Message to keep a connection alive.
  */
 struct GNUNET_MESH_ConnectionKeepAlive
 {
@@ -269,16 +340,16 @@ struct GNUNET_MESH_ConnectionKeepAlive
    * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE
    */
   struct GNUNET_MessageHeader header;
-  
+
   /**
-   * ID of the connection
+   * Always 0.
    */
-  uint32_t cid GNUNET_PACKED;
-  
+  uint32_t reserved GNUNET_PACKED;
+
   /**
-   * ID of the tunnel
+   * ID of the connection.
    */
-  struct GNUNET_HashCode tid;
+  struct GNUNET_HashCode cid;
 };