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
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.
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.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
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
41 * This is a scheduling client (aka transport service)
43 START_FLAG_SCHEDULING = 0,
46 * Performance monitoring client that wants to learn about
47 * changes in performance characteristics.
49 START_FLAG_PERFORMANCE_WITH_PIC = 1,
52 * Performance monitoring client that does NOT want to learn
53 * about changes in performance characteristics.
55 START_FLAG_PERFORMANCE_NO_PIC = 2,
58 * Connection suggestion handle.
60 START_FLAG_CONNECTION_SUGGESTION = 3
64 GNUNET_NETWORK_STRUCT_BEGIN
67 * First message any client sends to ATS, used to self-identify
68 * (what type of client this is).
70 struct ClientStartMessage
73 * Type is #GNUNET_MESSAGE_TYPE_ATS_START.
75 struct GNUNET_MessageHeader header;
78 * NBO value of an `enum StartFlag`.
80 uint32_t start_flag GNUNET_PACKED;
85 * Connectivity client to ATS service: we would like to have
86 * address suggestions for this peer.
88 struct RequestAddressMessage
91 * Type is #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS or
92 * #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL to stop
95 struct GNUNET_MessageHeader header;
98 * How "strong" is our need for an address for this peer?
100 uint32_t strength GNUNET_PACKED;
103 * Peer to get address suggestions for.
105 struct GNUNET_PeerIdentity peer;
110 * Scheduling client to ATS service: here is another address you can use.
112 struct AddressAddMessage
115 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD.
117 struct GNUNET_MessageHeader header;
120 * Number of bytes in the address that follows this struct.
122 uint16_t address_length GNUNET_PACKED;
125 * Number of bytes in the plugin name that follows this struct.
127 uint16_t plugin_name_length GNUNET_PACKED;
130 * Identity of the peer that this address is for.
132 struct GNUNET_PeerIdentity peer;
135 * Internal number this client will henceforth use to
136 * refer to this address.
138 uint32_t session_id GNUNET_PACKED;
141 * Local-only information of the address, see
142 * `enum GNUNET_HELLO_AddressInfo`.
144 uint32_t address_local_info GNUNET_PACKED;
147 * Performance properties of the address.
149 struct GNUNET_ATS_PropertiesNBO properties;
152 * - char address[address_length]
153 * - char plugin_name[plugin_name_length] (including '\0'-termination).
160 * Message used to notify ATS that the performance
161 * characteristics for an address have changed.
163 struct AddressUpdateMessage
166 * Message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE.
168 struct GNUNET_MessageHeader header;
171 * Internal number this client uses to refer to this address.
173 uint32_t session_id GNUNET_PACKED;
176 * Which peer is this about? (Technically redundant, as the
177 * @e session_id should be sufficient, but enables ATS service
178 * to find the session faster).
180 struct GNUNET_PeerIdentity peer;
183 * Performance properties of the address.
185 struct GNUNET_ATS_PropertiesNBO properties;
191 * Message sent by ATS client to ATS service when an address
192 * was destroyed and must thus henceforth no longer be considered
195 struct AddressDestroyedMessage
198 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED.
200 struct GNUNET_MessageHeader header;
203 * Internal number this client uses to refer to this address.
205 uint32_t session_id GNUNET_PACKED;
208 * Which peer is this about? (Technically redundant, as the
209 * @e session_id should be sufficient, but enables ATS service
210 * to find the session faster).
212 struct GNUNET_PeerIdentity peer;
218 * Message sent by ATS service to client to confirm that it is done
219 * using the given session ID.
221 struct GNUNET_ATS_SessionReleaseMessage
224 * Type is #GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE.
226 struct GNUNET_MessageHeader header;
229 * Number the client used to identify the session.
231 uint32_t session_id GNUNET_PACKED;
234 * Which peer is this about? (Technically redundant, as the
235 * @e session_id should be sufficient, but may enable client
236 * to find the session faster).
238 struct GNUNET_PeerIdentity peer;
244 * ATS Service suggests to the transport service to use the address
245 * identified by the given @e session_id for the given @e peer with
246 * the given @e bandwidth_in and @e bandwidth_out limits from now on.
248 struct AddressSuggestionMessage
251 * A message of type #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION.
253 struct GNUNET_MessageHeader header;
256 * Internal number this client uses to refer to the address this
257 * suggestion is about.
259 uint32_t session_id GNUNET_PACKED;
262 * Which peer is this about? (Technically redundant, as the
263 * @e session_id should be sufficient, but may enable client
264 * to find the session faster and/or check consistency).
266 struct GNUNET_PeerIdentity peer;
269 * How much bandwidth we are allowed for sending.
271 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
274 * How much bandwidth we are allowed for receiving.
276 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
284 struct PeerInformationMessage
287 * Type is #GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION
289 struct GNUNET_MessageHeader header;
294 uint16_t address_length GNUNET_PACKED;
299 uint16_t plugin_name_length GNUNET_PACKED;
304 struct GNUNET_PeerIdentity peer;
309 uint32_t address_active GNUNET_PACKED;
314 uint32_t id GNUNET_PACKED;
319 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
324 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
327 * Performance properties of the address.
329 struct GNUNET_ATS_PropertiesNBO properties;
332 * Local-only information of the address, see
333 * `enum GNUNET_HELLO_AddressInfo`.
335 uint32_t address_local_info GNUNET_PACKED;
338 * - char address[address_length]
339 * - char plugin_name[plugin_name_length] (including '\0'-termination).
346 * Client to service: please give us an overview of the addresses.
348 struct AddressListRequestMessage
351 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
353 struct GNUNET_MessageHeader header;
356 * ID used to match replies to this request.
358 uint32_t id GNUNET_PACKED;
361 * Which peer do we care about? All zeros for all.
363 struct GNUNET_PeerIdentity peer;
366 * #GNUNET_YES to get information about all addresses,
367 * #GNUNET_NO to only return addresses that are in use.
369 int32_t all GNUNET_PACKED;
377 struct ReservationRequestMessage
380 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
382 struct GNUNET_MessageHeader header;
387 int32_t amount GNUNET_PACKED;
392 struct GNUNET_PeerIdentity peer;
399 struct ReservationResultMessage
402 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT
404 struct GNUNET_MessageHeader header;
409 int32_t amount GNUNET_PACKED;
414 struct GNUNET_PeerIdentity peer;
419 struct GNUNET_TIME_RelativeNBO res_delay;
424 * Variable-size entry in a `struct ChangePreferenceMessage` or
425 * `struct FeedbackPreferenceMessage`.
427 struct PreferenceInformation
431 * An `enum GNUNET_ATS_PreferenceKind` in NBO.
433 uint32_t preference_kind GNUNET_PACKED;
436 * Degree of preference (or appreciation) for this @e
437 * preference_kind being expressed.
439 float preference_value GNUNET_PACKED;
445 * Client to ATS: I have a performance preference for a peer.
447 struct ChangePreferenceMessage
450 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE.
452 struct GNUNET_MessageHeader header;
455 * How many `struct PreferenceInformation` entries follow
458 uint32_t num_preferences GNUNET_PACKED;
461 * Which peer is the preference being expressed for?
463 struct GNUNET_PeerIdentity peer;
465 /* followed by 'num_preferences'
466 * struct PreferenceInformation values */
471 * Message containing application feedback for a peer
473 struct FeedbackPreferenceMessage
476 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK.
478 struct GNUNET_MessageHeader header;
481 * Number of feedback values included
483 uint32_t num_feedback GNUNET_PACKED;
486 * Relative time describing for which time interval this feedback is
488 struct GNUNET_TIME_RelativeNBO scope;
491 * Peer this feedback is for
493 struct GNUNET_PeerIdentity peer;
495 /* followed by 'num_feedback'
496 * struct PreferenceInformation values */
499 GNUNET_NETWORK_STRUCT_END