diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-04 12:02:43 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-04 12:02:43 +0000 |
commit | 425e9cdea733ca7be9a901abff7a070c460fa84d (patch) | |
tree | c4e2919e2f4183a324801c061fb2d57a3b232ddc /src | |
parent | 6713f0ce7d70cdb5cb0172157e647b8dfb6852ff (diff) | |
download | gnunet-425e9cdea733ca7be9a901abff7a070c460fa84d.tar.gz gnunet-425e9cdea733ca7be9a901abff7a070c460fa84d.zip |
peerinfo API change + changes in code using api
Diffstat (limited to 'src')
-rw-r--r-- | src/dht/gnunet-service-dht_hello.c | 2 | ||||
-rw-r--r-- | src/hostlist/hostlist-server.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_peerinfo_service.h | 30 | ||||
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 27 | ||||
-rw-r--r-- | src/peerinfo/gnunet-service-peerinfo.c | 18 | ||||
-rw-r--r-- | src/peerinfo/peerinfo.h | 48 | ||||
-rw-r--r-- | src/peerinfo/peerinfo_api.c | 16 | ||||
-rw-r--r-- | src/peerinfo/peerinfo_api_notify.c | 25 | ||||
-rw-r--r-- | src/peerinfo/test_peerinfo_api.c | 4 | ||||
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 4 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 2 |
11 files changed, 132 insertions, 46 deletions
diff --git a/src/dht/gnunet-service-dht_hello.c b/src/dht/gnunet-service-dht_hello.c index 19da79e23..32a99203f 100644 --- a/src/dht/gnunet-service-dht_hello.c +++ b/src/dht/gnunet-service-dht_hello.c | |||
@@ -98,7 +98,7 @@ process_hello (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
98 | void | 98 | void |
99 | GDS_HELLO_init () | 99 | GDS_HELLO_init () |
100 | { | 100 | { |
101 | pnc = GNUNET_PEERINFO_notify (GDS_cfg, &process_hello, NULL); | 101 | pnc = GNUNET_PEERINFO_notify (GDS_cfg, GNUNET_NO, &process_hello, NULL); |
102 | peer_to_hello = GNUNET_CONTAINER_multihashmap_create (256, GNUNET_NO); | 102 | peer_to_hello = GNUNET_CONTAINER_multihashmap_create (256, GNUNET_NO); |
103 | } | 103 | } |
104 | 104 | ||
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index 2e94083f5..081d3dac6 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c | |||
@@ -673,7 +673,7 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
673 | if (daemon_handle_v6 != NULL) | 673 | if (daemon_handle_v6 != NULL) |
674 | hostlist_task_v6 = prepare_daemon (daemon_handle_v6); | 674 | hostlist_task_v6 = prepare_daemon (daemon_handle_v6); |
675 | 675 | ||
676 | notify = GNUNET_PEERINFO_notify (cfg, &process_notify, NULL); | 676 | notify = GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_notify, NULL); |
677 | 677 | ||
678 | return GNUNET_OK; | 678 | return GNUNET_OK; |
679 | } | 679 | } |
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h index 49ba91600..6aadba964 100644 --- a/src/include/gnunet_peerinfo_service.h +++ b/src/include/gnunet_peerinfo_service.h | |||
@@ -145,28 +145,28 @@ struct GNUNET_PEERINFO_IteratorContext; | |||
145 | 145 | ||
146 | 146 | ||
147 | /** | 147 | /** |
148 | * Call a method for each known matching host to get its HELLO. | 148 | * Call a method for each known matching host. The callback method |
149 | * The callback method will be invoked once for each matching | 149 | * will be invoked once for each matching host and then finally once |
150 | * host and then finally once with a NULL pointer. After that final | 150 | * with a NULL pointer. After that final invocation, the iterator |
151 | * invocation, the iterator context must no longer be used. | 151 | * context must no longer be used. |
152 | * | 152 | * |
153 | * Instead of calling this function with 'peer == NULL' | 153 | * Instead of calling this function with 'peer == NULL' it is often |
154 | * it is often better to use 'GNUNET_PEERINFO_notify'. | 154 | * better to use 'GNUNET_PEERINFO_notify'. |
155 | * | 155 | * |
156 | * @param h handle to the peerinfo service | 156 | * @param h handle to the peerinfo service |
157 | * @param include_friend_only include HELLO messages for friends only | ||
157 | * @param peer restrict iteration to this peer only (can be NULL) | 158 | * @param peer restrict iteration to this peer only (can be NULL) |
158 | * @param timeout how long to wait until timing out | 159 | * @param timeout how long to wait until timing out |
159 | * @param callback the method to call for each peer | 160 | * @param callback the method to call for each peer |
160 | * @param callback_cls closure for callback | 161 | * @param callback_cls closure for callback |
161 | * @return NULL on error (in this case, 'callback' is never called!), | 162 | * @return iterator context |
162 | * otherwise an iterator context | ||
163 | */ | 163 | */ |
164 | struct GNUNET_PEERINFO_IteratorContext * | 164 | struct GNUNET_PEERINFO_IteratorContext * |
165 | GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | 165 | GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, |
166 | int include_friend_only, | ||
166 | const struct GNUNET_PeerIdentity *peer, | 167 | const struct GNUNET_PeerIdentity *peer, |
167 | struct GNUNET_TIME_Relative timeout, | 168 | struct GNUNET_TIME_Relative timeout, |
168 | GNUNET_PEERINFO_Processor callback, | 169 | GNUNET_PEERINFO_Processor callback, void *callback_cls); |
169 | void *callback_cls); | ||
170 | 170 | ||
171 | 171 | ||
172 | 172 | ||
@@ -189,17 +189,21 @@ struct GNUNET_PEERINFO_NotifyContext; | |||
189 | /** | 189 | /** |
190 | * Call a method whenever our known information about peers | 190 | * Call a method whenever our known information about peers |
191 | * changes. Initially calls the given function for all known | 191 | * changes. Initially calls the given function for all known |
192 | * peers and then only signals changes. Note that it is | 192 | * peers and then only signals changes. |
193 | * possible (i.e. on disconnects) that the callback is called | 193 | * |
194 | * twice with the same peer information. | 194 | * If include_friend_only is set to GNUNET_YES peerinfo will include HELLO |
195 | * messages which are intended for friend to friend mode and which do not | ||
196 | * have to be gossiped. Otherwise these messages are skipped. | ||
195 | * | 197 | * |
196 | * @param cfg configuration to use | 198 | * @param cfg configuration to use |
199 | * @param include_friend_only include HELLO messages for friends only | ||
197 | * @param callback the method to call for each peer | 200 | * @param callback the method to call for each peer |
198 | * @param callback_cls closure for callback | 201 | * @param callback_cls closure for callback |
199 | * @return NULL on error | 202 | * @return NULL on error |
200 | */ | 203 | */ |
201 | struct GNUNET_PEERINFO_NotifyContext * | 204 | struct GNUNET_PEERINFO_NotifyContext * |
202 | GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, | 205 | GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, |
206 | int include_friend_only, | ||
203 | GNUNET_PEERINFO_Processor callback, void *callback_cls); | 207 | GNUNET_PEERINFO_Processor callback, void *callback_cls); |
204 | 208 | ||
205 | 209 | ||
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 0cb434d89..39d6060c3 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -106,6 +106,11 @@ struct PrintContext | |||
106 | */ | 106 | */ |
107 | unsigned int off; | 107 | unsigned int off; |
108 | 108 | ||
109 | /** | ||
110 | * Hello was friend only, GNUNET_YES or GNUNET_NO | ||
111 | */ | ||
112 | int friend_only; | ||
113 | |||
109 | }; | 114 | }; |
110 | 115 | ||
111 | 116 | ||
@@ -120,6 +125,11 @@ static int no_resolve; | |||
120 | static int be_quiet; | 125 | static int be_quiet; |
121 | 126 | ||
122 | /** | 127 | /** |
128 | * Option '-f' | ||
129 | */ | ||
130 | static int include_friend_only; | ||
131 | |||
132 | /** | ||
123 | * Option '-s' | 133 | * Option '-s' |
124 | */ | 134 | */ |
125 | static int get_self; | 135 | static int get_self; |
@@ -211,7 +221,8 @@ dump_pc (struct PrintContext *pc) | |||
211 | unsigned int i; | 221 | unsigned int i; |
212 | 222 | ||
213 | GNUNET_CRYPTO_hash_to_enc (&pc->peer.hashPubKey, &enc); | 223 | GNUNET_CRYPTO_hash_to_enc (&pc->peer.hashPubKey, &enc); |
214 | printf (_("Peer `%s'\n"), | 224 | printf (_("%sPeer `%s'\n"), |
225 | (GNUNET_YES == pc->friend_only) ? "F2F: " : "", | ||
215 | (const char *) &enc); | 226 | (const char *) &enc); |
216 | for (i = 0; i < pc->num_addresses; i++) | 227 | for (i = 0; i < pc->num_addresses; i++) |
217 | { | 228 | { |
@@ -321,6 +332,7 @@ print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
321 | { | 332 | { |
322 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; | 333 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; |
323 | struct PrintContext *pc; | 334 | struct PrintContext *pc; |
335 | int friend_only; | ||
324 | 336 | ||
325 | if (NULL == peer) | 337 | if (NULL == peer) |
326 | { | 338 | { |
@@ -335,10 +347,13 @@ print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
335 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 347 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
336 | return; | 348 | return; |
337 | } | 349 | } |
350 | friend_only = GNUNET_HELLO_is_friend_only (hello); | ||
338 | if ((GNUNET_YES == be_quiet) || (NULL == hello)) | 351 | if ((GNUNET_YES == be_quiet) || (NULL == hello)) |
339 | { | 352 | { |
340 | GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &enc); | 353 | GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &enc); |
341 | printf ("%s\n", (const char *) &enc); | 354 | printf ("%s%s\n", |
355 | (GNUNET_YES == friend_only) ? "F2F: " : "", | ||
356 | (const char *) &enc); | ||
342 | return; | 357 | return; |
343 | } | 358 | } |
344 | pc = GNUNET_malloc (sizeof (struct PrintContext)); | 359 | pc = GNUNET_malloc (sizeof (struct PrintContext)); |
@@ -346,6 +361,7 @@ print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
346 | pc_tail, | 361 | pc_tail, |
347 | pc); | 362 | pc); |
348 | pc->peer = *peer; | 363 | pc->peer = *peer; |
364 | pc->friend_only = friend_only; | ||
349 | GNUNET_HELLO_iterate_addresses (hello, | 365 | GNUNET_HELLO_iterate_addresses (hello, |
350 | GNUNET_NO, | 366 | GNUNET_NO, |
351 | &count_address, | 367 | &count_address, |
@@ -608,7 +624,7 @@ state_machine (void *cls, | |||
608 | { | 624 | { |
609 | get_info = GNUNET_NO; | 625 | get_info = GNUNET_NO; |
610 | GPI_plugins_load (cfg); | 626 | GPI_plugins_load (cfg); |
611 | pic = GNUNET_PEERINFO_iterate (peerinfo, NULL, | 627 | pic = GNUNET_PEERINFO_iterate (peerinfo, include_friend_only, NULL, |
612 | TIMEOUT, | 628 | TIMEOUT, |
613 | &print_peer_info, NULL); | 629 | &print_peer_info, NULL); |
614 | return; | 630 | return; |
@@ -627,7 +643,7 @@ state_machine (void *cls, | |||
627 | if (GNUNET_YES == get_uri) | 643 | if (GNUNET_YES == get_uri) |
628 | { | 644 | { |
629 | GPI_plugins_load (cfg); | 645 | GPI_plugins_load (cfg); |
630 | pic = GNUNET_PEERINFO_iterate (peerinfo, &my_peer_identity, | 646 | pic = GNUNET_PEERINFO_iterate (peerinfo,include_friend_only, &my_peer_identity, |
631 | TIMEOUT, &print_my_uri, NULL); | 647 | TIMEOUT, &print_my_uri, NULL); |
632 | get_uri = GNUNET_NO; | 648 | get_uri = GNUNET_NO; |
633 | return; | 649 | return; |
@@ -653,6 +669,9 @@ main (int argc, char *const *argv) | |||
653 | {'q', "quiet", NULL, | 669 | {'q', "quiet", NULL, |
654 | gettext_noop ("output only the identity strings"), | 670 | gettext_noop ("output only the identity strings"), |
655 | 0, &GNUNET_GETOPT_set_one, &be_quiet}, | 671 | 0, &GNUNET_GETOPT_set_one, &be_quiet}, |
672 | {'f', "friends", NULL, | ||
673 | gettext_noop ("include friend-only information"), | ||
674 | 0, &GNUNET_GETOPT_set_one, &include_friend_only}, | ||
656 | {'s', "self", NULL, | 675 | {'s', "self", NULL, |
657 | gettext_noop ("output our own identity only"), | 676 | gettext_noop ("output our own identity only"), |
658 | 0, &GNUNET_GETOPT_set_one, &get_self}, | 677 | 0, &GNUNET_GETOPT_set_one, &get_self}, |
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 68024a90a..55d4177cf 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -90,6 +90,7 @@ static char *networkIdDirectory; | |||
90 | static struct GNUNET_STATISTICS_Handle *stats; | 90 | static struct GNUNET_STATISTICS_Handle *stats; |
91 | 91 | ||
92 | 92 | ||
93 | |||
93 | /** | 94 | /** |
94 | * Notify all clients in the notify list about the | 95 | * Notify all clients in the notify list about the |
95 | * given host entry changing. | 96 | * given host entry changing. |
@@ -638,9 +639,10 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
638 | { | 639 | { |
639 | const struct ListPeerMessage *lpm; | 640 | const struct ListPeerMessage *lpm; |
640 | struct GNUNET_SERVER_TransmitContext *tc; | 641 | struct GNUNET_SERVER_TransmitContext *tc; |
642 | int friend_only; | ||
641 | 643 | ||
642 | lpm = (const struct ListPeerMessage *) message; | 644 | lpm = (const struct ListPeerMessage *) message; |
643 | GNUNET_break (0 == ntohl (lpm->reserved)); | 645 | friend_only = ntohl (lpm->include_friend_only); |
644 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer `%4s'\n", | 646 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer `%4s'\n", |
645 | "GET", GNUNET_i2s (&lpm->peer)); | 647 | "GET", GNUNET_i2s (&lpm->peer)); |
646 | tc = GNUNET_SERVER_transmit_context_create (client); | 648 | tc = GNUNET_SERVER_transmit_context_create (client); |
@@ -663,8 +665,12 @@ static void | |||
663 | handle_get_all (void *cls, struct GNUNET_SERVER_Client *client, | 665 | handle_get_all (void *cls, struct GNUNET_SERVER_Client *client, |
664 | const struct GNUNET_MessageHeader *message) | 666 | const struct GNUNET_MessageHeader *message) |
665 | { | 667 | { |
668 | const struct ListAllPeersMessage *lapm; | ||
666 | struct GNUNET_SERVER_TransmitContext *tc; | 669 | struct GNUNET_SERVER_TransmitContext *tc; |
670 | int friend_only; | ||
667 | 671 | ||
672 | lapm = (const struct ListAllPeersMessage *) message; | ||
673 | friend_only = ntohl (lapm->include_friend_only); | ||
668 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "GET_ALL"); | 674 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "GET_ALL"); |
669 | tc = GNUNET_SERVER_transmit_context_create (client); | 675 | tc = GNUNET_SERVER_transmit_context_create (client); |
670 | GNUNET_CONTAINER_multihashmap_iterate (hostmap, &add_to_tc, tc); | 676 | GNUNET_CONTAINER_multihashmap_iterate (hostmap, &add_to_tc, tc); |
@@ -709,7 +715,11 @@ static void | |||
709 | handle_notify (void *cls, struct GNUNET_SERVER_Client *client, | 715 | handle_notify (void *cls, struct GNUNET_SERVER_Client *client, |
710 | const struct GNUNET_MessageHeader *message) | 716 | const struct GNUNET_MessageHeader *message) |
711 | { | 717 | { |
712 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "NOTIFY"); | 718 | struct NotifyMessage *nm = (struct NotifyMessage *) message; |
719 | int friend_only; | ||
720 | |||
721 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "NOTIFY"); | ||
722 | friend_only = ntohl (nm->include_friend_only); | ||
713 | GNUNET_SERVER_client_mark_monitor (client); | 723 | GNUNET_SERVER_client_mark_monitor (client); |
714 | GNUNET_SERVER_notification_context_add (notify_list, client); | 724 | GNUNET_SERVER_notification_context_add (notify_list, client); |
715 | GNUNET_CONTAINER_multihashmap_iterate (hostmap, &do_notify_entry, client); | 725 | GNUNET_CONTAINER_multihashmap_iterate (hostmap, &do_notify_entry, client); |
@@ -773,9 +783,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
773 | {&handle_get, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET, | 783 | {&handle_get, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET, |
774 | sizeof (struct ListPeerMessage)}, | 784 | sizeof (struct ListPeerMessage)}, |
775 | {&handle_get_all, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL, | 785 | {&handle_get_all, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL, |
776 | sizeof (struct GNUNET_MessageHeader)}, | 786 | sizeof (struct ListAllPeersMessage)}, |
777 | {&handle_notify, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY, | 787 | {&handle_notify, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY, |
778 | sizeof (struct GNUNET_MessageHeader)}, | 788 | sizeof (struct NotifyMessage)}, |
779 | {NULL, NULL, 0, 0} | 789 | {NULL, NULL, 0, 0} |
780 | }; | 790 | }; |
781 | char *peerdir; | 791 | char *peerdir; |
diff --git a/src/peerinfo/peerinfo.h b/src/peerinfo/peerinfo.h index e61848757..97f819aff 100644 --- a/src/peerinfo/peerinfo.h +++ b/src/peerinfo/peerinfo.h | |||
@@ -31,22 +31,22 @@ | |||
31 | GNUNET_NETWORK_STRUCT_BEGIN | 31 | GNUNET_NETWORK_STRUCT_BEGIN |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Message requesting a listing of all known peers, | 34 | * Message requesting a listing of peers, |
35 | * possibly restricted to the specified peer identity. | 35 | * restricted to the specified peer identity. |
36 | */ | 36 | */ |
37 | struct ListPeerMessage | 37 | struct ListPeerMessage |
38 | { | 38 | { |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Type will be GNUNET_MESSAGE_TYPE_PEERINFO_GET or | 41 | * Type will be GNUNET_MESSAGE_TYPE_PEERINFO_GET |
42 | * GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL. | 42 | * . |
43 | */ | 43 | */ |
44 | struct GNUNET_MessageHeader header; | 44 | struct GNUNET_MessageHeader header; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Always zero. | 47 | * Include friend only HELLOs and peers in callbacks |
48 | */ | 48 | */ |
49 | uint32_t reserved GNUNET_PACKED; | 49 | uint32_t include_friend_only GNUNET_PACKED; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Restrict to peers with this identity (optional | 52 | * Restrict to peers with this identity (optional |
@@ -56,6 +56,42 @@ struct ListPeerMessage | |||
56 | 56 | ||
57 | }; | 57 | }; |
58 | 58 | ||
59 | /** | ||
60 | * Message requesting a listing of all peers, | ||
61 | * restricted to the specified peer identity. | ||
62 | */ | ||
63 | struct ListAllPeersMessage | ||
64 | { | ||
65 | /** | ||
66 | * Type will be GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL | ||
67 | */ | ||
68 | struct GNUNET_MessageHeader header; | ||
69 | |||
70 | /** | ||
71 | * Include friend only HELLOs and peers in callbacks | ||
72 | */ | ||
73 | uint32_t include_friend_only GNUNET_PACKED; | ||
74 | |||
75 | }; | ||
76 | |||
77 | |||
78 | /** | ||
79 | * Header for all communications. | ||
80 | */ | ||
81 | struct NotifyMessage | ||
82 | { | ||
83 | /** | ||
84 | * Type will be GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY | ||
85 | */ | ||
86 | struct GNUNET_MessageHeader header; | ||
87 | |||
88 | /** | ||
89 | * Include friend only HELLOs and peers in callbacks | ||
90 | */ | ||
91 | uint32_t include_friend_only GNUNET_PACKED; | ||
92 | |||
93 | }; | ||
94 | |||
59 | 95 | ||
60 | /** | 96 | /** |
61 | * Message used to inform the client about | 97 | * Message used to inform the client about |
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index 175397c78..faa56e908 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c | |||
@@ -692,6 +692,7 @@ signal_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
692 | * better to use 'GNUNET_PEERINFO_notify'. | 692 | * better to use 'GNUNET_PEERINFO_notify'. |
693 | * | 693 | * |
694 | * @param h handle to the peerinfo service | 694 | * @param h handle to the peerinfo service |
695 | * @param include_friend_only include HELLO messages for friends only | ||
695 | * @param peer restrict iteration to this peer only (can be NULL) | 696 | * @param peer restrict iteration to this peer only (can be NULL) |
696 | * @param timeout how long to wait until timing out | 697 | * @param timeout how long to wait until timing out |
697 | * @param callback the method to call for each peer | 698 | * @param callback the method to call for each peer |
@@ -700,11 +701,12 @@ signal_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
700 | */ | 701 | */ |
701 | struct GNUNET_PEERINFO_IteratorContext * | 702 | struct GNUNET_PEERINFO_IteratorContext * |
702 | GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | 703 | GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, |
704 | int include_friend_only, | ||
703 | const struct GNUNET_PeerIdentity *peer, | 705 | const struct GNUNET_PeerIdentity *peer, |
704 | struct GNUNET_TIME_Relative timeout, | 706 | struct GNUNET_TIME_Relative timeout, |
705 | GNUNET_PEERINFO_Processor callback, void *callback_cls) | 707 | GNUNET_PEERINFO_Processor callback, void *callback_cls) |
706 | { | 708 | { |
707 | struct GNUNET_MessageHeader *lapm; | 709 | struct ListAllPeersMessage *lapm; |
708 | struct ListPeerMessage *lpm; | 710 | struct ListPeerMessage *lpm; |
709 | struct GNUNET_PEERINFO_IteratorContext *ic; | 711 | struct GNUNET_PEERINFO_IteratorContext *ic; |
710 | struct GNUNET_PEERINFO_AddContext *ac; | 712 | struct GNUNET_PEERINFO_AddContext *ac; |
@@ -716,11 +718,12 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | |||
716 | "Requesting list of peers from PEERINFO service\n"); | 718 | "Requesting list of peers from PEERINFO service\n"); |
717 | ac = | 719 | ac = |
718 | GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_AddContext) + | 720 | GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_AddContext) + |
719 | sizeof (struct GNUNET_MessageHeader)); | 721 | sizeof (struct ListAllPeersMessage)); |
720 | ac->size = sizeof (struct GNUNET_MessageHeader); | 722 | ac->size = sizeof (struct ListAllPeersMessage); |
721 | lapm = (struct GNUNET_MessageHeader *) &ac[1]; | 723 | lapm = (struct ListAllPeersMessage *) &ac[1]; |
722 | lapm->size = htons (sizeof (struct GNUNET_MessageHeader)); | 724 | lapm->header.size = htons (sizeof (struct ListAllPeersMessage)); |
723 | lapm->type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL); | 725 | lapm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL); |
726 | lapm->include_friend_only = htonl (include_friend_only); | ||
724 | } | 727 | } |
725 | else | 728 | else |
726 | { | 729 | { |
@@ -734,6 +737,7 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | |||
734 | lpm = (struct ListPeerMessage *) &ac[1]; | 737 | lpm = (struct ListPeerMessage *) &ac[1]; |
735 | lpm->header.size = htons (sizeof (struct ListPeerMessage)); | 738 | lpm->header.size = htons (sizeof (struct ListPeerMessage)); |
736 | lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET); | 739 | lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET); |
740 | lpm->include_friend_only = htonl (include_friend_only); | ||
737 | memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity)); | 741 | memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity)); |
738 | ic->have_peer = GNUNET_YES; | 742 | ic->have_peer = GNUNET_YES; |
739 | ic->peer = *peer; | 743 | ic->peer = *peer; |
diff --git a/src/peerinfo/peerinfo_api_notify.c b/src/peerinfo/peerinfo_api_notify.c index b9e83c9e7..4520decfd 100644 --- a/src/peerinfo/peerinfo_api_notify.c +++ b/src/peerinfo/peerinfo_api_notify.c | |||
@@ -69,6 +69,11 @@ struct GNUNET_PEERINFO_NotifyContext | |||
69 | */ | 69 | */ |
70 | GNUNET_SCHEDULER_TaskIdentifier task; | 70 | GNUNET_SCHEDULER_TaskIdentifier task; |
71 | 71 | ||
72 | /** | ||
73 | * Include friend only HELLOs in callbacks | ||
74 | */ | ||
75 | |||
76 | int include_friend_only; | ||
72 | }; | 77 | }; |
73 | 78 | ||
74 | 79 | ||
@@ -195,7 +200,7 @@ static size_t | |||
195 | transmit_notify_request (void *cls, size_t size, void *buf) | 200 | transmit_notify_request (void *cls, size_t size, void *buf) |
196 | { | 201 | { |
197 | struct GNUNET_PEERINFO_NotifyContext *nc = cls; | 202 | struct GNUNET_PEERINFO_NotifyContext *nc = cls; |
198 | struct GNUNET_MessageHeader hdr; | 203 | struct NotifyMessage nm; |
199 | 204 | ||
200 | nc->init = NULL; | 205 | nc->init = NULL; |
201 | if (buf == NULL) | 206 | if (buf == NULL) |
@@ -205,10 +210,11 @@ transmit_notify_request (void *cls, size_t size, void *buf) | |||
205 | request_notifications (nc); | 210 | request_notifications (nc); |
206 | return 0; | 211 | return 0; |
207 | } | 212 | } |
208 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); | 213 | GNUNET_assert (size >= sizeof (struct NotifyMessage)); |
209 | hdr.size = htons (sizeof (struct GNUNET_MessageHeader)); | 214 | nm.header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY); |
210 | hdr.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY); | 215 | nm.header.size = htons (sizeof (struct NotifyMessage)); |
211 | memcpy (buf, &hdr, sizeof (struct GNUNET_MessageHeader)); | 216 | nm.include_friend_only = htonl (nc->include_friend_only); |
217 | memcpy (buf, &nm, sizeof (struct NotifyMessage)); | ||
212 | receive_notifications (nc); | 218 | receive_notifications (nc); |
213 | return sizeof (struct GNUNET_MessageHeader); | 219 | return sizeof (struct GNUNET_MessageHeader); |
214 | } | 220 | } |
@@ -226,7 +232,7 @@ request_notifications (struct GNUNET_PEERINFO_NotifyContext *nc) | |||
226 | GNUNET_assert (NULL == nc->init); | 232 | GNUNET_assert (NULL == nc->init); |
227 | nc->init = | 233 | nc->init = |
228 | GNUNET_CLIENT_notify_transmit_ready (nc->client, | 234 | GNUNET_CLIENT_notify_transmit_ready (nc->client, |
229 | sizeof (struct GNUNET_MessageHeader), | 235 | sizeof (struct NotifyMessage), |
230 | GNUNET_TIME_UNIT_FOREVER_REL, | 236 | GNUNET_TIME_UNIT_FOREVER_REL, |
231 | GNUNET_YES, &transmit_notify_request, | 237 | GNUNET_YES, &transmit_notify_request, |
232 | nc); | 238 | nc); |
@@ -238,13 +244,19 @@ request_notifications (struct GNUNET_PEERINFO_NotifyContext *nc) | |||
238 | * changes. Initially calls the given function for all known | 244 | * changes. Initially calls the given function for all known |
239 | * peers and then only signals changes. | 245 | * peers and then only signals changes. |
240 | * | 246 | * |
247 | * If include_friend_only is set to GNUNET_YES peerinfo will include HELLO | ||
248 | * messages which are intended for friend to friend mode and which do not | ||
249 | * have to be gossiped. Otherwise these messages are skipped. | ||
250 | * | ||
241 | * @param cfg configuration to use | 251 | * @param cfg configuration to use |
252 | * @param include_friend_only include HELLO messages for friends only | ||
242 | * @param callback the method to call for each peer | 253 | * @param callback the method to call for each peer |
243 | * @param callback_cls closure for callback | 254 | * @param callback_cls closure for callback |
244 | * @return NULL on error | 255 | * @return NULL on error |
245 | */ | 256 | */ |
246 | struct GNUNET_PEERINFO_NotifyContext * | 257 | struct GNUNET_PEERINFO_NotifyContext * |
247 | GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, | 258 | GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, |
259 | int include_friend_only, | ||
248 | GNUNET_PEERINFO_Processor callback, void *callback_cls) | 260 | GNUNET_PEERINFO_Processor callback, void *callback_cls) |
249 | { | 261 | { |
250 | struct GNUNET_PEERINFO_NotifyContext *nc; | 262 | struct GNUNET_PEERINFO_NotifyContext *nc; |
@@ -262,6 +274,7 @@ GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
262 | nc->client = client; | 274 | nc->client = client; |
263 | nc->callback = callback; | 275 | nc->callback = callback; |
264 | nc->callback_cls = callback_cls; | 276 | nc->callback_cls = callback_cls; |
277 | nc->include_friend_only = include_friend_only; | ||
265 | request_notifications (nc); | 278 | request_notifications (nc); |
266 | return nc; | 279 | return nc; |
267 | } | 280 | } |
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index 59ea0ac8a..d3dcc2fd0 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c | |||
@@ -120,7 +120,7 @@ process (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
120 | /* try again */ | 120 | /* try again */ |
121 | retries++; | 121 | retries++; |
122 | add_peer (); | 122 | add_peer (); |
123 | ic = GNUNET_PEERINFO_iterate (h, NULL, | 123 | ic = GNUNET_PEERINFO_iterate (h, GNUNET_NO, NULL, |
124 | GNUNET_TIME_relative_multiply | 124 | GNUNET_TIME_relative_multiply |
125 | (GNUNET_TIME_UNIT_SECONDS, 15), &process, | 125 | (GNUNET_TIME_UNIT_SECONDS, 15), &process, |
126 | cls); | 126 | cls); |
@@ -152,7 +152,7 @@ run (void *cls, | |||
152 | h = GNUNET_PEERINFO_connect (cfg); | 152 | h = GNUNET_PEERINFO_connect (cfg); |
153 | GNUNET_assert (NULL != h); | 153 | GNUNET_assert (NULL != h); |
154 | add_peer (); | 154 | add_peer (); |
155 | ic = GNUNET_PEERINFO_iterate (h, NULL, | 155 | ic = GNUNET_PEERINFO_iterate (h, GNUNET_NO, NULL, |
156 | GNUNET_TIME_relative_multiply | 156 | GNUNET_TIME_relative_multiply |
157 | (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls); | 157 | (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls); |
158 | } | 158 | } |
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index c36108823..61ee308f8 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -918,7 +918,7 @@ process_peer (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
918 | _("Error in communication with PEERINFO service: %s\n"), | 918 | _("Error in communication with PEERINFO service: %s\n"), |
919 | err_msg); | 919 | err_msg); |
920 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); | 920 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); |
921 | peerinfo_notify = GNUNET_PEERINFO_notify (cfg, &process_peer, NULL); | 921 | peerinfo_notify = GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_peer, NULL); |
922 | return; | 922 | return; |
923 | } | 923 | } |
924 | GNUNET_assert (peer != NULL); | 924 | GNUNET_assert (peer != NULL); |
@@ -991,7 +991,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
991 | handle = server; | 991 | handle = server; |
992 | my_identity = *my_id; | 992 | my_identity = *my_id; |
993 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am peer `%s'\n", GNUNET_i2s (my_id)); | 993 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am peer `%s'\n", GNUNET_i2s (my_id)); |
994 | peerinfo_notify = GNUNET_PEERINFO_notify (cfg, &process_peer, NULL); | 994 | peerinfo_notify = GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_peer, NULL); |
995 | } | 995 | } |
996 | 996 | ||
997 | 997 | ||
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index a6c0b7f9d..71a96de12 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -800,7 +800,7 @@ GST_validation_start (unsigned int max_fds) | |||
800 | validations_fast_start_threshold, validation_delay.rel_value); | 800 | validations_fast_start_threshold, validation_delay.rel_value); |
801 | validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE, | 801 | validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE, |
802 | GNUNET_NO); | 802 | GNUNET_NO); |
803 | pnc = GNUNET_PEERINFO_notify (GST_cfg, &process_peerinfo_hello, NULL); | 803 | pnc = GNUNET_PEERINFO_notify (GST_cfg, GNUNET_YES, &process_peerinfo_hello, NULL); |
804 | } | 804 | } |
805 | 805 | ||
806 | 806 | ||