- don't use deltas, send last PID in POLL message instead
[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    * Last packet sent.
222    */
223   uint32_t pid GNUNET_PACKED;
224 };
225
226 /**
227  * Message for ack'ing a path
228  */
229 struct GNUNET_MESH_PathACK
230 {
231     /**
232      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
233      */
234   struct GNUNET_MessageHeader header;
235
236     /**
237      * TID of the tunnel
238      */
239   uint32_t tid GNUNET_PACKED;
240
241     /**
242      * OID of the tunnel
243      */
244   struct GNUNET_PeerIdentity oid;
245
246     /**
247      * ID of the endpoint
248      */
249   struct GNUNET_PeerIdentity peer_id;
250
251     /**
252      * Initial ACK value for payload.
253      */
254   uint32_t ack GNUNET_PACKED;
255
256   /* TODO: signature */
257 };
258
259
260 /**
261  * Message for notifying a disconnection in a path
262  */
263 struct GNUNET_MESH_PathBroken
264 {
265     /**
266      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
267      */
268   struct GNUNET_MessageHeader header;
269
270     /**
271      * TID of the tunnel
272      */
273   uint32_t tid GNUNET_PACKED;
274
275     /**
276      * OID of the tunnel
277      */
278   struct GNUNET_PeerIdentity oid;
279
280     /**
281      * ID of the endpoint
282      */
283   struct GNUNET_PeerIdentity peer1;
284
285     /**
286      * ID of the endpoint
287      */
288   struct GNUNET_PeerIdentity peer2;
289
290   /* TODO: signature */
291 };
292
293
294 /**
295  * Message to destroy a tunnel
296  */
297 struct GNUNET_MESH_TunnelDestroy
298 {
299     /**
300      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
301      */
302   struct GNUNET_MessageHeader header;
303
304     /**
305      * TID of the tunnel
306      */
307   uint32_t tid GNUNET_PACKED;
308
309     /**
310      * OID of the tunnel
311      */
312   struct GNUNET_PeerIdentity oid;
313
314   /* TODO: signature */
315 };
316
317
318 /**
319  * Message to destroy a tunnel
320  */
321 struct GNUNET_MESH_TunnelKeepAlive
322 {
323   /**
324    * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE
325    */
326   struct GNUNET_MessageHeader header;
327   
328   /**
329    * TID of the tunnel
330    */
331   uint32_t tid GNUNET_PACKED;
332   
333   /**
334    * OID of the tunnel
335    */
336   struct GNUNET_PeerIdentity oid;
337 };
338
339
340
341 GNUNET_NETWORK_STRUCT_END
342
343 #if 0                           /* keep Emacsens' auto-indent happy */
344 {
345 #endif
346 #ifdef __cplusplus
347 }
348 #endif
349
350 /* ifndef MESH_PROTOCOL_H */
351 #endif
352 /* end of mesh_protocol.h */