-convert to new transport API
authorChristian Grothoff <christian@grothoff.org>
Fri, 29 Jul 2016 21:55:23 +0000 (21:55 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 29 Jul 2016 21:55:23 +0000 (21:55 +0000)
src/testbed/gnunet-service-testbed_connectionpool.c
src/testbed/gnunet-service-testbed_connectionpool.h
src/testbed/gnunet-service-testbed_oc.c

index 020fcb8d772c89df54a6d3486b2b407b2c6b2737..3115285ea6394f1dcd100f250b75fc2db7dbf227 100644 (file)
@@ -27,6 +27,7 @@
 #include "gnunet-service-testbed.h"
 #include "gnunet-service-testbed_connectionpool.h"
 #include "testbed_api_operations.h"
+#include "gnunet_transport_core_service.h"
 
 /**
  * Redefine LOG with a changed log component string
@@ -71,7 +72,7 @@ struct PooledConnection
   /**
    * The transport handle to the peer corresponding to this entry; can be NULL
    */
-  struct GNUNET_TRANSPORT_Handle *handle_transport;
+  struct GNUNET_TRANSPORT_CoreHandle *handle_transport;
 
   /**
    * The core handle to the peer corresponding to this entry; can be NULL
@@ -525,16 +526,20 @@ peer_connect_notify_cb (void *cls,
  *
  * @param cls the #PooledConnection object
  * @param peer the peer that connected
+ * @param mq queue for sending data to @a peer
+ * @return NULL
  */
-static void
+static void *
 transport_peer_connect_notify_cb (void *cls,
-                                  const struct GNUNET_PeerIdentity *peer)
+                                  const struct GNUNET_PeerIdentity *peer,
+                                 struct GNUNET_MQ_Handle *mq)
 {
   struct PooledConnection *entry = cls;
 
   peer_connect_notify_cb (entry,
                           peer,
                           GST_CONNECTIONPOOL_SERVICE_TRANSPORT);
+  return NULL;
 }
 
 
@@ -553,12 +558,13 @@ opstart_get_handle_transport (void *cls)
   LOG_DEBUG ("Opening a transport connection to peer %u\n",
              entry->index);
   entry->handle_transport =
-      GNUNET_TRANSPORT_connect (entry->cfg,
-                                NULL,
-                                entry,
-                                NULL,
-                                &transport_peer_connect_notify_cb,
-                                NULL);
+      GNUNET_TRANSPORT_core_connect (entry->cfg,
+                                    NULL,
+                                    NULL,
+                                    entry,
+                                    &transport_peer_connect_notify_cb,
+                                    NULL,
+                                    NULL);
   if (NULL == entry->handle_transport)
   {
     GNUNET_break (0);
@@ -589,7 +595,7 @@ oprelease_get_handle_transport (void *cls)
 
   if (NULL == entry->handle_transport)
     return;
-  GNUNET_TRANSPORT_disconnect (entry->handle_transport);
+  GNUNET_TRANSPORT_core_disconnect (entry->handle_transport);
   entry->handle_transport = NULL;
 }
 
@@ -601,7 +607,8 @@ oprelease_get_handle_transport (void *cls)
  * @param peer peer identity this notification is about
  */
 static void
