- fixes, new message
[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 /******************************************************************************/
39 /********************      MESH NETWORK MESSAGES     **************************/
40 /******************************************************************************/
41
42 GNUNET_NETWORK_STRUCT_BEGIN
43
44 /**
45  * Message for mesh path management
46  */
47 struct GNUNET_MESH_ManipulatePath
48 {
49     /**
50      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL]
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 tunnel this path belongs to,
59      * unique in conjunction with the origin.
60      */
61   uint32_t tid 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 mesh data traffic to all tunnel targets.
72  */
73 struct GNUNET_MESH_Multicast
74 {
75     /**
76      * Type: GNUNET_MESSAGE_TYPE_MESH_MULTICAST
77      */
78   struct GNUNET_MessageHeader header;
79
80     /**
81      * TID of the tunnel
82      */
83   uint32_t tid GNUNET_PACKED;
84
85     /**
86      * Number of hops to live
87      */
88   uint32_t ttl GNUNET_PACKED;
89
90     /**
91      * Unique ID of the packet
92      */
93   uint32_t pid GNUNET_PACKED;
94
95     /**
96      * OID of the tunnel
97      */
98   struct GNUNET_PeerIdentity oid;
99
100     /**
101      * Payload follows
102      */
103 };
104
105
106 /**
107  * Message for mesh data traffic to a particular destination from origin.
108  */
109 struct GNUNET_MESH_Unicast
110 {
111     /**
112      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST
113      */
114   struct GNUNET_MessageHeader header;
115
116     /**
117      * TID of the tunnel
118      */
119   uint32_t tid GNUNET_PACKED;
120
121     /**
122      * Number of hops to live
123      */
124   uint32_t ttl GNUNET_PACKED;
125
126     /**
127      * Unique ID of the packet
128      */
129   uint32_t pid GNUNET_PACKED;
130
131     /**
132      * OID of the tunnel
133      */
134   struct GNUNET_PeerIdentity oid;
135
136     /**
137      * Destination.
138      */
139   struct GNUNET_PeerIdentity destination;
140
141     /**
142      * Payload follows
143      */
144 };
145
146
147 /**
148  * Message for mesh data traffic from a tunnel participant to origin.
149  */
150 struct GNUNET_MESH_ToOrigin
151 {
152     /**
153      * Type: GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
154      */
155   struct GNUNET_MessageHeader header;
156
157     /**
158      * TID of the tunnel
159      */
160   uint32_t tid GNUNET_PACKED;
161
162     /**
163      * OID of the tunnel
164      */
165   struct GNUNET_PeerIdentity oid;
166
167     /**
168      * Sender of the message.
169      */
170   struct GNUNET_PeerIdentity sender;
171
172     /**
173      * Payload follows
174      */
175 };
176
177
178 /**
179  * Message to acknowledte mesh data traffic.
180  */
181 struct GNUNET_MESH_ACK
182 {
183     /**
184      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
185      */
186   struct GNUNET_MessageHeader header;
187
188     /**
189      * TID of the tunnel
190      */
191   uint32_t tid GNUNET_PACKED;
192
193     /**
194      * OID of the tunnel
195      */
196   struct GNUNET_PeerIdentity oid;
197
198     /**
199      * Sender of the message.
200      */
201   struct GNUNET_PeerIdentity sender;
202
203     /**
204      * Payload follows
205      */
206 };
207
208 /**
209  * Message for ack'ing a path
210  */
211 struct GNUNET_MESH_PathACK
212 {
213     /**
214      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
215      */
216   struct GNUNET_MessageHeader header;
217
218     /**
219      * TID of the tunnel
220      */
221   uint32_t tid GNUNET_PACKED;
222
223     /**
224      * OID of the tunnel
225      */
226   struct GNUNET_PeerIdentity oid;
227
228     /**
229      * ID of the endpoint
230      */
231   struct GNUNET_PeerIdentity peer_id;
232
233   /* TODO: signature */
234 };
235
236
237 /**
238  * Message for notifying a disconnection in a path
239  */
240 struct GNUNET_MESH_PathBroken
241 {
242     /**
243      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
244      */
245   struct GNUNET_MessageHeader header;
246
247     /**
248      * TID of the tunnel
249      */
250   uint32_t tid GNUNET_PACKED;
251
252     /**
253      * OID of the tunnel
254      */
255   struct GNUNET_PeerIdentity oid;
256
257     /**
258      * ID of the endpoint
259      */
260   struct GNUNET_PeerIdentity peer1;
261
262     /**
263      * ID of the endpoint
264      */
265   struct GNUNET_PeerIdentity peer2;
266
267   /* TODO: signature */
268 };
269
270
271 /**
272  * Message to destroy a tunnel
273  */
274 struct GNUNET_MESH_TunnelDestroy
275 {
276     /**
277      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
278      */
279   struct GNUNET_MessageHeader header;
280
281     /**
282      * TID of the tunnel
283      */
284   uint32_t tid GNUNET_PACKED;
285
286     /**
287      * OID of the tunnel
288      */
289   struct GNUNET_PeerIdentity oid;
290
291   /* TODO: signature */
292 };
293
294
295 /**
296  * Message for mesh flow control
297  */
298 struct GNUNET_MESH_SpeedNotify
299 {
300     /**
301      * Type: GNUNET_MESSAGE_TYPE_DATA_SPEED_NOTIFY
302      */
303   struct GNUNET_MessageHeader header;
304
305     /**
306      * TID of the tunnel
307      */
308   uint32_t tid GNUNET_PACKED;
309
310     /**
311      * OID of the tunnel
312      */
313   struct GNUNET_PeerIdentity oid;
314
315     /**
316      * Is the speed limited by the slowest peer?.
317      */
318   int16_t speed_min;
319
320     /**
321      * Is the buffering allowed?.
322      */
323   int16_t buffering;
324
325 };
326 GNUNET_NETWORK_STRUCT_END
327
328 #if 0                           /* keep Emacsens' auto-indent happy */
329 {
330 #endif
331 #ifdef __cplusplus
332 }
333 #endif
334
335 /* ifndef MESH_PROTOCOL_H */
336 #endif
337 /* end of mesh_protocol.h */