gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35079 - in gnunet/src: ats include transport


From: gnunet
Subject: [GNUnet-SVN] r35079 - in gnunet/src: ats include transport
Date: Tue, 3 Feb 2015 15:11:03 +0100

Author: grothoff
Date: 2015-02-03 15:11:03 +0100 (Tue, 03 Feb 2015)
New Revision: 35079

Added:
   gnunet/src/ats/ats_api_connectivity.c
   gnunet/src/ats/gnunet-service-ats_connectivity.c
   gnunet/src/ats/gnunet-service-ats_connectivity.h
Modified:
   gnunet/src/ats/Makefile.am
   gnunet/src/ats/ats.h
   gnunet/src/ats/ats_api_scheduling.c
   gnunet/src/ats/gnunet-service-ats.c
   gnunet/src/ats/gnunet-service-ats_scheduling.c
   gnunet/src/ats/gnunet-service-ats_scheduling.h
   gnunet/src/ats/test_ats_api_bandwidth_consumption.c
   gnunet/src/ats/test_ats_simplistic_pref_aging.c
   gnunet/src/ats/test_ats_solver_add_address_and_request.c
   gnunet/src/ats/test_ats_solver_alternative_after_delete_address.c
   gnunet/src/ats/test_ats_solver_convergence.c
   gnunet/src/ats/test_ats_solver_preferences.c
   gnunet/src/ats/test_ats_solver_request_and_add_address.c
   gnunet/src/ats/test_ats_solver_request_and_delete_address.c
   gnunet/src/include/gnunet_ats_service.h
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport.h
   gnunet/src/transport/gnunet-service-transport_neighbours.c
Log:
separate ATS connectivity suggestions from ATS scheduling API

Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am  2015-02-03 13:23:01 UTC (rev 35078)
+++ gnunet/src/ats/Makefile.am  2015-02-03 14:11:03 UTC (rev 35079)
@@ -51,6 +51,7 @@
  $(LTLIBINTL)
 
 libgnunetats_la_SOURCES = \
+  ats_api_connectivity.c \
   ats_api_scheduling.c \
   ats_api_performance.c
 libgnunetats_la_LIBADD = \
@@ -99,6 +100,7 @@
 gnunet_service_ats_SOURCES = \
  gnunet-service-ats.c gnunet-service-ats.h\
  gnunet-service-ats_addresses.c gnunet-service-ats_addresses.h \
+ gnunet-service-ats_connectivity.c gnunet-service-ats_connectivity.h \
  gnunet-service-ats_normalization.c gnunet-service-ats_normalization.h \
  gnunet-service-ats_performance.c gnunet-service-ats_performance.h \
  gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \

Modified: gnunet/src/ats/ats.h
===================================================================
--- gnunet/src/ats/ats.h        2015-02-03 13:23:01 UTC (rev 35078)
+++ gnunet/src/ats/ats.h        2015-02-03 14:11:03 UTC (rev 35079)
@@ -50,7 +50,12 @@
    * Performance monitoring client that does NOT want to learn
    * about changes in performance characteristics.
    */
-  START_FLAG_PERFORMANCE_NO_PIC = 2
+  START_FLAG_PERFORMANCE_NO_PIC = 2,
+
+  /**
+   * Connection suggestion handle.
+   */
+  START_FLAG_CONNECTION_SUGGESTION = 3
 };
 
 

