- add packet ID to both multicast and unicast
[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 for ack'ing a path
180  */
181 struct GNUNET_MESH_PathACK
182 {
183     /**
184      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_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      * ID of the endpoint
200      */
201   struct GNUNET_PeerIdentity peer_id;
202
203   /* TODO: signature */
204 };
205
206
207 /**
208  * Message for notifying a disconnection in a path
209  */
210 struct GNUNET_MESH_PathBroken
211 {
212     /**
213      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
214      */
215   struct GNUNET_MessageHeader header;
216
217     /**
218      * TID of the tunnel
219      */
220   uint32_t tid GNUNET_PACKED;
221
222     /**
223      * OID of the tunnel
224      */
225   struct GNUNET_PeerIdentity oid;
226
227     /**
228      * ID of the endpoint
229      */
230   struct GNUNET_PeerIdentity peer1;
231
232     /**
233      * ID of the endpoint
234      */
235   struct GNUNET_PeerIdentity peer2;
236
237   /* TODO: signature */
238 };
239
240
241 /**
242  * Message to destroy a tunnel
243  */
244 struct GNUNET_MESH_TunnelDestroy
245 {
246     /**
247      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
248      */
249   struct GNUNET_MessageHeader header;
250
251     /**
252      * TID of the tunnel
253      */
254   uint32_t tid GNUNET_PACKED;
255
256     /**
257      * OID of the tunnel
258      */
259   struct GNUNET_PeerIdentity oid;
260
261   /* TODO: signature */
262 };
263
264
265 /**
266  * Message for mesh flow control
267  */
268 struct GNUNET_MESH_SpeedNotify
269 {
270     /**
271      * Type: GNUNET_MESSAGE_TYPE_DATA_SPEED_NOTIFY
272      */
273   struct GNUNET_MessageHeader header;
274
275     /**
276      * TID of the tunnel
277      */
278   uint32_t tid GNUNET_PACKED;
279
280     /**
281      * OID of the tunnel
282      */
283   struct GNUNET_PeerIdentity oid;
284
285     /**
286      * Is the speed limited by the slowest peer?.
287      */
288   int16_t speed_min;
289
290     /**
291      * Is the buffering allowed?.
292      */
293   int16_t buffering;
294
295 };
296 GNUNET_NETWORK_STRUCT_END
297
298 #if 0                           /* keep Emacsens' auto-indent happy */
299 {
300 #endif
301 #ifdef __cplusplus
302 }
303 #endif
304
305 /* ifndef MESH_PROTOCOL_H */
306 #endif
307 /* end of mesh_protocol.h */