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_ConnectionCreateAckMessage
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;
258 * Reserved, for alignment.
260 uint32_t reserved GNUNET_PACKED;
263 * Maximum packet ID authorized.
265 struct CadetEncryptedMessageIdentifier cemi;
269 * ID of the connection.
271 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
274 * MAC of the encrypted message, used to verify message integrity.
275 * Everything after this value will be encrypted with the header key
278 struct GNUNET_ShortHashCode hmac;
280 /**************** AX_HEADER start ****************/
283 * Number of messages sent with the current ratchet key.
285 uint32_t Ns GNUNET_PACKED;
288 * Number of messages sent with the previous ratchet key.
290 uint32_t PNs GNUNET_PACKED;
293 * Current ratchet key.
295 struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
297 /**************** AX_HEADER end ****************/
300 * Encrypted content follows.
308 * Message to query a peer about its Flow Control status regarding a tunnel.
310 * It is NOT yet clear if we need this.
312 struct GNUNET_CADET_ConnectionHopByHopPollMessage
315 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL
317 struct GNUNET_MessageHeader header;
322 struct CadetEncryptedMessageIdentifier cemi;
325 * ID of the connection.
327 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
333 * Message to acknowledge cadet encrypted traffic, used for
334 * flow-control on a hop-by-hop basis on the connection-level. Note
335 * that we do use the @e cemi from the tunnel layer as the connection
336 * layer's header is included/shared with the tunnel layer messages,
337 * and we only do flow control for the payload.
339 struct GNUNET_CADET_ConnectionEncryptedAckMessage
342 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK
344 struct GNUNET_MessageHeader header;
347 * Maximum packet ID authorized.
349 struct CadetEncryptedMessageIdentifier cemi_max;
352 * ID of the connection.
354 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
360 /******************************************************************************/
361 /******************************* CHANNEL ***********************************/
362 /******************************************************************************/
366 * Message to create a Channel.
368 struct GNUNET_CADET_ChannelOpenMessage
371 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN
373 struct GNUNET_MessageHeader header;
378 uint32_t opt GNUNET_PACKED;
383 struct GNUNET_HashCode port;
386 * ID of the channel within the tunnel.
388 struct GNUNET_CADET_ChannelTunnelNumber ctn;
393 * Message to manage a Channel
394 * (#GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK,
395 * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY).
397 struct GNUNET_CADET_ChannelManageMessage
400 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK or
401 * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY
403 struct GNUNET_MessageHeader header;
409 uint32_t reserved GNUNET_PACKED;
415 struct GNUNET_CADET_ChannelTunnelNumber ctn;
422 * Message for cadet data traffic.
424 struct GNUNET_CADET_ChannelAppDataMessage
427 * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST,
428 * #GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN
430 struct GNUNET_MessageHeader header;
433 * Unique ID of the payload message
435 /* NEW: struct ChannelMessageIdentifier */
436 uint32_t mid GNUNET_PACKED;
441 struct GNUNET_CADET_ChannelTunnelNumber ctn;
450 * Message to acknowledge end-to-end data.
452 struct GNUNET_CADET_ChannelDataAckMessage
455 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
457 struct GNUNET_MessageHeader header;
462 struct GNUNET_CADET_ChannelTunnelNumber ctn;
465 * Bitfield of already-received newer messages
469 uint64_t futures GNUNET_PACKED;
472 * Last message ID received.
474 /* NEW: struct ChannelMessageIdentifier */
475 uint32_t mid GNUNET_PACKED;
482 * Number used to uniquely identify messages in a CADET Channel.
484 struct ChannelMessageIdentifier
487 * Unique ID of the message, cycles around, in NBO.
489 uint32_t mid GNUNET_PACKED;
494 * Message for cadet data traffic.
496 struct GNUNET_CADET_ChannelAppDataMessage
499 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA.
501 struct GNUNET_MessageHeader header;
504 * Unique ID of the payload message.
506 struct ChannelMessageIdentifier mid;
511 struct GNUNET_CADET_ChannelTunnelNumber ctn;
520 * Message to acknowledge end-to-end data.
522 struct GNUNET_CADET_ChannelDataAckMessage
525 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
527 struct GNUNET_MessageHeader header;
532 struct GNUNET_CADET_ChannelTunnelNumber ctn;
535 * Bitfield of already-received messages past @e mid.
539 uint64_t futures GNUNET_PACKED;
542 * Last message ID received.
544 struct ChannelMessageIdentifier mid;
550 GNUNET_NETWORK_STRUCT_END
552 #if 0 /* keep Emacsens' auto-indent happy */
559 /* ifndef CADET_PROTOCOL_H */
561 /* end of cadet_protocol.h */