- ack is independent from tunnel
[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 #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 connection creation.
46  */
47 struct GNUNET_MESH_ConnectionCreate
48 {
49     /**
50      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_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      * ID of the connection for that tunnel.
59      */
60   uint32_t cid GNUNET_PACKED;
61
62     /**
63      * Tunnel options (GNUNET_MESH_OPTION_*).
64      */
65   uint32_t opt GNUNET_PACKED;
66
67     /**
68      * Reserved, always 0.
69      */
70   uint32_t reserved GNUNET_PACKED;
71
72     /**
73      * path_length structs defining the *whole* path from the origin [0] to the
74      * final destination [path_length-1].
75      */
76   /* struct GNUNET_PeerIdentity peers[path_length]; */
77 };
78
79 /**
80  * Message for ack'ing a connection
81  */
82 struct GNUNET_MESH_ConnectionACK
83 {
84     /**
85      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK
86      */
87   struct GNUNET_MessageHeader header;
88
89     /**
90      * CID of the connection
91      */
92   uint32_t cid GNUNET_PACKED;
93
94     /**
95      * TID of the tunnel
96      */
97   struct GNUNET_PeerIdentity tid;
98
99   /* TODO: signature */
100 };
101
102
103 /**
104  * Message for mesh data traffic.
105  */
106 struct GNUNET_MESH_Data
107 {
108     /**
109      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
110      *       GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
111      */
112   struct GNUNET_MessageHeader header;
113
114     /**
115      * TID of the tunnel
116      */
117   uint32_t tid GNUNET_PACKED;
118
119     /**
120      * Number of hops to live
121      */
122   uint32_t ttl GNUNET_PACKED;
123
124     /**
125      * ID of the packet
126      */
127   uint32_t pid GNUNET_PACKED;
128
129     /**
130      * OID of the tunnel
131      */
132   struct GNUNET_PeerIdentity oid;
133
134   /**
135    * Unique ID of the payload message
136    */
137   uint32_t mid GNUNET_PACKED;
138
139     /**
140      * Payload follows
141      */
142 };
143
144
145 /**
146  * Message to acknowledge end-to-end data.
147  */
148 struct GNUNET_MESH_DataACK
149 {
150   /**
151    * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
152    */
153   struct GNUNET_MessageHeader header;
154
155   /**
156    * TID of the tunnel
157    */
158   uint32_t tid GNUNET_PACKED;
159
160   /**
161    * OID of the tunnel
162    */
163   struct GNUNET_PeerIdentity oid;
164
165   /**
166    * Bitfield of already-received newer messages
167    * pid +  1 @ LSB
168    * pid + 64 @ MSB
169    */
170   uint64_t futures GNUNET_PACKED;
171
172   /**
173    * Last message ID received.
174    */
175   uint32_t mid GNUNET_PACKED;
176 };
177
178
179 /**
180  * Message to acknowledge mesh data traffic.
181  */
182 struct GNUNET_MESH_ACK
183 {
184     /**
185      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
186      */
187   struct GNUNET_MessageHeader header;
188
189     /**
190      * Maximum packet ID authorized.
191      */
192   uint32_t pid GNUNET_PACKED;
193
194     /**
195      * OID of the tunnel
196      */
197   struct GNUNET_PeerIdentity oid;
198
199 };
200
201
202 /**
203  * Message to query a peer about its Flow Control status regarding a tunnel.
204  */
205 struct GNUNET_MESH_Poll
206 {
207   /**
208    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
209    */
210   struct GNUNET_MessageHeader header;
211
212   /**
213    * TID of the tunnel
214    */
215   uint32_t tid GNUNET_PACKED;
216
217   /**
218    * OID of the tunnel
219    */
220   struct GNUNET_PeerIdentity oid;
221
222   /**
223    * Last packet sent.
224    */
225   uint32_t pid GNUNET_PACKED;
226 };
227
228
229 /**
230  * Message for notifying a disconnection in a path
231  */
232 struct GNUNET_MESH_ConnectionBroken
233 {
234     /**
235      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN
236      */
237   struct GNUNET_MessageHeader header;
238
239     /**
240      * TID of the tunnel
241      */
242   uint32_t tid GNUNET_PACKED;
243
244     /**
245      * OID of the tunnel
246      */
247   struct GNUNET_PeerIdentity oid;
248
249     /**
250      * ID of the endpoint
251      */
252   struct GNUNET_PeerIdentity peer1;
253
254     /**
255      * ID of the endpoint
256      */
257   struct GNUNET_PeerIdentity peer2;
258
259   /* TODO: signature */
260 };
261
262
263 /**
264  * Message to destroy a tunnel
265  */
266 struct GNUNET_MESH_ConnectionDestroy
267 {
268     /**
269      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY
270      */
271   struct GNUNET_MessageHeader header;
272
273     /**
274      * TID of the tunnel
275      */
276   uint32_t tid GNUNET_PACKED;
277
278     /**
279      * OID of the tunnel
280      */
281   struct GNUNET_PeerIdentity oid;
282
283   /* TODO: signature */
284 };
285
286
287 /**
288  * Message to destroy a tunnel
289  */
290 struct GNUNET_MESH_ConnectionKeepAlive
291 {
292   /**
293    * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_(FWD|BCK)_KEEPALIVE
294    */
295   struct GNUNET_MessageHeader header;
296   
297   /**
298    * TID of the tunnel
299    */
300   uint32_t tid GNUNET_PACKED;
301   
302   /**
303    * OID of the tunnel
304    */
305   struct GNUNET_PeerIdentity oid;
306 };
307
308
309
310 GNUNET_NETWORK_STRUCT_END
311
312 #if 0                           /* keep Emacsens' auto-indent happy */
313 {
314 #endif
315 #ifdef __cplusplus
316 }
317 #endif
318
319 /* ifndef MESH_PROTOCOL_H */
320 #endif
321 /* end of mesh_protocol.h */