gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r36534 - gnunet/src/cadet


From: gnunet
Subject: [GNUnet-SVN] r36534 - gnunet/src/cadet
Date: Sun, 18 Oct 2015 15:59:59 +0200

Author: grothoff
Date: 2015-10-18 15:59:59 +0200 (Sun, 18 Oct 2015)
New Revision: 36534

Modified:
   gnunet/src/cadet/Makefile.am
   gnunet/src/cadet/gnunet-service-cadet_peer.c
Log:
use ATS connectivity suggestion instead of deprecated 
GNUNET_TRANSPORT_try_connect

Modified: gnunet/src/cadet/Makefile.am
===================================================================
--- gnunet/src/cadet/Makefile.am        2015-10-18 13:53:25 UTC (rev 36533)
+++ gnunet/src/cadet/Makefile.am        2015-10-18 13:59:59 UTC (rev 36534)
@@ -62,6 +62,7 @@
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/transport/libgnunettransport.la \
   $(top_builddir)/src/core/libgnunetcore.la \
+  $(top_builddir)/src/ats/libgnunetats.la \
   $(top_builddir)/src/dht/libgnunetdht.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
@@ -210,4 +211,3 @@
   cadet.h cadet_protocol.h \
   test_cadet.conf \
   test_cadet_drop.conf
-

Modified: gnunet/src/cadet/gnunet-service-cadet_peer.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_peer.c        2015-10-18 13:53:25 UTC 
(rev 36533)
+++ gnunet/src/cadet/gnunet-service-cadet_peer.c        2015-10-18 13:59:59 UTC 
(rev 36534)
@@ -26,6 +26,7 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_signatures.h"
 #include "gnunet_transport_service.h"
+#include "gnunet_ats_service.h"
 #include "gnunet_core_service.h"
 #include "gnunet_statistics_service.h"
 #include "cadet_protocol.h"
@@ -194,6 +195,13 @@
    * Handle to us offering the HELLO to the transport.
    */
   struct GNUNET_TRANSPORT_OfferHelloHandle *hello_offer;
+
+  /**
+   * Handle to our ATS request asking ATS to suggest an address
+   * to TRANSPORT for this peer (to establish a direct link).
+   */
+  struct GNUNET_ATS_ConnectivitySuggestHandle *connectivity_suggestion;
+
 };
 
 
@@ -232,11 +240,16 @@
 static unsigned long long drop_percent;
 
 /**
- * Handle to communicate with core.
+ * Handle to communicate with CORE.
  */
 static struct GNUNET_CORE_Handle *core_handle;
 
 /**
+ * Handle to communicate with ATS.
+ */
+static struct GNUNET_ATS_ConnectivityHandle *ats_ch;
+
+/**
  * Handle to try to start new connections.
  */
 static struct GNUNET_TRANSPORT_Handle *transport_handle;
@@ -767,6 +780,11 @@
     GNUNET_TRANSPORT_offer_hello_cancel (peer->hello_offer);
     peer->hello_offer = NULL;
   }
+  if (NULL != peer->connectivity_suggestion)
+  {
+    GNUNET_ATS_connectivity_suggest_cancel (peer->connectivity_suggestion);
+    peer->connectivity_suggestion = NULL;
+  }
   GNUNET_free_non_null (peer->hello);
   GNUNET_free (peer);
   return GNUNET_OK;
@@ -1790,7 +1808,7 @@
     LOG (GNUNET_ERROR_TYPE_WARNING, "Remove DROP_PERCENT from config file.\n");
     LOG (GNUNET_ERROR_TYPE_WARNING, 
"**************************************\n");
   }
-
+  ats_ch = GNUNET_ATS_connectivity_init (c);
   core_handle = GNUNET_CORE_connect (c, /* Main configuration */
                                      NULL,      /* Closure passed to CADET 
functions */
                                      &core_init,        /* Call core_init once 
connected */
@@ -1835,7 +1853,8 @@
 void
 GCP_shutdown (void)
 {
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peers\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Shutting down peer subsystem\n");
   in_shutdown = GNUNET_YES;
   GNUNET_CONTAINER_multipeermap_iterate (peers,
                                          &shutdown_peer,
@@ -1850,6 +1869,11 @@
     GNUNET_TRANSPORT_disconnect (transport_handle);
     transport_handle = NULL;
   }
+  if (NULL != ats_ch)
+  {
+    GNUNET_ATS_connectivity_done (ats_ch);
+    ats_ch = NULL;
+  }
   GNUNET_PEER_change_rc (myid, -1);
   GNUNET_CONTAINER_multipeermap_destroy (peers);
   peers = NULL;
@@ -1912,23 +1936,19 @@
 
 
 /**
- * Try to connect to a peer on transport level.
+ * Function called once #GNUNET_TRANSPORT_offer_hello() is done.
+ * Marks the operation as finished.
  *
- * @param cls Closure (peer).
+ * @param cls Closure (our `struct CadetPeer`).
  * @param tc TaskContext.
  */
 static void
-try_connect (void *cls,
-             const struct GNUNET_SCHEDULER_TaskContext *tc)
+hello_offer_done (void *cls,
+                  const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct CadetPeer *peer = cls;
 
   peer->hello_offer = NULL;
-  if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
-    return;
-
-  GNUNET_TRANSPORT_try_connect (transport_handle,
-                                GNUNET_PEER_resolve2 (peer->id), NULL, NULL);
 }
 
 
@@ -2556,8 +2576,12 @@
   mh = GNUNET_HELLO_get_header (hello);
   peer->hello_offer = GNUNET_TRANSPORT_offer_hello (transport_handle,
                                                     mh,
-                                                    &try_connect,
+                                                    &hello_offer_done,
                                                     peer);
+  peer->connectivity_suggestion
+    = GNUNET_ATS_connectivity_suggest (ats_ch,
+                                       GNUNET_PEER_resolve2 (peer->id),
+                                       1 /* strength */);
   GCC_check_connections ();
 }
 




reply via email to

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