diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-22 20:16:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-22 20:16:14 +0000 |
commit | 3a81c3e236a3679c0c0676d814c71d9ae5f38ec3 (patch) | |
tree | 5c1975092f28f3f94fa19902bc7fbd0b773eaf6c /src | |
parent | f3910e0b479e7a4693d8dc5341e4c8a2769c1aaa (diff) | |
download | gnunet-3a81c3e236a3679c0c0676d814c71d9ae5f38ec3.tar.gz gnunet-3a81c3e236a3679c0c0676d814c71d9ae5f38ec3.zip |
eliminating GNUNET_TRANSPORT_set_quota code
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_transport_service.h | 16 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport.c | 7 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 30 | ||||
-rw-r--r-- | src/transport/transport.h | 2 | ||||
-rw-r--r-- | src/transport/transport_api.c | 99 |
5 files changed, 6 insertions, 148 deletions
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index 40e3fca5b..5f719f859 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h | |||
@@ -170,22 +170,6 @@ GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, | |||
170 | 170 | ||
171 | 171 | ||
172 | /** | 172 | /** |
173 | * Set the share of incoming/outgoing bandwidth for the given | ||
174 | * peer to the specified amount. | ||
175 | * | ||
176 | * @param handle connection to transport service | ||
177 | * @param target who's bandwidth quota is being changed | ||
178 | * @param quota_in incoming bandwidth quota | ||
179 | * @param quota_out outgoing bandwidth quota | ||
180 | */ | ||
181 | void | ||
182 | GNUNET_TRANSPORT_set_quota (struct GNUNET_TRANSPORT_Handle *handle, | ||
183 | const struct GNUNET_PeerIdentity *target, | ||
184 | struct GNUNET_BANDWIDTH_Value32NBO quota_in, | ||
185 | struct GNUNET_BANDWIDTH_Value32NBO quota_out); | ||
186 | |||
187 | |||
188 | /** | ||
189 | * Opaque handle for a transmission-ready request. | 173 | * Opaque handle for a transmission-ready request. |
190 | */ | 174 | */ |
191 | struct GNUNET_TRANSPORT_TransmitHandle; | 175 | struct GNUNET_TRANSPORT_TransmitHandle; |
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 6273816c7..602a597e5 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -404,8 +404,11 @@ ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
404 | /* ATS tells me to disconnect from peer*/ | 404 | /* ATS tells me to disconnect from peer*/ |
405 | if ((bw_in == 0) && (bw_out == 0)) | 405 | if ((bw_in == 0) && (bw_out == 0)) |
406 | { | 406 | { |
407 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ATS tells me to disconnect from peer `%s'\n", | 407 | #if DEBUG_TRANSPORT |
408 | GNUNET_i2s (peer)); | 408 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
409 | "ATS tells me to disconnect from peer `%s'\n", | ||
410 | GNUNET_i2s (peer)); | ||
411 | #endif | ||
409 | GST_neighbours_force_disconnect(peer); | 412 | GST_neighbours_force_disconnect(peer); |
410 | return; | 413 | return; |
411 | } | 414 | } |
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 9252a5c10..6b07136e8 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -600,34 +600,6 @@ clients_handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
600 | 600 | ||
601 | 601 | ||
602 | /** | 602 | /** |
603 | * Client asked for a quota change for a particular peer. Process the request. | ||
604 | * | ||
605 | * @param cls unused | ||
606 | * @param client the client | ||
607 | * @param message the quota changing message | ||
608 | */ | ||
609 | static void | ||
610 | clients_handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client, | ||
611 | const struct GNUNET_MessageHeader *message) | ||
612 | { | ||
613 | const struct QuotaSetMessage *qsm; | ||
614 | |||
615 | qsm = (const struct QuotaSetMessage *) message; | ||
616 | GNUNET_STATISTICS_update (GST_stats, | ||
617 | gettext_noop ("# SET QUOTA messages received"), 1, | ||
618 | GNUNET_NO); | ||
619 | #if DEBUG_TRANSPORT | ||
620 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
621 | "Received `%s' request (new quota %u) from client for peer `%4s'\n", | ||
622 | "SET_QUOTA", (unsigned int) ntohl (qsm->quota.value__), | ||
623 | GNUNET_i2s (&qsm->peer)); | ||
624 | #endif | ||
625 | GST_neighbours_set_incoming_quota (&qsm->peer, qsm->quota); | ||
626 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
627 | } | ||
628 | |||
629 | |||
630 | /** | ||
631 | * Take the given address and append it to the set of results sent back to | 603 | * Take the given address and append it to the set of results sent back to |
632 | * the client. | 604 | * the client. |
633 | * | 605 | * |
@@ -883,8 +855,6 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) | |||
883 | {&clients_handle_request_connect, NULL, | 855 | {&clients_handle_request_connect, NULL, |
884 | GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT, | 856 | GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT, |
885 | sizeof (struct TransportRequestConnectMessage)}, | 857 | sizeof (struct TransportRequestConnectMessage)}, |
886 | {&clients_handle_set_quota, NULL, | ||
887 | GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA, sizeof (struct QuotaSetMessage)}, | ||
888 | {&clients_handle_address_lookup, NULL, | 858 | {&clients_handle_address_lookup, NULL, |
889 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP, 0}, | 859 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP, 0}, |
890 | {&clients_handle_peer_address_lookup, NULL, | 860 | {&clients_handle_peer_address_lookup, NULL, |
diff --git a/src/transport/transport.h b/src/transport/transport.h index 8cc97e08f..f3c4329a9 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -176,7 +176,7 @@ struct QuotaSetMessage | |||
176 | { | 176 | { |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_NEIGHBOUR_INFO | 179 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA |
180 | */ | 180 | */ |
181 | struct GNUNET_MessageHeader header; | 181 | struct GNUNET_MessageHeader header; |
182 | 182 | ||
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 | */ | ||
977 | struct 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 | */ | ||
1000 | static size_t | ||
1001 | send_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 | */ | ||
1036 | void | ||
1037 | GNUNET_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' |