aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/cadet_protocol.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/cadet_protocol.h')
-rw-r--r--src/cadet/cadet_protocol.h253
1 files changed, 182 insertions, 71 deletions
diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h
index d034c63b0..cf32e0d6d 100644
--- a/src/cadet/cadet_protocol.h
+++ b/src/cadet/cadet_protocol.h
@@ -56,12 +56,12 @@ GNUNET_NETWORK_STRUCT_BEGIN
56/** 56/**
57 * Message for cadet connection creation. 57 * Message for cadet connection creation.
58 */ 58 */
59struct GNUNET_CADET_ConnectionCreate 59struct GNUNET_CADET_ConnectionCreateMessage
60{ 60{
61 /** 61 /**
62 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE 62 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE
63 * 63 *
64 * Size: sizeof (struct GNUNET_CADET_ConnectionCreate) + 64 * Size: sizeof (struct GNUNET_CADET_ConnectionCreateMessage) +
65 * path_length * sizeof (struct GNUNET_PeerIdentity) 65 * path_length * sizeof (struct GNUNET_PeerIdentity)
66 */ 66 */
67 struct GNUNET_MessageHeader header; 67 struct GNUNET_MessageHeader header;
@@ -70,11 +70,11 @@ struct GNUNET_CADET_ConnectionCreate
70 * For alignment. 70 * For alignment.
71 */ 71 */
72 uint32_t reserved GNUNET_PACKED; 72 uint32_t reserved GNUNET_PACKED;
73 73
74 /** 74 /**
75 * ID of the connection 75 * ID of the connection
76 */ 76 */
77 struct GNUNET_CADET_Hash cid; 77 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
78 78
79 /** 79 /**
80 * path_length structs defining the *whole* path from the origin [0] to the 80 * path_length structs defining the *whole* path from the origin [0] to the
@@ -87,10 +87,10 @@ struct GNUNET_CADET_ConnectionCreate
87/** 87/**
88 * Message for ack'ing a connection 88 * Message for ack'ing a connection
89 */ 89 */
90struct GNUNET_CADET_ConnectionACK 90struct GNUNET_CADET_ConnectionCreateMessageAckMessage
91{ 91{
92 /** 92 /**
93 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK 93 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK
94 */ 94 */
95 struct GNUNET_MessageHeader header; 95 struct GNUNET_MessageHeader header;
96 96
@@ -102,7 +102,7 @@ struct GNUNET_CADET_ConnectionACK
102 /** 102 /**
103 * ID of the connection. 103 * ID of the connection.
104 */ 104 */
105 struct GNUNET_CADET_Hash cid; 105 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
106 106
107}; 107};
108 108
@@ -110,10 +110,10 @@ struct GNUNET_CADET_ConnectionACK
110/** 110/**
111 * Message for notifying a disconnection in a path 111 * Message for notifying a disconnection in a path
112 */ 112 */
113struct GNUNET_CADET_ConnectionBroken 113struct GNUNET_CADET_ConnectionBrokenMessage
114{ 114{
115 /** 115 /**
116 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN 116 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN.
117 */ 117 */
118 struct GNUNET_MessageHeader header; 118 struct GNUNET_MessageHeader header;
119 119
@@ -125,7 +125,7 @@ struct GNUNET_CADET_ConnectionBroken
125 /** 125 /**
126 * ID of the connection. 126 * ID of the connection.
127 */ 127 */
128 struct GNUNET_CADET_Hash cid; 128 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
129 129
130 /** 130 /**
131 * ID of the endpoint 131 * ID of the endpoint
@@ -142,7 +142,7 @@ struct GNUNET_CADET_ConnectionBroken
142/** 142/**
143 * Message to destroy a connection. 143 * Message to destroy a connection.
144 */ 144 */
145struct GNUNET_CADET_ConnectionDestroy 145struct GNUNET_CADET_ConnectionDestroyMessage
146{ 146{
147 /** 147 /**
148 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY 148 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
@@ -157,60 +157,31 @@ struct GNUNET_CADET_ConnectionDestroy
157 /** 157 /**
158 * ID of the connection. 158 * ID of the connection.
159 */ 159 */
160 struct GNUNET_CADET_Hash cid; 160 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
161}; 161};
162 162
163 163
164/** 164/******************************************************************************/
165 * Message to acknowledge cadet encrypted traffic. 165/******************************* TUNNEL ***********************************/
166 */ 166/******************************************************************************/
167struct GNUNET_CADET_ACK
168{
169 /**
170 * Type: #GNUNET_MESSAGE_TYPE_CADET_ACK
171 */
172 struct GNUNET_MessageHeader header;
173
174 /**
175 * Maximum packet ID authorized.
176 */
177 uint32_t ack GNUNET_PACKED;
178
179 /**
180 * ID of the connection.
181 */
182 struct GNUNET_CADET_Hash cid;
183};
184
185 167
186/** 168/**
187 * Message to query a peer about its Flow Control status regarding a tunnel. 169 * Unique identifier (counter) for an encrypted message in a channel.
170 * Used to match #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK
171 * and #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL messages
172 * against the respective #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED
173 * messages.
188 */ 174 */
189struct GNUNET_CADET_Poll 175struct CadetEncryptedMessageIdentifier
190{ 176{
191 /** 177 /**
192 * Type: #GNUNET_MESSAGE_TYPE_CADET_POLL 178 * This number is incremented by one per message. It may wrap around.
193 */ 179 * In network byte order.
194 struct GNUNET_MessageHeader header;
195
196 /**
197 * Last packet sent.
198 */ 180 */
199 uint32_t pid GNUNET_PACKED; 181 uint32_t pid GNUNET_PACKED;
200
201 /**
202 * ID of the connection.
203 */
204 struct GNUNET_CADET_Hash cid;
205
206}; 182};
207 183
208 184
209
210/******************************************************************************/
211/******************************* TUNNEL ***********************************/
212/******************************************************************************/
213
214/** 185/**
215 * Flags to be used in GNUNET_CADET_KX. 186 * Flags to be used in GNUNET_CADET_KX.
216 */ 187 */
@@ -231,10 +202,10 @@ enum GNUNET_CADET_KX_Flags {
231/** 202/**
232 * Message for a Key eXchange for a tunnel. 203 * Message for a Key eXchange for a tunnel.
233 */ 204 */
234struct GNUNET_CADET_KX 205struct GNUNET_CADET_TunnelKeyExchangeMessage
235{ 206{
236 /** 207 /**
237 * Type: #GNUNET_MESSAGE_TYPE_CADET_KX. 208 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX.
238 */ 209 */
239 struct GNUNET_MessageHeader header; 210 struct GNUNET_MessageHeader header;
240 211
@@ -247,7 +218,7 @@ struct GNUNET_CADET_KX
247 /** 218 /**
248 * ID of the connection. 219 * ID of the connection.
249 */ 220 */
250 struct GNUNET_CADET_Hash cid; 221 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
251 222
252 /** 223 /**
253 * Sender's ephemeral public ECC key encoded in a 224 * Sender's ephemeral public ECC key encoded in a
@@ -262,35 +233,42 @@ struct GNUNET_CADET_KX
262 * using 'gcry_sexp_sprint'. 233 * using 'gcry_sexp_sprint'.
263 */ 234 */
264 struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key; 235 struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key;
236
237#ifdef NEW_CADET
238 /**
239 * Proof that sender could compute the 3-DH, in lieu of a signature.
240 */
241 struct GNUNET_HashCode triple_dh_proof;
242#endif
265}; 243};
266 244
267 245
268/** 246/**
269 * Axolotl tunnel message. 247 * Axolotl tunnel message.
270 */ 248 */
271struct GNUNET_CADET_Encrypted 249struct GNUNET_CADET_TunnelEncryptedMessage
272{ 250{
273 /** 251 /**
274 * Type: #GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED 252 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED
275 */ 253 */
276 struct GNUNET_MessageHeader header; 254 struct GNUNET_MessageHeader header;
277 255
278 /** 256 /**
279 * ID of the packet (hop by hop). 257 * ID of the packet (hop by hop).
280 */ 258 */
281 uint32_t pid GNUNET_PACKED; 259 struct CadetEncryptedMessageIdentifier cemi;
282 260
283 /** 261 /**
284 * ID of the connection. 262 * ID of the connection.
285 */ 263 */
286 struct GNUNET_CADET_Hash cid; 264 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
287 265
288 /** 266 /**
289 * MAC of the encrypted message, used to verify message integrity. 267 * MAC of the encrypted message, used to verify message integrity.
290 * Everything after this value will be encrypted with the header key 268 * Everything after this value will be encrypted with the header key
291 * and authenticated. 269 * and authenticated.
292 */ 270 */
293 struct GNUNET_CADET_Hash hmac; 271 struct GNUNET_ShortHashCode hmac;
294 272
295 /**************** AX_HEADER start ****************/ 273 /**************** AX_HEADER start ****************/
296 274
@@ -317,18 +295,69 @@ struct GNUNET_CADET_Encrypted
317}; 295};
318 296
319 297
298/**
299 * Message to query a peer about its Flow Control status regarding a tunnel.
300 *
301 * It is NOT yet clear if we need this.
302 */
303struct GNUNET_CADET_ConnectionHopByHopPollMessage
304{
305 /**
306 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL
307 */
308 struct GNUNET_MessageHeader header;
309
310 /**
311 * Last packet sent.
312 */
313 struct CadetEncryptedMessageIdentifier cemi;
314
315 /**
316 * ID of the connection.
317 */
318 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
319
320};
321
322
323/**
324 * Message to acknowledge cadet encrypted traffic, used for
325 * flow-control on a hop-by-hop basis on the connection-level. Note
326 * that we do use the @e cemi from the tunnel layer as the connection
327 * layer's header is included/shared with the tunnel layer messages,
328 * and we only do flow control for the payload.
329 */
330struct GNUNET_CADET_ConnectionEncryptedAckMessage
331{
332 /**
333 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK
334 */
335 struct GNUNET_MessageHeader header;
336
337 /**
338 * Maximum packet ID authorized.
339 */
340 struct CadetEncryptedMessageIdentifier cemi;
341
342 /**
343 * ID of the connection.
344 */
345 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
346};
347
320 348
321/******************************************************************************/ 349/******************************************************************************/
322/******************************* CHANNEL ***********************************/ 350/******************************* CHANNEL ***********************************/
323/******************************************************************************/ 351/******************************************************************************/
324 352
353
325/** 354/**
326 * Message to create a Channel. 355 * Message to create a Channel.
327 */ 356 */
328struct GNUNET_CADET_ChannelCreate 357struct GNUNET_CADET_ChannelOpenMessage
329{ 358{
330 /** 359 /**
331 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE 360 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN
332 */ 361 */
333 struct GNUNET_MessageHeader header; 362 struct GNUNET_MessageHeader header;
334 363
@@ -343,33 +372,42 @@ struct GNUNET_CADET_ChannelCreate
343 struct GNUNET_HashCode port; 372 struct GNUNET_HashCode port;
344 373
345 /** 374 /**
346 * ID of the channel 375 * ID of the channel within the tunnel.
347 */ 376 */
348 CADET_ChannelNumber chid GNUNET_PACKED; 377 struct GNUNET_CADET_ChannelTunnelNumber chid;
349}; 378};
350 379
351 380
352/** 381/**
353 * Message to manage a Channel (ACK, NACK, Destroy). 382 * Message to manage a Channel (ACK, NACK, Destroy).
354 */ 383 */
355struct GNUNET_CADET_ChannelManage 384struct GNUNET_CADET_ChannelManageMessage
356{ 385{
357 /** 386 /**
358 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_{ACK|NACK|DESTROY} 387 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_{ACK|NACK|DESTROY}
359 */ 388 */
360 struct GNUNET_MessageHeader header; 389 struct GNUNET_MessageHeader header;
361 390
391#ifdef NEW_CADET
392 /**
393 * For alignment.
394 */
395 uint32_t reserved GNUNET_PACKED;
396#endif
397
362 /** 398 /**
363 * ID of the channel 399 * ID of the channel
364 */ 400 */
365 CADET_ChannelNumber chid GNUNET_PACKED; 401 struct GNUNET_CADET_ChannelTunnelNumber chid;
366}; 402};
367 403
368 404
405#ifndef NEW_CADET
406
369/** 407/**
370 * Message for cadet data traffic. 408 * Message for cadet data traffic.
371 */ 409 */
372struct GNUNET_CADET_Data 410struct GNUNET_CADET_ChannelAppDataMessage
373{ 411{
374 /** 412 /**
375 * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST, 413 * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST,
@@ -380,12 +418,13 @@ struct GNUNET_CADET_Data
380 /** 418 /**
381 * Unique ID of the payload message 419 * Unique ID of the payload message
382 */ 420 */
421 /* NEW: struct ChannelMessageIdentifier */
383 uint32_t mid GNUNET_PACKED; 422 uint32_t mid GNUNET_PACKED;
384 423
385 /** 424 /**
386 * ID of the channel 425 * ID of the channel
387 */ 426 */
388 CADET_ChannelNumber chid GNUNET_PACKED; 427 struct GNUNET_CADET_ChannelTunnelNumber chid;
389 428
390 /** 429 /**
391 * Payload follows 430 * Payload follows
@@ -396,17 +435,17 @@ struct GNUNET_CADET_Data
396/** 435/**
397 * Message to acknowledge end-to-end data. 436 * Message to acknowledge end-to-end data.
398 */ 437 */
399struct GNUNET_CADET_DataACK 438struct GNUNET_CADET_ChannelDataAckMessage
400{ 439{
401 /** 440 /**
402 * Type: GNUNET_MESSAGE_TYPE_CADET_DATA_ACK 441 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
403 */ 442 */
404 struct GNUNET_MessageHeader header; 443 struct GNUNET_MessageHeader header;
405 444
406 /** 445 /**
407 * ID of the channel 446 * ID of the channel
408 */ 447 */
409 CADET_ChannelNumber chid GNUNET_PACKED; 448 struct GNUNET_CADET_ChannelTunnelNumber chid;
410 449
411 /** 450 /**
412 * Bitfield of already-received newer messages 451 * Bitfield of already-received newer messages
@@ -418,10 +457,82 @@ struct GNUNET_CADET_DataACK
418 /** 457 /**
419 * Last message ID received. 458 * Last message ID received.
420 */ 459 */
460 /* NEW: struct ChannelMessageIdentifier */
461 uint32_t mid GNUNET_PACKED;
462};
463
464#else
465
466
467/**
468 * Number used to uniquely identify messages in a CADET Channel.
469 */
470struct ChannelMessageIdentifier
471{
472 /**
473 * Unique ID of the message, cycles around, in NBO.
474 */
421 uint32_t mid GNUNET_PACKED; 475 uint32_t mid GNUNET_PACKED;
422}; 476};
423 477
424 478
479/**
480 * Message for cadet data traffic.
481 */
482struct GNUNET_CADET_ChannelAppDataMessage
483{
484 /**
485 * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST,
486 * #GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN
487 */
488 struct GNUNET_MessageHeader header;
489
490 /**
491 * Unique ID of the payload message.
492 */
493 struct ChannelMessageIdentifier mid;
494
495 /**
496 * ID of the channel
497 */
498 struct GNUNET_CADET_ChannelTunnelNumber gid;
499
500 /**
501 * Payload follows
502 */
503};
504
505
506/**
507 * Message to acknowledge end-to-end data.
508 */
509struct GNUNET_CADET_ChannelDataAckMessage
510{
511 /**
512 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
513 */
514 struct GNUNET_MessageHeader header;
515
516 /**
517 * ID of the channel
518 */
519 struct GNUNET_CADET_ChannelTunnelNumber gid;
520
521 /**
522 * Bitfield of already-received messages past @e mid.
523 * pid + 1 @ LSB
524 * pid + 64 @ MSB
525 */
526 uint64_t futures GNUNET_PACKED;
527
528 /**
529 * Last message ID received.
530 */
531 struct ChannelMessageIdentifier mid;
532};
533
534
535#endif
425 536
426GNUNET_NETWORK_STRUCT_END 537GNUNET_NETWORK_STRUCT_END
427 538