2 This file is part of GNUnet.
3 Copyright (C) 2010-2015 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
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 Affero General Public License for more details.
17 * @brief automatic transport selection messages
18 * @author Christian Grothoff
19 * @author Matthias Wachs
24 #include "gnunet_util_lib.h"
25 #include "gnunet_ats_service.h"
29 * Flag used to indicate which type of client is connecting
36 * This is a scheduling client (aka transport service)
38 START_FLAG_SCHEDULING = 0,
41 * Performance monitoring client that wants to learn about
42 * changes in performance characteristics.
44 START_FLAG_PERFORMANCE_WITH_PIC = 1,
47 * Performance monitoring client that does NOT want to learn
48 * about changes in performance characteristics.
50 START_FLAG_PERFORMANCE_NO_PIC = 2,
53 * Connection suggestion handle.
55 START_FLAG_CONNECTION_SUGGESTION = 3
59 GNUNET_NETWORK_STRUCT_BEGIN
62 * First message any client sends to ATS, used to self-identify
63 * (what type of client this is).
65 struct ClientStartMessage
68 * Type is #GNUNET_MESSAGE_TYPE_ATS_START.
70 struct GNUNET_MessageHeader header;
73 * NBO value of an `enum StartFlag`.
75 uint32_t start_flag GNUNET_PACKED;
80 * Connectivity client to ATS service: we would like to have
81 * address suggestions for this peer.
83 struct RequestAddressMessage
86 * Type is #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS or
87 * #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL to stop
90 struct GNUNET_MessageHeader header;
93 * How "strong" is our need for an address for this peer?
95 uint32_t strength GNUNET_PACKED;
98 * Peer to get address suggestions for.
100 struct GNUNET_PeerIdentity peer;
105 * Scheduling client to ATS service: here is another address you can use.
107 struct AddressAddMessage
110 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD.
112 struct GNUNET_MessageHeader header;
115 * Number of bytes in the address that follows this struct.
117 uint16_t address_length GNUNET_PACKED;
120 * Number of bytes in the plugin name that follows this struct.
122 uint16_t plugin_name_length GNUNET_PACKED;
125 * Identity of the peer that this address is for.
127 struct GNUNET_PeerIdentity peer;
130 * Internal number this client will henceforth use to
131 * refer to this address.
133 uint32_t session_id GNUNET_PACKED;
136 * Local-only information of the address, see
137 * `enum GNUNET_HELLO_AddressInfo`.
139 uint32_t address_local_info GNUNET_PACKED;
142 * Performance properties of the address.
144 struct GNUNET_ATS_PropertiesNBO properties;
147 * - char address[address_length]
148 * - char plugin_name[plugin_name_length] (including '\0'-termination).
155 * Message used to notify ATS that the performance
156 * characteristics for an address have changed.
158 struct AddressUpdateMessage
161 * Message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE.
163 struct GNUNET_MessageHeader header;
166 * Internal number this client uses to refer to this address.
168 uint32_t session_id GNUNET_PACKED;
171 * Which peer is this about? (Technically redundant, as the
172 * @e session_id should be sufficient, but enables ATS service
173 * to find the session faster).
175 struct GNUNET_PeerIdentity peer;
178 * Performance properties of the address.
180 struct GNUNET_ATS_PropertiesNBO properties;
186 * Message sent by ATS client to ATS service when an address
187 * was destroyed and must thus henceforth no longer be considered
190 struct AddressDestroyedMessage
193 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED.
195 struct GNUNET_MessageHeader header;
198 * Internal number this client uses to refer to this address.
200 uint32_t session_id GNUNET_PACKED;
203 * Which peer is this about? (Technically redundant, as the
204 * @e session_id should be sufficient, but enables ATS service
205 * to find the session faster).
207 struct GNUNET_PeerIdentity peer;
213 * Message sent by ATS service to client to confirm that it is done
214 * using the given session ID.
216 struct GNUNET_ATS_SessionReleaseMessage
219 * Type is #GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE.
221 struct GNUNET_MessageHeader header;
224 * Number the client used to identify the session.
226 uint32_t session_id GNUNET_PACKED;
229 * Which peer is this about? (Technically redundant, as the
230 * @e session_id should be sufficient, but may enable client
231 * to find the session faster).
233 struct GNUNET_PeerIdentity peer;
239 * ATS Service suggests to the transport service to use the address
240 * identified by the given @e session_id for the given @e peer with
241 * the given @e bandwidth_in and @e bandwidth_out limits from now on.
243 struct AddressSuggestionMessage
246 * A message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION.
248 struct GNUNET_MessageHeader header;
251 * Internal number this client uses to refer to the address this
252 * suggestion is about.
254 uint32_t session_id GNUNET_PACKED;
257 * Which peer is this about? (Technically redundant, as the
258 * @e session_id should be sufficient, but may enable client
259 * to find the session faster and/or check consistency).
261 struct GNUNET_PeerIdentity peer;
264 * How much bandwidth we are allowed for sending.
266 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
269 * How much bandwidth we are allowed for receiving.
271 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
279 struct PeerInformationMessage
282 * Type is #GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION
284 struct GNUNET_MessageHeader header;
289 uint16_t address_length GNUNET_PACKED;
294 uint16_t plugin_name_length GNUNET_PACKED;
299 struct GNUNET_PeerIdentity peer;
304 uint32_t address_active GNUNET_PACKED;
309 uint32_t id GNUNET_PACKED;
314 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
319 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
322 * Performance properties of the address.
324 struct GNUNET_ATS_PropertiesNBO properties;
327 * Local-only information of the address, see
328 * `enum GNUNET_HELLO_AddressInfo`.
330 uint32_t address_local_info GNUNET_PACKED;
333 * - char address[address_length]
334 * - char plugin_name[plugin_name_length] (including '\0'-termination).
341 * Client to service: please give us an overview of the addresses.
343 struct AddressListRequestMessage
346 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
348 struct GNUNET_MessageHeader header;
351 * ID used to match replies to this request.
353 uint32_t id GNUNET_PACKED;
356 * Which peer do we care about? All zeros for all.
358 struct GNUNET_PeerIdentity peer;
361 * #GNUNET_YES to get information about all addresses,
362 * #GNUNET_NO to only return addresses that are in use.
364 int32_t all GNUNET_PACKED;
372 struct ReservationRequestMessage
375 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
377 struct GNUNET_MessageHeader header;
382 int32_t amount GNUNET_PACKED;
387 struct GNUNET_PeerIdentity peer;
394 struct ReservationResultMessage
397 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT
399 struct GNUNET_MessageHeader header;
404 int32_t amount GNUNET_PACKED;
409 struct GNUNET_PeerIdentity peer;
414 struct GNUNET_TIME_RelativeNBO res_delay;
419 * Variable-size entry in a `struct ChangePreferenceMessage` or
420 * `struct FeedbackPreferenceMessage`.
422 struct PreferenceInformation
426 * An `enum GNUNET_ATS_PreferenceKind` in NBO.
428 uint32_t preference_kind GNUNET_PACKED;
431 * Degree of preference (or appreciation) for this @e
432 * preference_kind being expressed.
434 float preference_value GNUNET_PACKED;
440 * Client to ATS: I have a performance preference for a peer.
442 struct ChangePreferenceMessage
445 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE.
447 struct GNUNET_MessageHeader header;
450 * How many `struct PreferenceInformation` entries follow
453 uint32_t num_preferences GNUNET_PACKED;
456 * Which peer is the preference being expressed for?
458 struct GNUNET_PeerIdentity peer;
460 /* followed by 'num_preferences'
461 * struct PreferenceInformation values */
466 * Message containing application feedback for a peer
468 struct FeedbackPreferenceMessage
471 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK.
473 struct GNUNET_MessageHeader header;
476 * Number of feedback values included
478 uint32_t num_feedback GNUNET_PACKED;
481 * Relative time describing for which time interval this feedback is
483 struct GNUNET_TIME_RelativeNBO scope;
486 * Peer this feedback is for
488 struct GNUNET_PeerIdentity peer;
490 /* followed by 'num_feedback'
491 * struct PreferenceInformation values */
494 GNUNET_NETWORK_STRUCT_END