Added: gnunet/src/ats/ats_api_connectivity.c
===================================================================
--- gnunet/src/ats/ats_api_connectivity.c                               (rev 0)
+++ gnunet/src/ats/ats_api_connectivity.c       2015-02-03 14:11:03 UTC (rev 
35079)
@@ -0,0 +1,356 @@
+/*
+     This file is part of GNUnet.
+     (C) 2010-2015 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_api_connectivity.c
+ * @brief enable clients to ask ATS about establishing connections to peers
+ * @author Christian Grothoff
+ * @author Matthias Wachs
+ */
+#include "platform.h"
+#include "gnunet_ats_service.h"
+#include "ats.h"
+
+
+/**
+ * Handle for ATS address suggestion requests.
+ */
+struct GNUNET_ATS_ConnectivitySuggestHandle
+{
+  /**
+   * ID of the peer for which address suggestion was requested.
+   */
+  struct GNUNET_PeerIdentity id;
+
+  /**
+   * Connecitivity handle this suggestion handle belongs to.
+   */
+  struct GNUNET_ATS_ConnectivityHandle *ch;
+};
+
+
+/**
+ * Handle to the ATS subsystem for connectivity management.
+ */
+struct GNUNET_ATS_ConnectivityHandle
+{
+
+  /**
+   * Our configuration.
+   */
+  const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+  /**
+   * Map with the identities of all the peers for which we would
+   * like to have address suggestions.  The key is the PID, the
+   * value is currently the `struct GNUNET_ATS_ConnectivitySuggestHandle`
+   */
+  struct GNUNET_CONTAINER_MultiPeerMap *sug_requests;
+
+  /**
+   * Connection to ATS service.
+   */
+  struct GNUNET_CLIENT_Connection *client;
+
+  /**
+   * Message queue for sending requests to the ATS service.
+   */
+  struct GNUNET_MQ_Handle *mq;
+
+  /**
+   * Task to trigger reconnect.
+   */
+  struct GNUNET_SCHEDULER_Task *task;
+
+};
+
+
+/**
+ * Re-establish the connection to the ATS service.
+ *
+ * @param ch handle to use to re-connect.
+ */
+static void
+reconnect (struct GNUNET_ATS_ConnectivityHandle *ch);
+
+
+/**
+ * Re-establish the connection to the ATS service.
+ *
+ * @param cls handle to use to re-connect.
+ * @param tc scheduler context
+ */
+static void
+reconnect_task (void *cls,
+                const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_ATS_ConnectivityHandle *ch = cls;
+
+  ch->task = NULL;
+  reconnect (ch);
+}
+
+
+/**
+ * Disconnect from ATS and then reconnect.
+ *
+ * @param ch our handle
+ */
+static void
+force_reconnect (struct GNUNET_ATS_ConnectivityHandle *ch)
+{
+  if (NULL != ch->mq)
+  {
+    GNUNET_MQ_destroy (ch->mq);
+    ch->mq = NULL;
+  }
+  if (NULL != ch->client)
+  {
+    GNUNET_CLIENT_disconnect (ch->client);
+    ch->client = NULL;
+  }
+  ch->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                           &reconnect_task,
+                                           ch);
+}
+
+
+/**
+ * We encountered an error handling the MQ to the
+ * ATS service.  Reconnect.
+ *
+ * @param cls the `struct GNUNET_ATS_ConnectivityHandle`
+ * @param error details about the error
+ */
+static void
+error_handler (void *cls,
+               enum GNUNET_MQ_Error error)
+{
+  struct GNUNET_ATS_ConnectivityHandle *ch = cls;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "ATS connection died (code %d), reconnecting\n",
+              (int) error);
+  force_reconnect (ch);
+}
+
+
+/**
+ * Transmit request for an address suggestion.
+ *
+ * @param cls the `struct GNUNET_ATS_ConnectivityHandle`
+ * @param peer peer to ask for an address suggestion for
+ * @param value the `struct GNUNET_ATS_SuggestHandle`
+ * @return #GNUNET_OK (continue to iterate), #GNUNET_SYSERR on
+ *         failure (message queue no longer exists)
+ */
+static int
+transmit_suggestion (void *cls,
+                     const struct GNUNET_PeerIdentity *peer,
+                     void *value)
+{
+  struct GNUNET_ATS_ConnectivityHandle *ch = cls;
+  struct GNUNET_MQ_Envelope *ev;
+  struct RequestAddressMessage *m;
+
+  if (NULL == ch->mq)
+    return GNUNET_SYSERR;
+  ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS);
+  m->reserved = htonl (0);
+  m->peer = *peer;
+  GNUNET_MQ_send (ch->mq, ev);
+  return GNUNET_OK;
+}
+
+
+/**
+ * Re-establish the connection to the ATS service.
+ *
+ * @param ch handle to use to re-connect.
+ */
+static void
+reconnect (struct GNUNET_ATS_ConnectivityHandle *ch)
+{
+  static const struct GNUNET_MQ_MessageHandler handlers[] =
+    { { NULL, 0, 0 } };
+  struct GNUNET_MQ_Envelope *ev;
+  struct ClientStartMessage *init;
+
+  GNUNET_assert (NULL == ch->client);
+  ch->client = GNUNET_CLIENT_connect ("ats", ch->cfg);
+  if (NULL == ch->client)
+  {
+    force_reconnect (ch);
+    return;
+  }
+  ch->mq = GNUNET_MQ_queue_for_connection_client (ch->client,
+                                                  handlers,
+                                                  &error_handler,
+                                                  ch);
+  ev = GNUNET_MQ_msg (init,
+                      GNUNET_MESSAGE_TYPE_ATS_START);
+  init->start_flag = htonl (START_FLAG_CONNECTION_SUGGESTION);
+  GNUNET_MQ_send (ch->mq, ev);
+  if (NULL == ch->mq)
+    return;
+  GNUNET_CONTAINER_multipeermap_iterate (ch->sug_requests,
+                                         &transmit_suggestion,
+                                         ch);
+}
+
+
+/**
+ * Initialize the ATS connectivity suggestion client handle.
+ *
+ * @param cfg configuration to use
+ * @return ats connectivity handle, NULL on error
+ */
+struct GNUNET_ATS_ConnectivityHandle *
+GNUNET_ATS_connectivity_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNUNET_ATS_ConnectivityHandle *ch;
+
+  ch = GNUNET_new (struct GNUNET_ATS_ConnectivityHandle);
+  ch->cfg = cfg;
+  ch->sug_requests = GNUNET_CONTAINER_multipeermap_create (32,
+                                                           GNUNET_YES);
+  reconnect (ch);
+  return ch;
+}
+
+
+/**
+ * Function called to free all `struct GNUNET_ATS_SuggestHandles`
+ * in the map.
+ *
+ * @param cls NULL
+ * @param key the key
+ * @param value the value to free
+ * @return #GNUNET_OK (continue to iterate)
+ */
+static int
+free_sug_handle (void *cls,
+                 const struct GNUNET_PeerIdentity *key,
+                 void *value)
+{
+  struct GNUNET_ATS_ConnectivitySuggestHandle *cur = value;
+
+  GNUNET_free (cur);
+  return GNUNET_OK;
+}
+
+
+/**
+ * Client is done with ATS connectivity management, release resources.
+ *
+ * @param ch handle to release
+ */
+void
+GNUNET_ATS_connectivity_done (struct GNUNET_ATS_ConnectivityHandle *ch)
+{
+  if (NULL != ch->mq)
+  {
+    GNUNET_MQ_destroy (ch->mq);
+    ch->mq = NULL;
+  }
+  if (NULL != ch->client)
+  {
+    GNUNET_CLIENT_disconnect (ch->client);
+    ch->client = NULL;
+  }
+  if (NULL != ch->task)
+  {
+    GNUNET_SCHEDULER_cancel (ch->task);
+    ch->task = NULL;
+  }
+  GNUNET_CONTAINER_multipeermap_iterate (ch->sug_requests,
+                                         &free_sug_handle,
+                                         NULL);
+  GNUNET_CONTAINER_multipeermap_destroy (ch->sug_requests);
+  GNUNET_free (ch);
+}
+
+
+/**
+ * We would like to receive address suggestions for a peer. ATS will
+ * respond with a call to the continuation immediately containing an address or
+ * no address if none is available. ATS can suggest more addresses until we 
call
+ * #GNUNET_ATS_connectivity_suggest_cancel().
+ *
+ * @param ch handle
+ * @param peer identity of the peer we need an address for
+ * @return suggest handle, NULL if a request is already pending
+ */
+struct GNUNET_ATS_ConnectivitySuggestHandle *
+GNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch,
+                                 const struct GNUNET_PeerIdentity *peer)
+{
+  struct GNUNET_ATS_ConnectivitySuggestHandle *s;
+
+  s = GNUNET_new (struct GNUNET_ATS_ConnectivitySuggestHandle);
+  s->ch = ch;
+  s->id = *peer;
+  if (GNUNET_OK !=
+      GNUNET_CONTAINER_multipeermap_put (ch->sug_requests,
+                                         &s->id,
+                                         s,
+                                         
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
+  if (NULL == ch->mq)
+    return s;
+  (void) transmit_suggestion (ch,
+                              &s->id,
+                              s);
+  return s;
+}
+
+
+/**
+ * We no longer care about being connected to a peer.
+ *
+ * @param sh handle to stop
+ */
+void
+GNUNET_ATS_connectivity_suggest_cancel (struct 
GNUNET_ATS_ConnectivitySuggestHandle *sh)
+{
+  struct GNUNET_ATS_ConnectivityHandle *ch = sh->ch;
+  struct GNUNET_MQ_Envelope *ev;
+  struct RequestAddressMessage *m;
+
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests,
+                                                       &sh->id,
+                                                       sh));
+  if (NULL == ch->mq)
+  {
+    GNUNET_free (sh);
+    return;
+  }
+  ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL);
+  m->reserved = htonl (0);
+  m->peer = sh->id;
+  GNUNET_MQ_send (ch->mq, ev);
+  GNUNET_free (sh);
+}
+
+
+/* end of ats_api_connectivity.c */

