2 This file is part of GNUnet.
3 Copyright (C) 2001 - 2011 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Bartlomiej Polot
23 * @file cadet/cadet_protocol.h
26 #ifndef CADET_PROTOCOL_H_
27 #define CADET_PROTOCOL_H_
30 #include "gnunet_util_lib.h"
35 struct GNUNET_CADET_TunnelMessage;
39 /* keep Emacsens' auto-indent happy */
44 /******************************************************************************/
45 /******************** CADET NETWORK MESSAGES **************************/
46 /******************************************************************************/
48 GNUNET_NETWORK_STRUCT_BEGIN
51 /******************************************************************************/
52 /***************************** CONNECTION **********************************/
53 /******************************************************************************/
57 * Message for cadet connection creation.
59 struct GNUNET_CADET_ConnectionCreateMessage
62 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE
64 * Size: sizeof (struct GNUNET_CADET_ConnectionCreateMessage) +
65 * path_length * sizeof (struct GNUNET_PeerIdentity)
67 struct GNUNET_MessageHeader header;
70 * Connection options in network byte order.
71 * #GNUNET_CADET_OPTION_DEFAULT for buffered;
72 * #GNUNET_CADET_OPTION_NOBUFFER for unbuffered.
73 * Other flags are ignored and should not be set at this level.
75 uint32_t options GNUNET_PACKED;
78 * ID of the connection
80 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
83 * path_length structs defining the *whole* path from the origin [0] to the
84 * final destination [path_length-1].
86 /* struct GNUNET_PeerIdentity peers[path_length]; */
91 * Message for ack'ing a connection
93 struct GNUNET_CADET_ConnectionCreateAckMessage
96 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK
98 struct GNUNET_MessageHeader header;
103 uint32_t reserved GNUNET_PACKED;
106 * ID of the connection.
108 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
114 * Message for notifying a disconnection in a path
116 struct GNUNET_CADET_ConnectionBrokenMessage
119 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN.
121 struct GNUNET_MessageHeader header;
126 uint32_t reserved GNUNET_PACKED;
129 * ID of the connection.
131 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
136 struct GNUNET_PeerIdentity peer1;
141 struct GNUNET_PeerIdentity peer2;
146 * Message to destroy a connection.
148 struct GNUNET_CADET_ConnectionDestroyMessage
151 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
153 struct GNUNET_MessageHeader header;
158 uint32_t reserved GNUNET_PACKED;
161 * ID of the connection.
163 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
167 /******************************************************************************/
168 /******************************* TUNNEL ***********************************/
169 /******************************************************************************/
172 * Unique identifier (counter) for an encrypted message in a channel.
173 * Used to match #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK
174 * and #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL messages
175 * against the respective #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED
178 struct CadetEncryptedMessageIdentifier
181 * This number is incremented by one per message. It may wrap around.
182 * In network byte order.
184 uint32_t pid GNUNET_PACKED;
189 * Flags to be used in GNUNET_CADET_KX.
191 enum GNUNET_CADET_KX_Flags {
194 * Should the peer reply with its KX details?
196 GNUNET_CADET_KX_FLAG_NONE = 0,
199 * The peer should reply with its KX details?
201 GNUNET_CADET_KX_FLAG_FORCE_REPLY = 1
206 * Message for a Key eXchange for a tunnel.
208 struct GNUNET_CADET_TunnelKeyExchangeMessage
211 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX or
212 * #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH as part
213 * of `struct GNUNET_CADET_TunnelKeyExchangeAuthMessage`.
215 struct GNUNET_MessageHeader header;
218 * Flags for the key exchange in NBO, based on
219 * `enum GNUNET_CADET_KX_Flags`.
221 uint32_t flags GNUNET_PACKED;
224 * ID of the connection.
226 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
229 * Sender's ephemeral public ECC key encoded in a
230 * format suitable for network transmission, as created
231 * using 'gcry_sexp_sprint'.
233 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
236 * Sender's next ephemeral public ECC key encoded in a
237 * format suitable for network transmission, as created
238 * using 'gcry_sexp_sprint'.
240 struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key;
246 * Message for a Key eXchange for a tunnel, with authentication.
247 * Used as a response to the initial KX as well as for rekeying.
249 struct GNUNET_CADET_TunnelKeyExchangeAuthMessage
253 * Message header with key material.
255 struct GNUNET_CADET_TunnelKeyExchangeMessage kx;
258 * KDF-proof that sender could compute the 3-DH, used in lieu of a
259 * signature or payload data.
261 struct GNUNET_HashCode auth;
267 * Encrypted axolotl header with numbers that identify which
268 * keys in which ratchet are to be used to decrypt the body.
270 struct GNUNET_CADET_AxHeader
274 * Number of messages sent with the current ratchet key.
276 uint32_t Ns GNUNET_PACKED;
279 * Number of messages sent with the previous ratchet key.
281 uint32_t PNs GNUNET_PACKED;
284 * Current ratchet key.
286 struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
292 * Axolotl-encrypted tunnel message with application payload.
294 struct GNUNET_CADET_TunnelEncryptedMessage
297 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED
299 struct GNUNET_MessageHeader header;
303 * Reserved, for alignment.
305 uint32_t reserved GNUNET_PACKED;
308 * Maximum packet ID authorized.
310 struct CadetEncryptedMessageIdentifier cemi;
314 * ID of the connection.
316 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
319 * MAC of the encrypted message, used to verify message integrity.
320 * Everything after this value will be encrypted with the header key
323 struct GNUNET_ShortHashCode hmac;
327 * Axolotl-header that specifies which keys to use in which ratchet
328 * to decrypt the body that follows.
330 struct GNUNET_CADET_AxHeader ax_header;
333 * Number of messages sent with the current ratchet key.
335 uint32_t Ns GNUNET_PACKED;
338 * Number of messages sent with the previous ratchet key.
340 uint32_t PNs GNUNET_PACKED;
343 * Current ratchet key.
345 struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
348 * Encrypted content follows.
356 * Message to query a peer about its Flow Control status regarding a tunnel.
358 * It is NOT yet clear if we need this.
360 struct GNUNET_CADET_ConnectionHopByHopPollMessage
363 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL
365 struct GNUNET_MessageHeader header;
370 struct CadetEncryptedMessageIdentifier cemi;
373 * ID of the connection.
375 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
381 * Message to acknowledge cadet encrypted traffic, used for
382 * flow-control on a hop-by-hop basis on the connection-level. Note
383 * that we do use the @e cemi from the tunnel layer as the connection
384 * layer's header is included/shared with the tunnel layer messages,
385 * and we only do flow control for the payload.
387 struct GNUNET_CADET_ConnectionEncryptedAckMessage
390 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK
392 struct GNUNET_MessageHeader header;
395 * Maximum packet ID authorized.
397 struct CadetEncryptedMessageIdentifier cemi_max;
400 * ID of the connection.
402 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
408 /******************************************************************************/
409 /******************************* CHANNEL ***********************************/
410 /******************************************************************************/
414 * Message to create a Channel.
416 struct GNUNET_CADET_ChannelOpenMessage
419 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN
421 struct GNUNET_MessageHeader header;
426 uint32_t opt GNUNET_PACKED;
431 struct GNUNET_HashCode port;
434 * ID of the channel within the tunnel.
436 struct GNUNET_CADET_ChannelTunnelNumber ctn;
441 * Message to manage a Channel
442 * (#GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK,
443 * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY).
445 struct GNUNET_CADET_ChannelManageMessage
448 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK or
449 * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY
451 struct GNUNET_MessageHeader header;
457 uint32_t reserved GNUNET_PACKED;
463 struct GNUNET_CADET_ChannelTunnelNumber ctn;
470 * Message for cadet data traffic.
472 struct GNUNET_CADET_ChannelAppDataMessage
475 * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST,
476 * #GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN
478 struct GNUNET_MessageHeader header;
481 * Unique ID of the payload message
483 /* NEW: struct ChannelMessageIdentifier */
484 uint32_t mid GNUNET_PACKED;
489 struct GNUNET_CADET_ChannelTunnelNumber ctn;
498 * Message to acknowledge end-to-end data.
500 struct GNUNET_CADET_ChannelDataAckMessage
503 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
505 struct GNUNET_MessageHeader header;
510 struct GNUNET_CADET_ChannelTunnelNumber ctn;
513 * Bitfield of already-received messages past @e mid.
517 uint64_t futures GNUNET_PACKED;
520 * Last message ID received.
522 /* NEW: struct ChannelMessageIdentifier */
523 uint32_t mid GNUNET_PACKED;
530 * Number used to uniquely identify messages in a CADET Channel.
532 struct ChannelMessageIdentifier
535 * Unique ID of the message, cycles around, in NBO.
537 uint32_t mid GNUNET_PACKED;
542 * Message for cadet data traffic.
544 struct GNUNET_CADET_ChannelAppDataMessage
547 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA.
549 struct GNUNET_MessageHeader header;
552 * Unique ID of the payload message.
554 struct ChannelMessageIdentifier mid;
559 struct GNUNET_CADET_ChannelTunnelNumber ctn;
568 * Message to acknowledge end-to-end data.
570 struct GNUNET_CADET_ChannelDataAckMessage
573 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
575 struct GNUNET_MessageHeader header;
580 struct GNUNET_CADET_ChannelTunnelNumber ctn;
583 * Bitfield of already-received newer messages. Note that bit 0
584 * corresponds to @e mid + 1.
589 uint64_t futures GNUNET_PACKED;
592 * Next message ID expected.
594 struct ChannelMessageIdentifier mid;
600 GNUNET_NETWORK_STRUCT_END
602 #if 0 /* keep Emacsens' auto-indent happy */
609 /* ifndef CADET_PROTOCOL_H */
611 /* end of cadet_protocol.h */