From f390dabd6cf746840484d4f19846a083b49d23da Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 11 May 2019 13:40:05 +0200 Subject: [PATCH] remove duplicate API --- src/include/Makefile.am | 1 - src/include/gnunet_protocols.h | 7 - .../gnunet_transport_address_service.h | 119 --------- src/transport/Makefile.am | 10 - src/transport/gnunet-service-tng.c | 64 ----- src/transport/transport_api2_address.c | 235 ------------------ 6 files changed, 436 deletions(-) delete mode 100644 src/include/gnunet_transport_address_service.h delete mode 100644 src/transport/transport_api2_address.c diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 6ae011c92..3525a0607 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -125,7 +125,6 @@ gnunetinclude_HEADERS = \ gnunet_testing_lib.h \ gnunet_time_lib.h \ gnunet_transport_service.h \ - gnunet_transport_address_service.h \ gnunet_transport_application_service.h \ gnunet_transport_communication_service.h \ gnunet_transport_core_service.h \ diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 7a089ad65..73da40038 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -3141,13 +3141,6 @@ extern "C" { */ #define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING 1220 -/** - * We learned a possible network address of another peer. Transport - * should consider verifying it, and if successful, remembering it - * in the Peerstore. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY 1221 - /** * Message sent to indicate to the transport that a monitor diff --git a/src/include/gnunet_transport_address_service.h b/src/include/gnunet_transport_address_service.h deleted file mode 100644 index b33a11411..000000000 --- a/src/include/gnunet_transport_address_service.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2009-2018 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - 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 - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - - SPDX-License-Identifier: AGPL3.0-or-later -*/ - -/** - * @author Christian Grothoff - * - * @deprecated NOTE: we may want to drop this API and - * only keep the gnunet_transport_application_service.h in the future! - * - * @file - * Provide addresses to transport for validation - * - * @defgroup transport TRANSPORT service - * Low-level communication with other peers - * - * @see [Documentation](https://gnunet.org/transport-service) - * - * @{ - */ - -#ifndef GNUNET_TRANSPORT_ADDRESS_SERVICE_H -#define GNUNET_TRANSPORT_ADDRESS_SERVICE_H - -#ifdef __cplusplus -extern "C" { -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - -#include "gnunet_util_lib.h" -#include "gnunet_nt_lib.h" - -/** - * Version number of the transport address API. - */ -#define GNUNET_TRANSPORT_ADDRESS_VERSION 0x00000000 - - -/** - * Opaque handle to the transport service for communicators. - */ -struct GNUNET_TRANSPORT_AddressHandle; - - -/** - * Connect to the transport service. - * - * @param cfg configuration to use - * @return NULL on error - */ -struct GNUNET_TRANSPORT_AddressHandle * -GNUNET_TRANSPORT_address_connect ( - const struct GNUNET_CONFIGURATION_Handle *cfg); - - -/** - * Disconnect from the transport service. - * - * @param ch handle returned from connect - */ -void -GNUNET_TRANSPORT_address_disconnect (struct GNUNET_TRANSPORT_AddressHandle *ch); - - -/** - * The client has learned about a possible address for peer @a pid - * (i.e. via broadcast, multicast, DHT, ...). The transport service - * should consider validating it. Note that the plugin is NOT expected - * to have verified the signature, the transport service must decide - * whether to check the signature. - * - * While the notification is sent to @a ch asynchronously, this API - * does not return a handle as the delivery of addresses is simply - * unreliable, and if @a ch is down, the data provided will simply be - * lost. - * - * @param ch communicator handle - * @param pid peer the address is for - * @param raw raw address data - * @param raw_size number of bytes in @a raw - */ -void -GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch, - const struct GNUNET_PeerIdentity *pid, - const void *raw, - const size_t raw_size); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -/* ifndef GNUNET_TRANSPORT_ADDRESS_SERVICE_H */ -#endif - -/** @} */ /* end of group */ - -/* end of gnunet_transport_address_service.h */ diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 051c4ebc7..fa85e775c 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -154,7 +154,6 @@ endif lib_LTLIBRARIES = \ libgnunettransport.la \ - libgnunettransportaddress.la \ libgnunettransportapplication.la \ libgnunettransportcore.la \ libgnunettransportcommunicator.la \ @@ -216,15 +215,6 @@ libgnunettransportapplication_la_LDFLAGS = \ -version-info 0:0:0 -libgnunettransportaddress_la_SOURCES = \ - transport_api2_address.c -libgnunettransportaddress_la_LIBADD = \ - $(top_builddir)/src/util/libgnunetutil.la \ - $(GN_LIBINTL) -libgnunettransportaddress_la_LDFLAGS = \ - $(GN_LIB_LDFLAGS) $(WINFLAGS) \ - -version-info 0:0:0 - libgnunettransportcore_la_SOURCES = \ transport_api2_core.c libgnunettransportcore_la_LIBADD = \ diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index b8c5ea9f8..2141bc8e1 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c @@ -24,7 +24,6 @@ * * TODO: * Implement next: - * - remove duplicate HELLO vs. URI API code * - add (more) logging (beyond line ~7500) * - properly encrypt *all* DV traffic, not only backchannel; * rename BackchannelEncapsulation logic to DVEncapsulation! @@ -8701,25 +8700,6 @@ handle_suggest_cancel (void *cls, const struct ExpressPreferenceMessage *msg) } -/** - * Check #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY - * messages. We do nothing here, real verification is done later. - * - * @param cls a `struct TransportClient *` - * @param msg message to verify - * @return #GNUNET_OK - */ -static int -check_address_consider_verify ( - void *cls, - const struct GNUNET_TRANSPORT_AddressToVerify *hdr) -{ - (void) cls; - (void) hdr; - return GNUNET_OK; -} - - /** * Closure for #check_known_address. */ @@ -8906,46 +8886,6 @@ handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg) } -/** - * Given another peers address, consider checking it for validity - * and then adding it to the Peerstore. - * - * @param cls a `struct TransportClient` - * @param hdr message containing the raw address data and - * signature in the body, see #GNUNET_HELLO_extract_address() - */ -static void -handle_address_consider_verify ( - void *cls, - const struct GNUNET_TRANSPORT_AddressToVerify *hdr) -{ - struct TransportClient *tc = cls; - char *address; - enum GNUNET_NetworkType nt; - struct GNUNET_TIME_Absolute mono_time; - - (void) cls; - // OPTIMIZE-FIXME: checking that we know this address already should - // be done BEFORE checking the signature => HELLO API change! - // OPTIMIZE-FIXME: pre-check: rate-limit signature verification / - // validation?! - address = - GNUNET_HELLO_extract_address (&hdr[1], - ntohs (hdr->header.size) - sizeof (*hdr), - &hdr->peer, - &nt, - &mono_time); - if (NULL == address) - { - GNUNET_break_op (0); - return; - } - start_address_validation (&hdr->peer, address); - GNUNET_free (address); - GNUNET_SERVICE_client_continue (tc->client); -} - - /** * Check #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION * messages. @@ -9326,10 +9266,6 @@ GNUNET_SERVICE_MAIN ( GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, struct GNUNET_TRANSPORT_AddQueueMessage, NULL), - GNUNET_MQ_hd_var_size (address_consider_verify, - GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY, - struct GNUNET_TRANSPORT_AddressToVerify, - NULL), GNUNET_MQ_hd_fixed_size (del_queue_message, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, struct GNUNET_TRANSPORT_DelQueueMessage, diff --git a/src/transport/transport_api2_address.c b/src/transport/transport_api2_address.c deleted file mode 100644 index d2cab27d5..000000000 --- a/src/transport/transport_api2_address.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2009-2013, 2016, 2018, 2019 GNUnet e.V. - - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - 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 - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - - SPDX-License-Identifier: AGPL3.0-or-later -*/ - -/** - * @file transport/transport_api2_address.c - * @brief library to inform the transport service about addresses to be validated - * @author Christian Grothoff - */ -#include "platform.h" -#include "gnunet_util_lib.h" -#include "gnunet_constants.h" -#include "gnunet_protocols.h" -#include "gnunet_transport_address_service.h" -#include "gnunet_ats_transport_service.h" -#include "transport.h" - -#define LOG(kind, ...) \ - GNUNET_log_from (kind, "transport-api-address", __VA_ARGS__) - - -/** - * Handle for the transport service (includes all of the - * state for the transport service). - */ -struct GNUNET_TRANSPORT_AddressHandle -{ - - /** - * My client connection to the transport service. - */ - struct GNUNET_MQ_Handle *mq; - - /** - * My configuration. - */ - const struct GNUNET_CONFIGURATION_Handle *cfg; - - /** - * ID of the task trying to reconnect to the service. - */ - struct GNUNET_SCHEDULER_Task *reconnect_task; - - /** - * Delay until we try to reconnect. - */ - struct GNUNET_TIME_Relative reconnect_delay; -}; - - -/** - * Function that will schedule the job that will try - * to connect us again to the client. - * - * @param h transport service to reconnect - */ -static void -disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_AddressHandle *h); - - -/** - * Generic error handler, called with the appropriate - * error code and the same closure specified at the creation of - * the message queue. - * Not every message queue implementation supports an error handler. - * - * @param cls closure with the `struct GNUNET_TRANSPORT_AddressHandle *` - * @param error error code - */ -static void -mq_error_handler (void *cls, enum GNUNET_MQ_Error error) -{ - struct GNUNET_TRANSPORT_AddressHandle *h = cls; - - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Error receiving from transport service, disconnecting temporarily.\n"); - disconnect_and_schedule_reconnect (h); -} - - -/** - * Try again to connect to transport service. - * - * @param cls the handle to the transport service - */ -static void -reconnect (void *cls) -{ - struct GNUNET_TRANSPORT_AddressHandle *h = cls; - struct GNUNET_MQ_MessageHandler handlers[] = {GNUNET_MQ_handler_end ()}; - - h->reconnect_task = NULL; - LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n"); - GNUNET_assert (NULL == h->mq); - h->mq = - GNUNET_CLIENT_connect (h->cfg, "transport", handlers, &mq_error_handler, h); -} - - -/** - * Disconnect from the transport service. - * - * @param h transport service to disconnect - */ -static void -disconnect (struct GNUNET_TRANSPORT_AddressHandle *h) -{ - if (NULL != h->mq) - { - GNUNET_MQ_destroy (h->mq); - h->mq = NULL; - } -} - - -/** - * Function that will schedule the job that will try - * to connect us again to the client. - * - * @param h transport service to reconnect - */ -static void -disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_AddressHandle *h) -{ - GNUNET_assert (NULL == h->reconnect_task); - disconnect (h); - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Scheduling task to reconnect to transport service in %s.\n", - GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES)); - h->reconnect_task = - GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); - h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); -} - - -/** - * Connect to the transport service. - * - * @param cfg configuration to use - * @return NULL on error - */ -struct GNUNET_TRANSPORT_AddressHandle * -GNUNET_TRANSPORT_address_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) -{ - struct GNUNET_TRANSPORT_AddressHandle *h; - - h = GNUNET_new (struct GNUNET_TRANSPORT_AddressHandle); - h->cfg = cfg; - h->reconnect_delay = GNUNET_TIME_UNIT_ZERO; - LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service\n"); - reconnect (h); - if (NULL == h->mq) - { - GNUNET_free (h); - return NULL; - } - return h; -} - - -/** - * Disconnect from the transport service. - * - * @param handle handle to the service as returned from #GNUNET_TRANSPORT_address_connect() - */ -void -GNUNET_TRANSPORT_address_disconnect ( - struct GNUNET_TRANSPORT_AddressHandle *handle) -{ - LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n"); - /* this disconnects all neighbours... */ - disconnect (handle); - /* and now we stop trying to connect again... */ - if (NULL != handle->reconnect_task) - { - GNUNET_SCHEDULER_cancel (handle->reconnect_task); - handle->reconnect_task = NULL; - } - GNUNET_free (handle); -} - - -/** - * The client has learned about a possible address for peer @a pid - * (i.e. via broadcast, multicast, DHT, ...). The transport service - * should consider validating it. Note that the plugin is NOT expected - * to have verified the signature, the transport service must decide - * whether to check the signature. - * - * While the notification is sent to @a ch asynchronously, this API - * does not return a handle as the delivery of addresses is simply - * unreliable, and if @a ch is down, the data provided will simply be - * lost. - * - * @param ch communicator handle - * @param pid peer the address is for - * @param raw raw address data - * @param raw_size number of bytes in @a raw - */ -void -GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch, - const struct GNUNET_PeerIdentity *pid, - const void *raw, - const size_t raw_size) -{ - struct GNUNET_MQ_Envelope *env; - struct GNUNET_TRANSPORT_AddressToVerify *hdr; - - env = - GNUNET_MQ_msg_extra (hdr, - raw_size, - GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY); - hdr->peer = *pid; - memcpy (&hdr[1], raw, raw_size); - GNUNET_MQ_send (ch->mq, env); -} - - -/* end of transport_api2_address.c */ -- 2.25.1