Modified: gnunet/src/ats/ats_api_scheduling.c
===================================================================
--- gnunet/src/ats/ats_api_scheduling.c 2015-02-03 13:23:01 UTC (rev 35078)
+++ gnunet/src/ats/ats_api_scheduling.c 2015-02-03 14:11:03 UTC (rev 35079)
@@ -146,18 +146,6 @@
 
 
 /**
- * Handle for ATS address suggestion requests.
- */
-struct GNUNET_ATS_SuggestHandle
-{
-  /**
-   * ID of the peer for which address suggestion was requested.
-   */
-  struct GNUNET_PeerIdentity id;
-};
-
-
-/**
  * Handle to the ATS subsystem for bandwidth/transport scheduling information.
  */
 struct GNUNET_ATS_SchedulingHandle
@@ -179,13 +167,6 @@
   void *suggest_cb_cls;
 
   /**
-   * Map with the identities of all the peers for which we would
-   * like to have address suggestions.  The key is the PID, the
-   * value is currently the `struct GNUNET_ATS_SuggestHandle`
-   */
-  struct GNUNET_CONTAINER_MultiPeerMap *sug_requests;
-
-  /**
    * Connection to ATS service.
    */
   struct GNUNET_CLIENT_Connection *client;
@@ -588,34 +569,6 @@
 
 
 /**
- * Transmit request for an address suggestion.
- *
- * @param cls the `struct GNUNET_ATS_SchedulingHandle`
- * @param peer peer to ask for an address suggestion for
- * @param value the `struct GNUNET_ATS_SuggestHandle`
- * @return #GNUNET_OK (continue to iterate), #GNUNET_SYSERR on
- *         failure (message queue no longer exists)
- */
-static int
-transmit_suggestion (void *cls,
-                     const struct GNUNET_PeerIdentity *peer,
-                     void *value)
-{
-  struct GNUNET_ATS_SchedulingHandle *sh = cls;
-  struct GNUNET_MQ_Envelope *ev;
-  struct RequestAddressMessage *m;
-
-  if (NULL == sh->mq)
-    return GNUNET_SYSERR;
-  ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS);
-  m->reserved = htonl (0);
-  m->peer = *peer;
-  GNUNET_MQ_send (sh->mq, ev);
-  return GNUNET_OK;
-}
-
-
-/**
  * Generate and transmit the `struct AddressUseMessage` for the given
  * address record.
  *
@@ -687,9 +640,6 @@
     if (NULL == sh->mq)
       return;
   }
-  GNUNET_CONTAINER_multipeermap_iterate (sh->sug_requests,
-                                         &transmit_suggestion,
-                                         sh);
 }
 
 
@@ -1034,8 +984,6 @@
   GNUNET_array_grow (sh->session_array,
                      sh->session_array_size,
                      4);
-  sh->sug_requests = GNUNET_CONTAINER_multipeermap_create (32,
-                                                           GNUNET_YES);
   GNUNET_OS_network_interfaces_list (&interface_proc,
                                      sh);
   sh->interface_task = GNUNET_SCHEDULER_add_delayed 
(INTERFACE_PROCESSING_INTERVAL,
@@ -1047,27 +995,6 @@
 
 
 /**
- * Function called to free all `struct GNUNET_ATS_SuggestHandles`
- * in the map.
- *
- * @param cls NULL
- * @param key the key
- * @param value the value to free
- * @return #GNUNET_OK (continue to iterate)
- */
-static int
-free_sug_handle (void *cls,
-                 const struct GNUNET_PeerIdentity *key,
-                 void *value)
-{
-  struct GNUNET_ATS_SuggestHandle *cur = value;
-
-  GNUNET_free (cur);
-  return GNUNET_OK;
-}
-
-
-/**
  * Client is done with ATS scheduling, release resources.
  *
  * @param sh handle to release
@@ -1090,10 +1017,6 @@
     GNUNET_SCHEDULER_cancel (sh->task);
     sh->task = NULL;
   }
-  GNUNET_CONTAINER_multipeermap_iterate (sh->sug_requests,
-                                         &free_sug_handle,
-                                         NULL);
-  GNUNET_CONTAINER_multipeermap_destroy (sh->sug_requests);
   if (NULL != sh->interface_task)
   {
     GNUNET_SCHEDULER_cancel (sh->interface_task);
@@ -1129,77 +1052,6 @@
 
 
 /**
- * We would like to receive address suggestions for a peer. ATS will
- * respond with a call to the continuation immediately containing an address or
- * no address if none is available. ATS can suggest more addresses until we 
call
- * #GNUNET_ATS_suggest_address_cancel().
- *
- * @param sh handle
- * @param peer identity of the peer we need an address for
- * @return suggest handle, NULL if a request is already pending
- */
-struct GNUNET_ATS_SuggestHandle *
-GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
-                            const struct GNUNET_PeerIdentity *peer)
-{
-  struct GNUNET_ATS_SuggestHandle *s;
-
-  s = GNUNET_new (struct GNUNET_ATS_SuggestHandle);
-  s->id = *peer;
-  if (GNUNET_OK !=
-      GNUNET_CONTAINER_multipeermap_put (sh->sug_requests,
-                                         &s->id,
-                                         s,
-                                         
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
-  {
-    GNUNET_break (0);
-    return NULL;
-  }
-  if (NULL == sh->mq)
-    return s;
-  (void) transmit_suggestion (sh,
-                              &s->id,
-                              s);
-  return s;
-}
-
-
-/**
- * We would like to stop receiving address updates for this peer
- *
- * @param sh handle
- * @param peer identity of the peer
- */
-void
-GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh,
-                                   const struct GNUNET_PeerIdentity *peer)
-{
-  struct GNUNET_MQ_Envelope *ev;
-  struct RequestAddressMessage *m;
-  struct GNUNET_ATS_SuggestHandle *s;
-
-  s = GNUNET_CONTAINER_multipeermap_get (sh->sug_requests,
-                                         peer);
-  if (NULL == s)
-  {
-    GNUNET_break (0);
-    return;
-  }
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONTAINER_multipeermap_remove (sh->sug_requests,
-                                                       &s->id,
-                                                       s));
-  GNUNET_free (s);
-  if (NULL == sh->mq)
-    return;
-  ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL);
-  m->reserved = htonl (0);
-  m->peer = *peer;
-  GNUNET_MQ_send (sh->mq, ev);
-}
-
-
-/**
  * Test if a address and a session is known to ATS
  *
  * @param sh the scheduling handle

Modified: gnunet/src/ats/gnunet-service-ats.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats.c 2015-02-03 13:23:01 UTC (rev 35078)
+++ gnunet/src/ats/gnunet-service-ats.c 2015-02-03 14:11:03 UTC (rev 35079)
@@ -28,6 +28,7 @@
 #include "gnunet_util_lib.h"
 #include "gnunet-service-ats.h"
 #include "gnunet-service-ats_addresses.h"
+#include "gnunet-service-ats_connectivity.h"
 #include "gnunet-service-ats_performance.h"
 #include "gnunet-service-ats_scheduling.h"
 #include "gnunet-service-ats_reservations.h"
@@ -80,6 +81,9 @@
   case START_FLAG_PERFORMANCE_NO_PIC:
     GAS_performance_add_client (client, flag);
     break;
+  case START_FLAG_CONNECTION_SUGGESTION:
+    /* This client won't receive messages from us, no need to 'add' */
+    break;
   default:
     GNUNET_break (0);
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);

