From 4440df3d5ddffe5038b0354075e85c18fee57f3a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 21 Aug 2013 15:17:23 +0000 Subject: removing deprecated, dead test-connected API --- src/core/Makefile.am | 3 +- src/core/core_api_is_connected.c | 224 -------------------------------- src/core/core_api_iterate_peers.c | 27 +--- src/core/gnunet-service-core_clients.c | 4 - src/core/gnunet-service-core_sessions.c | 31 ----- src/core/gnunet-service-core_sessions.h | 18 --- 6 files changed, 8 insertions(+), 299 deletions(-) delete mode 100644 src/core/core_api_is_connected.c (limited to 'src/core') diff --git a/src/core/Makefile.am b/src/core/Makefile.am index ebe1ae1ce..b34cb5a44 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -22,8 +22,7 @@ lib_LTLIBRARIES = \ libgnunetcore_la_SOURCES = \ core_api.c core.h \ - core_api_iterate_peers.c \ - core_api_is_connected.c + core_api_iterate_peers.c libgnunetcore_la_LIBADD = \ $(top_builddir)/src/util/libgnunetutil.la \ $(GN_LIBINTL) $(XLIB) diff --git a/src/core/core_api_is_connected.c b/src/core/core_api_is_connected.c deleted file mode 100644 index 31edb94b4..000000000 --- a/src/core/core_api_is_connected.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - This file is part of GNUnet. - (C) 2009, 2010, 2012 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 - by the Free Software Foundation; either version 3, 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -/** - * @file core/core_api_is_connected.c - * @brief implementation of the 'GNUNET_CORE_is_peer_connected function - * @author Christian Grothoff - * @author Nathan Evans - * - * TODO: - * - define nice structs for the IPC messages in core.h - * - consider NOT always sending the 'END' message -- it is redundant! - */ -#include "platform.h" -#include "gnunet_core_service.h" -#include "core.h" - - -/** - * Closure for 'transmit_is_connected_request" - */ -struct GNUNET_CORE_ConnectTestHandle -{ - - /** - * Our connection to the service. - */ - struct GNUNET_CLIENT_Connection *client; - - /** - * Handle for transmitting a request. - */ - struct GNUNET_CLIENT_TransmitHandle *th; - - /** - * Function called with the peer. - */ - GNUNET_CORE_ConnectEventHandler peer_cb; - - /** - * Peer to check for. - */ - struct GNUNET_PeerIdentity peer; - - /** - * Closure for peer_cb. - */ - void *cb_cls; - -}; - - -/** - * Receive reply from core service with information about a peer. - * - * @param cls our 'struct GNUNET_CORE_RequestContext *' - * @param msg NULL on error or last entry - */ -static void -receive_connect_info (void *cls, const struct GNUNET_MessageHeader *msg) -{ - struct GNUNET_CORE_ConnectTestHandle *cth = cls; - const struct ConnectNotifyMessage *connect_message; - uint16_t msize; - - if (NULL == msg) - { - /* core died, failure */ - cth->peer_cb (cth->cb_cls, NULL); - GNUNET_CORE_is_peer_connected_cancel (cth); - return; - } - if ((ntohs (msg->type) == GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END) && - (ntohs (msg->size) == sizeof (struct GNUNET_MessageHeader))) - { - /* end of transmissions */ - cth->peer_cb (cth->cb_cls, NULL); - GNUNET_CORE_is_peer_connected_cancel (cth); - return; - } - msize = ntohs (msg->size); - /* Handle incorrect message type or size, disconnect and clean up */ - if ((ntohs (msg->type) != GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT) || - (msize < sizeof (struct ConnectNotifyMessage))) - { - GNUNET_break (0); - cth->peer_cb (cth->cb_cls, NULL); - GNUNET_CORE_is_peer_connected_cancel (cth); - return; - } - connect_message = (const struct ConnectNotifyMessage *) msg; - if (msize != sizeof (struct ConnectNotifyMessage)) - { - GNUNET_break (0); - cth->peer_cb (cth->cb_cls, NULL); - GNUNET_CORE_is_peer_connected_cancel (cth); - return; - } - /* Normal case */ - cth->peer_cb (cth->cb_cls, &connect_message->peer); - GNUNET_CLIENT_receive (cth->client, &receive_connect_info, - cth, GNUNET_TIME_UNIT_FOREVER_REL); -} - - -/** - * Function called to notify a client about the socket - * begin ready to queue more data. "buf" will be - * NULL and "size" zero if the socket was closed for - * writing in the meantime. - * - * @param cls closure - * @param size number of bytes available in buf - * @param buf where the callee should write the message - * @return number of bytes written to buf - */ -static size_t -transmit_is_connected_request (void *cls, size_t size, void *buf) -{ - struct GNUNET_CORE_ConnectTestHandle *cth = cls; - struct GNUNET_MessageHeader *msg; - unsigned int msize; - - cth->th = NULL; - msize = - sizeof (struct GNUNET_MessageHeader) + - sizeof (struct GNUNET_PeerIdentity); - if ( (NULL == buf) || (0 == size) ) - { - cth->peer_cb (cth->cb_cls, NULL); - GNUNET_CLIENT_disconnect (cth->client); - GNUNET_free (cth); - return 0; - } - GNUNET_assert (size >= msize); - msg = (struct GNUNET_MessageHeader *) buf; - msg->size = htons (msize); - msg->type = htons (GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED); - memcpy (&msg[1], &cth->peer, sizeof (struct GNUNET_PeerIdentity)); - GNUNET_CLIENT_receive (cth->client, &receive_connect_info, cth, - GNUNET_TIME_UNIT_FOREVER_REL); - return msize; -} - - -/** - * Iterate over all currently connected peers. - * Calls peer_cb with each connected peer, and then - * once with NULL to indicate that all peers have - * been handled. - * - * @param cfg configuration to use - * @param peer the specific peer to check for - * @param peer_cb function to call with the peer information - * @param cb_cls closure for peer_cb - * - * @return GNUNET_OK if iterating, GNUNET_SYSERR on error - */ -struct GNUNET_CORE_ConnectTestHandle * -GNUNET_CORE_is_peer_connected (const struct GNUNET_CONFIGURATION_Handle *cfg, - const struct GNUNET_PeerIdentity *peer, - GNUNET_CORE_ConnectEventHandler peer_cb, - void *cb_cls) -{ - struct GNUNET_CORE_ConnectTestHandle *cth; - struct GNUNET_CLIENT_Connection *client; - - GNUNET_assert (NULL != peer); - GNUNET_assert (NULL != peer_cb); - client = GNUNET_CLIENT_connect ("core", cfg); - if (NULL == client) - return NULL; - cth = GNUNET_malloc (sizeof (struct GNUNET_CORE_ConnectTestHandle)); - cth->peer = *peer; - cth->client = client; - cth->peer_cb = peer_cb; - cth->cb_cls = cb_cls; - cth->th = - GNUNET_CLIENT_notify_transmit_ready (client, - sizeof (struct GNUNET_MessageHeader) + - sizeof (struct GNUNET_PeerIdentity), - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_YES, &transmit_is_connected_request, cth); - GNUNET_assert (NULL != cth->th); - return cth; -} - - -/** - * Abort 'is_connected' test operation. - * - * @param cth handle for operation to cancel - */ -void -GNUNET_CORE_is_peer_connected_cancel (struct GNUNET_CORE_ConnectTestHandle *cth) -{ - if (NULL != cth->th) - { - GNUNET_CLIENT_notify_transmit_ready_cancel (cth->th); - cth->th = NULL; - } - GNUNET_CLIENT_disconnect (cth->client); - GNUNET_free (cth); -} - - -/* end of core_api_is_connected.c */ diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c index cc3db6476..4889e638a 100644 --- a/src/core/core_api_iterate_peers.c +++ b/src/core/core_api_iterate_peers.c @@ -37,6 +37,7 @@ struct GNUNET_CORE_RequestContext struct GNUNET_CLIENT_Connection *client; /** + * Handle for transmitting a request. */ struct GNUNET_CLIENT_TransmitHandle *th; @@ -120,7 +121,7 @@ receive_info (void *cls, const struct GNUNET_MessageHeader *msg) * NULL and "size" zero if the socket was closed for * writing in the meantime. * - * @param cls closure + * @param cls closure, always NULL * @param size number of bytes available in buf * @param buf where the callee should write the message * @return number of bytes written to buf @@ -129,32 +130,19 @@ static size_t transmit_request (void *cls, size_t size, void *buf) { struct GNUNET_MessageHeader *msg; - struct GNUNET_PeerIdentity *peer = cls; int msize; - if (peer == NULL) - msize = sizeof (struct GNUNET_MessageHeader); - else - msize = - sizeof (struct GNUNET_MessageHeader) + - sizeof (struct GNUNET_PeerIdentity); + msize = sizeof (struct GNUNET_MessageHeader); if ((size < msize) || (buf == NULL)) return 0; msg = (struct GNUNET_MessageHeader *) buf; msg->size = htons (msize); - if (peer != NULL) - { - msg->type = htons (GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED); - memcpy (&msg[1], peer, sizeof (struct GNUNET_PeerIdentity)); - } - else - msg->type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS); + msg->type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS); return msize; } - /** * Iterate over all currently connected peers. * Calls peer_cb with each connected peer, and then @@ -163,9 +151,8 @@ transmit_request (void *cls, size_t size, void *buf) * * @param cfg configuration to use * @param peer_cb function to call with the peer information - * @param cb_cls closure for peer_cb - * - * @return GNUNET_OK if iterating, GNUNET_SYSERR on error + * @param cb_cls closure for @a peer_cb + * @return #GNUNET_OK if iterating, #GNUNET_SYSERR on error */ int GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, @@ -178,7 +165,7 @@ GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, client = GNUNET_CLIENT_connect ("core", cfg); if (client == NULL) return GNUNET_SYSERR; - request_context = GNUNET_malloc (sizeof (struct GNUNET_CORE_RequestContext)); + request_context = GNUNET_new (struct GNUNET_CORE_RequestContext); request_context->client = client; request_context->peer_cb = peer_cb; request_context->cb_cls = cb_cls; diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c index eed890a8f..7813a97c1 100644 --- a/src/core/gnunet-service-core_clients.c +++ b/src/core/gnunet-service-core_clients.c @@ -829,10 +829,6 @@ GSC_CLIENTS_init (struct GNUNET_SERVER_Handle *server) {&GSC_SESSIONS_handle_client_iterate_peers, NULL, GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS, sizeof (struct GNUNET_MessageHeader)}, - {&GSC_SESSIONS_handle_client_have_peer, NULL, - GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED, - sizeof (struct GNUNET_MessageHeader) + - sizeof (struct GNUNET_PeerIdentity)}, {&handle_client_send_request, NULL, GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST, sizeof (struct SendMessageRequest)}, diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c index 161ce81a8..1deb3efc6 100644 --- a/src/core/gnunet-service-core_sessions.c +++ b/src/core/gnunet-service-core_sessions.c @@ -694,37 +694,6 @@ GSC_SESSIONS_handle_client_iterate_peers (void *cls, } -/** - * Handle CORE_PEER_CONNECTED request. Notify client about connection - * to the given neighbour. For this request type, the client does not - * have to have transmitted an INIT request. All current peers are - * returned, regardless of which message types they accept. - * - * @param cls unused - * @param client client sending the iteration request - * @param message iteration request message - */ -void -GSC_SESSIONS_handle_client_have_peer (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader - *message) -{ - struct GNUNET_MessageHeader done_msg; - struct GNUNET_SERVER_TransmitContext *tc; - const struct GNUNET_PeerIdentity *peer; - - peer = (const struct GNUNET_PeerIdentity *) &message[1]; // YUCK! - tc = GNUNET_SERVER_transmit_context_create (client); - GNUNET_CONTAINER_multihashmap_get_multiple (sessions, &peer->hashPubKey, - &queue_connect_message, tc); - done_msg.size = htons (sizeof (struct GNUNET_MessageHeader)); - done_msg.type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END); - GNUNET_SERVER_transmit_context_append_message (tc, &done_msg); - GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); -} - - /** * We've received a typemap message from a peer, update ours. * Notifies clients about the session. diff --git a/src/core/gnunet-service-core_sessions.h b/src/core/gnunet-service-core_sessions.h index e09cf500e..d578e3d72 100644 --- a/src/core/gnunet-service-core_sessions.h +++ b/src/core/gnunet-service-core_sessions.h @@ -156,24 +156,6 @@ GSC_SESSIONS_handle_client_iterate_peers (void *cls, *message); -/** - * Handle CORE_PEER_CONNECTED request. Notify client about connection - * to the given neighbour. For this request type, the client does not - * have to have transmitted an INIT request. All current peers are - * returned, regardless of which message types they accept. - * - * @param cls unused - * @param client client sending the iteration request - * @param message iteration request message - */ -void -GSC_SESSIONS_handle_client_have_peer (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader - *message); - - - /** * Initialize sessions subsystem. */ -- cgit v1.2.3