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
39 * This is a scheduling client (aka transport service)
41 START_FLAG_SCHEDULING = 0,
44 * Performance monitoring client that wants to learn about
45 * changes in performance characteristics.
47 START_FLAG_PERFORMANCE_WITH_PIC = 1,
50 * Performance monitoring client that does NOT want to learn
51 * about changes in performance characteristics.
53 START_FLAG_PERFORMANCE_NO_PIC = 2,
56 * Connection suggestion handle.
58 START_FLAG_CONNECTION_SUGGESTION = 3
62 GNUNET_NETWORK_STRUCT_BEGIN
65 * First message any client sends to ATS, used to self-identify
66 * (what type of client this is).
68 struct ClientStartMessage {
70 * Type is #GNUNET_MESSAGE_TYPE_ATS_START.
72 struct GNUNET_MessageHeader header;
75 * NBO value of an `enum StartFlag`.
77 uint32_t start_flag GNUNET_PACKED;
82 * Connectivity client to ATS service: we would like to have
83 * address suggestions for this peer.
85 struct RequestAddressMessage {
87 * Type is #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS or
88 * #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL to stop
91 struct GNUNET_MessageHeader header;
94 * How "strong" is our need for an address for this peer?
96 uint32_t strength GNUNET_PACKED;
99 * Peer to get address suggestions for.
101 struct GNUNET_PeerIdentity peer;
106 * Scheduling client to ATS service: here is another address you can use.
108 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).
154 * Message used to notify ATS that the performance
155 * characteristics for an address have changed.
157 struct AddressUpdateMessage {
159 * Message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE.
161 struct GNUNET_MessageHeader header;
164 * Internal number this client uses to refer to this address.
166 uint32_t session_id GNUNET_PACKED;
169 * Which peer is this about? (Technically redundant, as the
170 * @e session_id should be sufficient, but enables ATS service
171 * to find the session faster).
173 struct GNUNET_PeerIdentity peer;
176 * Performance properties of the address.
178 struct GNUNET_ATS_PropertiesNBO properties;
183 * Message sent by ATS client to ATS service when an address
184 * was destroyed and must thus henceforth no longer be considered
187 struct AddressDestroyedMessage {
189 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED.
191 struct GNUNET_MessageHeader header;
194 * Internal number this client uses to refer to this address.
196 uint32_t session_id GNUNET_PACKED;
199 * Which peer is this about? (Technically redundant, as the
200 * @e session_id should be sufficient, but enables ATS service
201 * to find the session faster).
203 struct GNUNET_PeerIdentity peer;
208 * Message sent by ATS service to client to confirm that it is done
209 * using the given session ID.
211 struct GNUNET_ATS_SessionReleaseMessage {
213 * Type is #GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE.
215 struct GNUNET_MessageHeader header;
218 * Number the client used to identify the session.
220 uint32_t session_id GNUNET_PACKED;
223 * Which peer is this about? (Technically redundant, as the
224 * @e session_id should be sufficient, but may enable client
225 * to find the session faster).
227 struct GNUNET_PeerIdentity peer;
233 * ATS Service suggests to the transport service to use the address
234 * identified by the given @e session_id for the given @e peer with
235 * the given @e bandwidth_in and @e bandwidth_out limits from now on.
237 struct AddressSuggestionMessage {
239 * A message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION.
241 struct GNUNET_MessageHeader header;
244 * Internal number this client uses to refer to the address this
245 * suggestion is about.
247 uint32_t session_id GNUNET_PACKED;
250 * Which peer is this about? (Technically redundant, as the
251 * @e session_id should be sufficient, but may enable client
252 * to find the session faster and/or check consistency).
254 struct GNUNET_PeerIdentity peer;
257 * How much bandwidth we are allowed for sending.
259 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
262 * How much bandwidth we are allowed for receiving.
264 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
271 struct PeerInformationMessage {
273 * Type is #GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION
275 struct GNUNET_MessageHeader header;
280 uint16_t address_length GNUNET_PACKED;
285 uint16_t plugin_name_length GNUNET_PACKED;
290 struct GNUNET_PeerIdentity peer;
295 uint32_t address_active GNUNET_PACKED;
300 uint32_t id GNUNET_PACKED;
305 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
310 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
313 * Performance properties of the address.
315 struct GNUNET_ATS_PropertiesNBO properties;
318 * Local-only information of the address, see
319 * `enum GNUNET_HELLO_AddressInfo`.
321 uint32_t address_local_info GNUNET_PACKED;
324 * - char address[address_length]
325 * - char plugin_name[plugin_name_length] (including '\0'-termination).
331 * Client to service: please give us an overview of the addresses.
333 struct AddressListRequestMessage {
335 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
337 struct GNUNET_MessageHeader header;
340 * ID used to match replies to this request.
342 uint32_t id GNUNET_PACKED;
345 * Which peer do we care about? All zeros for all.
347 struct GNUNET_PeerIdentity peer;
350 * #GNUNET_YES to get information about all addresses,
351 * #GNUNET_NO to only return addresses that are in use.
353 int32_t all GNUNET_PACKED;
360 struct ReservationRequestMessage {
362 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
364 struct GNUNET_MessageHeader header;
369 int32_t amount GNUNET_PACKED;
374 struct GNUNET_PeerIdentity peer;
381 struct ReservationResultMessage {
383 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT
385 struct GNUNET_MessageHeader header;
390 int32_t amount GNUNET_PACKED;
395 struct GNUNET_PeerIdentity peer;
400 struct GNUNET_TIME_RelativeNBO res_delay;
405 * Variable-size entry in a `struct ChangePreferenceMessage` or
406 * `struct FeedbackPreferenceMessage`.
408 struct PreferenceInformation {
410 * An `enum GNUNET_ATS_PreferenceKind` in NBO.
412 uint32_t preference_kind GNUNET_PACKED;
415 * Degree of preference (or appreciation) for this @e
416 * preference_kind being expressed.
418 float preference_value GNUNET_PACKED;
423 * Client to ATS: I have a performance preference for a peer.
425 struct ChangePreferenceMessage {
427 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE.
429 struct GNUNET_MessageHeader header;
432 * How many `struct PreferenceInformation` entries follow
435 uint32_t num_preferences GNUNET_PACKED;
438 * Which peer is the preference being expressed for?
440 struct GNUNET_PeerIdentity peer;
442 /* followed by 'num_preferences'
443 * struct PreferenceInformation values */
448 * Message containing application feedback for a peer
450 struct FeedbackPreferenceMessage {
452 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK.
454 struct GNUNET_MessageHeader header;
457 * Number of feedback values included
459 uint32_t num_feedback GNUNET_PACKED;
462 * Relative time describing for which time interval this feedback is
464 struct GNUNET_TIME_RelativeNBO scope;
467 * Peer this feedback is for
469 struct GNUNET_PeerIdentity peer;
471 /* followed by 'num_feedback'
472 * struct PreferenceInformation values */
475 GNUNET_NETWORK_STRUCT_END