-ftbfs
[oweals/gnunet.git] / src / mesh / mesh_protocol_enc.h
1 /*
2      This file is part of GNUnet.
3      (C) 2001 - 2011 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19 */
20
21 /**
22  * @author Bartlomiej Polot
23  * @file mesh/mesh_protocol_enc.h
24  */
25
26 #ifndef MESH_PROTOCOL_ENC_H_
27 #define MESH_PROTOCOL_ENC_H_
28
29 #include "platform.h"
30 #include "gnunet_util_lib.h"
31 #include "mesh_enc.h"
32
33 #ifdef __cplusplus
34
35 struct GNUNET_MESH_TunnelMessage;
36 extern "C"
37 {
38 #if 0
39   /* keep Emacsens' auto-indent happy */
40 }
41 #endif
42 #endif
43
44 /******************************************************************************/
45 /********************      MESH NETWORK MESSAGES     **************************/
46 /******************************************************************************/
47
48 GNUNET_NETWORK_STRUCT_BEGIN
49
50 /**
51  * Message for mesh connection creation.
52  * TODO onionify path, add random tunnel ID
53  */
54 struct GNUNET_MESH_ConnectionCreate
55 {
56     /**
57      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE
58      *
59      * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
60      *              path_length * sizeof (struct GNUNET_PeerIdentity)
61      */
62   struct GNUNET_MessageHeader header;
63
64     /**
65      * ID of the connection
66      */
67   struct GNUNET_HashCode cid;
68
69     /**
70      * path_length structs defining the *whole* path from the origin [0] to the
71      * final destination [path_length-1].
72      */
73   /* struct GNUNET_PeerIdentity peers[path_length]; */
74 };
75
76 /**
77  * Message for ack'ing a connection
78  */
79 struct GNUNET_MESH_ConnectionACK
80 {
81     /**
82      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK
83      */
84   struct GNUNET_MessageHeader header;
85
86     /**
87      * Always 0.
88      */
89   uint32_t reserved GNUNET_PACKED;
90
91     /**
92      * ID of the connection.
93      */
94   struct GNUNET_HashCode cid;
95
96   /* TODO: signature */
97 };
98
99 /**
100  * Tunnel(ed) message.
101  */
102 struct GNUNET_MESH_Encrypted
103 {
104   /**
105    * Type: GNUNET_MESSAGE_TYPE_MESH_{FWD,BCK}
106    */
107   struct GNUNET_MessageHeader header;
108
109   /**
110    * ID of the packet (hop by hop).
111    */
112   uint32_t pid GNUNET_PACKED;
113
114   /**
115    * ID of the connection.
116    */
117   struct GNUNET_HashCode cid;
118
119   /**
120    * Initialization Vector for payload encryption.
121    */
122   uint64_t iv GNUNET_PACKED;
123
124   /**
125    * Number of hops to live.
126    */
127   uint32_t ttl GNUNET_PACKED;
128
129   /**
130    * Always 0.
131    */
132   uint32_t reserved GNUNET_PACKED;
133
134   /**
135    * Encrypted content follows.
136    */
137 };
138
139 struct GNUNET_MESH_ChannelCreate
140 {
141   /**
142    * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE
143    */
144   struct GNUNET_MessageHeader header;
145
146   /**
147    * ID of the channel
148    */
149   MESH_ChannelNumber chid GNUNET_PACKED;
150
151   /**
152    * Destination port.
153    */
154   uint32_t port GNUNET_PACKED;
155
156   /**
157    * Channel options.
158    */
159   uint32_t opt GNUNET_PACKED;
160 };
161
162 struct GNUNET_MESH_ChannelManage
163 {
164   /**
165    * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_{ACK|DESTROY}
166    */
167   struct GNUNET_MessageHeader header;
168
169   /**
170    * ID of the channel
171    */
172   MESH_ChannelNumber chid GNUNET_PACKED;
173 };
174
175 /**
176  * Message for mesh data traffic.
177  */
178 struct GNUNET_MESH_Data
179 {
180     /**
181      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
182      *       GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
183      */
184   struct GNUNET_MessageHeader header;
185
186     /**
187      * Unique ID of the payload message
188      */
189   uint32_t mid GNUNET_PACKED;
190
191     /**
192      * ID of the channel
193      */
194   MESH_ChannelNumber chid GNUNET_PACKED;
195
196     /**
197      * Payload follows
198      */
199 };
200
201
202 /**
203  * Message to acknowledge end-to-end data.
204  */
205 struct GNUNET_MESH_DataACK
206 {
207   /**
208    * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
209    */
210   struct GNUNET_MessageHeader header;
211
212   /**
213    * ID of the channel
214    */
215   MESH_ChannelNumber chid GNUNET_PACKED;
216
217   /**
218    * Bitfield of already-received newer messages
219    * pid +  1 @ LSB
220    * pid + 64 @ MSB
221    */
222   uint64_t futures GNUNET_PACKED;
223
224   /**
225    * Last message ID received.
226    */
227   uint32_t mid GNUNET_PACKED;
228 };
229
230
231 /**
232  * Message to acknowledge mesh encrypted traffic.
233  */
234 struct GNUNET_MESH_ACK
235 {
236     /**
237      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
238      */
239   struct GNUNET_MessageHeader header;
240
241     /**
242      * Maximum packet ID authorized.
243      */
244   uint32_t ack GNUNET_PACKED;
245
246     /**
247      * ID of the connection.
248      */
249   struct GNUNET_HashCode cid;
250 };
251
252
253 /**
254  * Message to query a peer about its Flow Control status regarding a tunnel.
255  */
256 struct GNUNET_MESH_Poll
257 {
258   /**
259    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
260    */
261   struct GNUNET_MessageHeader header;
262
263   /**
264    * Last packet sent.
265    */
266   uint32_t pid GNUNET_PACKED;
267
268     /**
269      * ID of the connection.
270      */
271   struct GNUNET_HashCode cid;
272
273 };
274
275
276 /**
277  * Message for notifying a disconnection in a path
278  */
279 struct GNUNET_MESH_ConnectionBroken
280 {
281     /**
282      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN
283      */
284   struct GNUNET_MessageHeader header;
285
286     /**
287      * Always 0.
288      */
289   uint32_t reserved GNUNET_PACKED;
290
291     /**
292      * ID of the connection.
293      */
294   struct GNUNET_HashCode cid;
295
296     /**
297      * ID of the endpoint
298      */
299   struct GNUNET_PeerIdentity peer1;
300
301     /**
302      * ID of the endpoint
303      */
304   struct GNUNET_PeerIdentity peer2;
305
306   /* TODO: signature */
307 };
308
309
310 /**
311  * Message to destroy a connection.
312  */
313 struct GNUNET_MESH_ConnectionDestroy
314 {
315     /**
316      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY
317      */
318   struct GNUNET_MessageHeader header;
319
320     /**
321      * Always 0.
322      */
323   uint32_t reserved GNUNET_PACKED;
324
325     /**
326      * ID of the connection.
327      */
328   struct GNUNET_HashCode cid;
329
330   /* TODO: signature */
331 };
332
333
334 /**
335  * Message to keep a connection alive.
336  */
337 struct GNUNET_MESH_ConnectionKeepAlive
338 {
339   /**
340    * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE
341    */
342   struct GNUNET_MessageHeader header;
343
344   /**
345    * Always 0.
346    */
347   uint32_t reserved GNUNET_PACKED;
348
349   /**
350    * ID of the connection.
351    */
352   struct GNUNET_HashCode cid;
353 };
354
355
356
357 GNUNET_NETWORK_STRUCT_END
358
359 #if 0                           /* keep Emacsens' auto-indent happy */
360 {
361 #endif
362 #ifdef __cplusplus
363 }
364 #endif
365
366 /* ifndef MESH_PROTOCOL_H */
367 #endif
368 /* end of mesh_protocol.h */