also simplify message format for AddressSuggestionMessage
[oweals/gnunet.git] / src / ats / ats.h
1 /*
2      This file is part of GNUnet.
3      (C) 2010,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  * @file ats/ats.h
22  * @brief automatic transport selection messages
23  * @author Christian Grothoff
24  * @author Matthias Wachs
25  */
26 #ifndef ATS_H
27 #define ATS_H
28
29 #include "gnunet_util_lib.h"
30
31 /**
32  * Flag used to indicate which type of client is connecting
33  * to the ATS service.
34  */
35 enum StartFlag
36 {
37
38   START_FLAG_SCHEDULING = 0,
39
40   START_FLAG_PERFORMANCE_WITH_PIC = 1,
41
42   START_FLAG_PERFORMANCE_NO_PIC = 2
43 };
44
45
46 GNUNET_NETWORK_STRUCT_BEGIN
47
48 struct ClientStartMessage
49 {
50   struct GNUNET_MessageHeader header;
51
52   /**
53    * NBO value of an `enum StartFlag`.
54    */
55   uint32_t start_flag GNUNET_PACKED;
56 };
57
58
59 struct RequestAddressMessage
60 {
61   struct GNUNET_MessageHeader header;
62
63   uint32_t reserved GNUNET_PACKED;
64
65   struct GNUNET_PeerIdentity peer;
66 };
67
68 struct ResetBackoffMessage
69 {
70   struct GNUNET_MessageHeader header;
71
72   uint32_t reserved GNUNET_PACKED;
73
74   struct GNUNET_PeerIdentity peer;
75 };
76
77
78 /**
79  * ATS client to ATS service: here is another address you can use.
80  */
81 struct AddressAddMessage
82 {
83   /**
84    * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD.
85    */
86   struct GNUNET_MessageHeader header;
87
88   /**
89    * Length of the `struct GNUNET_ATS_Information` array that follows this struct.
90    */
91   uint32_t ats_count GNUNET_PACKED;
92
93   /**
94    * Identity of the peer that this address is for.
95    */
96   struct GNUNET_PeerIdentity peer;
97
98   /**
99    * Number of bytes in the address that follows this struct.
100    */
101   uint16_t address_length GNUNET_PACKED;
102
103   /**
104    * Number of bytes in the plugin name that follows this struct.
105    */
106   uint16_t plugin_name_length GNUNET_PACKED;
107
108   /**
109    * Internal number this client will henceforth use to
110    * refer to this address.
111    */
112   uint32_t session_id GNUNET_PACKED;
113
114   /**
115    * Local-only information of the address, see
116    * `enum GNUNET_HELLO_AddressInfo`.
117    */
118   uint32_t address_local_info GNUNET_PACKED;
119
120   /* followed by:
121    * - struct GNUNET_ATS_Information [ats_count];
122    * - char address[address_length]
123    * - char plugin_name[plugin_name_length] (including '\0'-termination).
124    */
125
126 };
127
128
129 /**
130  * Message used to notify ATS that the performance
131  * characteristics for an address have changed.
132  */
133 struct AddressUpdateMessage
134 {
135   /**
136    * Message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE.
137    */
138   struct GNUNET_MessageHeader header;
139
140   /**
141    * Length of the `struct GNUNET_ATS_Information` array that follows.
142    */
143   uint32_t ats_count GNUNET_PACKED;
144
145   /**
146    * Which peer is this about? (Technically redundant, as the
147    * @e session_id should be sufficient, but enables ATS service
148    * to find the session faster).
149    */
150   struct GNUNET_PeerIdentity peer;
151
152   /**
153    * Internal number this client uses to refer to this address.
154    */
155   uint32_t session_id GNUNET_PACKED;
156
157   /* followed by:
158    * - struct GNUNET_ATS_Information [ats_count];
159    */
160
161 };
162
163
164 /**
165  * Message sent from ATS client to ATS service to notify
166  * it if we started (or stopped) using an address.
167  */
168 struct AddressUseMessage
169 {
170   /**
171    * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE.
172    */
173   struct GNUNET_MessageHeader header;
174
175   /**
176    * Internal number this client uses to refer to this address.
177    */
178   uint32_t session_id GNUNET_PACKED;
179
180   /**
181    * Which peer is this about? (Technically redundant, as the
182    * @e session_id should be sufficient, but enables ATS service
183    * to find the session faster).
184    */
185   struct GNUNET_PeerIdentity peer;
186
187   /**
188    * #GNUNET_YES or #GNUNET_NO.
189    */
190   uint32_t in_use GNUNET_PACKED;
191
192 };
193
194
195 /**
196  * Message sent by ATS client to ATS service when an address
197  * was destroyed and must thus henceforth no longer be considered
198  * for scheduling.
199  */
200 struct AddressDestroyedMessage
201 {
202   /**
203    * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED.
204    */
205   struct GNUNET_MessageHeader header;
206
207   /**
208    * Internal number this client uses to refer to this address.
209    */
210   uint32_t session_id GNUNET_PACKED;
211
212   /**
213    * Which peer is this about? (Technically redundant, as the
214    * @e session_id should be sufficient, but enables ATS service
215    * to find the session faster).
216    */
217   struct GNUNET_PeerIdentity peer;
218
219 };
220
221
222 /**
223  * ATS Service suggests to the transport service to use the address
224  * identified by the given @e session_id for the given @e peer with
225  * the given @e bandwidth_in and @e bandwidth_out limits from now on.
226  */
227 struct AddressSuggestionMessage
228 {
229   /**
230    * A message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION.
231    */
232   struct GNUNET_MessageHeader header;
233
234   /**
235    * Internal number this client uses to refer to the address this
236    * suggestion is about.
237    */
238   uint32_t session_id GNUNET_PACKED;
239
240   /**
241    * Which peer is this about? (Technically redundant, as the
242    * @e session_id should be sufficient, but may enable client
243    * to find the session faster and/or check consistency).
244    */
245   struct GNUNET_PeerIdentity peer;
246
247   /**
248    * How much bandwidth we are allowed for sending.
249    */
250   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
251
252   /**
253    * How much bandwidth we are allowed for receiving.
254    */
255   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
256
257 };
258
259
260 struct PeerInformationMessage
261 {
262   struct GNUNET_MessageHeader header;
263
264   uint32_t ats_count GNUNET_PACKED;
265
266   uint32_t address_active GNUNET_PACKED;
267
268   uint32_t id GNUNET_PACKED;
269
270   struct GNUNET_PeerIdentity peer;
271
272   uint16_t address_length GNUNET_PACKED;
273
274   uint16_t plugin_name_length GNUNET_PACKED;
275
276   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
277
278   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
279
280   /* followed by:
281    * - struct GNUNET_ATS_Information [ats_count];
282    * - char address[address_length]
283    * - char plugin_name[plugin_name_length] (including '\0'-termination).
284    */
285
286 };
287
288
289 /**
290  * Client to service: please give us an overview of the addresses.
291  */
292 struct AddressListRequestMessage
293 {
294   /**
295    * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
296    */
297   struct GNUNET_MessageHeader header;
298
299   /**
300    * ID used to match replies to this request.
301    */
302   uint32_t id GNUNET_PACKED;
303
304   /**
305    * Which peer do we care about? All zeros for all.
306    */
307   struct GNUNET_PeerIdentity peer;
308
309   /**
310    * #GNUNET_YES to get information about all addresses,
311    * #GNUNET_NO to only return addresses that are in use.
312    */
313   int32_t all GNUNET_PACKED;
314
315 };
316
317
318 struct ReservationRequestMessage
319 {
320   struct GNUNET_MessageHeader header;
321
322   int32_t amount GNUNET_PACKED;
323
324   struct GNUNET_PeerIdentity peer;
325 };
326
327
328 /**
329  * Message sent by ATS service to client to confirm that it is done
330  * using the given session ID.
331  */
332 struct SessionReleaseMessage
333 {
334   struct GNUNET_MessageHeader header;
335
336   uint32_t session_id GNUNET_PACKED;
337
338   struct GNUNET_PeerIdentity peer;
339 };
340
341
342 struct ReservationResultMessage
343 {
344   struct GNUNET_MessageHeader header;
345
346   int32_t amount GNUNET_PACKED;
347
348   struct GNUNET_PeerIdentity peer;
349
350   struct GNUNET_TIME_RelativeNBO res_delay;
351 };
352
353 struct PreferenceInformation
354 {
355
356   uint32_t preference_kind GNUNET_PACKED;
357
358   float preference_value GNUNET_PACKED;
359
360 };
361
362
363 struct ChangePreferenceMessage
364 {
365   struct GNUNET_MessageHeader header;
366
367   uint32_t num_preferences GNUNET_PACKED;
368
369   struct GNUNET_PeerIdentity peer;
370
371   /* followed by 'num_preferences'
372    * struct PreferenceInformation values */
373 };
374
375
376 /**
377  * Message containing application feedback for a peer
378  */
379 struct FeedbackPreferenceMessage
380 {
381   struct GNUNET_MessageHeader header;
382
383   /**
384    * Number of feedback values included
385    */
386   uint32_t num_feedback GNUNET_PACKED;
387
388   /**
389    * Relative time describing for which time interval this feedback is
390    */
391   struct GNUNET_TIME_RelativeNBO scope;
392
393   /**
394    * Peer this feedback is for
395    */
396   struct GNUNET_PeerIdentity peer;
397
398   /* followed by 'num_feedback'
399    * struct PreferenceInformation values */
400 };
401
402 GNUNET_NETWORK_STRUCT_END
403
404
405
406 #endif