diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-07-17 09:47:51 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-07-17 09:47:51 +0000 |
commit | 615d5aef87f985e4c489fac6c6d6232d35f8b0c2 (patch) | |
tree | 82eb29b40821ee0a5405737ac2d9f0428c6c2619 /src/ats/plugin_ats_proportional.c | |
parent | 6053799e5d05b8d5c6c664b66e48f367b3dd6578 (diff) | |
download | gnunet-615d5aef87f985e4c489fac6c6d6232d35f8b0c2.tar.gz gnunet-615d5aef87f985e4c489fac6c6d6232d35f8b0c2.zip |
do not use NBO internally
Diffstat (limited to 'src/ats/plugin_ats_proportional.c')
-rw-r--r-- | src/ats/plugin_ats_proportional.c | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c index 139214118..5fc065cba 100644 --- a/src/ats/plugin_ats_proportional.c +++ b/src/ats/plugin_ats_proportional.c | |||
@@ -367,19 +367,22 @@ struct Network | |||
367 | */ | 367 | */ |
368 | struct AddressSolverInformation | 368 | struct AddressSolverInformation |
369 | { | 369 | { |
370 | /** | ||
371 | * Network scope this address is in | ||
372 | */ | ||
370 | struct Network *network; | 373 | struct Network *network; |
371 | 374 | ||
372 | /** | 375 | /** |
373 | * Inbound quota | 376 | * Inbound quota |
374 | * | 377 | * |
375 | */ | 378 | */ |
376 | unsigned long long calculated_quota_in_NBO; | 379 | uint32_t calculated_quota_in; |
377 | 380 | ||
378 | /** | 381 | /** |
379 | * Outbound quota | 382 | * Outbound quota |
380 | * | 383 | * |
381 | */ | 384 | */ |
382 | unsigned long long calculated_quota_out_NBO; | 385 | uint32_t calculated_quota_out; |
383 | 386 | ||
384 | /** | 387 | /** |
385 | * When was this address activated | 388 | * When was this address activated |
@@ -529,8 +532,8 @@ distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s, | |||
529 | double total_weight; | 532 | double total_weight; |
530 | const double *peer_relative_prefs = NULL; /* Important: has to be double not float due to precision */ | 533 | const double *peer_relative_prefs = NULL; /* Important: has to be double not float due to precision */ |
531 | 534 | ||
532 | unsigned long long assigned_quota_in = 0; | 535 | uint32_t assigned_quota_in = 0; |
533 | unsigned long long assigned_quota_out = 0; | 536 | uint32_t assigned_quota_out = 0; |
534 | 537 | ||
535 | 538 | ||
536 | LOG(GNUNET_ERROR_TYPE_INFO, | 539 | LOG(GNUNET_ERROR_TYPE_INFO, |
@@ -639,8 +642,8 @@ distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s, | |||
639 | 642 | ||
640 | /* Compare to current bandwidth assigned */ | 643 | /* Compare to current bandwidth assigned */ |
641 | asi = cur_address->addr->solver_information; | 644 | asi = cur_address->addr->solver_information; |
642 | asi->calculated_quota_in_NBO = htonl (assigned_quota_in); | 645 | asi->calculated_quota_in = assigned_quota_in; |
643 | asi->calculated_quota_out_NBO = htonl (assigned_quota_out); | 646 | asi->calculated_quota_out = assigned_quota_out; |
644 | } | 647 | } |
645 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 648 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
646 | "Total bandwidth assigned is (in/out): %llu /%llu\n", quota_in_used, | 649 | "Total bandwidth assigned is (in/out): %llu /%llu\n", quota_in_used, |
@@ -1087,23 +1090,22 @@ propagate_bandwidth (struct GAS_PROPORTIONAL_Handle *s, | |||
1087 | for (cur = net->head; NULL != cur; cur = cur->next) | 1090 | for (cur = net->head; NULL != cur; cur = cur->next) |
1088 | { | 1091 | { |
1089 | asi = cur->addr->solver_information; | 1092 | asi = cur->addr->solver_information; |
1090 | if ( (cur->addr->assigned_bw_in.value__ != asi->calculated_quota_in_NBO) || | 1093 | if ( (cur->addr->assigned_bw_in != asi->calculated_quota_in) || |
1091 | (cur->addr->assigned_bw_out.value__ != asi->calculated_quota_out_NBO) ) | 1094 | (cur->addr->assigned_bw_out != asi->calculated_quota_out) ) |
1092 | { | 1095 | { |
1093 | cur->addr->assigned_bw_in.value__ = asi->calculated_quota_in_NBO; | 1096 | cur->addr->assigned_bw_in = asi->calculated_quota_in; |
1094 | cur->addr->assigned_bw_out.value__ = asi->calculated_quota_out_NBO; | 1097 | cur->addr->assigned_bw_out = asi->calculated_quota_out; |
1095 | 1098 | ||
1096 | /* Reset for next iteration */ | 1099 | /* Reset for next iteration */ |
1097 | asi->calculated_quota_in_NBO = htonl (0); | 1100 | asi->calculated_quota_in = 0; |
1098 | asi->calculated_quota_out_NBO = htonl (0); | 1101 | asi->calculated_quota_out = 0; |
1099 | |||
1100 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1102 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1101 | "Bandwidth for %s address %p for peer `%s' changed to %u/%u\n", | 1103 | "Bandwidth for %s address %p for peer `%s' changed to %u/%u\n", |
1102 | (GNUNET_NO == cur->addr->active) ? "inactive" : "active", | 1104 | (GNUNET_NO == cur->addr->active) ? "inactive" : "active", |
1103 | cur->addr, | 1105 | cur->addr, |
1104 | GNUNET_i2s (&cur->addr->peer), | 1106 | GNUNET_i2s (&cur->addr->peer), |
1105 | ntohl (cur->addr->assigned_bw_in.value__), | 1107 | cur->addr->assigned_bw_in, |
1106 | ntohl (cur->addr->assigned_bw_out.value__ )); | 1108 | cur->addr->assigned_bw_out); |
1107 | 1109 | ||
1108 | /* Notify on change */ | 1110 | /* Notify on change */ |
1109 | if ((GNUNET_YES == cur->addr->active)) | 1111 | if ((GNUNET_YES == cur->addr->active)) |
@@ -1215,17 +1217,12 @@ update_active_address (struct GAS_PROPORTIONAL_Handle *s, | |||
1215 | /* Find active address */ | 1217 | /* Find active address */ |
1216 | current_address = get_active_address (s, s->addresses, peer); | 1218 | current_address = get_active_address (s, s->addresses, peer); |
1217 | 1219 | ||
1218 | LOG (GNUNET_ERROR_TYPE_INFO, | 1220 | LOG (GNUNET_ERROR_TYPE_INFO, "Peer `%s' has active address %p\n", |
1219 | "Peer `%s' has active address %p\n", | 1221 | GNUNET_i2s (peer), current_address); |
1220 | GNUNET_i2s (peer), | ||
1221 | current_address); | ||
1222 | |||
1223 | 1222 | ||
1224 | /* Find best address */ | 1223 | /* Find best address */ |
1225 | best_address = get_best_address (s,s->addresses, peer); | 1224 | best_address = get_best_address (s,s->addresses, peer); |
1226 | 1225 | LOG (GNUNET_ERROR_TYPE_INFO, "Peer `%s' has best address %p\n", | |
1227 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
1228 | "Peer `%s' has best address %p\n", | ||
1229 | GNUNET_i2s (peer), best_address); | 1226 | GNUNET_i2s (peer), best_address); |
1230 | 1227 | ||
1231 | if (NULL != current_address) | 1228 | if (NULL != current_address) |
@@ -1246,8 +1243,8 @@ update_active_address (struct GAS_PROPORTIONAL_Handle *s, | |||
1246 | net = asi->network; | 1243 | net = asi->network; |
1247 | asi->activated = GNUNET_TIME_UNIT_ZERO_ABS; | 1244 | asi->activated = GNUNET_TIME_UNIT_ZERO_ABS; |
1248 | current_address->active = GNUNET_NO; /* No active any longer */ | 1245 | current_address->active = GNUNET_NO; /* No active any longer */ |
1249 | current_address->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */ | 1246 | current_address->assigned_bw_in = 0; /* no bandwidth assigned */ |
1250 | current_address->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */ | 1247 | current_address->assigned_bw_out = 0; /* no bandwidth assigned */ |
1251 | 1248 | ||
1252 | if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES)) | 1249 | if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES)) |
1253 | GNUNET_break(0); | 1250 | GNUNET_break(0); |
@@ -1442,8 +1439,8 @@ GAS_proportional_stop_get_preferred_address (void *solver, | |||
1442 | cur_net = asi->network ; | 1439 | cur_net = asi->network ; |
1443 | asi->activated = GNUNET_TIME_UNIT_ZERO_ABS; | 1440 | asi->activated = GNUNET_TIME_UNIT_ZERO_ABS; |
1444 | cur->active = GNUNET_NO; /* No active any longer */ | 1441 | cur->active = GNUNET_NO; /* No active any longer */ |
1445 | cur->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */ | 1442 | cur->assigned_bw_in = 0; /* no bandwidth assigned */ |
1446 | cur->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */ | 1443 | cur->assigned_bw_out = 0; /* no bandwidth assigned */ |
1447 | 1444 | ||
1448 | if (GNUNET_SYSERR == addresse_decrement (s, cur_net, GNUNET_NO, GNUNET_YES)) | 1445 | if (GNUNET_SYSERR == addresse_decrement (s, cur_net, GNUNET_NO, GNUNET_YES)) |
1449 | GNUNET_break(0); | 1446 | GNUNET_break(0); |
@@ -1525,10 +1522,10 @@ GAS_proportional_address_delete (void *solver, | |||
1525 | /* Address was active, remove from network and update quotas*/ | 1522 | /* Address was active, remove from network and update quotas*/ |
1526 | address->active = GNUNET_NO; | 1523 | address->active = GNUNET_NO; |
1527 | 1524 | ||
1528 | address->assigned_bw_in = BANDWIDTH_ZERO; | 1525 | address->assigned_bw_in = 0; |
1529 | address->assigned_bw_out = BANDWIDTH_ZERO; | 1526 | address->assigned_bw_out = 0; |
1530 | asi->calculated_quota_in_NBO = htonl (0); | 1527 | asi->calculated_quota_in = 0; |
1531 | asi->calculated_quota_out_NBO = htonl (0); | 1528 | asi->calculated_quota_out = 0; |
1532 | 1529 | ||
1533 | if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES)) | 1530 | if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES)) |
1534 | GNUNET_break(0); | 1531 | GNUNET_break(0); |
@@ -1837,8 +1834,8 @@ GAS_proportional_address_change_network (void *solver, | |||
1837 | 1834 | ||
1838 | /* Disable and assign no bandwidth */ | 1835 | /* Disable and assign no bandwidth */ |
1839 | address->active = GNUNET_NO; | 1836 | address->active = GNUNET_NO; |
1840 | address->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */ | 1837 | address->assigned_bw_in = 0; /* no bandwidth assigned */ |
1841 | address->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */ | 1838 | address->assigned_bw_out = 0; /* no bandwidth assigned */ |
1842 | 1839 | ||
1843 | /* Remove from old network */ | 1840 | /* Remove from old network */ |
1844 | GAS_proportional_address_delete (solver, address, GNUNET_NO); | 1841 | GAS_proportional_address_delete (solver, address, GNUNET_NO); |
@@ -1910,8 +1907,8 @@ GAS_proportional_address_add (void *solver, | |||
1910 | 1907 | ||
1911 | asi = GNUNET_new (struct AddressSolverInformation); | 1908 | asi = GNUNET_new (struct AddressSolverInformation); |
1912 | asi->network = net; | 1909 | asi->network = net; |
1913 | asi->calculated_quota_in_NBO = htonl (0); | 1910 | asi->calculated_quota_in = 0; |
1914 | asi->calculated_quota_out_NBO = htonl (0); | 1911 | asi->calculated_quota_out = 0; |
1915 | aw->addr->solver_information = asi; | 1912 | aw->addr->solver_information = asi; |
1916 | 1913 | ||
1917 | LOG(GNUNET_ERROR_TYPE_INFO, | 1914 | LOG(GNUNET_ERROR_TYPE_INFO, |