2 This file is part of GNUnet.
3 Copyright (C) 2010-2015 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, 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 * Scheduling 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;
100 uint32_t reserved GNUNET_PACKED;
103 * Peer to get address suggestions for.
105 struct GNUNET_PeerIdentity peer;
110 * ATS 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 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 * - char address[address_length]
333 * - char plugin_name[plugin_name_length] (including '\0'-termination).
340 * Client to service: please give us an overview of the addresses.
342 struct AddressListRequestMessage
345 * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
347 struct GNUNET_MessageHeader header;
350 * ID used to match replies to this request.
352 uint32_t id GNUNET_PACKED;
355 * Which peer do we care about? All zeros for all.
357 struct GNUNET_PeerIdentity peer;
360 * #GNUNET_YES to get information about all addresses,
361 * #GNUNET_NO to only return addresses that are in use.
363 int32_t all GNUNET_PACKED;
371 struct ReservationRequestMessage
374 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
376 struct GNUNET_MessageHeader header;
381 int32_t amount GNUNET_PACKED;
386 struct GNUNET_PeerIdentity peer;
393 struct ReservationResultMessage
396 * Type is #GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT
398 struct GNUNET_MessageHeader header;
403 int32_t amount GNUNET_PACKED;
408 struct GNUNET_PeerIdentity peer;
413 struct GNUNET_TIME_RelativeNBO res_delay;
418 * Variable-size entry in a `struct ChangePreferenceMessage` or
419 * `struct FeedbackPreferenceMessage`.
421 struct PreferenceInformation
425 * An `enum GNUNET_ATS_PreferenceKind` in NBO.
427 uint32_t preference_kind GNUNET_PACKED;
430 * Degree of preference (or appreciation) for this @e
431 * preference_kind being expressed.
433 float preference_value GNUNET_PACKED;
439 * Client to ATS: I have a performance preference for a peer.
441 struct ChangePreferenceMessage
444 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE.
446 struct GNUNET_MessageHeader header;
449 * How many `struct PreferenceInformation` entries follow
452 uint32_t num_preferences GNUNET_PACKED;
455 * Which peer is the preference being expressed for?
457 struct GNUNET_PeerIdentity peer;
459 /* followed by 'num_preferences'
460 * struct PreferenceInformation values */
465 * Message containing application feedback for a peer
467 struct FeedbackPreferenceMessage
470 * Type is #GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK.
472 struct GNUNET_MessageHeader header;
475 * Number of feedback values included
477 uint32_t num_feedback GNUNET_PACKED;
480 * Relative time describing for which time interval this feedback is
482 struct GNUNET_TIME_RelativeNBO scope;
485 * Peer this feedback is for
487 struct GNUNET_PeerIdentity peer;
489 /* followed by 'num_feedback'
490 * struct PreferenceInformation values */
493 GNUNET_NETWORK_STRUCT_END