- change hop-by-hop ACK to be per-connection not per-peer
[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    * Channel options.
158    */
159   uint32_t opt GNUNET_PACKED;
160 };
161
162 struct GNUNET_MESH_ChannelDestroy
163 {
164   /**
165    * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_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 data 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 tunnel
248      */
249   struct GNUNET_HashCode tid;
250
251     /**
252      * ID of the connection
253      */
254   uint32_t cid GNUNET_PACKED;
255 };
256
257
258 /**
259  * Message to query a peer about its Flow Control status regarding a tunnel.
260  */
261 struct GNUNET_MESH_Poll
262 {
263   /**
264    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
265    */
266   struct GNUNET_MessageHeader header;
267
268   /**
269    * Last packet sent.
270    */
271   uint32_t pid GNUNET_PACKED;
272
273     /**
274      * ID of the tunnel
275      */
276   struct GNUNET_HashCode tid;
277
278     /**
279      * ID of the connection
280      */
281   uint32_t cid GNUNET_PACKED;
282 };
283
284
285 /**
286  * Message for notifying a disconnection in a path
287  */
288 struct GNUNET_MESH_ConnectionBroken
289 {
290     /**
291      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN
292      */
293   struct GNUNET_MessageHeader header;
294
295     /**
296      * ID of the connection.
297      */
298   uint32_t cid GNUNET_PACKED;
299
300     /**
301      * ID of the tunnel
302      */
303   struct GNUNET_HashCode tid;
304
305     /**
306      * ID of the endpoint
307      */
308   struct GNUNET_PeerIdentity peer1;
309
310     /**
311      * ID of the endpoint
312      */
313   struct GNUNET_PeerIdentity peer2;
314
315   /* TODO: signature */
316 };
317
318
319 /**
320  * Message to destroy a connection.
321  */
322 struct GNUNET_MESH_ConnectionDestroy
323 {
324     /**
325      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY
326      */
327   struct GNUNET_MessageHeader header;
328
329     /**
330      * ID of the connection.
331      */
332   uint32_t cid GNUNET_PACKED;
333
334     /**
335      * ID of the tunnel
336      */
337   struct GNUNET_HashCode tid;
338
339   /* TODO: signature */
340 };
341
342
343 /**
344  * Message to keep a connection alive.
345  */
346 struct GNUNET_MESH_ConnectionKeepAlive
347 {
348   /**
349    * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE
350    */
351   struct GNUNET_MessageHeader header;
352
353   /**
354    * ID of the connection
355    */
356   uint32_t cid GNUNET_PACKED;
357
358   /**
359    * ID of the tunnel
360    */
361   struct GNUNET_HashCode tid;
362 };
363
364
365
366 GNUNET_NETWORK_STRUCT_END
367
368 #if 0                           /* keep Emacsens' auto-indent happy */
369 {
370 #endif
371 #ifdef __cplusplus
372 }
373 #endif
374
375 /* ifndef MESH_PROTOCOL_H */
376 #endif
377 /* end of mesh_protocol.h */