Added mesh reliable tunnels
[oweals/gnunet.git] / src / mesh / mesh_protocol.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.h
24  */
25
26 #ifndef MESH_PROTOCOL_H_
27 #define MESH_PROTOCOL_H_
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #if 0
33   /* keep Emacsens' auto-indent happy */
34 }
35 #endif
36 #endif
37
38 /******************************************************************************/
39 /********************      MESH NETWORK MESSAGES     **************************/
40 /******************************************************************************/
41
42 GNUNET_NETWORK_STRUCT_BEGIN
43
44 /**
45  * Message for mesh path creation.
46  */
47 struct GNUNET_MESH_CreateTunnel
48 {
49     /**
50      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE
51      *
52      * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
53      *       path_length * sizeof (struct GNUNET_PeerIdentity)
54      */
55   struct GNUNET_MessageHeader header;
56
57     /**
58      * Global id of the tunnel this path belongs to,
59      * unique in conjunction with the origin.
60      */
61   uint32_t tid GNUNET_PACKED;
62
63     /**
64      * Tunnel options (GNUNET_MESH_OPTION_*).
65      */
66   uint32_t opt GNUNET_PACKED;
67
68     /**
69      * Destination port.
70      */
71   uint32_t port GNUNET_PACKED;
72
73     /**
74      * FIXME do not add the first hop
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 mesh path destruction.
83  */
84 struct GNUNET_MESH_DestroyTunnel
85 {
86   /**
87    * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY
88    *
89    * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
90    *       path_length * sizeof (struct GNUNET_PeerIdentity)
91    */
92   struct GNUNET_MessageHeader header;
93   
94   /**
95    * Global id of the tunnel this path belongs to,
96    * unique in conjunction with the origin.
97    */
98   uint32_t tid GNUNET_PACKED;
99 };
100
101
102 /**
103  * Message for mesh data traffic.
104  */
105 struct GNUNET_MESH_Data
106 {
107     /**
108      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
109      *       GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
110      */
111   struct GNUNET_MessageHeader header;
112
113     /**
114      * TID of the tunnel
115      */
116   uint32_t tid GNUNET_PACKED;
117
118     /**
119      * Number of hops to live
120      */
121   uint32_t ttl GNUNET_PACKED;
122
123     /**
124      * Unique ID of the packet
125      */
126   uint32_t pid GNUNET_PACKED;
127
128     /**
129      * OID of the tunnel
130      */
131   struct GNUNET_PeerIdentity oid;
132
133     /**
134      * Payload follows
135      */
136 };
137
138
139 /**
140  * Message to acknowledge end-to-end data.
141  */
142 struct GNUNET_MESH_DataACK
143 {
144   /**
145    * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
146    */
147   struct GNUNET_MessageHeader header;
148
149   /**
150    * TID of the tunnel
151    */
152   uint32_t tid GNUNET_PACKED;
153
154   /**
155    * OID of the tunnel
156    */
157   struct GNUNET_PeerIdentity oid;
158
159   /**
160    * Maximum packet ID acknowledged.
161    */
162   uint32_t pid;
163
164   /**
165    * Bitfield of already-received newer messages // TODO implement and use
166    * pid +  1 @ LSB
167    * pid + 32 @ MSB
168    */
169   uint32_t futures;
170 };
171
172
173 /**
174  * Message to acknowledge mesh data traffic.
175  */
176 struct GNUNET_MESH_ACK
177 {
178     /**
179      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
180      */
181   struct GNUNET_MessageHeader header;
182
183     /**
184      * TID of the tunnel
185      */
186   uint32_t tid GNUNET_PACKED;
187
188     /**
189      * OID of the tunnel
190      */
191   struct GNUNET_PeerIdentity oid;
192
193     /**
194      * Maximum packet ID authorized.
195      */
196   uint32_t pid;
197 };
198
199
200 /**
201  * Message to query a peer about its Flow Control status regarding a tunnel.
202  */
203 struct GNUNET_MESH_Poll
204 {
205   /**
206    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
207    */
208   struct GNUNET_MessageHeader header;
209
210   /**
211    * TID of the tunnel
212    */
213   uint32_t tid GNUNET_PACKED;
214
215   /**
216    * OID of the tunnel
217    */
218   struct GNUNET_PeerIdentity oid;
219 };
220
221 /**
222  * Message for ack'ing a path
223  */
224 struct GNUNET_MESH_PathACK
225 {
226     /**
227      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
228      */
229   struct GNUNET_MessageHeader header;
230
231     /**
232      * TID of the tunnel
233      */
234   uint32_t tid GNUNET_PACKED;
235
236     /**
237      * OID of the tunnel
238      */
239   struct GNUNET_PeerIdentity oid;
240
241     /**
242      * ID of the endpoint
243      */
244   struct GNUNET_PeerIdentity peer_id;
245
246     /**
247      * Initial ACK value for payload.
248      */
249   uint32_t ack GNUNET_PACKED;
250
251   /* TODO: signature */
252 };
253
254
255 /**
256  * Message for notifying a disconnection in a path
257  */
258 struct GNUNET_MESH_PathBroken
259 {
260     /**
261      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
262      */
263   struct GNUNET_MessageHeader header;
264
265     /**
266      * TID of the tunnel
267      */
268   uint32_t tid GNUNET_PACKED;
269
270     /**
271      * OID of the tunnel
272      */
273   struct GNUNET_PeerIdentity oid;
274
275     /**
276      * ID of the endpoint
277      */
278   struct GNUNET_PeerIdentity peer1;
279
280     /**
281      * ID of the endpoint
282      */
283   struct GNUNET_PeerIdentity peer2;
284
285   /* TODO: signature */
286 };
287
288
289 /**
290  * Message to destroy a tunnel
291  */
292 struct GNUNET_MESH_TunnelDestroy
293 {
294     /**
295      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
296      */
297   struct GNUNET_MessageHeader header;
298
299     /**
300      * TID of the tunnel
301      */
302   uint32_t tid GNUNET_PACKED;
303
304     /**
305      * OID of the tunnel
306      */
307   struct GNUNET_PeerIdentity oid;
308
309   /* TODO: signature */
310 };
311
312
313 /**
314  * Message to destroy a tunnel
315  */
316 struct GNUNET_MESH_TunnelKeepAlive
317 {
318   /**
319    * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE
320    */
321   struct GNUNET_MessageHeader header;
322   
323   /**
324    * TID of the tunnel
325    */
326   uint32_t tid GNUNET_PACKED;
327   
328   /**
329    * OID of the tunnel
330    */
331   struct GNUNET_PeerIdentity oid;
332 };
333
334
335
336 GNUNET_NETWORK_STRUCT_END
337
338 #if 0                           /* keep Emacsens' auto-indent happy */
339 {
340 #endif
341 #ifdef __cplusplus
342 }
343 #endif
344
345 /* ifndef MESH_PROTOCOL_H */
346 #endif
347 /* end of mesh_protocol.h */