From: Christian Grothoff Date: Mon, 18 Jan 2010 09:00:05 +0000 (+0000) Subject: making peer_configure API cancellable X-Git-Tag: initial-import-from-subversion-38251~22954 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=53840e9a81994acd8dc4c0cb1c54a0d4764667c3;p=oweals%2Fgnunet.git making peer_configure API cancellable --- diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 4c600c4fe..3dccb2dbd 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -14,7 +14,8 @@ lib_LTLIBRARIES = \ libgnunetcore.la libgnunetcore_la_SOURCES = \ - core_api.c core.h + core_api.c core.h \ + core_api_peer_get_info.c libgnunetcore_la_LIBADD = \ $(top_builddir)/src/arm/libgnunetarm.la \ $(top_builddir)/src/util/libgnunetutil.la \ diff --git a/src/core/core.h b/src/core/core.h index 19a090ea0..efa7bf1c9 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -45,11 +45,10 @@ #define GNUNET_CORE_OPTION_NOTHING 0 #define GNUNET_CORE_OPTION_SEND_CONNECT 1 #define GNUNET_CORE_OPTION_SEND_DISCONNECT 2 -#define GNUNET_CORE_OPTION_SEND_BFC 4 -#define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 8 -#define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 16 -#define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32 -#define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 64 +#define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 4 +#define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 8 +#define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 16 +#define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 32 /** @@ -159,7 +158,7 @@ struct NotifyTrafficMessage * Message sent to the core asking for configuration * information and possibly preference changes. */ -struct RequestConfigureMessage +struct RequestInfoMessage { /** * Header with type GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE @@ -200,7 +199,7 @@ struct RequestConfigureMessage /** - * Response from the core to a "RequestConfigureMessage" + * Response from the core to a "RequestInfoMessage" * providing traffic status information for a peer. */ struct ConfigurationInfoMessage @@ -239,32 +238,7 @@ struct ConfigurationInfoMessage * Current traffic preference for the peer. * 0 if we have been disconnected. */ - double preference; - - /** - * Identity of the receiver or sender. - */ - struct GNUNET_PeerIdentity peer; - -}; - - -/** - * Core asking a client to generate traffic for a particular - * target. - */ -struct SolicitTrafficMessage -{ - /** - * Header with type GNUNET_MESSAGE_TYPE_CORE_SOLICIT_TRAFFIC - * or GNUNET_MESSAGE_TYPE_CORE_RECV_OK - */ - struct GNUNET_MessageHeader header; - - /** - * Number of bytes of traffic being solicited. - */ - uint32_t solicit_size GNUNET_PACKED; + uint64_t preference; /** * Identity of the receiver or sender. diff --git a/src/core/core_api.c b/src/core/core_api.c index 58ac3cc0e..21ce09aec 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -65,12 +65,6 @@ struct GNUNET_CORE_Handle */ GNUNET_CORE_ClientEventHandler disconnects; - /** - * Function to call whenever we're asked to generate traffic - * (data provided to be transmitted back to the service). - */ - GNUNET_CORE_BufferFillCallback bfc; - /** * Function to call whenever we receive an inbound message. */ @@ -364,86 +358,6 @@ trigger_next_request (struct GNUNET_CORE_Handle *h) } -/** - * cls is a pointer to a 32 bit number followed by that - * amount of data. If possible, copy to buf and return - * number of bytes copied. Always free the buffer. - */ -static size_t -copy_and_free (void *cls, size_t size, void *buf) -{ - struct GNUNET_CORE_Handle *h = cls; - char *cbuf = h->solicit_buffer; - uint32_t have; - - h->solicit_transmit_req = NULL; - h->solicit_buffer = NULL; - memcpy (&have, cbuf, sizeof (uint32_t)); - if (have > size) - { - /* timeout / error case */ - GNUNET_free (cbuf); - return 0; - } - memcpy (buf, cbuf + sizeof (uint32_t), have); - GNUNET_free (cbuf); - return have; -} - - -/** - * Call bfc callback to solicit traffic for the given peer. - * - * @param h our handle to the core service - * @param peer peer for which traffic is solicited - * @param amount number of bytes that are being solicited - */ -static void -solicit_traffic (struct GNUNET_CORE_Handle *h, - const struct GNUNET_PeerIdentity *peer, uint32_t amount) -{ - char buf[amount]; - size_t have; - char *cbuf; - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Core solicited %u bytes of traffic for `%s'!\n", - amount, - GNUNET_i2s (peer)); - if (NULL != h->solicit_transmit_req) - { - /* more than one solicitation pending */ - GNUNET_break (0); - return; - } - have = h->bfc (h->cls, peer, buf, amount); - if (have == 0) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Can not help with traffic solicitation for `%s'!\n", - GNUNET_i2s (peer)); - return; - } - GNUNET_assert (have >= sizeof (struct GNUNET_MessageHeader)); - cbuf = GNUNET_malloc (have + sizeof (uint32_t)); - memcpy (cbuf, &have, sizeof (uint32_t)); - memcpy (cbuf + sizeof (uint32_t), buf, have); - h->solicit_buffer = cbuf; - h->solicit_transmit_req - = GNUNET_CORE_notify_transmit_ready (h, - 0, - GNUNET_TIME_UNIT_SECONDS, - peer, have, ©_and_free, h); - if (h->solicit_transmit_req == NULL) - { - /* this should not happen */ - GNUNET_break (0); - GNUNET_free (cbuf); - h->solicit_buffer = NULL; - } -} - - /** * Handler for most messages received from the core. * @@ -458,11 +372,9 @@ main_handler (void *cls, const struct GNUNET_MessageHeader *msg) const struct ConnectNotifyMessage *cnm; const struct NotifyTrafficMessage *ntm; const struct ConfigurationInfoMessage *cim; - const struct SolicitTrafficMessage *stm; const struct GNUNET_MessageHeader *em; uint16_t msize; uint16_t et; - uint32_t ss; const struct GNUNET_CORE_MessageHandler *mh; if (msg == NULL) @@ -601,27 +513,6 @@ main_handler (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_CORE_notify_transmit_ready_cancel (h->submitted); // HUH? trigger_next_request (h); break; - case GNUNET_MESSAGE_TYPE_CORE_SOLICIT_TRAFFIC: - if (msize != sizeof (struct SolicitTrafficMessage)) - { - GNUNET_break (0); - break; - } - stm = (const struct SolicitTrafficMessage *) msg; - if (NULL == h->bfc) - { - GNUNET_break (0); - break; - } - ss = ntohl (stm->solicit_size); - if ((ss > GNUNET_SERVER_MAX_MESSAGE_SIZE) || - (ss + sizeof (struct SendMessage) > GNUNET_SERVER_MAX_MESSAGE_SIZE)) - { - GNUNET_break (0); - break; - } - solicit_traffic (h, &stm->peer, ss); - break; default: GNUNET_break (0); break; @@ -766,8 +657,6 @@ transmit_start (void *cls, size_t size, void *buf) opt |= GNUNET_CORE_OPTION_SEND_CONNECT; if (h->disconnects != NULL) opt |= GNUNET_CORE_OPTION_SEND_DISCONNECT; - if (h->bfc != NULL) - opt |= GNUNET_CORE_OPTION_SEND_BFC; if (h->inbound_notify != NULL) { if (h->inbound_hdr_only) @@ -807,7 +696,6 @@ transmit_start (void *cls, size_t size, void *buf) * connected to the core service; note that timeout is only meaningful if init is not NULL * @param connects function to call on peer connect, can be NULL * @param disconnects function to call on peer disconnect / timeout, can be NULL - * @param bfc function to call to fill up spare bandwidth, can be NULL * @param inbound_notify function to call for all inbound messages, can be NULL * @param inbound_hdr_only set to GNUNET_YES if inbound_notify will only read the * GNUNET_MessageHeader and hence we do not need to give it the full message; @@ -828,7 +716,6 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ClientEventHandler connects, GNUNET_CORE_ClientEventHandler disconnects, - GNUNET_CORE_BufferFillCallback bfc, GNUNET_CORE_MessageCallback inbound_notify, int inbound_hdr_only, GNUNET_CORE_MessageCallback outbound_notify, @@ -844,7 +731,6 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, h->init = init; h->connects = connects; h->disconnects = disconnects; - h->bfc = bfc; h->inbound_notify = inbound_notify; h->outbound_notify = outbound_notify; h->inbound_hdr_only = inbound_hdr_only; @@ -898,108 +784,6 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle) } -/** - * Build the configure message. - */ -static size_t -produce_configure_message (void *cls, size_t size, void *buf) -{ - struct GNUNET_CORE_TransmitHandle *th = cls; - struct GNUNET_CORE_Handle *ch = th->ch; - - if (buf == NULL) - { - /* communicate handle timeout/error! */ - if (th->info != NULL) - th->info (th->info_cls, NULL, 0, 0, GNUNET_TIME_UNIT_ZERO, 0, 0.0); - if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) - GNUNET_CORE_notify_transmit_ready_cancel (th); - if (ch->submitted == th) - ch->submitted = NULL; - trigger_next_request (ch); - return 0; - } - GNUNET_assert (size >= sizeof (struct RequestConfigureMessage)); - memcpy (buf, &th[1], sizeof (struct RequestConfigureMessage)); - if (th->prev == NULL) - ch->pending_head = th->next; - else - th->prev->next = th->next; - if (th->next == NULL) - ch->pending_tail = th->prev; - else - th->next->prev = th->prev; - return sizeof (struct RequestConfigureMessage); -} - - -/** - * Obtain statistics and/or change preferences for the given peer. - * - * @param handle connection to core to use - * @param peer identifies the peer - * @param timeout after how long should we give up (and call "info" with NULL - * for "peer" to signal an error)? - * @param bpm_out set to the current bandwidth limit (sending) for this peer, - * caller should set "bpm_out" to "-1" to avoid changing - * the current value; otherwise "bpm_out" will be lowered to - * the specified value; passing a pointer to "0" can be used to force - * us to disconnect from the peer; "bpm_out" might not increase - * as specified since the upper bound is generally - * determined by the other peer! - * @param amount reserve N bytes for receiving, negative - * amounts can be used to undo a (recent) reservation; - * @param preference increase incoming traffic share preference by this amount; - * in the absence of "amount" reservations, we use this - * preference value to assign proportional bandwidth shares - * to all connected peers - * @param info function to call with the resulting configuration information - * @param info_cls closure for info - */ -void -GNUNET_CORE_peer_configure (struct GNUNET_CORE_Handle *handle, - const struct GNUNET_PeerIdentity *peer, - struct GNUNET_TIME_Relative timeout, - unsigned int bpm_out, - int amount, - unsigned long long preference, - GNUNET_CORE_PeerConfigurationInfoCallback info, - void *info_cls) -{ - struct RequestConfigureMessage *rcm; - struct GNUNET_CORE_TransmitHandle *th; - - th = GNUNET_malloc (sizeof (struct GNUNET_CORE_TransmitHandle) + - sizeof (struct RequestConfigureMessage)); - /* append to list */ - th->prev = handle->pending_tail; - if (handle->pending_tail == NULL) - handle->pending_head = th; - else - handle->pending_tail->next = th; - th->ch = handle; - th->get_message = &produce_configure_message; - th->get_message_cls = th; - th->info = info; - th->info_cls = info_cls; - th->timeout = GNUNET_TIME_relative_to_absolute (timeout); - th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, - timeout, - &timeout_request, th); - th->msize = sizeof (struct RequestConfigureMessage); - rcm = (struct RequestConfigureMessage *) &th[1]; - rcm->header.size = htons (sizeof (struct RequestConfigureMessage)); - rcm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE); - rcm->reserved = htonl (0); - rcm->limit_outbound_bpm = htonl (bpm_out); - rcm->reserve_inbound = htonl (amount); - rcm->preference_change = GNUNET_htonll(preference); - rcm->peer = *peer; - if (handle->pending_head == th) - trigger_next_request (handle); -} - - /** * Build the message requesting data transmission. */ diff --git a/src/core/core_api_peer_get_info.c b/src/core/core_api_peer_get_info.c new file mode 100644 index 000000000..aa6aff040 --- /dev/null +++ b/src/core/core_api_peer_get_info.c @@ -0,0 +1,177 @@ +/* + This file is part of GNUnet. + (C) 2009, 2010 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 2, 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_peer_get_info.c + * @brief implementation of the peer_get_info functions + * @author Christian Grothoff + */ +#include "platform.h" +#include "gnunet_core_service.h" +#include "core.h" + + +struct GNUNET_CORE_InformationRequestContext +{ + + /** + * Our connection to the service. + */ + struct GNUNET_CLIENT_Connection *client; + + /** + * Function to call with the information. + */ + GNUNET_CORE_PeerConfigurationInfoCallback info; + + /** + * Closure for info. + */ + void *info_cls; + +}; + + +/** + * Receive reply from core service with information about a peer. + * + * @param cls our 'struct GNUNET_CORE_InformationRequestContext *' + * @param msg NULL on error (i.e. timeout) + */ +static void +receive_info (void *cls, + const struct GNUNET_MessageHeader *msg) +{ + struct GNUNET_CORE_InformationRequestContext *irc = cls; + const struct ConfigurationInfoMessage *cim; + + if (msg == NULL) + { + if (irc != NULL) + irc->info (irc->info_cls, + NULL, 0, 0, GNUNET_TIME_UNIT_FOREVER_REL, 0, 0); + GNUNET_CLIENT_disconnect (irc->client); + GNUNET_free (irc); + return; + } + if ( (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO) || + (ntohs (msg->size) != sizeof (struct ConfigurationInfoMessage)) ) + { + GNUNET_break (0); + if (irc != NULL) + irc->info (irc->info_cls, + NULL, 0, 0, GNUNET_TIME_UNIT_FOREVER_REL, 0, 0); + GNUNET_CLIENT_disconnect (irc->client); + GNUNET_free (irc); + return; + } + cim = (const struct ConfigurationInfoMessage*) msg; + if (irc != NULL) + irc->info (irc->info_cls, + &cim->peer, + ntohl (cim->bpm_in), + ntohl (cim->bpm_out), + GNUNET_TIME_relative_ntoh (cim->latency), + ntohl (cim->reserved_amount), + GNUNET_ntohll (cim->preference)); + GNUNET_CLIENT_disconnect (irc->client); + GNUNET_free (irc); +} + + +/** + * Obtain statistics and/or change preferences for the given peer. + * + * @param sched scheduler to use + * @param cfg configuration to use + * @param peer identifies the peer + * @param timeout after how long should we give up (and call "info" with NULL + * for "peer" to signal an error)? + * @param bpm_out set to the current bandwidth limit (sending) for this peer, + * caller should set "bpm_out" to "-1" to avoid changing + * the current value; otherwise "bpm_out" will be lowered to + * the specified value; passing a pointer to "0" can be used to force + * us to disconnect from the peer; "bpm_out" might not increase + * as specified since the upper bound is generally + * determined by the other peer! + * @param amount reserve N bytes for receiving, negative + * amounts can be used to undo a (recent) reservation; + * @param preference increase incoming traffic share preference by this amount; + * in the absence of "amount" reservations, we use this + * preference value to assign proportional bandwidth shares + * to all connected peers + * @param info function to call with the resulting configuration information + * @param info_cls closure for info + * @return NULL on error + */ +struct GNUNET_CORE_InformationRequestContext * +GNUNET_CORE_peer_get_info (struct GNUNET_SCHEDULER_Handle *sched, + const struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_TIME_Relative timeout, + uint32_t bpm_out, + int32_t amount, + uint64_t preference, + GNUNET_CORE_PeerConfigurationInfoCallback info, + void *info_cls) +{ + struct GNUNET_CORE_InformationRequestContext *irc; + struct RequestInfoMessage rim; + struct GNUNET_CLIENT_Connection *client; + int retry; + + client = GNUNET_CLIENT_connect (sched, "core", cfg); + if (client == NULL) + return NULL; + irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext)); + irc->client = client; + irc->info = info; + irc->info_cls = info_cls; + rim.header.size = htons (sizeof (struct RequestInfoMessage)); + rim.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO); + rim.reserved = htonl (0); + rim.limit_outbound_bpm = htonl (bpm_out); + rim.reserve_inbound = htonl (amount); + rim.preference_change = GNUNET_htonll(preference); + rim.peer = *peer; + retry = ( (amount == 0) && (preference == 0) ) ? GNUNET_YES : GNUNET_NO; + GNUNET_assert (GNUNET_OK == GNUNET_CLIENT_transmit_and_get_response (client, + &rim.header, + timeout, + retry, + &receive_info, + irc)); + return irc; +} + + +/** + * Cancel request for getting information about a peer. + * + * @param irc context returned by the original GNUNET_CORE_peer_get_info call + */ +void +GNUNET_CORE_peer_get_info_cancel (struct GNUNET_CORE_InformationRequestContext *irc) +{ + GNUNET_CLIENT_disconnect (irc->client); + GNUNET_free (irc); +} + +/* end of core_api_peer_get_info.c */ diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 56ea6d30d..d1375dc45 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -1051,14 +1051,14 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) /** - * Handle REQUEST_CONFIGURE request. + * Handle REQUEST_INFO request. */ static void -handle_client_request_configure (void *cls, +handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { - const struct RequestConfigureMessage *rcm; + const struct RequestInfoMessage *rcm; struct Neighbour *n; struct ConfigurationInfoMessage cim; struct Client *c; @@ -1067,9 +1067,9 @@ handle_client_request_configure (void *cls, #if DEBUG_CORE_CLIENT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Core service receives `%s' request.\n", "CONFIGURE"); + "Core service receives `%s' request.\n", "REQUEST_INFO"); #endif - rcm = (const struct RequestConfigureMessage *) message; + rcm = (const struct RequestInfoMessage *) message; n = find_neighbour (&rcm->peer); memset (&cim, 0, sizeof (cim)); if ((n != NULL) && (n->status == PEER_STATE_KEY_CONFIRMED)) @@ -1991,9 +1991,9 @@ handle_client_send (void *cls, static struct GNUNET_SERVER_MessageHandler handlers[] = { {&handle_client_init, NULL, GNUNET_MESSAGE_TYPE_CORE_INIT, 0}, - {&handle_client_request_configure, NULL, - GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE, - sizeof (struct RequestConfigureMessage)}, + {&handle_client_request_info, NULL, + GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO, + sizeof (struct RequestInfoMessage)}, {&handle_client_send, NULL, GNUNET_MESSAGE_TYPE_CORE_SEND, 0}, {NULL, NULL, 0, 0} diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index ed68dcc4a..7a8c0ad33 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -416,6 +416,11 @@ struct PendingRequest */ struct GNUNET_CONTAINER_BloomFilter *bf; + /** + * Context of our GNUNET_CORE_peer_get_info call. + */ + struct GNUNET_CORE_InformationRequestContext *irc; + /** * Replies that we have received but were unable to forward yet * (typically non-null only if we have a pending transmission @@ -1787,6 +1792,7 @@ target_reservation_cb (void *cls, uint16_t size; struct GNUNET_TIME_Relative maxdelay; + pr->irc = NULL; GNUNET_assert (peer != NULL); if ( (amount != DBLOCK_SIZE) || (pr->cth != NULL) ) @@ -1865,17 +1871,15 @@ forward_request_task (void *cls, return; } /* (2) reserve reply bandwidth */ - // FIXME: need a way to cancel; this - // async operation is problematic (segv-problematic) - // if "pr" is destroyed while it happens! - GNUNET_CORE_peer_configure (core, - &psc.target, - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - -1, - DBLOCK_SIZE, // FIXME: make dependent on type? - 0, - &target_reservation_cb, - pr); + GNUNET_assert (NULL == pr->irc); + pr->irc = GNUNET_CORE_peer_get_info (sched, cfg, + &psc.target, + GNUNET_CONSTANTS_SERVICE_TIMEOUT, + -1, + DBLOCK_SIZE, // FIXME: make dependent on type? + 0, + &target_reservation_cb, + pr); } @@ -2216,6 +2220,11 @@ destroy_pending_request (struct PendingRequest *pr) pr); // FIXME: not sure how this can work (efficiently) // also, what does the return value mean? + if (pr->irc != NULL) + { + GNUNET_CORE_peer_get_info_cancel (pr->irc); + pr->irc = NULL; + } if (pr->client == NULL) { GNUNET_CONTAINER_heap_remove_node (requests_by_expiration, @@ -2914,10 +2923,10 @@ handle_p2p_get (void *cls, if (preference < QUERY_BANDWIDTH_VALUE) preference = QUERY_BANDWIDTH_VALUE; // FIXME: also reserve bandwidth for reply? - GNUNET_CORE_peer_configure (core, - other, - GNUNET_TIME_UNIT_FOREVER_REL, - 0, 0, preference, NULL, NULL); + (void) GNUNET_CORE_peer_get_info (sched, cfg, + other, + GNUNET_TIME_UNIT_FOREVER_REL, + 0, 0, preference, NULL, NULL); if (0 != (pgc->policy & ROUTING_POLICY_ANSWER)) pgc->drq = queue_ds_request (BASIC_DATASTORE_REQUEST_DELAY, &ds_get_request, @@ -3318,7 +3327,6 @@ run (void *cls, NULL, &peer_connect_handler, &peer_disconnect_handler, - NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, p2p_handlers); diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index 14daa29a6..fd1068839 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c @@ -192,7 +192,6 @@ run (void *cls, NULL, &core_init, ch, dh, - NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, handlers); diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index dbe39d0d7..c520b5b7d 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h @@ -62,25 +62,6 @@ typedef void (*GNUNET_CORE_ClientEventHandler) (void *cls, GNUNET_PeerIdentity * peer); -/** - * Type of a send callback to fill up buffers. - * - * @param receiver the receiver of the message - * @param position is the reference to the - * first unused position in the buffer where GNUnet is building - * the message - * @param padding is the number of bytes left in that buffer. - * @return the number of bytes written to - * that buffer (must be a positive number). - */ -typedef unsigned int - (*GNUNET_CORE_BufferFillCallback) (void *cls, - const struct GNUNET_PeerIdentity * - receiver, - void *position, - size_t padding); - - /** * Functions with this signature are called whenever a message is * received or transmitted. @@ -159,7 +140,6 @@ typedef void * connected to the core service; note that timeout is only meaningful if init is not NULL * @param connects function to call on peer connect, can be NULL * @param disconnects function to call on peer disconnect / timeout, can be NULL - * @param bfc function to call to fill up spare bandwidth, can be NULL * @param inbound_notify function to call for all inbound messages, can be NULL * @param inbound_hdr_only set to GNUNET_YES if inbound_notify will only read the * GNUNET_MessageHeader and hence we do not need to give it the full message; @@ -180,7 +160,6 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ClientEventHandler connects, GNUNET_CORE_ClientEventHandler disconnects, - GNUNET_CORE_BufferFillCallback bfc, GNUNET_CORE_MessageCallback inbound_notify, int inbound_hdr_only, GNUNET_CORE_MessageCallback outbound_notify, @@ -219,10 +198,17 @@ typedef void unsigned long long preference); + +/** + * Context that can be used to cancel a peer information request. + */ +struct GNUNET_CORE_InformationRequestContext; + /** * Obtain statistics and/or change preferences for the given peer. * - * @param handle connection to core to use + * @param sched scheduler to use + * @param cfg configuration to use * @param peer identifies the peer * @param timeout after how long should we give up (and call "info" with NULL * for "peer" to signal an error)? @@ -241,17 +227,27 @@ typedef void * to all connected peers * @param info function to call with the resulting configuration information * @param info_cls closure for info + * @return NULL on error + */ +struct GNUNET_CORE_InformationRequestContext * +GNUNET_CORE_peer_get_info (struct GNUNET_SCHEDULER_Handle *sched, + const struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_TIME_Relative timeout, + uint32_t bpm_out, + int32_t amount, + uint64_t preference, + GNUNET_CORE_PeerConfigurationInfoCallback info, + void *info_cls); + + +/** + * Cancel request for getting information about a peer. + * + * @param irc context returned by the original GNUNET_CORE_peer_get_info call */ -// FIXME: should return handle for cancellation! void -GNUNET_CORE_peer_configure (struct GNUNET_CORE_Handle *handle, - const struct GNUNET_PeerIdentity *peer, - struct GNUNET_TIME_Relative timeout, - unsigned int bpm_out, - int amount, - unsigned long long preference, - GNUNET_CORE_PeerConfigurationInfoCallback info, - void *info_cls); +GNUNET_CORE_peer_get_info_cancel (struct GNUNET_CORE_InformationRequestContext *irc); /** diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 8f966c737..51442958c 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -276,7 +276,7 @@ extern "C" /** * Request from client to "configure" P2P connection. */ -#define GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE 70 +#define GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO 70 /** * Response from server about (possibly updated) P2P @@ -285,16 +285,9 @@ extern "C" #define GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO 71 /** - * Solicitation from server for transmission (may have - * been requested or also be transmitted without - * client's request). + * Request from client with message to transmit. */ -#define GNUNET_MESSAGE_TYPE_CORE_SOLICIT_TRAFFIC 72 - -/** - * Response from client with message to transmit. - */ -#define GNUNET_MESSAGE_TYPE_CORE_SEND 73 +#define GNUNET_MESSAGE_TYPE_CORE_SEND 72 /** diff --git a/src/testing/testing.c b/src/testing/testing.c index 8604e90ed..cc584e74a 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -434,7 +434,7 @@ start_fsm (void *cls, ARM_START_WAIT, d, &testing_init, - NULL, NULL, NULL, + NULL, NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 880f8603c..157e270ab 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -238,14 +238,15 @@ static struct GNUNET_PEERINFO_IteratorContext *pitr_more; static void force_disconnect (const struct GNUNET_PeerIdentity *peer) { - GNUNET_CORE_peer_configure (handle, - peer, - GNUNET_TIME_UNIT_FOREVER_REL, - 0, - 0, - 0, - NULL, - NULL); + // FIXME: do something with return value! + GNUNET_CORE_peer_get_info (sched, cfg, + peer, + GNUNET_TIME_UNIT_FOREVER_REL, + 0, + 0, + 0, + NULL, + NULL); } @@ -1057,6 +1058,7 @@ gather_hello_callback (void *cls, } +// FIXME: this no longer works (no solicitation!) /** * Function to fill send buffer with HELLO. * @@ -1069,7 +1071,7 @@ gather_hello_callback (void *cls, * @return the number of bytes written to * that buffer (must be a positive number). */ -static unsigned int +/* static */ unsigned int hello_advertising (void *cls, const struct GNUNET_PeerIdentity * receiver, @@ -1275,7 +1277,6 @@ run (void *cls, &core_init, &connect_notify, &disconnect_notify, - &hello_advertising, NULL, GNUNET_NO, NULL, GNUNET_NO, handlers);