- 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;
- GNUNET_assert (ch->submitted == NULL);
- ch->submitted = th;
- 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,
- GNUNET_NO,
- GNUNET_SCHEDULER_PRIORITY_KEEP,
- GNUNET_SCHEDULER_NO_TASK,
- 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.
- */
-static size_t
-produce_send (void *cls, size_t size, void *buf)
-{
- struct GNUNET_CORE_TransmitHandle *th = cls;
- struct GNUNET_CORE_Handle *h;
- struct SendMessage *sm;
- size_t dt;
- GNUNET_CONNECTION_TransmitReadyNotify notify;
- void *notify_cls;
-
- h = th->ch;
- if (buf == NULL)