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