guix-env: some update.
[oweals/gnunet.git] / src / cadet / cadet.h
index f3f6fb6b4a5f730943561bfbb6b25c72d1e57d79..99f9f265310d43645caf768b1a488953e75b1d02 100644 (file)
@@ -57,19 +57,30 @@ extern "C"
 #include "gnunet_util_lib.h"
 #include "gnunet_peer_lib.h"
 #include "gnunet_core_service.h"
+#include "gnunet_cadet_service.h"
 #include "gnunet_protocols.h"
-#include <gnunet_cadet_service.h>
+#include "gnunet_cadet_service.h"
 
 /******************************************************************************/
 /**************************       CONSTANTS      ******************************/
 /******************************************************************************/
 
-#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI        0x80000000
-#define GNUNET_CADET_LOCAL_CHANNEL_ID_SERV       0xB0000000
+/**
+ * Minimum value for channel IDs of local clients.
+ */
+#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI        0x80000000U
 
+/**
+ * FIXME.
+ */
 #define HIGH_PID                                0xFF000000
+
+/**
+ * FIXME.
+ */
 #define LOW_PID                                 0x00FFFFFF
 
+
 /**
  * Test if the two PIDs (of type `uint32_t`) are in the range where we
  * have to worry about overflows.  This is the case when @a pid is
@@ -85,6 +96,22 @@ extern "C"
 GNUNET_NETWORK_STRUCT_BEGIN
 
 
+/**
+ * Number uniquely identifying a channel of a client.
+ */
+struct GNUNET_CADET_ClientChannelNumber
+{
+  /**
+   * Values for channel numbering.
+   * Local channel numbers given by the service (incoming) are
+   * smaller than #GNUNET_CADET_LOCAL_CHANNEL_ID_CLI.
+   * Local channel numbers given by the client (created) are
+   * larger than #GNUNET_CADET_LOCAL_CHANNEL_ID_CLI.
+   */
+  uint32_t channel_of_client GNUNET_PACKED;
+};
+
+
 /**
  * Message for a client to create and destroy channels.
  */
@@ -104,31 +131,23 @@ struct GNUNET_CADET_PortMessage
   struct GNUNET_HashCode port GNUNET_PACKED;
 };
 
-/**
- * Type for channel numbering.
- * - Local channel numbers given by the service (incoming) are >= 0xB0000000
- * - Local channel numbers given by the client (created) are >= 0x80000000
- * - Global channel numbers are < 0x80000000
- */
-typedef uint32_t CADET_ChannelNumber;
-
 
 /**
  * Message for a client to create channels.
  */
-struct GNUNET_CADET_ChannelCreateMessage
+struct GNUNET_CADET_LocalChannelCreateMessage
 {
   /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE
    *
-   * Size: sizeof(struct GNUNET_CADET_ChannelCreateMessage)
+   * Size: sizeof(struct GNUNET_CADET_ChannelOpenMessageMessage)
    */
   struct GNUNET_MessageHeader header;
 
   /**
    * ID of a channel controlled by this client.
    */
-  CADET_ChannelNumber channel_id GNUNET_PACKED;
+  struct GNUNET_CADET_ClientChannelNumber ccn;
 
   /**
    * Channel's peer
@@ -148,21 +167,19 @@ struct GNUNET_CADET_ChannelCreateMessage
 
 
 /**
- * Message for a client to destroy channels.
+ * Message for or to a client to destroy tunnel.
  */
-struct GNUNET_CADET_ChannelDestroyMessage
+struct GNUNET_CADET_LocalChannelDestroyMessage
 {
   /**
-   * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY
-   *
-   * Size: sizeof(struct GNUNET_CADET_ChannelDestroyMessage)
+   * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY
    */
   struct GNUNET_MessageHeader header;
-  
+
   /**
    * ID of a channel controlled by this client.
    */
-  CADET_ChannelNumber channel_id GNUNET_PACKED;
+  struct GNUNET_CADET_ClientChannelNumber ccn;
 };
 
 
@@ -179,7 +196,7 @@ struct GNUNET_CADET_LocalData
   /**
    * ID of the channel
    */
-  uint32_t id GNUNET_PACKED;
+  struct GNUNET_CADET_ClientChannelNumber ccn;
 
   /**
    * Payload follows
@@ -201,13 +218,15 @@ struct GNUNET_CADET_LocalAck
   /**
    * ID of the channel allowed to send more data.
    */
-  CADET_ChannelNumber channel_id GNUNET_PACKED;
+  struct GNUNET_CADET_ClientChannelNumber ccn;
 
 };
 
 
 /**
  * Message to inform the client about channels in the service.
+ *
+ * TODO: split into two messages!
  */
 struct GNUNET_CADET_LocalInfo
 {
@@ -220,12 +239,7 @@ struct GNUNET_CADET_LocalInfo
   /**
    * ID of the channel allowed to send more data.
    */
-  CADET_ChannelNumber channel_id GNUNET_PACKED;
-
-  /**
-   * ID of the owner of the channel (can be local peer).
-   */
-//   struct GNUNET_PeerIdentity owner;
+  struct GNUNET_CADET_ClientChannelNumber ccn;
 
   /**
    * ID of the destination of the channel (can be local peer).
@@ -236,6 +250,8 @@ struct GNUNET_CADET_LocalInfo
 
 /**
  * Message to inform the client about one of the peers in the service.
+ *
+ * TODO: split into two messages!
  */
 struct GNUNET_CADET_LocalInfoPeer
 {
@@ -264,8 +280,11 @@ struct GNUNET_CADET_LocalInfoPeer
    * (each path ends in destination) */
 };
 
+
 /**
  * Message to inform the client about one of the tunnels in the service.
+ *
+ * TODO: split into two messages!
  */
 struct GNUNET_CADET_LocalInfoTunnel
 {
@@ -300,7 +319,7 @@ struct GNUNET_CADET_LocalInfoTunnel
    */
   uint16_t cstate GNUNET_PACKED;
 
-  /* If TUNNEL (no 'S'): GNUNET_PeerIdentity connection_ids[connections] */
+  /* If TUNNEL (no 'S'): struct GNUNET_CADET_ConnectionTunnelIdentifier connection_ids[connections] */
   /* If TUNNEL (no 'S'): uint32_t channel_ids[channels] */
 };
 
@@ -355,25 +374,6 @@ uint32_t
 GC_min_pid (uint32_t a, uint32_t b);
 
 
-/**
- * Convert a 256 bit CadetHash into a 512 HashCode to use in GNUNET_h2s,
- * multihashmap, and other HashCode-based functions.
- *
- * @param id A 256 bit hash to expand.
- *
- * @return A HashCode containing the original 256 bit hash right-padded with 0.
- */
-const struct GNUNET_HashCode *
-GC_h2hc (const struct GNUNET_CADET_Hash *id);
-
-/**
- * Get a string from a Cadet Hash (256 bits).
- * WARNING: Not reentrant (based on GNUNET_h2s).
- */
-const char *
-GC_h2s (const struct GNUNET_CADET_Hash *id);
-
-
 /**
  * Allocate a string with a hexdump of any binary data.
  *
@@ -384,7 +384,10 @@ GC_h2s (const struct GNUNET_CADET_Hash *id);
  * @return The size of the output.
  */
 size_t
-GC_bin2s (void *bin, unsigned int len, char **output);
+GC_bin2s (void *bin,
+          unsigned int len,
+          char **output);
+
 
 /**
  * Convert a message type into a string to help debug