diff options
author | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-10-09 10:01:05 +0000 |
---|---|---|
committer | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-10-09 10:01:05 +0000 |
commit | b9839a135dd632f419475b5db7637e6e3bbe67d1 (patch) | |
tree | 1a86dd94e6be8a050353eb6dacbbb9b319e07218 /src | |
parent | 00dfa7c87e756ae8f301d59896850e1cb1a3e611 (diff) | |
download | gnunet-b9839a135dd632f419475b5db7637e6e3bbe67d1.tar.gz gnunet-b9839a135dd632f419475b5db7637e6e3bbe67d1.zip |
ats_ril: - removed some redundantly saved plugin environment attributes
Diffstat (limited to 'src')
-rwxr-xr-x | src/ats/libgnunet_plugin_ats_ril.c | 164 |
1 files changed, 64 insertions, 100 deletions
diff --git a/src/ats/libgnunet_plugin_ats_ril.c b/src/ats/libgnunet_plugin_ats_ril.c index 6d2bb5e31..5f03d17d7 100755 --- a/src/ats/libgnunet_plugin_ats_ril.c +++ b/src/ats/libgnunet_plugin_ats_ril.c | |||
@@ -242,39 +242,6 @@ struct RIL_Network | |||
242 | unsigned long long bw_out_assigned; | 242 | unsigned long long bw_out_assigned; |
243 | }; | 243 | }; |
244 | 244 | ||
245 | struct RIL_Callbacks | ||
246 | { | ||
247 | /** | ||
248 | * Bandwidth changed callback | ||
249 | */ | ||
250 | GAS_bandwidth_changed_cb bw_changed; | ||
251 | |||
252 | /** | ||
253 | * Bandwidth changed callback cls | ||
254 | */ | ||
255 | void *bw_changed_cls; | ||
256 | |||
257 | /** | ||
258 | * ATS function to get preferences for a peer | ||
259 | */ | ||
260 | GAS_get_preferences get_preferences; | ||
261 | |||
262 | /** | ||
263 | * Closure for ATS function to get preferences | ||
264 | */ | ||
265 | void *get_preferences_cls; | ||
266 | |||
267 | /** | ||
268 | * ATS function to get properties of an address | ||
269 | */ | ||
270 | GAS_get_properties get_properties; | ||
271 | |||
272 | /** | ||
273 | * Closure for ATS function to get properties | ||
274 | */ | ||
275 | void *get_properties_cls; | ||
276 | }; | ||
277 | |||
278 | /** | 245 | /** |
279 | * A handle for the reinforcement learning solver | 246 | * A handle for the reinforcement learning solver |
280 | */ | 247 | */ |
@@ -291,16 +258,6 @@ struct GAS_RIL_Handle | |||
291 | struct GNUNET_STATISTICS_Handle *stats; | 258 | struct GNUNET_STATISTICS_Handle *stats; |
292 | 259 | ||
293 | /** | 260 | /** |
294 | * Hashmap containing all valid addresses | ||
295 | */ | ||
296 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses; | ||
297 | |||
298 | /** | ||
299 | * Callbacks for the solver | ||
300 | */ | ||
301 | struct RIL_Callbacks *callbacks; | ||
302 | |||
303 | /** | ||
304 | * Number of performed time-steps | 261 | * Number of performed time-steps |
305 | */ | 262 | */ |
306 | unsigned long long step_count; | 263 | unsigned long long step_count; |
@@ -379,19 +336,19 @@ agent_decide_exploration (struct RIL_Peer_Agent *agent) | |||
379 | double r = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 336 | double r = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
380 | UINT32_MAX) / (double) UINT32_MAX; | 337 | UINT32_MAX) / (double) UINT32_MAX; |
381 | 338 | ||
382 | if (r < RIL_EXPLORE_RATIO) | 339 | if (r < RIL_EXPLORE_RATIO) |
383 | { | 340 | { |
384 | return GNUNET_YES; | 341 | return GNUNET_YES; |
385 | } | 342 | } |
386 | return GNUNET_NO; | 343 | return GNUNET_NO; |
387 | } | 344 | } |
388 | 345 | ||
389 | /** | 346 | /** |
390 | * Get the index of the address in the agent's list. | 347 | * Get the index of the address in the agent's list. |
391 | * @param agent agent handle | 348 | * @param agent agent handle |
392 | * @param address address handle | 349 | * @param address address handle |
393 | * @return the index, starting with zero | 350 | * @return the index, starting with zero |
394 | */ | 351 | */ |
395 | static int | 352 | static int |
396 | agent_address_get_index (struct RIL_Peer_Agent *agent, struct ATS_Address *address) | 353 | agent_address_get_index (struct RIL_Peer_Agent *agent, struct ATS_Address *address) |
397 | { | 354 | { |
@@ -555,7 +512,7 @@ envi_set_active_suggestion (struct GAS_RIL_Handle *solver, | |||
555 | { | 512 | { |
556 | int notify = GNUNET_NO; | 513 | int notify = GNUNET_NO; |
557 | 514 | ||
558 | LOG (GNUNET_ERROR_TYPE_DEBUG, "set_active_suggestion()\n"); | 515 | LOG(GNUNET_ERROR_TYPE_DEBUG, "set_active_suggestion()\n"); |
559 | 516 | ||
560 | //address change | 517 | //address change |
561 | if (agent->address_inuse != new_address) | 518 | if (agent->address_inuse != new_address) |
@@ -568,7 +525,7 @@ envi_set_active_suggestion (struct GAS_RIL_Handle *solver, | |||
568 | } | 525 | } |
569 | if (NULL != new_address) | 526 | if (NULL != new_address) |
570 | { | 527 | { |
571 | LOG (GNUNET_ERROR_TYPE_DEBUG, "set address active: %s\n", agent->active ? "yes" : "no"); | 528 | LOG(GNUNET_ERROR_TYPE_DEBUG, "set address active: %s\n", agent->active ? "yes" : "no"); |
572 | new_address->active = agent->active; | 529 | new_address->active = agent->active; |
573 | new_address->assigned_bw_in.value__ = htonl (agent->bw_in); | 530 | new_address->assigned_bw_in.value__ = htonl (agent->bw_in); |
574 | new_address->assigned_bw_out.value__ = htonl (agent->bw_out); | 531 | new_address->assigned_bw_out.value__ = htonl (agent->bw_out); |
@@ -603,16 +560,18 @@ envi_set_active_suggestion (struct GAS_RIL_Handle *solver, | |||
603 | { | 560 | { |
604 | if (new_address) | 561 | if (new_address) |
605 | { | 562 | { |
606 | solver->callbacks->bw_changed (solver->callbacks->bw_changed_cls, new_address); | 563 | solver->plugin_envi->bandwidth_changed_cb (solver->plugin_envi->bw_changed_cb_cls, |
564 | new_address); | ||
607 | } | 565 | } |
608 | else | 566 | else |
609 | { | 567 | { |
610 | GNUNET_assert (0 == ntohl(agent->address_inuse->assigned_bw_in.value__)); | 568 | GNUNET_assert(0 == ntohl (agent->address_inuse->assigned_bw_in.value__)); |
611 | GNUNET_assert (0 == ntohl(agent->address_inuse->assigned_bw_out.value__)); | 569 | GNUNET_assert(0 == ntohl (agent->address_inuse->assigned_bw_out.value__)); |
612 | agent->bw_in = 0; | 570 | agent->bw_in = 0; |
613 | agent->bw_out = 0; | 571 | agent->bw_out = 0; |
614 | //disconnect | 572 | //disconnect |
615 | solver->callbacks->bw_changed (solver->callbacks->bw_changed_cls, agent->address_inuse); | 573 | solver->plugin_envi->bandwidth_changed_cb (solver->plugin_envi->bw_changed_cb_cls, |
574 | agent->address_inuse); | ||
616 | } | 575 | } |
617 | } | 576 | } |
618 | agent->address_inuse = new_address; | 577 | agent->address_inuse = new_address; |
@@ -649,7 +608,8 @@ envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
649 | state[i++] = cur_address->address_naked->active; | 608 | state[i++] = cur_address->address_naked->active; |
650 | state[i++] = cur_address->address_naked->active ? agent->bw_in : 0; | 609 | state[i++] = cur_address->address_naked->active ? agent->bw_in : 0; |
651 | state[i++] = cur_address->address_naked->active ? agent->bw_out : 0; | 610 | state[i++] = cur_address->address_naked->active ? agent->bw_out : 0; |
652 | properties = solver->callbacks->get_properties (solver->callbacks->get_properties_cls, cur_address->address_naked); | 611 | properties = solver->plugin_envi->get_property (solver->plugin_envi->get_property_cls, |
612 | cur_address->address_naked); | ||
653 | for (k = 0; k < GNUNET_ATS_QualityPropertiesCount; k++) | 613 | for (k = 0; k < GNUNET_ATS_QualityPropertiesCount; k++) |
654 | { | 614 | { |
655 | state[i++] = properties[k]; | 615 | state[i++] = properties[k]; |
@@ -667,7 +627,7 @@ envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
667 | * @param direction_in whether the inbound bandwidth should be considered. Returns the maximum outbound bandwidth if GNUNET_NO | 627 | * @param direction_in whether the inbound bandwidth should be considered. Returns the maximum outbound bandwidth if GNUNET_NO |
668 | */ | 628 | */ |
669 | static long long unsigned | 629 | static long long unsigned |
670 | ril_get_max_bw(struct RIL_Peer_Agent *agent, int direction_in) | 630 | ril_get_max_bw (struct RIL_Peer_Agent *agent, int direction_in) |
671 | { | 631 | { |
672 | /* | 632 | /* |
673 | * get the maximum bandwidth possible for a peer, e.g. among all addresses which addresses' | 633 | * get the maximum bandwidth possible for a peer, e.g. among all addresses which addresses' |
@@ -732,16 +692,17 @@ envi_get_reward (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
732 | struct RIL_Network *net; | 692 | struct RIL_Network *net; |
733 | int prop_index; | 693 | int prop_index; |
734 | 694 | ||
735 | preferences = solver->callbacks->get_preferences (solver->callbacks->get_preferences_cls, &agent->peer); | 695 | preferences = solver->plugin_envi->get_preferences (solver->plugin_envi->get_preference_cls, |
736 | properties = solver->callbacks->get_properties (solver->callbacks->get_properties_cls, | 696 | &agent->peer); |
697 | properties = solver->plugin_envi->get_property (solver->plugin_envi->get_property_cls, | ||
737 | agent->address_inuse); | 698 | agent->address_inuse); |
738 | prop_index = ril_find_property_index(GNUNET_ATS_QUALITY_NET_DELAY); | 699 | prop_index = ril_find_property_index (GNUNET_ATS_QUALITY_NET_DELAY); |
739 | pref_match += preferences[GNUNET_ATS_PREFERENCE_LATENCY] * properties[prop_index]; | 700 | pref_match += preferences[GNUNET_ATS_PREFERENCE_LATENCY] * properties[prop_index]; |
740 | bw_norm = GNUNET_MAX(2, ((( | 701 | bw_norm = GNUNET_MAX(2, ((( |
741 | ((double) agent->bw_in / (double) ril_get_max_bw(agent, GNUNET_YES)) + | 702 | ((double) agent->bw_in / (double) ril_get_max_bw(agent, GNUNET_YES)) + |
742 | ((double) agent->bw_out / (double) ril_get_max_bw(agent, GNUNET_NO)) | 703 | ((double) agent->bw_out / (double) ril_get_max_bw(agent, GNUNET_NO)) |
743 | ) / 2 | 704 | ) / 2 |
744 | ) + 1)); | 705 | ) + 1)); |
745 | pref_match += preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * bw_norm; | 706 | pref_match += preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * bw_norm; |
746 | 707 | ||
747 | net = agent->address_inuse->solver_information; | 708 | net = agent->address_inuse->solver_information; |
@@ -797,14 +758,16 @@ envi_action_bw_halven (struct GAS_RIL_Handle *solver, | |||
797 | new_bw = agent->bw_in / 2; | 758 | new_bw = agent->bw_in / 2; |
798 | if (new_bw < min_bw) | 759 | if (new_bw < min_bw) |
799 | new_bw = min_bw; | 760 | new_bw = min_bw; |
800 | envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out, GNUNET_NO); | 761 | envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out, |
762 | GNUNET_NO); | ||
801 | } | 763 | } |
802 | else | 764 | else |
803 | { | 765 | { |
804 | new_bw = agent->bw_out / 2; | 766 | new_bw = agent->bw_out / 2; |
805 | if (new_bw < min_bw) | 767 | if (new_bw < min_bw) |
806 | new_bw = min_bw; | 768 | new_bw = min_bw; |
807 | envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw, GNUNET_NO); | 769 | envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw, |
770 | GNUNET_NO); | ||
808 | } | 771 | } |
809 | } | 772 | } |
810 | 773 | ||
@@ -851,14 +814,16 @@ envi_action_bw_dec (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent, | |||
851 | new_bw = agent->bw_in - (5 * min_bw); | 814 | new_bw = agent->bw_in - (5 * min_bw); |
852 | if (new_bw < min_bw) | 815 | if (new_bw < min_bw) |
853 | new_bw = min_bw; | 816 | new_bw = min_bw; |
854 | envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out, GNUNET_NO); | 817 | envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out, |
818 | GNUNET_NO); | ||
855 | } | 819 | } |
856 | else | 820 | else |
857 | { | 821 | { |
858 | new_bw = agent->bw_out - (5 * min_bw); | 822 | new_bw = agent->bw_out - (5 * min_bw); |
859 | if (new_bw < min_bw) | 823 | if (new_bw < min_bw) |
860 | new_bw = min_bw; | 824 | new_bw = min_bw; |
861 | envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw, GNUNET_NO); | 825 | envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw, |
826 | GNUNET_NO); | ||
862 | } | 827 | } |
863 | } | 828 | } |
864 | 829 | ||
@@ -880,7 +845,8 @@ envi_action_address_switch (struct GAS_RIL_Handle *solver, | |||
880 | { | 845 | { |
881 | if (i == address_index) | 846 | if (i == address_index) |
882 | { | 847 | { |
883 | envi_set_active_suggestion (solver, agent, cur->address_naked, agent->bw_in, agent->bw_out, GNUNET_NO); | 848 | envi_set_active_suggestion (solver, agent, cur->address_naked, agent->bw_in, agent->bw_out, |
849 | GNUNET_NO); | ||
884 | return; | 850 | return; |
885 | } | 851 | } |
886 | 852 | ||
@@ -1111,9 +1077,7 @@ ril_get_agent (struct GAS_RIL_Handle *solver, const struct GNUNET_PeerIdentity * | |||
1111 | 1077 | ||
1112 | for (cur = solver->agents_head; NULL != cur; cur = cur->next) | 1078 | for (cur = solver->agents_head; NULL != cur; cur = cur->next) |
1113 | { | 1079 | { |
1114 | if (0 == memcmp (peer, | 1080 | if (0 == memcmp (peer, &cur->peer, sizeof(struct GNUNET_PeerIdentity))) |
1115 | &cur->peer, | ||
1116 | sizeof (struct GNUNET_PeerIdentity))) | ||
1117 | { | 1081 | { |
1118 | return cur; | 1082 | return cur; |
1119 | } | 1083 | } |
@@ -1249,7 +1213,7 @@ void * | |||
1249 | libgnunet_plugin_ats_ril_init (void *cls) | 1213 | libgnunet_plugin_ats_ril_init (void *cls) |
1250 | { | 1214 | { |
1251 | struct GNUNET_ATS_PluginEnvironment *env = cls; | 1215 | struct GNUNET_ATS_PluginEnvironment *env = cls; |
1252 | struct GAS_RIL_Handle *solver = GNUNET_new (struct GAS_RIL_Handle);; | 1216 | struct GAS_RIL_Handle *solver = GNUNET_new (struct GAS_RIL_Handle); |
1253 | struct RIL_Network * cur; | 1217 | struct RIL_Network * cur; |
1254 | int c; | 1218 | int c; |
1255 | unsigned long long tmp; | 1219 | unsigned long long tmp; |
@@ -1278,7 +1242,8 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
1278 | { | 1242 | { |
1279 | solver->parameters.algorithm = RIL_DEFAULT_ALGORITHM; | 1243 | solver->parameters.algorithm = RIL_DEFAULT_ALGORITHM; |
1280 | } | 1244 | } |
1281 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats", "RIL_DISCOUNT_FACTOR", &tmp)) | 1245 | if (GNUNET_OK |
1246 | == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats", "RIL_DISCOUNT_FACTOR", &tmp)) | ||
1282 | { | 1247 | { |
1283 | solver->parameters.gamma = (double) tmp / 100; | 1248 | solver->parameters.gamma = (double) tmp / 100; |
1284 | } | 1249 | } |
@@ -1286,7 +1251,8 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
1286 | { | 1251 | { |
1287 | solver->parameters.gamma = RIL_DEFAULT_DISCOUNT_FACTOR; | 1252 | solver->parameters.gamma = RIL_DEFAULT_DISCOUNT_FACTOR; |
1288 | } | 1253 | } |
1289 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats", "RIL_GRADIENT_STEP_SIZE", &tmp)) | 1254 | if (GNUNET_OK |
1255 | == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats", "RIL_GRADIENT_STEP_SIZE", &tmp)) | ||
1290 | { | 1256 | { |
1291 | solver->parameters.alpha = (double) tmp / 100; | 1257 | solver->parameters.alpha = (double) tmp / 100; |
1292 | } | 1258 | } |
@@ -1317,17 +1283,8 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
1317 | env->sf.s_bulk_stop = &GAS_ril_bulk_stop; | 1283 | env->sf.s_bulk_stop = &GAS_ril_bulk_stop; |
1318 | 1284 | ||
1319 | solver->plugin_envi = env; | 1285 | solver->plugin_envi = env; |
1320 | solver->stats = (struct GNUNET_STATISTICS_Handle *) env->stats; | ||
1321 | solver->callbacks = GNUNET_malloc (sizeof (struct RIL_Callbacks)); | ||
1322 | solver->callbacks->bw_changed = env->bandwidth_changed_cb; | ||
1323 | solver->callbacks->bw_changed_cls = env->bw_changed_cb_cls; | ||
1324 | solver->callbacks->get_preferences = env->get_preferences; | ||
1325 | solver->callbacks->get_preferences_cls = env->get_preference_cls; | ||
1326 | solver->callbacks->get_properties = env->get_property; | ||
1327 | solver->callbacks->get_properties_cls = env->get_property_cls; | ||
1328 | solver->networks_count = env->network_count; | 1286 | solver->networks_count = env->network_count; |
1329 | solver->network_entries = GNUNET_malloc (env->network_count * sizeof (struct RIL_Network)); | 1287 | solver->network_entries = GNUNET_malloc (env->network_count * sizeof (struct RIL_Network)); |
1330 | solver->addresses = env->addresses; | ||
1331 | solver->step_count = 0; | 1288 | solver->step_count = 0; |
1332 | 1289 | ||
1333 | for (c = 0; c < env->network_count; c++) | 1290 | for (c = 0; c < env->network_count; c++) |
@@ -1367,11 +1324,10 @@ libgnunet_plugin_ats_ril_done (void *cls) | |||
1367 | } | 1324 | } |
1368 | 1325 | ||
1369 | GNUNET_SCHEDULER_cancel (s->next_step); | 1326 | GNUNET_SCHEDULER_cancel (s->next_step); |
1370 | GNUNET_free(s->callbacks); | ||
1371 | GNUNET_free(s->network_entries); | 1327 | GNUNET_free(s->network_entries); |
1372 | GNUNET_free(s); | 1328 | GNUNET_free(s); |
1373 | 1329 | ||
1374 | return NULL; | 1330 | return NULL ; |
1375 | } | 1331 | } |
1376 | 1332 | ||
1377 | /** | 1333 | /** |
@@ -1450,8 +1406,8 @@ GAS_ril_address_add (void *solver, struct ATS_Address *address, uint32_t network | |||
1450 | } | 1406 | } |
1451 | 1407 | ||
1452 | LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_add() Added %s %s address %p for peer '%s'\n", | 1408 | LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_add() Added %s %s address %p for peer '%s'\n", |
1453 | address->active ? "active" : "inactive", | 1409 | address->active ? "active" : "inactive", address->plugin, address->addr, |
1454 | address->plugin, address->addr, GNUNET_i2s (&address->peer)); | 1410 | GNUNET_i2s (&address->peer)); |
1455 | } | 1411 | } |
1456 | 1412 | ||
1457 | /** | 1413 | /** |
@@ -1511,9 +1467,10 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o | |||
1511 | for (i = 0; i < agent->n; i++) | 1467 | for (i = 0; i < agent->n; i++) |
1512 | { | 1468 | { |
1513 | ril_cut_from_vector ((void **) &agent->W[i], sizeof(double), | 1469 | ril_cut_from_vector ((void **) &agent->W[i], sizeof(double), |
1514 | ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m); | 1470 | ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) |
1471 | + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m); | ||
1515 | } | 1472 | } |
1516 | GNUNET_free (agent->W[RIL_ACTION_TYPE_NUM + address_index]); | 1473 | GNUNET_free(agent->W[RIL_ACTION_TYPE_NUM + address_index]); |
1517 | ril_cut_from_vector ((void **) &agent->W, sizeof(double *), RIL_ACTION_TYPE_NUM + address_index, | 1474 | ril_cut_from_vector ((void **) &agent->W, sizeof(double *), RIL_ACTION_TYPE_NUM + address_index, |
1518 | 1, agent->n); | 1475 | 1, agent->n); |
1519 | //correct last action | 1476 | //correct last action |
@@ -1527,13 +1484,15 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o | |||
1527 | } | 1484 | } |
1528 | //decrease old state vector and eligibility vector | 1485 | //decrease old state vector and eligibility vector |
1529 | ril_cut_from_vector ((void **) &agent->s_old, sizeof(double), | 1486 | ril_cut_from_vector ((void **) &agent->s_old, sizeof(double), |
1530 | ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m); | 1487 | ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) |
1488 | + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m); | ||
1531 | ril_cut_from_vector ((void **) &agent->e, sizeof(double), | 1489 | ril_cut_from_vector ((void **) &agent->e, sizeof(double), |
1532 | ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m); | 1490 | ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) |
1491 | + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m); | ||
1533 | agent->m = m_new; | 1492 | agent->m = m_new; |
1534 | agent->n = n_new; | 1493 | agent->n = n_new; |
1535 | 1494 | ||
1536 | LOG (GNUNET_ERROR_TYPE_DEBUG, "address was used: %s\n", address_was_used ? "yes" : "no"); | 1495 | LOG(GNUNET_ERROR_TYPE_DEBUG, "address was used: %s\n", address_was_used ? "yes" : "no"); |
1537 | 1496 | ||
1538 | if (address_was_used) | 1497 | if (address_was_used) |
1539 | { | 1498 | { |
@@ -1543,16 +1502,18 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o | |||
1543 | 1502 | ||
1544 | if (NULL != agent->addresses_head) //if peer has an address left, use it | 1503 | if (NULL != agent->addresses_head) //if peer has an address left, use it |
1545 | { | 1504 | { |
1546 | LOG (GNUNET_ERROR_TYPE_DEBUG, "address left: %p\n", agent->addresses_head->address_naked->addr); | 1505 | LOG(GNUNET_ERROR_TYPE_DEBUG, "address left: %p\n", |
1506 | agent->addresses_head->address_naked->addr); | ||
1547 | //TODO? check if network/bandwidth update can be done more clever/elegant at different function | 1507 | //TODO? check if network/bandwidth update can be done more clever/elegant at different function |
1548 | envi_set_active_suggestion (s, agent, agent->addresses_head->address_naked, min_bw, min_bw, GNUNET_NO); | 1508 | envi_set_active_suggestion (s, agent, agent->addresses_head->address_naked, min_bw, min_bw, |
1509 | GNUNET_NO); | ||
1549 | net = agent->addresses_head->address_naked->solver_information; | 1510 | net = agent->addresses_head->address_naked->solver_information; |
1550 | net->bw_in_assigned -= min_bw; | 1511 | net->bw_in_assigned -= min_bw; |
1551 | net->bw_out_assigned -= min_bw; | 1512 | net->bw_out_assigned -= min_bw; |
1552 | } | 1513 | } |
1553 | else | 1514 | else |
1554 | { | 1515 | { |
1555 | LOG (GNUNET_ERROR_TYPE_DEBUG, "no address left => disconnect\n"); | 1516 | LOG(GNUNET_ERROR_TYPE_DEBUG, "no address left => disconnect\n"); |
1556 | 1517 | ||
1557 | envi_set_active_suggestion (s, agent, NULL, 0, 0, GNUNET_NO); | 1518 | envi_set_active_suggestion (s, agent, NULL, 0, 0, GNUNET_NO); |
1558 | } | 1519 | } |
@@ -1747,7 +1708,8 @@ GAS_ril_get_preferred_address (void *solver, const struct GNUNET_PeerIdentity *p | |||
1747 | 1708 | ||
1748 | agent->active = GNUNET_YES; | 1709 | agent->active = GNUNET_YES; |
1749 | 1710 | ||
1750 | envi_set_active_suggestion(s, agent, agent->address_inuse, agent->bw_in, agent->bw_out, GNUNET_YES); | 1711 | envi_set_active_suggestion (s, agent, agent->address_inuse, agent->bw_in, agent->bw_out, |
1712 | GNUNET_YES); | ||
1751 | 1713 | ||
1752 | if (agent->address_inuse) | 1714 | if (agent->address_inuse) |
1753 | { | 1715 | { |
@@ -1758,7 +1720,8 @@ GAS_ril_get_preferred_address (void *solver, const struct GNUNET_PeerIdentity *p | |||
1758 | else | 1720 | else |
1759 | { | 1721 | { |
1760 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 1722 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1761 | "API_get_preferred_address() Activated agent for peer '%s', but no address available\n", GNUNET_i2s (peer)); | 1723 | "API_get_preferred_address() Activated agent for peer '%s', but no address available\n", |
1724 | GNUNET_i2s (peer)); | ||
1762 | } | 1725 | } |
1763 | 1726 | ||
1764 | return agent->address_inuse; | 1727 | return agent->address_inuse; |
@@ -1790,7 +1753,8 @@ GAS_ril_stop_get_preferred_address (void *solver, const struct GNUNET_PeerIdenti | |||
1790 | } | 1753 | } |
1791 | 1754 | ||
1792 | agent->active = GNUNET_NO; | 1755 | agent->active = GNUNET_NO; |
1793 | envi_set_active_suggestion(s, agent, agent->address_inuse, agent->bw_in, agent->bw_out, GNUNET_YES); | 1756 | envi_set_active_suggestion (s, agent, agent->address_inuse, agent->bw_in, agent->bw_out, |
1757 | GNUNET_YES); | ||
1794 | 1758 | ||
1795 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 1759 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
1796 | "API_stop_get_preferred_address() Paused agent for peer '%s' with %s address\n", | 1760 | "API_stop_get_preferred_address() Paused agent for peer '%s' with %s address\n", |