- wip
[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_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 /**
86  * Message for mesh data traffic to a particular destination from origin.
87  */
88 struct GNUNET_MESH_Unicast
89 {
90     /**
91      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST
92      */
93   struct GNUNET_MessageHeader header;
94
95     /**
96      * TID of the tunnel
97      */
98   uint32_t tid GNUNET_PACKED;
99
100     /**
101      * Number of hops to live
102      */
103   uint32_t ttl GNUNET_PACKED;
104
105     /**
106      * Unique ID of the packet
107      */
108   uint32_t pid GNUNET_PACKED;
109
110     /**
111      * OID of the tunnel
112      */
113   struct GNUNET_PeerIdentity oid;
114
115     /**
116      * Payload follows
117      */
118 };
119
120
121 /**
122  * Message for mesh data traffic from a tunnel participant to origin.
123  */
124 struct GNUNET_MESH_ToOrigin
125 {
126     /**
127      * Type: GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
128      */
129   struct GNUNET_MessageHeader header;
130
131     /**
132      * TID of the tunnel
133      */
134   uint32_t tid GNUNET_PACKED;
135
136     /**
137      * Number of hops to live
138      */
139   uint32_t ttl GNUNET_PACKED;
140
141     /**
142      * Unique ID of the packet
143      */
144   uint32_t pid GNUNET_PACKED;
145
146     /**
147      * OID of the tunnel
148      */
149   struct GNUNET_PeerIdentity oid;
150
151     /**
152      * Payload follows
153      */
154 };
155
156
157 /**
158  * Message to acknowledge mesh data traffic.
159  */
160 struct GNUNET_MESH_ACK
161 {
162     /**
163      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
164      */
165   struct GNUNET_MessageHeader header;
166
167     /**
168      * TID of the tunnel
169      */
170   uint32_t tid GNUNET_PACKED;
171
172     /**
173      * OID of the tunnel
174      */
175   struct GNUNET_PeerIdentity oid;
176
177     /**
178      * Maximum packet ID authorized.
179      */
180   uint32_t pid;
181
182 };
183
184 /**
185  * Message to query a peer about its Flow Control status regarding a tunnel.
186  */
187 struct GNUNET_MESH_Poll
188 {
189   /**
190    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
191    */
192   struct GNUNET_MessageHeader header;
193
194   /**
195    * TID of the tunnel
196    */
197   uint32_t tid GNUNET_PACKED;
198
199   /**
200    * OID of the tunnel
201    */
202   struct GNUNET_PeerIdentity oid;
203
204   /**
205    * Last ACK received.
206    */
207   uint32_t last_ack;
208 };
209
210 /**
211  * Message for ack'ing a path
212  */
213 struct GNUNET_MESH_PathACK
214 {
215     /**
216      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
217      */
218   struct GNUNET_MessageHeader header;
219
220     /**
221      * TID of the tunnel
222      */
223   uint32_t tid GNUNET_PACKED;
224
225     /**
226      * OID of the tunnel
227      */
228   struct GNUNET_PeerIdentity oid;
229
230     /**
231      * ID of the endpoint
232      */
233   struct GNUNET_PeerIdentity peer_id;
234
235   /* TODO: signature */
236 };
237
238
239 /**
240  * Message for notifying a disconnection in a path
241  */
242 struct GNUNET_MESH_PathBroken
243 {
244     /**
245      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
246      */
247   struct GNUNET_MessageHeader header;
248
249     /**
250      * TID of the tunnel
251      */
252   uint32_t tid GNUNET_PACKED;
253
254     /**
255      * OID of the tunnel
256      */
257   struct GNUNET_PeerIdentity oid;
258
259     /**
260      * ID of the endpoint
261      */
262   struct GNUNET_PeerIdentity peer1;
263
264     /**
265      * ID of the endpoint
266      */
267   struct GNUNET_PeerIdentity peer2;
268
269   /* TODO: signature */
270 };
271
272
273 /**
274  * Message to destroy a tunnel
275  */
276 struct GNUNET_MESH_TunnelDestroy
277 {
278     /**
279      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
280      */
281   struct GNUNET_MessageHeader header;
282
283     /**
284      * TID of the tunnel
285      */
286   uint32_t tid GNUNET_PACKED;
287
288     /**
289      * OID of the tunnel
290      */
291   struct GNUNET_PeerIdentity oid;
292
293   /* TODO: signature */
294 };
295
296
297 /**
298  * Message to destroy a tunnel
299  */
300 struct GNUNET_MESH_TunnelKeepAlive
301 {
302   /**
303    * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE
304    */
305   struct GNUNET_MessageHeader header;
306   
307   /**
308    * TID of the tunnel
309    */
310   uint32_t tid GNUNET_PACKED;
311   
312   /**
313    * OID of the tunnel
314    */
315   struct GNUNET_PeerIdentity oid;
316 };
317
318
319
320 GNUNET_NETWORK_STRUCT_END
321
322 #if 0                           /* keep Emacsens' auto-indent happy */
323 {
324 #endif
325 #ifdef __cplusplus
326 }
327 #endif
328
329 /* ifndef MESH_PROTOCOL_H */
330 #endif
331 /* end of mesh_protocol.h */