From 49d8694f79f2c716fd56f803e64e0b9008179970 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 29 Jul 2016 21:55:23 +0000 Subject: -convert to new transport API --- .../gnunet-service-testbed_connectionpool.c | 33 +++++++++++++--------- .../gnunet-service-testbed_connectionpool.h | 4 +-- src/testbed/gnunet-service-testbed_oc.c | 22 +++++++-------- 3 files changed, 32 insertions(+), 27 deletions(-) (limited to 'src/testbed') diff --git a/src/testbed/gnunet-service-testbed_connectionpool.c b/src/testbed/gnunet-service-testbed_connectionpool.c index 020fcb8d7..3115285ea 100644 --- a/src/testbed/gnunet-service-testbed_connectionpool.c +++ b/src/testbed/gnunet-service-testbed_connectionpool.c @@ -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) diff --git a/src/testbed/gnunet-service-testbed_connectionpool.h b/src/testbed/gnunet-service-testbed_connectionpool.h index 54b37f6d5..dc887ff8c 100644 --- a/src/testbed/gnunet-service-testbed_connectionpool.h +++ b/src/testbed/gnunet-service-testbed_connectionpool.h @@ -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); diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index cf74ea04e..02c369aaa 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c @@ -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, -- cgit v1.2.3