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