#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
GNUNET_NETWORK_STRUCT_BEGIN
/**
- * Message for mesh path creation.
+ * Message for mesh connection creation.
+ * TODO onionify path, add random tunnel ID
*/
-struct GNUNET_MESH_CreateTunnel
+struct GNUNET_MESH_ConnectionCreate
{
/**
- * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE
+ * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE
*
* Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
- * path_length * sizeof (struct GNUNET_PeerIdentity)
+ * path_length * sizeof (struct GNUNET_PeerIdentity)
*/
struct GNUNET_MessageHeader header;
/**
- * Global id of the tunnel this path belongs to,
- * unique in conjunction with the origin.
- */
- uint32_t tid GNUNET_PACKED;
-
- /**
- * Tunnel options (GNUNET_MESH_OPTION_*).
+ * ID of the connection
*/
- uint32_t opt GNUNET_PACKED;
+ struct GNUNET_HashCode cid;
/**
- * Destination port.
- */
- uint32_t port GNUNET_PACKED;
-
- /**
- * TODO do not add the first hop
* path_length structs defining the *whole* path from the origin [0] to the
* final destination [path_length-1].
*/
/* struct GNUNET_PeerIdentity peers[path_length]; */
};
-
/**
- * Message for mesh data traffic.
+ * Message for ack'ing a connection
*/
-struct GNUNET_MESH_Data
+struct GNUNET_MESH_ConnectionACK
{
/**
- * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
- * GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
+ * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK
*/
struct GNUNET_MessageHeader header;
/**
- * TID of the tunnel
+ * Always 0.
*/
- uint32_t tid GNUNET_PACKED;
+ uint32_t reserved GNUNET_PACKED;
/**
- * Number of hops to live
+ * ID of the connection.
*/
- uint32_t ttl GNUNET_PACKED;
+ struct GNUNET_HashCode cid;
- /**
- * ID of the packet
- */
+ /* 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;
- /**
- * OID of the tunnel
- */
- struct GNUNET_PeerIdentity oid;
+ /**
+ * ID of the connection.
+ */
+ struct GNUNET_HashCode cid;
/**
- * Unique ID of the payload message
+ * Initialization Vector for payload encryption.
*/
- uint32_t mid GNUNET_PACKED;
+ uint64_t iv GNUNET_PACKED;
- /**
- * Payload follows
- */
-};
+ /**
+ * Number of hops to live.
+ */
+ uint32_t ttl GNUNET_PACKED;
+ /**
+ * Always 0.
+ */
+ uint32_t reserved GNUNET_PACKED;
-/**
- * Message to acknowledge end-to-end data.
- */
-struct GNUNET_MESH_DataACK
+ /**
+ * Encrypted content follows.
+ */
+};
+
+struct GNUNET_MESH_ChannelCreate
{
/**
- * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
+ * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE
*/
struct GNUNET_MessageHeader header;
/**
- * TID of the tunnel
+ * ID of the channel
*/
- uint32_t tid GNUNET_PACKED;
+ MESH_ChannelNumber chid GNUNET_PACKED;
/**
- * OID of the tunnel
+ * Destination port.
*/
- struct GNUNET_PeerIdentity oid;
+ uint32_t port GNUNET_PACKED;
/**
- * Bitfield of already-received newer messages
- * pid + 1 @ LSB
- * pid + 64 @ MSB
+ * Channel options.
*/
- uint64_t futures GNUNET_PACKED;
+ uint32_t opt GNUNET_PACKED;
+};
+struct GNUNET_MESH_ChannelManage
+{
/**
- * Last message ID received.
+ * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_{ACK|DESTROY}
*/
- uint32_t mid GNUNET_PACKED;
-};
+ struct GNUNET_MessageHeader header;
+ /**
+ * ID of the channel
+ */
+ MESH_ChannelNumber chid GNUNET_PACKED;
+};
/**
- * Message to acknowledge mesh data traffic.
+ * Message for mesh data traffic.
*/
-struct GNUNET_MESH_ACK
+struct GNUNET_MESH_Data
{
/**
- * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
+ * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
+ * GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
*/
struct GNUNET_MessageHeader header;
/**
- * TID of the tunnel
+ * Unique ID of the payload message
*/
- uint32_t tid GNUNET_PACKED;
+ uint32_t mid GNUNET_PACKED;
/**
- * OID of the tunnel
+ * ID of the channel
*/
- struct GNUNET_PeerIdentity oid;
+ MESH_ChannelNumber chid GNUNET_PACKED;
/**
- * Maximum packet ID authorized.
+ * Payload follows
*/
- uint32_t pid GNUNET_PACKED;
};
/**
- * Message to query a peer about its Flow Control status regarding a tunnel.
+ * Message to acknowledge end-to-end data.
*/
-struct GNUNET_MESH_Poll
+struct GNUNET_MESH_DataACK
{
/**
- * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
+ * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
*/
struct GNUNET_MessageHeader header;
/**
- * TID of the tunnel
+ * ID of the channel
*/
- uint32_t tid GNUNET_PACKED;
+ MESH_ChannelNumber chid GNUNET_PACKED;
/**
- * OID of the tunnel
+ * Bitfield of already-received newer messages
+ * pid + 1 @ LSB
+ * pid + 64 @ MSB
*/
- struct GNUNET_PeerIdentity oid;
+ uint64_t futures GNUNET_PACKED;
/**
- * Last packet sent.
+ * Last message ID received.
*/
- uint32_t pid GNUNET_PACKED;
+ uint32_t mid GNUNET_PACKED;
};
+
/**
- * Message for ack'ing a path
+ * Message to acknowledge mesh encrypted traffic.
*/
-struct GNUNET_MESH_PathACK
+struct GNUNET_MESH_ACK
{
/**
- * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
+ * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
*/
struct GNUNET_MessageHeader header;
/**
- * TID of the tunnel
+ * Maximum packet ID authorized.
*/
- uint32_t tid GNUNET_PACKED;
+ uint32_t ack GNUNET_PACKED;
/**
- * OID of the tunnel
+ * ID of the connection.
*/
- struct GNUNET_PeerIdentity oid;
+ struct GNUNET_HashCode cid;
+};
- /**
- * ID of the endpoint
- */
- struct GNUNET_PeerIdentity peer_id;
+
+/**
+ * Message to query a peer about its Flow Control status regarding a tunnel.
+ */
+struct GNUNET_MESH_Poll
+{
+ /**
+ * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * Last packet sent.
+ */
+ uint32_t pid GNUNET_PACKED;
/**
- * Initial ACK value for payload.
+ * ID of the connection.
*/
- uint32_t ack GNUNET_PACKED;
+ struct GNUNET_HashCode cid;
- /* TODO: signature */
};
/**
* Message for notifying a disconnection in a path
*/
-struct GNUNET_MESH_PathBroken
+struct GNUNET_MESH_ConnectionBroken
{
/**
- * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
+ * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN
*/
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
/**
- * Message to destroy a tunnel
+ * Message to destroy a connection.
*/
-struct GNUNET_MESH_TunnelDestroy
+struct GNUNET_MESH_ConnectionDestroy
{
/**
- * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
+ * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY
*/
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_TunnelKeepAlive
+struct GNUNET_MESH_ConnectionKeepAlive
{
/**
- * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_(FWD|BCK)_KEEPALIVE
+ * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE
*/
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;
};