diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-30 20:35:10 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-30 20:35:10 +0000 |
commit | a0ba5b741b56036bd35bd9ba88164324b2ff7ada (patch) | |
tree | 3fd10a0fc15f9a9e7cf5415b2bec86d97d7fe825 /src/ats | |
parent | 427dd6f998fb1fde515a3b5c800f9f6d308197b2 (diff) | |
download | gnunet-a0ba5b741b56036bd35bd9ba88164324b2ff7ada.tar.gz gnunet-a0ba5b741b56036bd35bd9ba88164324b2ff7ada.zip |
-getting ATS and transport to compile again (part of #3047)
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats-solver_mlp.c | 132 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats-solver_mlp.h | 18 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats-solver_proportional.c | 88 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats-solver_proportional.h | 2 | ||||
-rwxr-xr-x | src/ats/gnunet-service-ats-solver_ril.c | 10 | ||||
-rwxr-xr-x | src/ats/gnunet-service-ats-solver_ril.h | 2 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 193 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.h | 2 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_normalization.c | 77 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_normalization.h | 24 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_reservations.c | 21 |
11 files changed, 332 insertions, 237 deletions
diff --git a/src/ats/gnunet-service-ats-solver_mlp.c b/src/ats/gnunet-service-ats-solver_mlp.c index f921c1b1f..f36a3808e 100644 --- a/src/ats/gnunet-service-ats-solver_mlp.c +++ b/src/ats/gnunet-service-ats-solver_mlp.c | |||
@@ -177,7 +177,9 @@ mlp_term_hook (void *info, const char *s) | |||
177 | * @return GNUNET_OK | 177 | * @return GNUNET_OK |
178 | */ | 178 | */ |
179 | static int | 179 | static int |
180 | reset_peers (void *cls, const struct GNUNET_HashCode * key, void *value) | 180 | reset_peers (void *cls, |
181 | const struct GNUNET_PeerIdentity *key, | ||
182 | void *value) | ||
181 | { | 183 | { |
182 | struct ATS_Peer *peer = value; | 184 | struct ATS_Peer *peer = value; |
183 | peer->processed = GNUNET_NO; | 185 | peer->processed = GNUNET_NO; |
@@ -237,7 +239,8 @@ mlp_delete_problem (struct GAS_MLP_Handle *mlp) | |||
237 | mlp->p.ci = MLP_UNDEFINED; | 239 | mlp->p.ci = MLP_UNDEFINED; |
238 | 240 | ||
239 | 241 | ||
240 | GNUNET_CONTAINER_multihashmap_iterate (mlp->requested_peers, &reset_peers, NULL); | 242 | GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers, |
243 | &reset_peers, NULL); | ||
241 | } | 244 | } |
242 | 245 | ||
243 | 246 | ||
@@ -385,28 +388,34 @@ get_performance_info (struct ATS_Address *address, uint32_t type) | |||
385 | 388 | ||
386 | struct CountContext | 389 | struct CountContext |
387 | { | 390 | { |
388 | struct GNUNET_CONTAINER_MultiHashMap * peers; | 391 | const struct GNUNET_CONTAINER_MultiPeerMap *peers; |
389 | int result; | 392 | int result; |
390 | }; | 393 | }; |
391 | 394 | ||
392 | static int | 395 | static int |
393 | mlp_create_problem_count_addresses_it (void *cls, const struct GNUNET_HashCode *key, void *value) | 396 | mlp_create_problem_count_addresses_it (void *cls, |
397 | const struct GNUNET_PeerIdentity *key, | ||
398 | void *value) | ||
394 | { | 399 | { |
395 | struct CountContext *cctx = cls; | 400 | struct CountContext *cctx = cls; |
401 | |||
396 | /* Check if we have to add this peer due to a pending request */ | 402 | /* Check if we have to add this peer due to a pending request */ |
397 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(cctx->peers, key)) | 403 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (cctx->peers, key)) |
398 | cctx->result++; | 404 | cctx->result++; |
399 | return GNUNET_OK; | 405 | return GNUNET_OK; |
400 | } | 406 | } |
401 | 407 | ||
402 | static int mlp_create_problem_count_addresses ( | 408 | |
403 | struct GNUNET_CONTAINER_MultiHashMap * peers, | 409 | static int |
404 | const struct GNUNET_CONTAINER_MultiHashMap * addresses) | 410 | mlp_create_problem_count_addresses (const struct GNUNET_CONTAINER_MultiPeerMap *peers, |
411 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses) | ||
405 | { | 412 | { |
406 | struct CountContext cctx; | 413 | struct CountContext cctx; |
414 | |||
407 | cctx.peers = peers; | 415 | cctx.peers = peers; |
408 | cctx.result = 0; | 416 | cctx.result = 0; |
409 | GNUNET_CONTAINER_multihashmap_iterate (addresses, &mlp_create_problem_count_addresses_it, &cctx); | 417 | GNUNET_CONTAINER_multipeermap_iterate (addresses, |
418 | &mlp_create_problem_count_addresses_it, &cctx); | ||
410 | return cctx.result; | 419 | return cctx.result; |
411 | } | 420 | } |
412 | 421 | ||
@@ -591,7 +600,9 @@ mlp_create_problem_create_constraint (struct MLP_Problem *p, char *name, | |||
591 | * - Set address dependent entries in problem matrix as well | 600 | * - Set address dependent entries in problem matrix as well |
592 | */ | 601 | */ |
593 | static int | 602 | static int |
594 | mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashCode *key, void *value) | 603 | mlp_create_problem_add_address_information (void *cls, |
604 | const struct GNUNET_PeerIdentity *key, | ||
605 | void *value) | ||
595 | { | 606 | { |
596 | struct GAS_MLP_Handle *mlp = cls; | 607 | struct GAS_MLP_Handle *mlp = cls; |
597 | struct MLP_Problem *p = &mlp->p; | 608 | struct MLP_Problem *p = &mlp->p; |
@@ -604,7 +615,7 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC | |||
604 | int c; | 615 | int c; |
605 | 616 | ||
606 | /* Check if we have to add this peer due to a pending request */ | 617 | /* Check if we have to add this peer due to a pending request */ |
607 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->requested_peers, key)) | 618 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains(mlp->requested_peers, key)) |
608 | return GNUNET_OK; | 619 | return GNUNET_OK; |
609 | 620 | ||
610 | mlpi = address->solver_information; | 621 | mlpi = address->solver_information; |
@@ -616,7 +627,7 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC | |||
616 | } | 627 | } |
617 | 628 | ||
618 | /* Get peer */ | 629 | /* Get peer */ |
619 | peer = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, key); | 630 | peer = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, key); |
620 | if (peer->processed == GNUNET_NO) | 631 | if (peer->processed == GNUNET_NO) |
621 | { | 632 | { |
622 | /* Add peer dependent constraints */ | 633 | /* Add peer dependent constraints */ |
@@ -822,14 +833,18 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp) | |||
822 | /* create the glpk problem */ | 833 | /* create the glpk problem */ |
823 | p->prob = glp_create_prob (); | 834 | p->prob = glp_create_prob (); |
824 | GNUNET_assert (NULL != p->prob); | 835 | GNUNET_assert (NULL != p->prob); |
825 | p->num_peers = GNUNET_CONTAINER_multihashmap_size (mlp->requested_peers); | 836 | p->num_peers = GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers); |
826 | p->num_addresses = mlp_create_problem_count_addresses (mlp->requested_peers, mlp->addresses); | 837 | p->num_addresses = mlp_create_problem_count_addresses (mlp->requested_peers, mlp->addresses); |
827 | 838 | ||
828 | /* Create problem matrix: 10 * #addresses + #q * #addresses + #q, + #peer + 2 + 1 */ | 839 | /* Create problem matrix: 10 * #addresses + #q * #addresses + #q, + #peer + 2 + 1 */ |
829 | p->num_elements = (10 * p->num_addresses + mlp->pv.m_q * p->num_addresses + | 840 | p->num_elements = (10 * p->num_addresses + mlp->pv.m_q * p->num_addresses + |
830 | mlp->pv.m_q + p->num_peers + 2 + 1); | 841 | mlp->pv.m_q + p->num_peers + 2 + 1); |
831 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Rebuilding problem for %u peer(s) and %u addresse(s) and %u quality metrics == %u elements\n", | 842 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
832 | p->num_peers, p->num_addresses, mlp->pv.m_q, p->num_elements); | 843 | "Rebuilding problem for %u peer(s) and %u addresse(s) and %u quality metrics == %u elements\n", |
844 | p->num_peers, | ||
845 | p->num_addresses, | ||
846 | mlp->pv.m_q, | ||
847 | p->num_elements); | ||
833 | 848 | ||
834 | /* Set a problem name */ | 849 | /* Set a problem name */ |
835 | glp_set_prob_name (p->prob, "GNUnet ATS bandwidth distribution"); | 850 | glp_set_prob_name (p->prob, "GNUnet ATS bandwidth distribution"); |
@@ -859,7 +874,9 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp) | |||
859 | mlp_create_problem_add_invariant_rows (mlp, p); | 874 | mlp_create_problem_add_invariant_rows (mlp, p); |
860 | 875 | ||
861 | /* Adding address dependent columns constraint rows */ | 876 | /* Adding address dependent columns constraint rows */ |
862 | GNUNET_CONTAINER_multihashmap_iterate (mlp->addresses, &mlp_create_problem_add_address_information, mlp); | 877 | GNUNET_CONTAINER_multipeermap_iterate (mlp->addresses, |
878 | &mlp_create_problem_add_address_information, | ||
879 | mlp); | ||
863 | 880 | ||
864 | /* Load the matrix */ | 881 | /* Load the matrix */ |
865 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Loading matrix\n"); | 882 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Loading matrix\n"); |
@@ -941,10 +958,12 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp) | |||
941 | * @param cls the MLP handle | 958 | * @param cls the MLP handle |
942 | * @param key the peer identity | 959 | * @param key the peer identity |
943 | * @param value the address | 960 | * @param value the address |
944 | * @return GNUNET_OK to continue | 961 | * @return #GNUNET_OK to continue |
945 | */ | 962 | */ |
946 | int | 963 | int |
947 | mlp_propagate_results (void *cls, const struct GNUNET_HashCode *key, void *value) | 964 | mlp_propagate_results (void *cls, |
965 | const struct GNUNET_PeerIdentity *key, | ||
966 | void *value) | ||
948 | { | 967 | { |
949 | struct GAS_MLP_Handle *mlp = cls; | 968 | struct GAS_MLP_Handle *mlp = cls; |
950 | struct ATS_Address *address; | 969 | struct ATS_Address *address; |
@@ -954,7 +973,8 @@ mlp_propagate_results (void *cls, const struct GNUNET_HashCode *key, void *value | |||
954 | double mlp_use = MLP_NaN; | 973 | double mlp_use = MLP_NaN; |
955 | 974 | ||
956 | /* Check if we have to add this peer due to a pending request */ | 975 | /* Check if we have to add this peer due to a pending request */ |
957 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->requested_peers, key)) | 976 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mlp->requested_peers, |
977 | key)) | ||
958 | { | 978 | { |
959 | return GNUNET_OK; | 979 | return GNUNET_OK; |
960 | } | 980 | } |
@@ -1082,9 +1102,9 @@ GAS_mlp_solve_problem (void *solver) | |||
1082 | return GNUNET_NO; | 1102 | return GNUNET_NO; |
1083 | } | 1103 | } |
1084 | 1104 | ||
1085 | if (0 == GNUNET_CONTAINER_multihashmap_size(mlp->requested_peers)) | 1105 | if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers)) |
1086 | return GNUNET_OK; /* No pending requests */ | 1106 | return GNUNET_OK; /* No pending requests */ |
1087 | if (0 == GNUNET_CONTAINER_multihashmap_size(mlp->addresses)) | 1107 | if (0 == GNUNET_CONTAINER_multipeermap_size (mlp->addresses)) |
1088 | return GNUNET_OK; /* No addresses available */ | 1108 | return GNUNET_OK; /* No addresses available */ |
1089 | 1109 | ||
1090 | if ((GNUNET_NO == mlp->mlp_prob_changed) && (GNUNET_NO == mlp->mlp_prob_updated)) | 1110 | if ((GNUNET_NO == mlp->mlp_prob_changed) && (GNUNET_NO == mlp->mlp_prob_updated)) |
@@ -1149,7 +1169,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1149 | /* Propagate result*/ | 1169 | /* Propagate result*/ |
1150 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) | 1170 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) |
1151 | { | 1171 | { |
1152 | GNUNET_CONTAINER_multihashmap_iterate (mlp->addresses, &mlp_propagate_results, mlp); | 1172 | GNUNET_CONTAINER_multipeermap_iterate (mlp->addresses, &mlp_propagate_results, mlp); |
1153 | } | 1173 | } |
1154 | 1174 | ||
1155 | struct GNUNET_TIME_Absolute time = GNUNET_TIME_absolute_get(); | 1175 | struct GNUNET_TIME_Absolute time = GNUNET_TIME_absolute_get(); |
@@ -1201,13 +1221,16 @@ GAS_mlp_address_add (void *solver, | |||
1201 | 1221 | ||
1202 | if (NULL == address->solver_information) | 1222 | if (NULL == address->solver_information) |
1203 | { | 1223 | { |
1204 | address->solver_information = GNUNET_malloc (sizeof (struct MLP_information)); | 1224 | address->solver_information = GNUNET_new (struct MLP_information); |
1205 | } | 1225 | } |
1206 | else | 1226 | else |
1207 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Adding address for peer `%s' multiple times\n"), GNUNET_i2s(&address->peer)); | 1227 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1228 | _("Adding address for peer `%s' multiple times\n"), | ||
1229 | GNUNET_i2s(&address->peer)); | ||
1208 | 1230 | ||
1209 | /* Is this peer included in the problem? */ | 1231 | /* Is this peer included in the problem? */ |
1210 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &address->peer.hashPubKey))) | 1232 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1233 | &address->peer))) | ||
1211 | { | 1234 | { |
1212 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s' without address request \n", GNUNET_i2s(&address->peer)); | 1235 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s' without address request \n", GNUNET_i2s(&address->peer)); |
1213 | return; | 1236 | return; |
@@ -1257,8 +1280,8 @@ GAS_mlp_address_property_changed (void *solver, | |||
1257 | return; | 1280 | return; |
1258 | } | 1281 | } |
1259 | 1282 | ||
1260 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, | 1283 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1261 | &address->peer.hashPubKey))) | 1284 | &address->peer))) |
1262 | { | 1285 | { |
1263 | /* Peer is not requested, so no need to update problem */ | 1286 | /* Peer is not requested, so no need to update problem */ |
1264 | return; | 1287 | return; |
@@ -1368,8 +1391,8 @@ GAS_mlp_address_change_network (void *solver, | |||
1368 | if (mlpi->c_b == MLP_UNDEFINED) | 1391 | if (mlpi->c_b == MLP_UNDEFINED) |
1369 | return; /* This address is not yet in the matrix*/ | 1392 | return; /* This address is not yet in the matrix*/ |
1370 | 1393 | ||
1371 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, | 1394 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1372 | &address->peer.hashPubKey))) | 1395 | &address->peer))) |
1373 | { | 1396 | { |
1374 | /* Peer is not requested, so no need to update problem */ | 1397 | /* Peer is not requested, so no need to update problem */ |
1375 | GNUNET_break (0); | 1398 | GNUNET_break (0); |
@@ -1467,7 +1490,8 @@ GAS_mlp_address_delete (void *solver, | |||
1467 | address->assigned_bw_out = BANDWIDTH_ZERO; | 1490 | address->assigned_bw_out = BANDWIDTH_ZERO; |
1468 | 1491 | ||
1469 | /* Is this peer included in the problem? */ | 1492 | /* Is this peer included in the problem? */ |
1470 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &address->peer.hashPubKey))) | 1493 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1494 | &address->peer))) | ||
1471 | { | 1495 | { |
1472 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s for peer `%s' without address request \n", | 1496 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s for peer `%s' without address request \n", |
1473 | (session_only == GNUNET_YES) ? "session" : "address", | 1497 | (session_only == GNUNET_YES) ? "session" : "address", |
@@ -1505,12 +1529,15 @@ GAS_mlp_address_delete (void *solver, | |||
1505 | * @return GNUNET_OK | 1529 | * @return GNUNET_OK |
1506 | */ | 1530 | */ |
1507 | static int | 1531 | static int |
1508 | mlp_get_preferred_address_it (void *cls, const struct GNUNET_HashCode * key, void *value) | 1532 | mlp_get_preferred_address_it (void *cls, |
1533 | const struct GNUNET_PeerIdentity *key, | ||
1534 | void *value) | ||
1509 | { | 1535 | { |
1510 | static int counter = 0; | 1536 | static int counter = 0; |
1511 | struct ATS_Address **aa = (struct ATS_Address **) cls; | 1537 | struct ATS_Address **aa = cls; |
1512 | struct ATS_Address *addr = value; | 1538 | struct ATS_Address *addr = value; |
1513 | struct MLP_information *mlpi = addr->solver_information; | 1539 | struct MLP_information *mlpi = addr->solver_information; |
1540 | |||
1514 | if (mlpi == NULL) | 1541 | if (mlpi == NULL) |
1515 | return GNUNET_YES; | 1542 | return GNUNET_YES; |
1516 | 1543 | ||
@@ -1536,7 +1563,8 @@ mlp_get_preferred_address_it (void *cls, const struct GNUNET_HashCode * key, voi | |||
1536 | } | 1563 | } |
1537 | 1564 | ||
1538 | 1565 | ||
1539 | static double get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentity *peer) | 1566 | static double |
1567 | get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentity *peer) | ||
1540 | { | 1568 | { |
1541 | double res; | 1569 | double res; |
1542 | const double *preferences = NULL; | 1570 | const double *preferences = NULL; |
@@ -1579,22 +1607,25 @@ GAS_mlp_get_preferred_address (void *solver, | |||
1579 | GNUNET_i2s (peer)); | 1607 | GNUNET_i2s (peer)); |
1580 | 1608 | ||
1581 | /* Is this peer included in the problem? */ | 1609 | /* Is this peer included in the problem? */ |
1582 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &peer->hashPubKey))) | 1610 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, |
1583 | { | 1611 | peer))) |
1612 | { | ||
1584 | LOG (GNUNET_ERROR_TYPE_INFO, "Adding peer `%s' to list of requested_peers with requests\n", | 1613 | LOG (GNUNET_ERROR_TYPE_INFO, "Adding peer `%s' to list of requested_peers with requests\n", |
1585 | GNUNET_i2s (peer)); | 1614 | GNUNET_i2s (peer)); |
1586 | 1615 | ||
1587 | p = GNUNET_malloc (sizeof (struct ATS_Peer)); | 1616 | p = GNUNET_malloc (sizeof (struct ATS_Peer)); |
1588 | p->id = (*peer); | 1617 | p->id = (*peer); |
1589 | p->f = get_peer_pref_value (mlp, peer); | 1618 | p->f = get_peer_pref_value (mlp, peer); |
1590 | GNUNET_CONTAINER_multihashmap_put (mlp->requested_peers, &peer->hashPubKey, p, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1619 | GNUNET_CONTAINER_multipeermap_put (mlp->requested_peers, |
1620 | peer, p, | ||
1621 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
1591 | 1622 | ||
1592 | /* Added new peer, we have to rebuild problem before solving */ | 1623 | /* Added new peer, we have to rebuild problem before solving */ |
1593 | mlp->mlp_prob_changed = GNUNET_YES; | 1624 | mlp->mlp_prob_changed = GNUNET_YES; |
1594 | 1625 | ||
1595 | if ((GNUNET_YES == mlp->mlp_auto_solve)&& | 1626 | if ((GNUNET_YES == mlp->mlp_auto_solve)&& |
1596 | (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(mlp->addresses, | 1627 | (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains(mlp->addresses, |
1597 | &peer->hashPubKey))) | 1628 | peer))) |
1598 | { | 1629 | { |
1599 | mlp->exclude_peer = peer; | 1630 | mlp->exclude_peer = peer; |
1600 | GAS_mlp_solve_problem (mlp); | 1631 | GAS_mlp_solve_problem (mlp); |
@@ -1603,7 +1634,7 @@ GAS_mlp_get_preferred_address (void *solver, | |||
1603 | } | 1634 | } |
1604 | /* Get prefered address */ | 1635 | /* Get prefered address */ |
1605 | res = NULL; | 1636 | res = NULL; |
1606 | GNUNET_CONTAINER_multihashmap_get_multiple (mlp->addresses, &peer->hashPubKey, | 1637 | GNUNET_CONTAINER_multipeermap_get_multiple (mlp->addresses, peer, |
1607 | mlp_get_preferred_address_it, &res); | 1638 | mlp_get_preferred_address_it, &res); |
1608 | return res; | 1639 | return res; |
1609 | } | 1640 | } |
@@ -1664,9 +1695,9 @@ GAS_mlp_stop_get_preferred_address (void *solver, | |||
1664 | 1695 | ||
1665 | GNUNET_assert (NULL != solver); | 1696 | GNUNET_assert (NULL != solver); |
1666 | GNUNET_assert (NULL != peer); | 1697 | GNUNET_assert (NULL != peer); |
1667 | if (NULL != (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &peer->hashPubKey))) | 1698 | if (NULL != (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, peer))) |
1668 | { | 1699 | { |
1669 | GNUNET_CONTAINER_multihashmap_remove (mlp->requested_peers, &peer->hashPubKey, p); | 1700 | GNUNET_CONTAINER_multipeermap_remove (mlp->requested_peers, peer, p); |
1670 | GNUNET_free (p); | 1701 | GNUNET_free (p); |
1671 | 1702 | ||
1672 | mlp->mlp_prob_changed = GNUNET_YES; | 1703 | mlp->mlp_prob_changed = GNUNET_YES; |
@@ -1704,7 +1735,7 @@ GAS_mlp_address_change_preference (void *solver, | |||
1704 | /* Update quality constraint c7 */ | 1735 | /* Update quality constraint c7 */ |
1705 | 1736 | ||
1706 | /* Update relativity constraint c9 */ | 1737 | /* Update relativity constraint c9 */ |
1707 | if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->requested_peers, &peer->hashPubKey))) | 1738 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, peer))) |
1708 | { | 1739 | { |
1709 | LOG (GNUNET_ERROR_TYPE_ERROR, "Updating preference for unknown peer `%s'\n", GNUNET_i2s(peer)); | 1740 | LOG (GNUNET_ERROR_TYPE_ERROR, "Updating preference for unknown peer `%s'\n", GNUNET_i2s(peer)); |
1710 | return; | 1741 | return; |
@@ -1749,12 +1780,13 @@ GAS_mlp_address_preference_feedback (void *solver, | |||
1749 | 1780 | ||
1750 | 1781 | ||
1751 | static int | 1782 | static int |
1752 | mlp_free_peers (void *cls, const struct GNUNET_HashCode *key, void *value) | 1783 | mlp_free_peers (void *cls, |
1784 | const struct GNUNET_PeerIdentity *key, void *value) | ||
1753 | { | 1785 | { |
1754 | struct GNUNET_CONTAINER_MultiHashMap *map = cls; | 1786 | struct GNUNET_CONTAINER_MultiPeerMap *map = cls; |
1755 | struct ATS_Peer *p = value; | 1787 | struct ATS_Peer *p = value; |
1756 | 1788 | ||
1757 | GNUNET_CONTAINER_multihashmap_remove (map, key, value); | 1789 | GNUNET_CONTAINER_multipeermap_remove (map, key, value); |
1758 | GNUNET_free (p); | 1790 | GNUNET_free (p); |
1759 | 1791 | ||
1760 | return GNUNET_OK; | 1792 | return GNUNET_OK; |
@@ -1775,8 +1807,10 @@ GAS_mlp_done (void *solver) | |||
1775 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down mlp solver\n"); | 1807 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down mlp solver\n"); |
1776 | mlp_delete_problem (mlp); | 1808 | mlp_delete_problem (mlp); |
1777 | 1809 | ||
1778 | GNUNET_CONTAINER_multihashmap_iterate (mlp->requested_peers, &mlp_free_peers, mlp->requested_peers); | 1810 | GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers, |
1779 | GNUNET_CONTAINER_multihashmap_destroy (mlp->requested_peers); | 1811 | &mlp_free_peers, |
1812 | mlp->requested_peers); | ||
1813 | GNUNET_CONTAINER_multipeermap_destroy (mlp->requested_peers); | ||
1780 | mlp->requested_peers = NULL; | 1814 | mlp->requested_peers = NULL; |
1781 | 1815 | ||
1782 | /* Clean up GLPK environment */ | 1816 | /* Clean up GLPK environment */ |
@@ -1808,7 +1842,7 @@ GAS_mlp_done (void *solver) | |||
1808 | void * | 1842 | void * |
1809 | GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1843 | GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1810 | const struct GNUNET_STATISTICS_Handle *stats, | 1844 | const struct GNUNET_STATISTICS_Handle *stats, |
1811 | const struct GNUNET_CONTAINER_MultiHashMap *addresses, | 1845 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses, |
1812 | int *network, | 1846 | int *network, |
1813 | unsigned long long *out_dest, | 1847 | unsigned long long *out_dest, |
1814 | unsigned long long *in_dest, | 1848 | unsigned long long *in_dest, |
@@ -2052,7 +2086,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2052 | mlp->mlp_prob_changed = GNUNET_NO; | 2086 | mlp->mlp_prob_changed = GNUNET_NO; |
2053 | mlp->mlp_prob_updated = GNUNET_NO; | 2087 | mlp->mlp_prob_updated = GNUNET_NO; |
2054 | mlp->mlp_auto_solve = GNUNET_YES; | 2088 | mlp->mlp_auto_solve = GNUNET_YES; |
2055 | mlp->requested_peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 2089 | mlp->requested_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
2056 | mlp->bulk_request = 0; | 2090 | mlp->bulk_request = 0; |
2057 | mlp->bulk_lock = 0; | 2091 | mlp->bulk_lock = 0; |
2058 | 2092 | ||
diff --git a/src/ats/gnunet-service-ats-solver_mlp.h b/src/ats/gnunet-service-ats-solver_mlp.h index c31d44b5e..1f4f0ec8c 100644 --- a/src/ats/gnunet-service-ats-solver_mlp.h +++ b/src/ats/gnunet-service-ats-solver_mlp.h | |||
@@ -212,7 +212,7 @@ struct GAS_MLP_Handle | |||
212 | /** | 212 | /** |
213 | * Address hashmap for lookups | 213 | * Address hashmap for lookups |
214 | */ | 214 | */ |
215 | const struct GNUNET_CONTAINER_MultiHashMap *addresses; | 215 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses; |
216 | 216 | ||
217 | /** | 217 | /** |
218 | * Addresses' bandwidth changed callback | 218 | * Addresses' bandwidth changed callback |
@@ -296,7 +296,7 @@ struct GAS_MLP_Handle | |||
296 | /** | 296 | /** |
297 | * Peers with pending address requests | 297 | * Peers with pending address requests |
298 | */ | 298 | */ |
299 | struct GNUNET_CONTAINER_MultiHashMap *requested_peers; | 299 | struct GNUNET_CONTAINER_MultiPeerMap *requested_peers; |
300 | 300 | ||
301 | /** | 301 | /** |
302 | * Was the problem updated since last solution | 302 | * Was the problem updated since last solution |
@@ -355,15 +355,17 @@ struct MLP_information | |||
355 | unsigned int r_c3; | 355 | unsigned int r_c3; |
356 | }; | 356 | }; |
357 | 357 | ||
358 | |||
358 | /** | 359 | /** |
359 | * Solves the MLP problem | 360 | * Solves the MLP problem |
360 | * | 361 | * |
361 | * @param solver the MLP Handle | 362 | * @param solver the MLP Handle |
362 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure | 363 | * @return #GNUNET_OK if could be solved, GNUNET_SYSERR on failure |
363 | */ | 364 | */ |
364 | int | 365 | int |
365 | GAS_mlp_solve_problem (void *solver); | 366 | GAS_mlp_solve_problem (void *solver); |
366 | 367 | ||
368 | |||
367 | /** | 369 | /** |
368 | * Init the MLP problem solving component | 370 | * Init the MLP problem solving component |
369 | * | 371 | * |
@@ -383,13 +385,14 @@ GAS_mlp_solve_problem (void *solver); | |||
383 | */ | 385 | */ |
384 | void * | 386 | void * |
385 | GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 387 | GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, |
386 | const struct GNUNET_STATISTICS_Handle *stats, | 388 | const struct GNUNET_STATISTICS_Handle *stats, |
387 | const struct GNUNET_CONTAINER_MultiHashMap *addresses, int *network, | 389 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses, int *network, |
388 | unsigned long long *out_dest, unsigned long long *in_dest, int dest_length, | 390 | unsigned long long *out_dest, unsigned long long *in_dest, int dest_length, |
389 | GAS_bandwidth_changed_cb bw_changed_cb, void *bw_changed_cb_cls, | 391 | GAS_bandwidth_changed_cb bw_changed_cb, void *bw_changed_cb_cls, |
390 | GAS_get_preferences get_preference, void *get_preference_cls, | 392 | GAS_get_preferences get_preference, void *get_preference_cls, |
391 | GAS_get_properties get_properties, void *get_properties_cls); | 393 | GAS_get_properties get_properties, void *get_properties_cls); |
392 | 394 | ||
395 | |||
393 | /** | 396 | /** |
394 | * Add a single address within a network to the solver | 397 | * Add a single address within a network to the solver |
395 | * | 398 | * |
@@ -401,6 +404,7 @@ void | |||
401 | GAS_mlp_address_add (void *solver, struct ATS_Address *address, | 404 | GAS_mlp_address_add (void *solver, struct ATS_Address *address, |
402 | uint32_t network); | 405 | uint32_t network); |
403 | 406 | ||
407 | |||
404 | /** | 408 | /** |
405 | * Transport properties for this address have changed | 409 | * Transport properties for this address have changed |
406 | * | 410 | * |
@@ -414,6 +418,7 @@ void | |||
414 | GAS_mlp_address_property_changed (void *solver, struct ATS_Address *address, | 418 | GAS_mlp_address_property_changed (void *solver, struct ATS_Address *address, |
415 | uint32_t type, uint32_t abs_value, double rel_value); | 419 | uint32_t type, uint32_t abs_value, double rel_value); |
416 | 420 | ||
421 | |||
417 | /** | 422 | /** |
418 | * Transport session for this address has changed | 423 | * Transport session for this address has changed |
419 | * | 424 | * |
@@ -426,7 +431,8 @@ GAS_mlp_address_property_changed (void *solver, struct ATS_Address *address, | |||
426 | */ | 431 | */ |
427 | void | 432 | void |
428 | GAS_mlp_address_session_changed (void *solver, struct ATS_Address *address, | 433 | GAS_mlp_address_session_changed (void *solver, struct ATS_Address *address, |
429 | uint32_t cur_session, uint32_t new_session); | 434 | uint32_t cur_session, uint32_t new_session); |
435 | |||
430 | 436 | ||
431 | /** | 437 | /** |
432 | * Usage for this address has changed | 438 | * Usage for this address has changed |
diff --git a/src/ats/gnunet-service-ats-solver_proportional.c b/src/ats/gnunet-service-ats-solver_proportional.c index 31d27fd2a..e9a553ad6 100644 --- a/src/ats/gnunet-service-ats-solver_proportional.c +++ b/src/ats/gnunet-service-ats-solver_proportional.c | |||
@@ -225,12 +225,12 @@ struct GAS_PROPORTIONAL_Handle | |||
225 | /** | 225 | /** |
226 | * Hashmap containing all valid addresses | 226 | * Hashmap containing all valid addresses |
227 | */ | 227 | */ |
228 | const struct GNUNET_CONTAINER_MultiHashMap *addresses; | 228 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses; |
229 | 229 | ||
230 | /** | 230 | /** |
231 | * Pending address requests | 231 | * Pending address requests |
232 | */ | 232 | */ |
233 | struct GNUNET_CONTAINER_MultiHashMap *requests; | 233 | struct GNUNET_CONTAINER_MultiPeerMap *requests; |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * Bandwidth changed callback | 236 | * Bandwidth changed callback |
@@ -576,8 +576,9 @@ find_property_index (uint32_t type) | |||
576 | * @return GNUNET_OK (continue to iterate) | 576 | * @return GNUNET_OK (continue to iterate) |
577 | */ | 577 | */ |
578 | static int | 578 | static int |
579 | find_best_address_it (void *cls, const struct GNUNET_HashCode * key, | 579 | find_best_address_it (void *cls, |
580 | void *value) | 580 | const struct GNUNET_PeerIdentity *key, |
581 | void *value) | ||
581 | { | 582 | { |
582 | struct FindBestAddressCtx *fba_ctx = (struct FindBestAddressCtx *) cls; | 583 | struct FindBestAddressCtx *fba_ctx = (struct FindBestAddressCtx *) cls; |
583 | struct ATS_Address *current = (struct ATS_Address *) value; | 584 | struct ATS_Address *current = (struct ATS_Address *) value; |
@@ -717,11 +718,12 @@ get_network (struct GAS_PROPORTIONAL_Handle *s, uint32_t type) | |||
717 | * @param cls last active address | 718 | * @param cls last active address |
718 | * @param key peer's key | 719 | * @param key peer's key |
719 | * @param value address to check | 720 | * @param value address to check |
720 | * @return GNUNET_NO on double active address else GNUNET_YES; | 721 | * @return #GNUNET_NO on double active address else #GNUNET_YES; |
721 | */ | 722 | */ |
722 | static int | 723 | static int |
723 | get_active_address_it (void *cls, const struct GNUNET_HashCode * key, | 724 | get_active_address_it (void *cls, |
724 | void *value) | 725 | const struct GNUNET_PeerIdentity *key, |
726 | void *value) | ||
725 | { | 727 | { |
726 | struct ATS_Address **dest = cls; | 728 | struct ATS_Address **dest = cls; |
727 | struct ATS_Address *aa = (struct ATS_Address *) value; | 729 | struct ATS_Address *aa = (struct ATS_Address *) value; |
@@ -752,16 +754,17 @@ get_active_address_it (void *cls, const struct GNUNET_HashCode * key, | |||
752 | */ | 754 | */ |
753 | static struct ATS_Address * | 755 | static struct ATS_Address * |
754 | get_active_address (void *solver, | 756 | get_active_address (void *solver, |
755 | struct GNUNET_CONTAINER_MultiHashMap * addresses, | 757 | const struct GNUNET_CONTAINER_MultiPeerMap * addresses, |
756 | const struct GNUNET_PeerIdentity *peer) | 758 | const struct GNUNET_PeerIdentity *peer) |
757 | { | 759 | { |
758 | struct ATS_Address * dest = NULL; | 760 | struct ATS_Address * dest = NULL; |
759 | 761 | ||
760 | GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey, | 762 | GNUNET_CONTAINER_multipeermap_get_multiple (addresses, peer, |
761 | &get_active_address_it, &dest); | 763 | &get_active_address_it, &dest); |
762 | return dest; | 764 | return dest; |
763 | } | 765 | } |
764 | 766 | ||
767 | |||
765 | static void | 768 | static void |
766 | addresse_increment (struct GAS_PROPORTIONAL_Handle *s, struct Network *net, | 769 | addresse_increment (struct GAS_PROPORTIONAL_Handle *s, struct Network *net, |
767 | int total, int active) | 770 | int total, int active) |
@@ -784,6 +787,7 @@ addresse_increment (struct GAS_PROPORTIONAL_Handle *s, struct Network *net, | |||
784 | 787 | ||
785 | } | 788 | } |
786 | 789 | ||
790 | |||
787 | static int | 791 | static int |
788 | addresse_decrement (struct GAS_PROPORTIONAL_Handle *s, struct Network *net, | 792 | addresse_decrement (struct GAS_PROPORTIONAL_Handle *s, struct Network *net, |
789 | int total, int active) | 793 | int total, int active) |
@@ -856,8 +860,9 @@ addresse_decrement (struct GAS_PROPORTIONAL_Handle *s, struct Network *net, | |||
856 | */ | 860 | */ |
857 | void | 861 | void |
858 | GAS_proportional_address_change_preference (void *solver, | 862 | GAS_proportional_address_change_preference (void *solver, |
859 | const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, | 863 | const struct GNUNET_PeerIdentity *peer, |
860 | double pref_rel) | 864 | enum GNUNET_ATS_PreferenceKind kind, |
865 | double pref_rel) | ||
861 | { | 866 | { |
862 | struct GAS_PROPORTIONAL_Handle *s = solver; | 867 | struct GAS_PROPORTIONAL_Handle *s = solver; |
863 | GNUNET_assert(NULL != solver); | 868 | GNUNET_assert(NULL != solver); |
@@ -866,6 +871,7 @@ GAS_proportional_address_change_preference (void *solver, | |||
866 | distribute_bandwidth_in_all_networks (s); | 871 | distribute_bandwidth_in_all_networks (s); |
867 | } | 872 | } |
868 | 873 | ||
874 | |||
869 | /** | 875 | /** |
870 | * Get application feedback for a peer | 876 | * Get application feedback for a peer |
871 | * | 877 | * |
@@ -910,19 +916,21 @@ GAS_proportional_get_preferred_address (void *solver, | |||
910 | GNUNET_assert(peer != NULL); | 916 | GNUNET_assert(peer != NULL); |
911 | 917 | ||
912 | /* Add to list of pending requests */ | 918 | /* Add to list of pending requests */ |
913 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (s->requests, | 919 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests, |
914 | &peer->hashPubKey)) | 920 | peer)) |
915 | { | 921 | { |
916 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (s->requests, &peer->hashPubKey, NULL, | 922 | GNUNET_assert (GNUNET_OK == |
917 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 923 | GNUNET_CONTAINER_multipeermap_put (s->requests, |
924 | peer, NULL, | ||
925 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
918 | } | 926 | } |
919 | 927 | ||
920 | /* Get address with: stick to current address, lower distance, lower latency */ | 928 | /* Get address with: stick to current address, lower distance, lower latency */ |
921 | fba_ctx.s = s; | 929 | fba_ctx.s = s; |
922 | fba_ctx.best = NULL; | 930 | fba_ctx.best = NULL; |
923 | 931 | ||
924 | GNUNET_CONTAINER_multihashmap_get_multiple (s->addresses, &peer->hashPubKey, | 932 | GNUNET_CONTAINER_multipeermap_get_multiple (s->addresses, peer, |
925 | &find_best_address_it, &fba_ctx); | 933 | &find_best_address_it, &fba_ctx); |
926 | if (NULL == fba_ctx.best) | 934 | if (NULL == fba_ctx.best) |
927 | { | 935 | { |
928 | LOG(GNUNET_ERROR_TYPE_INFO, "Cannot suggest address for peer `%s'\n", | 936 | LOG(GNUNET_ERROR_TYPE_INFO, "Cannot suggest address for peer `%s'\n", |
@@ -954,7 +962,7 @@ GAS_proportional_get_preferred_address (void *solver, | |||
954 | * - update quota for this address network | 962 | * - update quota for this address network |
955 | */ | 963 | */ |
956 | prev = get_active_address (s, | 964 | prev = get_active_address (s, |
957 | (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses, peer); | 965 | s->addresses, peer); |
958 | if (NULL != prev) | 966 | if (NULL != prev) |
959 | { | 967 | { |
960 | net_prev = (struct Network *) prev->solver_information; | 968 | net_prev = (struct Network *) prev->solver_information; |
@@ -993,13 +1001,13 @@ GAS_proportional_stop_get_preferred_address (void *solver, | |||
993 | struct Network *cur_net; | 1001 | struct Network *cur_net; |
994 | 1002 | ||
995 | if (GNUNET_YES | 1003 | if (GNUNET_YES |
996 | == GNUNET_CONTAINER_multihashmap_contains (s->requests, | 1004 | == GNUNET_CONTAINER_multipeermap_contains (s->requests, |
997 | &peer->hashPubKey)) | 1005 | peer)) |
998 | GNUNET_CONTAINER_multihashmap_remove (s->requests, &peer->hashPubKey, | 1006 | GNUNET_CONTAINER_multipeermap_remove (s->requests, peer, |
999 | NULL ); | 1007 | NULL); |
1000 | 1008 | ||
1001 | cur = get_active_address (s, | 1009 | cur = get_active_address (s, |
1002 | (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses, peer); | 1010 | s->addresses, peer); |
1003 | if (NULL != cur) | 1011 | if (NULL != cur) |
1004 | { | 1012 | { |
1005 | /* Disabling current address */ | 1013 | /* Disabling current address */ |
@@ -1115,6 +1123,7 @@ GAS_proportional_bulk_start (void *solver) | |||
1115 | s->bulk_lock++; | 1123 | s->bulk_lock++; |
1116 | } | 1124 | } |
1117 | 1125 | ||
1126 | |||
1118 | /** | 1127 | /** |
1119 | * Bulk operation done | 1128 | * Bulk operation done |
1120 | */ | 1129 | */ |
@@ -1140,6 +1149,7 @@ GAS_proportional_bulk_stop (void *solver) | |||
1140 | } | 1149 | } |
1141 | } | 1150 | } |
1142 | 1151 | ||
1152 | |||
1143 | /** | 1153 | /** |
1144 | * Add a new single address to a network | 1154 | * Add a new single address to a network |
1145 | * | 1155 | * |
@@ -1357,9 +1367,9 @@ GAS_proportional_address_add (void *solver, struct ATS_Address *address, | |||
1357 | addresse_increment (s, net, GNUNET_YES, GNUNET_NO); | 1367 | addresse_increment (s, net, GNUNET_YES, GNUNET_NO); |
1358 | aw->addr->solver_information = net; | 1368 | aw->addr->solver_information = net; |
1359 | 1369 | ||
1360 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (s->requests, &address->peer.hashPubKey)) | 1370 | if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer)) |
1361 | { | 1371 | { |
1362 | if (NULL == get_active_address (s, (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses, &address->peer)) | 1372 | if (NULL == get_active_address (s, s->addresses, &address->peer)) |
1363 | { | 1373 | { |
1364 | if (NULL != (new_address = GAS_proportional_get_preferred_address (s, &address->peer))) | 1374 | if (NULL != (new_address = GAS_proportional_get_preferred_address (s, &address->peer))) |
1365 | s->bw_changed (s->bw_changed_cls, (struct ATS_Address *) address); | 1375 | s->bw_changed (s->bw_changed_cls, (struct ATS_Address *) address); |
@@ -1401,13 +1411,13 @@ GAS_proportional_address_add (void *solver, struct ATS_Address *address, | |||
1401 | */ | 1411 | */ |
1402 | void * | 1412 | void * |
1403 | GAS_proportional_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1413 | GAS_proportional_init (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1404 | const struct GNUNET_STATISTICS_Handle *stats, | 1414 | const struct GNUNET_STATISTICS_Handle *stats, |
1405 | const struct GNUNET_CONTAINER_MultiHashMap *addresses, int *network, | 1415 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses, int *network, |
1406 | unsigned long long *out_quota, unsigned long long *in_quota, | 1416 | unsigned long long *out_quota, unsigned long long *in_quota, |
1407 | int dest_length, GAS_bandwidth_changed_cb bw_changed_cb, | 1417 | int dest_length, GAS_bandwidth_changed_cb bw_changed_cb, |
1408 | void *bw_changed_cb_cls, GAS_get_preferences get_preference, | 1418 | void *bw_changed_cb_cls, GAS_get_preferences get_preference, |
1409 | void *get_preference_cls, GAS_get_properties get_properties, | 1419 | void *get_preference_cls, GAS_get_properties get_properties, |
1410 | void *get_properties_cls) | 1420 | void *get_properties_cls) |
1411 | { | 1421 | { |
1412 | int c; | 1422 | int c; |
1413 | struct GAS_PROPORTIONAL_Handle *s = | 1423 | struct GAS_PROPORTIONAL_Handle *s = |
@@ -1436,7 +1446,7 @@ GAS_proportional_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1436 | s->bulk_lock = GNUNET_NO; | 1446 | s->bulk_lock = GNUNET_NO; |
1437 | s->addresses = addresses; | 1447 | s->addresses = addresses; |
1438 | 1448 | ||
1439 | s->requests = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 1449 | s->requests = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
1440 | 1450 | ||
1441 | for (c = 0; c < dest_length; c++) | 1451 | for (c = 0; c < dest_length; c++) |
1442 | { | 1452 | { |
@@ -1508,11 +1518,11 @@ GAS_proportional_done (void *solver) | |||
1508 | LOG(GNUNET_ERROR_TYPE_ERROR, | 1518 | LOG(GNUNET_ERROR_TYPE_ERROR, |
1509 | "Had %u active addresses not deleted during shutdown\n", | 1519 | "Had %u active addresses not deleted during shutdown\n", |
1510 | s->active_addresses); | 1520 | s->active_addresses); |
1511 | GNUNET_break(0); | 1521 | GNUNET_break (0); |
1512 | } | 1522 | } |
1513 | GNUNET_free(s->network_entries); | 1523 | GNUNET_free (s->network_entries); |
1514 | GNUNET_CONTAINER_multihashmap_destroy (s->requests); | 1524 | GNUNET_CONTAINER_multipeermap_destroy (s->requests); |
1515 | GNUNET_free(s); | 1525 | GNUNET_free (s); |
1516 | } | 1526 | } |
1517 | 1527 | ||
1518 | /* end of gnunet-service-ats-solver_proportional.c */ | 1528 | /* end of gnunet-service-ats-solver_proportional.c */ |
diff --git a/src/ats/gnunet-service-ats-solver_proportional.h b/src/ats/gnunet-service-ats-solver_proportional.h index 13cf54e8d..87b448866 100644 --- a/src/ats/gnunet-service-ats-solver_proportional.h +++ b/src/ats/gnunet-service-ats-solver_proportional.h | |||
@@ -95,7 +95,7 @@ GAS_proportional_address_preference_feedback (void *solver, void *application, | |||
95 | void * | 95 | void * |
96 | GAS_proportional_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 96 | GAS_proportional_init (const struct GNUNET_CONFIGURATION_Handle *cfg, |
97 | const struct GNUNET_STATISTICS_Handle *stats, | 97 | const struct GNUNET_STATISTICS_Handle *stats, |
98 | const struct GNUNET_CONTAINER_MultiHashMap *addresses, int *network, | 98 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses, int *network, |
99 | unsigned long long *out_quota, unsigned long long *in_quota, | 99 | unsigned long long *out_quota, unsigned long long *in_quota, |
100 | int dest_length, GAS_bandwidth_changed_cb bw_changed_cb, | 100 | int dest_length, GAS_bandwidth_changed_cb bw_changed_cb, |
101 | void *bw_changed_cb_cls, GAS_get_preferences get_preference, | 101 | void *bw_changed_cb_cls, GAS_get_preferences get_preference, |
diff --git a/src/ats/gnunet-service-ats-solver_ril.c b/src/ats/gnunet-service-ats-solver_ril.c index 8cc91bdf3..512184627 100755 --- a/src/ats/gnunet-service-ats-solver_ril.c +++ b/src/ats/gnunet-service-ats-solver_ril.c | |||
@@ -290,7 +290,7 @@ struct GAS_RIL_Handle | |||
290 | /** | 290 | /** |
291 | * Hashmap containing all valid addresses | 291 | * Hashmap containing all valid addresses |
292 | */ | 292 | */ |
293 | const struct GNUNET_CONTAINER_MultiHashMap *addresses; | 293 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses; |
294 | 294 | ||
295 | /** | 295 | /** |
296 | * Callbacks for the solver | 296 | * Callbacks for the solver |
@@ -976,7 +976,9 @@ ril_get_agent (struct GAS_RIL_Handle *solver, const struct GNUNET_PeerIdentity * | |||
976 | 976 | ||
977 | for (cur = solver->agents_head; NULL != cur; cur = cur->next) | 977 | for (cur = solver->agents_head; NULL != cur; cur = cur->next) |
978 | { | 978 | { |
979 | if (0 == GNUNET_CRYPTO_hash_cmp (&peer->hashPubKey, &cur->peer.hashPubKey)) | 979 | if (0 == memcmp (peer, |
980 | &cur->peer, | ||
981 | sizeof (struct GNUNET_PeerIdentity))) | ||
980 | { | 982 | { |
981 | return cur; | 983 | return cur; |
982 | } | 984 | } |
@@ -1129,7 +1131,7 @@ GAS_ril_address_change_preference (void *s, | |||
1129 | void * | 1131 | void * |
1130 | GAS_ril_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1132 | GAS_ril_init (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1131 | const struct GNUNET_STATISTICS_Handle *stats, | 1133 | const struct GNUNET_STATISTICS_Handle *stats, |
1132 | const struct GNUNET_CONTAINER_MultiHashMap *addresses, | 1134 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses, |
1133 | int *network, | 1135 | int *network, |
1134 | unsigned long long *out_quota, | 1136 | unsigned long long *out_quota, |
1135 | unsigned long long *in_quota, | 1137 | unsigned long long *in_quota, |
@@ -1145,7 +1147,7 @@ GAS_ril_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1145 | unsigned long long tmp; | 1147 | unsigned long long tmp; |
1146 | char *string; | 1148 | char *string; |
1147 | struct RIL_Network * cur; | 1149 | struct RIL_Network * cur; |
1148 | struct GAS_RIL_Handle *solver = GNUNET_malloc (sizeof (struct GAS_RIL_Handle)); | 1150 | struct GAS_RIL_Handle *solver = GNUNET_new (struct GAS_RIL_Handle); |
1149 | 1151 | ||
1150 | LOG(GNUNET_ERROR_TYPE_DEBUG, "API_init() Initializing RIL solver\n"); | 1152 | LOG(GNUNET_ERROR_TYPE_DEBUG, "API_init() Initializing RIL solver\n"); |
1151 | 1153 | ||
diff --git a/src/ats/gnunet-service-ats-solver_ril.h b/src/ats/gnunet-service-ats-solver_ril.h index 0053e3b9d..16f1fee5f 100755 --- a/src/ats/gnunet-service-ats-solver_ril.h +++ b/src/ats/gnunet-service-ats-solver_ril.h | |||
@@ -80,7 +80,7 @@ GAS_ril_address_change_preference (void *solver, | |||
80 | void * | 80 | void * |
81 | GAS_ril_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | 81 | GAS_ril_init (const struct GNUNET_CONFIGURATION_Handle *cfg, |
82 | const struct GNUNET_STATISTICS_Handle *stats, | 82 | const struct GNUNET_STATISTICS_Handle *stats, |
83 | const struct GNUNET_CONTAINER_MultiHashMap *addresses, | 83 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses, |
84 | int *network, | 84 | int *network, |
85 | unsigned long long *out_quota, | 85 | unsigned long long *out_quota, |
86 | unsigned long long *in_quota, | 86 | unsigned long long *in_quota, |
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 4db70dbae..8e3692b8e 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -294,7 +294,7 @@ struct GAS_Addresses_Handle | |||
294 | /** | 294 | /** |
295 | * A multihashmap to store all addresses | 295 | * A multihashmap to store all addresses |
296 | */ | 296 | */ |
297 | struct GNUNET_CONTAINER_MultiHashMap *addresses; | 297 | struct GNUNET_CONTAINER_MultiPeerMap *addresses; |
298 | 298 | ||
299 | /** | 299 | /** |
300 | * Configure WAN quota in | 300 | * Configure WAN quota in |
@@ -574,17 +574,19 @@ struct CompareAddressContext | |||
574 | struct ATS_Address *base_address; | 574 | struct ATS_Address *base_address; |
575 | }; | 575 | }; |
576 | 576 | ||
577 | |||
577 | /** | 578 | /** |
578 | * Comapre addresses | 579 | * Comapre addresses |
579 | * | 580 | * |
580 | * @param cls a CompareAddressContext containin the source address | 581 | * @param cls a CompareAddressContext containin the source address |
581 | * @param key peer id | 582 | * @param key peer id |
582 | * @param value the address to compare with | 583 | * @param value the address to compare with |
583 | * @return GNUNET_YES to continue, GNUNET_NO if address is founce | 584 | * @return #GNUNET_YES to continue, #GNUNET_NO if address is founce |
584 | */ | 585 | */ |
585 | |||
586 | static int | 586 | static int |
587 | compare_address_it (void *cls, const struct GNUNET_HashCode * key, void *value) | 587 | compare_address_it (void *cls, |
588 | const struct GNUNET_PeerIdentity *key, | ||
589 | void *value) | ||
588 | { | 590 | { |
589 | struct CompareAddressContext *cac = cls; | 591 | struct CompareAddressContext *cac = cls; |
590 | struct ATS_Address *aa = value; | 592 | struct ATS_Address *aa = value; |
@@ -672,14 +674,16 @@ find_equivalent_address (struct GAS_Addresses_Handle *handle, | |||
672 | cac.exact_address = NULL; | 674 | cac.exact_address = NULL; |
673 | cac.base_address = NULL; | 675 | cac.base_address = NULL; |
674 | cac.search = addr; | 676 | cac.search = addr; |
675 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses, | 677 | GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, |
676 | &peer->hashPubKey, &compare_address_it, &cac); | 678 | peer, |
679 | &compare_address_it, &cac); | ||
677 | 680 | ||
678 | if (cac.exact_address == NULL ) | 681 | if (cac.exact_address == NULL) |
679 | return cac.base_address; | 682 | return cac.base_address; |
680 | return cac.exact_address; | 683 | return cac.exact_address; |
681 | } | 684 | } |
682 | 685 | ||
686 | |||
683 | /** | 687 | /** |
684 | * Find the exact address | 688 | * Find the exact address |
685 | * | 689 | * |
@@ -787,13 +791,13 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, | |||
787 | { | 791 | { |
788 | /* Add a new address */ | 792 | /* Add a new address */ |
789 | GNUNET_assert( | 793 | GNUNET_assert( |
790 | GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (handle->addresses, | 794 | GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (handle->addresses, |
791 | &peer->hashPubKey, | 795 | peer, |
792 | new_address, | 796 | new_address, |
793 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 797 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
794 | 798 | ||
795 | GNUNET_STATISTICS_set (handle->stat, "# addresses", | 799 | GNUNET_STATISTICS_set (handle->stat, "# addresses", |
796 | GNUNET_CONTAINER_multihashmap_size (handle->addresses), GNUNET_NO); | 800 | GNUNET_CONTAINER_multipeermap_size (handle->addresses), GNUNET_NO); |
797 | 801 | ||
798 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 802 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
799 | "Adding new address %p for peer `%s', length %u, session id %u, %s\n", | 803 | "Adding new address %p for peer `%s', length %u, session id %u, %s\n", |
@@ -1013,8 +1017,9 @@ struct DestroyContext | |||
1013 | * @return GNUNET_OK (continue to iterate) | 1017 | * @return GNUNET_OK (continue to iterate) |
1014 | */ | 1018 | */ |
1015 | static int | 1019 | static int |
1016 | destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, | 1020 | destroy_by_session_id (void *cls, |
1017 | void *value) | 1021 | const struct GNUNET_PeerIdentity *key, |
1022 | void *value) | ||
1018 | { | 1023 | { |
1019 | struct DestroyContext *dc = cls; | 1024 | struct DestroyContext *dc = cls; |
1020 | struct GAS_Addresses_Handle *handle = dc->handle; | 1025 | struct GAS_Addresses_Handle *handle = dc->handle; |
@@ -1038,7 +1043,9 @@ destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, | |||
1038 | 1043 | ||
1039 | /* Notify solver about deletion */ | 1044 | /* Notify solver about deletion */ |
1040 | GNUNET_assert( | 1045 | GNUNET_assert( |
1041 | GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (handle->addresses, &aa->peer.hashPubKey, aa)); | 1046 | GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (handle->addresses, |
1047 | &aa->peer, | ||
1048 | aa)); | ||
1042 | handle->s_del (handle->solver, aa, GNUNET_NO); | 1049 | handle->s_del (handle->solver, aa, GNUNET_NO); |
1043 | free_address (aa); | 1050 | free_address (aa); |
1044 | dc->result = GNUNET_NO; | 1051 | dc->result = GNUNET_NO; |
@@ -1069,7 +1076,8 @@ destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, | |||
1069 | 1076 | ||
1070 | /* Notify solver about deletion */ | 1077 | /* Notify solver about deletion */ |
1071 | GNUNET_assert( | 1078 | GNUNET_assert( |
1072 | GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (handle->addresses, &aa->peer.hashPubKey, aa)); | 1079 | GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (handle->addresses, |
1080 | &aa->peer, aa)); | ||
1073 | handle->s_del (handle->solver, aa, GNUNET_NO); | 1081 | handle->s_del (handle->solver, aa, GNUNET_NO); |
1074 | free_address (aa); | 1082 | free_address (aa); |
1075 | dc->result = GNUNET_NO; | 1083 | dc->result = GNUNET_NO; |
@@ -1091,6 +1099,7 @@ destroy_by_session_id (void *cls, const struct GNUNET_HashCode * key, | |||
1091 | return GNUNET_OK; | 1099 | return GNUNET_OK; |
1092 | } | 1100 | } |
1093 | 1101 | ||
1102 | |||
1094 | /** | 1103 | /** |
1095 | * Remove an address or just a session for a peer. | 1104 | * Remove an address or just a session for a peer. |
1096 | * | 1105 | * |
@@ -1131,10 +1140,11 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, | |||
1131 | dc.aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, | 1140 | dc.aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, |
1132 | session_id); | 1141 | session_id); |
1133 | 1142 | ||
1134 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses, | 1143 | GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, |
1135 | &peer->hashPubKey, &destroy_by_session_id, &dc); | 1144 | peer, |
1145 | &destroy_by_session_id, &dc); | ||
1136 | GNUNET_STATISTICS_set (handle->stat, "# addresses", | 1146 | GNUNET_STATISTICS_set (handle->stat, "# addresses", |
1137 | GNUNET_CONTAINER_multihashmap_size (handle->addresses), GNUNET_NO); | 1147 | GNUNET_CONTAINER_multipeermap_size (handle->addresses), GNUNET_NO); |
1138 | free_address (dc.aa); | 1148 | free_address (dc.aa); |
1139 | } | 1149 | } |
1140 | 1150 | ||
@@ -1308,22 +1318,26 @@ GAS_addresses_request_address (struct GAS_Addresses_Handle *handle, | |||
1308 | * @param cls not used | 1318 | * @param cls not used |
1309 | * @param key the peer | 1319 | * @param key the peer |
1310 | * @param value the address to reset | 1320 | * @param value the address to reset |
1311 | * @return GNUNET_OK to continue | 1321 | * @return #GNUNET_OK to continue |
1312 | */ | 1322 | */ |
1313 | static int | 1323 | static int |
1314 | reset_address_it (void *cls, const struct GNUNET_HashCode *key, void *value) | 1324 | reset_address_it (void *cls, |
1325 | const struct GNUNET_PeerIdentity *key, | ||
1326 | void *value) | ||
1315 | { | 1327 | { |
1316 | struct ATS_Address *aa = value; | 1328 | struct ATS_Address *aa = value; |
1317 | 1329 | ||
1318 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1330 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1319 | "Resetting interval for peer `%s' address %p from %llu to 0\n", | 1331 | "Resetting interval for peer `%s' address %p from %llu to 0\n", |
1320 | GNUNET_i2s (&aa->peer), aa, aa->block_interval); | 1332 | GNUNET_i2s (&aa->peer), |
1321 | 1333 | aa, | |
1334 | aa->block_interval); | ||
1322 | aa->blocked_until = GNUNET_TIME_UNIT_ZERO_ABS; | 1335 | aa->blocked_until = GNUNET_TIME_UNIT_ZERO_ABS; |
1323 | aa->block_interval = GNUNET_TIME_UNIT_ZERO; | 1336 | aa->block_interval = GNUNET_TIME_UNIT_ZERO; |
1324 | return GNUNET_OK; | 1337 | return GNUNET_OK; |
1325 | } | 1338 | } |
1326 | 1339 | ||
1340 | |||
1327 | /** | 1341 | /** |
1328 | * Reset suggestion backoff for a peer | 1342 | * Reset suggestion backoff for a peer |
1329 | * | 1343 | * |
@@ -1341,9 +1355,12 @@ GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle, | |||
1341 | "RESET BACKOFF", GNUNET_i2s (peer)); | 1355 | "RESET BACKOFF", GNUNET_i2s (peer)); |
1342 | 1356 | ||
1343 | GNUNET_break( | 1357 | GNUNET_break( |
1344 | GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses, &peer->hashPubKey, &reset_address_it, NULL)); | 1358 | GNUNET_SYSERR != GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, |
1359 | peer, | ||
1360 | &reset_address_it, NULL)); | ||
1345 | } | 1361 | } |
1346 | 1362 | ||
1363 | |||
1347 | /** | 1364 | /** |
1348 | * The preference changed for a peer | 1365 | * The preference changed for a peer |
1349 | * | 1366 | * |
@@ -1436,9 +1453,9 @@ GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle, | |||
1436 | if (GNUNET_NO == handle->running) | 1453 | if (GNUNET_NO == handle->running) |
1437 | return; | 1454 | return; |
1438 | 1455 | ||
1439 | if (GNUNET_NO | 1456 | if (GNUNET_NO == |
1440 | == GNUNET_CONTAINER_multihashmap_contains (handle->addresses, | 1457 | GNUNET_CONTAINER_multipeermap_contains (handle->addresses, |
1441 | &peer->hashPubKey)) | 1458 | peer)) |
1442 | { | 1459 | { |
1443 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1460 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
1444 | "Received `%s' for unknown peer `%s' from client %p\n", | 1461 | "Received `%s' for unknown peer `%s' from client %p\n", |
@@ -1475,9 +1492,9 @@ GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle, | |||
1475 | if (GNUNET_NO == handle->running) | 1492 | if (GNUNET_NO == handle->running) |
1476 | return; | 1493 | return; |
1477 | 1494 | ||
1478 | if (GNUNET_NO | 1495 | if (GNUNET_NO == |
1479 | == GNUNET_CONTAINER_multihashmap_contains (handle->addresses, | 1496 | GNUNET_CONTAINER_multipeermap_contains (handle->addresses, |
1480 | &peer->hashPubKey)) | 1497 | peer)) |
1481 | { | 1498 | { |
1482 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1499 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
1483 | "Received `%s' for unknown peer `%s' from client %p\n", | 1500 | "Received `%s' for unknown peer `%s' from client %p\n", |
@@ -1699,7 +1716,7 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1699 | 1716 | ||
1700 | ah->stat = (struct GNUNET_STATISTICS_Handle *) stats; | 1717 | ah->stat = (struct GNUNET_STATISTICS_Handle *) stats; |
1701 | /* Initialize the addresses database */ | 1718 | /* Initialize the addresses database */ |
1702 | ah->addresses = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); | 1719 | ah->addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); |
1703 | GNUNET_assert(NULL != ah->addresses); | 1720 | GNUNET_assert(NULL != ah->addresses); |
1704 | 1721 | ||
1705 | /* Figure out configured solution method */ | 1722 | /* Figure out configured solution method */ |
@@ -1808,29 +1825,30 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1808 | break; | 1825 | break; |
1809 | } | 1826 | } |
1810 | 1827 | ||
1811 | GNUNET_assert(NULL != ah->s_init); | 1828 | GNUNET_assert (NULL != ah->s_init); |
1812 | GNUNET_assert(NULL != ah->s_add); | 1829 | GNUNET_assert (NULL != ah->s_add); |
1813 | GNUNET_assert(NULL != ah->s_address_update_inuse); | 1830 | GNUNET_assert (NULL != ah->s_address_update_inuse); |
1814 | GNUNET_assert(NULL != ah->s_address_update_property); | 1831 | GNUNET_assert (NULL != ah->s_address_update_property); |
1815 | GNUNET_assert(NULL != ah->s_address_update_session); | 1832 | GNUNET_assert (NULL != ah->s_address_update_session); |
1816 | GNUNET_assert(NULL != ah->s_address_update_network); | 1833 | GNUNET_assert (NULL != ah->s_address_update_network); |
1817 | GNUNET_assert(NULL != ah->s_get); | 1834 | GNUNET_assert (NULL != ah->s_get); |
1818 | GNUNET_assert(NULL != ah->s_get_stop); | 1835 | GNUNET_assert (NULL != ah->s_get_stop); |
1819 | GNUNET_assert(NULL != ah->s_pref); | 1836 | GNUNET_assert (NULL != ah->s_pref); |
1820 | GNUNET_assert(NULL != ah->s_feedback); | 1837 | GNUNET_assert (NULL != ah->s_feedback); |
1821 | GNUNET_assert(NULL != ah->s_del); | 1838 | GNUNET_assert (NULL != ah->s_del); |
1822 | GNUNET_assert(NULL != ah->s_done); | 1839 | GNUNET_assert (NULL != ah->s_done); |
1823 | GNUNET_assert(NULL != ah->s_bulk_start); | 1840 | GNUNET_assert (NULL != ah->s_bulk_start); |
1824 | GNUNET_assert(NULL != ah->s_bulk_stop); | 1841 | GNUNET_assert (NULL != ah->s_bulk_stop); |
1825 | 1842 | ||
1826 | GAS_normalization_start (&normalized_preference_changed_cb, ah, | 1843 | GAS_normalization_start (&normalized_preference_changed_cb, ah, |
1827 | &normalized_property_changed_cb, ah); | 1844 | &normalized_property_changed_cb, ah); |
1828 | quota_count = load_quotas (cfg, quotas_in, quotas_out, | 1845 | quota_count = load_quotas (cfg, quotas_in, quotas_out, |
1829 | GNUNET_ATS_NetworkTypeCount); | 1846 | GNUNET_ATS_NetworkTypeCount); |
1830 | 1847 | ||
1831 | ah->solver = ah->s_init (cfg, stats, ah->addresses, quotas, quotas_in, | 1848 | ah->solver = ah->s_init (cfg, stats, ah->addresses, quotas, quotas_in, |
1832 | quotas_out, quota_count, &bandwidth_changed_cb, ah, &get_preferences_cb, | 1849 | quotas_out, quota_count, |
1833 | NULL, &get_property_cb, NULL ); | 1850 | &bandwidth_changed_cb, ah, &get_preferences_cb, |
1851 | NULL, &get_property_cb, NULL ); | ||
1834 | if (NULL == ah->solver) | 1852 | if (NULL == ah->solver) |
1835 | { | 1853 | { |
1836 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize solver!\n")); | 1854 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize solver!\n")); |
@@ -1841,7 +1859,7 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1841 | ah->running = GNUNET_YES; | 1859 | ah->running = GNUNET_YES; |
1842 | 1860 | ||
1843 | GNUNET_STATISTICS_set (ah->stat, "# addresses", | 1861 | GNUNET_STATISTICS_set (ah->stat, "# addresses", |
1844 | GNUNET_CONTAINER_multihashmap_size (ah->addresses), GNUNET_NO); | 1862 | GNUNET_CONTAINER_multipeermap_size (ah->addresses), GNUNET_NO); |
1845 | 1863 | ||
1846 | return ah; | 1864 | return ah; |
1847 | } | 1865 | } |
@@ -1852,18 +1870,19 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1852 | * @param cls NULL | 1870 | * @param cls NULL |
1853 | * @param key peer identity (unused) | 1871 | * @param key peer identity (unused) |
1854 | * @param value the 'struct ATS_Address' to free | 1872 | * @param value the 'struct ATS_Address' to free |
1855 | * @return GNUNET_OK (continue to iterate) | 1873 | * @return #GNUNET_OK (continue to iterate) |
1856 | */ | 1874 | */ |
1857 | static int | 1875 | static int |
1858 | destroy_all_address_it (void *cls, const struct GNUNET_HashCode * key, | 1876 | destroy_all_address_it (void *cls, |
1859 | void *value) | 1877 | const struct GNUNET_PeerIdentity *key, |
1878 | void *value) | ||
1860 | { | 1879 | { |
1861 | struct GAS_Addresses_Handle *handle = cls; | 1880 | struct GAS_Addresses_Handle *handle = cls; |
1862 | struct ATS_Address *aa = value; | 1881 | struct ATS_Address *aa = value; |
1863 | 1882 | ||
1864 | /* Remove */ | 1883 | /* Remove */ |
1865 | GNUNET_assert( | 1884 | GNUNET_assert(GNUNET_YES == |
1866 | GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (handle->addresses, key, value)); | 1885 | GNUNET_CONTAINER_multipeermap_remove (handle->addresses, key, value)); |
1867 | /* Notify */ | 1886 | /* Notify */ |
1868 | handle->s_del (handle->solver, aa, GNUNET_NO); | 1887 | handle->s_del (handle->solver, aa, GNUNET_NO); |
1869 | /* Destroy */ | 1888 | /* Destroy */ |
@@ -1872,6 +1891,7 @@ destroy_all_address_it (void *cls, const struct GNUNET_HashCode * key, | |||
1872 | return GNUNET_OK; | 1891 | return GNUNET_OK; |
1873 | } | 1892 | } |
1874 | 1893 | ||
1894 | |||
1875 | /** | 1895 | /** |
1876 | * Remove all addresses | 1896 | * Remove all addresses |
1877 | * | 1897 | * |
@@ -1886,11 +1906,13 @@ GAS_addresses_destroy_all (struct GAS_Addresses_Handle *handle) | |||
1886 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Destroying all addresses\n"); | 1906 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Destroying all addresses\n"); |
1887 | handle->s_bulk_start (handle->solver); | 1907 | handle->s_bulk_start (handle->solver); |
1888 | if (handle->addresses != NULL ) | 1908 | if (handle->addresses != NULL ) |
1889 | GNUNET_CONTAINER_multihashmap_iterate (handle->addresses, | 1909 | GNUNET_CONTAINER_multipeermap_iterate (handle->addresses, |
1890 | &destroy_all_address_it, handle); | 1910 | &destroy_all_address_it, |
1911 | handle); | ||
1891 | handle->s_bulk_start (handle->solver); | 1912 | handle->s_bulk_start (handle->solver); |
1892 | } | 1913 | } |
1893 | 1914 | ||
1915 | |||
1894 | /** | 1916 | /** |
1895 | * Shutdown address subsystem. | 1917 | * Shutdown address subsystem. |
1896 | * | 1918 | * |
@@ -1905,7 +1927,7 @@ GAS_addresses_done (struct GAS_Addresses_Handle *handle) | |||
1905 | GNUNET_assert(NULL != handle); | 1927 | GNUNET_assert(NULL != handle); |
1906 | GAS_addresses_destroy_all (handle); | 1928 | GAS_addresses_destroy_all (handle); |
1907 | handle->running = GNUNET_NO; | 1929 | handle->running = GNUNET_NO; |
1908 | GNUNET_CONTAINER_multihashmap_destroy (handle->addresses); | 1930 | GNUNET_CONTAINER_multipeermap_destroy (handle->addresses); |
1909 | handle->addresses = NULL; | 1931 | handle->addresses = NULL; |
1910 | while (NULL != (cur = handle->r_head)) | 1932 | while (NULL != (cur = handle->r_head)) |
1911 | { | 1933 | { |
@@ -1918,34 +1940,36 @@ GAS_addresses_done (struct GAS_Addresses_Handle *handle) | |||
1918 | GAS_normalization_stop (); | 1940 | GAS_normalization_stop (); |
1919 | } | 1941 | } |
1920 | 1942 | ||
1943 | |||
1921 | struct PeerIteratorContext | 1944 | struct PeerIteratorContext |
1922 | { | 1945 | { |
1923 | GNUNET_ATS_Peer_Iterator it; | 1946 | GNUNET_ATS_Peer_Iterator it; |
1924 | void *it_cls; | 1947 | void *it_cls; |
1925 | struct GNUNET_CONTAINER_MultiHashMap *peers_returned; | 1948 | struct GNUNET_CONTAINER_MultiPeerMap *peers_returned; |
1926 | }; | 1949 | }; |
1927 | 1950 | ||
1951 | |||
1928 | /** | 1952 | /** |
1929 | * Iterator to iterate over all peers | 1953 | * Iterator to iterate over all peers |
1930 | * | 1954 | * |
1931 | * @param cls a PeerIteratorContext | 1955 | * @param cls a PeerIteratorContext |
1932 | * @param key the peer id | 1956 | * @param key the peer id |
1933 | * @param value the ATS_address | 1957 | * @param value the ATS_address |
1934 | * @return GNUNET_OK to continue | 1958 | * @return #GNUNET_OK to continue |
1935 | */ | 1959 | */ |
1936 | static int | 1960 | static int |
1937 | peer_it (void *cls, const struct GNUNET_HashCode * key, void *value) | 1961 | peer_it (void *cls, |
1962 | const struct GNUNET_PeerIdentity *key, | ||
1963 | void *value) | ||
1938 | { | 1964 | { |
1939 | struct PeerIteratorContext *ip_ctx = cls; | 1965 | struct PeerIteratorContext *ip_ctx = cls; |
1940 | struct GNUNET_PeerIdentity tmp; | ||
1941 | 1966 | ||
1942 | if (GNUNET_NO | 1967 | if (GNUNET_NO == |
1943 | == GNUNET_CONTAINER_multihashmap_contains (ip_ctx->peers_returned, key)) | 1968 | GNUNET_CONTAINER_multipeermap_contains (ip_ctx->peers_returned, key)) |
1944 | { | 1969 | { |
1945 | GNUNET_CONTAINER_multihashmap_put (ip_ctx->peers_returned, key, NULL, | 1970 | GNUNET_CONTAINER_multipeermap_put (ip_ctx->peers_returned, key, NULL, |
1946 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1971 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1947 | tmp.hashPubKey = (*key); | 1972 | ip_ctx->it (ip_ctx->it_cls, key); |
1948 | ip_ctx->it (ip_ctx->it_cls, &tmp); | ||
1949 | } | 1973 | } |
1950 | 1974 | ||
1951 | return GNUNET_OK; | 1975 | return GNUNET_OK; |
@@ -1969,16 +1993,17 @@ GAS_addresses_iterate_peers (struct GAS_Addresses_Handle *handle, | |||
1969 | return; | 1993 | return; |
1970 | GNUNET_assert(NULL != handle->addresses); | 1994 | GNUNET_assert(NULL != handle->addresses); |
1971 | 1995 | ||
1972 | size = GNUNET_CONTAINER_multihashmap_size (handle->addresses); | 1996 | size = GNUNET_CONTAINER_multipeermap_size (handle->addresses); |
1973 | if (0 != size) | 1997 | if (0 != size) |
1974 | { | 1998 | { |
1975 | ip_ctx.it = p_it; | 1999 | ip_ctx.it = p_it; |
1976 | ip_ctx.it_cls = p_it_cls; | 2000 | ip_ctx.it_cls = p_it_cls; |
1977 | ip_ctx.peers_returned = GNUNET_CONTAINER_multihashmap_create (size, | 2001 | ip_ctx.peers_returned = GNUNET_CONTAINER_multipeermap_create (size, |
1978 | GNUNET_NO); | 2002 | GNUNET_NO); |
1979 | GNUNET_CONTAINER_multihashmap_iterate (handle->addresses, &peer_it, | 2003 | GNUNET_CONTAINER_multipeermap_iterate (handle->addresses, |
1980 | &ip_ctx); | 2004 | &peer_it, |
1981 | GNUNET_CONTAINER_multihashmap_destroy (ip_ctx.peers_returned); | 2005 | &ip_ctx); |
2006 | GNUNET_CONTAINER_multipeermap_destroy (ip_ctx.peers_returned); | ||
1982 | } | 2007 | } |
1983 | p_it (p_it_cls, NULL ); | 2008 | p_it (p_it_cls, NULL ); |
1984 | } | 2009 | } |
@@ -1989,19 +2014,22 @@ struct PeerInfoIteratorContext | |||
1989 | void *it_cls; | 2014 | void *it_cls; |
1990 | }; | 2015 | }; |
1991 | 2016 | ||
2017 | |||
1992 | /** | 2018 | /** |
1993 | * Iterator to iterate over a peer's addresses | 2019 | * Iterator to iterate over a peer's addresses |
1994 | * | 2020 | * |
1995 | * @param cls a PeerInfoIteratorContext | 2021 | * @param cls a `struct PeerInfoIteratorContext` |
1996 | * @param key the peer id | 2022 | * @param key the peer id |
1997 | * @param value the ATS_address | 2023 | * @param value the `struct ATS_address` |
1998 | * @return GNUNET_OK to continue | 2024 | * @return #GNUNET_OK to continue |
1999 | */ | 2025 | */ |
2000 | static int | 2026 | static int |
2001 | peerinfo_it (void *cls, const struct GNUNET_HashCode * key, void *value) | 2027 | peerinfo_it (void *cls, |
2028 | const struct GNUNET_PeerIdentity *key, | ||
2029 | void *value) | ||
2002 | { | 2030 | { |
2003 | struct PeerInfoIteratorContext *pi_ctx = cls; | 2031 | struct PeerInfoIteratorContext *pi_ctx = cls; |
2004 | struct ATS_Address *addr = (struct ATS_Address *) value; | 2032 | struct ATS_Address *addr = value; |
2005 | 2033 | ||
2006 | if (NULL != pi_ctx->it) | 2034 | if (NULL != pi_ctx->it) |
2007 | { | 2035 | { |
@@ -2012,6 +2040,7 @@ peerinfo_it (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
2012 | return GNUNET_YES; | 2040 | return GNUNET_YES; |
2013 | } | 2041 | } |
2014 | 2042 | ||
2043 | |||
2015 | /** | 2044 | /** |
2016 | * Return information all peers currently known to ATS | 2045 | * Return information all peers currently known to ATS |
2017 | * | 2046 | * |
@@ -2027,6 +2056,7 @@ GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle, | |||
2027 | { | 2056 | { |
2028 | struct PeerInfoIteratorContext pi_ctx; | 2057 | struct PeerInfoIteratorContext pi_ctx; |
2029 | struct GNUNET_BANDWIDTH_Value32NBO zero_bw; | 2058 | struct GNUNET_BANDWIDTH_Value32NBO zero_bw; |
2059 | |||
2030 | GNUNET_assert(NULL != peer); | 2060 | GNUNET_assert(NULL != peer); |
2031 | GNUNET_assert(NULL != handle->addresses); | 2061 | GNUNET_assert(NULL != handle->addresses); |
2032 | if (NULL == pi_it) | 2062 | if (NULL == pi_it) |
@@ -2036,8 +2066,9 @@ GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle, | |||
2036 | pi_ctx.it = pi_it; | 2066 | pi_ctx.it = pi_it; |
2037 | pi_ctx.it_cls = pi_it_cls; | 2067 | pi_ctx.it_cls = pi_it_cls; |
2038 | 2068 | ||
2039 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->addresses, | 2069 | GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, |
2040 | &peer->hashPubKey, &peerinfo_it, &pi_ctx); | 2070 | peer, |
2071 | &peerinfo_it, &pi_ctx); | ||
2041 | 2072 | ||
2042 | if (NULL != pi_it) | 2073 | if (NULL != pi_it) |
2043 | pi_it (pi_it_cls, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, zero_bw, | 2074 | pi_it (pi_it_cls, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, zero_bw, |
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h index b5ae248e4..71dfde41f 100644 --- a/src/ats/gnunet-service-ats_addresses.h +++ b/src/ats/gnunet-service-ats_addresses.h | |||
@@ -411,7 +411,7 @@ typedef const double * | |||
411 | typedef void * | 411 | typedef void * |
412 | (*GAS_solver_init) (const struct GNUNET_CONFIGURATION_Handle *cfg, | 412 | (*GAS_solver_init) (const struct GNUNET_CONFIGURATION_Handle *cfg, |
413 | const struct GNUNET_STATISTICS_Handle *stats, | 413 | const struct GNUNET_STATISTICS_Handle *stats, |
414 | const struct GNUNET_CONTAINER_MultiHashMap *addresses, int *network, | 414 | const struct GNUNET_CONTAINER_MultiPeerMap *addresses, int *network, |
415 | unsigned long long *out_quota, unsigned long long *in_quota, | 415 | unsigned long long *out_quota, unsigned long long *in_quota, |
416 | int dest_length, GAS_bandwidth_changed_cb bw_changed_cb, | 416 | int dest_length, GAS_bandwidth_changed_cb bw_changed_cb, |
417 | void *bw_changed_cb_cls, GAS_get_preferences get_preference, | 417 | void *bw_changed_cb_cls, GAS_get_preferences get_preference, |
diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c index fabef09e4..bd9dcb706 100644 --- a/src/ats/gnunet-service-ats_normalization.c +++ b/src/ats/gnunet-service-ats_normalization.c | |||
@@ -149,12 +149,13 @@ void *prop_ch_cb_cls; | |||
149 | /** | 149 | /** |
150 | * Hashmap to store peer information for preference normalization | 150 | * Hashmap to store peer information for preference normalization |
151 | */ | 151 | */ |
152 | static struct GNUNET_CONTAINER_MultiHashMap *preference_peers; | 152 | static struct GNUNET_CONTAINER_MultiPeerMap *preference_peers; |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Hashmap to store peer information for property normalization | 155 | * Hashmap to store peer information for property normalization |
156 | * FIXME: this map is not used! | ||
156 | */ | 157 | */ |
157 | static struct GNUNET_CONTAINER_MultiHashMap *property_peers; | 158 | static struct GNUNET_CONTAINER_MultiPeerMap *property_peers; |
158 | 159 | ||
159 | /** | 160 | /** |
160 | * Clients in DLL: head | 161 | * Clients in DLL: head |
@@ -220,8 +221,8 @@ update_peers (struct GNUNET_PeerIdentity *id, | |||
220 | count, GNUNET_i2s (id), GNUNET_ATS_print_preference_type (kind), | 221 | count, GNUNET_i2s (id), GNUNET_ATS_print_preference_type (kind), |
221 | f_rel_total); | 222 | f_rel_total); |
222 | if (NULL | 223 | if (NULL |
223 | != (rp = GNUNET_CONTAINER_multihashmap_get (preference_peers, | 224 | != (rp = GNUNET_CONTAINER_multipeermap_get (preference_peers, |
224 | &id->hashPubKey))) | 225 | id))) |
225 | { | 226 | { |
226 | backup = rp->f_rel[kind]; | 227 | backup = rp->f_rel[kind]; |
227 | if (0 < count) | 228 | if (0 < count) |
@@ -302,7 +303,7 @@ recalculate_rel_preferences (struct PreferenceClient *c, | |||
302 | { | 303 | { |
303 | /* Value did not chang, return old value*/ | 304 | /* Value did not chang, return old value*/ |
304 | GNUNET_assert( | 305 | GNUNET_assert( |
305 | NULL != (rp = GNUNET_CONTAINER_multihashmap_get (preference_peers, &p->id.hashPubKey))); | 306 | NULL != (rp = GNUNET_CONTAINER_multipeermap_get (preference_peers, &p->id))); |
306 | ret = rp->f_rel[kind]; | 307 | ret = rp->f_rel[kind]; |
307 | } | 308 | } |
308 | } | 309 | } |
@@ -474,14 +475,14 @@ GAS_normalization_normalize_preference (void *src, | |||
474 | GNUNET_CONTAINER_DLL_insert(c_cur->p_head, c_cur->p_tail, p_cur); | 475 | GNUNET_CONTAINER_DLL_insert(c_cur->p_head, c_cur->p_tail, p_cur); |
475 | } | 476 | } |
476 | 477 | ||
477 | if (NULL == GNUNET_CONTAINER_multihashmap_get (preference_peers, | 478 | if (NULL == GNUNET_CONTAINER_multipeermap_get (preference_peers, |
478 | &peer->hashPubKey)) | 479 | peer)) |
479 | { | 480 | { |
480 | r_cur = GNUNET_malloc (sizeof (struct PeerRelative)); | 481 | r_cur = GNUNET_malloc (sizeof (struct PeerRelative)); |
481 | r_cur->id = (*peer); | 482 | r_cur->id = (*peer); |
482 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) | 483 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) |
483 | r_cur->f_rel[i] = DEFAULT_REL_PREFERENCE; | 484 | r_cur->f_rel[i] = DEFAULT_REL_PREFERENCE; |
484 | GNUNET_CONTAINER_multihashmap_put (preference_peers, &r_cur->id.hashPubKey, | 485 | GNUNET_CONTAINER_multipeermap_put (preference_peers, &r_cur->id, |
485 | r_cur, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 486 | r_cur, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
486 | } | 487 | } |
487 | 488 | ||
@@ -508,8 +509,8 @@ GAS_normalization_get_preferences (const struct GNUNET_PeerIdentity *id) | |||
508 | 509 | ||
509 | struct PeerRelative *rp; | 510 | struct PeerRelative *rp; |
510 | if (NULL | 511 | if (NULL |
511 | == (rp = GNUNET_CONTAINER_multihashmap_get (preference_peers, | 512 | == (rp = GNUNET_CONTAINER_multipeermap_get (preference_peers, |
512 | &id->hashPubKey))) | 513 | id))) |
513 | { | 514 | { |
514 | return defvalues.f_rel; | 515 | return defvalues.f_rel; |
515 | } | 516 | } |
@@ -625,6 +626,7 @@ property_average (struct ATS_Address *address, | |||
625 | return res; | 626 | return res; |
626 | } | 627 | } |
627 | 628 | ||
629 | |||
628 | struct FindMinMaxCtx | 630 | struct FindMinMaxCtx |
629 | { | 631 | { |
630 | struct Property *p; | 632 | struct Property *p; |
@@ -632,11 +634,14 @@ struct FindMinMaxCtx | |||
632 | uint32_t max; | 634 | uint32_t max; |
633 | }; | 635 | }; |
634 | 636 | ||
637 | |||
635 | static int | 638 | static int |
636 | find_min_max_it (void *cls, const struct GNUNET_HashCode *h, void *k) | 639 | find_min_max_it (void *cls, |
640 | const struct GNUNET_PeerIdentity *h, | ||
641 | void *k) | ||
637 | { | 642 | { |
638 | struct ATS_Address *a = (struct ATS_Address *) k; | ||
639 | struct FindMinMaxCtx *find_res = cls; | 643 | struct FindMinMaxCtx *find_res = cls; |
644 | struct ATS_Address *a = k; | ||
640 | 645 | ||
641 | if (a->atsin[find_res->p->prop_type].avg > find_res->max) | 646 | if (a->atsin[find_res->p->prop_type].avg > find_res->max) |
642 | find_res->max = a->atsin[find_res->p->prop_type].avg; | 647 | find_res->max = a->atsin[find_res->p->prop_type].avg; |
@@ -647,11 +652,14 @@ find_min_max_it (void *cls, const struct GNUNET_HashCode *h, void *k) | |||
647 | return GNUNET_OK; | 652 | return GNUNET_OK; |
648 | } | 653 | } |
649 | 654 | ||
655 | |||
650 | static int | 656 | static int |
651 | normalize_address (void *cls, const struct GNUNET_HashCode *h, void *k) | 657 | normalize_address (void *cls, |
658 | const struct GNUNET_PeerIdentity *h, | ||
659 | void *k) | ||
652 | { | 660 | { |
653 | struct Property *p = cls; | 661 | struct Property *p = cls; |
654 | struct ATS_Address *address = (struct ATS_Address *) k; | 662 | struct ATS_Address *address = k; |
655 | 663 | ||
656 | double delta; | 664 | double delta; |
657 | uint32_t avg_value = address->atsin[p->prop_type].avg; | 665 | uint32_t avg_value = address->atsin[p->prop_type].avg; |
@@ -673,6 +681,7 @@ normalize_address (void *cls, const struct GNUNET_HashCode *h, void *k) | |||
673 | return GNUNET_OK; | 681 | return GNUNET_OK; |
674 | } | 682 | } |
675 | 683 | ||
684 | |||
676 | /** | 685 | /** |
677 | * Normalize avg_value to a range of values between [1.0, 2.0] | 686 | * Normalize avg_value to a range of values between [1.0, 2.0] |
678 | * based on min max values currently known. | 687 | * based on min max values currently known. |
@@ -682,10 +691,11 @@ normalize_address (void *cls, const struct GNUNET_HashCode *h, void *k) | |||
682 | * @param address the address | 691 | * @param address the address |
683 | * @param avg_value the value to normalize | 692 | * @param avg_value the value to normalize |
684 | */ | 693 | */ |
685 | |||
686 | static void | 694 | static void |
687 | property_normalize (struct GNUNET_CONTAINER_MultiHashMap *addresses, | 695 | property_normalize (struct GNUNET_CONTAINER_MultiPeerMap *addresses, |
688 | struct Property *p, struct ATS_Address *address, uint32_t avg_value) | 696 | struct Property *p, |
697 | struct ATS_Address *address, | ||
698 | uint32_t avg_value) | ||
689 | { | 699 | { |
690 | struct FindMinMaxCtx find_ctx; | 700 | struct FindMinMaxCtx find_ctx; |
691 | int addr_count; | 701 | int addr_count; |
@@ -694,8 +704,8 @@ property_normalize (struct GNUNET_CONTAINER_MultiHashMap *addresses, | |||
694 | find_ctx.p = p; | 704 | find_ctx.p = p; |
695 | find_ctx.max = 0; | 705 | find_ctx.max = 0; |
696 | find_ctx.min = UINT32_MAX; | 706 | find_ctx.min = UINT32_MAX; |
697 | addr_count = GNUNET_CONTAINER_multihashmap_iterate (addresses, | 707 | addr_count = GNUNET_CONTAINER_multipeermap_iterate (addresses, |
698 | &find_min_max_it, &find_ctx); | 708 | &find_min_max_it, &find_ctx); |
699 | if (0 == addr_count) | 709 | if (0 == addr_count) |
700 | { | 710 | { |
701 | GNUNET_break(0); | 711 | GNUNET_break(0); |
@@ -731,13 +741,13 @@ property_normalize (struct GNUNET_CONTAINER_MultiHashMap *addresses, | |||
731 | if (GNUNET_NO == limits_changed) | 741 | if (GNUNET_NO == limits_changed) |
732 | { | 742 | { |
733 | /* normalize just this address */ | 743 | /* normalize just this address */ |
734 | normalize_address (p, &address->peer.hashPubKey, address); | 744 | normalize_address (p, &address->peer, address); |
735 | return; | 745 | return; |
736 | } | 746 | } |
737 | else | 747 | else |
738 | { | 748 | { |
739 | /* limits changed, normalize all addresses */ | 749 | /* limits changed, normalize all addresses */ |
740 | GNUNET_CONTAINER_multihashmap_iterate (addresses, &normalize_address, p); | 750 | GNUNET_CONTAINER_multipeermap_iterate (addresses, &normalize_address, p); |
741 | return; | 751 | return; |
742 | } | 752 | } |
743 | } | 753 | } |
@@ -751,10 +761,10 @@ property_normalize (struct GNUNET_CONTAINER_MultiHashMap *addresses, | |||
751 | * @param atsi_count the number of atsi information in the array | 761 | * @param atsi_count the number of atsi information in the array |
752 | */ | 762 | */ |
753 | void | 763 | void |
754 | GAS_normalization_normalize_property ( | 764 | GAS_normalization_normalize_property (struct GNUNET_CONTAINER_MultiPeerMap *addresses, |
755 | struct GNUNET_CONTAINER_MultiHashMap *addresses, | 765 | struct ATS_Address *address, |
756 | struct ATS_Address *address, const struct GNUNET_ATS_Information *atsi, | 766 | const struct GNUNET_ATS_Information *atsi, |
757 | uint32_t atsi_count) | 767 | uint32_t atsi_count) |
758 | { | 768 | { |
759 | struct Property *cur_prop; | 769 | struct Property *cur_prop; |
760 | int c1; | 770 | int c1; |
@@ -814,8 +824,8 @@ GAS_normalization_start (GAS_Normalization_preference_changed_cb pref_ch_cb, | |||
814 | { | 824 | { |
815 | int c1; | 825 | int c1; |
816 | int i; | 826 | int i; |
817 | preference_peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 827 | preference_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
818 | property_peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 828 | property_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
819 | unsigned int existing_properties[] = GNUNET_ATS_QualityProperties; | 829 | unsigned int existing_properties[] = GNUNET_ATS_QualityProperties; |
820 | 830 | ||
821 | for (c1 = 0; c1 < GNUNET_ATS_QualityPropertiesCount; c1++) | 831 | for (c1 = 0; c1 < GNUNET_ATS_QualityPropertiesCount; c1++) |
@@ -840,20 +850,21 @@ GAS_normalization_start (GAS_Normalization_preference_changed_cb pref_ch_cb, | |||
840 | return; | 850 | return; |
841 | } | 851 | } |
842 | 852 | ||
853 | |||
843 | /** | 854 | /** |
844 | * Free a peer | 855 | * Free a peer |
845 | * | 856 | * |
846 | * @param cls unused | 857 | * @param cls unused |
847 | * @param key the key | 858 | * @param key the key |
848 | * @param value RelativePeer | 859 | * @param value RelativePeer |
849 | * @return GNUNET_OK to continue | 860 | * @return #GNUNET_OK to continue |
850 | */ | 861 | */ |
851 | static int | 862 | static int |
852 | free_peer (void *cls, const struct GNUNET_HashCode * key, void *value) | 863 | free_peer (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
853 | { | 864 | { |
854 | struct PeerRelative *rp = value; | 865 | struct PeerRelative *rp = value; |
855 | if (GNUNET_YES | 866 | if (GNUNET_YES |
856 | == GNUNET_CONTAINER_multihashmap_remove (preference_peers, key, value)) | 867 | == GNUNET_CONTAINER_multipeermap_remove (preference_peers, key, value)) |
857 | GNUNET_free(rp); | 868 | GNUNET_free(rp); |
858 | else | 869 | else |
859 | GNUNET_break(0); | 870 | GNUNET_break(0); |
@@ -892,9 +903,9 @@ GAS_normalization_stop () | |||
892 | GNUNET_free(pc); | 903 | GNUNET_free(pc); |
893 | } | 904 | } |
894 | 905 | ||
895 | GNUNET_CONTAINER_multihashmap_iterate (preference_peers, &free_peer, NULL ); | 906 | GNUNET_CONTAINER_multipeermap_iterate (preference_peers, &free_peer, NULL ); |
896 | GNUNET_CONTAINER_multihashmap_destroy (preference_peers); | 907 | GNUNET_CONTAINER_multipeermap_destroy (preference_peers); |
897 | GNUNET_CONTAINER_multihashmap_destroy (property_peers); | 908 | GNUNET_CONTAINER_multipeermap_destroy (property_peers); |
898 | return; | 909 | return; |
899 | } | 910 | } |
900 | 911 | ||
diff --git a/src/ats/gnunet-service-ats_normalization.h b/src/ats/gnunet-service-ats_normalization.h index 969263b3e..1f0d081d4 100644 --- a/src/ats/gnunet-service-ats_normalization.h +++ b/src/ats/gnunet-service-ats_normalization.h | |||
@@ -51,8 +51,8 @@ typedef void | |||
51 | /** | 51 | /** |
52 | * Get the normalized preference values for a specific peer | 52 | * Get the normalized preference values for a specific peer |
53 | * | 53 | * |
54 | * @param id the peer | 54 | * @param id the peer @return pointer to the values, can be indexed |
55 | * @return pointer to the values, can be indexed with GNUNET_ATS_PreferenceKind, NULL if peer does not exist | 55 | * with GNUNET_ATS_PreferenceKind, NULL if peer does not exist |
56 | */ | 56 | */ |
57 | const double * | 57 | const double * |
58 | GAS_normalization_get_preferences (const struct GNUNET_PeerIdentity *id); | 58 | GAS_normalization_get_preferences (const struct GNUNET_PeerIdentity *id); |
@@ -79,9 +79,9 @@ GAS_normalization_get_properties (struct ATS_Address *address); | |||
79 | */ | 79 | */ |
80 | void | 80 | void |
81 | GAS_normalization_normalize_preference (void *src, | 81 | GAS_normalization_normalize_preference (void *src, |
82 | const struct GNUNET_PeerIdentity *peer, | 82 | const struct GNUNET_PeerIdentity *peer, |
83 | enum GNUNET_ATS_PreferenceKind kind, | 83 | enum GNUNET_ATS_PreferenceKind kind, |
84 | float score_abs); | 84 | float score_abs); |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Update and normalize a atsi performance information | 87 | * Update and normalize a atsi performance information |
@@ -92,10 +92,10 @@ GAS_normalization_normalize_preference (void *src, | |||
92 | * @param atsi_count the number of atsi information in the array | 92 | * @param atsi_count the number of atsi information in the array |
93 | */ | 93 | */ |
94 | void | 94 | void |
95 | GAS_normalization_normalize_property (struct GNUNET_CONTAINER_MultiHashMap *addresses, | 95 | GAS_normalization_normalize_property (struct GNUNET_CONTAINER_MultiPeerMap *addresses, |
96 | struct ATS_Address *address, | 96 | struct ATS_Address *address, |
97 | const struct GNUNET_ATS_Information *atsi, | 97 | const struct GNUNET_ATS_Information *atsi, |
98 | uint32_t atsi_count); | 98 | uint32_t atsi_count); |
99 | 99 | ||
100 | 100 | ||
101 | /** | 101 | /** |
@@ -108,9 +108,9 @@ GAS_normalization_normalize_property (struct GNUNET_CONTAINER_MultiHashMap *addr | |||
108 | */ | 108 | */ |
109 | void | 109 | void |
110 | GAS_normalization_start (GAS_Normalization_preference_changed_cb pref_ch_cb, | 110 | GAS_normalization_start (GAS_Normalization_preference_changed_cb pref_ch_cb, |
111 | void *pref_ch_cb_cls, | 111 | void *pref_ch_cb_cls, |
112 | GAS_Normalization_property_changed_cb property_ch_cb, | 112 | GAS_Normalization_property_changed_cb property_ch_cb, |
113 | void *property_ch_cb_cls); | 113 | void *property_ch_cb_cls); |
114 | 114 | ||
115 | 115 | ||
116 | /** | 116 | /** |
diff --git a/src/ats/gnunet-service-ats_reservations.c b/src/ats/gnunet-service-ats_reservations.c index 0b4948576..c75577cf9 100644 --- a/src/ats/gnunet-service-ats_reservations.c +++ b/src/ats/gnunet-service-ats_reservations.c | |||
@@ -36,7 +36,7 @@ | |||
36 | /** | 36 | /** |
37 | * Map of peer identities to 'struct GNUNET_BANDWIDTH_Tracker *'s | 37 | * Map of peer identities to 'struct GNUNET_BANDWIDTH_Tracker *'s |
38 | */ | 38 | */ |
39 | static struct GNUNET_CONTAINER_MultiHashMap *trackers; | 39 | static struct GNUNET_CONTAINER_MultiPeerMap *trackers; |
40 | 40 | ||
41 | 41 | ||
42 | /** | 42 | /** |
@@ -57,7 +57,7 @@ GAS_reservations_reserve (const struct GNUNET_PeerIdentity *peer, | |||
57 | struct GNUNET_BANDWIDTH_Tracker *tracker; | 57 | struct GNUNET_BANDWIDTH_Tracker *tracker; |
58 | struct GNUNET_TIME_Relative ret; | 58 | struct GNUNET_TIME_Relative ret; |
59 | 59 | ||
60 | tracker = GNUNET_CONTAINER_multihashmap_get (trackers, &peer->hashPubKey); | 60 | tracker = GNUNET_CONTAINER_multipeermap_get (trackers, peer); |
61 | if (NULL == tracker) | 61 | if (NULL == tracker) |
62 | return GNUNET_TIME_UNIT_ZERO; /* not connected, satisfy now */ | 62 | return GNUNET_TIME_UNIT_ZERO; /* not connected, satisfy now */ |
63 | if (amount >= 0) | 63 | if (amount >= 0) |
@@ -93,14 +93,14 @@ GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer, | |||
93 | { | 93 | { |
94 | struct GNUNET_BANDWIDTH_Tracker *tracker; | 94 | struct GNUNET_BANDWIDTH_Tracker *tracker; |
95 | 95 | ||
96 | tracker = GNUNET_CONTAINER_multihashmap_get (trackers, &peer->hashPubKey); | 96 | tracker = GNUNET_CONTAINER_multipeermap_get (trackers, peer); |
97 | if (0 == ntohl (bandwidth_in.value__)) | 97 | if (0 == ntohl (bandwidth_in.value__)) |
98 | { | 98 | { |
99 | if (NULL == tracker) | 99 | if (NULL == tracker) |
100 | return; | 100 | return; |
101 | GNUNET_assert (GNUNET_YES == | 101 | GNUNET_assert (GNUNET_YES == |
102 | GNUNET_CONTAINER_multihashmap_remove (trackers, | 102 | GNUNET_CONTAINER_multipeermap_remove (trackers, |
103 | &peer->hashPubKey, | 103 | peer, |
104 | tracker)); | 104 | tracker)); |
105 | GNUNET_free (tracker); | 105 | GNUNET_free (tracker); |
106 | return; | 106 | return; |
@@ -110,7 +110,7 @@ GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer, | |||
110 | tracker = GNUNET_malloc (sizeof (struct GNUNET_BANDWIDTH_Tracker)); | 110 | tracker = GNUNET_malloc (sizeof (struct GNUNET_BANDWIDTH_Tracker)); |
111 | GNUNET_BANDWIDTH_tracker_init (tracker, bandwidth_in, | 111 | GNUNET_BANDWIDTH_tracker_init (tracker, bandwidth_in, |
112 | MAX_BANDWIDTH_CARRY_S); | 112 | MAX_BANDWIDTH_CARRY_S); |
113 | GNUNET_CONTAINER_multihashmap_put (trackers, &peer->hashPubKey, tracker, | 113 | GNUNET_CONTAINER_multipeermap_put (trackers, peer, tracker, |
114 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 114 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
115 | return; | 115 | return; |
116 | } | 116 | } |
@@ -124,7 +124,7 @@ GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer, | |||
124 | void | 124 | void |
125 | GAS_reservations_init () | 125 | GAS_reservations_init () |
126 | { | 126 | { |
127 | trackers = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); | 127 | trackers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
@@ -137,7 +137,8 @@ GAS_reservations_init () | |||
137 | * @return GNUNET_OK (continue to iterate) | 137 | * @return GNUNET_OK (continue to iterate) |
138 | */ | 138 | */ |
139 | static int | 139 | static int |
140 | free_tracker (void *cls, const struct GNUNET_HashCode * key, void *value) | 140 | free_tracker (void *cls, |
141 | const struct GNUNET_PeerIdentity *key, void *value) | ||
141 | { | 142 | { |
142 | struct GNUNET_BANDWIDTH_Tracker *tracker = value; | 143 | struct GNUNET_BANDWIDTH_Tracker *tracker = value; |
143 | 144 | ||
@@ -152,8 +153,8 @@ free_tracker (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
152 | void | 153 | void |
153 | GAS_reservations_done () | 154 | GAS_reservations_done () |
154 | { | 155 | { |
155 | GNUNET_CONTAINER_multihashmap_iterate (trackers, &free_tracker, NULL); | 156 | GNUNET_CONTAINER_multipeermap_iterate (trackers, &free_tracker, NULL); |
156 | GNUNET_CONTAINER_multihashmap_destroy (trackers); | 157 | GNUNET_CONTAINER_multipeermap_destroy (trackers); |
157 | } | 158 | } |
158 | 159 | ||
159 | /* end of gnunet-service-ats_reservations.c */ | 160 | /* end of gnunet-service-ats_reservations.c */ |