diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-30 21:41:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-30 21:41:59 +0000 |
commit | 5f4c71b95681eee889deeb83449a514955a69153 (patch) | |
tree | 97d3dda1c838c3649c287b628f93d87f98b3b933 /src/topology/gnunet-daemon-topology.c | |
parent | 760a885e3d7d59a79f8372ced6c368a15d390629 (diff) | |
download | gnunet-5f4c71b95681eee889deeb83449a514955a69153.tar.gz gnunet-5f4c71b95681eee889deeb83449a514955a69153.zip |
-getting topology to compile again (part of #3047)
Diffstat (limited to 'src/topology/gnunet-daemon-topology.c')
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 140 |
1 files changed, 66 insertions, 74 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 372659bbc..5b59995a9 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -24,13 +24,13 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | ||
27 | #include "gnunet_constants.h" | 28 | #include "gnunet_constants.h" |
28 | #include "gnunet_core_service.h" | 29 | #include "gnunet_core_service.h" |
29 | #include "gnunet_protocols.h" | 30 | #include "gnunet_protocols.h" |
30 | #include "gnunet_peerinfo_service.h" | 31 | #include "gnunet_peerinfo_service.h" |
31 | #include "gnunet_statistics_service.h" | 32 | #include "gnunet_statistics_service.h" |
32 | #include "gnunet_transport_service.h" | 33 | #include "gnunet_transport_service.h" |
33 | #include "gnunet_util_lib.h" | ||
34 | 34 | ||
35 | 35 | ||
36 | /** | 36 | /** |
@@ -185,7 +185,7 @@ static struct GNUNET_PeerIdentity my_identity; | |||
185 | * which we have HELLOs. So pretty much everyone. Maps peer identities | 185 | * which we have HELLOs. So pretty much everyone. Maps peer identities |
186 | * to 'struct Peer *' values. | 186 | * to 'struct Peer *' values. |
187 | */ | 187 | */ |
188 | static struct GNUNET_CONTAINER_MultiHashMap *peers; | 188 | static struct GNUNET_CONTAINER_MultiPeerMap *peers; |
189 | 189 | ||
190 | /** | 190 | /** |
191 | * Handle for reporting statistics. | 191 | * Handle for reporting statistics. |
@@ -248,7 +248,7 @@ blacklist_check (void *cls, const struct GNUNET_PeerIdentity *pid) | |||
248 | { | 248 | { |
249 | struct Peer *pos; | 249 | struct Peer *pos; |
250 | 250 | ||
251 | pos = GNUNET_CONTAINER_multihashmap_get (peers, &pid->hashPubKey); | 251 | pos = GNUNET_CONTAINER_multipeermap_get (peers, pid); |
252 | if ((pos != NULL) && (pos->is_friend == GNUNET_YES)) | 252 | if ((pos != NULL) && (pos->is_friend == GNUNET_YES)) |
253 | return GNUNET_OK; | 253 | return GNUNET_OK; |
254 | GNUNET_STATISTICS_update (stats, gettext_noop ("# peers blacklisted"), 1, | 254 | GNUNET_STATISTICS_update (stats, gettext_noop ("# peers blacklisted"), 1, |
@@ -311,13 +311,13 @@ is_connection_allowed (struct Peer *peer) | |||
311 | * @return GNUNET_YES (always: continue to iterate) | 311 | * @return GNUNET_YES (always: continue to iterate) |
312 | */ | 312 | */ |
313 | static int | 313 | static int |
314 | free_peer (void *cls, const struct GNUNET_HashCode * pid, void *value) | 314 | free_peer (void *cls, const struct GNUNET_PeerIdentity * pid, void *value) |
315 | { | 315 | { |
316 | struct Peer *pos = value; | 316 | struct Peer *pos = value; |
317 | 317 | ||
318 | GNUNET_break (GNUNET_NO == pos->is_connected); | 318 | GNUNET_break (GNUNET_NO == pos->is_connected); |
319 | GNUNET_break (GNUNET_OK == | 319 | GNUNET_break (GNUNET_OK == |
320 | GNUNET_CONTAINER_multihashmap_remove (peers, pid, pos)); | 320 | GNUNET_CONTAINER_multipeermap_remove (peers, pid, pos)); |
321 | if (pos->hello_req != NULL) | 321 | if (pos->hello_req != NULL) |
322 | GNUNET_CORE_notify_transmit_ready_cancel (pos->hello_req); | 322 | GNUNET_CORE_notify_transmit_ready_cancel (pos->hello_req); |
323 | if (pos->hello_delay_task != GNUNET_SCHEDULER_NO_TASK) | 323 | if (pos->hello_delay_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -462,7 +462,7 @@ remove_from_greylist (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
462 | if ((GNUNET_NO == pos->is_friend) && (GNUNET_NO == pos->is_connected) && | 462 | if ((GNUNET_NO == pos->is_friend) && (GNUNET_NO == pos->is_connected) && |
463 | (NULL == pos->hello)) | 463 | (NULL == pos->hello)) |
464 | { | 464 | { |
465 | free_peer (NULL, &pos->pid.hashPubKey, pos); | 465 | free_peer (NULL, &pos->pid, pos); |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | } | 468 | } |
@@ -491,7 +491,7 @@ make_peer (const struct GNUNET_PeerIdentity *peer, | |||
491 | memcpy (ret->hello, hello, GNUNET_HELLO_size (hello)); | 491 | memcpy (ret->hello, hello, GNUNET_HELLO_size (hello)); |
492 | } | 492 | } |
493 | GNUNET_break (GNUNET_OK == | 493 | GNUNET_break (GNUNET_OK == |
494 | GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey, | 494 | GNUNET_CONTAINER_multipeermap_put (peers, peer, |
495 | ret, | 495 | ret, |
496 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 496 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
497 | return ret; | 497 | return ret; |
@@ -506,6 +506,8 @@ make_peer (const struct GNUNET_PeerIdentity *peer, | |||
506 | static void | 506 | static void |
507 | setup_filter (struct Peer *peer) | 507 | setup_filter (struct Peer *peer) |
508 | { | 508 | { |
509 | struct GNUNET_HashCode hc; | ||
510 | |||
509 | /* 2^{-5} chance of not sending a HELLO to a peer is | 511 | /* 2^{-5} chance of not sending a HELLO to a peer is |
510 | * acceptably small (if the filter is 50% full); | 512 | * acceptably small (if the filter is 50% full); |
511 | * 64 bytes of memory are small compared to the rest | 513 | * 64 bytes of memory are small compared to the rest |
@@ -518,7 +520,8 @@ setup_filter (struct Peer *peer) | |||
518 | GNUNET_TIME_relative_to_absolute | 520 | GNUNET_TIME_relative_to_absolute |
519 | (HELLO_ADVERTISEMENT_MIN_REPEAT_FREQUENCY); | 521 | (HELLO_ADVERTISEMENT_MIN_REPEAT_FREQUENCY); |
520 | /* never send a peer its own HELLO */ | 522 | /* never send a peer its own HELLO */ |
521 | GNUNET_CONTAINER_bloomfilter_add (peer->filter, &peer->pid.hashPubKey); | 523 | GNUNET_CRYPTO_hash (&peer->pid, sizeof (struct GNUNET_PeerIdentity), &hc); |
524 | GNUNET_CONTAINER_bloomfilter_add (peer->filter, &hc); | ||
522 | } | 525 | } |
523 | 526 | ||
524 | 527 | ||
@@ -526,9 +529,9 @@ setup_filter (struct Peer *peer) | |||
526 | * Function to fill send buffer with HELLO. | 529 | * Function to fill send buffer with HELLO. |
527 | * | 530 | * |
528 | * @param cls 'struct Peer' of the target peer | 531 | * @param cls 'struct Peer' of the target peer |
529 | * @param size number of bytes available in buf | 532 | * @param size number of bytes available in @a buf |
530 | * @param buf where the callee should write the message | 533 | * @param buf where the callee should write the message |
531 | * @return number of bytes written to buf | 534 | * @return number of bytes written to @a buf |
532 | */ | 535 | */ |
533 | static size_t | 536 | static size_t |
534 | hello_advertising_ready (void *cls, size_t size, void *buf); | 537 | hello_advertising_ready (void *cls, size_t size, void *buf); |
@@ -568,11 +571,12 @@ struct FindAdvHelloContext | |||
568 | * @return GNUNET_YES (continue iteration) | 571 | * @return GNUNET_YES (continue iteration) |
569 | */ | 572 | */ |
570 | static int | 573 | static int |
571 | find_advertisable_hello (void *cls, const struct GNUNET_HashCode * pid, void *value) | 574 | find_advertisable_hello (void *cls, const struct GNUNET_PeerIdentity * pid, void *value) |
572 | { | 575 | { |
573 | struct FindAdvHelloContext *fah = cls; | 576 | struct FindAdvHelloContext *fah = cls; |
574 | struct Peer *pos = value; | 577 | struct Peer *pos = value; |
575 | struct GNUNET_TIME_Relative rst_time; | 578 | struct GNUNET_TIME_Relative rst_time; |
579 | struct GNUNET_HashCode hc; | ||
576 | size_t hs; | 580 | size_t hs; |
577 | 581 | ||
578 | if (pos == fah->peer) | 582 | if (pos == fah->peer) |
@@ -590,9 +594,10 @@ find_advertisable_hello (void *cls, const struct GNUNET_HashCode * pid, void *va | |||
590 | hs = GNUNET_HELLO_size (pos->hello); | 594 | hs = GNUNET_HELLO_size (pos->hello); |
591 | if (hs > fah->max_size) | 595 | if (hs > fah->max_size) |
592 | return GNUNET_YES; | 596 | return GNUNET_YES; |
597 | GNUNET_CRYPTO_hash (&fah->peer->pid, sizeof (struct GNUNET_PeerIdentity), &hc); | ||
593 | if (GNUNET_NO == | 598 | if (GNUNET_NO == |
594 | GNUNET_CONTAINER_bloomfilter_test (pos->filter, | 599 | GNUNET_CONTAINER_bloomfilter_test (pos->filter, |
595 | &fah->peer->pid.hashPubKey)) | 600 | &hc)) |
596 | fah->result = pos; | 601 | fah->result = pos; |
597 | return GNUNET_YES; | 602 | return GNUNET_YES; |
598 | } | 603 | } |
@@ -624,7 +629,7 @@ schedule_next_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
624 | fah.result = NULL; | 629 | fah.result = NULL; |
625 | fah.max_size = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1; | 630 | fah.max_size = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1; |
626 | fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; | 631 | fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; |
627 | GNUNET_CONTAINER_multihashmap_iterate (peers, &find_advertisable_hello, &fah); | 632 | GNUNET_CONTAINER_multipeermap_iterate (peers, &find_advertisable_hello, &fah); |
628 | pl->hello_delay_task = | 633 | pl->hello_delay_task = |
629 | GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl); | 634 | GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl); |
630 | if (fah.result == NULL) | 635 | if (fah.result == NULL) |
@@ -654,7 +659,7 @@ schedule_next_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
654 | * @return GNUNET_YES (always) | 659 | * @return GNUNET_YES (always) |
655 | */ | 660 | */ |
656 | static int | 661 | static int |
657 | reschedule_hellos (void *cls, const struct GNUNET_HashCode * pid, void *value) | 662 | reschedule_hellos (void *cls, const struct GNUNET_PeerIdentity * pid, void *value) |
658 | { | 663 | { |
659 | struct Peer *peer = value; | 664 | struct Peer *peer = value; |
660 | struct Peer *skip = cls; | 665 | struct Peer *skip = cls; |
@@ -699,7 +704,7 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
699 | connection_count++; | 704 | connection_count++; |
700 | GNUNET_STATISTICS_set (stats, gettext_noop ("# peers connected"), | 705 | GNUNET_STATISTICS_set (stats, gettext_noop ("# peers connected"), |
701 | connection_count, GNUNET_NO); | 706 | connection_count, GNUNET_NO); |
702 | pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 707 | pos = GNUNET_CONTAINER_multipeermap_get (peers, peer); |
703 | if (NULL == pos) | 708 | if (NULL == pos) |
704 | { | 709 | { |
705 | pos = make_peer (peer, NULL, GNUNET_NO); | 710 | pos = make_peer (peer, NULL, GNUNET_NO); |
@@ -721,7 +726,7 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
721 | GNUNET_STATISTICS_set (stats, gettext_noop ("# friends connected"), | 726 | GNUNET_STATISTICS_set (stats, gettext_noop ("# friends connected"), |
722 | friend_count, GNUNET_NO); | 727 | friend_count, GNUNET_NO); |
723 | } | 728 | } |
724 | reschedule_hellos (NULL, &peer->hashPubKey, pos); | 729 | reschedule_hellos (NULL, peer, pos); |
725 | } | 730 | } |
726 | 731 | ||
727 | 732 | ||
@@ -734,7 +739,7 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
734 | * @return GNUNET_YES (continue to iterate) | 739 | * @return GNUNET_YES (continue to iterate) |
735 | */ | 740 | */ |
736 | static int | 741 | static int |
737 | try_add_peers (void *cls, const struct GNUNET_HashCode * pid, void *value) | 742 | try_add_peers (void *cls, const struct GNUNET_PeerIdentity * pid, void *value) |
738 | { | 743 | { |
739 | struct Peer *pos = value; | 744 | struct Peer *pos = value; |
740 | 745 | ||
@@ -755,7 +760,7 @@ add_peer_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
755 | { | 760 | { |
756 | add_task = GNUNET_SCHEDULER_NO_TASK; | 761 | add_task = GNUNET_SCHEDULER_NO_TASK; |
757 | 762 | ||
758 | GNUNET_CONTAINER_multihashmap_iterate (peers, &try_add_peers, NULL); | 763 | GNUNET_CONTAINER_multipeermap_iterate (peers, &try_add_peers, NULL); |
759 | } | 764 | } |
760 | 765 | ||
761 | 766 | ||
@@ -775,7 +780,7 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
775 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 780 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
776 | "Core told us that we disconnected from `%s'\n", | 781 | "Core told us that we disconnected from `%s'\n", |
777 | GNUNET_i2s (peer)); | 782 | GNUNET_i2s (peer)); |
778 | pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 783 | pos = GNUNET_CONTAINER_multipeermap_get (peers, peer); |
779 | if (NULL == pos) | 784 | if (NULL == pos) |
780 | { | 785 | { |
781 | GNUNET_break (0); | 786 | GNUNET_break (0); |
@@ -862,7 +867,7 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
862 | &have_address); | 867 | &have_address); |
863 | if (GNUNET_NO == have_address) | 868 | if (GNUNET_NO == have_address) |
864 | return; /* no point in advertising this one... */ | 869 | return; /* no point in advertising this one... */ |
865 | peer = GNUNET_CONTAINER_multihashmap_get (peers, &pid.hashPubKey); | 870 | peer = GNUNET_CONTAINER_multipeermap_get (peers, &pid); |
866 | if (NULL == peer) | 871 | if (NULL == peer) |
867 | { | 872 | { |
868 | peer = make_peer (&pid, hello, GNUNET_NO); | 873 | peer = make_peer (&pid, hello, GNUNET_NO); |
@@ -893,7 +898,7 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
893 | setup_filter (peer); | 898 | setup_filter (peer); |
894 | /* since we have a new HELLO to pick from, re-schedule all | 899 | /* since we have a new HELLO to pick from, re-schedule all |
895 | * HELLO requests that are not bound by the HELLO send rate! */ | 900 | * HELLO requests that are not bound by the HELLO send rate! */ |
896 | GNUNET_CONTAINER_multihashmap_iterate (peers, &reschedule_hellos, peer); | 901 | GNUNET_CONTAINER_multipeermap_iterate (peers, &reschedule_hellos, peer); |
897 | } | 902 | } |
898 | 903 | ||
899 | 904 | ||
@@ -927,7 +932,7 @@ process_peer (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
927 | if (hello == NULL) | 932 | if (hello == NULL) |
928 | { | 933 | { |
929 | /* free existing HELLO, if any */ | 934 | /* free existing HELLO, if any */ |
930 | pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 935 | pos = GNUNET_CONTAINER_multipeermap_get (peers, peer); |
931 | if (NULL != pos) | 936 | if (NULL != pos) |
932 | { | 937 | { |
933 | GNUNET_free_non_null (pos->hello); | 938 | GNUNET_free_non_null (pos->hello); |
@@ -941,12 +946,12 @@ process_peer (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
941 | (0 == | 946 | (0 == |
942 | GNUNET_TIME_absolute_get_remaining (pos-> | 947 | GNUNET_TIME_absolute_get_remaining (pos-> |
943 | greylisted_until).rel_value_us)) | 948 | greylisted_until).rel_value_us)) |
944 | free_peer (NULL, &pos->pid.hashPubKey, pos); | 949 | free_peer (NULL, &pos->pid, pos); |
945 | } | 950 | } |
946 | return; | 951 | return; |
947 | } | 952 | } |
948 | consider_for_advertising (hello); | 953 | consider_for_advertising (hello); |
949 | pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 954 | pos = GNUNET_CONTAINER_multipeermap_get (peers, peer); |
950 | if (pos == NULL) | 955 | if (pos == NULL) |
951 | pos = make_peer (peer, hello, GNUNET_NO); | 956 | pos = make_peer (peer, hello, GNUNET_NO); |
952 | GNUNET_assert (NULL != pos); | 957 | GNUNET_assert (NULL != pos); |
@@ -1005,9 +1010,9 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1005 | char *fn; | 1010 | char *fn; |
1006 | char *data; | 1011 | char *data; |
1007 | size_t pos; | 1012 | size_t pos; |
1013 | size_t start; | ||
1008 | struct GNUNET_PeerIdentity pid; | 1014 | struct GNUNET_PeerIdentity pid; |
1009 | uint64_t fsize; | 1015 | uint64_t fsize; |
1010 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; | ||
1011 | unsigned int entries_found; | 1016 | unsigned int entries_found; |
1012 | struct Peer *fl; | 1017 | struct Peer *fl; |
1013 | 1018 | ||
@@ -1032,15 +1037,16 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1032 | GNUNET_free (fn); | 1037 | GNUNET_free (fn); |
1033 | return; | 1038 | return; |
1034 | } | 1039 | } |
1035 | if (fsize == 0) | 1040 | if (0 == fsize) |
1036 | { | 1041 | { |
1037 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Friends file `%s' is empty.\n"), | 1042 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1043 | _("Friends file `%s' is empty.\n"), | ||
1038 | fn); | 1044 | fn); |
1039 | GNUNET_free (fn); | 1045 | GNUNET_free (fn); |
1040 | return; | 1046 | return; |
1041 | } | 1047 | } |
1042 | data = GNUNET_malloc_large (fsize); | 1048 | data = GNUNET_malloc_large (fsize); |
1043 | if (data == NULL) | 1049 | if (NULL == data) |
1044 | { | 1050 | { |
1045 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1051 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1046 | _("Failed to read friends list from `%s': out of memory\n"), | 1052 | _("Failed to read friends list from `%s': out of memory\n"), |
@@ -1057,56 +1063,40 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1057 | return; | 1063 | return; |
1058 | } | 1064 | } |
1059 | entries_found = 0; | 1065 | entries_found = 0; |
1066 | start = 0; | ||
1060 | pos = 0; | 1067 | pos = 0; |
1061 | while ((pos < fsize) && isspace ((unsigned char) data[pos])) | 1068 | while (pos < fsize) |
1062 | pos++; | ||
1063 | while ((fsize >= sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) && | ||
1064 | (pos <= | ||
1065 | fsize - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) | ||
1066 | { | 1069 | { |
1067 | memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); | 1070 | while ((pos < fsize) && isspace ((unsigned char) data[pos])) |
1068 | if (!isspace | 1071 | pos++; |
1069 | ((unsigned char) | 1072 | if (GNUNET_OK != |
1070 | enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) | 1073 | GNUNET_CRYPTO_ecc_public_sign_key_from_string (&data[start], |
1074 | pos - start, | ||
1075 | &pid.public_key)) | ||
1071 | { | 1076 | { |
1072 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1077 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1073 | _ | 1078 | _("Syntax error in topology specification at offset %llu, skipping bytes `%.*s'.\n"), |
1074 | ("Syntax error in topology specification at offset %llu, skipping bytes.\n"), | 1079 | (unsigned long long) pos, |
1075 | (unsigned long long) pos); | 1080 | (int) (pos - start), |
1081 | &data[start]); | ||
1076 | pos++; | 1082 | pos++; |
1077 | while ((pos < fsize) && (!isspace ((unsigned char) data[pos]))) | 1083 | start = pos; |
1078 | pos++; | ||
1079 | continue; | 1084 | continue; |
1080 | } | 1085 | } |
1081 | enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; | 1086 | pos++; |
1082 | if (GNUNET_OK != | 1087 | start = pos; |
1083 | GNUNET_CRYPTO_hash_from_string ((char *) &enc, &pid.hashPubKey)) | 1088 | if (0 == memcmp (&pid, &my_identity, sizeof (struct GNUNET_PeerIdentity))) |
1084 | { | 1089 | { |
1085 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1090 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1086 | _ | 1091 | _("Found myself `%s' in friend list (useless, ignored)\n"), |
1087 | ("Syntax error in topology specification at offset %llu, skipping bytes `%s'.\n"), | 1092 | GNUNET_i2s (&pid)); |
1088 | (unsigned long long) pos, &enc); | 1093 | continue; |
1089 | } | ||
1090 | else | ||
1091 | { | ||
1092 | if (0 != memcmp (&pid, &my_identity, sizeof (struct GNUNET_PeerIdentity))) | ||
1093 | { | ||
1094 | entries_found++; | ||
1095 | fl = make_peer (&pid, NULL, GNUNET_YES); | ||
1096 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1097 | _("Found friend `%s' in configuration\n"), | ||
1098 | GNUNET_i2s (&fl->pid)); | ||
1099 | } | ||
1100 | else | ||
1101 | { | ||
1102 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1103 | _("Found myself `%s' in friend list (useless, ignored)\n"), | ||
1104 | GNUNET_i2s (&pid)); | ||
1105 | } | ||
1106 | } | 1094 | } |
1107 | pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded); | 1095 | entries_found++; |
1108 | while ((pos < fsize) && isspace ((unsigned char) data[pos])) | 1096 | fl = make_peer (&pid, NULL, GNUNET_YES); |
1109 | pos++; | 1097 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1098 | _("Found friend `%s' in configuration\n"), | ||
1099 | GNUNET_i2s (&fl->pid)); | ||
1110 | } | 1100 | } |
1111 | GNUNET_free (data); | 1101 | GNUNET_free (data); |
1112 | GNUNET_free (fn); | 1102 | GNUNET_free (fn); |
@@ -1156,7 +1146,7 @@ handle_encrypted_hello (void *cls, const struct GNUNET_PeerIdentity *other, | |||
1156 | } | 1146 | } |
1157 | GNUNET_STATISTICS_update (stats, gettext_noop ("# HELLO messages received"), | 1147 | GNUNET_STATISTICS_update (stats, gettext_noop ("# HELLO messages received"), |
1158 | 1, GNUNET_NO); | 1148 | 1, GNUNET_NO); |
1159 | peer = GNUNET_CONTAINER_multihashmap_get (peers, &pid.hashPubKey); | 1149 | peer = GNUNET_CONTAINER_multipeermap_get (peers, &pid); |
1160 | if (NULL == peer) | 1150 | if (NULL == peer) |
1161 | { | 1151 | { |
1162 | if ((GNUNET_YES == friends_only) || (friend_count < minimum_friend_count)) | 1152 | if ((GNUNET_YES == friends_only) || (friend_count < minimum_friend_count)) |
@@ -1190,6 +1180,7 @@ hello_advertising_ready (void *cls, size_t size, void *buf) | |||
1190 | struct Peer *pl = cls; | 1180 | struct Peer *pl = cls; |
1191 | struct FindAdvHelloContext fah; | 1181 | struct FindAdvHelloContext fah; |
1192 | size_t want; | 1182 | size_t want; |
1183 | struct GNUNET_HashCode hc; | ||
1193 | 1184 | ||
1194 | pl->hello_req = NULL; | 1185 | pl->hello_req = NULL; |
1195 | GNUNET_assert (GNUNET_YES == pl->is_connected); | 1186 | GNUNET_assert (GNUNET_YES == pl->is_connected); |
@@ -1198,14 +1189,15 @@ hello_advertising_ready (void *cls, size_t size, void *buf) | |||
1198 | fah.result = NULL; | 1189 | fah.result = NULL; |
1199 | fah.max_size = size; | 1190 | fah.max_size = size; |
1200 | fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; | 1191 | fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; |
1201 | GNUNET_CONTAINER_multihashmap_iterate (peers, &find_advertisable_hello, &fah); | 1192 | GNUNET_CONTAINER_multipeermap_iterate (peers, &find_advertisable_hello, &fah); |
1202 | want = 0; | 1193 | want = 0; |
1203 | if (fah.result != NULL) | 1194 | if (fah.result != NULL) |
1204 | { | 1195 | { |
1205 | want = GNUNET_HELLO_size (fah.result->hello); | 1196 | want = GNUNET_HELLO_size (fah.result->hello); |
1206 | GNUNET_assert (want <= size); | 1197 | GNUNET_assert (want <= size); |
1207 | memcpy (buf, fah.result->hello, want); | 1198 | memcpy (buf, fah.result->hello, want); |
1208 | GNUNET_CONTAINER_bloomfilter_add (fah.result->filter, &pl->pid.hashPubKey); | 1199 | GNUNET_CRYPTO_hash (&pl->pid, sizeof (struct GNUNET_PeerIdentity), &hc); |
1200 | GNUNET_CONTAINER_bloomfilter_add (fah.result->filter, &hc); | ||
1209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' with %u bytes", "HELLO", | 1201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' with %u bytes", "HELLO", |
1210 | (unsigned int) want); | 1202 | (unsigned int) want); |
1211 | GNUNET_STATISTICS_update (stats, | 1203 | GNUNET_STATISTICS_update (stats, |
@@ -1250,8 +1242,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1250 | GNUNET_SCHEDULER_cancel (add_task); | 1242 | GNUNET_SCHEDULER_cancel (add_task); |
1251 | add_task = GNUNET_SCHEDULER_NO_TASK; | 1243 | add_task = GNUNET_SCHEDULER_NO_TASK; |
1252 | } | 1244 | } |
1253 | GNUNET_CONTAINER_multihashmap_iterate (peers, &free_peer, NULL); | 1245 | GNUNET_CONTAINER_multipeermap_iterate (peers, &free_peer, NULL); |
1254 | GNUNET_CONTAINER_multihashmap_destroy (peers); | 1246 | GNUNET_CONTAINER_multipeermap_destroy (peers); |
1255 | peers = NULL; | 1247 | peers = NULL; |
1256 | if (stats != NULL) | 1248 | if (stats != NULL) |
1257 | { | 1249 | { |
@@ -1293,7 +1285,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1293 | "TARGET-CONNECTION-COUNT", &opt)) | 1285 | "TARGET-CONNECTION-COUNT", &opt)) |
1294 | opt = 16; | 1286 | opt = 16; |
1295 | target_connection_count = (unsigned int) opt; | 1287 | target_connection_count = (unsigned int) opt; |
1296 | peers = GNUNET_CONTAINER_multihashmap_create (target_connection_count * 2, GNUNET_NO); | 1288 | peers = GNUNET_CONTAINER_multipeermap_create (target_connection_count * 2, GNUNET_NO); |
1297 | 1289 | ||
1298 | if ((friends_only == GNUNET_YES) || (minimum_friend_count > 0)) | 1290 | if ((friends_only == GNUNET_YES) || (minimum_friend_count > 0)) |
1299 | read_friends_file (cfg); | 1291 | read_friends_file (cfg); |