gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r17434 - in gnunet/src: ats dht fs include transport


From: gnunet
Subject: [GNUnet-SVN] r17434 - in gnunet/src: ats dht fs include transport
Date: Thu, 13 Oct 2011 13:59:13 +0200

Author: grothoff
Date: 2011-10-13 13:59:13 +0200 (Thu, 13 Oct 2011)
New Revision: 17434

Added:
   gnunet/src/ats/ats.h
   gnunet/src/ats/ats_api_new.c
   gnunet/src/ats/ats_api_performance.c
Modified:
   gnunet/src/ats/Makefile.am
   gnunet/src/ats/ats_api.c
   gnunet/src/ats/ats_api.h
   gnunet/src/ats/ats_api_peer_change_preference.c
   gnunet/src/ats/test_ats_api.c
   gnunet/src/ats/test_ats_api_update_address.c
   gnunet/src/dht/gnunet-service-dht_neighbours.c
   gnunet/src/fs/gnunet-service-fs_cp.c
   gnunet/src/include/gnunet_ats_service.h
   gnunet/src/include/gnunet_protocols.h
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport.h
Log:
new ATS API -- code won't compile

Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am  2011-10-13 08:28:15 UTC (rev 17433)
+++ gnunet/src/ats/Makefile.am  2011-10-13 11:59:13 UTC (rev 17434)
@@ -11,8 +11,8 @@
 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

Added: gnunet/src/ats/ats.h
===================================================================
--- gnunet/src/ats/ats.h                                (rev 0)
+++ gnunet/src/ats/ats.h        2011-10-13 11:59:13 UTC (rev 17434)
@@ -0,0 +1,210 @@
+/*
+     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

Modified: gnunet/src/ats/ats_api.c
===================================================================
--- gnunet/src/ats/ats_api.c    2011-10-13 08:28:15 UTC (rev 17433)
+++ gnunet/src/ats/ats_api.c    2011-10-13 11:59:13 UTC (rev 17434)
@@ -70,7 +70,7 @@
   /**
    * Global ATS handle.
    */
-  struct GNUNET_ATS_Handle *atc;
+  struct GNUNET_ATS_SchedulingHandle *atc;
 
   /**
    * Which peer are we monitoring?
@@ -108,7 +108,7 @@
   /**
    * ATS handle.
    */
-  struct GNUNET_ATS_Handle *atc;
+  struct GNUNET_ATS_SchedulingHandle *atc;
 
   /**
    * Inbound bandwidth to assign.
@@ -184,13 +184,13 @@
 /**
  * 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;
 
@@ -218,7 +218,7 @@
  * @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... */
@@ -277,7 +277,7 @@
  * @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)
@@ -332,17 +332,17 @@
  * @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;
@@ -382,7 +382,7 @@
  * @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");
@@ -410,7 +410,7 @@
   /**
    * Ats handle.
    */
-  struct GNUNET_ATS_Handle *atc;
+  struct GNUNET_ATS_SchedulingHandle *atc;
 
   /**
    * Allocation record with new information.
@@ -556,7 +556,7 @@
 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)
@@ -583,7 +583,7 @@
  * @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,
@@ -628,7 +628,7 @@
  * @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
@@ -650,7 +650,7 @@
   /**
    * Ats handle.
    */
-  struct GNUNET_ATS_Handle *atc;
+  struct GNUNET_ATS_SchedulingHandle *atc;
 
   /**
    * Session being destroyed.
@@ -699,7 +699,7 @@
  * @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)
 {
@@ -756,7 +756,7 @@
  * @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,

Modified: gnunet/src/ats/ats_api.h
===================================================================
--- gnunet/src/ats/ats_api.h    2011-10-13 08:28:15 UTC (rev 17433)
+++ gnunet/src/ats/ats_api.h    2011-10-13 11:59:13 UTC (rev 17434)
@@ -91,7 +91,7 @@
 /**
  * Handle to the ATS subsystem.
  */
