- make sure all flow control values are updated correctly
[oweals/gnunet.git] / src / mesh / mesh2_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_NOBUFFER        0x2
39
40
41 /******************************************************************************/
42 /********************      MESH NETWORK MESSAGES     **************************/
43 /******************************************************************************/
44
45 GNUNET_NETWORK_STRUCT_BEGIN
46
47 /**
48  * Message for mesh path management
49  */
50 struct GNUNET_MESH_ManipulatePath
51 {
52     /**
53      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DESTROY]
54      *
55      * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
56      *       path_length * sizeof (struct GNUNET_PeerIdentity)
57      */
58   struct GNUNET_MessageHeader header;
59
60     /**
61      * Global id of the tunnel this path belongs to,
62      * unique in conjunction with the origin.
63      */
64   uint32_t tid GNUNET_PACKED;
65
66     /**
67      * Tunnel options (MESH_TUNNEL_OPT_*).
68      */
69   uint32_t opt GNUNET_PACKED;
70
71     /**
72      * 64 bit alignment padding.
73      */
74   uint32_t reserved GNUNET_PACKED;
75
76     /**
77      * path_length structs defining the *whole* path from the origin [0] to the
78      * final destination [path_length-1].
79      */
80   /* struct GNUNET_PeerIdentity peers[path_length]; */
81 };
82
83
84 /**
85  * Message for mesh data traffic to a particular destination from origin.
86  */
87 struct GNUNET_MESH_Unicast
88 {
89     /**
90      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST
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 from a tunnel participant to origin.
122  */
123 struct GNUNET_MESH_ToOrigin
124 {
125     /**
126      * Type: GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
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      * Payload follows
152      */
153 };
154
155
156 /**
157  * Message to acknowledge mesh data traffic.
158  */
159 struct GNUNET_MESH_ACK
160 {
161     /**
162      * Type: GNUNET_MESSAGE_TYPE_MESH_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      * Maximum packet ID authorized.
178      */
179   uint32_t pid;
180
181 };
182
183 /**
184  * Message to query a peer about its Flow Control status regarding a tunnel.
185  */
186 struct GNUNET_MESH_Poll
187 {
188   /**
189    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
190    */
191   struct GNUNET_MessageHeader header;
192
193   /**
194    * TID of the tunnel
195    */
196   uint32_t tid GNUNET_PACKED;
197
198   /**
199    * OID of the tunnel
200    */
201   struct GNUNET_PeerIdentity oid;
202 };
203
204 /**
205  * Message for ack'ing a path
206  */
207 struct GNUNET_MESH_PathACK
208 {
209     /**
210      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
211      */
212   struct GNUNET_MessageHeader header;
213
214     /**
215      * TID of the tunnel
216      */
217   uint32_t tid GNUNET_PACKED;
218
219     /**
220      * OID of the tunnel
221      */
222   struct GNUNET_PeerIdentity oid;
223
224     /**
225      * ID of the endpoint
226      */
227   struct GNUNET_PeerIdentity peer_id;
228
229   /* TODO: signature */
230 };
231
232
233 /**
234  * Message for notifying a disconnection in a path
235  */
236 struct GNUNET_MESH_PathBroken
237 {
238     /**
239      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
240      */
241   struct GNUNET_MessageHeader header;
242
243     /**
244      * TID of the tunnel
245      */
246   uint32_t tid GNUNET_PACKED;
247
248     /**
249      * OID of the tunnel
250      */
251   struct GNUNET_PeerIdentity oid;
252
253     /**
254      * ID of the endpoint
255      */
256   struct GNUNET_PeerIdentity peer1;
257
258     /**
259      * ID of the endpoint
260      */
261   struct GNUNET_PeerIdentity peer2;
262
263   /* TODO: signature */
264 };
265
266
267 /**
268  * Message to destroy a tunnel
269  */
270 struct GNUNET_MESH_TunnelDestroy
271 {
272     /**
273      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
274      */
275   struct GNUNET_MessageHeader header;
276
277     /**
278      * TID of the tunnel
279      */
280   uint32_t tid GNUNET_PACKED;
281
282     /**
283      * OID of the tunnel
284      */
285   struct GNUNET_PeerIdentity oid;
286
287   /* TODO: signature */
288 };
289
290
291 /**
292  * Message to destroy a tunnel
293  */
294 struct GNUNET_MESH_TunnelKeepAlive
295 {
296   /**
297    * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE
298    */
299   struct GNUNET_MessageHeader header;
300   
301   /**
302    * TID of the tunnel
303    */
304   uint32_t tid GNUNET_PACKED;
305   
306   /**
307    * OID of the tunnel
308    */
309   struct GNUNET_PeerIdentity oid;
310 };
311
312
313
314 GNUNET_NETWORK_STRUCT_END
315
316 #if 0                           /* keep Emacsens' auto-indent happy */
317 {
318 #endif
319 #ifdef __cplusplus
320 }
321 #endif
322
323 /* ifndef MESH_PROTOCOL_H */
324 #endif
325 /* end of mesh_protocol.h */