fixing 2012: network structure alignment now forced to be correct even on W32 using...
[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 /******************************************************************************/
39 /********************      MESH NETWORK MESSAGES     **************************/
40 /******************************************************************************/
41
42 GNUNET_NETWORK_STRUCT_BEGIN
43
44 /**
45  * Message for mesh path management
46  */
47 struct GNUNET_MESH_ManipulatePath
48 {
49     /**
50      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL]
51      *
52      * Size: sizeof(struct GNUNET_MESH_ManipulatePath) +
53      *       path_length * sizeof (struct GNUNET_PeerIdentity)
54      */
55   struct GNUNET_MessageHeader header;
56
57     /**
58      * Global id of the tunnel this path belongs to,
59      * unique in conjunction with the origin.
60      */
61   uint32_t tid 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 mesh data traffic to all tunnel targets.
72  */
73 struct GNUNET_MESH_Multicast
74 {
75     /**
76      * Type: GNUNET_MESSAGE_TYPE_MESH_MULTICAST
77      */
78   struct GNUNET_MessageHeader header;
79
80     /**
81      * TID of the tunnel
82      */
83   uint32_t tid GNUNET_PACKED;
84
85     /**
86      * Number of hops to live
87      */
88   uint32_t ttl GNUNET_PACKED;
89
90     /**
91      * Unique ID of the packet
92      */
93   uint32_t mid GNUNET_PACKED;
94
95     /**
96      * OID of the tunnel
97      */
98   struct GNUNET_PeerIdentity oid;
99
100     /**
101      * Payload follows
102      */
103 };
104
105
106 /**
107  * Message for mesh data traffic to a particular destination from origin.
108  */
109 struct GNUNET_MESH_Unicast
110 {
111     /**
112      * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST
113      */
114   struct GNUNET_MessageHeader header;
115
116     /**
117      * TID of the tunnel
118      */
119   uint32_t tid GNUNET_PACKED;
120
121     /**
122      * OID of the tunnel
123      */
124   struct GNUNET_PeerIdentity oid;
125
126     /**
127      * Destination.
128      */
129   struct GNUNET_PeerIdentity destination;
130
131     /**
132      * Payload follows
133      */
134 };
135
136
137 /**
138  * Message for mesh data traffic from a tunnel participant to origin.
139  */
140 struct GNUNET_MESH_ToOrigin
141 {
142     /**
143      * Type: GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
144      */
145   struct GNUNET_MessageHeader header;
146
147     /**
148      * TID of the tunnel
149      */
150   uint32_t tid GNUNET_PACKED;
151
152     /**
153      * OID of the tunnel
154      */
155   struct GNUNET_PeerIdentity oid;
156
157     /**
158      * Sender of the message.
159      */
160   struct GNUNET_PeerIdentity sender;
161
162     /**
163      * Payload follows
164      */
165 };
166
167
168 /**
169  * Message for ack'ing a path
170  */
171 struct GNUNET_MESH_PathACK
172 {
173     /**
174      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_ACK
175      */
176   struct GNUNET_MessageHeader header;
177
178     /**
179      * TID of the tunnel
180      */
181   uint32_t tid GNUNET_PACKED;
182
183     /**
184      * OID of the tunnel
185      */
186   struct GNUNET_PeerIdentity oid;
187
188     /**
189      * ID of the endpoint
190      */
191   struct GNUNET_PeerIdentity peer_id;
192
193   /* TODO: signature */
194 };
195
196
197 /**
198  * Message for notifying a disconnection in a path
199  */
200 struct GNUNET_MESH_PathBroken
201 {
202     /**
203      * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN
204      */
205   struct GNUNET_MessageHeader header;
206
207     /**
208      * TID of the tunnel
209      */
210   uint32_t tid GNUNET_PACKED;
211
212     /**
213      * OID of the tunnel
214      */
215   struct GNUNET_PeerIdentity oid;
216
217     /**
218      * ID of the endpoint
219      */
220   struct GNUNET_PeerIdentity peer1;
221
222     /**
223      * ID of the endpoint
224      */
225   struct GNUNET_PeerIdentity peer2;
226
227   /* TODO: signature */
228 };
229
230
231 /**
232  * Message to destroy a tunnel
233  */
234 struct GNUNET_MESH_TunnelDestroy
235 {
236     /**
237      * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
238      */
239   struct GNUNET_MessageHeader header;
240
241     /**
242      * TID of the tunnel
243      */
244   uint32_t tid GNUNET_PACKED;
245
246     /**
247      * OID of the tunnel
248      */
249   struct GNUNET_PeerIdentity oid;
250
251   /* TODO: signature */
252 };
253
254
255 /**
256  * Message for mesh flow control
257  */
258 struct GNUNET_MESH_SpeedNotify
259 {
260     /**
261      * Type: GNUNET_MESSAGE_TYPE_DATA_SPEED_NOTIFY
262      */
263   struct GNUNET_MessageHeader header;
264
265     /**
266      * TID of the tunnel
267      */
268   uint32_t tid GNUNET_PACKED;
269
270     /**
271      * OID of the tunnel
272      */
273   struct GNUNET_PeerIdentity oid;
274
275     /**
276      * Slowest link down the path (above minimum speed requirement).
277      */
278   uint32_t speed_min;
279
280 };
281 GNUNET_NETWORK_STRUCT_END
282
283 #if 0                           /* keep Emacsens' auto-indent happy */
284 {
285 #endif
286 #ifdef __cplusplus
287 }
288 #endif
289
290 /* ifndef MES_PROTOCOL_H */
291 #endif
292 /* end of mesh_protocol.h */