diff options
-rw-r--r-- | src/dv/dv_api.c | 32 | ||||
-rw-r--r-- | src/dv/gnunet-service-dv.c | 169 | ||||
-rw-r--r-- | src/dv/plugin_transport_dv.c | 48 |
3 files changed, 127 insertions, 122 deletions
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index a24965e84..1bbb789f9 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c | |||
@@ -143,7 +143,7 @@ struct GNUNET_DV_ServiceHandle | |||
143 | * upon successful transmission. The respective | 143 | * upon successful transmission. The respective |
144 | * transmissions have already been done. | 144 | * transmissions have already been done. |
145 | */ | 145 | */ |
146 | struct GNUNET_CONTAINER_MultiHashMap *send_callbacks; | 146 | struct GNUNET_CONTAINER_MultiPeerMap *send_callbacks; |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * Current unique ID | 149 | * Current unique ID |
@@ -196,8 +196,8 @@ transmit_pending (void *cls, size_t size, void *buf) | |||
196 | ret += tsize; | 196 | ret += tsize; |
197 | if (NULL != th->cb) | 197 | if (NULL != th->cb) |
198 | { | 198 | { |
199 | (void) GNUNET_CONTAINER_multihashmap_put (sh->send_callbacks, | 199 | (void) GNUNET_CONTAINER_multipeermap_put (sh->send_callbacks, |
200 | &th->target.hashPubKey, | 200 | &th->target, |
201 | th, | 201 | th, |
202 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 202 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
203 | } | 203 | } |
@@ -259,7 +259,7 @@ struct AckContext | |||
259 | */ | 259 | */ |
260 | static int | 260 | static int |
261 | process_ack (void *cls, | 261 | process_ack (void *cls, |
262 | const struct GNUNET_HashCode *key, | 262 | const struct GNUNET_PeerIdentity *key, |
263 | void *value) | 263 | void *value) |
264 | { | 264 | { |
265 | struct AckContext *ctx = cls; | 265 | struct AckContext *ctx = cls; |
@@ -269,9 +269,9 @@ process_ack (void *cls, | |||
269 | return GNUNET_OK; | 269 | return GNUNET_OK; |
270 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 270 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
271 | "Matchedk ACK for message to peer %s\n", | 271 | "Matchedk ACK for message to peer %s\n", |
272 | GNUNET_h2s (key)); | 272 | GNUNET_i2s (key)); |
273 | GNUNET_assert (GNUNET_YES == | 273 | GNUNET_assert (GNUNET_YES == |
274 | GNUNET_CONTAINER_multihashmap_remove (ctx->sh->send_callbacks, | 274 | GNUNET_CONTAINER_multipeermap_remove (ctx->sh->send_callbacks, |
275 | key, | 275 | key, |
276 | th)); | 276 | th)); |
277 | th->cb (th->cb_cls, | 277 | th->cb (th->cb_cls, |
@@ -380,8 +380,8 @@ handle_message_receipt (void *cls, | |||
380 | ack = (const struct GNUNET_DV_AckMessage *) msg; | 380 | ack = (const struct GNUNET_DV_AckMessage *) msg; |
381 | ctx.ack = ack; | 381 | ctx.ack = ack; |
382 | ctx.sh = sh; | 382 | ctx.sh = sh; |
383 | GNUNET_CONTAINER_multihashmap_get_multiple (sh->send_callbacks, | 383 | GNUNET_CONTAINER_multipeermap_get_multiple (sh->send_callbacks, |
384 | &ack->target.hashPubKey, | 384 | &ack->target, |
385 | &process_ack, | 385 | &process_ack, |
386 | &ctx); | 386 | &ctx); |
387 | break; | 387 | break; |
@@ -441,14 +441,14 @@ transmit_start (void *cls, | |||
441 | */ | 441 | */ |
442 | static int | 442 | static int |
443 | cleanup_send_cb (void *cls, | 443 | cleanup_send_cb (void *cls, |
444 | const struct GNUNET_HashCode *key, | 444 | const struct GNUNET_PeerIdentity *key, |
445 | void *value) | 445 | void *value) |
446 | { | 446 | { |
447 | struct GNUNET_DV_ServiceHandle *sh = cls; | 447 | struct GNUNET_DV_ServiceHandle *sh = cls; |
448 | struct GNUNET_DV_TransmitHandle *th = value; | 448 | struct GNUNET_DV_TransmitHandle *th = value; |
449 | 449 | ||
450 | GNUNET_assert (GNUNET_YES == | 450 | GNUNET_assert (GNUNET_YES == |
451 | GNUNET_CONTAINER_multihashmap_remove (sh->send_callbacks, | 451 | GNUNET_CONTAINER_multipeermap_remove (sh->send_callbacks, |
452 | key, | 452 | key, |
453 | th)); | 453 | th)); |
454 | th->cb (th->cb_cls, GNUNET_SYSERR); | 454 | th->cb (th->cb_cls, GNUNET_SYSERR); |
@@ -475,7 +475,7 @@ reconnect (struct GNUNET_DV_ServiceHandle *sh) | |||
475 | GNUNET_CLIENT_disconnect (sh->client); | 475 | GNUNET_CLIENT_disconnect (sh->client); |
476 | sh->client = NULL; | 476 | sh->client = NULL; |
477 | } | 477 | } |
478 | GNUNET_CONTAINER_multihashmap_iterate (sh->send_callbacks, | 478 | GNUNET_CONTAINER_multipeermap_iterate (sh->send_callbacks, |
479 | &cleanup_send_cb, | 479 | &cleanup_send_cb, |
480 | sh); | 480 | sh); |
481 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 481 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -523,7 +523,7 @@ GNUNET_DV_service_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
523 | sh->distance_cb = distance_cb; | 523 | sh->distance_cb = distance_cb; |
524 | sh->disconnect_cb = disconnect_cb; | 524 | sh->disconnect_cb = disconnect_cb; |
525 | sh->message_cb = message_cb; | 525 | sh->message_cb = message_cb; |
526 | sh->send_callbacks = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_YES); | 526 | sh->send_callbacks = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES); |
527 | reconnect (sh); | 527 | reconnect (sh); |
528 | return sh; | 528 | return sh; |
529 | } | 529 | } |
@@ -558,10 +558,10 @@ GNUNET_DV_service_disconnect (struct GNUNET_DV_ServiceHandle *sh) | |||
558 | GNUNET_CLIENT_disconnect (sh->client); | 558 | GNUNET_CLIENT_disconnect (sh->client); |
559 | sh->client = NULL; | 559 | sh->client = NULL; |
560 | } | 560 | } |
561 | GNUNET_CONTAINER_multihashmap_iterate (sh->send_callbacks, | 561 | GNUNET_CONTAINER_multipeermap_iterate (sh->send_callbacks, |
562 | &cleanup_send_cb, | 562 | &cleanup_send_cb, |
563 | sh); | 563 | sh); |
564 | GNUNET_CONTAINER_multihashmap_destroy (sh->send_callbacks); | 564 | GNUNET_CONTAINER_multipeermap_destroy (sh->send_callbacks); |
565 | GNUNET_free (sh); | 565 | GNUNET_free (sh); |
566 | } | 566 | } |
567 | 567 | ||
@@ -637,8 +637,8 @@ GNUNET_DV_send_cancel (struct GNUNET_DV_TransmitHandle *th) | |||
637 | struct GNUNET_DV_ServiceHandle *sh = th->sh; | 637 | struct GNUNET_DV_ServiceHandle *sh = th->sh; |
638 | int ret; | 638 | int ret; |
639 | 639 | ||
640 | ret = GNUNET_CONTAINER_multihashmap_remove (sh->send_callbacks, | 640 | ret = GNUNET_CONTAINER_multipeermap_remove (sh->send_callbacks, |
641 | &th->target.hashPubKey, | 641 | &th->target, |
642 | th); | 642 | th); |
643 | if (GNUNET_YES != ret) | 643 | if (GNUNET_YES != ret) |
644 | GNUNET_CONTAINER_DLL_remove (sh->th_head, | 644 | GNUNET_CONTAINER_DLL_remove (sh->th_head, |
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index a1ce191cf..19303ed83 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -198,7 +198,7 @@ struct DirectNeighbor | |||
198 | * Note that the distances in the targets are from the point-of-view | 198 | * Note that the distances in the targets are from the point-of-view |
199 | * of the peer, not from us! | 199 | * of the peer, not from us! |
200 | */ | 200 | */ |
201 | struct GNUNET_CONTAINER_MultiHashMap *neighbor_table; | 201 | struct GNUNET_CONTAINER_MultiPeerMap *neighbor_table; |
202 | 202 | ||
203 | /** | 203 | /** |
204 | * Updated routing table of the neighbor, under construction, | 204 | * Updated routing table of the neighbor, under construction, |
@@ -207,7 +207,7 @@ struct DirectNeighbor | |||
207 | * Note that the distances in the targets are from the point-of-view | 207 | * Note that the distances in the targets are from the point-of-view |
208 | * of the peer, not from us! | 208 | * of the peer, not from us! |
209 | */ | 209 | */ |
210 | struct GNUNET_CONTAINER_MultiHashMap *neighbor_table_consensus; | 210 | struct GNUNET_CONTAINER_MultiPeerMap *neighbor_table_consensus; |
211 | 211 | ||
212 | /** | 212 | /** |
213 | * Our current (exposed) routing table as a set. | 213 | * Our current (exposed) routing table as a set. |
@@ -317,18 +317,18 @@ struct ConsensusSet | |||
317 | 317 | ||
318 | 318 | ||
319 | /** | 319 | /** |
320 | * Hashmap of all of our neighbors; processing these usually requires | 320 | * Peermap of all of our neighbors; processing these usually requires |
321 | * first checking to see if the peer is core-connected and if the | 321 | * first checking to see if the peer is core-connected and if the |
322 | * distance is 1, in which case they are direct neighbors. | 322 | * distance is 1, in which case they are direct neighbors. |
323 | */ | 323 | */ |
324 | static struct GNUNET_CONTAINER_MultiHashMap *direct_neighbors; | 324 | static struct GNUNET_CONTAINER_MultiPeerMap *direct_neighbors; |
325 | 325 | ||
326 | /** | 326 | /** |
327 | * Hashmap with all routes that we currently support; contains | 327 | * Hashmap with all routes that we currently support; contains |
328 | * routing information for all peers from distance 2 | 328 | * routing information for all peers from distance 2 |
329 | * up to distance DEFAULT_FISHEYE_DEPTH. | 329 | * up to distance DEFAULT_FISHEYE_DEPTH. |
330 | */ | 330 | */ |
331 | static struct GNUNET_CONTAINER_MultiHashMap *all_routes; | 331 | static struct GNUNET_CONTAINER_MultiPeerMap *all_routes; |
332 | 332 | ||
333 | /** | 333 | /** |
334 | * Array of consensus sets we expose to the outside world. Sets | 334 | * Array of consensus sets we expose to the outside world. Sets |
@@ -804,6 +804,8 @@ static void | |||
804 | handle_direct_connect (struct DirectNeighbor *neighbor) | 804 | handle_direct_connect (struct DirectNeighbor *neighbor) |
805 | { | 805 | { |
806 | struct Route *route; | 806 | struct Route *route; |
807 | struct GNUNET_HashCode h1; | ||
808 | struct GNUNET_HashCode h2; | ||
807 | struct GNUNET_HashCode session_id; | 809 | struct GNUNET_HashCode session_id; |
808 | 810 | ||
809 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 811 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -812,8 +814,8 @@ handle_direct_connect (struct DirectNeighbor *neighbor) | |||
812 | GNUNET_STATISTICS_update (stats, | 814 | GNUNET_STATISTICS_update (stats, |
813 | "# peers connected (1-hop)", | 815 | "# peers connected (1-hop)", |
814 | 1, GNUNET_NO); | 816 | 1, GNUNET_NO); |
815 | route = GNUNET_CONTAINER_multihashmap_get (all_routes, | 817 | route = GNUNET_CONTAINER_multipeermap_get (all_routes, |
816 | &neighbor->peer.hashPubKey); | 818 | &neighbor->peer); |
817 | if (NULL != route) | 819 | if (NULL != route) |
818 | { | 820 | { |
819 | send_disconnect_to_plugin (&neighbor->peer); | 821 | send_disconnect_to_plugin (&neighbor->peer); |
@@ -821,8 +823,10 @@ handle_direct_connect (struct DirectNeighbor *neighbor) | |||
821 | GNUNET_free (route); | 823 | GNUNET_free (route); |
822 | } | 824 | } |
823 | /* construct session ID seed as XOR of both peer's identities */ | 825 | /* construct session ID seed as XOR of both peer's identities */ |
824 | GNUNET_CRYPTO_hash_xor (&my_identity.hashPubKey, | 826 | GNUNET_CRYPTO_hash (&my_identity, sizeof (my_identity), &h1); |
825 | &neighbor->peer.hashPubKey, | 827 | GNUNET_CRYPTO_hash (&neighbor->peer, sizeof (struct GNUNET_PeerIdentity), &h2); |
828 | GNUNET_CRYPTO_hash_xor (&h1, | ||
829 | &h2, | ||
826 | &session_id); | 830 | &session_id); |
827 | /* make sure session ID is unique across applications by salting it with 'DV' */ | 831 | /* make sure session ID is unique across applications by salting it with 'DV' */ |
828 | GNUNET_CRYPTO_hkdf (&neighbor->real_session_id, sizeof (struct GNUNET_HashCode), | 832 | GNUNET_CRYPTO_hkdf (&neighbor->real_session_id, sizeof (struct GNUNET_HashCode), |
@@ -830,8 +834,9 @@ handle_direct_connect (struct DirectNeighbor *neighbor) | |||
830 | "DV-SALT", 2, | 834 | "DV-SALT", 2, |
831 | &session_id, sizeof (session_id), | 835 | &session_id, sizeof (session_id), |
832 | NULL, 0); | 836 | NULL, 0); |
833 | if (1 == GNUNET_CRYPTO_hash_cmp (&neighbor->peer.hashPubKey, | 837 | if (0 < memcmp (&neighbor->peer, |
834 | &my_identity.hashPubKey)) | 838 | &my_identity, |
839 | sizeof (struct GNUNET_PeerIdentity))) | ||
835 | { | 840 | { |
836 | neighbor->initiate_task = GNUNET_SCHEDULER_add_now (&initiate_set_union, | 841 | neighbor->initiate_task = GNUNET_SCHEDULER_add_now (&initiate_set_union, |
837 | neighbor); | 842 | neighbor); |
@@ -865,8 +870,8 @@ handle_core_connect (void *cls, | |||
865 | if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) | 870 | if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) |
866 | return; | 871 | return; |
867 | /* check if entry exists */ | 872 | /* check if entry exists */ |
868 | neighbor = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, | 873 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, |
869 | &peer->hashPubKey); | 874 | peer); |
870 | if (NULL != neighbor) | 875 | if (NULL != neighbor) |
871 | { | 876 | { |
872 | GNUNET_break (GNUNET_YES != neighbor->connected); | 877 | GNUNET_break (GNUNET_YES != neighbor->connected); |
@@ -886,8 +891,8 @@ handle_core_connect (void *cls, | |||
886 | neighbor = GNUNET_new (struct DirectNeighbor); | 891 | neighbor = GNUNET_new (struct DirectNeighbor); |
887 | neighbor->peer = *peer; | 892 | neighbor->peer = *peer; |
888 | GNUNET_assert (GNUNET_YES == | 893 | GNUNET_assert (GNUNET_YES == |
889 | GNUNET_CONTAINER_multihashmap_put (direct_neighbors, | 894 | GNUNET_CONTAINER_multipeermap_put (direct_neighbors, |
890 | &peer->hashPubKey, | 895 | peer, |
891 | neighbor, | 896 | neighbor, |
892 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 897 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
893 | neighbor->connected = GNUNET_YES; | 898 | neighbor->connected = GNUNET_YES; |
@@ -905,7 +910,7 @@ handle_core_connect (void *cls, | |||
905 | */ | 910 | */ |
906 | static int | 911 | static int |
907 | free_targets (void *cls, | 912 | free_targets (void *cls, |
908 | const struct GNUNET_HashCode *key, | 913 | const struct GNUNET_PeerIdentity *key, |
909 | void *value) | 914 | void *value) |
910 | { | 915 | { |
911 | GNUNET_free (value); | 916 | GNUNET_free (value); |
@@ -914,7 +919,7 @@ free_targets (void *cls, | |||
914 | 919 | ||
915 | 920 | ||
916 | /** | 921 | /** |
917 | * Multihashmap iterator for checking if a given route is | 922 | * Multipeerhmap iterator for checking if a given route is |
918 | * (now) useful to this peer. | 923 | * (now) useful to this peer. |
919 | * | 924 | * |
920 | * @param cls the direct neighbor for the given route | 925 | * @param cls the direct neighbor for the given route |
@@ -925,14 +930,14 @@ free_targets (void *cls, | |||
925 | */ | 930 | */ |
926 | static int | 931 | static int |
927 | check_possible_route (void *cls, | 932 | check_possible_route (void *cls, |
928 | const struct GNUNET_HashCode *key, | 933 | const struct GNUNET_PeerIdentity *key, |
929 | void *value) | 934 | void *value) |
930 | { | 935 | { |
931 | struct DirectNeighbor *neighbor = cls; | 936 | struct DirectNeighbor *neighbor = cls; |
932 | struct Target *target = value; | 937 | struct Target *target = value; |
933 | struct Route *route; | 938 | struct Route *route; |
934 | 939 | ||
935 | route = GNUNET_CONTAINER_multihashmap_get (all_routes, | 940 | route = GNUNET_CONTAINER_multipeermap_get (all_routes, |
936 | key); | 941 | key); |
937 | if (NULL != route) | 942 | if (NULL != route) |
938 | { | 943 | { |
@@ -951,8 +956,8 @@ check_possible_route (void *cls, | |||
951 | route->target.peer = target->peer; | 956 | route->target.peer = target->peer; |
952 | allocate_route (route, ntohl (route->target.distance)); | 957 | allocate_route (route, ntohl (route->target.distance)); |
953 | GNUNET_assert (GNUNET_YES == | 958 | GNUNET_assert (GNUNET_YES == |
954 | GNUNET_CONTAINER_multihashmap_put (all_routes, | 959 | GNUNET_CONTAINER_multipeermap_put (all_routes, |
955 | &route->target.peer.hashPubKey, | 960 | &route->target.peer, |
956 | route, | 961 | route, |
957 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 962 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
958 | send_connect_to_plugin (&route->target.peer, ntohl (target->distance)); | 963 | send_connect_to_plugin (&route->target.peer, ntohl (target->distance)); |
@@ -961,7 +966,7 @@ check_possible_route (void *cls, | |||
961 | 966 | ||
962 | 967 | ||
963 | /** | 968 | /** |
964 | * Multihashmap iterator for finding routes that were previously | 969 | * Multipeermap iterator for finding routes that were previously |
965 | * "hidden" due to a better route (called after a disconnect event). | 970 | * "hidden" due to a better route (called after a disconnect event). |
966 | * | 971 | * |
967 | * @param cls NULL | 972 | * @param cls NULL |
@@ -971,7 +976,7 @@ check_possible_route (void *cls, | |||
971 | */ | 976 | */ |
972 | static int | 977 | static int |
973 | refresh_routes (void *cls, | 978 | refresh_routes (void *cls, |
974 | const struct GNUNET_HashCode *key, | 979 | const struct GNUNET_PeerIdentity *key, |
975 | void *value) | 980 | void *value) |
976 | { | 981 | { |
977 | struct DirectNeighbor *neighbor = value; | 982 | struct DirectNeighbor *neighbor = value; |
@@ -980,7 +985,7 @@ refresh_routes (void *cls, | |||
980 | (DIRECT_NEIGHBOR_COST != neighbor->distance) ) | 985 | (DIRECT_NEIGHBOR_COST != neighbor->distance) ) |
981 | return GNUNET_YES; | 986 | return GNUNET_YES; |
982 | if (NULL != neighbor->neighbor_table) | 987 | if (NULL != neighbor->neighbor_table) |
983 | GNUNET_CONTAINER_multihashmap_iterate (neighbor->neighbor_table, | 988 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table, |
984 | &check_possible_route, | 989 | &check_possible_route, |
985 | neighbor); | 990 | neighbor); |
986 | return GNUNET_YES; | 991 | return GNUNET_YES; |
@@ -1009,7 +1014,7 @@ get_atsi_distance (const struct GNUNET_ATS_Information *atsi, | |||
1009 | 1014 | ||
1010 | 1015 | ||
1011 | /** | 1016 | /** |
1012 | * Multihashmap iterator for freeing routes that go via a particular | 1017 | * Multipeermap iterator for freeing routes that go via a particular |
1013 | * neighbor that disconnected and is thus no longer available. | 1018 | * neighbor that disconnected and is thus no longer available. |
1014 | * | 1019 | * |
1015 | * @param cls the direct neighbor that is now unavailable | 1020 | * @param cls the direct neighbor that is now unavailable |
@@ -1020,7 +1025,7 @@ get_atsi_distance (const struct GNUNET_ATS_Information *atsi, | |||
1020 | */ | 1025 | */ |
1021 | static int | 1026 | static int |
1022 | cull_routes (void *cls, | 1027 | cull_routes (void *cls, |
1023 | const struct GNUNET_HashCode *key, | 1028 | const struct GNUNET_PeerIdentity *key, |
1024 | void *value) | 1029 | void *value) |
1025 | { | 1030 | { |
1026 | struct DirectNeighbor *neighbor = cls; | 1031 | struct DirectNeighbor *neighbor = cls; |
@@ -1029,7 +1034,7 @@ cull_routes (void *cls, | |||
1029 | if (route->next_hop != neighbor) | 1034 | if (route->next_hop != neighbor) |
1030 | return GNUNET_YES; /* not affected */ | 1035 | return GNUNET_YES; /* not affected */ |
1031 | GNUNET_assert (GNUNET_YES == | 1036 | GNUNET_assert (GNUNET_YES == |
1032 | GNUNET_CONTAINER_multihashmap_remove (all_routes, key, value)); | 1037 | GNUNET_CONTAINER_multipeermap_remove (all_routes, key, value)); |
1033 | release_route (route); | 1038 | release_route (route); |
1034 | send_disconnect_to_plugin (&route->target.peer); | 1039 | send_disconnect_to_plugin (&route->target.peer); |
1035 | GNUNET_free (route); | 1040 | GNUNET_free (route); |
@@ -1048,7 +1053,7 @@ cull_routes (void *cls, | |||
1048 | static void | 1053 | static void |
1049 | handle_direct_disconnect (struct DirectNeighbor *neighbor) | 1054 | handle_direct_disconnect (struct DirectNeighbor *neighbor) |
1050 | { | 1055 | { |
1051 | GNUNET_CONTAINER_multihashmap_iterate (all_routes, | 1056 | GNUNET_CONTAINER_multipeermap_iterate (all_routes, |
1052 | &cull_routes, | 1057 | &cull_routes, |
1053 | neighbor); | 1058 | neighbor); |
1054 | if (NULL != neighbor->cth) | 1059 | if (NULL != neighbor->cth) |
@@ -1058,18 +1063,18 @@ handle_direct_disconnect (struct DirectNeighbor *neighbor) | |||
1058 | } | 1063 | } |
1059 | if (NULL != neighbor->neighbor_table_consensus) | 1064 | if (NULL != neighbor->neighbor_table_consensus) |
1060 | { | 1065 | { |
1061 | GNUNET_CONTAINER_multihashmap_iterate (neighbor->neighbor_table_consensus, | 1066 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table_consensus, |
1062 | &free_targets, | 1067 | &free_targets, |
1063 | NULL); | 1068 | NULL); |
1064 | GNUNET_CONTAINER_multihashmap_destroy (neighbor->neighbor_table_consensus); | 1069 | GNUNET_CONTAINER_multipeermap_destroy (neighbor->neighbor_table_consensus); |
1065 | neighbor->neighbor_table_consensus = NULL; | 1070 | neighbor->neighbor_table_consensus = NULL; |
1066 | } | 1071 | } |
1067 | if (NULL != neighbor->neighbor_table) | 1072 | if (NULL != neighbor->neighbor_table) |
1068 | { | 1073 | { |
1069 | GNUNET_CONTAINER_multihashmap_iterate (neighbor->neighbor_table, | 1074 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table, |
1070 | &free_targets, | 1075 | &free_targets, |
1071 | NULL); | 1076 | NULL); |
1072 | GNUNET_CONTAINER_multihashmap_destroy (neighbor->neighbor_table); | 1077 | GNUNET_CONTAINER_multipeermap_destroy (neighbor->neighbor_table); |
1073 | neighbor->neighbor_table = NULL; | 1078 | neighbor->neighbor_table = NULL; |
1074 | } | 1079 | } |
1075 | if (NULL != neighbor->set_op) | 1080 | if (NULL != neighbor->set_op) |
@@ -1127,8 +1132,8 @@ handle_ats_update (void *cls, | |||
1127 | GNUNET_i2s (&address->peer), | 1132 | GNUNET_i2s (&address->peer), |
1128 | (unsigned int) distance); | 1133 | (unsigned int) distance); |
1129 | /* check if entry exists */ | 1134 | /* check if entry exists */ |
1130 | neighbor = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, | 1135 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, |
1131 | &address->peer.hashPubKey); | 1136 | &address->peer); |
1132 | if (NULL != neighbor) | 1137 | if (NULL != neighbor) |
1133 | { | 1138 | { |
1134 | if ( (DIRECT_NEIGHBOR_COST == neighbor->distance) && | 1139 | if ( (DIRECT_NEIGHBOR_COST == neighbor->distance) && |
@@ -1141,7 +1146,7 @@ handle_ats_update (void *cls, | |||
1141 | "# peers connected (1-hop)", | 1146 | "# peers connected (1-hop)", |
1142 | -1, GNUNET_NO); | 1147 | -1, GNUNET_NO); |
1143 | handle_direct_disconnect (neighbor); | 1148 | handle_direct_disconnect (neighbor); |
1144 | GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, | 1149 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, |
1145 | &refresh_routes, | 1150 | &refresh_routes, |
1146 | NULL); | 1151 | NULL); |
1147 | return; | 1152 | return; |
@@ -1157,8 +1162,8 @@ handle_ats_update (void *cls, | |||
1157 | neighbor = GNUNET_new (struct DirectNeighbor); | 1162 | neighbor = GNUNET_new (struct DirectNeighbor); |
1158 | neighbor->peer = address->peer; | 1163 | neighbor->peer = address->peer; |
1159 | GNUNET_assert (GNUNET_YES == | 1164 | GNUNET_assert (GNUNET_YES == |
1160 | GNUNET_CONTAINER_multihashmap_put (direct_neighbors, | 1165 | GNUNET_CONTAINER_multipeermap_put (direct_neighbors, |
1161 | &address->peer.hashPubKey, | 1166 | &address->peer, |
1162 | neighbor, | 1167 | neighbor, |
1163 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1168 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1164 | neighbor->connected = GNUNET_NO; /* not yet */ | 1169 | neighbor->connected = GNUNET_NO; /* not yet */ |
@@ -1177,19 +1182,19 @@ handle_ats_update (void *cls, | |||
1177 | */ | 1182 | */ |
1178 | static int | 1183 | static int |
1179 | check_target_removed (void *cls, | 1184 | check_target_removed (void *cls, |
1180 | const struct GNUNET_HashCode *key, | 1185 | const struct GNUNET_PeerIdentity *key, |
1181 | void *value) | 1186 | void *value) |
1182 | { | 1187 | { |
1183 | struct DirectNeighbor *neighbor = cls; | 1188 | struct DirectNeighbor *neighbor = cls; |
1184 | struct Target *new_target; | 1189 | struct Target *new_target; |
1185 | struct Route *current_route; | 1190 | struct Route *current_route; |
1186 | 1191 | ||
1187 | new_target = GNUNET_CONTAINER_multihashmap_get (neighbor->neighbor_table_consensus, | 1192 | new_target = GNUNET_CONTAINER_multipeermap_get (neighbor->neighbor_table_consensus, |
1188 | key); | 1193 | key); |
1189 | if (NULL == new_target) | 1194 | if (NULL == new_target) |
1190 | { | 1195 | { |
1191 | /* target was revoked, check if it was used */ | 1196 | /* target was revoked, check if it was used */ |
1192 | current_route = GNUNET_CONTAINER_multihashmap_get (all_routes, | 1197 | current_route = GNUNET_CONTAINER_multipeermap_get (all_routes, |
1193 | key); | 1198 | key); |
1194 | if ( (NULL == current_route) || | 1199 | if ( (NULL == current_route) || |
1195 | (current_route->next_hop != neighbor) ) | 1200 | (current_route->next_hop != neighbor) ) |
@@ -1202,7 +1207,7 @@ check_target_removed (void *cls, | |||
1202 | "Lost route to %s\n", | 1207 | "Lost route to %s\n", |
1203 | GNUNET_i2s (¤t_route->target.peer)); | 1208 | GNUNET_i2s (¤t_route->target.peer)); |
1204 | GNUNET_assert (GNUNET_YES == | 1209 | GNUNET_assert (GNUNET_YES == |
1205 | GNUNET_CONTAINER_multihashmap_remove (all_routes, key, current_route)); | 1210 | GNUNET_CONTAINER_multipeermap_remove (all_routes, key, current_route)); |
1206 | send_disconnect_to_plugin (¤t_route->target.peer); | 1211 | send_disconnect_to_plugin (¤t_route->target.peer); |
1207 | GNUNET_free (current_route); | 1212 | GNUNET_free (current_route); |
1208 | neighbor->target_removed = GNUNET_YES; | 1213 | neighbor->target_removed = GNUNET_YES; |
@@ -1222,7 +1227,7 @@ check_target_removed (void *cls, | |||
1222 | */ | 1227 | */ |
1223 | static int | 1228 | static int |
1224 | check_target_added (void *cls, | 1229 | check_target_added (void *cls, |
1225 | const struct GNUNET_HashCode *key, | 1230 | const struct GNUNET_PeerIdentity *key, |
1226 | void *value) | 1231 | void *value) |
1227 | { | 1232 | { |
1228 | struct DirectNeighbor *neighbor = cls; | 1233 | struct DirectNeighbor *neighbor = cls; |
@@ -1230,7 +1235,7 @@ check_target_added (void *cls, | |||
1230 | struct Route *current_route; | 1235 | struct Route *current_route; |
1231 | 1236 | ||
1232 | /* target was revoked, check if it was used */ | 1237 | /* target was revoked, check if it was used */ |
1233 | current_route = GNUNET_CONTAINER_multihashmap_get (all_routes, | 1238 | current_route = GNUNET_CONTAINER_multipeermap_get (all_routes, |
1234 | key); | 1239 | key); |
1235 | if (NULL != current_route) | 1240 | if (NULL != current_route) |
1236 | { | 1241 | { |
@@ -1270,8 +1275,8 @@ check_target_added (void *cls, | |||
1270 | current_route->target.peer = target->peer; | 1275 | current_route->target.peer = target->peer; |
1271 | current_route->target.distance = htonl (ntohl (target->distance) + 1); | 1276 | current_route->target.distance = htonl (ntohl (target->distance) + 1); |
1272 | GNUNET_assert (GNUNET_YES == | 1277 | GNUNET_assert (GNUNET_YES == |
1273 | GNUNET_CONTAINER_multihashmap_put (all_routes, | 1278 | GNUNET_CONTAINER_multipeermap_put (all_routes, |
1274 | ¤t_route->target.peer.hashPubKey, | 1279 | ¤t_route->target.peer, |
1275 | current_route, | 1280 | current_route, |
1276 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1281 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1277 | send_connect_to_plugin (¤t_route->target.peer, | 1282 | send_connect_to_plugin (¤t_route->target.peer, |
@@ -1312,8 +1317,8 @@ handle_set_union_result (void *cls, | |||
1312 | target = GNUNET_new (struct Target); | 1317 | target = GNUNET_new (struct Target); |
1313 | memcpy (target, element->data, sizeof (struct Target)); | 1318 | memcpy (target, element->data, sizeof (struct Target)); |
1314 | if (GNUNET_YES != | 1319 | if (GNUNET_YES != |
1315 | GNUNET_CONTAINER_multihashmap_put (neighbor->neighbor_table_consensus, | 1320 | GNUNET_CONTAINER_multipeermap_put (neighbor->neighbor_table_consensus, |
1316 | &target->peer.hashPubKey, | 1321 | &target->peer, |
1317 | target, | 1322 | target, |
1318 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | 1323 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) |
1319 | { | 1324 | { |
@@ -1328,14 +1333,15 @@ handle_set_union_result (void *cls, | |||
1328 | neighbor->set_op = NULL; | 1333 | neighbor->set_op = NULL; |
1329 | if (NULL != neighbor->neighbor_table_consensus) | 1334 | if (NULL != neighbor->neighbor_table_consensus) |
1330 | { | 1335 | { |
1331 | GNUNET_CONTAINER_multihashmap_iterate (neighbor->neighbor_table_consensus, | 1336 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table_consensus, |
1332 | &free_targets, | 1337 | &free_targets, |
1333 | NULL); | 1338 | NULL); |
1334 | GNUNET_CONTAINER_multihashmap_destroy (neighbor->neighbor_table_consensus); | 1339 | GNUNET_CONTAINER_multipeermap_destroy (neighbor->neighbor_table_consensus); |
1335 | neighbor->neighbor_table_consensus = NULL; | 1340 | neighbor->neighbor_table_consensus = NULL; |
1336 | } | 1341 | } |
1337 | if (1 == GNUNET_CRYPTO_hash_cmp (&neighbor->peer.hashPubKey, | 1342 | if (0 < memcmp (&neighbor->peer, |
1338 | &my_identity.hashPubKey)) | 1343 | &my_identity, |
1344 | sizeof (struct GNUNET_PeerIdentity))) | ||
1339 | neighbor->initiate_task = GNUNET_SCHEDULER_add_delayed (GNUNET_DV_CONSENSUS_FREQUENCY, | 1345 | neighbor->initiate_task = GNUNET_SCHEDULER_add_delayed (GNUNET_DV_CONSENSUS_FREQUENCY, |
1340 | &initiate_set_union, | 1346 | &initiate_set_union, |
1341 | neighbor); | 1347 | neighbor); |
@@ -1343,26 +1349,26 @@ handle_set_union_result (void *cls, | |||
1343 | case GNUNET_SET_STATUS_HALF_DONE: | 1349 | case GNUNET_SET_STATUS_HALF_DONE: |
1344 | /* we got all of our updates; integrate routing table! */ | 1350 | /* we got all of our updates; integrate routing table! */ |
1345 | neighbor->target_removed = GNUNET_NO; | 1351 | neighbor->target_removed = GNUNET_NO; |
1346 | GNUNET_CONTAINER_multihashmap_iterate (neighbor->neighbor_table, | 1352 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table, |
1347 | &check_target_removed, | 1353 | &check_target_removed, |
1348 | neighbor); | 1354 | neighbor); |
1349 | if (GNUNET_YES == neighbor->target_removed) | 1355 | if (GNUNET_YES == neighbor->target_removed) |
1350 | { | 1356 | { |
1351 | /* check if we got an alternative for the removed routes */ | 1357 | /* check if we got an alternative for the removed routes */ |
1352 | GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, | 1358 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, |
1353 | &refresh_routes, | 1359 | &refresh_routes, |
1354 | NULL); | 1360 | NULL); |
1355 | } | 1361 | } |
1356 | /* add targets that appeared (and check for improved routes) */ | 1362 | /* add targets that appeared (and check for improved routes) */ |
1357 | GNUNET_CONTAINER_multihashmap_iterate (neighbor->neighbor_table_consensus, | 1363 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table_consensus, |
1358 | &check_target_added, | 1364 | &check_target_added, |
1359 | neighbor); | 1365 | neighbor); |
1360 | if (NULL != neighbor->neighbor_table) | 1366 | if (NULL != neighbor->neighbor_table) |
1361 | { | 1367 | { |
1362 | GNUNET_CONTAINER_multihashmap_iterate (neighbor->neighbor_table, | 1368 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table, |
1363 | &free_targets, | 1369 | &free_targets, |
1364 | NULL); | 1370 | NULL); |
1365 | GNUNET_CONTAINER_multihashmap_destroy (neighbor->neighbor_table); | 1371 | GNUNET_CONTAINER_multipeermap_destroy (neighbor->neighbor_table); |
1366 | neighbor->neighbor_table = NULL; | 1372 | neighbor->neighbor_table = NULL; |
1367 | } | 1373 | } |
1368 | neighbor->neighbor_table = neighbor->neighbor_table_consensus; | 1374 | neighbor->neighbor_table = neighbor->neighbor_table_consensus; |
@@ -1371,8 +1377,9 @@ handle_set_union_result (void *cls, | |||
1371 | case GNUNET_SET_STATUS_DONE: | 1377 | case GNUNET_SET_STATUS_DONE: |
1372 | /* operation done, schedule next run! */ | 1378 | /* operation done, schedule next run! */ |
1373 | neighbor->set_op = NULL; | 1379 | neighbor->set_op = NULL; |
1374 | if (1 == GNUNET_CRYPTO_hash_cmp (&neighbor->peer.hashPubKey, | 1380 | if (0 < memcmp (&neighbor->peer, |
1375 | &my_identity.hashPubKey)) | 1381 | &my_identity, |
1382 | sizeof (struct GNUNET_PeerIdentity))) | ||
1376 | neighbor->initiate_task = GNUNET_SCHEDULER_add_delayed (GNUNET_DV_CONSENSUS_FREQUENCY, | 1383 | neighbor->initiate_task = GNUNET_SCHEDULER_add_delayed (GNUNET_DV_CONSENSUS_FREQUENCY, |
1377 | &initiate_set_union, | 1384 | &initiate_set_union, |
1378 | neighbor); | 1385 | neighbor); |
@@ -1500,8 +1507,8 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1500 | sizeof (struct GNUNET_PeerIdentity))) | 1507 | sizeof (struct GNUNET_PeerIdentity))) |
1501 | { | 1508 | { |
1502 | /* message is for me, check reverse route! */ | 1509 | /* message is for me, check reverse route! */ |
1503 | route = GNUNET_CONTAINER_multihashmap_get (all_routes, | 1510 | route = GNUNET_CONTAINER_multipeermap_get (all_routes, |
1504 | &rm->sender.hashPubKey); | 1511 | &rm->sender); |
1505 | if (NULL == route) | 1512 | if (NULL == route) |
1506 | { | 1513 | { |
1507 | /* don't have reverse route, drop */ | 1514 | /* don't have reverse route, drop */ |
@@ -1518,8 +1525,8 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1518 | ntohl (route->target.distance)); | 1525 | ntohl (route->target.distance)); |
1519 | return GNUNET_OK; | 1526 | return GNUNET_OK; |
1520 | } | 1527 | } |
1521 | route = GNUNET_CONTAINER_multihashmap_get (all_routes, | 1528 | route = GNUNET_CONTAINER_multipeermap_get (all_routes, |
1522 | &rm->target.hashPubKey); | 1529 | &rm->target); |
1523 | if (NULL == route) | 1530 | if (NULL == route) |
1524 | { | 1531 | { |
1525 | GNUNET_STATISTICS_update (stats, | 1532 | GNUNET_STATISTICS_update (stats, |
@@ -1578,8 +1585,8 @@ handle_dv_send_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
1578 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1585 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1579 | return; | 1586 | return; |
1580 | } | 1587 | } |
1581 | route = GNUNET_CONTAINER_multihashmap_get (all_routes, | 1588 | route = GNUNET_CONTAINER_multipeermap_get (all_routes, |
1582 | &msg->target.hashPubKey); | 1589 | &msg->target); |
1583 | if (NULL == route) | 1590 | if (NULL == route) |
1584 | { | 1591 | { |
1585 | /* got disconnected */ | 1592 | /* got disconnected */ |
@@ -1625,8 +1632,8 @@ cleanup_neighbor (struct DirectNeighbor *neighbor) | |||
1625 | } | 1632 | } |
1626 | handle_direct_disconnect (neighbor); | 1633 | handle_direct_disconnect (neighbor); |
1627 | GNUNET_assert (GNUNET_YES == | 1634 | GNUNET_assert (GNUNET_YES == |
1628 | GNUNET_CONTAINER_multihashmap_remove (direct_neighbors, | 1635 | GNUNET_CONTAINER_multipeermap_remove (direct_neighbors, |
1629 | &neighbor->peer.hashPubKey, | 1636 | &neighbor->peer, |
1630 | neighbor)); | 1637 | neighbor)); |
1631 | GNUNET_free (neighbor); | 1638 | GNUNET_free (neighbor); |
1632 | } | 1639 | } |
@@ -1650,7 +1657,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1650 | if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) | 1657 | if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) |
1651 | return; | 1658 | return; |
1652 | neighbor = | 1659 | neighbor = |
1653 | GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey); | 1660 | GNUNET_CONTAINER_multipeermap_get (direct_neighbors, peer); |
1654 | if (NULL == neighbor) | 1661 | if (NULL == neighbor) |
1655 | { | 1662 | { |
1656 | GNUNET_break (0); | 1663 | GNUNET_break (0); |
@@ -1665,14 +1672,14 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1665 | -1, GNUNET_NO); | 1672 | -1, GNUNET_NO); |
1666 | } | 1673 | } |
1667 | cleanup_neighbor (neighbor); | 1674 | cleanup_neighbor (neighbor); |
1668 | GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, | 1675 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, |
1669 | &refresh_routes, | 1676 | &refresh_routes, |
1670 | NULL); | 1677 | NULL); |
1671 | } | 1678 | } |
1672 | 1679 | ||
1673 | 1680 | ||
1674 | /** | 1681 | /** |
1675 | * Multihashmap iterator for freeing routes. Should never be called. | 1682 | * Multipeermap iterator for freeing routes. Should never be called. |
1676 | * | 1683 | * |
1677 | * @param cls NULL | 1684 | * @param cls NULL |
1678 | * @param key key value stored under | 1685 | * @param key key value stored under |
@@ -1681,13 +1688,13 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1681 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop | 1688 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop |
1682 | */ | 1689 | */ |
1683 | static int | 1690 | static int |
1684 | free_route (void *cls, const struct GNUNET_HashCode * key, void *value) | 1691 | free_route (void *cls, const struct GNUNET_PeerIdentity * key, void *value) |
1685 | { | 1692 | { |
1686 | struct Route *route = value; | 1693 | struct Route *route = value; |
1687 | 1694 | ||
1688 | GNUNET_break (0); | 1695 | GNUNET_break (0); |
1689 | GNUNET_assert (GNUNET_YES == | 1696 | GNUNET_assert (GNUNET_YES == |
1690 | GNUNET_CONTAINER_multihashmap_remove (all_routes, key, value)); | 1697 | GNUNET_CONTAINER_multipeermap_remove (all_routes, key, value)); |
1691 | release_route (route); | 1698 | release_route (route); |
1692 | send_disconnect_to_plugin (&route->target.peer); | 1699 | send_disconnect_to_plugin (&route->target.peer); |
1693 | GNUNET_free (route); | 1700 | GNUNET_free (route); |
@@ -1696,7 +1703,7 @@ free_route (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
1696 | 1703 | ||
1697 | 1704 | ||
1698 | /** | 1705 | /** |
1699 | * Multihashmap iterator for freeing direct neighbors. Should never be called. | 1706 | * Multipeermap iterator for freeing direct neighbors. Should never be called. |
1700 | * | 1707 | * |
1701 | * @param cls NULL | 1708 | * @param cls NULL |
1702 | * @param key key value stored under | 1709 | * @param key key value stored under |
@@ -1705,7 +1712,7 @@ free_route (void *cls, const struct GNUNET_HashCode * key, void *value) | |||
1705 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop | 1712 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop |
1706 | */ | 1713 | */ |
1707 | static int | 1714 | static int |
1708 | free_direct_neighbors (void *cls, const struct GNUNET_HashCode * key, void *value) | 1715 | free_direct_neighbors (void *cls, const struct GNUNET_PeerIdentity * key, void *value) |
1709 | { | 1716 | { |
1710 | struct DirectNeighbor *neighbor = value; | 1717 | struct DirectNeighbor *neighbor = value; |
1711 | 1718 | ||
@@ -1730,12 +1737,12 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1730 | core_api = NULL; | 1737 | core_api = NULL; |
1731 | GNUNET_ATS_performance_done (ats); | 1738 | GNUNET_ATS_performance_done (ats); |
1732 | ats = NULL; | 1739 | ats = NULL; |
1733 | GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, | 1740 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, |
1734 | &free_direct_neighbors, NULL); | 1741 | &free_direct_neighbors, NULL); |
1735 | GNUNET_CONTAINER_multihashmap_iterate (all_routes, | 1742 | GNUNET_CONTAINER_multipeermap_iterate (all_routes, |
1736 | &free_route, NULL); | 1743 | &free_route, NULL); |
1737 | GNUNET_CONTAINER_multihashmap_destroy (direct_neighbors); | 1744 | GNUNET_CONTAINER_multipeermap_destroy (direct_neighbors); |
1738 | GNUNET_CONTAINER_multihashmap_destroy (all_routes); | 1745 | GNUNET_CONTAINER_multipeermap_destroy (all_routes); |
1739 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | 1746 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
1740 | stats = NULL; | 1747 | stats = NULL; |
1741 | GNUNET_SERVER_notification_context_destroy (nc); | 1748 | GNUNET_SERVER_notification_context_destroy (nc); |
@@ -1757,7 +1764,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1757 | */ | 1764 | */ |
1758 | static int | 1765 | static int |
1759 | add_route (void *cls, | 1766 | add_route (void *cls, |
1760 | const struct GNUNET_HashCode *key, | 1767 | const struct GNUNET_PeerIdentity *key, |
1761 | void *value) | 1768 | void *value) |
1762 | { | 1769 | { |
1763 | struct GNUNET_SERVER_Client *client = cls; | 1770 | struct GNUNET_SERVER_Client *client = cls; |
@@ -1791,7 +1798,7 @@ handle_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
1791 | { | 1798 | { |
1792 | GNUNET_SERVER_notification_context_add (nc, client); | 1799 | GNUNET_SERVER_notification_context_add (nc, client); |
1793 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1800 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1794 | GNUNET_CONTAINER_multihashmap_iterate (all_routes, | 1801 | GNUNET_CONTAINER_multipeermap_iterate (all_routes, |
1795 | &add_route, | 1802 | &add_route, |
1796 | client); | 1803 | client); |
1797 | } | 1804 | } |
@@ -1840,8 +1847,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1840 | }; | 1847 | }; |
1841 | 1848 | ||
1842 | cfg = c; | 1849 | cfg = c; |
1843 | direct_neighbors = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); | 1850 | direct_neighbors = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); |
1844 | all_routes = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO); | 1851 | all_routes = GNUNET_CONTAINER_multipeermap_create (65536, GNUNET_NO); |
1845 | core_api = GNUNET_CORE_connect (cfg, NULL, | 1852 | core_api = GNUNET_CORE_connect (cfg, NULL, |
1846 | &core_init, | 1853 | &core_init, |
1847 | &handle_core_connect, | 1854 | &handle_core_connect, |
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index 9d1e06777..76c823b17 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c | |||
@@ -27,10 +27,8 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "platform.h" | 29 | #include "platform.h" |
30 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_protocols.h" | 31 | #include "gnunet_protocols.h" |
31 | #include "gnunet_connection_lib.h" | ||
32 | #include "gnunet_server_lib.h" | ||
33 | #include "gnunet_service_lib.h" | ||
34 | #include "gnunet_statistics_service.h" | 32 | #include "gnunet_statistics_service.h" |
35 | #include "gnunet_dv_service.h" | 33 | #include "gnunet_dv_service.h" |
36 | #include "gnunet_transport_service.h" | 34 | #include "gnunet_transport_service.h" |
@@ -146,7 +144,7 @@ struct Plugin | |||
146 | /** | 144 | /** |
147 | * Hash map of sessions (active and inactive). | 145 | * Hash map of sessions (active and inactive). |
148 | */ | 146 | */ |
149 | struct GNUNET_CONTAINER_MultiHashMap *sessions; | 147 | struct GNUNET_CONTAINER_MultiPeerMap *sessions; |
150 | 148 | ||
151 | /** | 149 | /** |
152 | * Copy of the handler array where the closures are | 150 | * Copy of the handler array where the closures are |
@@ -236,8 +234,8 @@ handle_dv_message_received (void *cls, | |||
236 | struct GNUNET_ATS_Information ats; | 234 | struct GNUNET_ATS_Information ats; |
237 | struct Session *session; | 235 | struct Session *session; |
238 | 236 | ||
239 | session = GNUNET_CONTAINER_multihashmap_get (plugin->sessions, | 237 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, |
240 | &sender->hashPubKey); | 238 | sender); |
241 | if (NULL == session) | 239 | if (NULL == session) |
242 | { | 240 | { |
243 | GNUNET_break (0); | 241 | GNUNET_break (0); |
@@ -280,8 +278,8 @@ handle_dv_connect (void *cls, | |||
280 | struct Plugin *plugin = cls; | 278 | struct Plugin *plugin = cls; |
281 | struct Session *session; | 279 | struct Session *session; |
282 | 280 | ||
283 | session = GNUNET_CONTAINER_multihashmap_get (plugin->sessions, | 281 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, |
284 | &peer->hashPubKey); | 282 | peer); |
285 | if (NULL != session) | 283 | if (NULL != session) |
286 | { | 284 | { |
287 | GNUNET_break (0); | 285 | GNUNET_break (0); |
@@ -294,8 +292,8 @@ handle_dv_connect (void *cls, | |||
294 | session->sender = *peer; | 292 | session->sender = *peer; |
295 | session->distance = distance; | 293 | session->distance = distance; |
296 | GNUNET_assert (GNUNET_YES == | 294 | GNUNET_assert (GNUNET_YES == |
297 | GNUNET_CONTAINER_multihashmap_put (plugin->sessions, | 295 | GNUNET_CONTAINER_multipeermap_put (plugin->sessions, |
298 | &session->sender.hashPubKey, | 296 | &session->sender, |
299 | session, | 297 | session, |
300 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 298 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
301 | } | 299 | } |
@@ -316,8 +314,8 @@ handle_dv_distance_changed (void *cls, | |||
316 | struct Plugin *plugin = cls; | 314 | struct Plugin *plugin = cls; |
317 | struct Session *session; | 315 | struct Session *session; |
318 | 316 | ||
319 | session = GNUNET_CONTAINER_multihashmap_get (plugin->sessions, | 317 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, |
320 | &peer->hashPubKey); | 318 | peer); |
321 | if (NULL == session) | 319 | if (NULL == session) |
322 | { | 320 | { |
323 | GNUNET_break (0); | 321 | GNUNET_break (0); |
@@ -342,8 +340,8 @@ free_session (struct Session *session) | |||
342 | struct PendingRequest *pr; | 340 | struct PendingRequest *pr; |
343 | 341 | ||
344 | GNUNET_assert (GNUNET_YES == | 342 | GNUNET_assert (GNUNET_YES == |
345 | GNUNET_CONTAINER_multihashmap_remove (plugin->sessions, | 343 | GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, |
346 | &session->sender.hashPubKey, | 344 | &session->sender, |
347 | session)); | 345 | session)); |
348 | if (GNUNET_YES == session->active) | 346 | if (GNUNET_YES == session->active) |
349 | plugin->env->session_end (plugin->env->cls, | 347 | plugin->env->session_end (plugin->env->cls, |
@@ -379,8 +377,8 @@ handle_dv_disconnect (void *cls, | |||
379 | struct Plugin *plugin = cls; | 377 | struct Plugin *plugin = cls; |
380 | struct Session *session; | 378 | struct Session *session; |
381 | 379 | ||
382 | session = GNUNET_CONTAINER_multihashmap_get (plugin->sessions, | 380 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, |
383 | &peer->hashPubKey); | 381 | peer); |
384 | if (NULL == session) | 382 | if (NULL == session) |
385 | return; /* nothing to do */ | 383 | return; /* nothing to do */ |
386 | free_session (session); | 384 | free_session (session); |
@@ -486,8 +484,8 @@ dv_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
486 | struct Session *session; | 484 | struct Session *session; |
487 | struct PendingRequest *pr; | 485 | struct PendingRequest *pr; |
488 | 486 | ||
489 | session = GNUNET_CONTAINER_multihashmap_get (plugin->sessions, | 487 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, |
490 | &target->hashPubKey); | 488 | target); |
491 | if (NULL == session) | 489 | if (NULL == session) |
492 | return; /* nothing to do */ | 490 | return; /* nothing to do */ |
493 | while (NULL != (pr = session->pr_head)) | 491 | while (NULL != (pr = session->pr_head)) |
@@ -599,8 +597,8 @@ dv_get_session (void *cls, | |||
599 | 597 | ||
600 | if (0 != address->address_length) | 598 | if (0 != address->address_length) |
601 | return NULL; | 599 | return NULL; |
602 | session = GNUNET_CONTAINER_multihashmap_get (plugin->sessions, | 600 | session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, |
603 | &address->peer.hashPubKey); | 601 | &address->peer); |
604 | if (NULL == session) | 602 | if (NULL == session) |
605 | return NULL; /* not valid right now */ | 603 | return NULL; /* not valid right now */ |
606 | session->active = GNUNET_YES; | 604 | session->active = GNUNET_YES; |
@@ -672,7 +670,7 @@ libgnunet_plugin_transport_dv_init (void *cls) | |||
672 | 670 | ||
673 | plugin = GNUNET_new (struct Plugin); | 671 | plugin = GNUNET_new (struct Plugin); |
674 | plugin->env = env; | 672 | plugin->env = env; |
675 | plugin->sessions = GNUNET_CONTAINER_multihashmap_create (1024 * 8, GNUNET_YES); | 673 | plugin->sessions = GNUNET_CONTAINER_multipeermap_create (1024 * 8, GNUNET_YES); |
676 | plugin->mst = GNUNET_SERVER_mst_create (&unbox_cb, | 674 | plugin->mst = GNUNET_SERVER_mst_create (&unbox_cb, |
677 | plugin); | 675 | plugin); |
678 | plugin->dvh = GNUNET_DV_service_connect (env->cfg, | 676 | plugin->dvh = GNUNET_DV_service_connect (env->cfg, |
@@ -683,7 +681,7 @@ libgnunet_plugin_transport_dv_init (void *cls) | |||
683 | &handle_dv_message_received); | 681 | &handle_dv_message_received); |
684 | if (NULL == plugin->dvh) | 682 | if (NULL == plugin->dvh) |
685 | { | 683 | { |
686 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); | 684 | GNUNET_CONTAINER_multipeermap_destroy (plugin->sessions); |
687 | GNUNET_SERVER_mst_destroy (plugin->mst); | 685 | GNUNET_SERVER_mst_destroy (plugin->mst); |
688 | GNUNET_free (plugin); | 686 | GNUNET_free (plugin); |
689 | return NULL; | 687 | return NULL; |
@@ -712,7 +710,7 @@ libgnunet_plugin_transport_dv_init (void *cls) | |||
712 | */ | 710 | */ |
713 | static int | 711 | static int |
714 | free_session_iterator (void *cls, | 712 | free_session_iterator (void *cls, |
715 | const struct GNUNET_HashCode *key, | 713 | const struct GNUNET_PeerIdentity *key, |
716 | void *value) | 714 | void *value) |
717 | { | 715 | { |
718 | struct Session *session = value; | 716 | struct Session *session = value; |
@@ -735,10 +733,10 @@ libgnunet_plugin_transport_dv_done (void *cls) | |||
735 | struct Plugin *plugin = api->cls; | 733 | struct Plugin *plugin = api->cls; |
736 | 734 | ||
737 | GNUNET_DV_service_disconnect (plugin->dvh); | 735 | GNUNET_DV_service_disconnect (plugin->dvh); |
738 | GNUNET_CONTAINER_multihashmap_iterate (plugin->sessions, | 736 | GNUNET_CONTAINER_multipeermap_iterate (plugin->sessions, |
739 | &free_session_iterator, | 737 | &free_session_iterator, |
740 | NULL); | 738 | NULL); |
741 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); | 739 | GNUNET_CONTAINER_multipeermap_destroy (plugin->sessions); |
742 | GNUNET_SERVER_mst_destroy (plugin->mst); | 740 | GNUNET_SERVER_mst_destroy (plugin->mst); |
743 | GNUNET_free (plugin); | 741 | GNUNET_free (plugin); |
744 | GNUNET_free (api); | 742 | GNUNET_free (api); |