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/>.
20 * @brief automatic transport selection messages
21 * @author Christian Grothoff
22 * @author Matthias Wachs
27 #include "gnunet_util_lib.h"
28 #include "gnunet_ats_service.h"
32 * 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
71 * Type is #GNUNET_MESSAGE_TYPE_ATS_START.
73 struct GNUNET_MessageHeader header;
76 * NBO value of an `enum StartFlag`.
78 uint32_t start_flag GNUNET_PACKED;
83 * Connectivity client to ATS service: we would like to have
84 * address suggestions for this peer.
86 struct RequestAddressMessage
89 * Type is #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS or
90 * #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL to stop
93 struct GNUNET_MessageHeader header;
96 * How "strong" is our need for an address for this peer?
98 uint32_t strength GNUNET_PACKED;
101 * Peer to get address suggestions for.
103 struct GNUNET_PeerIdentity peer;
108 * Scheduling client to ATS service: here is another address you can use.
110 struct AddressAddMessage
113 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD.
115 struct GNUNET_MessageHeader header;
118 * Number of bytes in the address that follows this struct.
120 uint16_t address_length GNUNET_PACKED;
123 * Number of bytes in the plugin name that follows this struct.
125 uint16_t plugin_name_length GNUNET_PACKED;
128 * Identity of the peer that this address is for.
130 struct GNUNET_PeerIdentity peer;
133 * Internal number this client will henceforth use to
134 * refer to this address.
136 uint32_t session_id GNUNET_PACKED;
139 * Local-only information of the address, see
140 * `enum GNUNET_HELLO_AddressInfo`.
142 uint32_t address_local_info GNUNET_PACKED;
145 * Performance properties of the address.
147 struct GNUNET_ATS_PropertiesNBO properties;
150 * - char address[address_length]
151 * - 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;
189 * Message sent by ATS client to ATS service when an address
190 * was destroyed and must thus henceforth no longer be considered
193 struct AddressDestroyedMessage
196 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED.
198 struct GNUNET_MessageHeader header;
201 * Internal number this client uses to refer to this address.
203 uint32_t session_id GNUNET_PACKED;
206 * Which peer is this about? (Technically redundant, as the
207 * @e session_id should be sufficient, but enables ATS service
208 * to find the session faster).
210 struct GNUNET_PeerIdentity peer;
216 * Message sent by ATS service to client to confirm that it is done
217 * using the given session ID.
219 struct GNUNET_ATS_SessionReleaseMessage
222 * Type is #GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE.
224 struct GNUNET_MessageHeader header;
227 * Number the client used to identify the session.
229 uint32_t session_id GNUNET_PACKED;
232 * Which peer is this about? (Technically redundant, as the
233 * @e session_id should be sufficient, but may enable client
234 * to find the session faster).
236 struct GNUNET_PeerIdentity peer;
242 * ATS Service suggests to the transport service to use the address
243 * identified by the given @e session_id for the given @e peer with
244 * the given @e bandwidth_in and @e bandwidth_out limits from now on.
246 struct AddressSuggestionMessage
249 * A message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION.
251 struct GNUNET_MessageHeader header;
254 * Internal number this client uses to refer to the address this
255 * suggestion is about.
257 uint32_t session_id GNUNET_PACKED;
260 * Which peer is this about? (Technically redundant, as the
261 * @e session_id should be sufficient, but may enable client
262 * to find the session faster and/or check consistency).
264 struct GNUNET_PeerIdentity peer;
267 * How much bandwidth we are allowed for sending.
269 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
272 * How much bandwidth we are allowed for receiving.
274 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
282 struct PeerInformationMessage
285 * Type is #GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION
287 struct GNUNET_MessageHeader header;
292 uint16_t address_length GNUNET_PACKED;
297 uint16_t plugin_name_length GNUNET_PACKED;
302 struct GNUNET_PeerIdentity peer;
307 uint32_t address_active GNUNET_PACKED;
312 uint32_t id GNUNET_PACKED;
317 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
322 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
325 * Performance properties of the address.
327 struct GNUNET_ATS_PropertiesNBO properties;
330 * Local-only information of the address, see
331 * `enum GNUNET_HELLO_AddressInfo`.
333 uint32_t address_local_info GNUNET_PACKED;
336 * - char address[address_length]
337 * - char plugin_name[plugin_name_length] (including '\0'-termination).
344 * Client to service: please give us an overview of the addresses.
346 struct AddressListRequestMessage
349 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
351 struct GNUNET_MessageHeader header;
354 * ID used to match replies to this request.
356 uint32_t id GNUNET_PACKED;
359 * Which peer do we care about? All zeros for all.
361 struct GNUNET_PeerIdentity peer;
364 * #GNUNET_YES to get information about all addresses,
365 * #GNUNET_NO to only return addresses that are in use.
367 int32_t all GNUNET_PACKED;
375 struct ReservationRequestMessage
378 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
380 struct GNUNET_MessageHeader header;
385 int32_t amount GNUNET_PACKED;
390 struct GNUNET_PeerIdentity peer;
397 struct ReservationResultMessage
400 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT
402 struct GNUNET_MessageHeader header;
407 int32_t amount GNUNET_PACKED;
412 struct GNUNET_PeerIdentity peer;
417 struct GNUNET_TIME_RelativeNBO res_delay;
422 * Variable-size entry in a `struct ChangePreferenceMessage` or
423 * `struct FeedbackPreferenceMessage`.
425 struct PreferenceInformation
429 * An `enum GNUNET_ATS_PreferenceKind` in NBO.
431 uint32_t preference_kind GNUNET_PACKED;
434 * Degree of preference (or appreciation) for this @e
435 * preference_kind being expressed.
437 float preference_value GNUNET_PACKED;
443 * Client to ATS: I have a performance preference for a peer.
445 struct ChangePreferenceMessage
448 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE.
450 struct GNUNET_MessageHeader header;
453 * How many `struct PreferenceInformation` entries follow
456 uint32_t num_preferences GNUNET_PACKED;
459 * Which peer is the preference being expressed for?
461 struct GNUNET_PeerIdentity peer;
463 /* followed by 'num_preferences'
464 * struct PreferenceInformation values */
469 * Message containing application feedback for a peer
471 struct FeedbackPreferenceMessage
474 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK.
476 struct GNUNET_MessageHeader header;
479 * Number of feedback values included
481 uint32_t num_feedback GNUNET_PACKED;
484 * Relative time describing for which time interval this feedback is
486 struct GNUNET_TIME_RelativeNBO scope;
489 * Peer this feedback is for
491 struct GNUNET_PeerIdentity peer;
493 /* followed by 'num_feedback'
494 * struct PreferenceInformation values */
497 GNUNET_NETWORK_STRUCT_END