diff options
Diffstat (limited to 'src/cadet/cadet.h')
-rw-r--r-- | src/cadet/cadet.h | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h index f3f6fb6b4..163734c06 100644 --- a/src/cadet/cadet.h +++ b/src/cadet/cadet.h | |||
@@ -57,6 +57,7 @@ extern "C" | |||
57 | #include "gnunet_util_lib.h" | 57 | #include "gnunet_util_lib.h" |
58 | #include "gnunet_peer_lib.h" | 58 | #include "gnunet_peer_lib.h" |
59 | #include "gnunet_core_service.h" | 59 | #include "gnunet_core_service.h" |
60 | #include "gnunet_cadet_service.h" | ||
60 | #include "gnunet_protocols.h" | 61 | #include "gnunet_protocols.h" |
61 | #include <gnunet_cadet_service.h> | 62 | #include <gnunet_cadet_service.h> |
62 | 63 | ||
@@ -64,12 +65,22 @@ extern "C" | |||
64 | /************************** CONSTANTS ******************************/ | 65 | /************************** CONSTANTS ******************************/ |
65 | /******************************************************************************/ | 66 | /******************************************************************************/ |
66 | 67 | ||
68 | /** | ||
69 | * Minimum value for channel IDs of local clients. | ||
70 | */ | ||
67 | #define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000 | 71 | #define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000 |
68 | #define GNUNET_CADET_LOCAL_CHANNEL_ID_SERV 0xB0000000 | ||
69 | 72 | ||
73 | /** | ||
74 | * FIXME. | ||
75 | */ | ||
70 | #define HIGH_PID 0xFF000000 | 76 | #define HIGH_PID 0xFF000000 |
77 | |||
78 | /** | ||
79 | * FIXME. | ||
80 | */ | ||
71 | #define LOW_PID 0x00FFFFFF | 81 | #define LOW_PID 0x00FFFFFF |
72 | 82 | ||
83 | |||
73 | /** | 84 | /** |
74 | * Test if the two PIDs (of type `uint32_t`) are in the range where we | 85 | * Test if the two PIDs (of type `uint32_t`) are in the range where we |
75 | * have to worry about overflows. This is the case when @a pid is | 86 | * have to worry about overflows. This is the case when @a pid is |
@@ -86,6 +97,22 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
86 | 97 | ||
87 | 98 | ||
88 | /** | 99 | /** |
100 | * Number uniquely identifying a channel of a client. | ||
101 | */ | ||
102 | struct GNUNET_CADET_ClientChannelNumber | ||
103 | { | ||
104 | /** | ||
105 | * Values for channel numbering. | ||
106 | * Local channel numbers given by the service (incoming) are | ||
107 | * smaller than #GNUNET_CADET_LOCAL_CHANNEL_ID_CLI. | ||
108 | * Local channel numbers given by the client (created) are | ||
109 | * larger than #GNUNET_CADET_LOCAL_CHANNEL_ID_CLI. | ||
110 | */ | ||
111 | uint32_t channel_of_client GNUNET_PACKED; | ||
112 | }; | ||
113 | |||
114 | |||
115 | /** | ||
89 | * Message for a client to create and destroy channels. | 116 | * Message for a client to create and destroy channels. |
90 | */ | 117 | */ |
91 | struct GNUNET_CADET_PortMessage | 118 | struct GNUNET_CADET_PortMessage |
@@ -104,14 +131,6 @@ struct GNUNET_CADET_PortMessage | |||
104 | struct GNUNET_HashCode port GNUNET_PACKED; | 131 | struct GNUNET_HashCode port GNUNET_PACKED; |
105 | }; | 132 | }; |
106 | 133 | ||
107 | /** | ||
108 | * Type for channel numbering. | ||
109 | * - Local channel numbers given by the service (incoming) are >= 0xB0000000 | ||
110 | * - Local channel numbers given by the client (created) are >= 0x80000000 | ||
111 | * - Global channel numbers are < 0x80000000 | ||
112 | */ | ||
113 | typedef uint32_t CADET_ChannelNumber; | ||
114 | |||
115 | 134 | ||
116 | /** | 135 | /** |
117 | * Message for a client to create channels. | 136 | * Message for a client to create channels. |
@@ -128,7 +147,7 @@ struct GNUNET_CADET_ChannelCreateMessage | |||
128 | /** | 147 | /** |
129 | * ID of a channel controlled by this client. | 148 | * ID of a channel controlled by this client. |
130 | */ | 149 | */ |
131 | CADET_ChannelNumber channel_id GNUNET_PACKED; | 150 | struct GNUNET_CADET_ClientChannelNumber channel_id; |
132 | 151 | ||
133 | /** | 152 | /** |
134 | * Channel's peer | 153 | * Channel's peer |
@@ -158,11 +177,11 @@ struct GNUNET_CADET_ChannelDestroyMessage | |||
158 | * Size: sizeof(struct GNUNET_CADET_ChannelDestroyMessage) | 177 | * Size: sizeof(struct GNUNET_CADET_ChannelDestroyMessage) |
159 | */ | 178 | */ |
160 | struct GNUNET_MessageHeader header; | 179 | struct GNUNET_MessageHeader header; |
161 | 180 | ||
162 | /** | 181 | /** |
163 | * ID of a channel controlled by this client. | 182 | * ID of a channel controlled by this client. |
164 | */ | 183 | */ |
165 | CADET_ChannelNumber channel_id GNUNET_PACKED; | 184 | struct GNUNET_CADET_ClientChannelNumber channel_id; |
166 | }; | 185 | }; |
167 | 186 | ||
168 | 187 | ||
@@ -179,7 +198,7 @@ struct GNUNET_CADET_LocalData | |||
179 | /** | 198 | /** |
180 | * ID of the channel | 199 | * ID of the channel |
181 | */ | 200 | */ |
182 | uint32_t id GNUNET_PACKED; | 201 | struct GNUNET_CADET_ClientChannelNumber id; |
183 | 202 | ||
184 | /** | 203 | /** |
185 | * Payload follows | 204 | * Payload follows |
@@ -201,7 +220,7 @@ struct GNUNET_CADET_LocalAck | |||
201 | /** | 220 | /** |
202 | * ID of the channel allowed to send more data. | 221 | * ID of the channel allowed to send more data. |
203 | */ | 222 | */ |
204 | CADET_ChannelNumber channel_id GNUNET_PACKED; | 223 | struct GNUNET_CADET_ClientChannelNumber channel_id; |
205 | 224 | ||
206 | }; | 225 | }; |
207 | 226 | ||
@@ -220,7 +239,7 @@ struct GNUNET_CADET_LocalInfo | |||
220 | /** | 239 | /** |
221 | * ID of the channel allowed to send more data. | 240 | * ID of the channel allowed to send more data. |
222 | */ | 241 | */ |
223 | CADET_ChannelNumber channel_id GNUNET_PACKED; | 242 | struct GNUNET_CADET_ClientChannelNumber channel_id; |
224 | 243 | ||
225 | /** | 244 | /** |
226 | * ID of the owner of the channel (can be local peer). | 245 | * ID of the owner of the channel (can be local peer). |
@@ -264,6 +283,7 @@ struct GNUNET_CADET_LocalInfoPeer | |||
264 | * (each path ends in destination) */ | 283 | * (each path ends in destination) */ |
265 | }; | 284 | }; |
266 | 285 | ||
286 | |||
267 | /** | 287 | /** |
268 | * Message to inform the client about one of the tunnels in the service. | 288 | * Message to inform the client about one of the tunnels in the service. |
269 | */ | 289 | */ |
@@ -300,7 +320,7 @@ struct GNUNET_CADET_LocalInfoTunnel | |||
300 | */ | 320 | */ |
301 | uint16_t cstate GNUNET_PACKED; | 321 | uint16_t cstate GNUNET_PACKED; |
302 | 322 | ||
303 | /* If TUNNEL (no 'S'): GNUNET_PeerIdentity connection_ids[connections] */ | 323 | /* If TUNNEL (no 'S'): struct GNUNET_CADET_ConnectionTunnelIdentifier connection_ids[connections] */ |
304 | /* If TUNNEL (no 'S'): uint32_t channel_ids[channels] */ | 324 | /* If TUNNEL (no 'S'): uint32_t channel_ids[channels] */ |
305 | }; | 325 | }; |
306 | 326 | ||
@@ -366,6 +386,7 @@ GC_min_pid (uint32_t a, uint32_t b); | |||
366 | const struct GNUNET_HashCode * | 386 | const struct GNUNET_HashCode * |
367 | GC_h2hc (const struct GNUNET_CADET_Hash *id); | 387 | GC_h2hc (const struct GNUNET_CADET_Hash *id); |
368 | 388 | ||
389 | |||
369 | /** | 390 | /** |
370 | * Get a string from a Cadet Hash (256 bits). | 391 | * Get a string from a Cadet Hash (256 bits). |
371 | * WARNING: Not reentrant (based on GNUNET_h2s). | 392 | * WARNING: Not reentrant (based on GNUNET_h2s). |