From 8cdbd31820ad0b71bbe3eb431723802bda7883df Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 5 Aug 2011 08:26:53 +0000 Subject: [PATCH] more client code --- .../gnunet-service-transport_clients.c | 17 ++++++ .../gnunet-service-transport_neighbours.c | 58 +++++++++++++++++++ .../gnunet-service-transport_neighbours.h | 9 ++- 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 97939bbf7..5fbd60df8 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -452,6 +452,23 @@ GST_clients_handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { + const struct QuotaSetMessage *qsm; + + qsm = (const struct QuotaSetMessage *) message; + GNUNET_STATISTICS_update (stats, + gettext_noop ("# SET QUOTA messages received"), + 1, + GNUNET_NO); +#if DEBUG_TRANSPORT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received `%s' request (new quota %u) from client for peer `%4s'\n", + "SET_QUOTA", + (unsigned int) ntohl (qsm->quota.value__), + GNUNET_i2s (&qsm->peer)); +#endif + GST_neighbours_set_incoming_quota (&qsm->peer, + qsm->quota); + GNUNET_SERVER_receive_done (client, GNUNET_OK); } diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 4107c0012..89a622d95 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -83,6 +83,64 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target) } +/** + * Transmit a message to the given target using the active connection. + * + * @param target destination + * @param msg message to send + * @param cont function to call when done + * @param cont_cls closure for 'cont' + */ +void +GST_neighbours_send (const struct GNUNET_PeerIdentity *target, + const struct GNUNET_MessageHeader *msg, + GST_NeighbourSendContinuation cont, + void *cont_cls) +{ +} + + +/** + * Change the incoming quota for the given peer. + * + * @param neighbour identity of peer to change qutoa for + * @param quota new quota + */ +void +GST_neighbours_set_quota (const struct GNUNET_PeerIdentity *neighbour, + struct GNUNET_BANDWIDTH_Value32NBO quota) +{ +#if 0 + + n = find_neighbour (neighbour); + if (n == NULL) + { + GNUNET_STATISTICS_update (stats, + gettext_noop ("# SET QUOTA messages ignored (no such peer)"), + 1, + GNUNET_NO); + return; + } + GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker, + quota); + if (0 != ntohl (qsm->quota.value__)) + return; +#if DEBUG_TRANSPORT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Disconnecting peer `%4s' due to `%s'\n", + GNUNET_i2s(&n->id), + "SET_QUOTA"); +#endif + GNUNET_STATISTICS_update (stats, + gettext_noop ("# disconnects due to quota of 0"), + 1, + GNUNET_NO); + GST_neighbours_force_disconnect (neighbour); + +#endif +} + + /** * If we have an active connection to the given target, it must be shutdown. * diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index 27e7d20a9..26b3a11b8 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h @@ -99,15 +99,14 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, void *cont_cls); /** - * Change the quota for the given peer. - * FIXME: inbound or outbound quota? + * Change the incoming quota for the given peer. * * @param neighbour identity of peer to change qutoa for - * @param quota new quota FIXME: fix type! + * @param quota new quota */ void -GST_neighbours_set_quota (const struct GNUNET_PeerIdentity *neighbour, - const float quota); +GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour, + struct GNUNET_BANDWIDTH_Value32NBO quota); /** -- 2.25.1