From 75e1efb22d791bd28be6acbc19dbcdfbd737c173 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 18 Oct 2015 21:02:16 +0000 Subject: [PATCH] -remove deprecated try_disconnect API --- src/include/gnunet_protocols.h | 6 - src/include/gnunet_transport_service.h | 46 ----- .../gnunet-service-transport_clients.c | 39 ----- src/transport/transport_api.c | 158 ------------------ 4 files changed, 249 deletions(-) diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index a47af7f59..9ac749637 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -1364,12 +1364,6 @@ extern "C" */ #define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC 390 -/** - * Message for transport service from a client asking that a - * connection with another peer be torn down. - */ -#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_DISCONNECT 391 - /******************************************************************************* * FS-PUBLISH-HELPER IPC Messages diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index 5acc2807c..c2f5798ad 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h @@ -209,52 +209,6 @@ void GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch); -/** - * Opaque handle for a transmission-ready request. - */ -struct GNUNET_TRANSPORT_TryDisconnectHandle; - -/** - * Function to call with result of the try connect request. - * - * @param cls closure - * @param result #GNUNET_OK if message was transmitted to transport service - * #GNUNET_SYSERR if message was not transmitted to transport service - */ -typedef void -(*GNUNET_TRANSPORT_TryDisconnectCallback) (void *cls, - int result); - - -/** - * Ask the transport service to disconnect from the given peer. - * - * @param handle connection to transport service - * @param target who we should try to disconnect from - * @param cb callback to be called when request was transmitted to transport - * service - * @param cb_cls closure for the callback @a cb - * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or - * NULL on failure (@a cb will not be called) - * @deprecated use blacklisting API instead! - */ -struct GNUNET_TRANSPORT_TryDisconnectHandle * -GNUNET_TRANSPORT_try_disconnect (struct GNUNET_TRANSPORT_Handle *handle, - const struct GNUNET_PeerIdentity *target, - GNUNET_TRANSPORT_TryDisconnectCallback cb, - void *cb_cls); - - -/** - * Cancel the request to transport to disconnect. - * Callback will not be called anymore. - * - * @param tdh handle for operation to cancel - */ -void -GNUNET_TRANSPORT_try_disconnect_cancel (struct GNUNET_TRANSPORT_TryDisconnectHandle *tdh); - - /* ************************* Sending *************************** */ /** diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 8c1ca61e5..538dd15ea 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -878,42 +878,6 @@ clients_handle_request_connect (void *cls, } -/** - * Handle request disconnect message - * - * @param cls closure (always NULL) - * @param client identification of the client - * @param message the actual message - */ -static void -clients_handle_request_disconnect (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message) -{ - const struct TransportRequestDisconnectMessage *trdm; - - trdm = (const struct TransportRequestDisconnectMessage *) message; - GNUNET_break (0 == ntohl (trdm->reserved)); - GNUNET_STATISTICS_update (GST_stats, - gettext_noop - ("# REQUEST DISCONNECT messages received"), 1, - GNUNET_NO); - if (0 == memcmp (&trdm->peer, - &GST_my_identity, - sizeof (struct GNUNET_PeerIdentity))) - { - GNUNET_break (0); - GNUNET_SERVER_receive_done (client, GNUNET_OK); - return; - } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received a request disconnect message for peer `%s'\n", - GNUNET_i2s (&trdm->peer)); - (void) GST_neighbours_force_disconnect (&trdm->peer); - GNUNET_SERVER_receive_done (client, GNUNET_OK); -} - - /** * Take the given address and append it to the set of results sent back to * the client. This function may be called serveral times for a single @@ -1551,9 +1515,6 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) {&clients_handle_request_connect, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT, sizeof (struct TransportRequestConnectMessage)}, - {&clients_handle_request_disconnect, NULL, - GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_DISCONNECT, - sizeof (struct TransportRequestDisconnectMessage)}, {&clients_handle_address_to_string, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0}, {&clients_handle_monitor_peers, NULL, diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 502968553..e84ef9898 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -245,49 +245,6 @@ struct GNUNET_TRANSPORT_TryConnectHandle }; -/** - * Entry in linked list for all try-disconnect requests - */ -struct GNUNET_TRANSPORT_TryDisconnectHandle -{ - /** - * For the DLL. - */ - struct GNUNET_TRANSPORT_TryDisconnectHandle *prev; - - /** - * For the DLL. - */ - struct GNUNET_TRANSPORT_TryDisconnectHandle *next; - - /** - * Peer we should try to connect to. - */ - struct GNUNET_PeerIdentity pid; - - /** - * Transport service handle this request is part of. - */ - struct GNUNET_TRANSPORT_Handle *th; - - /** - * Message transmission request to communicate to service. - */ - struct GNUNET_TRANSPORT_TransmitHandle *tth; - - /** - * Function to call upon completion (of request transmission). - */ - GNUNET_TRANSPORT_TryDisconnectCallback cb; - - /** - * Closure for @e cb. - */ - void *cb_cls; - -}; - - /** * Entry in linked list for all offer-HELLO requests. */ @@ -408,16 +365,6 @@ struct GNUNET_TRANSPORT_Handle */ struct GNUNET_TRANSPORT_TryConnectHandle *tc_tail; - /** - * Linked list of pending try disconnect requests head - */ - struct GNUNET_TRANSPORT_TryDisconnectHandle *td_head; - - /** - * Linked list of pending try connect requests tail - */ - struct GNUNET_TRANSPORT_TryDisconnectHandle *td_tail; - /** * Linked list of pending offer HELLO requests head */ @@ -1500,111 +1447,6 @@ GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *t } -/** - * Send #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_DISCONNECT message to the - * service. - * - * @param cls the `struct GNUNET_TRANSPORT_TryDisconnectHandle` - * @param size number of bytes available in @a buf - * @param buf where to copy the message - * @return number of bytes copied to @a buf - */ -static size_t -send_try_disconnect (void *cls, - size_t size, - void *buf) -{ - struct GNUNET_TRANSPORT_TryDisconnectHandle *tdh = cls; - struct TransportRequestConnectMessage msg; - - tdh->th = NULL; - if (NULL == buf) - { - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Discarding `%s' request to `%s' due to error in transport service connection.\n", - "REQUEST_DISCONNECT", - GNUNET_i2s (&tdh->pid)); - if (NULL != tdh->cb) - tdh->cb (tdh->cb_cls, - GNUNET_SYSERR); - GNUNET_TRANSPORT_try_disconnect_cancel (tdh); - return 0; - } - LOG (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting `%s' request with respect to `%s'.\n", - "REQUEST_DISCONNECT", - GNUNET_i2s (&tdh->pid)); - GNUNET_assert (size >= sizeof (struct TransportRequestDisconnectMessage)); - msg.header.size = htons (sizeof (struct TransportRequestDisconnectMessage)); - msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_DISCONNECT); - msg.reserved = htonl (0); - msg.peer = tdh->pid; - memcpy (buf, &msg, sizeof (msg)); - if (NULL != tdh->cb) - tdh->cb (tdh->cb_cls, GNUNET_OK); - GNUNET_TRANSPORT_try_disconnect_cancel (tdh); - return sizeof (struct TransportRequestDisconnectMessage); -} - - -/** - * Ask the transport service to shutdown a connection to - * the given peer. - * - * @param handle connection to transport service - * @param target who we should try to connect to - * @param cb callback to be called when request was transmitted to transport - * service - * @param cb_cls closure for the callback @a cb - * @return a `struct GNUNET_TRANSPORT_TryDisconnectHandle` handle or - * NULL on failure (cb will not be called) - */ -struct GNUNET_TRANSPORT_TryDisconnectHandle * -GNUNET_TRANSPORT_try_disconnect (struct GNUNET_TRANSPORT_Handle *handle, - const struct GNUNET_PeerIdentity *target, - GNUNET_TRANSPORT_TryDisconnectCallback cb, - void *cb_cls) -{ - struct GNUNET_TRANSPORT_TryDisconnectHandle *tdh; - - if (NULL == handle->client) - return NULL; - tdh = GNUNET_new (struct GNUNET_TRANSPORT_TryDisconnectHandle); - tdh->th = handle; - tdh->pid = *target; - tdh->cb = cb; - tdh->cb_cls = cb_cls; - tdh->tth = schedule_control_transmit (handle, - sizeof (struct TransportRequestDisconnectMessage), - &send_try_disconnect, tdh); - GNUNET_CONTAINER_DLL_insert (handle->td_head, - handle->td_tail, - tdh); - return tdh; -} - - -/** - * Cancel the request to transport to try a disconnect - * Callback will not be called - * - * @param tdh the handle to cancel - */ -void -GNUNET_TRANSPORT_try_disconnect_cancel (struct GNUNET_TRANSPORT_TryDisconnectHandle *tdh) -{ - struct GNUNET_TRANSPORT_Handle *th; - - th = tdh->th; - if (NULL != tdh->tth) - cancel_control_transmit (th, tdh->tth); - GNUNET_CONTAINER_DLL_remove (th->td_head, - th->td_tail, - tdh); - GNUNET_free (tdh); -} - - /** * Send HELLO message to the service. * -- 2.25.1