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