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;
165 * Unique identifier (counter) for an encrypted message in a channel.
166 * Used to match #GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED_HOP_BY_HOP_ACK
167 * and #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_POLL messages
168 * against the respective #GNUNET_MESSAGE_TYPE_CONNECTION_ENCRYPTED
171 struct CadetEncryptedMessageIdentifier
174 * This number is incremented by one per message. It may wrap around.
175 * In network byte order.
177 uint32_t pid GNUNET_PACKED;
182 * Message to acknowledge cadet encrypted traffic.
184 struct GNUNET_CADET_ConnectionEncryptedAckMessage
187 * Type: #GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED_HOP_BY_HOP_ACK
189 struct GNUNET_MessageHeader header;
192 * Maximum packet ID authorized.
194 struct CadetEncryptedMessageIdentifier cemi;
197 * ID of the connection.
199 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
204 * Message to query a peer about its Flow Control status regarding a tunnel.
206 struct GNUNET_CADET_ConnectionHopByHopPollMessage
209 * Type: #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_POLL
211 struct GNUNET_MessageHeader header;
216 struct CadetEncryptedMessageIdentifier cemi;
219 * ID of the connection.
221 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
227 /******************************************************************************/
228 /******************************* TUNNEL ***********************************/
229 /******************************************************************************/
232 * Flags to be used in GNUNET_CADET_KX.
234 enum GNUNET_CADET_KX_Flags {
237 * Should the peer reply with its KX details?
239 GNUNET_CADET_KX_FLAG_NONE = 0,
242 * The peer should reply with its KX details?
244 GNUNET_CADET_KX_FLAG_FORCE_REPLY = 1
249 * Message for a Key eXchange for a tunnel.
251 struct GNUNET_CADET_TunnelKeyExchangeMessage
254 * Type: #GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX.
256 struct GNUNET_MessageHeader header;
259 * Flags for the key exchange in NBO, based on
260 * `enum GNUNET_CADET_KX_Flags`.
262 uint32_t flags GNUNET_PACKED;
265 * ID of the connection.
267 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
270 * Sender's ephemeral public ECC key encoded in a
271 * format suitable for network transmission, as created
272 * using 'gcry_sexp_sprint'.
274 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
277 * Sender's next ephemeral public ECC key encoded in a
278 * format suitable for network transmission, as created
279 * using 'gcry_sexp_sprint'.
281 struct GNUNET_CRYPTO_EcdhePublicKey ratchet_key;
286 * Axolotl tunnel message.
288 struct GNUNET_CADET_ConnectionEncryptedMessage
291 * Type: #GNUNET_MESSAGE_TYPE_CONNECTION_ENCRYPTED
293 struct GNUNET_MessageHeader header;
296 * ID of the packet (hop by hop).
298 struct CadetEncryptedMessageIdentifier cemi;
301 * ID of the connection.
303 struct GNUNET_CADET_ConnectionTunnelIdentifier cid;
306 * MAC of the encrypted message, used to verify message integrity.
307 * Everything after this value will be encrypted with the header key
310 struct GNUNET_ShortHashCode hmac;
312 /**************** AX_HEADER start ****************/
315 * Number of messages sent with the current ratchet key.
317 uint32_t Ns GNUNET_PACKED;
320 * Number of messages sent with the previous ratchet key.
322 uint32_t PNs GNUNET_PACKED;
325 * Current ratchet key.
327 struct GNUNET_CRYPTO_EcdhePublicKey DHRs;
329 /**************** AX_HEADER end ****************/
332 * Encrypted content follows.
338 /******************************************************************************/
339 /******************************* CHANNEL ***********************************/
340 /******************************************************************************/
345 * Message to create a Channel.
347 struct GNUNET_CADET_ChannelCreateMessage
350 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE
352 struct GNUNET_MessageHeader header;
357 uint32_t opt GNUNET_PACKED;
362 struct GNUNET_HashCode port;
367 struct GNUNET_CADET_ChannelNumber chid;
373 * Message to manage a Channel (ACK, NACK, Destroy).
375 struct GNUNET_CADET_ChannelManageMessage
378 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_{ACK|NACK|DESTROY}
380 struct GNUNET_MessageHeader header;
385 struct GNUNET_CADET_ChannelNumber chid;
392 * Message for cadet data traffic.
394 struct GNUNET_CADET_ChannelDataMessage
397 * Type: #GNUNET_MESSAGE_TYPE_CADET_UNICAST,
398 * #GNUNET_MESSAGE_TYPE_CADET_TO_ORIGIN
400 struct GNUNET_MessageHeader header;
403 * Unique ID of the payload message
405 /* NEW: struct ChannelMessageIdentifier */
406 uint32_t mid GNUNET_PACKED;
411 struct GNUNET_CADET_ChannelNumber chid;
420 * Message to acknowledge end-to-end data.
422 struct GNUNET_CADET_ChannelDataAckMessage
425 * Type: #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DATA_ACK
427 struct GNUNET_MessageHeader header;
432 struct GNUNET_CADET_ChannelNumber chid;
435 * Bitfield of already-received newer messages
439 uint64_t futures GNUNET_PACKED;
442 * Last message ID received.
444 /* NEW: struct ChannelMessageIdentifier */
445 uint32_t mid GNUNET_PACKED;
450 GNUNET_NETWORK_STRUCT_END
452 #if 0 /* keep Emacsens' auto-indent happy */
459 /* ifndef CADET_PROTOCOL_H */
461 /* end of cadet_protocol.h */