Added: gnunet/src/ats/gnunet-service-ats_connectivity.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_connectivity.c                            
(rev 0)
+++ gnunet/src/ats/gnunet-service-ats_connectivity.c    2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -0,0 +1,86 @@
+/*
+     This file is part of GNUnet.
+     (C) 2011-2015 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/gnunet-service-ats_connectivity.c
+ * @brief ats service, interaction with 'connecivity' API
+ * @author Matthias Wachs
+ * @author Christian Grothoff
+ *
+ * FIXME:
+ * - we should track requests by client, and if a client
+ *   disconnects cancel all associated requests; right
+ *   now, they will persist forever unless the client
+ *   explicitly sends us a cancel before disconnecting!
+ */
+#include "platform.h"
+#include "gnunet-service-ats.h"
+#include "gnunet-service-ats_addresses.h"
+#include "gnunet-service-ats_connectivity.h"
+#include "ats.h"
+
+/**
+ * Handle 'request address' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_request_address (void *cls,
+                            struct GNUNET_SERVER_Client *client,
+                            const struct GNUNET_MessageHeader *message)
+{
+  const struct RequestAddressMessage *msg =
+      (const struct RequestAddressMessage *) message;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received `%s' message\n",
+              "REQUEST_ADDRESS");
+  GNUNET_break (0 == ntohl (msg->reserved));
+  GAS_addresses_request_address (&msg->peer);
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
+/**
+ * Handle 'request address' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_request_address_cancel (void *cls,
+                                   struct GNUNET_SERVER_Client *client,
+                                   const struct GNUNET_MessageHeader *message)
+{
+  const struct RequestAddressMessage *msg =
+      (const struct RequestAddressMessage *) message;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received `%s' message\n",
+              "REQUEST_ADDRESS_CANCEL");
+  GNUNET_break (0 == ntohl (msg->reserved));
+  GAS_addresses_request_address_cancel (&msg->peer);
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+/* end of gnunet-service-ats_connectivity.c */

Added: gnunet/src/ats/gnunet-service-ats_connectivity.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_connectivity.h                            
(rev 0)
+++ gnunet/src/ats/gnunet-service-ats_connectivity.h    2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -0,0 +1,58 @@
+/*
+     This file is part of GNUnet.
+     (C) 2011-2015 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/gnunet-service-ats_connectivity.h
+ * @brief ats service, interaction with 'connecivity' API
+ * @author Matthias Wachs
+ * @author Christian Grothoff
+ */
+#ifndef GNUNET_SERVICE_ATS_CONNECTIVITY_H
+#define GNUNET_SERVICE_ATS_CONNECTIVITY_H
+
+
+/**
+ * Handle 'request address' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_request_address (void *cls,
+                            struct GNUNET_SERVER_Client *client,
+                            const struct GNUNET_MessageHeader *message);
+
+
+/**
+ * Cancel 'request address' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_request_address_cancel (void *cls,
+                                   struct GNUNET_SERVER_Client *client,
+                                   const struct GNUNET_MessageHeader *message);
+
+
+#endif
+/* end of gnunet-service-ats_connectivity.h */

