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