Replace mesh with new version
[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_NOBUFFER        0x2
39
40
41 /******************************************************************************/
42 /********************      MESH NETWORK MESSAGES     **************************/
43 /******************************************************************************/
44
45 GNUNET_NETWORK_STRUCT_BEGIN
46
47 /**
48  * Message for mesh path creation.
49  */
50 struct GNUNET_MESH_CreateTunnel
51 {
52     /**
53      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE
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      * Destination port.
73      */
74   uint32_t port GNUNET_PACKED;
75
76     /**
77      * FIXME do not add the first hop
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 path destruction.
86  */
87 struct GNUNET_MESH_DestroyTunnel
88 {
89   /**
90    * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY
91    *
92    * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
93    *       path_length * sizeof (struct GNUNET_PeerIdentity)
94    */
95   struct GNUNET_MessageHeader header;
96   
97   /**
98    * Global id of the tunnel this path belongs to,
99    * unique in conjunction with the origin.
100    */
101   uint32_t tid GNUNET_PACKED;
102 };
103
104
105 /**
106  * Message for mesh data traffic.
107  */
108 struct GNUNET_MESH_Data
109 {
110     /**
111      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
112      *       GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
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      * Payload follows
138      */
139 };
140
141
142 /**
143  * Message to acknowledge mesh data traffic.
144  */
145 struct GNUNET_MESH_ACK
146 {
147     /**
148      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
149      */
150   struct GNUNET_MessageHeader header;
151
152     /**
153      * TID of the tunnel
154      */
155   uint32_t tid GNUNET_PACKED;
156
157     /**
158      * OID of the tunnel
159      */
160   struct GNUNET_PeerIdentity oid;
161
162     /**
163      * Maximum packet ID authorized.
164      */
165   uint32_t pid;
166
167 };
168
169 /**
170  * Message to query a peer about its Flow Control status regarding a tunnel.
171  */
172 struct GNUNET_MESH_Poll
173 {
174   /**
175    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
176    */
177   struct GNUNET_MessageHeader header;
178
179   /**
180    * TID of the tunnel
181    */
182   uint32_t tid GNUNET_PACKED;
183
184   /**
185    * OID of the tunnel
186    */
187   struct GNUNET_PeerIdentity oid;
188 };
189
190 /**
191  * Message for ack'ing a path
192  */
193 struct GNUNET_MESH_PathACK
194 {
195     /**
196      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
197      */
198   struct GNUNET_MessageHeader header;
199
200     /**
201      * TID of the tunnel
202      */
203   uint32_t tid GNUNET_PACKED;
204
205     /**
206      * OID of the tunnel
207      */
208   struct GNUNET_PeerIdentity oid;
209
210     /**
211      * ID of the endpoint
212      */
213   struct GNUNET_PeerIdentity peer_id;
214
215     /**
216      * Initial ACK value for payload.
217      */
218   uint32_t ack GNUNET_PACKED;
219
220   /* TODO: signature */
221 };
222
223
224 /**
225  * Message for notifying a disconnection in a path
226  */
227 struct GNUNET_MESH_PathBroken
228 {
229     /**
230      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
231      */
232   struct GNUNET_MessageHeader header;
233
234     /**
235      * TID of the tunnel
236      */
237   uint32_t tid GNUNET_PACKED;
238
239     /**
240      * OID of the tunnel
241      */
242   struct GNUNET_PeerIdentity oid;
243
244     /**
245      * ID of the endpoint
246      */
247   struct GNUNET_PeerIdentity peer1;
248
249     /**
250      * ID of the endpoint
251      */
252   struct GNUNET_PeerIdentity peer2;
253
254   /* TODO: signature */
255 };
256
257
258 /**
259  * Message to destroy a tunnel
260  */
261 struct GNUNET_MESH_TunnelDestroy
262 {
263     /**
264      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
265      */
266   struct GNUNET_MessageHeader header;
267
268     /**
269      * TID of the tunnel
270      */
271   uint32_t tid GNUNET_PACKED;
272
273     /**
274      * OID of the tunnel
275      */
276   struct GNUNET_PeerIdentity oid;
277
278   /* TODO: signature */
279 };
280
281
282 /**
283  * Message to destroy a tunnel
284  */
285 struct GNUNET_MESH_TunnelKeepAlive
286 {
287   /**
288    * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE
289    */
290   struct GNUNET_MessageHeader header;
291   
292   /**
293    * TID of the tunnel
294    */
295   uint32_t tid GNUNET_PACKED;
296   
297   /**
298    * OID of the tunnel
299    */
300   struct GNUNET_PeerIdentity oid;
301 };
302
303
304
305 GNUNET_NETWORK_STRUCT_END
306
307 #if 0                           /* keep Emacsens' auto-indent happy */
308 {
309 #endif
310 #ifdef __cplusplus
311 }
312 #endif
313
314 /* ifndef MESH_PROTOCOL_H */
315 #endif
316 /* end of mesh_protocol.h */