Modified: gnunet/src/ats/gnunet-service-ats_scheduling.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_scheduling.c      2015-02-03 13:23:01 UTC 
(rev 35078)
+++ gnunet/src/ats/gnunet-service-ats_scheduling.c      2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -120,53 +120,6 @@
 
 
 /**
- * Handle 'request address' messages from clients.
- *
- * @param cls unused, NULL
- * @param client client that sent the request
- * @param message the request message
- */
-void
-GAS_handle_request_address (void *cls,
-                            struct GNUNET_SERVER_Client *client,
-                            const struct GNUNET_MessageHeader *message)
-{
-  const struct RequestAddressMessage *msg =
-      (const struct RequestAddressMessage *) message;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
-              "REQUEST_ADDRESS");
-  GNUNET_break (0 == ntohl (msg->reserved));
-  GAS_addresses_request_address (&msg->peer);
-  GNUNET_SERVER_receive_done (client, GNUNET_OK);
-}
-
-
-/**
- * Handle 'request address' messages from clients.
- *
- * @param cls unused, NULL
- * @param client client that sent the request
- * @param message the request message
- */
-void
-GAS_handle_request_address_cancel (void *cls,
-                                   struct GNUNET_SERVER_Client *client,
-                                   const struct GNUNET_MessageHeader *message)
-{
-  const struct RequestAddressMessage *msg =
-      (const struct RequestAddressMessage *) message;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received `%s' message\n",
-              "REQUEST_ADDRESS_CANCEL");
-  GNUNET_break (0 == ntohl (msg->reserved));
-  GAS_addresses_request_address_cancel (&msg->peer);
-  GNUNET_SERVER_receive_done (client, GNUNET_OK);
-}
-
-
-/**
  * Handle 'reset backoff' messages from clients.
  *
  * @param cls unused, NULL

Modified: gnunet/src/ats/gnunet-service-ats_scheduling.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_scheduling.h      2015-02-03 13:23:01 UTC 
(rev 35078)
+++ gnunet/src/ats/gnunet-service-ats_scheduling.h      2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -80,32 +80,6 @@
 
 
 /**
- * Handle 'request address' messages from clients.
- *
- * @param cls unused, NULL
- * @param client client that sent the request
- * @param message the request message
- */
-void
-GAS_handle_request_address (void *cls,
-                            struct GNUNET_SERVER_Client *client,
-                            const struct GNUNET_MessageHeader *message);
-
-
-/**
- * Cancel 'request address' messages from clients.
- *
- * @param cls unused, NULL
- * @param client client that sent the request
- * @param message the request message
- */
-void
-GAS_handle_request_address_cancel (void *cls,
-                                   struct GNUNET_SERVER_Client *client,
-                                   const struct GNUNET_MessageHeader *message);
-
-
-/**
  * Handle 'address add' messages from clients.
  *
  * @param cls unused, NULL

Modified: gnunet/src/ats/test_ats_api_bandwidth_consumption.c
===================================================================
--- gnunet/src/ats/test_ats_api_bandwidth_consumption.c 2015-02-03 13:23:01 UTC 
(rev 35078)
+++ gnunet/src/ats/test_ats_api_bandwidth_consumption.c 2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -39,8 +39,13 @@
 
 static struct GNUNET_ATS_PerformanceHandle *atp;
 
-struct GNUNET_ATS_ReservationContext *sh;
+/**
+ * Connectivity handle
+ */
+static struct GNUNET_ATS_ConnectivityHandle *connect_ats;
 
+static struct GNUNET_ATS_ReservationContext *sh;
+
 static struct PeerContext *p;
 
 static uint32_t bw_in;
@@ -75,44 +80,51 @@
 
 
 static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+end ()
 {
-  die_task = NULL;
+  if (NULL != connect_ats)
+  {
+    GNUNET_ATS_connectivity_done (connect_ats);
+    connect_ats = NULL;
+  }
+  if (die_task != NULL)
+  {
+    GNUNET_SCHEDULER_cancel (die_task);
+    die_task = NULL;
+  }
   if (consume_task != NULL)
   {
     GNUNET_SCHEDULER_cancel (consume_task);
     consume_task = NULL;
   }
   if (sh != NULL)
+  {
     GNUNET_ATS_reserve_bandwidth_cancel (sh);
+    sh = NULL;
+  }
   if (ats != NULL)
+  {
     GNUNET_ATS_scheduling_done (ats);
+    ats = NULL;
+  }
   if (atp != NULL)
+  {
     GNUNET_ATS_performance_done (atp);
+    atp = NULL;
+  }
   GNUNET_free (p->addr);
   GNUNET_free (p);
-  ret = GNUNET_SYSERR;
+  p = NULL;
+  ret = 0;
 }
 
 
 static void
-end ()
+end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  if (die_task != NULL)
-  {
-    GNUNET_SCHEDULER_cancel (die_task);
-    die_task = NULL;
-  }
-  if (consume_task != NULL)
-  {
-    GNUNET_SCHEDULER_cancel (consume_task);
-    consume_task = NULL;
-  }
-  GNUNET_ATS_scheduling_done (ats);
-  GNUNET_ATS_performance_done (atp);
-  GNUNET_free (p->addr);
-  GNUNET_free (p);
-  ret = 0;
+  die_task = NULL;
+  end ();
+  ret = GNUNET_SYSERR;
 }
 
 
@@ -182,6 +194,8 @@
 
   ret = GNUNET_SYSERR;
   die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
+  connect_ats = GNUNET_ATS_connectivity_init (mycfg);
+
   ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
   if (ats == NULL)
   {
@@ -218,7 +232,7 @@
   GNUNET_ATS_address_update (ats, &p->id, addr->plugin, addr->addr,
                              addr->addr_len, addr->session, NULL, 0);
 
-  GNUNET_ATS_suggest_address (ats, &p->id);
+  GNUNET_ATS_connectivity_suggest (connect_ats, &p->id);
 }
 
 

Modified: gnunet/src/ats/test_ats_simplistic_pref_aging.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_pref_aging.c     2015-02-03 13:23:01 UTC 
(rev 35078)
+++ gnunet/src/ats/test_ats_simplistic_pref_aging.c     2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -48,6 +48,11 @@
 static struct GNUNET_ATS_SchedulingHandle *sched_ats;
 
 /**
+ * Connectivity handle
+ */
+static struct GNUNET_ATS_ConnectivityHandle *connect_ats;
+
+/**
  * Performance handle
  */
 static struct GNUNET_ATS_PerformanceHandle *perf_ats;
@@ -67,11 +72,15 @@
  */
 static struct PeerContext p[2];
 
+/**
+ * Connectivity suggestion handles.
+ */
+static struct GNUNET_ATS_ConnectivitySuggestHandle *sh[2];
 
 /**
  * HELLO address
  */
-struct GNUNET_HELLO_Address test_hello_address[2];
+static struct GNUNET_HELLO_Address test_hello_address[2];
 
 /**
  * Session
@@ -81,22 +90,22 @@
 /**
  * Test ats info
  */
-struct GNUNET_ATS_Information test_ats_info[2];
+static struct GNUNET_ATS_Information test_ats_info[2];
 
 /**
  * Test ats count
  */
-uint32_t test_ats_count;
+static uint32_t test_ats_count;
 
 /**
  * Configured WAN out quota
  */
-unsigned long long wan_quota_out;
+static unsigned long long wan_quota_out;
 
 /**
  * Configured WAN in quota
  */
-unsigned long long wan_quota_in;
+static unsigned long long wan_quota_in;
 
 
 static void
@@ -109,6 +118,11 @@
     GNUNET_ATS_scheduling_done (sched_ats);
     sched_ats = NULL;
   }
+  if (NULL != connect_ats)
+  {
+    GNUNET_ATS_connectivity_done (connect_ats);
+    connect_ats = NULL;
+  }
   if (perf_ats != NULL)
   {
     GNUNET_ATS_performance_done (perf_ats);
@@ -129,8 +143,8 @@
     die_task = NULL;
   }
 
-  GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
-  GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id);
+  GNUNET_ATS_connectivity_suggest_cancel (sh[0]);
+  GNUNET_ATS_connectivity_suggest_cancel (sh[1]);
 
   if (NULL != sched_ats)
        GNUNET_ATS_scheduling_done (sched_ats);
@@ -366,6 +380,7 @@
   die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
 
   /* Connect to ATS scheduling */
+  connect_ats = GNUNET_ATS_connectivity_init (mycfg);
   sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
   if (sched_ats == NULL)
   {
@@ -439,8 +454,8 @@
   test_hello_address[1].address_length = test_addr[1].addr_len;
   GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], 
test_ats_info, test_ats_count);
 
-  GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
-  GNUNET_ATS_suggest_address (sched_ats, &p[1].id);
+  sh[0] = GNUNET_ATS_connectivity_suggest (connect_ats, &p[0].id);
+  sh[1] = GNUNET_ATS_connectivity_suggest (connect_ats, &p[1].id);
 }
 
 

Modified: gnunet/src/ats/test_ats_solver_add_address_and_request.c
===================================================================
--- gnunet/src/ats/test_ats_solver_add_address_and_request.c    2015-02-03 
13:23:01 UTC (rev 35078)
+++ gnunet/src/ats/test_ats_solver_add_address_and_request.c    2015-02-03 
14:11:03 UTC (rev 35079)
@@ -51,6 +51,11 @@
 static struct GNUNET_ATS_SchedulingHandle *sched_ats;
 
 /**
+ * Connectivity handle
+ */
+static struct GNUNET_ATS_ConnectivityHandle *connect_ats;
+
+/**
  * Return value
  */
 static int ret;
@@ -106,6 +111,11 @@
     GNUNET_ATS_scheduling_done (sched_ats);
     sched_ats = NULL;
   }
+  if (NULL != connect_ats)
+  {
+    GNUNET_ATS_connectivity_done (connect_ats);
+    connect_ats = NULL;
+  }
 
   GNUNET_STATISTICS_watch_cancel (stats, "ats", "# addresses", &stat_cb, NULL);
   if (NULL != stats)
@@ -154,7 +164,7 @@
          const char *name, uint64_t value,
          int is_persistent)
 {
-  static struct GNUNET_ATS_SuggestHandle *sh;
+  static struct GNUNET_ATS_ConnectivitySuggestHandle *sh;
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "ATS statistics: `%s' `%s' %llu\n",
@@ -162,7 +172,7 @@
               name,
               value);
   if (NULL == sh)
