- new P2P messages
[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 path 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      * Global id of the connection.
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      * TODO do not add the first hop
74      * path_length structs defining the *whole* path from the origin [0] to the
75      * final destination [path_length-1].
76      */
77   /* struct GNUNET_PeerIdentity peers[path_length]; */
78 };
79
80 /**
81  * Message for ack'ing a path
82  */
83 struct GNUNET_MESH_ConnnectionACK
84 {
85     /**
86      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
87      */
88   struct GNUNET_MessageHeader header;
89
90     /**
91      * CID of the connection
92      */
93   uint32_t cid GNUNET_PACKED;
94
95     /**
96      * OID of the tunnel
97      */
98   struct GNUNET_PeerIdentity oid;
99
100     /**
101      * ID of the endpoint
102      */
103   struct GNUNET_PeerIdentity peer_id;
104
105     /**
106      * Initial ACK value for payload.
107      */
108   uint32_t ack GNUNET_PACKED;
109
110   /* TODO: signature */
111 };
112
113
114 /**
115  * Message for mesh data traffic.
116  */
117 struct GNUNET_MESH_Data
118 {
119     /**
120      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
121      *       GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
122      */
123   struct GNUNET_MessageHeader header;
124
125     /**
126      * TID of the tunnel
127      */
128   uint32_t tid GNUNET_PACKED;
129
130     /**
131      * Number of hops to live
132      */
133   uint32_t ttl GNUNET_PACKED;
134
135     /**
136      * ID of the packet
137      */
138   uint32_t pid GNUNET_PACKED;
139
140     /**
141      * OID of the tunnel
142      */
143   struct GNUNET_PeerIdentity oid;
144
145   /**
146    * Unique ID of the payload message
147    */
148   uint32_t mid GNUNET_PACKED;
149
150     /**
151      * Payload follows
152      */
153 };
154
155
156 /**
157  * Message to acknowledge end-to-end data.
158  */
159 struct GNUNET_MESH_DataACK
160 {
161   /**
162    * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
163    */
164   struct GNUNET_MessageHeader header;
165
166   /**
167    * TID of the tunnel
168    */
169   uint32_t tid GNUNET_PACKED;
170
171   /**
172    * OID of the tunnel
173    */
174   struct GNUNET_PeerIdentity oid;
175
176   /**
177    * Bitfield of already-received newer messages
178    * pid +  1 @ LSB
179    * pid + 64 @ MSB
180    */
181   uint64_t futures GNUNET_PACKED;
182
183   /**
184    * Last message ID received.
185    */
186   uint32_t mid GNUNET_PACKED;
187 };
188
189
190 /**
191  * Message to acknowledge mesh data traffic.
192  */
193 struct GNUNET_MESH_ACK
194 {
195     /**
196      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
197      */
198   struct GNUNET_MessageHeader header;
199
200     /**
201      * TID of the tunnel
202      */
203   uint32_t tid GNUNET_PACKED;
204
205     /**
206      * OID of the tunnel
207      */
208   struct GNUNET_PeerIdentity oid;
209
210     /**
211      * Maximum packet ID authorized.
212      */
213   uint32_t pid GNUNET_PACKED;
214 };
215
216
217 /**
218  * Message to query a peer about its Flow Control status regarding a tunnel.
219  */
220 struct GNUNET_MESH_Poll
221 {
222   /**
223    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
224    */
225   struct GNUNET_MessageHeader header;
226
227   /**
228    * TID of the tunnel
229    */
230   uint32_t tid GNUNET_PACKED;
231
232   /**
233    * OID of the tunnel
234    */
235   struct GNUNET_PeerIdentity oid;
236
237   /**
238    * Last packet sent.
239    */
240   uint32_t pid GNUNET_PACKED;
241 };
242
243
244 /**
245  * Message for notifying a disconnection in a path
246  */
247 struct GNUNET_MESH_ConnectionBroken
248 {
249     /**
250      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN
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     /**
265      * ID of the endpoint
266      */
267   struct GNUNET_PeerIdentity peer1;
268
269     /**
270      * ID of the endpoint
271      */
272   struct GNUNET_PeerIdentity peer2;
273
274   /* TODO: signature */
275 };
276
277
278 /**
279  * Message to destroy a tunnel
280  */
281 struct GNUNET_MESH_ConnectionDestroy
282 {
283     /**
284      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY
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   /* TODO: signature */
299 };
300
301
302 /**
303  * Message to destroy a tunnel
304  */
305 struct GNUNET_MESH_ConnectionKeepAlive
306 {
307   /**
308    * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_(FWD|BCK)_KEEPALIVE
309    */
310   struct GNUNET_MessageHeader header;
311   
312   /**
313    * TID of the tunnel
314    */
315   uint32_t tid GNUNET_PACKED;
316   
317   /**
318    * OID of the tunnel
319    */
320   struct GNUNET_PeerIdentity oid;
321 };
322
323
324
325 GNUNET_NETWORK_STRUCT_END
326
327 #if 0                           /* keep Emacsens' auto-indent happy */
328 {
329 #endif
330 #ifdef __cplusplus
331 }
332 #endif
333
334 /* ifndef MESH_PROTOCOL_H */
335 #endif
336 /* end of mesh_protocol.h */