gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r36600 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r36600 - gnunet/src/testbed
Date: Tue, 27 Oct 2015 15:49:03 +0100

Author: grothoff
Date: 2015-10-27 15:49:03 +0100 (Tue, 27 Oct 2015)
New Revision: 36600

Modified:
   gnunet/src/testbed/Makefile.am
   gnunet/src/testbed/gnunet-service-testbed_connectionpool.c
   gnunet/src/testbed/gnunet-service-testbed_connectionpool.h
   gnunet/src/testbed/gnunet-service-testbed_oc.c
Log:
prepare testbed for #3675 by having an option to establish connections to ATS

Modified: gnunet/src/testbed/Makefile.am
===================================================================
--- gnunet/src/testbed/Makefile.am      2015-10-27 14:28:19 UTC (rev 36599)
+++ gnunet/src/testbed/Makefile.am      2015-10-27 14:49:03 UTC (rev 36600)
@@ -53,6 +53,7 @@
  $(top_builddir)/src/core/libgnunetcore.la \
  $(top_builddir)/src/hello/libgnunethello.la \
  $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/ats/libgnunetats.la \
  $(top_builddir)/src/testing/libgnunettesting.la \
  libgnunettestbed.la \
  $(top_builddir)/src/arm/libgnunetarm.la \

Modified: gnunet/src/testbed/gnunet-service-testbed_connectionpool.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_connectionpool.c  2015-10-27 
14:28:19 UTC (rev 36599)
+++ gnunet/src/testbed/gnunet-service-testbed_connectionpool.c  2015-10-27 
14:49:03 UTC (rev 36600)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet.
-  Copyright (C) 2008--2013 Christian Grothoff (and other contributing authors)
+  Copyright (C) 2008--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
@@ -79,6 +79,11 @@
   struct GNUNET_CORE_Handle *handle_core;
 
   /**
+   * The ATS handle to the peer correspondign to this entry; can be NULL.
+   */
+  struct GNUNET_ATS_ConnectivityHandle *handle_ats_connectivity;
+
+  /**
    * The operation handle for transport handle
    */
   struct GNUNET_TESTBED_Operation *op_transport;
@@ -89,6 +94,11 @@
   struct GNUNET_TESTBED_Operation *op_core;
 
   /**
+   * The operation handle for ATS handle
+   */
+  struct GNUNET_TESTBED_Operation *op_ats_connectivity;
+
+  /**
    * The peer identity of this peer. Will be set upon opening a connection to
    * the peers CORE service. Will be NULL until then and after the CORE
    * connection is closed
@@ -299,6 +309,13 @@
     GNUNET_TESTBED_operation_done (entry->op_transport);
     entry->op_transport = NULL;
   }
+  if (NULL != entry->handle_ats_connectivity)
+    GNUNET_assert (NULL != entry->op_ats_connectivity);
+  if (NULL != entry->op_ats_connectivity)
+  {
+    GNUNET_TESTBED_operation_done (entry->op_ats_connectivity);
+    entry->op_ats_connectivity = NULL;
+  }
   if (NULL != entry->op_core)
   {
     GNUNET_TESTBED_operation_done (entry->op_core);
@@ -305,6 +322,7 @@
     entry->op_core = NULL;
   }
   GNUNET_assert (NULL == entry->handle_core);
+  GNUNET_assert (NULL == entry->handle_ats_connectivity);
   GNUNET_assert (NULL == entry->handle_transport);
   GNUNET_CONFIGURATION_destroy (entry->cfg);
   GNUNET_free (entry);
@@ -318,7 +336,8 @@
  * @param tc scheduler task context
  */
 static void
-expire (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+expire (void *cls,
+        const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct PooledConnection *entry = cls;
 
@@ -392,6 +411,10 @@
       if (NULL == entry->handle_transport)
         continue;
       break;
+    case GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY:
+      if (NULL == entry->handle_ats_connectivity)
+        continue;
+      break;
     }
     break;
   }
@@ -422,18 +445,27 @@
   gh_next = NULL;
   if (NULL != gh->next)
     gh_next = search_waiting (entry, gh->next);