-struct GNUNET_ATS_Handle
+struct GNUNET_ATS_SchedulingHandle
 {
   /**
    * Configuration.

Added: gnunet/src/ats/ats_api_new.c
===================================================================
--- gnunet/src/ats/ats_api_new.c                                (rev 0)
+++ gnunet/src/ats/ats_api_new.c        2011-10-13 11:59:13 UTC (rev 17434)
@@ -0,0 +1,129 @@
+/*
+     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 */

Modified: gnunet/src/ats/ats_api_peer_change_preference.c
===================================================================
--- gnunet/src/ats/ats_api_peer_change_preference.c     2011-10-13 08:28:15 UTC 
(rev 17433)
+++ gnunet/src/ats/ats_api_peer_change_preference.c     2011-10-13 11:59:13 UTC 
(rev 17434)
@@ -40,7 +40,7 @@
   /**
    * Our connection to the service.
    */
-  struct GNUNET_ATS_Handle *h;
+  struct GNUNET_ATS_SchedulingHandle *h;
 
   int32_t amount;
 
@@ -124,7 +124,7 @@
  * @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
@@ -173,7 +173,7 @@
   /**
    * Our connection to the service.
    */
-  struct GNUNET_ATS_Handle *h;
+  struct GNUNET_ATS_SchedulingHandle *h;
 
   /**
    * Link to control message, NULL if CM was sent.
@@ -218,7 +218,7 @@
  * @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
@@ -290,7 +290,7 @@
                                            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);

Added: gnunet/src/ats/ats_api_performance.c
===================================================================
--- gnunet/src/ats/ats_api_performance.c                                (rev 0)
+++ gnunet/src/ats/ats_api_performance.c        2011-10-13 11:59:13 UTC (rev 
17434)
@@ -0,0 +1,128 @@
+/*
+     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 */
+

Modified: gnunet/src/ats/test_ats_api.c
===================================================================
--- gnunet/src/ats/test_ats_api.c       2011-10-13 08:28:15 UTC (rev 17433)
+++ gnunet/src/ats/test_ats_api.c       2011-10-13 11:59:13 UTC (rev 17434)
@@ -42,7 +42,7 @@
 
 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,

Modified: gnunet/src/ats/test_ats_api_update_address.c
===================================================================
--- gnunet/src/ats/test_ats_api_update_address.c        2011-10-13 08:28:15 UTC 
(rev 17433)
+++ gnunet/src/ats/test_ats_api_update_address.c        2011-10-13 11:59:13 UTC 
(rev 17434)
@@ -44,7 +44,7 @@
 
 #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;
 

Modified: gnunet/src/dht/gnunet-service-dht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_neighbours.c      2011-10-13 08:28:15 UTC 
(rev 17433)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c      2011-10-13 11:59:13 UTC 
(rev 17434)
@@ -415,7 +415,7 @@
 /**
  * Handle to ATS.
  */
-static struct GNUNET_ATS_Handle *atsAPI;
+static struct GNUNET_ATS_SchedulingHandle *atsAPI;
 
 
 

Modified: gnunet/src/fs/gnunet-service-fs_cp.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_cp.c        2011-10-13 08:28:15 UTC (rev 
17433)
+++ gnunet/src/fs/gnunet-service-fs_cp.c        2011-10-13 11:59:13 UTC (rev 
17434)
@@ -305,7 +305,7 @@
 /**
  * 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

Modified: gnunet/src/include/gnunet_ats_service.h
===================================================================
--- gnunet/src/include/gnunet_ats_service.h     2011-10-13 08:28:15 UTC (rev 
17433)
+++ gnunet/src/include/gnunet_ats_service.h     2011-10-13 11:59:13 UTC (rev 
17434)
@@ -25,8 +25,6 @@
  *
  * 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
@@ -37,24 +35,26 @@
 #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
@@ -69,11 +69,7 @@
                                                       bandwidth_out,
                                                       struct
                                                       
GNUNET_BANDWIDTH_Value32NBO
-                                                      bandwidth_in,
-                                                      const struct
-                                                      
GNUNET_TRANSPORT_ATS_Information
-                                                      * ats,
-                                                      uint32_t ats_count);
+                                                      bandwidth_in);
 
 
 /**
@@ -84,133 +80,145 @@
  * @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);
+GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *atc);
 
 
 /**
- * Handle to cancel suggestion request.
- */
-struct GNUNET_ATS_SuggestionContext;
-
-
-/**
- * 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
+ * @param peer identity of the peer we need an address for
  */
-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
- */
 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);
+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);
 
 
 /**
- * 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);
-
-
-/**
  * 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_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);
 
+
 /**
- * Function called with perference change information about the given peer.
+ * 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 reservation result.
+ *
  * @param cls closure
  * @param peer identifies the peer
  * @param amount set to the amount that was actually reserved or unreserved;
@@ -218,67 +226,101 @@
  * @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_peer_change_preference_cancel (struct
-                                         GNUNET_ATS_InformationRequestContext
-                                         *irc);
+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_change_preference (struct GNUNET_ATS_PerformanceHandle *h,
+                             const struct GNUNET_PeerIdentity *peer,
+                             ...);
+
+
+
 #endif
 /* end of file gnunet-service-transport_ats.h */

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2011-10-13 08:28:15 UTC (rev 
17433)
+++ gnunet/src/include/gnunet_protocols.h       2011-10-13 11:59:13 UTC (rev 
17434)
@@ -987,6 +987,27 @@
 #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
  * define here should leave some room (4-10 additional messages to the previous

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2011-10-13 08:28:15 UTC 
(rev 17433)
+++ gnunet/src/transport/gnunet-service-transport.c     2011-10-13 11:59:13 UTC 
(rev 17434)
@@ -73,7 +73,7 @@
 /**
  * ATS handle.
  */
-struct GNUNET_ATS_Handle *GST_ats;
+struct GNUNET_ATS_SchedulingHandle *GST_ats;
 
 
 /**

Modified: gnunet/src/transport/gnunet-service-transport.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport.h     2011-10-13 08:28:15 UTC 
(rev 17433)
+++ gnunet/src/transport/gnunet-service-transport.h     2011-10-13 11:59:13 UTC 
(rev 17434)
@@ -65,7 +65,7 @@
 /**
  * ATS handle.
  */
-extern struct GNUNET_ATS_Handle *GST_ats;
+extern struct GNUNET_ATS_SchedulingHandle *GST_ats;
 
 
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]