2 This file is part of GNUnet.
3 (C) 2001 - 2011 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @author Bartlomiej Polot
23 * @file mesh/mesh_protocol.h
26 #ifndef MESH_PROTOCOL_H_
27 #define MESH_PROTOCOL_H_
30 #include "gnunet_util_lib.h"
35 struct GNUNET_MESH_TunnelMessage;
39 /* keep Emacsens' auto-indent happy */
44 /******************************************************************************/
45 /******************** MESH NETWORK MESSAGES **************************/
46 /******************************************************************************/
48 GNUNET_NETWORK_STRUCT_BEGIN
51 * Message for mesh connection creation.
52 * TODO onionify path, add random tunnel ID
54 struct GNUNET_MESH_ConnectionCreate
57 * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE
59 * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
60 * path_length * sizeof (struct GNUNET_PeerIdentity)
62 struct GNUNET_MessageHeader header;
65 * ID of the connection
67 struct GNUNET_HashCode cid;
70 * path_length structs defining the *whole* path from the origin [0] to the
71 * final destination [path_length-1].
73 /* struct GNUNET_PeerIdentity peers[path_length]; */
77 * Message for ack'ing a connection
79 struct GNUNET_MESH_ConnectionACK
82 * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK
84 struct GNUNET_MessageHeader header;
89 uint32_t reserved GNUNET_PACKED;
92 * ID of the connection.
94 struct GNUNET_HashCode cid;
101 * Message for encapsulation of a Key eXchange message in a connection.
103 struct GNUNET_MESH_KX
106 * Type: GNUNET_MESSAGE_TYPE_MESH_KX.
108 struct GNUNET_MessageHeader header;
113 uint32_t reserved GNUNET_PACKED;
116 * ID of the connection.
118 struct GNUNET_HashCode cid;
120 /* Specific KX message follows. */
125 * Message transmitted with the signed ephemeral key of a peer. The
126 * session key is then derived from the two ephemeral keys (ECDHE).
128 * As far as possible, same as CORE's EphemeralKeyMessage.
130 struct GNUNET_MESH_KX_Ephemeral
134 * Message type is GNUNET_MESSAGE_TYPE_MESH_KX_EPHEMERAL.
136 struct GNUNET_MessageHeader header;
139 * Status of the sender (should be in "enum PeerStateMachine"), nbo.
141 int32_t sender_status GNUNET_PACKED;
144 * An ECC signature of the 'origin' asserting the validity of
145 * the given ephemeral key.
147 struct GNUNET_CRYPTO_EddsaSignature signature;
150 * Information about what is being signed.
152 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
155 * At what time was this key created (beginning of validity).
157 struct GNUNET_TIME_AbsoluteNBO creation_time;
160 * When does the given ephemeral key expire (end of validity).
162 struct GNUNET_TIME_AbsoluteNBO expiration_time;
165 * Ephemeral public ECC key (always for NIST P-521) encoded in a format suitable
166 * for network transmission as created using 'gcry_sexp_sprint'.
168 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
171 * Public key of the signing peer (persistent version, not the ephemeral public key).
173 struct GNUNET_PeerIdentity origin_identity;
178 * We're sending an (encrypted) PING to the other peer to check if he
179 * can decrypt. The other peer should respond with a PONG with the
180 * same content, except this time encrypted with the receiver's key.
182 struct GNUNET_MESH_KX_Ping
185 * Message type is GNUNET_MESSAGE_TYPE_MESH_KX_PING.
187 struct GNUNET_MessageHeader header;
192 uint32_t iv GNUNET_PACKED;
195 * Intended target of the PING, used primarily to check
196 * that decryption actually worked.
198 struct GNUNET_PeerIdentity target;
201 * Random number chosen to make reply harder.
203 uint32_t nonce GNUNET_PACKED;
208 * Response to a PING. Includes data from the original PING.
210 struct GNUNET_MESH_KX_Pong
213 * Message type is GNUNET_MESSAGE_TYPE_MESH_KX_PONG.
215 struct GNUNET_MessageHeader header;
220 uint32_t iv GNUNET_PACKED;
223 * Same nonce as in the reve.
225 uint32_t nonce GNUNET_PACKED;
230 * Tunnel(ed) message.
232 struct GNUNET_MESH_Encrypted
235 * Type: GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED
237 struct GNUNET_MessageHeader header;
240 * Initialization Vector for payload encryption.
242 uint32_t iv GNUNET_PACKED;
245 * ID of the connection.
247 struct GNUNET_HashCode cid;
250 * ID of the packet (hop by hop).
252 uint32_t pid GNUNET_PACKED;
255 * Number of hops to live.
257 uint32_t ttl GNUNET_PACKED;
260 * Encrypted content follows.
264 struct GNUNET_MESH_ChannelCreate
267 * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE
269 struct GNUNET_MessageHeader header;
274 MESH_ChannelNumber chid GNUNET_PACKED;
279 uint32_t port GNUNET_PACKED;
284 uint32_t opt GNUNET_PACKED;
287 struct GNUNET_MESH_ChannelManage
290 * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_{ACK|NACK|DESTROY}
292 struct GNUNET_MessageHeader header;
297 MESH_ChannelNumber chid GNUNET_PACKED;
301 * Message for mesh data traffic.
303 struct GNUNET_MESH_Data
306 * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
307 * GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
309 struct GNUNET_MessageHeader header;
312 * Unique ID of the payload message
314 uint32_t mid GNUNET_PACKED;
319 MESH_ChannelNumber chid GNUNET_PACKED;
328 * Message to acknowledge end-to-end data.
330 struct GNUNET_MESH_DataACK
333 * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
335 struct GNUNET_MessageHeader header;
340 MESH_ChannelNumber chid GNUNET_PACKED;
343 * Bitfield of already-received newer messages
347 uint64_t futures GNUNET_PACKED;
350 * Last message ID received.
352 uint32_t mid GNUNET_PACKED;
357 * Message to acknowledge mesh encrypted traffic.
359 struct GNUNET_MESH_ACK
362 * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
364 struct GNUNET_MessageHeader header;
367 * Maximum packet ID authorized.
369 uint32_t ack GNUNET_PACKED;
372 * ID of the connection.
374 struct GNUNET_HashCode cid;
379 * Message to query a peer about its Flow Control status regarding a tunnel.
381 struct GNUNET_MESH_Poll
384 * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
386 struct GNUNET_MessageHeader header;
391 uint32_t pid GNUNET_PACKED;
394 * ID of the connection.
396 struct GNUNET_HashCode cid;
402 * Message for notifying a disconnection in a path
404 struct GNUNET_MESH_ConnectionBroken
407 * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN
409 struct GNUNET_MessageHeader header;
414 uint32_t reserved GNUNET_PACKED;
417 * ID of the connection.
419 struct GNUNET_HashCode cid;
424 struct GNUNET_PeerIdentity peer1;
429 struct GNUNET_PeerIdentity peer2;
431 /* TODO: signature */
436 * Message to destroy a connection.
438 struct GNUNET_MESH_ConnectionDestroy
441 * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY
443 struct GNUNET_MessageHeader header;
448 uint32_t reserved GNUNET_PACKED;
451 * ID of the connection.
453 struct GNUNET_HashCode cid;
455 /* TODO: signature */
460 * Message to keep a connection alive.
462 struct GNUNET_MESH_ConnectionKeepAlive
465 * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE
467 struct GNUNET_MessageHeader header;
472 uint32_t reserved GNUNET_PACKED;
475 * ID of the connection.
477 struct GNUNET_HashCode cid;
482 GNUNET_NETWORK_STRUCT_END
484 #if 0 /* keep Emacsens' auto-indent happy */
491 /* ifndef MESH_PROTOCOL_H */
493 /* end of mesh_protocol.h */