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