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;
72 uint32_t reserved GNUNET_PACKED;
75 * ID of the connection
77 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
80 * path_length structs defining the *whole* path from the origin [0] to the
81 * final destination [path_length-1].
83 /* struct GNUNET_PeerIdentity peers[path_length]; */
88 * Message for ack'ing a connection
90 struct GNUNET_CADET_ConnectionCreateMessageAckMessage
93 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK
95 struct GNUNET_MessageHeader header;
100 uint32_t reserved GNUNET_PACKED;
103 * ID of the connection.
105 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
111 * Message for notifying a disconnection in a path
113 struct GNUNET_CADET_ConnectionBrokenMessage
116 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN.
118 struct GNUNET_MessageHeader header;
123 uint32_t reserved GNUNET_PACKED;
126 * ID of the connection.
128 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
133 struct GNUNET_PeerIdentity peer1;
138 struct GNUNET_PeerIdentity peer2;
143 * Message to destroy a connection.
145 struct GNUNET_CADET_ConnectionDestroyMessage
148 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
150 struct GNUNET_MessageHeader header;
155 uint32_t reserved GNUNET_PACKED;
158 * ID of the connection.
160 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
164 /******************************************************************************/
165 /******************************* TUNNEL ***********************************/
166 /******************************************************************************/
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
175 struct CadetEncryptedMessageIdentifier
178 * This number is incremented by one per message. It may wrap around.
179 * In network byte order.
181 uint32_t pid GNUNET_PACKED;
186 * Flags to be used in GNUNET_CADET_KX.
188 enum GNUNET_CADET_KX_Flags {
191 * Should the peer reply with its KX details?
193 GNUNET_CADET_KX_FLAG_NONE = 0,
196 * The peer should reply with its KX details?
198 GNUNET_CADET_KX_FLAG_FORCE_REPLY = 1
203 * Message for a Key eXchange for a tunnel.
205 struct GNUNET_CADET_TunnelKeyExchangeMessage
208 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX.
210 struct GNUNET_MessageHeader header;
213 * Flags for the key exchange in NBO, based on
214 * `enum GNUNET_CADET_KX_Flags`.
216 uint32_t flags GNUNET_PACKED;
219 * ID of the connection.
221 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
224 * Sender's ephemeral public ECC key encoded in a
225 * format suitable for network transmission, as created
226 * using 'gcry_sexp_sprint'.
228 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
231 * Sender's next ephemeral public ECC key encoded in a
232 * format suitable for network transmission, as created
233 * using 'gcry_sexp_sprint'.
235 struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key;
239 * Proof that sender could compute the 3-DH, in lieu of a signature.
241 struct GNUNET_HashCode triple_dh_proof;
247 * Axolotl tunnel message.
249 struct GNUNET_CADET_TunnelEncryptedMessage
252 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED
254 struct GNUNET_MessageHeader header;
257 * ID of the packet (hop by hop).
259 struct CadetEncryptedMessageIdentifier cemi;
262 * ID of the connection.
264 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
267 * MAC of the encrypted message, used to verify message integrity.
268 * Everything after this value will be encrypted with the header key
271 struct GNUNET_ShortHashCode hmac;
273 /**************** AX_HEADER start ****************/
276 * Number of messages sent with the current ratchet key.
278 uint32_t Ns GNUNET_PACKED;
281 * Number of messages sent with the previous ratchet key.
283 uint32_t PNs GNUNET_PACKED;
286 * Current ratchet key.
288 struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
290 /**************** AX_HEADER end ****************/
293 * Encrypted content follows.
299 * Message to query a peer about its Flow Control status regarding a tunnel.
301 * It is NOT yet clear if we need this.
303 struct GNUNET_CADET_ConnectionHopByHopPollMessage
306 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL
308 struct GNUNET_MessageHeader header;
313 struct CadetEncryptedMessageIdentifier cemi;
316 * ID of the connection.
318 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
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.
330 struct GNUNET_CADET_ConnectionEncryptedAckMessage
333 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK
335 struct GNUNET_MessageHeader header;
338 * Maximum packet ID authorized.
340 struct CadetEncryptedMessageIdentifier cemi_max;
343 * ID of the connection.
345 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
349 /******************************************************************************/
350 /******************************* CHANNEL ***********************************/
351 /******************************************************************************/
355 * Message to create a Channel.
357 struct GNUNET_CADET_ChannelOpenMessage
360 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN
362 struct GNUNET_MessageHeader header;
367 uint32_t opt GNUNET_PACKED;
372 struct GNUNET_HashCode port;
375 * ID of the channel within the tunnel.
377 struct GNUNET_CADET_ChannelTunnelNumber chid;
382 * Message to manage a Channel (CHANNEL_CREATE_ACK, CHANNEL_DESTROY).
384 struct GNUNET_CADET_ChannelManageMessage
387 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE_ACK or
388 * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY
390 struct GNUNET_MessageHeader header;
396 uint32_t reserved GNUNET_PACKED;
402 struct GNUNET_CADET_ChannelTunnelNumber chid;
409 * Message for cadet data traffic.
411 struct GNUNET_CADET_ChannelAppDataMessage
414 * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST,
415 * #GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN
417 struct GNUNET_MessageHeader header;
420 * Unique ID of the payload message
422 /* NEW: struct ChannelMessageIdentifier */
423 uint32_t mid GNUNET_PACKED;
428 struct GNUNET_CADET_ChannelTunnelNumber chid;
437 * Message to acknowledge end-to-end data.
439 struct GNUNET_CADET_ChannelDataAckMessage
442 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
444 struct GNUNET_MessageHeader header;
449 struct GNUNET_CADET_ChannelTunnelNumber chid;
452 * Bitfield of already-received newer messages
456 uint64_t futures GNUNET_PACKED;
459 * Last message ID received.
461 /* NEW: struct ChannelMessageIdentifier */
462 uint32_t mid GNUNET_PACKED;
469 * Number used to uniquely identify messages in a CADET Channel.
471 struct ChannelMessageIdentifier
474 * Unique ID of the message, cycles around, in NBO.
476 uint32_t mid GNUNET_PACKED;
481 * Message for cadet data traffic.
483 struct GNUNET_CADET_ChannelAppDataMessage
486 * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST,
487 * #GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN
489 struct GNUNET_MessageHeader header;
492 * Unique ID of the payload message.
494 struct ChannelMessageIdentifier mid;
499 struct GNUNET_CADET_ChannelTunnelNumber gid;
508 * Message to acknowledge end-to-end data.
510 struct GNUNET_CADET_ChannelDataAckMessage
513 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
515 struct GNUNET_MessageHeader header;
520 struct GNUNET_CADET_ChannelTunnelNumber gid;
523 * Bitfield of already-received messages past @e mid.
527 uint64_t futures GNUNET_PACKED;
530 * Last message ID received.
532 struct ChannelMessageIdentifier mid;
538 GNUNET_NETWORK_STRUCT_END
540 #if 0 /* keep Emacsens' auto-indent happy */
547 /* ifndef CADET_PROTOCOL_H */
549 /* end of cadet_protocol.h */