gnunet-service-core_clients.c gnunet-service-core_clients.h \
gnunet-service-core_neighbours.c gnunet-service-core_neighbours.h \
gnunet-service-core_kx.c gnunet-service-core_kx.h \
- gnunet-service-core_sessions.c gnunet-service-core_sessions.h
+ gnunet-service-core_sessions.c gnunet-service-core_sessions.h \
+ gnunet-service-core_typemap.c gnunet-service-core_typemap.h
gnunet_service_core_new_LDADD = \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
disconnect_and_free_peer_entry (void *cls, const GNUNET_HashCode * key,
void *value)
{
- static struct GNUNET_BANDWIDTH_Value32NBO zero;
struct GNUNET_CORE_Handle *h = cls;
struct GNUNET_CORE_TransmitHandle *th;
struct PeerRecord *pr = value;
GNUNET_break (0);
pcic_cls = pr->pcic_cls;
GNUNET_CORE_peer_change_preference_cancel (pr->pcic_ptr);
- pcic (pcic_cls, &pr->peer, zero, 0, GNUNET_TIME_UNIT_FOREVER_REL, 0);
+ pcic (pcic_cls, &pr->peer, 0, GNUNET_TIME_UNIT_FOREVER_REL);
}
while (NULL != (th = pr->pending_head))
{
GNUNET_free_non_null (pr->pcic_ptr);
pr->pcic_ptr = NULL;
if (pcic != NULL)
- pcic (pr->pcic_cls, &pr->peer, cim->bw_out, ntohl (cim->reserved_amount),
- GNUNET_TIME_relative_ntoh (cim->reserve_delay),
- GNUNET_ntohll (cim->preference));
+ pcic (pr->pcic_cls, &pr->peer, ntohl (cim->reserved_amount),
+ GNUNET_TIME_relative_ntoh (cim->reserve_delay));
break;
default:
reconnect_later (h);
*
* @param h core handle
* @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 bw_out set to the current bandwidth limit (sending) for this peer,
- * caller should set "bw_out" to "-1" to avoid changing
- * the current value; otherwise "bw_out" will be lowered to
- * the specified value; passing a pointer to "0" can be used to force
- * us to disconnect from the peer; "bw_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;
struct GNUNET_CORE_InformationRequestContext *
GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h,
const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_TIME_Relative timeout,
- struct GNUNET_BANDWIDTH_Value32NBO bw_out,
int32_t amount, uint64_t preference,
GNUNET_CORE_PeerConfigurationInfoCallback
info, void *info_cls)
rim->header.size = htons (sizeof (struct RequestInfoMessage));
rim->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO);
rim->rim_id = htonl (pr->rim_id = h->rim_id_gen++);
- rim->limit_outbound = bw_out;
+ rim->limit_outbound = GNUNET_BANDWIDTH_VALUE_MAX; // FIXME: remove entirely soon...
rim->reserve_inbound = htonl (amount);
rim->preference_change = GNUNET_htonll (preference);
rim->peer = *peer;
GSC_SESSIONS_handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
-#if 0
- // FIXME!
const struct RequestInfoMessage *rcm;
- struct GSC_Client *pos;
- struct Neighbour *n;
+ struct Session *session;
struct ConfigurationInfoMessage cim;
int32_t want_reserv;
int32_t got_reserv;
- unsigned long long old_preference;
struct GNUNET_TIME_Relative rdelay;
rdelay = GNUNET_TIME_UNIT_ZERO;
#if DEBUG_CORE_CLIENT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service receives `%s' request.\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Core service receives `%s' request.\n",
"REQUEST_INFO");
#endif
rcm = (const struct RequestInfoMessage *) message;
- n = find_neighbour (&rcm->peer);
- memset (&cim, 0, sizeof (cim));
- if ((n != NULL) && (GNUNET_YES == n->is_connected))
- {
- want_reserv = ntohl (rcm->reserve_inbound);
- if (n->bw_out_internal_limit.value__ != rcm->limit_outbound.value__)
- {
- n->bw_out_internal_limit = rcm->limit_outbound;
- if (n->bw_out.value__ !=
- GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit,
- n->bw_out_external_limit).value__)
- {
- n->bw_out =
- GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit,
- n->bw_out_external_limit);
- GNUNET_BANDWIDTH_tracker_update_quota (&n->available_recv_window,
- n->bw_out);
- GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out);
- handle_peer_status_change (n);
- }
- }
- if (want_reserv < 0)
- {
- got_reserv = want_reserv;
- }
- else if (want_reserv > 0)
- {
- rdelay =
- GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window,
- want_reserv);
- if (rdelay.rel_value == 0)
- got_reserv = want_reserv;
- else
- got_reserv = 0; /* all or nothing */
- }
- else
- got_reserv = 0;
- GNUNET_BANDWIDTH_tracker_consume (&n->available_recv_window, got_reserv);
- old_preference = n->current_preference;
- n->current_preference += GNUNET_ntohll (rcm->preference_change);
- if (old_preference > n->current_preference)
- {
- /* overflow; cap at maximum value */
- n->current_preference = ULLONG_MAX;
- }
- update_preference_sum (n->current_preference - old_preference);
-#if DEBUG_CORE_QUOTA
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received reservation request for %d bytes for peer `%4s', reserved %d bytes, suggesting delay of %llu ms\n",
- (int) want_reserv, GNUNET_i2s (&rcm->peer), (int) got_reserv,
- (unsigned long long) rdelay.rel_value);
-#endif
- cim.reserved_amount = htonl (got_reserv);
- cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay);
- cim.bw_out = n->bw_out;
- cim.preference = n->current_preference;
- }
- else
+ session = find_session (&rcm->peer);
+ if (NULL == session)
{
/* Technically, this COULD happen (due to asynchronous behavior),
* but it should be rare, so we should generate an info event
* to help diagnosis of serious errors that might be masked by this */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _
- ("Client asked for preference change with peer `%s', which is not connected!\n"),
+ _("Client asked for preference change with peer `%s', which is not connected!\n"),
GNUNET_i2s (&rcm->peer));
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
+
+ want_reserv = ntohl (rcm->reserve_inbound);
+ if (session->bw_out_internal_limit.value__ != rcm->limit_outbound.value__)
+ {
+ session->bw_out_internal_limit = rcm->limit_outbound;
+ if (session->bw_out.value__ !=
+ GNUNET_BANDWIDTH_value_min (session->bw_out_internal_limit,
+ session->bw_out_external_limit).value__)
+ {
+ session->bw_out =
+ GNUNET_BANDWIDTH_value_min (session->bw_out_internal_limit,
+ session->bw_out_external_limit);
+ GNUNET_BANDWIDTH_tracker_update_quota (&session->available_recv_window,
+ session->bw_out);
+#if 0
+ // FIXME: who does this?
+ GNUNET_TRANSPORT_set_quota (transport, &session->peer,
+ session->bw_in,
+ session->bw_out);
+#endif
+ }
+ }
+ if (want_reserv < 0)
+ {
+ got_reserv = want_reserv;
+ }
+ else if (want_reserv > 0)
+ {
+ rdelay =
+ GNUNET_BANDWIDTH_tracker_get_delay (&session->available_recv_window,
+ want_reserv);
+ if (rdelay.rel_value == 0)
+ got_reserv = want_reserv;
+ else
+ got_reserv = 0; /* all or nothing */
+ }
+ else
+ got_reserv = 0;
+ GNUNET_BANDWIDTH_tracker_consume (&session->available_recv_window, got_reserv);
+#if DEBUG_CORE_QUOTA
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received reservation request for %d bytes for peer `%4s', reserved %d bytes, suggesting delay of %llu ms\n",
+ (int) want_reserv, GNUNET_i2s (&rcm->peer), (int) got_reserv,
+ (unsigned long long) rdelay.rel_value);
+#endif
cim.header.size = htons (sizeof (struct ConfigurationInfoMessage));
cim.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO);
- cim.peer = rcm->peer;
+ cim.reserved_amount = htonl (got_reserv);
+ cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay);
cim.rim_id = rcm->rim_id;
-#if DEBUG_CORE_CLIENT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
- "CONFIGURATION_INFO");
-#endif
+ cim.bw_out = session->bw_out;
+ cim.preference = 0; /* FIXME: remove */
+ cim.peer = rcm->peer;
GSC_CLIENTS_send_to_client (client, &cim.header, GNUNET_NO);
-#endif
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
static void
preference_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, int32_t amount,
- struct GNUNET_TIME_Relative res_delay, uint64_t preference);
+ int32_t amount,
+ struct GNUNET_TIME_Relative res_delay);
static void
do_reserve (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
"Requesting reservatin of 32k from core in 1s!\n");
irc =
GNUNET_CORE_peer_change_preference (p1.ch, &p2.id,
- GNUNET_TIME_UNIT_SECONDS,
- GNUNET_BANDWIDTH_VALUE_MAX,
1000000 /* bandwidth for 1s */ ,
0, &preference_cb, pc);
}
static void
preference_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, int32_t amount,
- struct GNUNET_TIME_Relative res_delay, uint64_t preference)
+ int32_t amount,
+ struct GNUNET_TIME_Relative res_delay)
{
struct PeerContext *pc = cls;
*
* @param cls closure
* @param peer identifies the peer
- * @param bpm_out set to the current bandwidth limit (sending) for this peer
* @param amount set to the amount that was actually reserved or unreserved;
* either the full requested amount or zero (no partial reservations)
* @param res_delay if the reservation could not be satisfied (amount was 0), how
* long should the client wait until re-trying?
- * @param preference current traffic preference for the given peer
*/
static void
update_core_preference_finish (void *cls,
const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_BANDWIDTH_Value32NBO bpm_out,
int32_t amount,
- struct GNUNET_TIME_Relative res_delay,
- uint64_t preference)
+ struct GNUNET_TIME_Relative res_delay)
{
struct PeerInfo *peer_info = cls;
GNUNET_NO);
peer->info_ctx =
GNUNET_CORE_peer_change_preference (coreAPI, &peer->id,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_BANDWIDTH_VALUE_MAX, 0,
+ 0,
preference,
&update_core_preference_finish, peer);
}
peer_transmit_ready_cb (void *cls, size_t size, void *buf);
-
-
/**
* Function called by core upon success or failure of our bandwidth reservation request.
*
* @param cls the 'struct GSF_ConnectedPeer' of the peer for which we made the request
* @param peer identifies the peer
- * @param bandwidth_out available amount of outbound bandwidth
* @param amount set to the amount that was actually reserved or unreserved;
* either the full requested amount or zero (no partial reservations)
* @param res_delay if the reservation could not be satisfied (amount was 0), how
* long should the client wait until re-trying?
- * @param preference current traffic preference for the given peer
*/
static void
core_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- int32_t amount, struct GNUNET_TIME_Relative res_delay,
- uint64_t preference);
+ int32_t amount, struct GNUNET_TIME_Relative res_delay);
/**
cp->inc_preference = 0;
cp->irc =
GNUNET_CORE_peer_change_preference (GSF_core, &target,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_BANDWIDTH_VALUE_MAX,
DBLOCK_SIZE, ip,
&core_reserve_callback, cp);
}
cp->inc_preference = 0;
cp->irc =
GNUNET_CORE_peer_change_preference (GSF_core, &target,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_BANDWIDTH_VALUE_MAX,
DBLOCK_SIZE, ip,
&core_reserve_callback, cp);
}
*
* @param cls the 'struct GSF_ConnectedPeer' of the peer for which we made the request
* @param peer identifies the peer
- * @param bandwidth_out available amount of outbound bandwidth
* @param amount set to the amount that was actually reserved or unreserved;
* either the full requested amount or zero (no partial reservations)
* @param res_delay if the reservation could not be satisfied (amount was 0), how
* long should the client wait until re-trying?
- * @param preference current traffic preference for the given peer
*/
static void
core_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- int32_t amount, struct GNUNET_TIME_Relative res_delay,
- uint64_t preference)
+ int32_t amount, struct GNUNET_TIME_Relative res_delay)
{
struct GSF_ConnectedPeer *cp = cls;
struct GSF_PeerTransmitHandle *pth;
cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO);
cp->irc =
GNUNET_CORE_peer_change_preference (GSF_core, peer,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_BANDWIDTH_VALUE_MAX,
DBLOCK_SIZE, 0,
&core_reserve_callback, cp);
fn = get_trust_filename (peer);
*
* @param cls closure
* @param peer identifies the peer
- * @param bandwidth_out available amount of outbound bandwidth
* @param amount set to the amount that was actually reserved or unreserved;
* either the full requested amount or zero (no partial reservations)
* @param res_delay if the reservation could not be satisfied (amount was 0), how
* long should the client wait until re-trying?
- * @param preference current traffic preference for the given peer
*/
typedef void (*GNUNET_CORE_PeerConfigurationInfoCallback) (void *cls,
const struct
GNUNET_PeerIdentity *
peer,
- struct
- GNUNET_BANDWIDTH_Value32NBO
- bandwidth_out,
int32_t amount,
struct
GNUNET_TIME_Relative
- res_delay,
- uint64_t preference);
+ res_delay);
*
* @param h core handle
* @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 bw_out set to the current bandwidth limit (sending) for this peer,
- * caller should set "bpm_out" to "GNUNET_BANDWIDTH_VALUE_MAX" to avoid changing
- * the current value; otherwise "bw_out" will be lowered to
- * the specified value; passing a pointer to "0" can be used to force
- * us to disconnect from the peer; "bw_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;
struct GNUNET_CORE_InformationRequestContext *
GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h,
const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_TIME_Relative timeout,
- struct GNUNET_BANDWIDTH_Value32NBO bw_out,
int32_t amount, uint64_t preference,
GNUNET_CORE_PeerConfigurationInfoCallback
info, void *info_cls);