aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-22 20:16:14 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-22 20:16:14 +0000
commit3a81c3e236a3679c0c0676d814c71d9ae5f38ec3 (patch)
tree5c1975092f28f3f94fa19902bc7fbd0b773eaf6c /src/transport/transport_api.c
parentf3910e0b479e7a4693d8dc5341e4c8a2769c1aaa (diff)
downloadgnunet-3a81c3e236a3679c0c0676d814c71d9ae5f38ec3.tar.gz
gnunet-3a81c3e236a3679c0c0676d814c71d9ae5f38ec3.zip
eliminating GNUNET_TRANSPORT_set_quota code
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r--src/transport/transport_api.c99
1 files changed, 0 insertions, 99 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index 3d3d426e2..ab2993047 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -972,105 +972,6 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
972 972
973 973
974/** 974/**
975 * Closure for 'send_set_quota'.
976 */
977struct SetQuotaContext
978{
979
980 /**
981 * Identity of the peer impacted by the quota change.
982 */
983 struct GNUNET_PeerIdentity target;
984
985 /**
986 * Quota to transmit.
987 */
988 struct GNUNET_BANDWIDTH_Value32NBO quota_in;
989};
990
991
992/**
993 * Send SET_QUOTA message to the service.
994 *
995 * @param cls the 'struct SetQuotaContext'
996 * @param size number of bytes available in buf
997 * @param buf where to copy the message
998 * @return number of bytes copied to buf
999 */
1000static size_t
1001send_set_quota (void *cls, size_t size, void *buf)
1002{
1003 struct SetQuotaContext *sqc = cls;
1004 struct QuotaSetMessage msg;
1005
1006 if (buf == NULL)
1007 {
1008 GNUNET_free (sqc);
1009 return 0;
1010 }
1011#if DEBUG_TRANSPORT_API
1012 LOG (GNUNET_ERROR_TYPE_DEBUG,
1013 "Transmitting `%s' request with respect to `%4s'.\n", "SET_QUOTA",
1014 GNUNET_i2s (&sqc->target));
1015#endif
1016 GNUNET_assert (size >= sizeof (struct QuotaSetMessage));
1017 msg.header.size = htons (sizeof (struct QuotaSetMessage));
1018 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
1019 msg.quota = sqc->quota_in;
1020 msg.peer = sqc->target;
1021 memcpy (buf, &msg, sizeof (msg));
1022 GNUNET_free (sqc);
1023 return sizeof (struct QuotaSetMessage);
1024}
1025
1026
1027/**
1028 * Set the share of incoming bandwidth for the given
1029 * peer to the specified amount.
1030 *
1031 * @param handle connection to transport service
1032 * @param target who's bandwidth quota is being changed
1033 * @param quota_in incoming bandwidth quota in bytes per ms
1034 * @param quota_out outgoing bandwidth quota in bytes per ms
1035 */
1036void
1037GNUNET_TRANSPORT_set_quota (struct GNUNET_TRANSPORT_Handle *handle,
1038 const struct GNUNET_PeerIdentity *target,
1039 struct GNUNET_BANDWIDTH_Value32NBO quota_in,
1040 struct GNUNET_BANDWIDTH_Value32NBO quota_out)
1041{
1042 struct Neighbour *n;
1043 struct SetQuotaContext *sqc;
1044
1045 n = neighbour_find (handle, target);
1046 if (NULL == n)
1047 {
1048 LOG (GNUNET_ERROR_TYPE_ERROR,
1049 "Quota changed to %u for peer `%s', but I have no such neighbour!\n",
1050 (unsigned int) ntohl (quota_out.value__), GNUNET_i2s (target));
1051 return;
1052 }
1053 GNUNET_assert (NULL != handle->client);
1054#if DEBUG_TRANSPORT_API
1055 if (ntohl (quota_out.value__) != n->out_tracker.available_bytes_per_s__)
1056 LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota changed from %u to %u for peer `%s'\n",
1057 (unsigned int) n->out_tracker.available_bytes_per_s__,
1058 (unsigned int) ntohl (quota_out.value__), GNUNET_i2s (target));
1059 else
1060 LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota remains at %u for peer `%s'\n",
1061 (unsigned int) n->out_tracker.available_bytes_per_s__,
1062 GNUNET_i2s (target));
1063#endif
1064 GNUNET_BANDWIDTH_tracker_update_quota (&n->out_tracker, quota_out);
1065 sqc = GNUNET_malloc (sizeof (struct SetQuotaContext));
1066 sqc->target = *target;
1067 sqc->quota_in = quota_in;
1068 schedule_control_transmit (handle, sizeof (struct QuotaSetMessage),
1069 &send_set_quota, sqc);
1070}
1071
1072
1073/**
1074 * Send REQUEST_CONNECT message to the service. 975 * Send REQUEST_CONNECT message to the service.
1075 * 976 *
1076 * @param cls the 'struct GNUNET_PeerIdentity' 977 * @param cls the 'struct GNUNET_PeerIdentity'