-  GNUNET_CONTAINER_DLL_remove (entry->head_waiting, entry->tail_waiting, gh);
+  GNUNET_CONTAINER_DLL_remove (entry->head_waiting,
+                               entry->tail_waiting,
+                               gh);
   gh->connection_ready_called = 1;
   if (NULL != gh_next)
-    entry->notify_task = GNUNET_SCHEDULER_add_now (&connection_ready, entry);
-  if ( (NULL != gh->target) && (NULL != gh->connect_notify_cb) )
+    entry->notify_task = GNUNET_SCHEDULER_add_now (&connection_ready,
+                                                   entry);
+  if ( (NULL != gh->target) &&
+       (NULL != gh->connect_notify_cb) )
   {
-    GNUNET_CONTAINER_DLL_insert_tail (entry->head_notify, entry->tail_notify,
+    GNUNET_CONTAINER_DLL_insert_tail (entry->head_notify,
+                                      entry->tail_notify,
                                       gh);
     gh->notify_waiting = 1;
   }
-  LOG_DEBUG ("Connection ready for handle type %u\n", gh->service);
-  gh->cb (gh->cb_cls, entry->handle_core, entry->handle_transport,
+  LOG_DEBUG ("Connection ready for handle type %u\n",
+             gh->service);
+  gh->cb (gh->cb_cls,
+          entry->handle_core,
+          entry->handle_transport,
+          entry->handle_ats_connectivity,
           entry->peer_identity);
 }
 
@@ -448,7 +480,8 @@
  * @param service the service where this notification has originated
  */
 static void
-peer_connect_notify_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
+peer_connect_notify_cb (void *cls,
+                        const struct GNUNET_PeerIdentity *peer,
                         const enum GST_ConnectionPool_Service service)
 {
   struct PooledConnection *entry = cls;
@@ -467,7 +500,9 @@
       gh = gh->next;
       continue;
     }
-    if (0 != memcmp (gh->target, peer, sizeof (struct GNUNET_PeerIdentity)))
+    if (0 != memcmp (gh->target,
+                     peer,
+                     sizeof (struct GNUNET_PeerIdentity)))
     {
       gh = gh->next;
       continue;
@@ -477,7 +512,9 @@
     gh_next = gh->next;
     GNUNET_CONTAINER_DLL_remove (entry->head_notify, entry->tail_notify, gh);
     gh->notify_waiting = 0;
-    LOG_DEBUG ("Peer connected to peer %u at service %u\n", entry->index, 
gh->service);
+    LOG_DEBUG ("Peer connected to peer %u at service %u\n",
+               entry->index,
+               gh->service);
     gh = gh_next;
     cb (cb_cls, peer);
   }
@@ -497,7 +534,9 @@
 {
   struct PooledConnection *entry = cls;
 
-  peer_connect_notify_cb (entry, peer, GST_CONNECTIONPOOL_SERVICE_TRANSPORT);
+  peer_connect_notify_cb (entry,
+                          peer,
+                          GST_CONNECTIONPOOL_SERVICE_TRANSPORT);
 }
 
 
@@ -637,7 +676,7 @@
 
 
 /**
- * Function called when the operation responsible for opening a TRANSPORT
+ * Function called when the operation responsible for opening a CORE
  * connection is marked as done.
  *
  * @param cls the #PooledConnection object
@@ -657,6 +696,40 @@
 
 
 /**
+ * Function called when resources for opening a connection to ATS are
+ * available.
+ *
+ * @param cls the #PooledConnection object
+ */
+static void
+opstart_get_handle_ats_connectivity (void *cls)
+{
+  struct PooledConnection *entry = cls;
+
+  entry->handle_ats_connectivity =
+    GNUNET_ATS_connectivity_init (entry->cfg);
+}
+
+
+/**
+ * Function called when the operation responsible for opening a ATS
+ * connection is marked as done.
+ *
+ * @param cls the #PooledConnection object
+ */
+static void
+oprelease_get_handle_ats_connectivity (void *cls)
+{
+  struct PooledConnection *entry = cls;
+
+  if (NULL == entry->handle_ats_connectivity)
+    return;
+  GNUNET_ATS_connectivity_done (entry->handle_ats_connectivity);
+  entry->handle_ats_connectivity = NULL;
+}
+
+
+/**
  * This function will be called for every #PooledConnection object in @p map
  *
  * @param cls NULL
@@ -798,6 +871,12 @@
         LOG_DEBUG ("Found CORE handle for peer %u\n",
                    entry->index);
       break;
+    case GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY:
+      handle = entry->handle_ats_connectivity;
+      if (NULL != handle)
+        LOG_DEBUG ("Found ATS CONNECTIVITY handle for peer %u\n",
+                   entry->index);
+      break;
     }
   }
   else
@@ -863,6 +942,14 @@
                                            &oprelease_get_handle_core);
     entry->op_core = op;
     break;
+  case GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY:
+    if (NULL != entry->op_ats_connectivity)
+      return gh;                /* Operation pending */
+    op = GNUNET_TESTBED_operation_create_ (entry,
+                                           
&opstart_get_handle_ats_connectivity,
+                                           
&oprelease_get_handle_ats_connectivity);
+    entry->op_ats_connectivity = op;
+    break;
   }
   GNUNET_TESTBED_operation_queue_insert_ (GST_opq_openfds,
                                           op);

