lib_LTLIBRARIES = libgnunetats.la
libgnunetats_la_SOURCES = \
- ats_api.c ats_api.h \
- ats_api_peer_change_preference.c
+ ats_api_new.c \
+ ats_api_performance.c
libgnunetats_la_LIBADD = \
$(top_builddir)/src/util/libgnunetutil.la
--- /dev/null
+/*
+ This file is part of GNUnet.
+ (C) 2010,2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file ats/ats.h
+ * @brief automatic transport selection messages
+ * @author Christian Grothoff
+ * @author Matthias Wachs
+ */
+#ifndef ATS_H
+#define ATS_H
+
+#include "gnunet_util_lib.h"
+
+
+enum StartFlag
+{
+
+ START_FLAG_SCHEDULING = 0,
+
+ START_FLAG_PERFORMANCE_WITH_PIC = 1,
+
+ START_FLAG_PERFORMANCE_NO_PIC = 2
+
+};
+
+
+
+struct ClientStart
+{
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * NBO value of an 'enum StartFlag'.
+ */
+ uint32_t start_flag;
+};
+
+
+
+struct RequestAddressMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ uint32_t reserved GNUNET_PACKED;
+
+ struct GNUNET_PeerIdentity peer;
+};
+
+struct AddressUpdateMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ uint32_t ats_count GNUNET_PACKED;
+
+ struct GNUNET_PeerIdentity peer;
+
+ uint16_t address_length GNUNET_PACKED;
+
+ uint16_t plugin_name_length GNUNET_PACKED;
+
+ uint32_t session_id GNUNET_PACKED;
+
+ /* followed by:
+ - struct GNUNET_TRANSPORT_ATS_Information [ats_count];
+ - char address[address_length]
+ - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
+
+};
+
+struct AddressDestroyedMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ uint32_t reserved GNUNET_PACKED;
+
+ struct GNUNET_PeerIdentity peer;
+
+ uint16_t address_length GNUNET_PACKED;
+
+ uint16_t plugin_name_length GNUNET_PACKED;
+
+ uint32_t session_id GNUNET_PACKED;
+
+ /* followed by:
+ - char address[address_length]
+ - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
+
+};
+
+
+struct AddressSuggestionMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ uint32_t reserved GNUNET_PACKED;
+
+ struct GNUNET_PeerIdentity peer;
+
+ uint16_t address_length GNUNET_PACKED;
+
+ uint16_t plugin_name_length GNUNET_PACKED;
+
+ uint32_t session_id GNUNET_PACKED;
+
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
+
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
+
+ /* followed by:
+ - char address[address_length]
+ - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
+
+};
+
+
+
+struct PeerInformationMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ uint32_t ats_count GNUNET_PACKED;
+
+ struct GNUNET_PeerIdentity peer;
+
+ uint16_t address_length GNUNET_PACKED;
+
+ uint16_t plugin_name_length GNUNET_PACKED;
+
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
+
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
+
+ /* followed by:
+ - struct GNUNET_TRANSPORT_ATS_Information [ats_count];
+ - char address[address_length]
+ - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
+
+};
+
+
+
+
+struct ReservationRequestMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ int32_t amount GNUNET_PACKED;
+
+ struct GNUNET_PeerIdentity peer;
+};
+
+
+struct ReservationResultMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ int32_t amount GNUNET_PACKED;
+
+ struct GNUNET_PeerIdentity peer;
+
+ struct GNUNET_TIME_RelativeNBO res_delay;
+};
+
+
+struct PreferenceInformation
+{
+
+ uint32_t preference_kind GNUNET_PACKED;
+
+ float preference_value GNUNET_PACKED;
+
+};
+
+
+struct ChangePreferenceMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ uint32_t num_preferences GNUNET_PACKED;
+
+ struct GNUNET_PeerIdentity peer;
+
+ /* followed by 'num_preferences'
+ struct PreferenceInformation values */
+};
+
+
+
+#endif
/**
* Global ATS handle.
*/
- struct GNUNET_ATS_Handle *atc;
+ struct GNUNET_ATS_SchedulingHandle *atc;
/**
* Which peer are we monitoring?
/**
* ATS handle.
*/
- struct GNUNET_ATS_Handle *atc;
+ struct GNUNET_ATS_SchedulingHandle *atc;
/**
* Inbound bandwidth to assign.
/**
* Task run to update bandwidth assignments.
*
- * @param cls the 'struct GNUNET_ATS_Handle'
+ * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
* @param tc scheduler context
*/
static void
update_bandwidth_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct GNUNET_ATS_Handle *atc = cls;
+ struct GNUNET_ATS_SchedulingHandle *atc = cls;
unsigned int ac = 0;
struct SetBandwidthContext bwc;
* @param change which allocation record changed?
*/
static void
-update_bandwidth_assignment (struct GNUNET_ATS_Handle *atc,
+update_bandwidth_assignment (struct GNUNET_ATS_SchedulingHandle *atc,
struct AllocationRecord *change)
{
/* FIXME: based on the 'change', update the LP-problem... */
* @param cb_cls closure for cb
*/
struct GNUNET_ATS_SuggestionContext *
-GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc,
+GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *atc,
const struct GNUNET_PeerIdentity *peer,
GNUNET_ATS_AddressSuggestionCallback cb,
void *cb_cls)
* @param alloc_cb_cls closure for 'alloc_cb'
* @return ats context
*/
-struct GNUNET_ATS_Handle *
+struct GNUNET_ATS_SchedulingHandle *
GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_ATS_AddressSuggestionCallback alloc_cb,
void *alloc_cb_cls)
{
- struct GNUNET_ATS_Handle *atc;
+ struct GNUNET_ATS_SchedulingHandle *atc;
#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS init\n");
#endif
- atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_Handle));
+ atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SchedulingHandle));
atc->cfg = cfg;
atc->alloc_cb = alloc_cb;
atc->alloc_cb_cls = alloc_cb_cls;
* @param atc handle
*/
void
-GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc)
+GNUNET_ATS_shutdown (struct GNUNET_ATS_SchedulingHandle *atc)
{
#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS shutdown\n");
/**
* Ats handle.
*/
- struct GNUNET_ATS_Handle *atc;
+ struct GNUNET_ATS_SchedulingHandle *atc;
/**
* Allocation record with new information.
static int
disconnect_peer (void *cls, const GNUNET_HashCode * key, void *value)
{
- struct GNUNET_ATS_Handle *atc = cls;
+ struct GNUNET_ATS_SchedulingHandle *atc = cls;
struct AllocationRecord *ar = value;
if (GNUNET_YES == ar->connected)
* @param ats_count number of performance records in 'ats'
*/
void
-GNUNET_ATS_peer_connect (struct GNUNET_ATS_Handle *atc,
+GNUNET_ATS_peer_connect (struct GNUNET_ATS_SchedulingHandle *atc,
const struct GNUNET_PeerIdentity *peer,
const char *plugin_name, struct Session *session,
const void *plugin_addr, size_t plugin_addr_len,
* @param peer identity of the new peer
*/
void
-GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_Handle *atc,
+GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_SchedulingHandle *atc,
const struct GNUNET_PeerIdentity *peer)
{
#if DEBUG_ATS
/**
* Ats handle.
*/
- struct GNUNET_ATS_Handle *atc;
+ struct GNUNET_ATS_SchedulingHandle *atc;
/**
* Session being destroyed.
* @param session session handle that is no longer valid
*/
void
-GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc,
+GNUNET_ATS_session_destroyed (struct GNUNET_ATS_SchedulingHandle *atc,
const struct GNUNET_PeerIdentity *peer,
const struct Session *session)
{
* @param ats_count number of performance records in 'ats'
*/
void
-GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc,
+GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
const struct GNUNET_PeerIdentity *peer,
struct GNUNET_TIME_Absolute valid_until,
const char *plugin_name, struct Session *session,
/**
* Handle to the ATS subsystem.
*/
-struct GNUNET_ATS_Handle
+struct GNUNET_ATS_SchedulingHandle
{
/**
* Configuration.
--- /dev/null
+/*
+ This file is part of GNUnet.
+ (C) 2010,2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file include/gnunet_ats_service.h
+ * @brief automatic transport selection and outbound bandwidth determination
+ * @author Christian Grothoff
+ * @author Matthias Wachs
+ */
+#include "platform.h"
+#include "gnunet_ats_service.h"
+
+
+/**
+ * Handle to the ATS subsystem for bandwidth/transport scheduling information.
+ */
+struct GNUNET_ATS_SchedulingHandle
+{
+};
+
+
+/**
+ * Initialize the ATS subsystem.
+ *
+ * @param cfg configuration to use
+ * @param alloc_cb notification to call whenever the allocation changed
+ * @param alloc_cb_cls closure for 'alloc_cb'
+ * @return ats context
+ */
+struct GNUNET_ATS_SchedulingHandle *
+GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ATS_AddressSuggestionCallback alloc_cb,
+ void *alloc_cb_cls)
+{
+ return NULL;
+}
+
+
+/**
+ * Client is done with ATS scheduling, release resources.
+ *
+ * @param atc handle to release
+ */
+void
+GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *atc)
+{
+}
+
+
+/**
+ * We would like to establish a new connection with a peer. ATS
+ * should suggest a good address to begin with.
+ *
+ * @param atc handle
+ * @param peer identity of the peer we need an address for
+ */
+void
+GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *atc,
+ const struct GNUNET_PeerIdentity *peer)
+{
+}
+
+
+/**
+ * We have updated performance statistics for a given address. Note
+ * that this function can be called for addresses that are currently
+ * in use as well as addresses that are valid but not actively in use.
+ * Furthermore, the peer may not even be connected to us right now (in
+ * which case the call may be ignored or the information may be stored
+ * for later use). Update bandwidth assignments.
+ *
+ * @param atc handle
+ * @param peer identity of the new peer
+ * @param plugin_name name of the transport plugin
+ * @param plugin_addr address (if available)
+ * @param plugin_addr_len number of bytes in plugin_addr
+ * @param session session handle (if available)
+ * @param ats performance data for the address
+ * @param ats_count number of performance records in 'ats'
+ */
+void
+GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr, size_t plugin_addr_len,
+ struct Session *session,
+ const struct GNUNET_TRANSPORT_ATS_Information *ats,
+ uint32_t ats_count)
+{
+}
+
+
+/**
+ * A session got destroyed, stop including it as a valid address.
+ *
+ * @param atc handle
+ * @param peer identity of the peer
+ * @param plugin_name name of the transport plugin
+ * @param plugin_addr address (if available)
+ * @param plugin_addr_len number of bytes in plugin_addr
+ * @param session session handle that is no longer valid
+ */
+void
+GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *atc,
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ const struct Session *session)
+{
+}
+
+/* end of ats_api_new.c */
/**
* Our connection to the service.
*/
- struct GNUNET_ATS_Handle *h;
+ struct GNUNET_ATS_SchedulingHandle *h;
int32_t amount;
* @return NULL on error
*/
struct GNUNET_ATS_InformationRequestContext *
-GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h,
+GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
const struct GNUNET_PeerIdentity *peer,
int32_t amount, uint64_t preference,
GNUNET_ATS_PeerConfigurationInfoCallback
/**
* Our connection to the service.
*/
- struct GNUNET_ATS_Handle *h;
+ struct GNUNET_ATS_SchedulingHandle *h;
/**
* Link to control message, NULL if CM was sent.
* @return NULL on error
*/
struct GNUNET_ATS_InformationRequestContext *
-GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h,
+GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
const struct GNUNET_PeerIdentity *peer,
int32_t amount, uint64_t preference,
GNUNET_ATS_PeerConfigurationInfoCallback
GNUNET_ATS_InformationRequestContext
*irc)
{
- struct GNUNET_ATS_Handle *h = irc->h;
+ struct GNUNET_ATS_SchedulingHandle *h = irc->h;
struct PeerRecord *pr = irc->pr;
GNUNET_assert (pr->pcic_ptr == irc);
--- /dev/null
+/*
+ This file is part of GNUnet.
+ (C) 2010,2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file include/gnunet_ats_service.h
+ * @brief automatic transport selection and outbound bandwidth determination
+ * @author Christian Grothoff
+ * @author Matthias Wachs
+ */
+#include "platform.h"
+#include "gnunet_ats_service.h"
+
+/* ******************************** Performance API ***************************** */
+
+/**
+ * ATS Handle to obtain and/or modify performance information.
+ */
+struct GNUNET_ATS_PerformanceHandle
+{
+};
+
+
+/**
+ * Get handle to access performance API of the ATS subsystem.
+ *
+ * @param cfg configuration to use
+ * @param infocb function to call on allocation changes, can be NULL
+ * @param infocb_cls closure for infocb
+ * @return ats performance context
+ */
+struct GNUNET_ATS_PerformanceHandle *
+GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ATS_PeerInformationCallback infocb,
+ void *infocb_cls)
+{
+ return NULL;
+}
+
+
+/**
+ * Client is done using the ATS performance subsystem, release resources.
+ *
+ * @param atc handle
+ */
+void
+GNUNET_ATS_performance_done (struct GNUNET_ATS_SchedulingHandle *atc)
+{
+}
+
+
+/**
+ * Context that can be used to cancel a peer information request.
+ */
+struct GNUNET_ATS_ReservationContext
+{
+};
+
+
+/**
+ * Reserve inbound bandwidth from the given peer. ATS will look at
+ * the current amount of traffic we receive from the peer and ensure
+ * that the peer could add 'amount' of data to its stream.
+ *
+ * @param h core handle
+ * @param peer identifies the peer
+ * @param amount reserve N bytes for receiving, negative
+ * amounts can be used to undo a (recent) reservation;
+ * @param info function to call with the resulting reservation information
+ * @param info_cls closure for info
+ * @return NULL on error
+ * @deprecated will be replaced soon
+ */
+struct GNUNET_ATS_ReservationContext *
+GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *h,
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount,
+ GNUNET_ATS_ReservationCallback info,
+ void *info_cls)
+{
+ return NULL;
+}
+
+
+/**
+ * Cancel request for reserving bandwidth.
+ *
+ * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
+ */
+void
+GNUNET_ATS_reserve_bandwidth_cancel (struct
+ GNUNET_ATS_ReservationContext *rc)
+{
+}
+
+
+/**
+ * Change preferences for the given peer. Preference changes are forgotten if peers
+ * disconnect.
+ *
+ * @param cls closure
+ * @param peer identifies the peer
+ * @param ... 0-terminated specification of the desired changes
+ */
+void
+GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *h,
+ const struct GNUNET_PeerIdentity *peer,
+ ...)
+{
+}
+
+/* end of ats_api_performance.c */
+
static struct GNUNET_CONFIGURATION_Handle *cfg;
-static struct GNUNET_ATS_Handle *ats;
+static struct GNUNET_ATS_SchedulingHandle *ats;
static void
alloc_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
#define VALID GNUNET_TIME_absolute_get_forever ()
-static struct GNUNET_ATS_Handle *ats;
+static struct GNUNET_ATS_SchedulingHandle *ats;
static struct GNUNET_ATS_SuggestionContext *asc;
/**
* Handle to ATS.
*/
-static struct GNUNET_ATS_Handle *atsAPI;
+static struct GNUNET_ATS_SchedulingHandle *atsAPI;
/**
* Handle to ATS service.
*/
-static struct GNUNET_ATS_Handle *ats;
+static struct GNUNET_ATS_SchedulingHandle *ats;
/**
* Get the filename under which we would store the GNUNET_HELLO_Message
*
* TODO:
* - move GNUNET_TRANSPORT_ATS* in here and rename...
- * - extend API to express communication preferences to ATS
- * (to be called DIRECTLY from apps, not from transport/core!)
*/
#ifndef GNUNET_ATS_SERVICE_H
#define GNUNET_ATS_SERVICE_H
#include "gnunet_transport_plugin.h"
+/* ******************************** Scheduling API ***************************** */
+
/**
- * Handle to the ATS subsystem.
+ * Handle to the ATS subsystem for bandwidth/transport scheduling information.
*/
-struct GNUNET_ATS_Handle;
+struct GNUNET_ATS_SchedulingHandle;
/**
- * Signature of a function that takes an address suggestion
+ * Signature of a function called by ATS with the current bandwidth
+ * and address preferences as determined by ATS.
*
* @param cls closure
* @param peer identity of the new peer
* @param plugin_name name of the plugin, NULL if we have no suggestion
* @param plugin_addr suggested address, NULL if we have no suggestion
* @param plugin_addr_len number of bytes in plugin_addr
+ * @param session session to use
* @param bandwidth_out assigned outbound bandwidth for the connection
* @param bandwidth_in assigned inbound bandwidth for the connection
- * @param ats performance data for the address (as far as known)
- * @param ats_count number of performance records in 'ats'
*/
typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
const struct
bandwidth_out,
struct
GNUNET_BANDWIDTH_Value32NBO
- bandwidth_in,
- const struct
- GNUNET_TRANSPORT_ATS_Information
- * ats,
- uint32_t ats_count);
+ bandwidth_in);
/**
* @param alloc_cb_cls closure for 'alloc_cb'
* @return ats context
*/
-struct GNUNET_ATS_Handle *
-GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_ATS_AddressSuggestionCallback alloc_cb,
- void *alloc_cb_cls);
+struct GNUNET_ATS_SchedulingHandle *
+GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ATS_AddressSuggestionCallback alloc_cb,
+ void *alloc_cb_cls);
/**
- * Shutdown the ATS subsystem.
+ * Client is done with ATS scheduling, release resources.
*
- * @param atc handle
+ * @param atc handle to release
*/
void
-GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc);
-
-
-/**
- * Handle to cancel suggestion request.
- */
-struct GNUNET_ATS_SuggestionContext;
+GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *atc);
/**
- * We would like to establish a new connection with a peer.
- * ATS should suggest a good address to begin with.
+ * We would like to establish a new connection with a peer. ATS
+ * should suggest a good address to begin with.
*
* @param atc handle
- * @param peer identity of the new peer
- * @param cb function to call with the address
- * @param cb_cls closure for cb
- */
-struct GNUNET_ATS_SuggestionContext *
-GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc,
- const struct GNUNET_PeerIdentity *peer,
- GNUNET_ATS_AddressSuggestionCallback cb,
- void *cb_cls);
-
-
-/**
- * Cancel suggestion request.
- *
- * @param asc handle of the request to cancel
+ * @param peer identity of the peer we need an address for
*/
void
-GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SuggestionContext *asc);
+GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *atc,
+ const struct GNUNET_PeerIdentity *peer);
/**
- * We established a new connection with a peer (for example, because
- * core asked for it or because the other peer connected to us).
- * Calculate bandwidth assignments including the new peer.
+ * We have updated performance statistics for a given address. Note
+ * that this function can be called for addresses that are currently
+ * in use as well as addresses that are valid but not actively in use.
+ * Furthermore, the peer may not even be connected to us right now (in
+ * which case the call may be ignored or the information may be stored
+ * for later use). Update bandwidth assignments.
*
* @param atc handle
* @param peer identity of the new peer
- * @param plugin_name name of the currently used transport plugin
- * @param session session in use (if available)
- * @param plugin_addr address in use (if available)
+ * @param plugin_name name of the transport plugin
+ * @param plugin_addr address (if available)
* @param plugin_addr_len number of bytes in plugin_addr
- * @param ats performance data for the connection
+ * @param session session handle (if available)
+ * @param ats performance data for the address
* @param ats_count number of performance records in 'ats'
*/
void
-GNUNET_ATS_peer_connect (struct GNUNET_ATS_Handle *atc,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name, struct Session *session,
- const void *plugin_addr, size_t plugin_addr_len,
- const struct GNUNET_TRANSPORT_ATS_Information *ats,
- uint32_t ats_count);
-
-
-/**
- * We disconnected from the given peer (for example, because ats, core
- * or blacklist asked for it or because the other peer disconnected).
- * Calculate bandwidth assignments without the peer.
- *
- * @param atc handle
- * @param peer identity of the peer
- */
-void
-GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_Handle *atc,
- const struct GNUNET_PeerIdentity *peer);
+GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr, size_t plugin_addr_len,
+ struct Session *session,
+ const struct GNUNET_TRANSPORT_ATS_Information *ats,
+ uint32_t ats_count);
/**
*
* @param atc handle
* @param peer identity of the peer
+ * @param plugin_name name of the transport plugin
+ * @param plugin_addr address (if available)
+ * @param plugin_addr_len number of bytes in plugin_addr
* @param session session handle that is no longer valid
*/
void
-GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc,
+GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *atc,
const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
const struct Session *session);
+/* ******************************** Performance API ***************************** */
+
/**
- * We have updated performance statistics for a given address. Note
- * that this function can be called for addresses that are currently
- * in use as well as addresses that are valid but not actively in use.
- * Furthermore, the peer may not even be connected to us right now (in
- * which case the call may be ignored or the information may be stored
- * for later use). Update bandwidth assignments.
+ * ATS Handle to obtain and/or modify performance information.
+ */
+struct GNUNET_ATS_PerformanceHandle;
+
+
+/**
+ * Signature of a function that is called with QoS information about a peer.
*
- * @param atc handle
+ * @param cls closure
* @param peer identity of the new peer
- * @param valid_until how long is the address valid?
- * @param plugin_name name of the transport plugin
- * @param session session handle (if available)
- * @param plugin_addr address (if available)
+ * @param plugin_name name of the plugin, NULL if we have no suggestion
+ * @param plugin_addr suggested address, NULL if we have no suggestion
* @param plugin_addr_len number of bytes in plugin_addr
- * @param ats performance data for the address
+ * @param bandwidth_out assigned outbound bandwidth for the connection
+ * @param bandwidth_in assigned inbound bandwidth for the connection
+ * @param ats performance data for the address (as far as known)
* @param ats_count number of performance records in 'ats'
*/
-void
-GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc,
- const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_TIME_Absolute valid_until,
- const char *plugin_name, struct Session *session,
- const void *plugin_addr, size_t plugin_addr_len,
- const struct GNUNET_TRANSPORT_ATS_Information *ats,
- uint32_t ats_count);
+typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls,
+ const struct
+ GNUNET_PeerIdentity *
+ peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ struct
+ GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out,
+ struct
+ GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_in,
+ const struct
+ GNUNET_TRANSPORT_ATS_Information
+ * ats,
+ uint32_t ats_count);
+/**
+ * Get handle to access performance API of the ATS subsystem.
+ *
+ * @param cfg configuration to use
+ * @param infocb function to call on allocation changes, can be NULL
+ * @param infocb_cls closure for infocb
+ * @return ats performance context
+ */
+struct GNUNET_ATS_PerformanceHandle *
+GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ATS_PeerInformationCallback infocb,
+ void *infocb_cls);
+
+
+/**
+ * Client is done using the ATS performance subsystem, release resources.
+ *
+ * @param atc handle
+ */
+void
+GNUNET_ATS_performance_done (struct GNUNET_ATS_SchedulingHandle *atc);
+
/**
- * Function called with perference change information about the given peer.
+ * Function called with reservation result.
*
* @param cls closure
* @param peer identifies the peer
* @param res_delay if the reservation could not be satisfied (amount was 0), how
* long should the client wait until re-trying?
*/
-typedef void (*GNUNET_ATS_PeerConfigurationInfoCallback) (void *cls,
- const struct
- GNUNET_PeerIdentity *
- peer,
- int32_t amount,
- struct
- GNUNET_TIME_Relative
- res_delay);
+typedef void (*GNUNET_ATS_ReservationCallback) (void *cls,
+ const struct
+ GNUNET_PeerIdentity *
+ peer,
+ int32_t amount,
+ struct
+ GNUNET_TIME_Relative
+ res_delay);
/**
* Context that can be used to cancel a peer information request.
*/
-struct GNUNET_ATS_InformationRequestContext;
+struct GNUNET_ATS_ReservationContext;
/**
- * Obtain statistics and/or change preferences for the given peer.
- * You can only have one such pending request per peer.
+ * Reserve inbound bandwidth from the given peer. ATS will look at
+ * the current amount of traffic we receive from the peer and ensure
+ * that the peer could add 'amount' of data to its stream.
*
* @param h core handle
* @param peer identifies the peer
* @param amount reserve N bytes for receiving, negative
* amounts can be used to undo a (recent) reservation;
- * @param preference increase incoming traffic share preference by this amount;
- * in the absence of "amount" reservations, we use this
- * preference value to assign proportional bandwidth shares
- * to all connected peers; in the future, this should be
- * replaced with more specific QoS expressions...
- * @param info function to call with the resulting configuration information
+ * @param info function to call with the resulting reservation information
* @param info_cls closure for info
* @return NULL on error
* @deprecated will be replaced soon
*/
-struct GNUNET_ATS_InformationRequestContext *
-GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h,
- const struct GNUNET_PeerIdentity *peer,
- int32_t amount, uint64_t preference,
- GNUNET_ATS_PeerConfigurationInfoCallback
- info, void *info_cls);
+struct GNUNET_ATS_ReservationContext *
+GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *h,
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount,
+ GNUNET_ATS_ReservationCallback info,
+ void *info_cls);
/**
- * Cancel request for getting information about a peer.
- * Note that an eventual change in preference, trust or bandwidth
- * assignment MAY have already been committed at the time,
- * so cancelling a request is NOT sure to undo the original
- * request. The original request may or may not still commit.
- * The only thing cancellation ensures is that the callback
- * from the original request will no longer be called.
+ * Cancel request for reserving bandwidth.
*
- * @param irc context returned by the original GNUNET_ATS_peer_get_info call
- * @deprecated will be replaced soon
+ * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
+ */
+void
+GNUNET_ATS_reserve_bandwidth_cancel (struct
+ GNUNET_ATS_ReservationContext *rc);
+
+
+
+/**
+ * Enum defining all known preference categories.
+ */
+enum GNUNET_ATS_PreferenceKind
+{
+
+ /**
+ * End of preference list.
+ */
+ GNUNET_ATS_PREFERENCE_END = 0,
+
+ /**
+ * Change the peer's bandwidth value (value per byte of bandwidth in
+ * the goal function) to the given amount. The argument is followed
+ * by a double value giving the desired value (can be negative).
+ * Preference changes are forgotten if peers disconnect.
+ */
+ GNUNET_ATS_PREFERENCE_BANDWIDTH,
+
+ /**
+ * Change the peer's latency value to the given amount. The
+ * argument is followed by a double value giving the desired value
+ * (can be negative). The absolute score in the goal function is
+ * the inverse of the latency in ms (minimum: 1 ms) multiplied by
+ * the latency preferences.
+ */
+ GNUNET_ATS_PREFERENCE_LATENCY
+
+};
+
+
+/**
+ * Change preferences for the given peer. Preference changes are forgotten if peers
+ * disconnect.
+ *
+ * @param cls closure
+ * @param peer identifies the peer
+ * @param ... 0-terminated specification of the desired changes
*/
void
-GNUNET_ATS_peer_change_preference_cancel (struct
- GNUNET_ATS_InformationRequestContext
- *irc);
+GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *h,
+ const struct GNUNET_PeerIdentity *peer,
+ ...);
*/
#define GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY 334
+/*******************************************************************************
+ * ATS message types
+ ******************************************************************************/
+
+#define GNUNET_MESSAGE_TYPE_ATS_START 340
+
+#define GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS 341
+
+#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE 342
+
+#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED 343
+
+#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION 344
+
+#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST 345
+
+#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT 346
+
+#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE 347
+
+
/*******************************************************************************
* TODO: we need a way to register message types centrally (via some webpage).
* For now: unofficial extensions should start at 48k, internal extensions
/**
* ATS handle.
*/
-struct GNUNET_ATS_Handle *GST_ats;
+struct GNUNET_ATS_SchedulingHandle *GST_ats;
/**
/**
* ATS handle.
*/
-extern struct GNUNET_ATS_Handle *GST_ats;
+extern struct GNUNET_ATS_SchedulingHandle *GST_ats;
#endif