- tunnel queue
[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 for that tunnel.
66      */
67   uint32_t cid GNUNET_PACKED;
68
69     /**
70      * ID of the tunnel
71      */
72   struct GNUNET_HashCode tid;
73
74     /**
75      * path_length structs defining the *whole* path from the origin [0] to the
76      * final destination [path_length-1].
77      */
78   /* struct GNUNET_PeerIdentity peers[path_length]; */
79 };
80
81 /**
82  * Message for ack'ing a connection
83  */
84 struct GNUNET_MESH_ConnectionACK
85 {
86     /**
87      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK
88      */
89   struct GNUNET_MessageHeader header;
90
91     /**
92      * ID of the connection
93      */
94   uint32_t cid GNUNET_PACKED;
95
96     /**
97      * ID of the tunnel
98      */
99   struct GNUNET_HashCode tid;
100
101   /* TODO: signature */
102 };
103
104 /**
105  * Tunnel(ed) message.
106  */
107 struct GNUNET_MESH_Encrypted
108 {
109   /**
110    * Type: GNUNET_MESSAGE_TYPE_MESH_{FWD,BCK}
111    */
112   struct GNUNET_MessageHeader header;
113
114   /**
115    * ID of the connection.
116    */
117   uint32_t cid GNUNET_PACKED;
118
119   /**
120    * ID of the tunnel.
121    */
122   struct GNUNET_HashCode tid;
123
124   /**
125    * ID of the packet (hop by hop).
126    */
127   uint32_t pid GNUNET_PACKED;
128
129   /**
130    * Number of hops to live.
131    */
132   uint32_t ttl GNUNET_PACKED;
133
134   /**
135    * Initialization Vector for payload encryption.
136    */
137   uint64_t iv;
138
139   /**
140    * Encrypted content follows.
141    */
142 };
143
144 struct GNUNET_MESH_ChannelCreate
145 {
146   /**
147    * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE
148    */
149   struct GNUNET_MessageHeader header;
150
151   /**
152    * ID of the channel
153    */
154   MESH_ChannelNumber chid GNUNET_PACKED;
155
156   /**
157    * Destination port.
158    */
159   uint32_t port GNUNET_PACKED;
160
161   /**
162    * Channel options.
163    */
164   uint32_t opt GNUNET_PACKED;
165 };
166
167 struct GNUNET_MESH_ChannelDestroy
168 {
169   /**
170    * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY
171    */
172   struct GNUNET_MessageHeader header;
173
174   /**
175    * ID of the channel
176    */
177   MESH_ChannelNumber chid GNUNET_PACKED;
178 };
179
180 /**
181  * Message for mesh data traffic.
182  */
183 struct GNUNET_MESH_Data
184 {
185     /**
186      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
187      *       GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
188      */
189   struct GNUNET_MessageHeader header;
190
191     /**
192      * Unique ID of the payload message
193      */
194   uint32_t mid GNUNET_PACKED;
195
196     /**
197      * ID of the channel
198      */
199   MESH_ChannelNumber chid GNUNET_PACKED;
200
201     /**
202      * Payload follows
203      */
204 };
205
206
207 /**
208  * Message to acknowledge end-to-end data.
209  */
210 struct GNUNET_MESH_DataACK
211 {
212   /**
213    * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
214    */
215   struct GNUNET_MessageHeader header;
216
217   /**
218    * ID of the channel
219    */
220   MESH_ChannelNumber chid GNUNET_PACKED;
221
222   /**
223    * Bitfield of already-received newer messages
224    * pid +  1 @ LSB
225    * pid + 64 @ MSB
226    */
227   uint64_t futures GNUNET_PACKED;
228
229   /**
230    * Last message ID received.
231    */
232   uint32_t mid GNUNET_PACKED;
233 };
234
235
236 /**
237  * Message to acknowledge mesh data traffic.
238  */
239 struct GNUNET_MESH_ACK
240 {
241     /**
242      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
243      */
244   struct GNUNET_MessageHeader header;
245
246     /**
247      * Maximum packet ID authorized.
248      */
249   uint32_t ack GNUNET_PACKED;
250
251     /**
252      * ID of the tunnel
253      */
254   struct GNUNET_HashCode tid;
255
256     /**
257      * ID of the connection
258      */
259   uint32_t cid GNUNET_PACKED;
260 };
261
262
263 /**
264  * Message to query a peer about its Flow Control status regarding a tunnel.
265  */
266 struct GNUNET_MESH_Poll
267 {
268   /**
269    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
270    */
271   struct GNUNET_MessageHeader header;
272
273   /**
274    * Last packet sent.
275    */
276   uint32_t pid GNUNET_PACKED;
277
278     /**
279      * ID of the tunnel
280      */
281   struct GNUNET_HashCode tid;
282
283     /**
284      * ID of the connection
285      */
286   uint32_t cid GNUNET_PACKED;
287 };
288
289
290 /**
291  * Message for notifying a disconnection in a path
292  */
293 struct GNUNET_MESH_ConnectionBroken
294 {
295     /**
296      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN
297      */
298   struct GNUNET_MessageHeader header;
299
300     /**
301      * ID of the connection.
302      */
303   uint32_t cid GNUNET_PACKED;
304
305     /**
306      * ID of the tunnel
307      */
308   struct GNUNET_HashCode tid;
309
310     /**
311      * ID of the endpoint
312      */
313   struct GNUNET_PeerIdentity peer1;
314
315     /**
316      * ID of the endpoint
317      */
318   struct GNUNET_PeerIdentity peer2;
319
320   /* TODO: signature */
321 };
322
323
324 /**
325  * Message to destroy a connection.
326  */
327 struct GNUNET_MESH_ConnectionDestroy
328 {
329     /**
330      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY
331      */
332   struct GNUNET_MessageHeader header;
333
334     /**
335      * ID of the connection.
336      */
337   uint32_t cid GNUNET_PACKED;
338
339     /**
340      * ID of the tunnel
341      */
342   struct GNUNET_HashCode tid;
343
344   /* TODO: signature */
345 };
346
347
348 /**
349  * Message to keep a connection alive.
350  */
351 struct GNUNET_MESH_ConnectionKeepAlive
352 {
353   /**
354    * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE
355    */
356   struct GNUNET_MessageHeader header;
357
358   /**
359    * ID of the connection
360    */
361   uint32_t cid GNUNET_PACKED;
362
363   /**
364    * ID of the tunnel
365    */
366   struct GNUNET_HashCode tid;
367 };
368
369
370
371 GNUNET_NETWORK_STRUCT_END
372
373 #if 0                           /* keep Emacsens' auto-indent happy */
374 {
375 #endif
376 #ifdef __cplusplus
377 }
378 #endif
379
380 /* ifndef MESH_PROTOCOL_H */
381 #endif
382 /* end of mesh_protocol.h */