-    sh = GNUNET_ATS_suggest_address (sched_ats, &p.id);
+    sh = GNUNET_ATS_connectivity_suggest (connect_ats, &p.id);
   return GNUNET_OK;
 }
 
@@ -177,6 +187,7 @@
   GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
 
 
+  connect_ats = GNUNET_ATS_connectivity_init (mycfg);
   /* Connect to ATS scheduling */
   sched_ats = GNUNET_ATS_scheduling_init (mycfg, &address_suggest_cb, NULL);
   if (sched_ats == NULL)

Modified: gnunet/src/ats/test_ats_solver_alternative_after_delete_address.c
===================================================================
--- gnunet/src/ats/test_ats_solver_alternative_after_delete_address.c   
2015-02-03 13:23:01 UTC (rev 35078)
+++ gnunet/src/ats/test_ats_solver_alternative_after_delete_address.c   
2015-02-03 14:11:03 UTC (rev 35079)
@@ -45,6 +45,11 @@
 static struct GNUNET_ATS_SchedulingHandle *sched_ats;
 
 /**
+ * Connectivity handle
+ */
+static struct GNUNET_ATS_ConnectivityHandle *connect_ats;
+
+/**
  * Return value
  */
 static int ret;
@@ -125,12 +130,16 @@
 static void
 end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  if (die_task != NULL)
+  if (NULL != die_task)
   {
     GNUNET_SCHEDULER_cancel (die_task);
     die_task = NULL;
   }
-
+  if (NULL != connect_ats)
+  {
+    GNUNET_ATS_connectivity_done (connect_ats);
+    connect_ats = NULL;
+  }
   if (NULL != sched_ats)
   {
     GNUNET_ATS_scheduling_done (sched_ats);
@@ -313,7 +322,7 @@
                 "All addresses added, requesting....\n");
     /* We have 2 addresses, so we can request */
     addresses_added = GNUNET_YES;
-    GNUNET_ATS_suggest_address (sched_ats, &p.id);
+    GNUNET_ATS_connectivity_suggest (connect_ats, &p.id);
   }
   return GNUNET_OK;
 }
@@ -328,6 +337,7 @@
   stats = GNUNET_STATISTICS_create ("ats", mycfg);
   GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
 
+  connect_ats = GNUNET_ATS_connectivity_init (mycfg);
 
   /* Connect to ATS scheduling */
   sched_ats = GNUNET_ATS_scheduling_init (mycfg, &address_suggest_cb, NULL);

Modified: gnunet/src/ats/test_ats_solver_convergence.c
===================================================================
--- gnunet/src/ats/test_ats_solver_convergence.c        2015-02-03 13:23:01 UTC 
(rev 35078)
+++ gnunet/src/ats/test_ats_solver_convergence.c        2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -46,6 +46,11 @@
 static struct GNUNET_ATS_SchedulingHandle *sched_ats;
 
 /**
+ * Connectivity handle
+ */
+static struct GNUNET_ATS_ConnectivityHandle *connect_ats;
+
+/**
  * Return value
  */
 static int ret;
@@ -125,6 +130,11 @@
     sched_ats = NULL;
   }
 
+  if (NULL != connect_ats)
+  {
+    GNUNET_ATS_connectivity_done (connect_ats);
+    connect_ats = NULL;
+  }
   GNUNET_STATISTICS_watch_cancel (stats, "ats", "# addresses", &stat_cb, NULL);
   if (NULL != stats)
   {
@@ -219,7 +229,7 @@
               "ATS statistics: `%s' `%s' %llu\n",
               subsystem,name,
               (unsigned long long) value);
-  GNUNET_ATS_suggest_address (sched_ats, &p.id);
+  GNUNET_ATS_connectivity_suggest (connect_ats, &p.id);
   return GNUNET_OK;
 }
 
@@ -233,6 +243,7 @@
   stats = GNUNET_STATISTICS_create ("ats", mycfg);
   GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
 
+  connect_ats = GNUNET_ATS_connectivity_init (mycfg);
   /* Connect to ATS scheduling */
   sched_ats = GNUNET_ATS_scheduling_init (mycfg, &address_suggest_cb, NULL);
   if (sched_ats == NULL)

Modified: gnunet/src/ats/test_ats_solver_preferences.c
===================================================================
--- gnunet/src/ats/test_ats_solver_preferences.c        2015-02-03 13:23:01 UTC 
(rev 35078)
+++ gnunet/src/ats/test_ats_solver_preferences.c        2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -51,8 +51,13 @@
 static struct GNUNET_ATS_SchedulingHandle *sched_ats;
 
 /**
- * Scheduling handle
+ * Connectivity handle
  */
