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 \
#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
/**
* 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
/**
- * Response from the core to a "RequestConfigureMessage"
+ * Response from the core to a "RequestInfoMessage"
* providing traffic status information for a peer.
*/
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.
*/
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.
*/
}
-/**
- * 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.
*
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)
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;
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)
* 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;
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,
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;
}
-/**
- * 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.
*/
--- /dev/null
+/*
+ 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 */
/**
- * 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;
#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))
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}
*/
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
uint16_t size;
struct GNUNET_TIME_Relative maxdelay;
+ pr->irc = NULL;
GNUNET_assert (peer != NULL);
if ( (amount != DBLOCK_SIZE) ||
(pr->cth != NULL) )
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);
}
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,
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,
NULL,
&peer_connect_handler,
&peer_disconnect_handler,
- NULL,
NULL, GNUNET_NO,
NULL, GNUNET_NO,
p2p_handlers);
NULL,
&core_init,
ch, dh,
- NULL,
NULL, GNUNET_NO,
NULL, GNUNET_NO,
handlers);
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.
* 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;
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,
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)?
* 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);
/**
/**
* 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
#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
/**
ARM_START_WAIT,
d,
&testing_init,
- NULL, NULL, NULL,
+ NULL, NULL,
NULL, GNUNET_NO,
NULL, GNUNET_NO,
no_handlers);
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);
}
}
+// FIXME: this no longer works (no solicitation!)
/**
* Function to fill send buffer with HELLO.
*
* @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,
&core_init,
&connect_notify,
&disconnect_notify,
- &hello_advertising,
NULL, GNUNET_NO,
NULL, GNUNET_NO,
handlers);