Modified: gnunet/src/testbed/gnunet-service-testbed_connectionpool.h
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_connectionpool.h  2015-10-27 
14:28:19 UTC (rev 36599)
+++ gnunet/src/testbed/gnunet-service-testbed_connectionpool.h  2015-10-27 
14:49:03 UTC (rev 36600)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet.
-  Copyright (C) 2008--2013 Christian Grothoff (and other contributing authors)
+  Copyright (C) 2008--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
@@ -23,8 +23,10 @@
  * @brief Interface for connection pooling subroutines
  * @author Sree Harsha Totakura <address@hidden>
  */
+#include "gnunet_ats_service.h"
+#include "gnunet_core_service.h"
+#include "gnunet_transport_service.h"
 
-
 /**
  * The request handle for obtaining a pooled connection
  */
@@ -44,7 +46,12 @@
   /**
    * Core service
    */
-  GST_CONNECTIONPOOL_SERVICE_CORE
+  GST_CONNECTIONPOOL_SERVICE_CORE,
+
+  /**
+   * ATS service
+   */
+  GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY
 };
 
 
@@ -63,7 +70,7 @@
  * Cleanup the connection pool
  */
 void
-GST_connection_pool_destroy ();
+GST_connection_pool_destroy (void);
 
 /**
  * Functions of this type are called when the needed handle is available for
@@ -75,15 +82,16 @@
  * @param cls the closure passed to GST_connection_pool_get_handle()
  * @param ch the handle to CORE. Can be NULL if it is not requested
  * @param th the handle to TRANSPORT. Can be NULL if it is not requested
+ * @param ac the handle to ATS, can be NULL if it is not requested
  * @param peer_id the identity of the peer. Will be NULL if ch is NULL. In 
other
  *          cases, its value being NULL means that CORE connection has failed.
  */
 typedef void
 (*GST_connection_pool_connection_ready_cb) (void *cls,
-                                            struct GNUNET_CORE_Handle * ch,
-                                            struct GNUNET_TRANSPORT_Handle * 
th,
-                                            const struct GNUNET_PeerIdentity *
-                                            peer_id);
+                                            struct GNUNET_CORE_Handle *ch,
+                                            struct GNUNET_TRANSPORT_Handle *th,
+                                            struct 
GNUNET_ATS_ConnectivityHandle *ac,
+                                            const struct GNUNET_PeerIdentity 
*peer_id);
 
 
 /**
@@ -96,8 +104,7 @@
  */
 typedef void
 (*GST_connection_pool_peer_connect_notify) (void *cls,
-                                            const struct GNUNET_PeerIdentity
-                                            *target);
+                                            const struct GNUNET_PeerIdentity 
*target);
 
 
 /**

Modified: gnunet/src/testbed/gnunet-service-testbed_oc.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_oc.c      2015-10-27 14:28:19 UTC 
(rev 36599)
+++ gnunet/src/testbed/gnunet-service-testbed_oc.c      2015-10-27 14:49:03 UTC 
(rev 36600)
@@ -625,7 +625,8 @@
  * @param new_peer the peer that connected
  */
 static void
-overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer)
+overlay_connect_notify (void *cls,
+                        const struct GNUNET_PeerIdentity *new_peer)
 {
   struct OverlayConnectContext *occ = cls;
   struct LocalPeer2Context *lp2c;
@@ -684,7 +685,8 @@
  * @param tc the scheduler task context
  */
 static void
-try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+try_connect_task (void *cls,
+                  const struct GNUNET_SCHEDULER_TaskContext *tc);
 
 
 /**
@@ -691,11 +693,12 @@
  * Callback to be called with result of the try connect request.
  *
  * @param cls the overlay connect context
- * @param result GNUNET_OK if message was transmitted to transport service
- *               GNUNET_SYSERR if message was not transmitted to transport 
service
+ * @param result #GNUNET_OK if message was transmitted to transport service
+ *               #GNUNET_SYSERR if message was not transmitted to transport 
service
  */
 static void
-try_connect_cb (void *cls, const int result)
+try_connect_cb (void *cls,
+                const int result)
 {
   struct TryConnectContext *tcc = cls;
 
@@ -716,7 +719,8 @@
  * @param tc the scheduler task context
  */
 static void
-try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+try_connect_task (void *cls,
+                  const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct TryConnectContext *tcc = cls;
 
@@ -742,7 +746,8 @@
  * @param tc the TaskContext from scheduler
  */
 static void
-send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+send_hello (void *cls,
+            const struct GNUNET_SCHEDULER_TaskContext *tc);
 
 
 /**
@@ -750,11 +755,12 @@
  *
  * @param cls the overlay connect context
  * @param tc the scheduler task context; if tc->reason =
- *          GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if
- *          GNUNET_SCHEDULER_REASON_READ_READY is succeeded
+ *          #GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if
+ *          #GNUNET_SCHEDULER_REASON_READ_READY is succeeded
  */
 static void
-occ_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+occ_hello_sent_cb (void *cls,
+                   const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct OverlayConnectContext *occ = cls;
   struct LocalPeer2Context *lp2c;
@@ -790,7 +796,7 @@
  * request.
  *
  * @param occ the overlay connect context.  Its type must be either
- *          OCC_TYPE_REMOTE_SLAVE or OCC_TYPE_REMOTE_LATERAL
+ *          #OCC_TYPE_REMOTE_SLAVE or #OCC_TYPE_REMOTE_LATERAL
  */
 void
 send_hello_thru_rocc (struct OverlayConnectContext *occ)
@@ -877,6 +883,7 @@
  * @param cls the closure passed to GST_cache_get_handle_transport()
  * @param ch the handle to CORE. Can be NULL if it is not requested
  * @param th the handle to TRANSPORT. Can be NULL if it is not requested
+ * @param ac the handle to ATS. Can be NULL if it is not requested
  * @param ignore_ peer identity which is ignored in this callback
  */
 static void
@@ -883,6 +890,7 @@
 p2_transport_connect_cache_callback (void *cls,
                                      struct GNUNET_CORE_Handle *ch,
                                      struct GNUNET_TRANSPORT_Handle *th,
+                                     struct GNUNET_ATS_ConnectivityHandle *ac,
                                      const struct GNUNET_PeerIdentity *ignore_)
 {
   struct OverlayConnectContext *occ = cls;
@@ -1014,11 +1022,14 @@
  * @param cls the closure passed to GST_cache_get_handle_transport()
  * @param ch the handle to CORE. Can be NULL if it is not requested
  * @param th the handle to TRANSPORT. Can be NULL if it is not requested
+ * @param ac the handle to ATS. Can be NULL if it is not requested
  * @param ignore_ peer identity which is ignored in this callback
  */
 static void
-p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
+p1_transport_connect_cache_callback (void *cls,
+                                     struct GNUNET_CORE_Handle *ch,
                                      struct GNUNET_TRANSPORT_Handle *th,
+                                     struct GNUNET_ATS_ConnectivityHandle *ac,
                                      const struct GNUNET_PeerIdentity *ignore_)
 {
   struct OverlayConnectContext *occ = cls;
@@ -1055,6 +1066,7 @@
  * @param cls the closure passed to GST_cache_get_handle_transport()
  * @param ch the handle to CORE. Can be NULL if it is not requested
  * @param th the handle to TRANSPORT. Can be NULL if it is not requested
+ * @param ac the handle to ATS. Can be NULL if it is not requested
  * @param my_identity the identity of our peer
  */
 static void
@@ -1061,6 +1073,7 @@
 occ_cache_get_handle_core_cb (void *cls,
                               struct GNUNET_CORE_Handle *ch,
                               struct GNUNET_TRANSPORT_Handle *th,
+                              struct GNUNET_ATS_ConnectivityHandle *ac,
                               const struct GNUNET_PeerIdentity *my_identity)
 {
   struct OverlayConnectContext *occ = cls;
@@ -1244,7 +1257,8 @@
  *           already registered, NULL is returned.
  */
 static struct RegisteredHostContext *
-register_host (struct Slave *slave, struct GNUNET_TESTBED_Host *host)
+register_host (struct Slave *slave,
+               struct GNUNET_TESTBED_Host *host)
 {
   struct GNUNET_HashCode hash;
   struct RegisteredHostContext *rhc;
@@ -1357,9 +1371,12 @@
                                              
&GST_forwarded_operation_reply_relay,
                                              fopc);
   fopc->timeout_task =
-      GNUNET_SCHEDULER_add_delayed (GST_timeout, 
&GST_forwarded_operation_timeout,
+      GNUNET_SCHEDULER_add_delayed (GST_timeout,
+                                    &GST_forwarded_operation_timeout,
                                     fopc);
-  GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc);
+  GNUNET_CONTAINER_DLL_insert_tail (fopcq_head,
+                                    fopcq_tail,
+                                    fopc);
 }
 
 
@@ -1640,7 +1657,8 @@
  *          #GNUNET_SCHEDULER_REASON_READ_READY is succeeded
  */
 static void
-rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+rocc_hello_sent_cb (void *cls,
+                    const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct RemoteOverlayConnectCtx *rocc = cls;
 
@@ -1672,7 +1690,8 @@
  * @param tc the TaskContext from scheduler
  */
 static void
-attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+attempt_connect_task (void *cls,
+                      const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct RemoteOverlayConnectCtx *rocc = cls;
 
@@ -1700,11 +1719,14 @@
  * @param cls the closure passed to GST_cache_get_handle_transport()
  * @param ch the handle to CORE. Can be NULL if it is not requested
  * @param th the handle to TRANSPORT. Can be NULL if it is not requested
+ * @param ac the handle to ATS. Can be NULL if it is not requested
  * @param ignore_ peer identity which is ignored in this callback
  */
 static void
-rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch,
+rocc_cache_get_handle_transport_cb (void *cls,
+                                    struct GNUNET_CORE_Handle *ch,
                                     struct GNUNET_TRANSPORT_Handle *th,
+                                    struct GNUNET_ATS_ConnectivityHandle *ac,
                                     const struct GNUNET_PeerIdentity *ignore_)
 {
   struct RemoteOverlayConnectCtx *rocc = cls;
@@ -1718,7 +1740,8 @@
   rocc->tcc.th_ = th;
   rocc->tcc.pid = &rocc->a_id;
   if (GNUNET_YES ==
-      GNUNET_TRANSPORT_check_peer_connected (rocc->tcc.th_, rocc->tcc.pid))
+      GNUNET_TRANSPORT_check_peer_connected (rocc->tcc.th_,
+                                             rocc->tcc.pid))
   {
     LOG_DEBUG ("0x%llx: Target peer %4s already connected to local peer: %u\n",
                rocc->op_id,




reply via email to

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