+static struct GNUNET_ATS_ConnectivityHandle *connect_ats;
+
+/**
+ * Performance handle
+ */
 static struct GNUNET_ATS_PerformanceHandle *perf_ats;
 
 /**
@@ -95,6 +100,7 @@
 stat_cb (void *cls, const char *subsystem, const char *name, uint64_t value,
     int is_persistent);
 
+
 static void
 end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -111,7 +117,11 @@
     GNUNET_ATS_scheduling_done (sched_ats);
     sched_ats = NULL;
   }
-
+  if (NULL != connect_ats)
+  {
+    GNUNET_ATS_connectivity_done (connect_ats);
+    connect_ats = NULL;
+  }
   if (NULL != perf_ats)
   {
     GNUNET_ATS_performance_done (perf_ats);
@@ -203,6 +213,7 @@
   return GNUNET_OK;
 }
 
+
 static void
 run (void *cls, const struct GNUNET_CONFIGURATION_Handle *mycfg,
     struct GNUNET_TESTING_Peer *peer)
@@ -212,6 +223,8 @@
   stats = GNUNET_STATISTICS_create ("ats", mycfg);
   GNUNET_STATISTICS_watch (stats, "ats", "# active performance clients", 
&stat_cb, NULL );
 
+  connect_ats = GNUNET_ATS_connectivity_init (mycfg);
+
   /* Connect to ATS scheduling */
   sched_ats = GNUNET_ATS_scheduling_init (mycfg, &address_suggest_cb, NULL );
   if (sched_ats == NULL )
@@ -258,7 +271,7 @@
   /* Adding address */
   GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session,
       test_ats_info, test_ats_count);
-  GNUNET_ATS_suggest_address(sched_ats, &test_hello_address.peer);
+  GNUNET_ATS_connectivity_suggest (connect_ats, &test_hello_address.peer);
 }
 
 

Modified: gnunet/src/ats/test_ats_solver_request_and_add_address.c
===================================================================
--- gnunet/src/ats/test_ats_solver_request_and_add_address.c    2015-02-03 
13:23:01 UTC (rev 35078)
+++ gnunet/src/ats/test_ats_solver_request_and_add_address.c    2015-02-03 
14:11:03 UTC (rev 35079)
@@ -51,6 +51,11 @@
 static struct GNUNET_ATS_SchedulingHandle *sched_ats;
 
 /**
+ * Connectivity handle
+ */
+static struct GNUNET_ATS_ConnectivityHandle *connect_ats;
+
+/**
  * Return value
  */
 static int ret;
@@ -105,7 +110,11 @@
     GNUNET_ATS_scheduling_done (sched_ats);
     sched_ats = NULL;
   }
-
+  if (NULL != connect_ats)
+  {
+    GNUNET_ATS_connectivity_done (connect_ats);
+    connect_ats = NULL;
+  }
   GNUNET_STATISTICS_watch_cancel (stats, "ats", "# addresses", &stat_cb, NULL);
   if (NULL != stats)
   {
@@ -165,7 +174,7 @@
   stats = GNUNET_STATISTICS_create ("ats", mycfg);
   GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
 
-
+  connect_ats = GNUNET_ATS_connectivity_init (mycfg);
   /* Connect to ATS scheduling */
   sched_ats = GNUNET_ATS_scheduling_init (mycfg, &address_suggest_cb, NULL);
   if (sched_ats == NULL)
@@ -196,7 +205,7 @@
   test_hello_address.address_length = test_addr.addr_len;
 
   /* Request */
-  GNUNET_ATS_suggest_address (sched_ats, &p.id);
+  GNUNET_ATS_connectivity_suggest (connect_ats, &p.id);
 
 
   /* Adding address */

Modified: gnunet/src/ats/test_ats_solver_request_and_delete_address.c
===================================================================
--- gnunet/src/ats/test_ats_solver_request_and_delete_address.c 2015-02-03 
13:23:01 UTC (rev 35078)
+++ gnunet/src/ats/test_ats_solver_request_and_delete_address.c 2015-02-03 
14:11:03 UTC (rev 35079)
@@ -45,6 +45,11 @@
 static struct GNUNET_ATS_SchedulingHandle *sched_ats;
 
 /**
+ * Connectivity handle
+ */
+static struct GNUNET_ATS_ConnectivityHandle *connect_ats;
+
+/**
  * Return value
  */
 static int ret;
@@ -108,6 +113,11 @@
     sched_ats = NULL;
   }
 
+  if (NULL != connect_ats)
+  {
+    GNUNET_ATS_connectivity_done (connect_ats);
+    connect_ats = NULL;
+  }
   GNUNET_STATISTICS_watch_cancel (stats, "ats", "# addresses", &stat_cb, NULL);
   if (NULL != stats)
   {
@@ -178,7 +188,7 @@
          const char *name, uint64_t value,
          int is_persistent)
 {
-  static struct GNUNET_ATS_SuggestHandle *sh;
+  static struct GNUNET_ATS_ConnectivitySuggestHandle *sh;
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "ATS statistics: `%s' `%s' %llu\n",
@@ -186,7 +196,7 @@
               name,
               value);
   if (NULL == sh)
-    sh = GNUNET_ATS_suggest_address (sched_ats, &p.id);
+    sh = GNUNET_ATS_connectivity_suggest (connect_ats, &p.id);
   return GNUNET_OK;
 }
 
@@ -200,6 +210,7 @@
   stats = GNUNET_STATISTICS_create ("ats", mycfg);
   GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
 
+  connect_ats = GNUNET_ATS_connectivity_init (mycfg);
 
   /* Connect to ATS scheduling */
   sched_ats = GNUNET_ATS_scheduling_init (mycfg, &address_suggest_cb, NULL);

Modified: gnunet/src/include/gnunet_ats_service.h
===================================================================
--- gnunet/src/include/gnunet_ats_service.h     2015-02-03 13:23:01 UTC (rev 
35078)
+++ gnunet/src/include/gnunet_ats_service.h     2015-02-03 14:11:03 UTC (rev 
35079)
@@ -304,6 +304,62 @@
 };
 GNUNET_NETWORK_STRUCT_END
 
