- use fitting data type
[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      * 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    * Unique ID of the payload message
135    */
136   uint64_t mid GNUNET_PACKED;
137
138     /**
139      * Payload follows
140      */
141 };
142
143
144 /**
145  * Message to acknowledge end-to-end data.
146  */
147 struct GNUNET_MESH_DataACK
148 {
149   /**
150    * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
151    */
152   struct GNUNET_MessageHeader header;
153
154   /**
155    * TID of the tunnel
156    */
157   uint32_t tid GNUNET_PACKED;
158
159   /**
160    * OID of the tunnel
161    */
162   struct GNUNET_PeerIdentity oid;
163
164   /**
165    * Last message ID received.
166    */
167   uint64_t mid GNUNET_PACKED;
168
169   /**
170    * Bitfield of already-received newer messages // TODO implement and use
171    * pid +  1 @ LSB
172    * pid + 64 @ MSB
173    */
174   uint64_t futures GNUNET_PACKED;
175 };
176
177
178 /**
179  * Message to acknowledge mesh data traffic.
180  */
181 struct GNUNET_MESH_ACK
182 {
183     /**
184      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
185      */
186   struct GNUNET_MessageHeader header;
187
188     /**
189      * TID of the tunnel
190      */
191   uint32_t tid GNUNET_PACKED;
192
193     /**
194      * OID of the tunnel
195      */
196   struct GNUNET_PeerIdentity oid;
197
198     /**
199      * Maximum packet ID authorized.
200      */
201   uint32_t pid GNUNET_PACKED;
202 };
203
204
205 /**
206  * Message to query a peer about its Flow Control status regarding a tunnel.
207  */
208 struct GNUNET_MESH_Poll
209 {
210   /**
211    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
212    */
213   struct GNUNET_MessageHeader header;
214
215   /**
216    * TID of the tunnel
217    */
218   uint32_t tid GNUNET_PACKED;
219
220   /**
221    * OID of the tunnel
222    */
223   struct GNUNET_PeerIdentity oid;
224
225   /**
226    * Last packet sent.
227    */
228   uint32_t pid GNUNET_PACKED;
229 };
230
231 /**
232  * Message for ack'ing a path
233  */
234 struct GNUNET_MESH_PathACK
235 {
236     /**
237      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
238      */
239   struct GNUNET_MessageHeader header;
240
241     /**
242      * TID of the tunnel
243      */
244   uint32_t tid GNUNET_PACKED;
245
246     /**
247      * OID of the tunnel
248      */
249   struct GNUNET_PeerIdentity oid;
250
251     /**
252      * ID of the endpoint
253      */
254   struct GNUNET_PeerIdentity peer_id;
255
256     /**
257      * Initial ACK value for payload.
258      */
259   uint32_t ack GNUNET_PACKED;
260
261   /* TODO: signature */
262 };
263
264
265 /**
266  * Message for notifying a disconnection in a path
267  */
268 struct GNUNET_MESH_PathBroken
269 {
270     /**
271      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
272      */
273   struct GNUNET_MessageHeader header;
274
275     /**
276      * TID of the tunnel
277      */
278   uint32_t tid GNUNET_PACKED;
279
280     /**
281      * OID of the tunnel
282      */
283   struct GNUNET_PeerIdentity oid;
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 tunnel
301  */
302 struct GNUNET_MESH_TunnelDestroy
303 {
304     /**
305      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
306      */
307   struct GNUNET_MessageHeader header;
308
309     /**
310      * TID of the tunnel
311      */
312   uint32_t tid GNUNET_PACKED;
313
314     /**
315      * OID of the tunnel
316      */
317   struct GNUNET_PeerIdentity oid;
318
319   /* TODO: signature */
320 };
321
322
323 /**
324  * Message to destroy a tunnel
325  */
326 struct GNUNET_MESH_TunnelKeepAlive
327 {
328   /**
329    * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE
330    */
331   struct GNUNET_MessageHeader header;
332   
333   /**
334    * TID of the tunnel
335    */
336   uint32_t tid GNUNET_PACKED;
337   
338   /**
339    * OID of the tunnel
340    */
341   struct GNUNET_PeerIdentity oid;
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 */