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.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @brief automatic transport selection messages
23 * @author Christian Grothoff
24 * @author Matthias Wachs
29 #include "gnunet_util_lib.h"
30 #include "gnunet_ats_service.h"
34 * Flag used to indicate which type of client is connecting
40 * This is a scheduling client (aka transport service)
42 START_FLAG_SCHEDULING = 0,
45 * Performance monitoring client that wants to learn about
46 * changes in performance characteristics.
48 START_FLAG_PERFORMANCE_WITH_PIC = 1,
51 * Performance monitoring client that does NOT want to learn
52 * about changes in performance characteristics.
54 START_FLAG_PERFORMANCE_NO_PIC = 2,
57 * Connection suggestion handle.
59 START_FLAG_CONNECTION_SUGGESTION = 3
63 GNUNET_NETWORK_STRUCT_BEGIN
66 * First message any client sends to ATS, used to self-identify
67 * (what type of client this is).
69 struct ClientStartMessage
72 * Type is #GNUNET_MESSAGE_TYPE_ATS_START.
74 struct GNUNET_MessageHeader header;
77 * NBO value of an `enum StartFlag`.
79 uint32_t start_flag GNUNET_PACKED;
84 * Connectivity client to ATS service: we would like to have
85 * address suggestions for this peer.
87 struct RequestAddressMessage
90 * Type is #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS or
91 * #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL to stop
94 struct GNUNET_MessageHeader header;
97 * How "strong" is our need for an address for this peer?
99 uint32_t strength GNUNET_PACKED;
102 * Peer to get address suggestions for.
104 struct GNUNET_PeerIdentity peer;
109 * Scheduling client to ATS service: here is another address you can use.
111 struct AddressAddMessage
114 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD.
116 struct GNUNET_MessageHeader header;
119 * Number of bytes in the address that follows this struct.
121 uint16_t address_length GNUNET_PACKED;
124 * Number of bytes in the plugin name that follows this struct.
126 uint16_t plugin_name_length GNUNET_PACKED;
129 * Identity of the peer that this address is for.
131 struct GNUNET_PeerIdentity peer;
134 * Internal number this client will henceforth use to
135 * refer to this address.
137 uint32_t session_id GNUNET_PACKED;
140 * Local-only information of the address, see
141 * `enum GNUNET_HELLO_AddressInfo`.
143 uint32_t address_local_info GNUNET_PACKED;
146 * Performance properties of the address.
148 struct GNUNET_ATS_PropertiesNBO properties;
151 * - char address[address_length]
152 * - char plugin_name[plugin_name_length] (including '\0'-termination).
158 * Message used to notify ATS that the performance
159 * characteristics for an address have changed.
161 struct AddressUpdateMessage
164 * Message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE.
166 struct GNUNET_MessageHeader header;
169 * Internal number this client uses to refer to this address.
171 uint32_t session_id GNUNET_PACKED;
174 * Which peer is this about? (Technically redundant, as the
175 * @e session_id should be sufficient, but enables ATS service
176 * to find the session faster).
178 struct GNUNET_PeerIdentity peer;
181 * Performance properties of the address.
183 struct GNUNET_ATS_PropertiesNBO properties;
188 * Message sent by ATS client to ATS service when an address
189 * was destroyed and must thus henceforth no longer be considered
192 struct AddressDestroyedMessage
195 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED.
197 struct GNUNET_MessageHeader header;
200 * Internal number this client uses to refer to this address.
202 uint32_t session_id GNUNET_PACKED;
205 * Which peer is this about? (Technically redundant, as the
206 * @e session_id should be sufficient, but enables ATS service
207 * to find the session faster).
209 struct GNUNET_PeerIdentity peer;
214 * Message sent by ATS service to client to confirm that it is done
215 * using the given session ID.
217 struct GNUNET_ATS_SessionReleaseMessage
220 * Type is #GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE.
222 struct GNUNET_MessageHeader header;
225 * Number the client used to identify the session.
227 uint32_t session_id GNUNET_PACKED;
230 * Which peer is this about? (Technically redundant, as the
231 * @e session_id should be sufficient, but may enable client
232 * to find the session faster).
234 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;
278 struct PeerInformationMessage
281 * Type is #GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION
283 struct GNUNET_MessageHeader header;
288 uint16_t address_length GNUNET_PACKED;
293 uint16_t plugin_name_length GNUNET_PACKED;
298 struct GNUNET_PeerIdentity peer;
303 uint32_t address_active GNUNET_PACKED;
308 uint32_t id GNUNET_PACKED;
313 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
318 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
321 * Performance properties of the address.
323 struct GNUNET_ATS_PropertiesNBO properties;
326 * Local-only information of the address, see
327 * `enum GNUNET_HELLO_AddressInfo`.
329 uint32_t address_local_info GNUNET_PACKED;
332 * - char address[address_length]
333 * - char plugin_name[plugin_name_length] (including '\0'-termination).
339 * Client to service: please give us an overview of the addresses.
341 struct AddressListRequestMessage
344 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
346 struct GNUNET_MessageHeader header;
349 * ID used to match replies to this request.
351 uint32_t id GNUNET_PACKED;
354 * Which peer do we care about? All zeros for all.
356 struct GNUNET_PeerIdentity peer;
359 * #GNUNET_YES to get information about all addresses,
360 * #GNUNET_NO to only return addresses that are in use.
362 int32_t all GNUNET_PACKED;
369 struct ReservationRequestMessage
372 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
374 struct GNUNET_MessageHeader header;
379 int32_t amount GNUNET_PACKED;
384 struct GNUNET_PeerIdentity peer;
391 struct ReservationResultMessage
394 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT
396 struct GNUNET_MessageHeader header;
401 int32_t amount GNUNET_PACKED;
406 struct GNUNET_PeerIdentity peer;
411 struct GNUNET_TIME_RelativeNBO res_delay;
416 * Variable-size entry in a `struct ChangePreferenceMessage` or
417 * `struct FeedbackPreferenceMessage`.
419 struct PreferenceInformation
422 * An `enum GNUNET_ATS_PreferenceKind` in NBO.
424 uint32_t preference_kind GNUNET_PACKED;
427 * Degree of preference (or appreciation) for this @e
428 * preference_kind being expressed.
430 float preference_value GNUNET_PACKED;
435 * Client to ATS: I have a performance preference for a peer.
437 struct ChangePreferenceMessage
440 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE.
442 struct GNUNET_MessageHeader header;
445 * How many `struct PreferenceInformation` entries follow
448 uint32_t num_preferences GNUNET_PACKED;
451 * Which peer is the preference being expressed for?
453 struct GNUNET_PeerIdentity peer;
455 /* followed by 'num_preferences'
456 * struct PreferenceInformation values */
461 * Message containing application feedback for a peer
463 struct FeedbackPreferenceMessage
466 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK.
468 struct GNUNET_MessageHeader header;
471 * Number of feedback values included
473 uint32_t num_feedback GNUNET_PACKED;
476 * Relative time describing for which time interval this feedback is
478 struct GNUNET_TIME_RelativeNBO scope;
481 * Peer this feedback is for
483 struct GNUNET_PeerIdentity peer;
485 /* followed by 'num_feedback'
486 * struct PreferenceInformation values */
489 GNUNET_NETWORK_STRUCT_END