- stop using message types of payload on service side
[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 #define MESH_TUNNEL_OPT_SPEED_MIN       0x1
39 #define MESH_TUNNEL_OPT_NOBUFFER        0x2
40
41
42 /******************************************************************************/
43 /********************      MESH NETWORK MESSAGES     **************************/
44 /******************************************************************************/
45
46 GNUNET_NETWORK_STRUCT_BEGIN
47
48 /**
49  * Message for mesh path management
50  */
51 struct GNUNET_MESH_ManipulatePath
52 {
53     /**
54      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DESTROY]
55      *
56      * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
57      *       path_length * sizeof (struct GNUNET_PeerIdentity)
58      */
59   struct GNUNET_MessageHeader header;
60
61     /**
62      * Global id of the tunnel this path belongs to,
63      * unique in conjunction with the origin.
64      */
65   uint32_t tid GNUNET_PACKED;
66
67     /**
68      * Tunnel options (MESH_TUNNEL_OPT_*).
69      */
70   uint32_t opt GNUNET_PACKED;
71
72     /**
73      * 64 bit alignment padding.
74      */
75   uint32_t reserved GNUNET_PACKED;
76
77     /**
78      * path_length structs defining the *whole* path from the origin [0] to the
79      * final destination [path_length-1].
80      */
81   /* struct GNUNET_PeerIdentity peers[path_length]; */
82 };
83
84 /**
85  * Message for mesh data traffic to all tunnel targets.
86  */
87 struct GNUNET_MESH_Multicast
88 {
89     /**
90      * Type: GNUNET_MESSAGE_TYPE_MESH_MULTICAST
91      */
92   struct GNUNET_MessageHeader header;
93
94     /**
95      * TID of the tunnel
96      */
97   uint32_t tid GNUNET_PACKED;
98
99     /**
100      * Number of hops to live
101      */
102   uint32_t ttl GNUNET_PACKED;
103
104     /**
105      * Unique ID of the packet
106      */
107   uint32_t pid GNUNET_PACKED;
108
109     /**
110      * OID of the tunnel
111      */
112   struct GNUNET_PeerIdentity oid;
113
114     /**
115      * Payload follows
116      */
117 };
118
119
120 /**
121  * Message for mesh data traffic to a particular destination from origin.
122  */
123 struct GNUNET_MESH_Unicast
124 {
125     /**
126      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST
127      */
128   struct GNUNET_MessageHeader header;
129
130     /**
131      * TID of the tunnel
132      */
133   uint32_t tid GNUNET_PACKED;
134
135     /**
136      * Number of hops to live
137      */
138   uint32_t ttl GNUNET_PACKED;
139
140     /**
141      * Unique ID of the packet
142      */
143   uint32_t pid GNUNET_PACKED;
144
145     /**
146      * OID of the tunnel
147      */
148   struct GNUNET_PeerIdentity oid;
149
150     /**
151      * Destination.
152      */
153   struct GNUNET_PeerIdentity destination;
154
155     /**
156      * Payload follows
157      */
158 };
159
160
161 /**
162  * Message for mesh data traffic from a tunnel participant to origin.
163  */
164 struct GNUNET_MESH_ToOrigin
165 {
166     /**
167      * Type: GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
168      */
169   struct GNUNET_MessageHeader header;
170
171     /**
172      * TID of the tunnel
173      */
174   uint32_t tid GNUNET_PACKED;
175
176     /**
177      * Number of hops to live
178      */
179   uint32_t ttl GNUNET_PACKED;
180
181     /**
182      * Unique ID of the packet
183      */
184   uint32_t pid GNUNET_PACKED;
185
186     /**
187      * OID of the tunnel
188      */
189   struct GNUNET_PeerIdentity oid;
190
191     /**
192      * Sender of the message.
193      */
194   struct GNUNET_PeerIdentity sender;
195
196     /**
197      * Payload follows
198      */
199 };
200
201
202 /**
203  * Message to acknowledge mesh data traffic.
204  */
205 struct GNUNET_MESH_ACK
206 {
207     /**
208      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
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      * Maximum packet ID authorized.
224      */
225   uint32_t pid;
226
227 };
228
229 /**
230  * Message to query a peer about its Flow Control status regarding a tunnel.
231  */
232 struct GNUNET_MESH_Poll
233 {
234   /**
235    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
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    * Last ACK received.
251    */
252   uint32_t last_ack;
253 };
254
255 /**
256  * Message for ack'ing a path
257  */
258 struct GNUNET_MESH_PathACK
259 {
260     /**
261      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
262      */
263   struct GNUNET_MessageHeader header;
264
265     /**
266      * TID of the tunnel
267      */
268   uint32_t tid GNUNET_PACKED;
269
270     /**
271      * OID of the tunnel
272      */
273   struct GNUNET_PeerIdentity oid;
274
275     /**
276      * ID of the endpoint
277      */
278   struct GNUNET_PeerIdentity peer_id;
279
280   /* TODO: signature */
281 };
282
283
284 /**
285  * Message for notifying a disconnection in a path
286  */
287 struct GNUNET_MESH_PathBroken
288 {
289     /**
290      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
291      */
292   struct GNUNET_MessageHeader header;
293
294     /**
295      * TID of the tunnel
296      */
297   uint32_t tid GNUNET_PACKED;
298
299     /**
300      * OID of the tunnel
301      */
302   struct GNUNET_PeerIdentity oid;
303
304     /**
305      * ID of the endpoint
306      */
307   struct GNUNET_PeerIdentity peer1;
308
309     /**
310      * ID of the endpoint
311      */
312   struct GNUNET_PeerIdentity peer2;
313
314   /* TODO: signature */
315 };
316
317
318 /**
319  * Message to destroy a tunnel
320  */
321 struct GNUNET_MESH_TunnelDestroy
322 {
323     /**
324      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
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   /* TODO: signature */
339 };
340
341
342 /**
343  * Message to destroy a tunnel
344  */
345 struct GNUNET_MESH_TunnelKeepAlive
346 {
347   /**
348    * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE
349    */
350   struct GNUNET_MessageHeader header;
351   
352   /**
353    * TID of the tunnel
354    */
355   uint32_t tid GNUNET_PACKED;
356   
357   /**
358    * OID of the tunnel
359    */
360   struct GNUNET_PeerIdentity oid;
361 };
362
363
364
365 GNUNET_NETWORK_STRUCT_END
366
367 #if 0                           /* keep Emacsens' auto-indent happy */
368 {
369 #endif
370 #ifdef __cplusplus
371 }
372 #endif
373
374 /* ifndef MESH_PROTOCOL_H */
375 #endif
376 /* end of mesh_protocol.h */