- channel messages do not include tunnel info
[oweals/gnunet.git] / src / mesh / mesh_protocol_enc.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_enc.h
24  */
25
26 #ifndef MESH_PROTOCOL_ENC_H_
27 #define MESH_PROTOCOL_ENC_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 connection creation.
46  * TODO onionify path, add random tunnel ID
47  */
48 struct GNUNET_MESH_ConnectionCreate
49 {
50     /**
51      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE
52      *
53      * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
54      *              path_length * sizeof (struct GNUNET_PeerIdentity)
55      */
56   struct GNUNET_MessageHeader header;
57
58     /**
59      * ID of the connection for that tunnel.
60      */
61   uint32_t cid 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 ack'ing a connection
72  */
73 struct GNUNET_MESH_ConnectionACK
74 {
75     /**
76      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK
77      */
78   struct GNUNET_MessageHeader header;
79
80     /**
81      * CID of the connection
82      */
83   uint32_t cid GNUNET_PACKED;
84
85     /**
86      * TID of the tunnel
87      */
88   struct GNUNET_PeerIdentity tid;
89
90   /* TODO: signature */
91 };
92
93
94 /**
95  * Message for mesh data traffic.
96  */
97 struct GNUNET_MESH_Data
98 {
99     /**
100      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST,
101      *       GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
102      */
103   struct GNUNET_MessageHeader header;
104
105     /**
106      * TID of the tunnel
107      */
108   uint32_t tid GNUNET_PACKED;
109
110     /**
111      * Number of hops to live
112      */
113   uint32_t ttl GNUNET_PACKED;
114
115     /**
116      * ID of the packet
117      */
118   uint32_t pid GNUNET_PACKED;
119
120     /**
121      * OID of the tunnel
122      */
123   struct GNUNET_PeerIdentity oid;
124
125   /**
126    * Unique ID of the payload message
127    */
128   uint32_t mid GNUNET_PACKED;
129
130     /**
131      * Payload follows
132      */
133 };
134
135
136 /**
137  * Message to acknowledge end-to-end data.
138  */
139 struct GNUNET_MESH_DataACK
140 {
141   /**
142    * Type: GNUNET_MESSAGE_TYPE_MESH_DATA_ACK
143    */
144   struct GNUNET_MessageHeader header;
145
146   /**
147    * ID of the channel
148    */
149   uint32_t id GNUNET_PACKED;
150
151   /**
152    * Bitfield of already-received newer messages
153    * pid +  1 @ LSB
154    * pid + 64 @ MSB
155    */
156   uint64_t futures GNUNET_PACKED;
157
158   /**
159    * Last message ID received.
160    */
161   uint32_t mid GNUNET_PACKED;
162 };
163
164
165 /**
166  * Message to acknowledge mesh data traffic.
167  */
168 struct GNUNET_MESH_ACK
169 {
170     /**
171      * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
172      */
173   struct GNUNET_MessageHeader header;
174
175     /**
176      * Maximum packet ID authorized.
177      */
178   uint32_t pid GNUNET_PACKED;
179
180     /**
181      * OID of the tunnel
182      */
183   struct GNUNET_PeerIdentity oid;
184
185 };
186
187
188 /**
189  * Message to query a peer about its Flow Control status regarding a tunnel.
190  */
191 struct GNUNET_MESH_Poll
192 {
193   /**
194    * Type: GNUNET_MESSAGE_TYPE_MESH_POLL
195    */
196   struct GNUNET_MessageHeader header;
197
198   /**
199    * Last packet sent.
200    */
201   uint32_t pid GNUNET_PACKED;
202 };
203
204
205 /**
206  * Message for notifying a disconnection in a path
207  */
208 struct GNUNET_MESH_ConnectionBroken
209 {
210     /**
211      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN
212      */
213   struct GNUNET_MessageHeader header;
214
215     /**
216      * TID of the tunnel
217      */
218   uint32_t tid GNUNET_PACKED;
219
220     /**
221      * OID of the tunnel
222      */
223   struct GNUNET_PeerIdentity oid;
224
225     /**
226      * ID of the endpoint
227      */
228   struct GNUNET_PeerIdentity peer1;
229
230     /**
231      * ID of the endpoint
232      */
233   struct GNUNET_PeerIdentity peer2;
234
235   /* TODO: signature */
236 };
237
238
239 /**
240  * Message to destroy a tunnel
241  */
242 struct GNUNET_MESH_ConnectionDestroy
243 {
244     /**
245      * Type: GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY
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   /* TODO: signature */
260 };
261
262
263 /**
264  * Message to destroy a tunnel
265  */
266 struct GNUNET_MESH_ConnectionKeepAlive
267 {
268   /**
269    * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE
270    */
271   struct GNUNET_MessageHeader header;
272   
273   /**
274    * ID of the connection
275    */
276   uint32_t cid GNUNET_PACKED;
277   
278   /**
279    * ID of the tunnel
280    */
281   struct GNUNET_HashCode tid;
282 };
283
284
285
286 GNUNET_NETWORK_STRUCT_END
287
288 #if 0                           /* keep Emacsens' auto-indent happy */
289 {
290 #endif
291 #ifdef __cplusplus
292 }
293 #endif
294
295 /* ifndef MESH_PROTOCOL_H */
296 #endif
297 /* end of mesh_protocol.h */