-core_peer_connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
+core_peer_connect_cb (void *cls,
+                     const struct GNUNET_PeerIdentity *peer)
 {
   struct PooledConnection *entry = cls;
 
@@ -634,9 +641,7 @@ core_startup_cb (void *cls,
   }
   GNUNET_assert (NULL == entry->peer_identity);
   entry->peer_identity = GNUNET_new (struct GNUNET_PeerIdentity);
-  GNUNET_memcpy (entry->peer_identity,
-          my_identity,
-          sizeof (struct GNUNET_PeerIdentity));
+  *entry->peer_identity = *my_identity;
   if (0 == entry->demand)
     return;
   if (NULL != entry->notify_task)
index 54b37f6d55cf47d9c16cef65857e62327462d132..dc887ff8ce0f8aea1b3a2d282d24562d9d9bc0bb 100644 (file)
@@ -25,7 +25,7 @@
  */
 #include "gnunet_ats_service.h"
 #include "gnunet_core_service.h"
-#include "gnunet_transport_service.h"
+#include "gnunet_transport_core_service.h"
 
 /**
  * The request handle for obtaining a pooled connection
@@ -90,7 +90,7 @@ GST_connection_pool_destroy (void);
 typedef void
 (*GST_connection_pool_connection_ready_cb) (void *cls,
                                             struct GNUNET_CORE_Handle *ch,
-                                            struct GNUNET_TRANSPORT_Handle *th,
+                                            struct GNUNET_TRANSPORT_CoreHandle *th,
                                             struct GNUNET_ATS_ConnectivityHandle *ac,
                                             const struct GNUNET_PeerIdentity *peer_id,
                                             const struct GNUNET_CONFIGURATION_Handle *cfg);
index cf74ea04e2607954d3e69712c39c9047ceab7a2c..02c369aaa2631148a4d3227706cd7a3a9a15f282 100644 (file)
@@ -46,7 +46,7 @@ struct ConnectivitySuggestContext
   /**
    * The transport handle obtained from cache. Do NOT close/disconnect.
    */
-  struct GNUNET_TRANSPORT_Handle *th_;
+  struct GNUNET_TRANSPORT_CoreHandle *th_;
 
   /**
    * Configuration of the peer from cache. Do not free!
@@ -178,7 +178,7 @@ struct OverlayConnectContext
    * Transport handle of the first peer obtained from cache to get its HELLO. Do
    * NOT close/disconnect.
    */
-  struct GNUNET_TRANSPORT_Handle *p1th_;
+  struct GNUNET_TRANSPORT_CoreHandle *p1th_;
 
   /**
    * The #GST_ConnectionPool_GetHandle for the peer1's transport handle
@@ -709,7 +709,7 @@ overlay_connect_notify (void *cls,
 static void
 occ_cache_get_handle_ats_occ_cb (void *cls,
                                  struct GNUNET_CORE_Handle *ch,
-                                 struct GNUNET_TRANSPORT_Handle *th,
+                                 struct GNUNET_TRANSPORT_CoreHandle *th,
                                  struct GNUNET_ATS_ConnectivityHandle *ac,
                                  const struct GNUNET_PeerIdentity *my_identity,
                                  const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -759,7 +759,7 @@ occ_cache_get_handle_ats_occ_cb (void *cls,
 static void
 occ_cache_get_handle_ats_rocc_cb (void *cls,
                                   struct GNUNET_CORE_Handle *ch,
-                                  struct GNUNET_TRANSPORT_Handle *th,
+                                  struct GNUNET_TRANSPORT_CoreHandle *th,
                                   struct GNUNET_ATS_ConnectivityHandle *ac,
                                   const struct GNUNET_PeerIdentity *my_identity,
                                   const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -921,7 +921,7 @@ send_hello (void *cls)
 static void
 p2_transport_connect_cache_callback (void *cls,
                                      struct GNUNET_CORE_Handle *ch,
-                                     struct GNUNET_TRANSPORT_Handle *th,
+                                     struct GNUNET_TRANSPORT_CoreHandle *th,
                                      struct GNUNET_ATS_ConnectivityHandle *ac,
                                      const struct GNUNET_PeerIdentity *ignore_,
                                      const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -1063,7 +1063,7 @@ hello_update_cb (void *cls,
 static void
 p1_transport_connect_cache_callback (void *cls,
                                      struct GNUNET_CORE_Handle *ch,
-                                     struct GNUNET_TRANSPORT_Handle *th,
+                                     struct GNUNET_TRANSPORT_CoreHandle *th,
                                      struct GNUNET_ATS_ConnectivityHandle *ac,
                                      const struct GNUNET_PeerIdentity *ignore_,
                                      const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -1108,7 +1108,7 @@ p1_transport_connect_cache_callback (void *cls,
 static void
 occ_cache_get_handle_core_cb (void *cls,
                               struct GNUNET_CORE_Handle *ch,
-                              struct GNUNET_TRANSPORT_Handle *th,
+                              struct GNUNET_TRANSPORT_CoreHandle *th,
                               struct GNUNET_ATS_ConnectivityHandle *ac,
                               const struct GNUNET_PeerIdentity *my_identity,
                               const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -1759,7 +1759,7 @@ attempt_connect_task (void *cls)
 static void
 rocc_cache_get_handle_transport_cb (void *cls,
                                     struct GNUNET_CORE_Handle *ch,
-                                    struct GNUNET_TRANSPORT_Handle *th,
+                                    struct GNUNET_TRANSPORT_CoreHandle *th,
                                     struct GNUNET_ATS_ConnectivityHandle *ac,
                                     const struct GNUNET_PeerIdentity *ignore_,
                                     const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -1774,9 +1774,9 @@ rocc_cache_get_handle_transport_cb (void *cls,
   }
   rocc->tcc.th_ = th;
   rocc->tcc.cfg = cfg;
-  if (GNUNET_YES ==
-      GNUNET_TRANSPORT_check_peer_connected (rocc->tcc.th_,
-                                             &rocc->a_id))
+  if (NULL !=
+      GNUNET_TRANSPORT_core_get_mq (rocc->tcc.th_,
+                                   &rocc->a_id))
   {
     LOG_DEBUG ("0x%llx: Target peer %s already connected to local peer: %u\n",
                rocc->op_id,