- wip
[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    * Last packet sent.
205    */
206   uint32_t pid GNUNET_PACKED;
207 };
208
209
210 /**
211  * Message for notifying a disconnection in a path
212  */
213 struct GNUNET_MESH_ConnectionBroken
214 {
215     /**
216      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN
217      */
218   struct GNUNET_MessageHeader header;
219
220     /**
221      * TID of the tunnel
222      */
223   uint32_t tid GNUNET_PACKED;
224
225     /**
226      * OID of the tunnel
227      */
228   struct GNUNET_PeerIdentity oid;
229
230     /**
231      * ID of the endpoint
232      */
233   struct GNUNET_PeerIdentity peer1;
234
235     /**
236      * ID of the endpoint
237      */
238   struct GNUNET_PeerIdentity peer2;
239
240   /* TODO: signature */
241 };
242
243
244 /**
245  * Message to destroy a tunnel
246  */
247 struct GNUNET_MESH_ConnectionDestroy
248 {
249     /**
250      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY
251      */
252   struct GNUNET_MessageHeader header;
253
254     /**
255      * TID of the tunnel
256      */
257   uint32_t tid GNUNET_PACKED;
258
259     /**
260      * OID of the tunnel
261      */
262   struct GNUNET_PeerIdentity oid;
263
264   /* TODO: signature */
265 };
266
267
268 /**
269  * Message to destroy a tunnel
270  */
271 struct GNUNET_MESH_ConnectionKeepAlive
272 {
273   /**
274    * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE
275    */
276   struct GNUNET_MessageHeader header;
277   
278   /**
279    * ID of the connection
280    */
281   uint32_t cid GNUNET_PACKED;
282   
283   /**
284    * ID of the tunnel
285    */
286   struct GNUNET_HashCode tid;
287 };
288
289
290
291 GNUNET_NETWORK_STRUCT_END
292
293 #if 0                           /* keep Emacsens' auto-indent happy */
294 {
295 #endif
296 #ifdef __cplusplus
297 }
298 #endif
299
300 /* ifndef MESH_PROTOCOL_H */
301 #endif
302 /* end of mesh_protocol.h */