diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-03 12:22:22 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-03 12:22:22 +0000 |
commit | 3a2c5bed831339afdb4166644adfd466af1f14ef (patch) | |
tree | 67216a3bb89edeccb54ec6c70ff9eaa6d352f1d3 /src | |
parent | 6d04a07b8b6f0553f535e224d22c9bfe4df4a704 (diff) | |
download | gnunet-3a2c5bed831339afdb4166644adfd466af1f14ef.tar.gz gnunet-3a2c5bed831339afdb4166644adfd466af1f14ef.zip |
ats change, done
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 17 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 66 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_simplistic.c | 12 | ||||
-rw-r--r-- | src/ats/test_ats_mlp_update.c | 15 | ||||
-rw-r--r-- | src/include/gnunet_ats_service.h | 13 |
5 files changed, 77 insertions, 46 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 52b60cba1..e0650d5fa 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -419,7 +419,7 @@ disassemble_ats_information (struct ATS_Address *dest, | |||
419 | for (c1 = 0; c1 < update_count; c1 ++) | 419 | for (c1 = 0; c1 < update_count; c1 ++) |
420 | { | 420 | { |
421 | (*delta_dest)[c1].type = update[c1].type; | 421 | (*delta_dest)[c1].type = update[c1].type; |
422 | (*delta_dest)[c1].value = htonl(UINT32_MAX); | 422 | (*delta_dest)[c1].value = htonl(GNUNET_ATS_VALUE_UNDEFINED); |
423 | } | 423 | } |
424 | (*delta_count) = update_count; | 424 | (*delta_count) = update_count; |
425 | return GNUNET_YES; | 425 | return GNUNET_YES; |
@@ -451,7 +451,7 @@ disassemble_ats_information (struct ATS_Address *dest, | |||
451 | add_atsi[add_atsi_count] = update[c1]; | 451 | add_atsi[add_atsi_count] = update[c1]; |
452 | add_atsi_count ++; | 452 | add_atsi_count ++; |
453 | delta_atsi[delta_atsi_count].type = update[c1].type; | 453 | delta_atsi[delta_atsi_count].type = update[c1].type; |
454 | delta_atsi[delta_atsi_count].type = htonl (UINT32_MAX); | 454 | delta_atsi[delta_atsi_count].value = htonl (GNUNET_ATS_VALUE_UNDEFINED); |
455 | delta_atsi_count ++; | 455 | delta_atsi_count ++; |
456 | } | 456 | } |
457 | } | 457 | } |
@@ -717,7 +717,7 @@ lookup_address (struct GAS_Addresses_Handle *handle, | |||
717 | * | 717 | * |
718 | * @param address the address | 718 | * @param address the address |
719 | * @param type the type to extract in HBO | 719 | * @param type the type to extract in HBO |
720 | * @return the value in HBO or UINT32_MAX in HBO if value does not exist | 720 | * @return the value in HBO or GNUNET_ATS_VALUE_UNDEFINED in HBO if value does not exist |
721 | */ | 721 | */ |
722 | static int | 722 | static int |
723 | get_performance_info (struct ATS_Address *address, uint32_t type) | 723 | get_performance_info (struct ATS_Address *address, uint32_t type) |
@@ -726,14 +726,14 @@ get_performance_info (struct ATS_Address *address, uint32_t type) | |||
726 | GNUNET_assert (NULL != address); | 726 | GNUNET_assert (NULL != address); |
727 | 727 | ||
728 | if ((NULL == address->atsi) || (0 == address->atsi_count)) | 728 | if ((NULL == address->atsi) || (0 == address->atsi_count)) |
729 | return UINT32_MAX; | 729 | return GNUNET_ATS_VALUE_UNDEFINED; |
730 | 730 | ||
731 | for (c1 = 0; c1 < address->atsi_count; c1++) | 731 | for (c1 = 0; c1 < address->atsi_count; c1++) |
732 | { | 732 | { |
733 | if (ntohl(address->atsi[c1].type) == type) | 733 | if (ntohl(address->atsi[c1].type) == type) |
734 | return ntohl(address->atsi[c1].value); | 734 | return ntohl(address->atsi[c1].value); |
735 | } | 735 | } |
736 | return UINT32_MAX; | 736 | return GNUNET_ATS_VALUE_UNDEFINED; |
737 | } | 737 | } |
738 | 738 | ||
739 | 739 | ||
@@ -779,6 +779,10 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
779 | atsi_delta = NULL; | 779 | atsi_delta = NULL; |
780 | disassemble_ats_information (aa, atsi, atsi_count, &atsi_delta, &atsi_delta_count); | 780 | disassemble_ats_information (aa, atsi, atsi_count, &atsi_delta, &atsi_delta_count); |
781 | GNUNET_free_non_null (atsi_delta); | 781 | GNUNET_free_non_null (atsi_delta); |
782 | addr_net = get_performance_info (aa, GNUNET_ATS_NETWORK_TYPE); | ||
783 | if (GNUNET_ATS_VALUE_UNDEFINED == addr_net) | ||
784 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; | ||
785 | |||
782 | /* Get existing address or address with session == 0 */ | 786 | /* Get existing address or address with session == 0 */ |
783 | ea = find_equivalent_address (handle, peer, aa); | 787 | ea = find_equivalent_address (handle, peer, aa); |
784 | if (ea == NULL) | 788 | if (ea == NULL) |
@@ -790,9 +794,6 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
790 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 794 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
791 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new address for peer `%s' session id %u, %p\n", | 795 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new address for peer `%s' session id %u, %p\n", |
792 | GNUNET_i2s (peer), session_id, aa); | 796 | GNUNET_i2s (peer), session_id, aa); |
793 | addr_net = get_performance_info (aa, GNUNET_ATS_NETWORK_TYPE); | ||
794 | if (UINT32_MAX == addr_net) | ||
795 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; | ||
796 | /* Tell solver about new address */ | 797 | /* Tell solver about new address */ |
797 | handle->s_add (handle->solver, handle->addresses, aa, addr_net); | 798 | handle->s_add (handle->solver, handle->addresses, aa, addr_net); |
798 | /* Notify performance clients about new address */ | 799 | /* Notify performance clients about new address */ |
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index e9c0cec07..dfede6c9b 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c | |||
@@ -364,7 +364,7 @@ mlp_solve_to_string (int retcode) | |||
364 | * | 364 | * |
365 | * @param address the address | 365 | * @param address the address |
366 | * @param type the type to extract in HBO | 366 | * @param type the type to extract in HBO |
367 | * @return the value in HBO or UINT32_MAX in HBO if value does not exist | 367 | * @return the value in HBO or GNUNET_ATS_VALUE_UNDEFINED in HBO if value does not exist |
368 | */ | 368 | */ |
369 | static int | 369 | static int |
370 | get_performance_info (struct ATS_Address *address, uint32_t type) | 370 | get_performance_info (struct ATS_Address *address, uint32_t type) |
@@ -373,14 +373,14 @@ get_performance_info (struct ATS_Address *address, uint32_t type) | |||
373 | GNUNET_assert (NULL != address); | 373 | GNUNET_assert (NULL != address); |
374 | 374 | ||
375 | if ((NULL == address->atsi) || (0 == address->atsi_count)) | 375 | if ((NULL == address->atsi) || (0 == address->atsi_count)) |
376 | return UINT32_MAX; | 376 | return GNUNET_ATS_VALUE_UNDEFINED; |
377 | 377 | ||
378 | for (c1 = 0; c1 < address->atsi_count; c1++) | 378 | for (c1 = 0; c1 < address->atsi_count; c1++) |
379 | { | 379 | { |
380 | if (ntohl(address->atsi[c1].type) == type) | 380 | if (ntohl(address->atsi[c1].type) == type) |
381 | return ntohl(address->atsi[c1].value); | 381 | return ntohl(address->atsi[c1].value); |
382 | } | 382 | } |
383 | return UINT32_MAX; | 383 | return GNUNET_ATS_VALUE_UNDEFINED; |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
@@ -606,7 +606,7 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC | |||
606 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) | 606 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) |
607 | { | 607 | { |
608 | addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); | 608 | addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); |
609 | if (UINT32_MAX == addr_net) | 609 | if (GNUNET_ATS_VALUE_UNDEFINED == addr_net) |
610 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; | 610 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; |
611 | 611 | ||
612 | if (mlp->pv.quota_index[c] == addr_net) | 612 | if (mlp->pv.quota_index[c] == addr_net) |
@@ -1092,7 +1092,7 @@ static void | |||
1092 | mlp_update_quality (struct GAS_MLP_Handle *mlp, | 1092 | mlp_update_quality (struct GAS_MLP_Handle *mlp, |
1093 | struct GNUNET_CONTAINER_MultiHashMap *addresses, | 1093 | struct GNUNET_CONTAINER_MultiHashMap *addresses, |
1094 | struct ATS_Address * address, | 1094 | struct ATS_Address * address, |
1095 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) | 1095 | const struct GNUNET_ATS_Information *ats_prev, uint32_t ats_prev_count) |
1096 | { | 1096 | { |
1097 | struct MLP_information *mlpi = address->solver_information; | 1097 | struct MLP_information *mlpi = address->solver_information; |
1098 | unsigned int c_ats_entry; | 1098 | unsigned int c_ats_entry; |
@@ -1105,9 +1105,9 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp, | |||
1105 | int qual_changed; | 1105 | int qual_changed; |
1106 | int type_index; | 1106 | int type_index; |
1107 | int avg_index; | 1107 | int avg_index; |
1108 | uint32_t addr_net; | ||
1109 | uint32_t type; | 1108 | uint32_t type; |
1110 | uint32_t value; | 1109 | uint32_t prev_value; |
1110 | uint32_t new_value; | ||
1111 | double avg; | 1111 | double avg; |
1112 | double *queue; | 1112 | double *queue; |
1113 | int rows; | 1113 | int rows; |
@@ -1116,36 +1116,36 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp, | |||
1116 | 1116 | ||
1117 | 1117 | ||
1118 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating %u quality metrics for peer `%s'\n", | 1118 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating %u quality metrics for peer `%s'\n", |
1119 | ats_count, GNUNET_i2s (&address->peer)); | 1119 | ats_prev_count, GNUNET_i2s (&address->peer)); |
1120 | 1120 | ||
1121 | GNUNET_assert (NULL != mlp); | 1121 | GNUNET_assert (NULL != mlp); |
1122 | GNUNET_assert (NULL != address); | 1122 | GNUNET_assert (NULL != address); |
1123 | GNUNET_assert (NULL != address->solver_information); | 1123 | GNUNET_assert (NULL != address->solver_information); |
1124 | GNUNET_assert (NULL != ats); | 1124 | GNUNET_assert (NULL != ats_prev); |
1125 | 1125 | ||
1126 | if (NULL == mlp->p.prob) | 1126 | if (NULL == mlp->p.prob) |
1127 | return; | 1127 | return; |
1128 | 1128 | ||
1129 | qual_changed = GNUNET_NO; | 1129 | qual_changed = GNUNET_NO; |
1130 | for (c_ats_entry = 0; c_ats_entry < ats_count; c_ats_entry++) | 1130 | for (c_ats_entry = 0; c_ats_entry < ats_prev_count; c_ats_entry++) |
1131 | { | 1131 | { |
1132 | type = ntohl (ats[c_ats_entry].type); | 1132 | type = ntohl (ats_prev[c_ats_entry].type); |
1133 | value = ntohl (ats[c_ats_entry].value); | 1133 | prev_value = ntohl (ats_prev[c_ats_entry].value); |
1134 | type_index = -1; | 1134 | type_index = -1; |
1135 | avg_index = -1; | 1135 | avg_index = -1; |
1136 | 1136 | ||
1137 | /* Check for network update */ | 1137 | /* Check for network update */ |
1138 | if (type == GNUNET_ATS_NETWORK_TYPE) | 1138 | if (type == GNUNET_ATS_NETWORK_TYPE) |
1139 | { | 1139 | { |
1140 | addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); | 1140 | new_value = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); |
1141 | if (UINT32_MAX == addr_net) | 1141 | if (GNUNET_ATS_VALUE_UNDEFINED == new_value) |
1142 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; | 1142 | new_value = GNUNET_ATS_NET_UNSPECIFIED; |
1143 | if (addr_net != value) | 1143 | if (new_value != prev_value) |
1144 | { | 1144 | { |
1145 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating network for peer `%s' from `%s' to `%s'\n", | 1145 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating network for peer `%s' from `%s' to `%s'\n", |
1146 | GNUNET_i2s (&address->peer), | 1146 | GNUNET_i2s (&address->peer), |
1147 | GNUNET_ATS_print_network_type(addr_net), | 1147 | GNUNET_ATS_print_network_type(prev_value), |
1148 | GNUNET_ATS_print_network_type(value)); | 1148 | GNUNET_ATS_print_network_type(new_value)); |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | if (mlpi->c_b == MLP_UNDEFINED) | 1151 | if (mlpi->c_b == MLP_UNDEFINED) |
@@ -1158,13 +1158,13 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp, | |||
1158 | 1158 | ||
1159 | for (c_net = 0; c_net <= length + 1; c_net ++) | 1159 | for (c_net = 0; c_net <= length + 1; c_net ++) |
1160 | { | 1160 | { |
1161 | if (ind[c_net] == mlp->p.r_quota[addr_net]) | 1161 | if (ind[c_net] == mlp->p.r_quota[prev_value]) |
1162 | break; /* Found index for old network */ | 1162 | break; /* Found index for old network */ |
1163 | } | 1163 | } |
1164 | val[c_net] = 0.0; | 1164 | val[c_net] = 0.0; |
1165 | glp_set_mat_col (mlp->p.prob, mlpi->c_b, length, ind, val); | 1165 | glp_set_mat_col (mlp->p.prob, mlpi->c_b, length, ind, val); |
1166 | /* Set updated column */ | 1166 | /* Set updated column */ |
1167 | ind[c_net] = mlp->p.r_quota[value]; | 1167 | ind[c_net] = mlp->p.r_quota[new_value]; |
1168 | val[c_net] = 1.0; | 1168 | val[c_net] = 1.0; |
1169 | glp_set_mat_col (mlp->p.prob, mlpi->c_b, length, ind, val); | 1169 | glp_set_mat_col (mlp->p.prob, mlpi->c_b, length, ind, val); |
1170 | GNUNET_free (ind); | 1170 | GNUNET_free (ind); |
@@ -1177,9 +1177,9 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp, | |||
1177 | 1177 | ||
1178 | for (c_net = 0; c_net <= length + 1; c_net ++) | 1178 | for (c_net = 0; c_net <= length + 1; c_net ++) |
1179 | { | 1179 | { |
1180 | if (ind[c_net] == mlp->p.r_quota[value]) | 1180 | if (ind[c_net] == mlp->p.r_quota[prev_value]) |
1181 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing old network index [%u] == [%f]\n",ind[c_net],val[c_net]); | 1181 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Removing old network index [%u] == [%f]\n",ind[c_net],val[c_net]); |
1182 | if (ind[c_net] == mlp->p.r_quota[addr_net]) | 1182 | if (ind[c_net] == mlp->p.r_quota[new_value]) |
1183 | { | 1183 | { |
1184 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Setting new network index [%u] == [%f]\n",ind[c_net],val[c_net]); | 1184 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Setting new network index [%u] == [%f]\n",ind[c_net],val[c_net]); |
1185 | break; | 1185 | break; |
@@ -1208,7 +1208,12 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp, | |||
1208 | avg_index = mlpi->q_avg_i[type_index]; | 1208 | avg_index = mlpi->q_avg_i[type_index]; |
1209 | 1209 | ||
1210 | /* Update averaging queue */ | 1210 | /* Update averaging queue */ |
1211 | mlpi->q[type_index][avg_index] = value; | 1211 | new_value = get_performance_info (address, type); |
1212 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s': `%s' from %u to %u\n", | ||
1213 | GNUNET_i2s (&address->peer), | ||
1214 | mlp_ats_to_string(mlp->pv.q[type_index]), prev_value, new_value); | ||
1215 | GNUNET_assert (GNUNET_ATS_VALUE_UNDEFINED != new_value); | ||
1216 | mlpi->q[type_index][avg_index] = new_value; | ||
1212 | 1217 | ||
1213 | /* Update averaging index */ | 1218 | /* Update averaging index */ |
1214 | if (mlpi->q_avg_i[type_index] + 1 < (MLP_AVERAGING_QUEUE_LENGTH)) | 1219 | if (mlpi->q_avg_i[type_index] + 1 < (MLP_AVERAGING_QUEUE_LENGTH)) |
@@ -1298,6 +1303,9 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp, | |||
1298 | * If the address did not exist before in the problem: | 1303 | * If the address did not exist before in the problem: |
1299 | * The MLP problem has to be recreated and the problem has to be resolved | 1304 | * The MLP problem has to be recreated and the problem has to be resolved |
1300 | * | 1305 | * |
1306 | * ATS performance information in address are already updated, delta + previous | ||
1307 | * values are included in atsi_prev (value GNUNET_ATS_VALUE_UNDEFINED if not existing before) | ||
1308 | * | ||
1301 | * Otherwise the addresses' values can be updated and the existing base can | 1309 | * Otherwise the addresses' values can be updated and the existing base can |
1302 | * be reused | 1310 | * be reused |
1303 | * | 1311 | * |
@@ -1306,8 +1314,8 @@ mlp_update_quality (struct GAS_MLP_Handle *mlp, | |||
1306 | * @param address the update address | 1314 | * @param address the update address |
1307 | * @param session the new session (if changed otherwise current) | 1315 | * @param session the new session (if changed otherwise current) |
1308 | * @param in_use the new address in use state (if changed otherwise current) | 1316 | * @param in_use the new address in use state (if changed otherwise current) |
1309 | * @param atsi the latest ATS information | 1317 | * @param atsi_prev ATS information updated + previous values, GNUNET_ATS_VALUE_UNDEFINED if not existing before |
1310 | * @param atsi_count the atsi count | 1318 | * @param atsi_count_prev number of atsi values updated |
1311 | */ | 1319 | */ |
1312 | void | 1320 | void |
1313 | GAS_mlp_address_update (void *solver, | 1321 | GAS_mlp_address_update (void *solver, |
@@ -1315,8 +1323,8 @@ GAS_mlp_address_update (void *solver, | |||
1315 | struct ATS_Address *address, | 1323 | struct ATS_Address *address, |
1316 | uint32_t session, | 1324 | uint32_t session, |
1317 | int in_use, | 1325 | int in_use, |
1318 | const struct GNUNET_ATS_Information *atsi, | 1326 | const struct GNUNET_ATS_Information *atsi_prev, |
1319 | uint32_t atsi_count) | 1327 | uint32_t atsi_count_prev) |
1320 | { | 1328 | { |
1321 | struct ATS_Peer *p; | 1329 | struct ATS_Peer *p; |
1322 | struct GAS_MLP_Handle *mlp = solver; | 1330 | struct GAS_MLP_Handle *mlp = solver; |
@@ -1325,14 +1333,14 @@ GAS_mlp_address_update (void *solver, | |||
1325 | GNUNET_assert (NULL != solver); | 1333 | GNUNET_assert (NULL != solver); |
1326 | GNUNET_assert (NULL != addresses); | 1334 | GNUNET_assert (NULL != addresses); |
1327 | GNUNET_assert (NULL != address); | 1335 | GNUNET_assert (NULL != address); |
1328 | GNUNET_assert ((NULL != atsi) || (0 == atsi_count)); | 1336 | GNUNET_assert ((NULL != atsi_prev) || (0 == atsi_count_prev)); |
1329 | 1337 | ||
1330 | if (NULL == mlpi) | 1338 | if (NULL == mlpi) |
1331 | { | 1339 | { |
1332 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Updating address for peer `%s' not added before\n"), GNUNET_i2s(&address->peer)); | 1340 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Updating address for peer `%s' not added before\n"), GNUNET_i2s(&address->peer)); |
1333 | return; | 1341 | return; |
1334 | } | 1342 | } |
1335 | mlp_update_quality (mlp, addresses, address, atsi, atsi_count); | 1343 | mlp_update_quality (mlp, addresses, address, atsi_prev, atsi_count_prev); |
1336 | 1344 | ||
1337 | /* Is this peer included in the problem? */ | 1345 | /* Is this peer included in the problem? */ |
1338 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->peers, &address->peer.hashPubKey))) | 1346 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->peers, &address->peer.hashPubKey))) |
diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c index 1e847cb31..598c8ee20 100644 --- a/src/ats/gnunet-service-ats_addresses_simplistic.c +++ b/src/ats/gnunet-service-ats_addresses_simplistic.c | |||
@@ -770,7 +770,7 @@ addresse_decrement (struct GAS_SIMPLISTIC_Handle *s, | |||
770 | * | 770 | * |
771 | * @param address the address | 771 | * @param address the address |
772 | * @param type the type to extract in HBO | 772 | * @param type the type to extract in HBO |
773 | * @return the value in HBO or UINT32_MAX in HBO if value does not exist | 773 | * @return the value in HBO or GNUNET_ATS_VALUE_UNDEFINED in HBO if value does not exist |
774 | */ | 774 | */ |
775 | static int | 775 | static int |
776 | get_performance_info (struct ATS_Address *address, uint32_t type) | 776 | get_performance_info (struct ATS_Address *address, uint32_t type) |
@@ -779,14 +779,14 @@ get_performance_info (struct ATS_Address *address, uint32_t type) | |||
779 | GNUNET_assert (NULL != address); | 779 | GNUNET_assert (NULL != address); |
780 | 780 | ||
781 | if ((NULL == address->atsi) || (0 == address->atsi_count)) | 781 | if ((NULL == address->atsi) || (0 == address->atsi_count)) |
782 | return UINT32_MAX; | 782 | return GNUNET_ATS_VALUE_UNDEFINED; |
783 | 783 | ||
784 | for (c1 = 0; c1 < address->atsi_count; c1++) | 784 | for (c1 = 0; c1 < address->atsi_count; c1++) |
785 | { | 785 | { |
786 | if (ntohl(address->atsi[c1].type) == type) | 786 | if (ntohl(address->atsi[c1].type) == type) |
787 | return ntohl(address->atsi[c1].value); | 787 | return ntohl(address->atsi[c1].value); |
788 | } | 788 | } |
789 | return UINT32_MAX; | 789 | return GNUNET_ATS_VALUE_UNDEFINED; |
790 | } | 790 | } |
791 | 791 | ||
792 | 792 | ||
@@ -984,7 +984,7 @@ GAS_simplistic_address_update (void *solver, | |||
984 | break; | 984 | break; |
985 | case GNUNET_ATS_NETWORK_TYPE: | 985 | case GNUNET_ATS_NETWORK_TYPE: |
986 | addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); | 986 | addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); |
987 | if (UINT32_MAX == addr_net) | 987 | if (GNUNET_ATS_VALUE_UNDEFINED == addr_net) |
988 | { | 988 | { |
989 | GNUNET_break (0); | 989 | GNUNET_break (0); |
990 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; | 990 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; |
@@ -1140,7 +1140,7 @@ find_address_it (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
1140 | 1140 | ||
1141 | p_distance_prev = get_performance_info (previous, GNUNET_ATS_QUALITY_NET_DISTANCE); | 1141 | p_distance_prev = get_performance_info (previous, GNUNET_ATS_QUALITY_NET_DISTANCE); |
1142 | p_distance_cur = get_performance_info (current, GNUNET_ATS_QUALITY_NET_DISTANCE); | 1142 | p_distance_cur = get_performance_info (current, GNUNET_ATS_QUALITY_NET_DISTANCE); |
1143 | if ((p_distance_prev != UINT32_MAX) && (p_distance_cur != UINT32_MAX) && | 1143 | if ((p_distance_prev != GNUNET_ATS_VALUE_UNDEFINED) && (p_distance_cur != GNUNET_ATS_VALUE_UNDEFINED) && |
1144 | (p_distance_prev > p_distance_cur)) | 1144 | (p_distance_prev > p_distance_cur)) |
1145 | { | 1145 | { |
1146 | /* user shorter distance */ | 1146 | /* user shorter distance */ |
@@ -1150,7 +1150,7 @@ find_address_it (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
1150 | 1150 | ||
1151 | p_delay_prev = get_performance_info (previous, GNUNET_ATS_QUALITY_NET_DELAY); | 1151 | p_delay_prev = get_performance_info (previous, GNUNET_ATS_QUALITY_NET_DELAY); |
1152 | p_delay_cur = get_performance_info (current, GNUNET_ATS_QUALITY_NET_DELAY); | 1152 | p_delay_cur = get_performance_info (current, GNUNET_ATS_QUALITY_NET_DELAY); |
1153 | if ((p_delay_prev != UINT32_MAX) && (p_delay_cur != UINT32_MAX) && | 1153 | if ((p_delay_prev != GNUNET_ATS_VALUE_UNDEFINED) && (p_delay_cur != GNUNET_ATS_VALUE_UNDEFINED) && |
1154 | (p_delay_prev > p_delay_cur)) | 1154 | (p_delay_prev > p_delay_cur)) |
1155 | { | 1155 | { |
1156 | /* user lower latency */ | 1156 | /* user lower latency */ |
diff --git a/src/ats/test_ats_mlp_update.c b/src/ats/test_ats_mlp_update.c index 6f1bf7005..de66dd2c0 100644 --- a/src/ats/test_ats_mlp_update.c +++ b/src/ats/test_ats_mlp_update.c | |||
@@ -41,6 +41,7 @@ static int ret; | |||
41 | */ | 41 | */ |
42 | struct GNUNET_ATS_Information ats[4]; | 42 | struct GNUNET_ATS_Information ats[4]; |
43 | 43 | ||
44 | struct GNUNET_ATS_Information ats_prev[4]; | ||
44 | 45 | ||
45 | /** | 46 | /** |
46 | * MLP solver handle | 47 | * MLP solver handle |
@@ -228,6 +229,8 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
228 | /* Solve problem to build matrix */ | 229 | /* Solve problem to build matrix */ |
229 | GAS_mlp_solve_problem (mlp, addresses); | 230 | GAS_mlp_solve_problem (mlp, addresses); |
230 | 231 | ||
232 | address[0]->atsi = ats; | ||
233 | address[0]->atsi_count = 4; | ||
231 | /* Updating address 0*/ | 234 | /* Updating address 0*/ |
232 | ats[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); | 235 | ats[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); |
233 | ats[0].value = htonl (GNUNET_ATS_NET_WAN); | 236 | ats[0].value = htonl (GNUNET_ATS_NET_WAN); |
@@ -237,7 +240,17 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
237 | ats[2].value = htonl (1); | 240 | ats[2].value = htonl (1); |
238 | ats[3].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR); | 241 | ats[3].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR); |
239 | ats[3].value = htonl (GNUNET_ATS_ARRAY_TERMINATOR); | 242 | ats[3].value = htonl (GNUNET_ATS_ARRAY_TERMINATOR); |
240 | GAS_mlp_address_update (mlp, addresses, address[0], 1, GNUNET_NO, ats, 4); | 243 | |
244 | ats_prev[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); | ||
245 | ats_prev[0].value = htonl (GNUNET_ATS_NET_UNSPECIFIED); | ||
246 | ats_prev[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); | ||
247 | ats_prev[1].value = htonl (GNUNET_ATS_VALUE_UNDEFINED); | ||
248 | ats_prev[2].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
249 | ats_prev[2].value = htonl (GNUNET_ATS_VALUE_UNDEFINED); | ||
250 | ats_prev[3].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR); | ||
251 | ats_prev[3].value = htonl (GNUNET_ATS_VALUE_UNDEFINED); | ||
252 | |||
253 | GAS_mlp_address_update (mlp, addresses, address[0], 1, GNUNET_NO, ats_prev, 4); | ||
241 | 254 | ||
242 | /* Solve problem to build matrix */ | 255 | /* Solve problem to build matrix */ |
243 | GAS_mlp_solve_problem (mlp, addresses); | 256 | GAS_mlp_solve_problem (mlp, addresses); |
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index 692592148..3713949cb 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h | |||
@@ -59,11 +59,15 @@ enum GNUNET_ATS_Network_Type | |||
59 | */ | 59 | */ |
60 | #define GNUNET_ATS_DefaultBandwidth 65536 | 60 | #define GNUNET_ATS_DefaultBandwidth 65536 |
61 | 61 | ||
62 | /** | ||
63 | * Undefined value for a GNUNET_ATS_Property | ||
64 | */ | ||
65 | #define GNUNET_ATS_VALUE_UNDEFINED UINT32_MAX | ||
62 | 66 | ||
63 | /** | 67 | /** |
64 | * Textual equivalent for GNUNET_ATS_MaxBandwidth | 68 | * String representation for GNUNET_ATS_VALUE_UNDEFINED |
65 | */ | 69 | */ |
66 | #define GNUNET_ATS_MaxBandwidthString "unlimited" | 70 | #define GNUNET_ATS_VALUE_UNDEFINED_STR "undefined" |
67 | 71 | ||
68 | /** | 72 | /** |
69 | * Maximum bandwidth assigned to a network : 4095 MB/s | 73 | * Maximum bandwidth assigned to a network : 4095 MB/s |
@@ -71,6 +75,11 @@ enum GNUNET_ATS_Network_Type | |||
71 | #define GNUNET_ATS_MaxBandwidth UINT32_MAX | 75 | #define GNUNET_ATS_MaxBandwidth UINT32_MAX |
72 | 76 | ||
73 | /** | 77 | /** |
78 | * Textual equivalent for GNUNET_ATS_MaxBandwidth | ||
79 | */ | ||
80 | #define GNUNET_ATS_MaxBandwidthString "unlimited" | ||
81 | |||
82 | /** | ||
74 | * Number of property types supported by ATS | 83 | * Number of property types supported by ATS |
75 | */ | 84 | */ |
76 | #define GNUNET_ATS_PropertyCount 9 | 85 | #define GNUNET_ATS_PropertyCount 9 |