diff options
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/ats.h | 54 | ||||
-rw-r--r-- | src/ats/ats_api_connectivity.c | 6 | ||||
-rw-r--r-- | src/ats/ats_api_scheduling.c | 94 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats.c | 6 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 167 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.h | 31 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_scheduling.c | 53 | ||||
-rw-r--r-- | src/ats/plugin_ats_mlp.c | 20 | ||||
-rw-r--r-- | src/ats/plugin_ats_proportional.c | 301 | ||||
-rw-r--r-- | src/ats/plugin_ats_ril.c | 40 |
10 files changed, 185 insertions, 587 deletions
diff --git a/src/ats/ats.h b/src/ats/ats.h index 482b7b4b3..69788971e 100644 --- a/src/ats/ats.h +++ b/src/ats/ats.h | |||
@@ -105,29 +105,6 @@ struct RequestAddressMessage | |||
105 | 105 | ||
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Scheduling client to ATS service: reset backoff for | ||
109 | * address suggestions to this peer. | ||
110 | */ | ||
111 | struct ResetBackoffMessage | ||
112 | { | ||
113 | /** | ||
114 | * Type is #GNUNET_MESSAGE_TYPE_ATS_RESET_BACKOFF. | ||
115 | */ | ||
116 | struct GNUNET_MessageHeader header; | ||
117 | |||
118 | /** | ||
119 | * Always zero. | ||
120 | */ | ||
121 | uint32_t reserved GNUNET_PACKED; | ||
122 | |||
123 | /** | ||
124 | * Peer to reset backoff for. | ||
125 | */ | ||
126 | struct GNUNET_PeerIdentity peer; | ||
127 | }; | ||
128 | |||
129 | |||
130 | /** | ||
131 | * ATS client to ATS service: here is another address you can use. | 108 | * ATS client to ATS service: here is another address you can use. |
132 | */ | 109 | */ |
133 | struct AddressAddMessage | 110 | struct AddressAddMessage |
@@ -214,37 +191,6 @@ struct AddressUpdateMessage | |||
214 | 191 | ||
215 | 192 | ||
216 | /** | 193 | /** |
217 | * Message sent from ATS client to ATS service to notify | ||
218 | * it if we started (or stopped) using an address. | ||
219 | */ | ||
220 | struct AddressUseMessage | ||
221 | { | ||
222 | /** | ||
223 | * Type is #GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE. | ||
224 | */ | ||
225 | struct GNUNET_MessageHeader header; | ||
226 | |||
227 | /** | ||
228 | * Internal number this client uses to refer to this address. | ||
229 | */ | ||
230 | uint32_t session_id GNUNET_PACKED; | ||
231 | |||
232 | /** | ||
233 | * Which peer is this about? (Technically redundant, as the | ||
234 | * @e session_id should be sufficient, but enables ATS service | ||
235 | * to find the session faster). | ||
236 | */ | ||
237 | struct GNUNET_PeerIdentity peer; | ||
238 | |||
239 | /** | ||
240 | * #GNUNET_YES or #GNUNET_NO. | ||
241 | */ | ||
242 | uint32_t in_use GNUNET_PACKED; | ||
243 | |||
244 | }; | ||
245 | |||
246 | |||
247 | /** | ||
248 | * Message sent by ATS client to ATS service when an address | 194 | * Message sent by ATS client to ATS service when an address |
249 | * was destroyed and must thus henceforth no longer be considered | 195 | * was destroyed and must thus henceforth no longer be considered |
250 | * for scheduling. | 196 | * for scheduling. |
diff --git a/src/ats/ats_api_connectivity.c b/src/ats/ats_api_connectivity.c index 9198118a4..0871544dc 100644 --- a/src/ats/ats_api_connectivity.c +++ b/src/ats/ats_api_connectivity.c | |||
@@ -303,6 +303,9 @@ GNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch, | |||
303 | { | 303 | { |
304 | struct GNUNET_ATS_ConnectivitySuggestHandle *s; | 304 | struct GNUNET_ATS_ConnectivitySuggestHandle *s; |
305 | 305 | ||
306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
307 | "Requesting ATS to suggest address for `%s'\n", | ||
308 | GNUNET_i2s (peer)); | ||
306 | s = GNUNET_new (struct GNUNET_ATS_ConnectivitySuggestHandle); | 309 | s = GNUNET_new (struct GNUNET_ATS_ConnectivitySuggestHandle); |
307 | s->ch = ch; | 310 | s->ch = ch; |
308 | s->id = *peer; | 311 | s->id = *peer; |
@@ -336,6 +339,9 @@ GNUNET_ATS_connectivity_suggest_cancel (struct GNUNET_ATS_ConnectivitySuggestHan | |||
336 | struct GNUNET_MQ_Envelope *ev; | 339 | struct GNUNET_MQ_Envelope *ev; |
337 | struct RequestAddressMessage *m; | 340 | struct RequestAddressMessage *m; |
338 | 341 | ||
342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
343 | "Telling ATS we no longer care for an address for `%s'\n", | ||
344 | GNUNET_i2s (&sh->id)); | ||
339 | GNUNET_assert (GNUNET_OK == | 345 | GNUNET_assert (GNUNET_OK == |
340 | GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests, | 346 | GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests, |
341 | &sh->id, | 347 | &sh->id, |
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index f81dfe7eb..792215598 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -92,13 +92,6 @@ struct GNUNET_ATS_AddressRecord | |||
92 | uint32_t slot; | 92 | uint32_t slot; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Is this address currently in use? In use means | ||
96 | * that the transport service will use this address | ||
97 | * for sending. | ||
98 | */ | ||
99 | int in_use; | ||
100 | |||
101 | /** | ||
102 | * We're about to destroy this address record, just ATS does | 95 | * We're about to destroy this address record, just ATS does |
103 | * not know this yet. Once ATS confirms its destruction, | 96 | * not know this yet. Once ATS confirms its destruction, |
104 | * we can clean up. | 97 | * we can clean up. |
@@ -418,6 +411,11 @@ process_ats_address_suggestion_message (void *cls, | |||
418 | if ( (0 == ntohl (m->bandwidth_out.value__)) && | 411 | if ( (0 == ntohl (m->bandwidth_out.value__)) && |
419 | (0 == ntohl (m->bandwidth_in.value__)) ) | 412 | (0 == ntohl (m->bandwidth_in.value__)) ) |
420 | { | 413 | { |
414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
415 | "ATS suggests disconnect from peer `%s' with BW %u/%u\n", | ||
416 | GNUNET_i2s (&ar->address->peer), | ||
417 | (unsigned int) ntohl (m->bandwidth_out.value__), | ||
418 | (unsigned int) ntohl (m->bandwidth_in.value__)); | ||
421 | sh->suggest_cb (sh->suggest_cb_cls, | 419 | sh->suggest_cb (sh->suggest_cb_cls, |
422 | &m->peer, | 420 | &m->peer, |
423 | NULL, | 421 | NULL, |
@@ -434,6 +432,11 @@ process_ats_address_suggestion_message (void *cls, | |||
434 | GNUNET_break (0); | 432 | GNUNET_break (0); |
435 | return; | 433 | return; |
436 | } | 434 | } |
435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
436 | "ATS suggests address slot %u for peer `%s' using plugin %s\n", | ||
437 | ar->slot, | ||
438 | GNUNET_i2s (&ar->address->peer), | ||
439 | ar->address->transport_name); | ||
437 | sh->suggest_cb (sh->suggest_cb_cls, | 440 | sh->suggest_cb (sh->suggest_cb_cls, |
438 | &m->peer, | 441 | &m->peer, |
439 | ar->address, | 442 | ar->address, |
@@ -498,7 +501,7 @@ send_add_address_message (struct GNUNET_ATS_SchedulingHandle *sh, | |||
498 | m->session_id = htonl (ar->slot); | 501 | m->session_id = htonl (ar->slot); |
499 | 502 | ||
500 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
501 | "Adding address for peer `%s', plugin `%s', session %p id %u\n", | 504 | "Adding address for peer `%s', plugin `%s', session %p slot %u\n", |
502 | GNUNET_i2s (&ar->address->peer), | 505 | GNUNET_i2s (&ar->address->peer), |
503 | ar->address->transport_name, | 506 | ar->address->transport_name, |
504 | ar->session, | 507 | ar->session, |
@@ -520,29 +523,6 @@ send_add_address_message (struct GNUNET_ATS_SchedulingHandle *sh, | |||
520 | 523 | ||
521 | 524 | ||
522 | /** | 525 | /** |
523 | * Generate and transmit the `struct AddressUseMessage` for the given | ||
524 | * address record. | ||
525 | * | ||
526 | * @param ar the address to inform the ATS service about | ||
527 | * @param in_use say if it is in use or not | ||
528 | */ | ||
529 | static void | ||
530 | send_in_use_message (struct GNUNET_ATS_AddressRecord *ar, | ||
531 | int in_use) | ||
532 | { | ||
533 | struct GNUNET_ATS_SchedulingHandle *sh = ar->sh; | ||
534 | struct GNUNET_MQ_Envelope *ev; | ||
535 | struct AddressUseMessage *m; | ||
536 | |||
537 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE); | ||
538 | m->peer = ar->address->peer; | ||
539 | m->in_use = htonl ((uint32_t) in_use); | ||
540 | m->session_id = htonl (ar->slot); | ||
541 | GNUNET_MQ_send (sh->mq, ev); | ||
542 | } | ||
543 | |||
544 | |||
545 | /** | ||
546 | * Re-establish the connection to the ATS service. | 526 | * Re-establish the connection to the ATS service. |
547 | * | 527 | * |
548 | * @param sh handle to use to re-connect. | 528 | * @param sh handle to use to re-connect. |
@@ -586,8 +566,6 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh) | |||
586 | if (NULL == ar) | 566 | if (NULL == ar) |
587 | continue; | 567 | continue; |
588 | send_add_address_message (sh, ar); | 568 | send_add_address_message (sh, ar); |
589 | if (ar->in_use) | ||
590 | send_in_use_message (ar, GNUNET_YES); | ||
591 | if (NULL == sh->mq) | 569 | if (NULL == sh->mq) |
592 | return; | 570 | return; |
593 | } | 571 | } |
@@ -652,27 +630,6 @@ GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh) | |||
652 | 630 | ||
653 | 631 | ||
654 | /** | 632 | /** |
655 | * We would like to reset the address suggestion block time for this | ||
656 | * peer. | ||
657 | * | ||
658 | * @param sh handle | ||
659 | * @param peer identity of the peer we want to reset | ||
660 | */ | ||
661 | void | ||
662 | GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh, | ||
663 | const struct GNUNET_PeerIdentity *peer) | ||
664 | { | ||
665 | struct GNUNET_MQ_Envelope *ev; | ||
666 | struct ResetBackoffMessage *m; | ||
667 | |||
668 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_RESET_BACKOFF); | ||
669 | m->reserved = htonl (0); | ||
670 | m->peer = *peer; | ||
671 | GNUNET_MQ_send (sh->mq, ev); | ||
672 | } | ||
673 | |||
674 | |||
675 | /** | ||
676 | * Test if a address and a session is known to ATS | 633 | * Test if a address and a session is known to ATS |
677 | * | 634 | * |
678 | * @param sh the scheduling handle | 635 | * @param sh the scheduling handle |
@@ -799,7 +756,6 @@ GNUNET_ATS_address_del_session (struct GNUNET_ATS_AddressRecord *ar, | |||
799 | { | 756 | { |
800 | GNUNET_break (session == ar->session); | 757 | GNUNET_break (session == ar->session); |
801 | ar->session = NULL; | 758 | ar->session = NULL; |
802 | GNUNET_break (GNUNET_NO == ar->in_use); | ||
803 | if (GNUNET_HELLO_address_check_option (ar->address, | 759 | if (GNUNET_HELLO_address_check_option (ar->address, |
804 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | 760 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) |
805 | { | 761 | { |
@@ -834,7 +790,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
834 | size_t msize; | 790 | size_t msize; |
835 | 791 | ||
836 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 792 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
837 | "Adding address for peer `%s', plugin `%s', session %p id %u\n", | 793 | "Updating address for peer `%s', plugin `%s', session %p slot %u\n", |
838 | GNUNET_i2s (&ar->address->peer), | 794 | GNUNET_i2s (&ar->address->peer), |
839 | ar->address->transport_name, | 795 | ar->address->transport_name, |
840 | ar->session, | 796 | ar->session, |
@@ -861,29 +817,6 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
861 | } | 817 | } |
862 | 818 | ||
863 | 819 | ||
864 | /** | ||
865 | * An address is now in use or not used any more. | ||
866 | * | ||
867 | * @param ar the address | ||
868 | * @param in_use #GNUNET_YES if this address is now used, #GNUNET_NO | ||
869 | * if address is not used any more | ||
870 | */ | ||
871 | void | ||
872 | GNUNET_ATS_address_set_in_use (struct GNUNET_ATS_AddressRecord *ar, | ||
873 | int in_use) | ||
874 | { | ||
875 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
876 | "Setting address used to %s for peer `%s', plugin `%s', session %p\n", | ||
877 | (GNUNET_YES == in_use) ? "YES" : "NO", | ||
878 | GNUNET_i2s (&ar->address->peer), | ||
879 | ar->address->transport_name, | ||
880 | ar->session); | ||
881 | ar->in_use = in_use; | ||
882 | if (NULL == ar->sh->mq) | ||
883 | return; | ||
884 | send_in_use_message (ar, in_use); | ||
885 | } | ||
886 | |||
887 | 820 | ||
888 | /** | 821 | /** |
889 | * An address got destroyed, stop using it as a valid address. | 822 | * An address got destroyed, stop using it as a valid address. |
@@ -898,9 +831,10 @@ GNUNET_ATS_address_destroy (struct GNUNET_ATS_AddressRecord *ar) | |||
898 | struct AddressDestroyedMessage *m; | 831 | struct AddressDestroyedMessage *m; |
899 | 832 | ||
900 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 833 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
901 | "Deleting address for peer `%s', plugin `%s', session %p\n", | 834 | "Deleting address for peer `%s', plugin `%s', slot %u session %p\n", |
902 | GNUNET_i2s (&ar->address->peer), | 835 | GNUNET_i2s (&ar->address->peer), |
903 | ar->address->transport_name, | 836 | ar->address->transport_name, |
837 | ar->slot, | ||
904 | ar->session); | 838 | ar->session); |
905 | GNUNET_break (NULL == ar->session); | 839 | GNUNET_break (NULL == ar->session); |
906 | ar->session = NULL; | 840 | ar->session = NULL; |
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c index 83fa42b35..944db77f6 100644 --- a/src/ats/gnunet-service-ats.c +++ b/src/ats/gnunet-service-ats.c | |||
@@ -165,9 +165,6 @@ run (void *cls, | |||
165 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD, 0}, | 165 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD, 0}, |
166 | {&GAS_handle_address_update, NULL, | 166 | {&GAS_handle_address_update, NULL, |
167 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, 0}, | 167 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, 0}, |
168 | {&GAS_handle_address_in_use, NULL, | ||
169 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE, | ||
170 | sizeof (struct AddressUseMessage) }, | ||
171 | {&GAS_handle_address_destroyed, NULL, | 168 | {&GAS_handle_address_destroyed, NULL, |
172 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, | 169 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, |
173 | sizeof (struct AddressDestroyedMessage) }, | 170 | sizeof (struct AddressDestroyedMessage) }, |
@@ -178,9 +175,6 @@ run (void *cls, | |||
178 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0}, | 175 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0}, |
179 | {&GAS_handle_preference_feedback, NULL, | 176 | {&GAS_handle_preference_feedback, NULL, |
180 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK, 0}, | 177 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK, 0}, |
181 | {&GAS_handle_reset_backoff, NULL, | ||
182 | GNUNET_MESSAGE_TYPE_ATS_RESET_BACKOFF, | ||
183 | sizeof (struct ResetBackoffMessage)}, | ||
184 | {NULL, NULL, 0, 0} | 178 | {NULL, NULL, 0, 0} |
185 | }; | 179 | }; |
186 | GSA_server = server; | 180 | GSA_server = server; |
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 8b38120cc..1d2c9d3e5 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2011-2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | /** | 38 | /** |
39 | * NOTE: Do not change this documentation. This documentation is based on | 39 | * NOTE: Do not change this documentation. This documentation is based on |
40 | * gnunet.org:/vcs/fsnsg/ats-paper.git/tech-doku/ats-tech-guide.tex | 40 | * gnunet.org:/vcs/fsnsg/2014-p2p-ats.git/tech-doku/ats-tech-guide.tex |
41 | * use build_txt.sh to generate plaintext output | 41 | * use build_txt.sh to generate plaintext output |
42 | * | 42 | * |
43 | * 1 ATS addresses : ATS address management | 43 | * 1 ATS addresses : ATS address management |
@@ -192,22 +192,10 @@ | |||
192 | * available it will not respond at all If the client is not interested | 192 | * available it will not respond at all If the client is not interested |
193 | * anymore, it has to cancel the address suggestion request. | 193 | * anymore, it has to cancel the address suggestion request. |
194 | * | 194 | * |
195 | * 1.7.6 Suggestions blocks and reset | 195 | * 1.7.6 Address lifecycle |
196 | * | ||
197 | * After suggesting an address it is blocked for ATS_BLOCKING_DELTA sec. to | ||
198 | * prevent the client from being thrashed. If the client requires immediately | ||
199 | * it can reset this block using GAS_addresses_handle_backoff_reset. | ||
200 | * | ||
201 | * 1.7.7 Marking address in use | ||
202 | * | ||
203 | * The client can notify addresses that it successfully uses an address and | ||
204 | * wants this address to be kept by calling GSA_address_in_use. Adresses will | ||
205 | * mark the address as used an notify the solver about the use. | ||
206 | * | ||
207 | * 1.7.8 Address lifecycle | ||
208 | * | 196 | * |
209 | * * (add address) | 197 | * * (add address) |
210 | * * (updated address) || (address in use) | 198 | * * (updated address) |
211 | * * (delete address) | 199 | * * (delete address) |
212 | * | 200 | * |
213 | * 1.8 Bandwidth assignment | 201 | * 1.8 Bandwidth assignment |
@@ -302,7 +290,9 @@ static int ats_mode; | |||
302 | static void *solver; | 290 | static void *solver; |
303 | 291 | ||
304 | /** | 292 | /** |
305 | * Address suggestion requests DLL head | 293 | * Address suggestion requests DLL head. |
294 | * FIXME: This must become a Multipeermap! O(n) operations | ||
295 | * galore instead of O(1)!!! | ||
306 | */ | 296 | */ |
307 | static struct GAS_Addresses_Suggestion_Requests *pending_requests_head; | 297 | static struct GAS_Addresses_Suggestion_Requests *pending_requests_head; |
308 | 298 | ||
@@ -1086,66 +1076,6 @@ GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer, | |||
1086 | 1076 | ||
1087 | 1077 | ||
1088 | /** | 1078 | /** |
1089 | * Notification about active use of an address. | ||
1090 | * in_use == #GNUNET_YES: | ||
1091 | * This address is used to maintain an active connection with a peer. | ||
1092 | * in_use == #GNUNET_NO: | ||
1093 | * This address is no longer used to maintain an active connection with a peer. | ||
1094 | * | ||
1095 | * Note: can only be called with in_use == #GNUNET_NO if called with #GNUNET_YES | ||
1096 | * before | ||
1097 | * | ||
1098 | * @param peer peer | ||
1099 | * @param session_id session id, can be 0 | ||
1100 | * @param in_use #GNUNET_YES if #GNUNET_NO FIXME | ||
1101 | * @return #GNUNET_SYSERR on failure (address unknown ...) | ||
1102 | */ | ||
1103 | int | ||
1104 | GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer, | ||
1105 | uint32_t session_id, | ||
1106 | int in_use) | ||
1107 | { | ||
1108 | struct ATS_Address *ea; | ||
1109 | |||
1110 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
1111 | "Received `%s' for peer `%s'\n", | ||
1112 | "ADDRESS IN USE", | ||
1113 | GNUNET_i2s (peer)); | ||
1114 | if (GNUNET_NO == running) | ||
1115 | return GNUNET_SYSERR; | ||
1116 | ea = find_exact_address (peer, | ||
1117 | session_id); | ||
1118 | if (NULL == ea) | ||
1119 | { | ||
1120 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1121 | "Trying to set unknown address `%s' `%u' to %s \n", | ||
1122 | GNUNET_i2s (peer), | ||
1123 | session_id, | ||
1124 | (GNUNET_NO == in_use) ? "NO" : "YES"); | ||
1125 | GNUNET_break (0); | ||
1126 | return GNUNET_SYSERR; | ||
1127 | } | ||
1128 | if (ea->used == in_use) | ||
1129 | { | ||
1130 | GNUNET_break (0); | ||
1131 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | ||
1132 | "Address in use called multiple times for peer `%s': %s -> %s \n", | ||
1133 | GNUNET_i2s (peer), | ||
1134 | (GNUNET_NO == ea->used) ? "NO" : "YES", | ||
1135 | (GNUNET_NO == in_use) ? "NO" : "YES"); | ||
1136 | return GNUNET_SYSERR; | ||
1137 | } | ||
1138 | /* Tell solver about update */ | ||
1139 | ea->used = in_use; | ||
1140 | ea->t_last_activity = GNUNET_TIME_absolute_get(); | ||
1141 | env.sf.s_address_update_inuse (solver, | ||
1142 | ea, | ||
1143 | ea->used); | ||
1144 | return GNUNET_OK; | ||
1145 | } | ||
1146 | |||
1147 | |||
1148 | /** | ||
1149 | * Cancel address suggestions for a peer | 1079 | * Cancel address suggestions for a peer |
1150 | * | 1080 | * |
1151 | * @param peer the peer id | 1081 | * @param peer the peer id |
@@ -1169,16 +1099,15 @@ GAS_addresses_request_address_cancel (const struct GNUNET_PeerIdentity *peer) | |||
1169 | 1099 | ||
1170 | if (NULL == cur) | 1100 | if (NULL == cur) |
1171 | { | 1101 | { |
1172 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1102 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1173 | "No address requests pending for peer `%s', cannot remove!\n", | 1103 | "No address requests pending for peer `%s', cannot remove!\n", |
1174 | GNUNET_i2s (peer)); | 1104 | GNUNET_i2s (peer)); |
1175 | return; | 1105 | return; |
1176 | } | 1106 | } |
1177 | env.sf.s_get_stop (solver, peer); | 1107 | env.sf.s_get_stop (solver, peer); |
1178 | GAS_addresses_handle_backoff_reset (peer); | 1108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1179 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1109 | "Removed request pending for peer `%s\n", |
1180 | "Removed request pending for peer `%s\n", | 1110 | GNUNET_i2s (peer)); |
1181 | GNUNET_i2s (peer)); | ||
1182 | GNUNET_CONTAINER_DLL_remove (pending_requests_head, | 1111 | GNUNET_CONTAINER_DLL_remove (pending_requests_head, |
1183 | pending_requests_tail, | 1112 | pending_requests_tail, |
1184 | cur); | 1113 | cur); |
@@ -1213,10 +1142,10 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) | |||
1213 | if (NULL == cur) | 1142 | if (NULL == cur) |
1214 | { | 1143 | { |
1215 | cur = GNUNET_new (struct GAS_Addresses_Suggestion_Requests); | 1144 | cur = GNUNET_new (struct GAS_Addresses_Suggestion_Requests); |
1216 | cur->id = (*peer); | 1145 | cur->id = *peer; |
1217 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1218 | "Adding new address suggestion request for `%s'\n", | 1147 | "Adding new address suggestion request for `%s'\n", |
1219 | GNUNET_i2s (peer)); | 1148 | GNUNET_i2s (peer)); |
1220 | GNUNET_CONTAINER_DLL_insert (pending_requests_head, | 1149 | GNUNET_CONTAINER_DLL_insert (pending_requests_head, |
1221 | pending_requests_tail, | 1150 | pending_requests_tail, |
1222 | cur); | 1151 | cur); |
@@ -1249,55 +1178,6 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) | |||
1249 | aa->block_interval); | 1178 | aa->block_interval); |
1250 | } | 1179 | } |
1251 | 1180 | ||
1252 | /** | ||
1253 | * Iterator to reset address blocking | ||
1254 | * | ||
1255 | * @param cls not used | ||
1256 | * @param key the peer | ||
1257 | * @param value the address to reset | ||
1258 | * @return #GNUNET_OK to continue | ||
1259 | */ | ||
1260 | static int | ||
1261 | reset_address_it (void *cls, | ||
1262 | const struct GNUNET_PeerIdentity *key, | ||
1263 | void *value) | ||
1264 | { | ||
1265 | struct ATS_Address *aa = value; | ||
1266 | |||
1267 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
1268 | "Resetting interval for peer `%s' address %p from %llu to 0\n", | ||
1269 | GNUNET_i2s (&aa->peer), | ||
1270 | aa, | ||
1271 | aa->block_interval); | ||
1272 | aa->blocked_until = GNUNET_TIME_UNIT_ZERO_ABS; | ||
1273 | aa->block_interval = GNUNET_TIME_UNIT_ZERO; | ||
1274 | return GNUNET_OK; | ||
1275 | } | ||
1276 | |||
1277 | |||
1278 | /** | ||
1279 | * Reset suggestion backoff for a peer | ||
1280 | * | ||
1281 | * Suggesting addresses is blocked for ATS_BLOCKING_DELTA. Blocking can be | ||
1282 | * reset using this function | ||
1283 | * | ||
1284 | * @param peer the peer id | ||
1285 | */ | ||
1286 | void | ||
1287 | GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer) | ||
1288 | { | ||
1289 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
1290 | "Received `%s' for peer `%s'\n", | ||
1291 | "RESET BACKOFF", | ||
1292 | GNUNET_i2s (peer)); | ||
1293 | |||
1294 | GNUNET_break(GNUNET_SYSERR != | ||
1295 | GNUNET_CONTAINER_multipeermap_get_multiple (addresses, | ||
1296 | peer, | ||
1297 | &reset_address_it, | ||
1298 | NULL)); | ||
1299 | } | ||
1300 | |||
1301 | 1181 | ||
1302 | /** | 1182 | /** |
1303 | * Solver information callback | 1183 | * Solver information callback |
@@ -1741,7 +1621,9 @@ bandwidth_changed_cb (void *cls, struct ATS_Address *address) | |||
1741 | GNUNET_BANDWIDTH_value_init (address->assigned_bw_in)); | 1621 | GNUNET_BANDWIDTH_value_init (address->assigned_bw_in)); |
1742 | 1622 | ||
1743 | for (cur = pending_requests_head;NULL != cur; cur = cur->next) | 1623 | for (cur = pending_requests_head;NULL != cur; cur = cur->next) |
1744 | if (0 == memcmp (&address->peer, &cur->id, sizeof(cur->id))) | 1624 | if (0 == memcmp (&address->peer, |
1625 | &cur->id, | ||
1626 | sizeof(cur->id))) | ||
1745 | break; /* we have an address request pending*/ | 1627 | break; /* we have an address request pending*/ |
1746 | if (NULL == cur) | 1628 | if (NULL == cur) |
1747 | { | 1629 | { |
@@ -1891,10 +1773,10 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1891 | GNUNET_asprintf (&plugin, | 1773 | GNUNET_asprintf (&plugin, |
1892 | "libgnunet_plugin_ats_%s", | 1774 | "libgnunet_plugin_ats_%s", |
1893 | plugin_short); | 1775 | plugin_short); |
1894 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1776 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1895 | _("Initializing solver `%s '`%s'\n"), | 1777 | "Initializing solver `%s '`%s'\n", |
1896 | plugin_short, | 1778 | plugin_short, |
1897 | plugin); | 1779 | plugin); |
1898 | if (NULL == (solver = GNUNET_PLUGIN_load (plugin, &env))) | 1780 | if (NULL == (solver = GNUNET_PLUGIN_load (plugin, &env))) |
1899 | { | 1781 | { |
1900 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1782 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1904,7 +1786,6 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1904 | } | 1786 | } |
1905 | 1787 | ||
1906 | GNUNET_assert (NULL != env.sf.s_add); | 1788 | GNUNET_assert (NULL != env.sf.s_add); |
1907 | GNUNET_assert (NULL != env.sf.s_address_update_inuse); | ||
1908 | GNUNET_assert (NULL != env.sf.s_address_update_property); | 1789 | GNUNET_assert (NULL != env.sf.s_address_update_property); |
1909 | GNUNET_assert (NULL != env.sf.s_address_update_session); | 1790 | GNUNET_assert (NULL != env.sf.s_address_update_session); |
1910 | GNUNET_assert (NULL != env.sf.s_address_update_network); | 1791 | GNUNET_assert (NULL != env.sf.s_address_update_network); |
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h index 2f21ae380..8892f77c4 100644 --- a/src/ats/gnunet-service-ats_addresses.h +++ b/src/ats/gnunet-service-ats_addresses.h | |||
@@ -196,16 +196,10 @@ | |||
196 | * prevent the client from being thrashed. If the client requires immediately | 196 | * prevent the client from being thrashed. If the client requires immediately |
197 | * it can reset this block using GAS_addresses_handle_backoff_reset. | 197 | * it can reset this block using GAS_addresses_handle_backoff_reset. |
198 | * | 198 | * |
199 | * 1.7.7 Marking address in use | 199 | * 1.7.7 Address lifecycle |
200 | * | ||
201 | * The client can notify addresses that it successfully uses an address and | ||
202 | * wants this address to be kept by calling GSA_address_in_use. Adresses will | ||
203 | * mark the address as used an notify the solver about the use. | ||
204 | * | ||
205 | * 1.7.8 Address lifecycle | ||
206 | * | 200 | * |
207 | * * (add address) | 201 | * * (add address) |
208 | * * (updated address) || (address in use) | 202 | * * (updated address) |
209 | * * (delete address) | 203 | * * (delete address) |
210 | * | 204 | * |
211 | * 1.8 Bandwidth assignment | 205 | * 1.8 Bandwidth assignment |
@@ -454,27 +448,6 @@ GAS_addresses_add (const struct GNUNET_PeerIdentity *peer, | |||
454 | 448 | ||
455 | 449 | ||
456 | /** | 450 | /** |
457 | * Notification about active use of an address. | ||
458 | * in_use == #GNUNET_YES: | ||
459 | * This address is used to maintain an active connection with a peer. | ||
460 | * in_use == #GNUNET_NO: | ||
461 | * This address is no longer used to maintain an active connection with a peer. | ||
462 | * | ||
463 | * Note: can only be called with in_use == #GNUNET_NO if called with #GNUNET_YES | ||
464 | * before | ||
465 | * | ||
466 | * @param peer peer | ||
467 | * @param session_id session id, can never be 0 | ||
468 | * @param in_use #GNUNET_YES if #GNUNET_NO FIXME | ||
469 | * @return #GNUNET_SYSERR on failure (address unknown ...) | ||
470 | */ | ||
471 | int | ||
472 | GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer, | ||
473 | uint32_t session_id, | ||
474 | int in_use); | ||
475 | |||
476 | |||
477 | /** | ||
478 | * Update an address with new performance information for a peer. | 451 | * Update an address with new performance information for a peer. |
479 | * | 452 | * |
480 | * @param peer peer | 453 | * @param peer peer |
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c index 6b6b6c24f..9d7562e7b 100644 --- a/src/ats/gnunet-service-ats_scheduling.c +++ b/src/ats/gnunet-service-ats_scheduling.c | |||
@@ -120,30 +120,6 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *pe | |||
120 | 120 | ||
121 | 121 | ||
122 | /** | 122 | /** |
123 | * Handle 'reset backoff' messages from clients. | ||
124 | * | ||
125 | * @param cls unused, NULL | ||
126 | * @param client client that sent the request | ||
127 | * @param message the request message | ||
128 | */ | ||
129 | void | ||
130 | GAS_handle_reset_backoff (void *cls, | ||
131 | struct GNUNET_SERVER_Client *client, | ||
132 | const struct GNUNET_MessageHeader *message) | ||
133 | { | ||
134 | const struct ResetBackoffMessage *msg = | ||
135 | (const struct ResetBackoffMessage *) message; | ||
136 | |||
137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
138 | "Received `%s' message\n", | ||
139 | "RESET_BACKOFF"); | ||
140 | GNUNET_break (0 == ntohl (msg->reserved)); | ||
141 | GAS_addresses_handle_backoff_reset (&msg->peer); | ||
142 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
143 | } | ||
144 | |||
145 | |||
146 | /** | ||
147 | * Handle 'address add' messages from clients. | 123 | * Handle 'address add' messages from clients. |
148 | * | 124 | * |
149 | * @param cls unused, NULL | 125 | * @param cls unused, NULL |
@@ -262,35 +238,6 @@ GAS_handle_address_update (void *cls, | |||
262 | 238 | ||
263 | 239 | ||
264 | /** | 240 | /** |
265 | * Handle 'address in use' messages from clients. | ||
266 | * | ||
267 | * @param cls unused, NULL | ||
268 | * @param client client that sent the request | ||
269 | * @param message the request message | ||
270 | */ | ||
271 | void | ||
272 | GAS_handle_address_in_use (void *cls, | ||
273 | struct GNUNET_SERVER_Client *client, | ||
274 | const struct GNUNET_MessageHeader *message) | ||
275 | { | ||
276 | const struct AddressUseMessage *m; | ||
277 | int res; | ||
278 | |||
279 | m = (const struct AddressUseMessage *) message; | ||
280 | res = GAS_addresses_in_use (&m->peer, | ||
281 | ntohl (m->session_id), | ||
282 | ntohl (m->in_use)); | ||
283 | if (GNUNET_OK != res) | ||
284 | { | ||
285 | GNUNET_break (0); | ||
286 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
287 | return; | ||
288 | } | ||
289 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
290 | } | ||
291 | |||
292 | |||
293 | /** | ||
294 | * Handle 'address destroyed' messages from clients. | 241 | * Handle 'address destroyed' messages from clients. |
295 | * | 242 | * |
296 | * @param cls unused, NULL | 243 | * @param cls unused, NULL |
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c index 75bb76dde..15fa5e6bd 100644 --- a/src/ats/plugin_ats_mlp.c +++ b/src/ats/plugin_ats_mlp.c | |||
@@ -2064,25 +2064,6 @@ GAS_mlp_address_session_changed (void *solver, | |||
2064 | 2064 | ||
2065 | 2065 | ||
2066 | /** | 2066 | /** |
2067 | * Transport session for this address has changed | ||
2068 | * | ||
2069 | * NOTE: values in addresses are already updated | ||
2070 | * | ||
2071 | * @param solver solver handle | ||
2072 | * @param address the address | ||
2073 | * @param in_use usage state | ||
2074 | */ | ||
2075 | static void | ||
2076 | GAS_mlp_address_inuse_changed (void *solver, | ||
2077 | struct ATS_Address *address, | ||
2078 | int in_use) | ||
2079 | { | ||
2080 | /* Nothing to do here */ | ||
2081 | return; | ||
2082 | } | ||
2083 | |||
2084 | |||
2085 | /** | ||
2086 | * Network scope for this address has changed | 2067 | * Network scope for this address has changed |
2087 | * | 2068 | * |
2088 | * NOTE: values in addresses are already updated | 2069 | * NOTE: values in addresses are already updated |
@@ -2973,7 +2954,6 @@ libgnunet_plugin_ats_mlp_init (void *cls) | |||
2973 | env->sf.s_add = &GAS_mlp_address_add; | 2954 | env->sf.s_add = &GAS_mlp_address_add; |
2974 | env->sf.s_address_update_property = &GAS_mlp_address_property_changed; | 2955 | env->sf.s_address_update_property = &GAS_mlp_address_property_changed; |
2975 | env->sf.s_address_update_session = &GAS_mlp_address_session_changed; | 2956 | env->sf.s_address_update_session = &GAS_mlp_address_session_changed; |
2976 | env->sf.s_address_update_inuse = &GAS_mlp_address_inuse_changed; | ||
2977 | env->sf.s_address_update_network = &GAS_mlp_address_change_network; | 2957 | env->sf.s_address_update_network = &GAS_mlp_address_change_network; |
2978 | env->sf.s_get = &GAS_mlp_get_preferred_address; | 2958 | env->sf.s_get = &GAS_mlp_get_preferred_address; |
2979 | env->sf.s_get_stop = &GAS_mlp_stop_get_preferred_address; | 2959 | env->sf.s_get_stop = &GAS_mlp_stop_get_preferred_address; |
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c index 64dca90c5..7bcc948b7 100644 --- a/src/ats/plugin_ats_proportional.c +++ b/src/ats/plugin_ats_proportional.c | |||
@@ -50,7 +50,7 @@ | |||
50 | * outbound quota is configured and the bandwidth available in | 50 | * outbound quota is configured and the bandwidth available in |
51 | * these networks is distributed over the addresses. The solver | 51 | * these networks is distributed over the addresses. The solver |
52 | * first assigns every addresses the minimum amount of bandwidth | 52 | * first assigns every addresses the minimum amount of bandwidth |
53 | * GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT and then distributes the | 53 | * #GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT and then distributes the |
54 | * remaining bandwidth available according to the preference | 54 | * remaining bandwidth available according to the preference |
55 | * values. For each peer only a single address gets bandwidth | 55 | * values. For each peer only a single address gets bandwidth |
56 | * assigned and only one address marked as active. The most | 56 | * assigned and only one address marked as active. The most |
@@ -104,7 +104,7 @@ | |||
104 | * solver is when an address switches network it is located | 104 | * solver is when an address switches network it is located |
105 | * in. This is common because addresses added by transport's | 105 | * in. This is common because addresses added by transport's |
106 | * validation mechanism are commonly located in | 106 | * validation mechanism are commonly located in |
107 | * GNUNET_ATS_NET_UNSPECIFIED. Addresses in validation are located | 107 | * #GNUNET_ATS_NET_UNSPECIFIED. Addresses in validation are located |
108 | * in this network type and only if a connection is successful on | 108 | * in this network type and only if a connection is successful on |
109 | * return of payload data transport switches to the real network | 109 | * return of payload data transport switches to the real network |
110 | * the address is located in. When an address changes networks it | 110 | * the address is located in. When an address changes networks it |
@@ -155,9 +155,9 @@ | |||
155 | * the best available address. Several checks are done when an | 155 | * the best available address. Several checks are done when an |
156 | * address is selected. First if this address is currently blocked | 156 | * address is selected. First if this address is currently blocked |
157 | * by addresses from being suggested. An address is blocked for the | 157 | * by addresses from being suggested. An address is blocked for the |
158 | * duration of ATS_BLOCKING_DELTA when it is suggested to | 158 | * duration of #ATS_BLOCKING_DELTA when it is suggested to |
159 | * transport. Next it is checked if at least | 159 | * transport. Next it is checked if at least |
160 | * GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT bytes bandwidth is available | 160 | * #GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT bytes bandwidth is available |
161 | * in the addresse's network, because suggesting an address without | 161 | * in the addresse's network, because suggesting an address without |
162 | * bandwidth does not make sense. This also ensures that all active | 162 | * bandwidth does not make sense. This also ensures that all active |
163 | * addresses in this network get at least the minimum amount of | 163 | * addresses in this network get at least the minimum amount of |
@@ -322,13 +322,11 @@ struct Network | |||
322 | 322 | ||
323 | /** | 323 | /** |
324 | * Total inbound quota | 324 | * Total inbound quota |
325 | * | ||
326 | */ | 325 | */ |
327 | unsigned long long total_quota_in; | 326 | unsigned long long total_quota_in; |
328 | 327 | ||
329 | /** | 328 | /** |
330 | * Total outbound quota | 329 | * Total outbound quota |
331 | * | ||
332 | */ | 330 | */ |
333 | unsigned long long total_quota_out; | 331 | unsigned long long total_quota_out; |
334 | 332 | ||
@@ -375,13 +373,11 @@ struct AddressSolverInformation | |||
375 | 373 | ||
376 | /** | 374 | /** |
377 | * Inbound quota | 375 | * Inbound quota |
378 | * | ||
379 | */ | 376 | */ |
380 | uint32_t calculated_quota_in; | 377 | uint32_t calculated_quota_in; |
381 | 378 | ||
382 | /** | 379 | /** |
383 | * Outbound quota | 380 | * Outbound quota |
384 | * | ||
385 | */ | 381 | */ |
386 | uint32_t calculated_quota_out; | 382 | uint32_t calculated_quota_out; |
387 | 383 | ||
@@ -427,7 +423,6 @@ libgnunet_plugin_ats_proportional_done (void *cls) | |||
427 | struct AddressWrapper *next; | 423 | struct AddressWrapper *next; |
428 | int c; | 424 | int c; |
429 | 425 | ||
430 | GNUNET_assert(s != NULL); | ||
431 | for (c = 0; c < s->network_count; c++) | 426 | for (c = 0; c < s->network_count; c++) |
432 | { | 427 | { |
433 | if (s->network_entries[c].total_addresses > 0) | 428 | if (s->network_entries[c].total_addresses > 0) |
@@ -515,11 +510,10 @@ is_bandwidth_available_in_network (struct Network *net) | |||
515 | */ | 510 | */ |
516 | static void | 511 | static void |
517 | distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s, | 512 | distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s, |
518 | struct Network *net) | 513 | struct Network *net) |
519 | { | 514 | { |
520 | struct AddressSolverInformation *asi; | 515 | struct AddressSolverInformation *asi; |
521 | struct AddressWrapper *cur_address; | 516 | struct AddressWrapper *cur_address; |
522 | |||
523 | unsigned long long remaining_quota_in = 0; | 517 | unsigned long long remaining_quota_in = 0; |
524 | unsigned long long quota_out_used = 0; | 518 | unsigned long long quota_out_used = 0; |
525 | unsigned long long remaining_quota_out = 0; | 519 | unsigned long long remaining_quota_out = 0; |
@@ -537,10 +531,12 @@ distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s, | |||
537 | uint32_t assigned_quota_out = 0; | 531 | uint32_t assigned_quota_out = 0; |
538 | 532 | ||
539 | 533 | ||
540 | LOG(GNUNET_ERROR_TYPE_INFO, | 534 | LOG (GNUNET_ERROR_TYPE_INFO, |
541 | "Recalculate quota for network type `%s' for %u addresses (in/out): %llu/%llu \n", | 535 | "Recalculate quota for network type `%s' for %u addresses (in/out): %llu/%llu \n", |
542 | net->desc, net->active_addresses, net->total_quota_in, | 536 | net->desc, |
543 | net->total_quota_in); | 537 | net->active_addresses, |
538 | net->total_quota_in, | ||
539 | net->total_quota_in); | ||
544 | 540 | ||
545 | if (net->active_addresses == 0) | 541 | if (net->active_addresses == 0) |
546 | { | 542 | { |
@@ -803,7 +799,6 @@ find_best_address_it (void *cls, | |||
803 | /* user shorter distance */ | 799 | /* user shorter distance */ |
804 | if (cur_distance < best_distance) | 800 | if (cur_distance < best_distance) |
805 | { | 801 | { |
806 | |||
807 | if (GNUNET_NO == ctx->best->active) | 802 | if (GNUNET_NO == ctx->best->active) |
808 | { | 803 | { |
809 | current_best = current; /* Use current */ | 804 | current_best = current; /* Use current */ |
@@ -864,9 +859,10 @@ get_best_address (struct GAS_PROPORTIONAL_Handle *s, | |||
864 | 859 | ||
865 | fba_ctx.best = NULL; | 860 | fba_ctx.best = NULL; |
866 | fba_ctx.s = s; | 861 | fba_ctx.s = s; |
867 | GNUNET_CONTAINER_multipeermap_get_multiple (addresses, id, | 862 | GNUNET_CONTAINER_multipeermap_get_multiple (addresses, |
868 | &find_best_address_it, &fba_ctx); | 863 | id, |
869 | 864 | &find_best_address_it, | |
865 | &fba_ctx); | ||
870 | return fba_ctx.best; | 866 | return fba_ctx.best; |
871 | } | 867 | } |
872 | 868 | ||
@@ -1203,7 +1199,7 @@ distribute_bandwidth_in_network (struct GAS_PROPORTIONAL_Handle *s, | |||
1203 | * @param peer the peer to check | 1199 | * @param peer the peer to check |
1204 | * return the new address or NULL if no update was performed | 1200 | * return the new address or NULL if no update was performed |
1205 | */ | 1201 | */ |
1206 | static const struct ATS_Address * | 1202 | static struct ATS_Address * |
1207 | update_active_address (struct GAS_PROPORTIONAL_Handle *s, | 1203 | update_active_address (struct GAS_PROPORTIONAL_Handle *s, |
1208 | const struct GNUNET_PeerIdentity *peer) | 1204 | const struct GNUNET_PeerIdentity *peer) |
1209 | { | 1205 | { |
@@ -1217,27 +1213,38 @@ update_active_address (struct GAS_PROPORTIONAL_Handle *s, | |||
1217 | GNUNET_i2s (peer)); | 1213 | GNUNET_i2s (peer)); |
1218 | 1214 | ||
1219 | /* Find active address */ | 1215 | /* Find active address */ |
1220 | current_address = get_active_address (s, s->addresses, peer); | 1216 | current_address = get_active_address (s, |
1217 | s->addresses, | ||
1218 | peer); | ||
1221 | 1219 | ||
1222 | LOG (GNUNET_ERROR_TYPE_INFO, "Peer `%s' has active address %p\n", | 1220 | LOG (GNUNET_ERROR_TYPE_INFO, |
1223 | GNUNET_i2s (peer), current_address); | 1221 | "Peer `%s' has active address %p\n", |
1222 | GNUNET_i2s (peer), | ||
1223 | current_address); | ||
1224 | 1224 | ||
1225 | /* Find best address */ | 1225 | /* Find best address */ |
1226 | best_address = get_best_address (s,s->addresses, peer); | 1226 | best_address = get_best_address (s, |
1227 | LOG (GNUNET_ERROR_TYPE_INFO, "Peer `%s' has best address %p\n", | 1227 | s->addresses, |
1228 | GNUNET_i2s (peer), best_address); | 1228 | peer); |
1229 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
1230 | "Peer `%s' has best address %p\n", | ||
1231 | GNUNET_i2s (peer), | ||
1232 | best_address); | ||
1229 | 1233 | ||
1230 | if (NULL != current_address) | 1234 | if (NULL != current_address) |
1231 | { | 1235 | { |
1232 | if ((NULL == best_address) || ((NULL != best_address) && | 1236 | if ( (NULL == best_address) || |
1233 | (GNUNET_NO == address_eq (current_address, best_address)))) | 1237 | ( (NULL != best_address) && |
1238 | (GNUNET_NO == address_eq (current_address, | ||
1239 | best_address)) ) ) | ||
1234 | { | 1240 | { |
1235 | /* We switch to a new address, mark old address as inactive */ | 1241 | /* We switch to a new address (or to none), |
1242 | mark old address as inactive */ | ||
1236 | LOG (GNUNET_ERROR_TYPE_INFO, | 1243 | LOG (GNUNET_ERROR_TYPE_INFO, |
1237 | "Disabling previous %s address %p for peer `%s'\n", | 1244 | "Disabling previous %s address %p for peer `%s'\n", |
1238 | (GNUNET_NO == current_address->active) ? "inactive" : "active", | 1245 | (GNUNET_NO == current_address->active) ? "inactive" : "active", |
1239 | current_address, | 1246 | current_address, |
1240 | GNUNET_i2s (peer)); | 1247 | GNUNET_i2s (peer)); |
1241 | 1248 | ||
1242 | asi = current_address->solver_information; | 1249 | asi = current_address->solver_information; |
1243 | GNUNET_assert (NULL != asi); | 1250 | GNUNET_assert (NULL != asi); |
@@ -1258,32 +1265,31 @@ update_active_address (struct GAS_PROPORTIONAL_Handle *s, | |||
1258 | { | 1265 | { |
1259 | /* We previously had an active address, but now we cannot suggest one | 1266 | /* We previously had an active address, but now we cannot suggest one |
1260 | * Therefore we have to disconnect the peer */ | 1267 | * Therefore we have to disconnect the peer */ |
1261 | |||
1262 | LOG (GNUNET_ERROR_TYPE_INFO, | 1268 | LOG (GNUNET_ERROR_TYPE_INFO, |
1263 | "Disconnecting peer `%s' with previous %s address %p\n", | 1269 | "Disconnecting peer `%s' with previous address %p\n", |
1264 | GNUNET_i2s (peer), | 1270 | GNUNET_i2s (peer), |
1265 | (GNUNET_NO == current_address->active) ? "inactive" : "active", | 1271 | current_address); |
1266 | current_address); | 1272 | s->bw_changed (s->bw_changed_cls, |
1267 | s->bw_changed (s->bw_changed_cls, current_address); | 1273 | current_address); |
1268 | } | 1274 | } |
1269 | } | 1275 | } |
1270 | |||
1271 | if (NULL == best_address) | 1276 | if (NULL == best_address) |
1272 | { | 1277 | { |
1273 | LOG (GNUNET_ERROR_TYPE_INFO, "Cannot suggest address for peer `%s'\n", | 1278 | LOG (GNUNET_ERROR_TYPE_INFO, |
1274 | GNUNET_i2s (peer)); | 1279 | "Cannot suggest address for peer `%s'\n", |
1275 | return NULL ; | 1280 | GNUNET_i2s (peer)); |
1281 | return NULL; | ||
1276 | } | 1282 | } |
1277 | 1283 | ||
1278 | LOG (GNUNET_ERROR_TYPE_INFO, "Suggesting %s address %p for peer `%s'\n", | 1284 | LOG (GNUNET_ERROR_TYPE_INFO, |
1279 | (GNUNET_NO == best_address->active) ? "inactive" : "active", best_address, | 1285 | "Suggesting new address %p for peer `%s'\n", |
1280 | GNUNET_i2s (peer)); | 1286 | best_address, |
1287 | GNUNET_i2s (peer)); | ||
1281 | 1288 | ||
1282 | if ((NULL != current_address) && | 1289 | if ( (NULL != current_address) && |
1283 | (GNUNET_YES == address_eq (best_address, current_address))) | 1290 | (GNUNET_YES == address_eq (best_address, current_address)) ) |
1284 | { | 1291 | { |
1285 | if (current_address->active == GNUNET_NO) | 1292 | GNUNET_break (GNUNET_NO != current_address->active); |
1286 | GNUNET_break (0); /* Should never happen */ | ||
1287 | return best_address; /* Same same */ | 1293 | return best_address; /* Same same */ |
1288 | } | 1294 | } |
1289 | 1295 | ||
@@ -1292,11 +1298,13 @@ update_active_address (struct GAS_PROPORTIONAL_Handle *s, | |||
1292 | net = asi->network; | 1298 | net = asi->network; |
1293 | 1299 | ||
1294 | /* Mark address as active */ | 1300 | /* Mark address as active */ |
1295 | asi->activated = GNUNET_TIME_absolute_get(); | 1301 | asi->activated = GNUNET_TIME_absolute_get (); |
1296 | best_address->active = GNUNET_YES; | 1302 | best_address->active = GNUNET_YES; |
1297 | address_increment (s, net, GNUNET_NO, GNUNET_YES); | 1303 | address_increment (s, net, GNUNET_NO, GNUNET_YES); |
1298 | LOG (GNUNET_ERROR_TYPE_INFO, "Address %p for peer `%s' is now active\n", | 1304 | LOG (GNUNET_ERROR_TYPE_INFO, |
1299 | best_address, GNUNET_i2s (peer)); | 1305 | "Address %p for peer `%s' is now active\n", |
1306 | best_address, | ||
1307 | GNUNET_i2s (peer)); | ||
1300 | /* Distribute bandwidth */ | 1308 | /* Distribute bandwidth */ |
1301 | distribute_bandwidth_in_network (s, net); | 1309 | distribute_bandwidth_in_network (s, net); |
1302 | return best_address; | 1310 | return best_address; |
@@ -1322,15 +1330,13 @@ GAS_proportional_address_change_preference (void *solver, | |||
1322 | struct ATS_Address *active_address; | 1330 | struct ATS_Address *active_address; |
1323 | struct AddressSolverInformation *asi; | 1331 | struct AddressSolverInformation *asi; |
1324 | 1332 | ||
1325 | GNUNET_assert(NULL != s); | 1333 | if (GNUNET_NO == |
1326 | GNUNET_assert(NULL != peer); | 1334 | GNUNET_CONTAINER_multipeermap_contains (s->requests, peer)) |
1327 | |||
1328 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests, peer)) | ||
1329 | return; /* Peer is not requested */ | 1335 | return; /* Peer is not requested */ |
1330 | 1336 | ||
1331 | /* This peer is requested, find best address */ | 1337 | /* This peer is requested, find best address */ |
1332 | active_address = get_active_address(s, s->addresses, peer); | 1338 | active_address = get_active_address (s, s->addresses, peer); |
1333 | best_address = (struct ATS_Address *) update_active_address (s, peer); | 1339 | best_address = update_active_address (s, peer); |
1334 | 1340 | ||
1335 | if ((NULL != best_address) && ((NULL != active_address) && | 1341 | if ((NULL != best_address) && ((NULL != active_address) && |
1336 | (GNUNET_YES == address_eq (active_address, best_address)))) | 1342 | (GNUNET_YES == address_eq (active_address, best_address)))) |
@@ -1383,18 +1389,18 @@ GAS_proportional_get_preferred_address (void *solver, | |||
1383 | struct GAS_PROPORTIONAL_Handle *s = solver; | 1389 | struct GAS_PROPORTIONAL_Handle *s = solver; |
1384 | const struct ATS_Address *best_address; | 1390 | const struct ATS_Address *best_address; |
1385 | 1391 | ||
1386 | |||
1387 | GNUNET_assert(s != NULL); | ||
1388 | GNUNET_assert(peer != NULL); | ||
1389 | |||
1390 | /* Add to list of pending requests */ | 1392 | /* Add to list of pending requests */ |
1391 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests, peer)) | 1393 | if (GNUNET_NO == |
1394 | GNUNET_CONTAINER_multipeermap_contains (s->requests, peer)) | ||
1392 | { | 1395 | { |
1393 | GNUNET_assert( | 1396 | GNUNET_assert (GNUNET_OK == |
1394 | GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (s->requests, peer, NULL, | 1397 | GNUNET_CONTAINER_multipeermap_put (s->requests, |
1398 | peer, | ||
1399 | NULL, | ||
1395 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1400 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1396 | LOG (GNUNET_ERROR_TYPE_INFO, "Start suggesting addresses for peer `%s'\n", | 1401 | LOG (GNUNET_ERROR_TYPE_INFO, |
1397 | GNUNET_i2s (peer)); | 1402 | "Start suggesting addresses for peer `%s'\n", |
1403 | GNUNET_i2s (peer)); | ||
1398 | } | 1404 | } |
1399 | 1405 | ||
1400 | best_address = update_active_address (s, peer); | 1406 | best_address = update_active_address (s, peer); |
@@ -1420,23 +1426,28 @@ GAS_proportional_stop_get_preferred_address (void *solver, | |||
1420 | struct AddressSolverInformation *asi; | 1426 | struct AddressSolverInformation *asi; |
1421 | struct Network *cur_net; | 1427 | struct Network *cur_net; |
1422 | 1428 | ||
1423 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (s->requests, peer)) | 1429 | if (GNUNET_YES == |
1430 | GNUNET_CONTAINER_multipeermap_contains (s->requests, peer)) | ||
1424 | { | 1431 | { |
1425 | GNUNET_assert (GNUNET_OK == | 1432 | GNUNET_assert (GNUNET_OK == |
1426 | GNUNET_CONTAINER_multipeermap_remove (s->requests, | 1433 | GNUNET_CONTAINER_multipeermap_remove (s->requests, |
1427 | peer, NULL)); | 1434 | peer, |
1435 | NULL)); | ||
1428 | LOG (GNUNET_ERROR_TYPE_INFO, | 1436 | LOG (GNUNET_ERROR_TYPE_INFO, |
1429 | "Stop suggesting addresses for peer `%s'\n", | 1437 | "Stop suggesting addresses for peer `%s'\n", |
1430 | GNUNET_i2s (peer)); | 1438 | GNUNET_i2s (peer)); |
1431 | } | 1439 | } |
1432 | 1440 | ||
1433 | cur = get_active_address (s, s->addresses, peer); | 1441 | cur = get_active_address (s, |
1442 | s->addresses, | ||
1443 | peer); | ||
1434 | if (NULL != cur) | 1444 | if (NULL != cur) |
1435 | { | 1445 | { |
1436 | LOG(GNUNET_ERROR_TYPE_INFO, | 1446 | LOG (GNUNET_ERROR_TYPE_INFO, |
1437 | "Disabling %s address %p for peer `%s'\n", | 1447 | "Disabling %s address %p for peer `%s'\n", |
1438 | (GNUNET_NO == cur->active) ? "inactive" : "active", cur, | 1448 | (GNUNET_NO == cur->active) ? "inactive" : "active", |
1439 | GNUNET_i2s (&cur->peer)); | 1449 | cur, |
1450 | GNUNET_i2s (&cur->peer)); | ||
1440 | 1451 | ||
1441 | /* Disabling current address */ | 1452 | /* Disabling current address */ |
1442 | asi = cur->solver_information; | 1453 | asi = cur->solver_information; |
@@ -1446,12 +1457,12 @@ GAS_proportional_stop_get_preferred_address (void *solver, | |||
1446 | cur->assigned_bw_in = 0; /* no bandwidth assigned */ | 1457 | cur->assigned_bw_in = 0; /* no bandwidth assigned */ |
1447 | cur->assigned_bw_out = 0; /* no bandwidth assigned */ | 1458 | cur->assigned_bw_out = 0; /* no bandwidth assigned */ |
1448 | 1459 | ||
1449 | if (GNUNET_SYSERR == addresse_decrement (s, cur_net, GNUNET_NO, GNUNET_YES)) | 1460 | if (GNUNET_SYSERR == |
1461 | addresse_decrement (s, cur_net, GNUNET_NO, GNUNET_YES)) | ||
1450 | GNUNET_break(0); | 1462 | GNUNET_break(0); |
1451 | 1463 | ||
1452 | distribute_bandwidth_in_network (s, cur_net ); | 1464 | distribute_bandwidth_in_network (s, cur_net); |
1453 | } | 1465 | } |
1454 | return; | ||
1455 | } | 1466 | } |
1456 | 1467 | ||
1457 | 1468 | ||
@@ -1490,11 +1501,14 @@ GAS_proportional_address_delete (void *solver, | |||
1490 | 1501 | ||
1491 | if (GNUNET_NO == session_only) | 1502 | if (GNUNET_NO == session_only) |
1492 | { | 1503 | { |
1493 | LOG(GNUNET_ERROR_TYPE_INFO, | 1504 | LOG (GNUNET_ERROR_TYPE_INFO, |
1494 | "Deleting %s address %p for peer `%s' from network `%s' (total: %u/ active: %u)\n", | 1505 | "Deleting %s address %p for peer `%s' from network `%s' (total: %u/ active: %u)\n", |
1495 | (GNUNET_NO == address->active) ? "inactive" : "active", address, | 1506 | (GNUNET_NO == address->active) ? "inactive" : "active", |
1496 | GNUNET_i2s (&address->peer), net->desc, net->total_addresses, | 1507 | address, |
1497 | net->active_addresses); | 1508 | GNUNET_i2s (&address->peer), |
1509 | net->desc, | ||
1510 | net->total_addresses, | ||
1511 | net->active_addresses); | ||
1498 | 1512 | ||
1499 | /* Remove address */ | 1513 | /* Remove address */ |
1500 | addresse_decrement (s, net, GNUNET_YES, GNUNET_NO); | 1514 | addresse_decrement (s, net, GNUNET_YES, GNUNET_NO); |
@@ -1508,42 +1522,48 @@ GAS_proportional_address_delete (void *solver, | |||
1508 | GNUNET_break(0); | 1522 | GNUNET_break(0); |
1509 | return; | 1523 | return; |
1510 | } | 1524 | } |
1511 | GNUNET_CONTAINER_DLL_remove(net->head, net->tail, aw); | 1525 | GNUNET_CONTAINER_DLL_remove (net->head, |
1512 | GNUNET_free(aw); | 1526 | net->tail, |
1527 | aw); | ||
1528 | GNUNET_free (aw); | ||
1513 | } | 1529 | } |
1514 | else | 1530 | else |
1515 | { | 1531 | { |
1516 | /* Remove session only: remove if active and update */ | 1532 | /* Remove session only: remove if active and update */ |
1517 | LOG(GNUNET_ERROR_TYPE_INFO, | 1533 | LOG (GNUNET_ERROR_TYPE_INFO, |
1518 | "Deleting %s session %p for peer `%s' from network `%s' (total: %u/ active: %u)\n", | 1534 | "Deleting %s session %p for peer `%s' from network `%s' (total: %u/ active: %u)\n", |
1519 | (GNUNET_NO == address->active) ? "inactive" : "active", address, | 1535 | (GNUNET_NO == address->active) ? "inactive" : "active", |
1520 | GNUNET_i2s (&address->peer), net->desc, net->total_addresses, | 1536 | address, |
1521 | net->active_addresses); | 1537 | GNUNET_i2s (&address->peer), |
1538 | net->desc, | ||
1539 | net->total_addresses, | ||
1540 | net->active_addresses); | ||
1522 | } | 1541 | } |
1523 | 1542 | ||
1524 | if (GNUNET_YES == address->active) | 1543 | if (GNUNET_YES == address->active) |
1525 | { | 1544 | { |
1526 | /* Address was active, remove from network and update quotas*/ | 1545 | /* Address was active, remove from network and update quotas*/ |
1527 | address->active = GNUNET_NO; | 1546 | address->active = GNUNET_NO; |
1528 | |||
1529 | address->assigned_bw_in = 0; | 1547 | address->assigned_bw_in = 0; |
1530 | address->assigned_bw_out = 0; | 1548 | address->assigned_bw_out = 0; |
1531 | asi->calculated_quota_in = 0; | 1549 | asi->calculated_quota_in = 0; |
1532 | asi->calculated_quota_out = 0; | 1550 | asi->calculated_quota_out = 0; |
1533 | 1551 | ||
1534 | if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES)) | 1552 | if (GNUNET_SYSERR == |
1553 | addresse_decrement (s, net, GNUNET_NO, GNUNET_YES)) | ||
1535 | GNUNET_break(0); | 1554 | GNUNET_break(0); |
1536 | distribute_bandwidth_in_network (s, net); | 1555 | distribute_bandwidth_in_network (s, net); |
1537 | 1556 | ||
1538 | if (NULL == update_active_address (s, &address->peer)) | 1557 | if (NULL == |
1558 | update_active_address (s, &address->peer)) | ||
1539 | { | 1559 | { |
1540 | /* No alternative address found, disconnect peer */ | 1560 | /* No alternative address found, disconnect peer */ |
1541 | LOG (GNUNET_ERROR_TYPE_INFO, | 1561 | LOG (GNUNET_ERROR_TYPE_INFO, |
1542 | "Disconnecting peer `%s' after deleting previous %s address %p\n", | 1562 | "Disconnecting peer `%s' after deleting previous address %p\n", |
1543 | GNUNET_i2s (&address->peer), | 1563 | GNUNET_i2s (&address->peer), |
1544 | (GNUNET_NO == address->active) ? "inactive" : "active", | 1564 | address); |
1545 | address); | 1565 | s->bw_changed (s->bw_changed_cls, |
1546 | s->bw_changed (s->bw_changed_cls, address); | 1566 | address); |
1547 | } | 1567 | } |
1548 | } | 1568 | } |
1549 | if (GNUNET_NO == session_only) | 1569 | if (GNUNET_NO == session_only) |
@@ -1552,10 +1572,11 @@ GAS_proportional_address_delete (void *solver, | |||
1552 | address->solver_information = NULL; | 1572 | address->solver_information = NULL; |
1553 | } | 1573 | } |
1554 | 1574 | ||
1555 | LOG(GNUNET_ERROR_TYPE_INFO, | 1575 | LOG (GNUNET_ERROR_TYPE_INFO, |
1556 | "After deleting address now total %u and active %u addresses in network `%s'\n", | 1576 | "After deleting address now total %u and active %u addresses in network `%s'\n", |
1557 | net->total_addresses, net->active_addresses, net->desc); | 1577 | net->total_addresses, |
1558 | 1578 | net->active_addresses, | |
1579 | net->desc); | ||
1559 | } | 1580 | } |
1560 | 1581 | ||
1561 | 1582 | ||
@@ -1571,7 +1592,7 @@ GAS_proportional_bulk_start (void *solver) | |||
1571 | 1592 | ||
1572 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1593 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1573 | "Locking solver for bulk operation ...\n"); | 1594 | "Locking solver for bulk operation ...\n"); |
1574 | GNUNET_assert(NULL != solver); | 1595 | GNUNET_assert (NULL != solver); |
1575 | s->bulk_lock++; | 1596 | s->bulk_lock++; |
1576 | } | 1597 | } |
1577 | 1598 | ||
@@ -1586,8 +1607,6 @@ GAS_proportional_bulk_stop (void *solver) | |||
1586 | 1607 | ||
1587 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1608 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1588 | "Unlocking solver from bulk operation ...\n"); | 1609 | "Unlocking solver from bulk operation ...\n"); |
1589 | GNUNET_assert(NULL != solver); | ||
1590 | |||
1591 | if (s->bulk_lock < 1) | 1610 | if (s->bulk_lock < 1) |
1592 | { | 1611 | { |
1593 | GNUNET_break(0); | 1612 | GNUNET_break(0); |
@@ -1638,8 +1657,6 @@ GAS_proportional_address_property_changed (void *solver, | |||
1638 | struct ATS_Address *best_address; | 1657 | struct ATS_Address *best_address; |
1639 | struct ATS_Address *active_address; | 1658 | struct ATS_Address *active_address; |
1640 | 1659 | ||
1641 | GNUNET_assert(NULL != s); | ||
1642 | GNUNET_assert(NULL != address); | ||
1643 | asi = address->solver_information; | 1660 | asi = address->solver_information; |
1644 | if (NULL == asi) | 1661 | if (NULL == asi) |
1645 | { | 1662 | { |
@@ -1664,7 +1681,8 @@ GAS_proportional_address_property_changed (void *solver, | |||
1664 | 1681 | ||
1665 | /* This peer is requested, find active and best address */ | 1682 | /* This peer is requested, find active and best address */ |
1666 | active_address = get_active_address(s, s->addresses, &address->peer); | 1683 | active_address = get_active_address(s, s->addresses, &address->peer); |
1667 | best_address = (struct ATS_Address *) update_active_address (s, &address->peer); | 1684 | best_address = update_active_address (s, |
1685 | &address->peer); | ||
1668 | 1686 | ||
1669 | if ((NULL != best_address) && ((NULL != active_address) && | 1687 | if ((NULL != best_address) && ((NULL != active_address) && |
1670 | (GNUNET_YES == address_eq (active_address, best_address)))) | 1688 | (GNUNET_YES == address_eq (active_address, best_address)))) |
@@ -1712,12 +1730,13 @@ GAS_proportional_address_session_changed (void *solver, | |||
1712 | return; | 1730 | return; |
1713 | } | 1731 | } |
1714 | 1732 | ||
1715 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer)) | 1733 | if (GNUNET_NO == |
1734 | GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer)) | ||
1716 | return; /* Peer is not requested */ | 1735 | return; /* Peer is not requested */ |
1717 | 1736 | ||
1718 | /* This peer is requested, find active and best address */ | 1737 | /* This peer is requested, find active and best address */ |
1719 | active_address = get_active_address(s, s->addresses, &address->peer); | 1738 | active_address = get_active_address (s, s->addresses, &address->peer); |
1720 | best_address = (struct ATS_Address *) update_active_address (s, &address->peer); | 1739 | best_address = update_active_address (s, &address->peer); |
1721 | 1740 | ||
1722 | if ((NULL != best_address) && ((NULL != active_address) && | 1741 | if ((NULL != best_address) && ((NULL != active_address) && |
1723 | (GNUNET_YES == address_eq (active_address, best_address)))) | 1742 | (GNUNET_YES == address_eq (active_address, best_address)))) |
@@ -1732,65 +1751,6 @@ GAS_proportional_address_session_changed (void *solver, | |||
1732 | 1751 | ||
1733 | 1752 | ||
1734 | /** | 1753 | /** |
1735 | * Usage for this address has changed | ||
1736 | * | ||
1737 | * NOTE: values in addresses are already updated | ||
1738 | * | ||
1739 | * @param solver solver handle | ||
1740 | * @param address the address | ||
1741 | * @param in_use usage state | ||
1742 | */ | ||
1743 | static void | ||
1744 | GAS_proportional_address_inuse_changed (void *solver, | ||
1745 | struct ATS_Address *address, | ||
1746 | int in_use) | ||
1747 | { | ||
1748 | struct GAS_PROPORTIONAL_Handle *s = solver; | ||
1749 | struct Network *n; | ||
1750 | struct AddressSolverInformation *asi; | ||
1751 | struct ATS_Address *best_address; | ||
1752 | struct ATS_Address *active_address; | ||
1753 | |||
1754 | GNUNET_assert(NULL != s); | ||
1755 | GNUNET_assert(NULL != address); | ||
1756 | asi = address->solver_information; | ||
1757 | if (NULL == asi) | ||
1758 | { | ||
1759 | GNUNET_break(0); | ||
1760 | return; | ||
1761 | } | ||
1762 | |||
1763 | n = asi->network; | ||
1764 | if (NULL == n) | ||
1765 | { | ||
1766 | GNUNET_break(0); | ||
1767 | return; | ||
1768 | } | ||
1769 | |||
1770 | LOG(GNUNET_ERROR_TYPE_INFO, | ||
1771 | "Usage of peer `%s' address %p changed to %s \n", | ||
1772 | GNUNET_i2s (&address->peer), address, | ||
1773 | (GNUNET_YES == in_use) ? "YES" : "NO"); | ||
1774 | |||
1775 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer)) | ||
1776 | return; /* Peer is not requested */ | ||
1777 | |||
1778 | /* This peer is requested, find active and best address */ | ||
1779 | active_address = get_active_address(s, s->addresses, &address->peer); | ||
1780 | best_address = (struct ATS_Address *) update_active_address (s, &address->peer); | ||
1781 | |||
1782 | if ((NULL != best_address) && ((NULL != active_address) && | ||
1783 | (GNUNET_YES == address_eq (active_address, best_address)))) | ||
1784 | { | ||
1785 | asi = best_address->solver_information; | ||
1786 | GNUNET_assert (NULL != asi); | ||
1787 | |||
1788 | /* We sticked to the same address, therefore redistribute */ | ||
1789 | distribute_bandwidth_in_network (s, asi->network); | ||
1790 | } | ||
1791 | } | ||
1792 | |||
1793 | /** | ||
1794 | * Network scope for this address has changed | 1754 | * Network scope for this address has changed |
1795 | * | 1755 | * |
1796 | * NOTE: values in addresses are already updated | 1756 | * NOTE: values in addresses are already updated |
@@ -1955,7 +1915,6 @@ libgnunet_plugin_ats_proportional_init (void *cls) | |||
1955 | env->sf.s_add = &GAS_proportional_address_add; | 1915 | env->sf.s_add = &GAS_proportional_address_add; |
1956 | env->sf.s_address_update_property = &GAS_proportional_address_property_changed; | 1916 | env->sf.s_address_update_property = &GAS_proportional_address_property_changed; |
1957 | env->sf.s_address_update_session = &GAS_proportional_address_session_changed; | 1917 | env->sf.s_address_update_session = &GAS_proportional_address_session_changed; |
1958 | env->sf.s_address_update_inuse = &GAS_proportional_address_inuse_changed; | ||
1959 | env->sf.s_address_update_network = &GAS_proportional_address_change_network; | 1918 | env->sf.s_address_update_network = &GAS_proportional_address_change_network; |
1960 | env->sf.s_get = &GAS_proportional_get_preferred_address; | 1919 | env->sf.s_get = &GAS_proportional_get_preferred_address; |
1961 | env->sf.s_get_stop = &GAS_proportional_stop_get_preferred_address; | 1920 | env->sf.s_get_stop = &GAS_proportional_stop_get_preferred_address; |
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index c87876ea1..5c396e82e 100644 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c | |||
@@ -2166,7 +2166,7 @@ GAS_ril_address_change_preference (void *solver, | |||
2166 | * @param network network type of this address | 2166 | * @param network network type of this address |
2167 | */ | 2167 | */ |
2168 | static void | 2168 | static void |
2169 | GAS_ril_address_add (void *solver, | 2169 | GAS_ril_address_add (void *solver, |
2170 | struct ATS_Address *address, | 2170 | struct ATS_Address *address, |
2171 | uint32_t network) | 2171 | uint32_t network) |
2172 | { | 2172 | { |
@@ -2181,7 +2181,7 @@ GAS_ril_address_add (void *solver, | |||
2181 | int i; | 2181 | int i; |
2182 | unsigned int zero; | 2182 | unsigned int zero; |
2183 | 2183 | ||
2184 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2184 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2185 | "API_address_add()\n"); | 2185 | "API_address_add()\n"); |
2186 | 2186 | ||
2187 | net = ril_get_network (s, network); | 2187 | net = ril_get_network (s, network); |
@@ -2256,7 +2256,7 @@ GAS_ril_address_add (void *solver, | |||
2256 | */ | 2256 | */ |
2257 | static void | 2257 | static void |
2258 | GAS_ril_address_delete (void *solver, | 2258 | GAS_ril_address_delete (void *solver, |
2259 | struct ATS_Address *address, | 2259 | struct ATS_Address *address, |
2260 | int session_only) | 2260 | int session_only) |
2261 | { | 2261 | { |
2262 | struct GAS_RIL_Handle *s = solver; | 2262 | struct GAS_RIL_Handle *s = solver; |
@@ -2272,7 +2272,7 @@ GAS_ril_address_delete (void *solver, | |||
2272 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2272 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2273 | "API_address_delete() Delete %s%s %s address %s for peer '%s'\n", | 2273 | "API_address_delete() Delete %s%s %s address %s for peer '%s'\n", |
2274 | session_only ? "session for " : "", address->active ? "active" : "inactive", address->plugin, | 2274 | session_only ? "session for " : "", address->active ? "active" : "inactive", address->plugin, |
2275 | address->addr, | 2275 | address->addr, |
2276 | GNUNET_i2s (&address->peer)); | 2276 | GNUNET_i2s (&address->peer)); |
2277 | 2277 | ||
2278 | agent = ril_get_agent (s, &address->peer, GNUNET_NO); | 2278 | agent = ril_get_agent (s, &address->peer, GNUNET_NO); |
@@ -2373,7 +2373,7 @@ GAS_ril_address_property_changed (void *solver, | |||
2373 | 2373 | ||
2374 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2374 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
2375 | "API_address_property_changed() Property '%s' for peer '%s' address %s changed " | 2375 | "API_address_property_changed() Property '%s' for peer '%s' address %s changed " |
2376 | "to %.2f \n", | 2376 | "to %.2f \n", |
2377 | GNUNET_ATS_print_property_type (type), | 2377 | GNUNET_ATS_print_property_type (type), |
2378 | GNUNET_i2s (&address->peer), | 2378 | GNUNET_i2s (&address->peer), |
2379 | address->addr, rel_value); | 2379 | address->addr, rel_value); |
@@ -2407,27 +2407,6 @@ GAS_ril_address_session_changed (void *solver, | |||
2407 | 2407 | ||
2408 | 2408 | ||
2409 | /** | 2409 | /** |
2410 | * Notify the solver that an address is (not) actively used by transport | ||
2411 | * to communicate with a remote peer | ||
2412 | * | ||
2413 | * NOTE: values in addresses are already updated | ||
2414 | * | ||
2415 | * @param solver solver handle | ||
2416 | * @param address the address | ||
2417 | * @param in_use usage state | ||
2418 | */ | ||
2419 | static void | ||
2420 | GAS_ril_address_inuse_changed (void *solver, | ||
2421 | struct ATS_Address *address, | ||
2422 | int in_use) | ||
2423 | { | ||
2424 | LOG(GNUNET_ERROR_TYPE_DEBUG, | ||
2425 | "API_address_inuse_changed() Usage for %s address of peer '%s' changed to %s\n", | ||
2426 | address->plugin, GNUNET_i2s (&address->peer), (GNUNET_YES == in_use) ? "USED" : "UNUSED"); | ||
2427 | } | ||
2428 | |||
2429 | |||
2430 | /** | ||
2431 | * Notify solver that the network an address is located in has changed | 2410 | * Notify solver that the network an address is located in has changed |
2432 | * | 2411 | * |
2433 | * NOTE: values in addresses are already updated | 2412 | * NOTE: values in addresses are already updated |
@@ -2446,7 +2425,7 @@ GAS_ril_address_change_network (void *solver, | |||
2446 | struct GAS_RIL_Handle *s = solver; | 2425 | struct GAS_RIL_Handle *s = solver; |
2447 | struct RIL_Peer_Agent *agent; | 2426 | struct RIL_Peer_Agent *agent; |
2448 | 2427 | ||
2449 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2428 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
2450 | "API_address_change_network() Network type changed, moving " | 2429 | "API_address_change_network() Network type changed, moving " |
2451 | "%s address of peer %s from '%s' to '%s'\n", | 2430 | "%s address of peer %s from '%s' to '%s'\n", |
2452 | (GNUNET_YES == address->active) ? "active" : "inactive", GNUNET_i2s (&address->peer), | 2431 | (GNUNET_YES == address->active) ? "active" : "inactive", GNUNET_i2s (&address->peer), |
@@ -2526,8 +2505,8 @@ GAS_ril_bulk_stop (void *solver) | |||
2526 | { | 2505 | { |
2527 | struct GAS_RIL_Handle *s = solver; | 2506 | struct GAS_RIL_Handle *s = solver; |
2528 | 2507 | ||
2529 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2508 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
2530 | "API_bulk_stop() lock: %d\n", | 2509 | "API_bulk_stop() lock: %d\n", |
2531 | s->bulk_lock - 1); | 2510 | s->bulk_lock - 1); |
2532 | 2511 | ||
2533 | if (s->bulk_lock < 1) | 2512 | if (s->bulk_lock < 1) |
@@ -2604,7 +2583,7 @@ GAS_ril_stop_get_preferred_address (void *solver, | |||
2604 | struct GAS_RIL_Handle *s = solver; | 2583 | struct GAS_RIL_Handle *s = solver; |
2605 | struct RIL_Peer_Agent *agent; | 2584 | struct RIL_Peer_Agent *agent; |
2606 | 2585 | ||
2607 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2586 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2608 | "API_stop_get_preferred_address()"); | 2587 | "API_stop_get_preferred_address()"); |
2609 | 2588 | ||
2610 | agent = ril_get_agent (s, peer, GNUNET_NO); | 2589 | agent = ril_get_agent (s, peer, GNUNET_NO); |
@@ -2872,7 +2851,6 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2872 | env->sf.s_add = &GAS_ril_address_add; | 2851 | env->sf.s_add = &GAS_ril_address_add; |
2873 | env->sf.s_address_update_property = &GAS_ril_address_property_changed; | 2852 | env->sf.s_address_update_property = &GAS_ril_address_property_changed; |
2874 | env->sf.s_address_update_session = &GAS_ril_address_session_changed; | 2853 | env->sf.s_address_update_session = &GAS_ril_address_session_changed; |
2875 | env->sf.s_address_update_inuse = &GAS_ril_address_inuse_changed; | ||
2876 | env->sf.s_address_update_network = &GAS_ril_address_change_network; | 2854 | env->sf.s_address_update_network = &GAS_ril_address_change_network; |
2877 | env->sf.s_get = &GAS_ril_get_preferred_address; | 2855 | env->sf.s_get = &GAS_ril_get_preferred_address; |
2878 | env->sf.s_get_stop = &GAS_ril_stop_get_preferred_address; | 2856 | env->sf.s_get_stop = &GAS_ril_stop_get_preferred_address; |