simplifying IPC for address destruction
[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 struct AddressSuggestionMessage
223 {
224   struct GNUNET_MessageHeader header;
225
226   uint32_t ats_count GNUNET_PACKED;
227
228   struct GNUNET_PeerIdentity peer;
229
230   uint16_t address_length GNUNET_PACKED;
231
232   uint16_t plugin_name_length GNUNET_PACKED;
233
234   uint32_t session_id GNUNET_PACKED;
235
236   uint32_t address_local_info GNUNET_PACKED;
237
238   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
239
240   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
241
242   /* followed by:
243    * - struct GNUNET_ATS_Information [ats_count];
244    * - char address[address_length]
245    * - char plugin_name[plugin_name_length] (including '\0'-termination).
246    */
247
248 };
249
250
251 struct PeerInformationMessage
252 {
253   struct GNUNET_MessageHeader header;
254
255   uint32_t ats_count GNUNET_PACKED;
256
257   uint32_t address_active GNUNET_PACKED;
258
259   uint32_t id GNUNET_PACKED;
260
261   struct GNUNET_PeerIdentity peer;
262
263   uint16_t address_length GNUNET_PACKED;
264
265   uint16_t plugin_name_length GNUNET_PACKED;
266
267   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
268
269   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
270
271   /* followed by:
272    * - struct GNUNET_ATS_Information [ats_count];
273    * - char address[address_length]
274    * - char plugin_name[plugin_name_length] (including '\0'-termination).
275    */
276
277 };
278
279
280 /**
281  * Client to service: please give us an overview of the addresses.
282  */
283 struct AddressListRequestMessage
284 {
285   /**
286    * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
287    */
288   struct GNUNET_MessageHeader header;
289
290   /**
291    * ID used to match replies to this request.
292    */
293   uint32_t id GNUNET_PACKED;
294
295   /**
296    * Which peer do we care about? All zeros for all.
297    */
298   struct GNUNET_PeerIdentity peer;
299
300   /**
301    * #GNUNET_YES to get information about all addresses,
302    * #GNUNET_NO to only return addresses that are in use.
303    */
304   int32_t all GNUNET_PACKED;
305
306 };
307
308
309 struct ReservationRequestMessage
310 {
311   struct GNUNET_MessageHeader header;
312
313   int32_t amount GNUNET_PACKED;
314
315   struct GNUNET_PeerIdentity peer;
316 };
317
318
319 /**
320  * Message sent by ATS service to client to confirm that it is done
321  * using the given session ID.
322  */
323 struct SessionReleaseMessage
324 {
325   struct GNUNET_MessageHeader header;
326
327   uint32_t session_id GNUNET_PACKED;
328
329   struct GNUNET_PeerIdentity peer;
330 };
331
332
333 struct ReservationResultMessage
334 {
335   struct GNUNET_MessageHeader header;
336
337   int32_t amount GNUNET_PACKED;
338
339   struct GNUNET_PeerIdentity peer;
340
341   struct GNUNET_TIME_RelativeNBO res_delay;
342 };
343
344 struct PreferenceInformation
345 {
346
347   uint32_t preference_kind GNUNET_PACKED;
348
349   float preference_value GNUNET_PACKED;
350
351 };
352
353
354 struct ChangePreferenceMessage
355 {
356   struct GNUNET_MessageHeader header;
357
358   uint32_t num_preferences GNUNET_PACKED;
359
360   struct GNUNET_PeerIdentity peer;
361
362   /* followed by 'num_preferences'
363    * struct PreferenceInformation values */
364 };
365
366
367 /**
368  * Message containing application feedback for a peer
369  */
370 struct FeedbackPreferenceMessage
371 {
372   struct GNUNET_MessageHeader header;
373
374   /**
375    * Number of feedback values included
376    */
377   uint32_t num_feedback GNUNET_PACKED;
378
379   /**
380    * Relative time describing for which time interval this feedback is
381    */
382   struct GNUNET_TIME_RelativeNBO scope;
383
384   /**
385    * Peer this feedback is for
386    */
387   struct GNUNET_PeerIdentity peer;
388
389   /* followed by 'num_feedback'
390    * struct PreferenceInformation values */
391 };
392
393 GNUNET_NETWORK_STRUCT_END
394
395
396
397 #endif