+
+/* ********************Connection Suggestion API ***************************** 
*/
+
+/**
+ * Handle to the ATS subsystem for making suggestions about
+ * connections the peer would like to have.
+ */
+struct GNUNET_ATS_ConnectivityHandle;
+
+/**
+ * Handle for address suggestion requests.
+ */
+struct GNUNET_ATS_ConnectivitySuggestHandle;
+
+
+/**
+ * Initialize the ATS connectivity suggestion client handle.
+ *
+ * @param cfg configuration to use
+ * @return ats connectivity handle, NULL on error
+ */
+struct GNUNET_ATS_ConnectivityHandle *
+GNUNET_ATS_connectivity_init (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+
+/**
+ * Shutdown ATS connectivity suggestion client.
+ *
+ * @param ch handle to destroy
+ */
+void
+GNUNET_ATS_connectivity_done (struct GNUNET_ATS_ConnectivityHandle *ch);
+
+
+/**
+ * We would like to establish a new connection with a peer.  ATS
+ * should suggest a good address to begin with.
+ *
+ * @param ch handle
+ * @param peer identity of the peer we need an address for
+ * @return suggestion handle, NULL if request is already pending
+ */
+struct GNUNET_ATS_ConnectivitySuggestHandle *
+GNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch,
+                                 const struct GNUNET_PeerIdentity *peer);
+
+
+/**
+ * We no longer care about being connected to a peer.
+ *
+ * @param sh handle
+ */
+void
+GNUNET_ATS_connectivity_suggest_cancel (struct 
GNUNET_ATS_ConnectivitySuggestHandle *sh);
+
+
 /* ******************************** Scheduling API 
***************************** */
 
 /**
@@ -312,11 +368,6 @@
 struct GNUNET_ATS_SchedulingHandle;
 
 /**
- * Handle for address suggestion requests
- */
-struct GNUNET_ATS_SuggestHandle;
-
-/**
  * Opaque session handle, defined by plugins.  Contents not known to ATS.
  */
 struct Session;
@@ -343,7 +394,7 @@
 
 
 /**
- * Initialize the ATS subsystem.
+ * Initialize the ATS scheduling subsystem.
  *
  * @param cfg configuration to use
  * @param suggest_cb notification to call whenever the suggestation changed
@@ -377,30 +428,6 @@
 
 
 /**
- * We would like to establish a new connection with a peer.  ATS
- * should suggest a good address to begin with.
- *
- * @param sh handle
- * @param peer identity of the peer we need an address for
- * @return suggestion handle, NULL if a request is already pending
- */
-struct GNUNET_ATS_SuggestHandle *
-GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
-                            const struct GNUNET_PeerIdentity *peer);
-
-
-/**
- * We want to cancel ATS suggesting addresses for a peer.
- *
- * @param sh handle
- * @param peer identity of the peer
- */
-void
-GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh,
-                                   const struct GNUNET_PeerIdentity *peer);
-
-
-/**
  * Convert a ATS property to a string
  *
  * @param type the property type

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2015-02-03 13:23:01 UTC 
(rev 35078)
+++ gnunet/src/transport/gnunet-service-transport.c     2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -122,11 +122,16 @@
 struct GNUNET_CRYPTO_EddsaPrivateKey *GST_my_private_key;
 
 /**
- * ATS handle.
+ * ATS scheduling handle.
  */
 struct GNUNET_ATS_SchedulingHandle *GST_ats;
 
 /**
+ * ATS connectivity handle.
+ */
+struct GNUNET_ATS_ConnectivityHandle *GST_ats_connect;
+
+/**
  * Hello address expiration
  */
 struct GNUNET_TIME_Relative hello_expiration;
@@ -857,6 +862,8 @@
   GST_ats_done ();
   GNUNET_ATS_scheduling_done (GST_ats);
   GST_ats = NULL;
+  GNUNET_ATS_connectivity_done (GST_ats_connect);
+  GST_ats_connect = NULL;
   GST_clients_stop ();
   GST_blacklist_stop ();
   GST_hello_stop ();
@@ -986,6 +993,7 @@
   GST_hello_start (friend_only, &process_hello_update, NULL );
   GNUNET_assert(NULL != GST_hello_get());
   GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity);
+  GST_ats_connect = GNUNET_ATS_connectivity_init (GST_cfg);
   GST_ats = GNUNET_ATS_scheduling_init (GST_cfg,
                                         &ats_request_address_change,
                                         NULL);

Modified: gnunet/src/transport/gnunet-service-transport.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport.h     2015-02-03 13:23:01 UTC 
(rev 35078)
+++ gnunet/src/transport/gnunet-service-transport.h     2015-02-03 14:11:03 UTC 
(rev 35079)
@@ -63,7 +63,12 @@
  */
 extern struct GNUNET_ATS_SchedulingHandle *GST_ats;
 
+/**
+ * ATS connectivity handle.
+ */
+extern struct GNUNET_ATS_ConnectivityHandle *GST_ats_connect;
 
+
 /**
  * Function to call when a peer's address has changed
  *

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-02-03 
13:23:01 UTC (rev 35078)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-02-03 
14:11:03 UTC (rev 35079)
@@ -373,7 +373,7 @@
   /**
    * ATS address suggest handle
    */
-  struct GNUNET_ATS_SuggestHandle *suggest_handle;
+  struct GNUNET_ATS_ConnectivitySuggestHandle *suggest_handle;
 
   /**
    * Time where we should cut the connection (timeout) if we don't
@@ -1047,7 +1047,7 @@
   /* Cancel address requests for this peer */
   if (NULL != n->suggest_handle)
   {
-    GNUNET_ATS_suggest_address_cancel (GST_ats, &n->id);
+    GNUNET_ATS_connectivity_suggest_cancel (n->suggest_handle);
     n->suggest_handle = NULL;
   }
 
@@ -2173,8 +2173,8 @@
                          GNUNET_TIME_relative_to_absolute 
(ATS_RESPONSE_TIMEOUT));
   GNUNET_ATS_reset_backoff (GST_ats, peer);
   GNUNET_assert (NULL == n->suggest_handle);
-  n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats,
-                                                  peer);
+  n->suggest_handle = GNUNET_ATS_connectivity_suggest (GST_ats_connect,
+                                                       peer);
 }
 
 
@@ -2321,7 +2321,8 @@
     set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
         GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
     if (NULL == n->suggest_handle)
-      n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer);
+      n->suggest_handle = GNUNET_ATS_connectivity_suggest (GST_ats_connect,
+                                                           peer);
     break;
   case GNUNET_TRANSPORT_PS_INIT_ATS:
     /* SYN message takes priority over us asking ATS for address:
@@ -2375,7 +2376,8 @@
     n->ack_state = ACK_SEND_SYN_ACK;
     n->connect_ack_timestamp = ts;
     /* Request an address for the peer */
-    n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer);
+    n->suggest_handle = GNUNET_ATS_connectivity_suggest (GST_ats_connect,
+                                                         peer);
     GNUNET_ATS_reset_backoff (GST_ats, peer);
     set_state (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS);
     break;




reply via email to

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