aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO10
-rw-r--r--src/core/gnunet-service-core.c22
-rw-r--r--src/hostlist/hostlist-server.c20
-rw-r--r--src/include/gnunet_peerinfo_service.h84
-rw-r--r--src/include/gnunet_protocols.h5
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c17
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c40
-rw-r--r--src/peerinfo/peerinfo.h25
-rw-r--r--src/peerinfo/peerinfo_api.c344
-rw-r--r--src/peerinfo/test_peerinfo_api.c30
-rw-r--r--src/transport/gnunet-service-transport.c33
11 files changed, 133 insertions, 497 deletions
diff --git a/TODO b/TODO
index b5b5176b2..dcc13d8e9 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,4 @@
10.9.0pre1: 10.9.0pre1:
2* PEERINFO: [CG]
3 - finish implementing NEW API (cancel, timeout, submit-during-receive prevention)
4 - test new API
5 - transition existing code to new API
6 - remove support for old API
7* FS: [CG] 2* FS: [CG]
8 - support recursive download even if filename is NULL and we hence 3 - support recursive download even if filename is NULL and we hence
9 do not generate files on disk (use temp_filename) 4 do not generate files on disk (use temp_filename)
@@ -175,6 +170,11 @@ Optimizations:
175* DATASTORE (?): 170* DATASTORE (?):
176 - check for duplicates on insertion (currently, same content is frequently 171 - check for duplicates on insertion (currently, same content is frequently
177 stored again [seen with KBLOCKS and SBLOCKS]!) 172 stored again [seen with KBLOCKS and SBLOCKS]!)
173* PEERINFO:
174 - merge multiple HELLOs of the same peer in the transmission queue
175 (theoretically reduces overhead; bounds message queue size)
176 - merge multiple iteration requests over "all" peers in the queue
177 (theoretically reduces overhead; bounds messgae queue size)
178 178
179Minor features: 179Minor features:
180* TCP: 180* TCP:
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index bad6f05d3..aa4d4afb1 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -656,6 +656,11 @@ static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
656struct GNUNET_SCHEDULER_Handle *sched; 656struct GNUNET_SCHEDULER_Handle *sched;
657 657
658/** 658/**
659 * Handle to peerinfo service.
660 */
661static struct GNUNET_PEERINFO_Handle *peerinfo;
662
663/**
659 * Our configuration. 664 * Our configuration.
660 */ 665 */
661const struct GNUNET_CONFIGURATION_Handle *cfg; 666const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -2491,8 +2496,7 @@ send_key (struct Neighbour *n)
2491 GNUNET_i2s (&n->peer)); 2496 GNUNET_i2s (&n->peer));
2492#endif 2497#endif
2493 GNUNET_assert (n->pitr == NULL); 2498 GNUNET_assert (n->pitr == NULL);
2494 n->pitr = GNUNET_PEERINFO_iterate (cfg, 2499 n->pitr = GNUNET_PEERINFO_iterate (peerinfo,
2495 sched,
2496 &n->peer, 2500 &n->peer,
2497 0, 2501 0,
2498 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20), 2502 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20),
@@ -2923,8 +2927,7 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m)
2923 /* lookup n's public key, then try again */ 2927 /* lookup n's public key, then try again */
2924 GNUNET_assert (n->skm == NULL); 2928 GNUNET_assert (n->skm == NULL);
2925 n->skm = m_cpy; 2929 n->skm = m_cpy;
2926 n->pitr = GNUNET_PEERINFO_iterate (cfg, 2930 n->pitr = GNUNET_PEERINFO_iterate (peerinfo,
2927 sched,
2928 &n->peer, 2931 &n->peer,
2929 0, 2932 0,
2930 GNUNET_TIME_UNIT_MINUTES, 2933 GNUNET_TIME_UNIT_MINUTES,
@@ -3737,6 +3740,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3737 GNUNET_CRYPTO_rsa_key_free (my_private_key); 3740 GNUNET_CRYPTO_rsa_key_free (my_private_key);
3738 if (stats != NULL) 3741 if (stats != NULL)
3739 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 3742 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
3743 if (peerinfo != NULL)
3744 GNUNET_PEERINFO_disconnect (peerinfo);
3740} 3745}
3741 3746
3742 3747
@@ -3781,12 +3786,21 @@ run (void *cls,
3781 GNUNET_SCHEDULER_shutdown (s); 3786 GNUNET_SCHEDULER_shutdown (s);
3782 return; 3787 return;
3783 } 3788 }
3789 peerinfo = GNUNET_PEERINFO_connect (sched, cfg);
3790 if (NULL == peerinfo)
3791 {
3792 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3793 _("Could not access PEERINFO service. Exiting.\n"));
3794 GNUNET_SCHEDULER_shutdown (s);
3795 return;
3796 }
3784 my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 3797 my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
3785 GNUNET_free (keyfile); 3798 GNUNET_free (keyfile);
3786 if (my_private_key == NULL) 3799 if (my_private_key == NULL)
3787 { 3800 {
3788 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3801 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3789 _("Core service could not access hostkey. Exiting.\n")); 3802 _("Core service could not access hostkey. Exiting.\n"));
3803 GNUNET_PEERINFO_disconnect (peerinfo);
3790 GNUNET_SCHEDULER_shutdown (s); 3804 GNUNET_SCHEDULER_shutdown (s);
3791 return; 3805 return;
3792 } 3806 }
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c
index 4a28cdfc3..fdc3e34d0 100644
--- a/src/hostlist/hostlist-server.c
+++ b/src/hostlist/hostlist-server.c
@@ -95,6 +95,11 @@ static struct MHD_Response *response;
95static struct GNUNET_PEERINFO_IteratorContext *pitr; 95static struct GNUNET_PEERINFO_IteratorContext *pitr;
96 96
97/** 97/**
98 * Handle for accessing peerinfo service.
99 */
100static struct GNUNET_PEERINFO_Handle *peerinfo;
101
102/**
98 * Context for host processor. 103 * Context for host processor.
99 */ 104 */
100struct HostSet 105struct HostSet
@@ -280,7 +285,8 @@ update_response (void *cls,
280 285
281 response_task = GNUNET_SCHEDULER_NO_TASK; 286 response_task = GNUNET_SCHEDULER_NO_TASK;
282 results = GNUNET_malloc(sizeof(struct HostSet)); 287 results = GNUNET_malloc(sizeof(struct HostSet));
283 pitr = GNUNET_PEERINFO_iterate (cfg, sched, 288 GNUNET_assert (peerinfo != NULL);
289 pitr = GNUNET_PEERINFO_iterate (peerinfo,
284 NULL, 290 NULL,
285 0, 291 0,
286 GNUNET_TIME_UNIT_MINUTES, 292 GNUNET_TIME_UNIT_MINUTES,
@@ -596,6 +602,13 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c,
596 sched = s; 602 sched = s;
597 cfg = c; 603 cfg = c;
598 stats = st; 604 stats = st;
605 peerinfo = GNUNET_PEERINFO_connect (sched, cfg);
606 if (peerinfo == NULL)
607 {
608 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
609 _("Could not access PEERINFO service. Exiting.\n"));
610 return GNUNET_SYSERR;
611 }
599 if (-1 == GNUNET_CONFIGURATION_get_value_number (cfg, 612 if (-1 == GNUNET_CONFIGURATION_get_value_number (cfg,
600 "HOSTLIST", 613 "HOSTLIST",
601 "HTTPPORT", 614 "HTTPPORT",
@@ -724,6 +737,11 @@ GNUNET_HOSTLIST_server_stop ()
724 MHD_destroy_response (response); 737 MHD_destroy_response (response);
725 response = NULL; 738 response = NULL;
726 } 739 }
740 if (peerinfo != NULL)
741 {
742 GNUNET_PEERINFO_disconnect (peerinfo);
743 peerinfo = NULL;
744 }
727} 745}
728 746
729/* end of hostlist-server.c */ 747/* end of hostlist-server.c */
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h
index ac88df201..4f689e504 100644
--- a/src/include/gnunet_peerinfo_service.h
+++ b/src/include/gnunet_peerinfo_service.h
@@ -51,14 +51,15 @@ struct GNUNET_PEERINFO_Handle;
51/** 51/**
52 * Connect to the peerinfo service. 52 * Connect to the peerinfo service.
53 * 53 *
54 * @param cfg configuration to use
55 * @param sched scheduler to use 54 * @param sched scheduler to use
55 * @param cfg configuration to use
56 * @return NULL on error (configuration related, actual connection 56 * @return NULL on error (configuration related, actual connection
57 * etablishment may happen asynchronously). 57 * etablishment may happen asynchronously).
58 */ 58 */
59struct GNUNET_PEERINFO_Handle * 59struct GNUNET_PEERINFO_Handle *
60GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 60GNUNET_PEERINFO_connect (struct GNUNET_SCHEDULER_Handle *sched,
61 struct GNUNET_SCHEDULER_Handle *sched); 61 const struct GNUNET_CONFIGURATION_Handle *cfg);
62
62 63
63 64
64/** 65/**
@@ -86,26 +87,11 @@ GNUNET_PEERINFO_disconnect (struct GNUNET_PEERINFO_Handle *h);
86 * @param hello the verified (!) HELLO message 87 * @param hello the verified (!) HELLO message
87 */ 88 */
88void 89void
89GNUNET_PEERINFO_add_peer_new (struct GNUNET_PEERINFO_Handle *h, 90GNUNET_PEERINFO_add_peer (struct GNUNET_PEERINFO_Handle *h,
90 const struct GNUNET_HELLO_Message *hello); 91 const struct GNUNET_HELLO_Message *hello);
91
92 92
93 93
94/** 94/**
95 * Add a host to the persistent list.
96 *
97 * @param cfg configuration to use
98 * @param sched scheduler to use
99 * @param peer identity of the peer
100 * @param hello the verified (!) HELLO message
101 */
102void
103GNUNET_PEERINFO_add_peer (const struct GNUNET_CONFIGURATION_Handle *cfg,
104 struct GNUNET_SCHEDULER_Handle *sched,
105 const struct GNUNET_PeerIdentity *peer,
106 const struct GNUNET_HELLO_Message *hello);
107
108/**
109 * Type of an iterator over the hosts. Note that each 95 * Type of an iterator over the hosts. Note that each
110 * host will be called with each available protocol. 96 * host will be called with each available protocol.
111 * 97 *
@@ -128,40 +114,6 @@ struct GNUNET_PEERINFO_IteratorContext;
128 114
129 115
130/** 116/**
131 * Call a method for each known matching host and change
132 * its trust value. The method will be invoked once for
133 * each host and then finally once with a NULL pointer. After
134 * that final invocation, the iterator context must no longer
135 * be used.
136 *
137 * Note that the last call can be triggered by timeout or by simply
138 * being done; however, the trust argument will be set to zero if we
139 * are done, 1 if we timed out and 2 for fatal error.
140 *
141 * @param cfg configuration to use
142 * @param sched scheduler to use
143 * @param peer restrict iteration to this peer only (can be NULL)
144 * @param trust_delta how much to change the trust in all matching peers
145 * @param timeout how long to wait until timing out
146 * @param callback the method to call for each peer
147 * @param callback_cls closure for callback
148 * @return NULL on error (in this case, 'callback' is never called!),
149 * otherwise an iterator context
150 */
151struct GNUNET_PEERINFO_IteratorContext *
152GNUNET_PEERINFO_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
153 struct GNUNET_SCHEDULER_Handle *sched,
154 const struct GNUNET_PeerIdentity *peer,
155 int trust_delta,
156 struct GNUNET_TIME_Relative timeout,
157 GNUNET_PEERINFO_Processor callback,
158 void *callback_cls);
159
160
161struct GNUNET_PEERINFO_NewIteratorContext;
162
163
164/**
165 * Call a method for each known matching host and change its trust 117 * Call a method for each known matching host and change its trust
166 * value. The callback method will be invoked once for each matching 118 * value. The callback method will be invoked once for each matching
167 * host and then finally once with a NULL pointer. After that final 119 * host and then finally once with a NULL pointer. After that final
@@ -183,23 +135,14 @@ struct GNUNET_PEERINFO_NewIteratorContext;
183 * @return NULL on error (in this case, 'callback' is never called!), 135 * @return NULL on error (in this case, 'callback' is never called!),
184 * otherwise an iterator context 136 * otherwise an iterator context
185 */ 137 */
186struct GNUNET_PEERINFO_NewIteratorContext * 138struct GNUNET_PEERINFO_IteratorContext *
187GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h, 139GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
188 const struct GNUNET_PeerIdentity *peer, 140 const struct GNUNET_PeerIdentity *peer,
189 int trust_delta, 141 int trust_delta,
190 struct GNUNET_TIME_Relative timeout, 142 struct GNUNET_TIME_Relative timeout,
191 GNUNET_PEERINFO_Processor callback, 143 GNUNET_PEERINFO_Processor callback,
192 void *callback_cls); 144 void *callback_cls);
193
194
195 145
196/**
197 * Cancel an iteration over peer information.
198 *
199 * @param ic context of the iterator to cancel
200 */
201void
202GNUNET_PEERINFO_iterate_cancel_new (struct GNUNET_PEERINFO_NewIteratorContext *ic);
203 146
204 147
205/** 148/**
@@ -211,6 +154,7 @@ void
211GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic); 154GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic);
212 155
213 156
157
214/** 158/**
215 * Handle for notifications about changes to the set of known peers. 159 * Handle for notifications about changes to the set of known peers.
216 */ 160 */
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index d992c9fb7..72fcccf94 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -199,11 +199,6 @@ extern "C"
199#define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG 33 199#define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG 33
200 200
201/** 201/**
202 * Request addition of a HELLO
203 */
204#define GNUNET_MESSAGE_TYPE_PEERINFO_ADD 36
205
206/**
207 * Request update and listing of a peer. 202 * Request update and listing of a peer.
208 */ 203 */
209#define GNUNET_MESSAGE_TYPE_PEERINFO_GET 37 204#define GNUNET_MESSAGE_TYPE_PEERINFO_GET 37
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index 63c5cc008..5efd7262c 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -39,6 +39,8 @@ static int get_self;
39 39
40static struct GNUNET_SCHEDULER_Handle *sched; 40static struct GNUNET_SCHEDULER_Handle *sched;
41 41
42static struct GNUNET_PEERINFO_Handle *peerinfo;
43
42static const struct GNUNET_CONFIGURATION_Handle *cfg; 44static const struct GNUNET_CONFIGURATION_Handle *cfg;
43 45
44struct PrintContext 46struct PrintContext
@@ -166,7 +168,10 @@ print_peer_info (void *cls,
166 struct PrintContext *pc; 168 struct PrintContext *pc;
167 169
168 if (peer == NULL) 170 if (peer == NULL)
169 return; 171 {
172 GNUNET_PEERINFO_disconnect (peerinfo);
173 return;
174 }
170 if (be_quiet) 175 if (be_quiet)
171 { 176 {
172 GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &enc); 177 GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &enc);
@@ -212,8 +217,14 @@ run (void *cls,
212 cfg = c; 217 cfg = c;
213 if (get_self != GNUNET_YES) 218 if (get_self != GNUNET_YES)
214 { 219 {
215 (void) GNUNET_PEERINFO_iterate (cfg, 220 peerinfo = GNUNET_PEERINFO_connect (sched, cfg);
216 sched, 221 if (peerinfo == NULL)
222 {
223 fprintf (stderr,
224 _("Could not access PEERINFO service. Exiting.\n"));
225 return;
226 }
227 (void) GNUNET_PEERINFO_iterate (peerinfo,
217 NULL, 228 NULL,
218 0, 229 0,
219 GNUNET_TIME_relative_multiply 230 GNUNET_TIME_relative_multiply
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 1802da959..e200eae2f 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -29,8 +29,6 @@
29 * 29 *
30 * TODO: 30 * TODO:
31 * - HostEntries are never 'free'd (add expiration, upper bound?) 31 * - HostEntries are never 'free'd (add expiration, upper bound?)
32 * - AddPeer message is obsolete with NEW peerinfo API (remove handler,
33 * message struct and protocol)
34 */ 32 */
35 33
36#include "platform.h" 34#include "platform.h"
@@ -649,43 +647,6 @@ cron_clean_data_hosts (void *cls,
649 647
650 648
651/** 649/**
652 * Handle ADD-message.
653 *
654 * @param cls closure
655 * @param client identification of the client
656 * @param message the actual message
657 */
658static void
659handle_add (void *cls,
660 struct GNUNET_SERVER_Client *client,
661 const struct GNUNET_MessageHeader *message)
662{
663 const struct PeerAddMessage *pam;
664 const struct GNUNET_MessageHeader *hello;
665 uint16_t size;
666
667 size = ntohs (message->size);
668 if (size <
669 sizeof (struct PeerAddMessage) + sizeof (struct GNUNET_MessageHeader))
670 {
671 GNUNET_break (0);
672 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
673 return;
674 }
675 pam = (const struct PeerAddMessage *) message;
676 hello = (const struct GNUNET_MessageHeader *) &pam[1];
677 if (size != sizeof (struct PeerAddMessage) + ntohs (hello->size))
678 {
679 GNUNET_break (0);
680 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
681 return;
682 }
683 bind_address (&pam->peer, (const struct GNUNET_HELLO_Message *) hello);
684 GNUNET_SERVER_receive_done (client, GNUNET_OK);
685}
686
687
688/**
689 * Handle HELLO-message. 650 * Handle HELLO-message.
690 * 651 *
691 * @param cls closure 652 * @param cls closure
@@ -787,7 +748,6 @@ handle_notify (void *cls,
787 */ 748 */
788static struct GNUNET_SERVER_MessageHandler handlers[] = { 749static struct GNUNET_SERVER_MessageHandler handlers[] = {
789 {&handle_hello, NULL, GNUNET_MESSAGE_TYPE_HELLO, 0}, 750 {&handle_hello, NULL, GNUNET_MESSAGE_TYPE_HELLO, 0},
790 {&handle_add, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_ADD, 0},
791 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET, 751 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET,
792 sizeof (struct ListPeerMessage)}, 752 sizeof (struct ListPeerMessage)},
793 {&handle_get_all, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL, 753 {&handle_get_all, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL,
diff --git a/src/peerinfo/peerinfo.h b/src/peerinfo/peerinfo.h
index 607aad4db..3e959a6c7 100644
--- a/src/peerinfo/peerinfo.h
+++ b/src/peerinfo/peerinfo.h
@@ -30,31 +30,6 @@
30#define DEBUG_PEERINFO GNUNET_NO 30#define DEBUG_PEERINFO GNUNET_NO
31 31
32/** 32/**
33 * Add the given peer to the list. This message
34 * is always followed by a verified HELLO message.
35 */
36struct PeerAddMessage
37{
38
39 /**
40 * Type will be GNUNET_MESSAGE_TYPE_PEERINFO_ADD
41 */
42 struct GNUNET_MessageHeader header;
43
44 /**
45 * Always zero.
46 */
47 uint32_t reserved GNUNET_PACKED;
48
49 /**
50 * For which peer do we provide a HELLO message here?
51 */
52 struct GNUNET_PeerIdentity peer;
53
54};
55
56
57/**
58 * Message requesting a listing of all known peers, 33 * Message requesting a listing of all known peers,
59 * possibly modified by the specified trust value 34 * possibly modified by the specified trust value
60 * and restricted to the specified peer identity. 35 * and restricted to the specified peer identity.
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c
index 5392d1696..44af04c92 100644
--- a/src/peerinfo/peerinfo_api.c
+++ b/src/peerinfo/peerinfo_api.c
@@ -127,14 +127,14 @@ struct GNUNET_PEERINFO_Handle
127/** 127/**
128 * Connect to the peerinfo service. 128 * Connect to the peerinfo service.
129 * 129 *
130 * @param cfg configuration to use
131 * @param sched scheduler to use 130 * @param sched scheduler to use
131 * @param cfg configuration to use
132 * @return NULL on error (configuration related, actual connection 132 * @return NULL on error (configuration related, actual connection
133 * etablishment may happen asynchronously). 133 * etablishment may happen asynchronously).
134 */ 134 */
135struct GNUNET_PEERINFO_Handle * 135struct GNUNET_PEERINFO_Handle *
136GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 136GNUNET_PEERINFO_connect (struct GNUNET_SCHEDULER_Handle *sched,
137 struct GNUNET_SCHEDULER_Handle *sched) 137 const struct GNUNET_CONFIGURATION_Handle *cfg)
138{ 138{
139 struct GNUNET_CLIENT_Connection *client; 139 struct GNUNET_CLIENT_Connection *client;
140 struct GNUNET_PEERINFO_Handle *ret; 140 struct GNUNET_PEERINFO_Handle *ret;
@@ -197,7 +197,7 @@ static void
197reconnect (struct GNUNET_PEERINFO_Handle *h) 197reconnect (struct GNUNET_PEERINFO_Handle *h)
198{ 198{
199 GNUNET_CLIENT_disconnect (h->client, GNUNET_SYSERR); 199 GNUNET_CLIENT_disconnect (h->client, GNUNET_SYSERR);
200 h->client = GNUNET_CLIENT_connect (h->sched, "client", h->cfg); 200 h->client = GNUNET_CLIENT_connect (h->sched, "peerinfo", h->cfg);
201 GNUNET_assert (h->client != NULL); 201 GNUNET_assert (h->client != NULL);
202} 202}
203 203
@@ -291,8 +291,8 @@ trigger_transmit (struct GNUNET_PEERINFO_Handle *h)
291 * @param hello the verified (!) HELLO message 291 * @param hello the verified (!) HELLO message
292 */ 292 */
293void 293void
294GNUNET_PEERINFO_add_peer_new (struct GNUNET_PEERINFO_Handle *h, 294GNUNET_PEERINFO_add_peer (struct GNUNET_PEERINFO_Handle *h,
295 const struct GNUNET_HELLO_Message *hello) 295 const struct GNUNET_HELLO_Message *hello)
296{ 296{
297 uint16_t hs = GNUNET_HELLO_size (hello); 297 uint16_t hs = GNUNET_HELLO_size (hello);
298 struct TransmissionQueueEntry *tqe; 298 struct TransmissionQueueEntry *tqe;
@@ -321,7 +321,7 @@ GNUNET_PEERINFO_add_peer_new (struct GNUNET_PEERINFO_Handle *h,
321/** 321/**
322 * Context for an iteration request. 322 * Context for an iteration request.
323 */ 323 */
324struct GNUNET_PEERINFO_NewIteratorContext 324struct GNUNET_PEERINFO_IteratorContext
325{ 325{
326 /** 326 /**
327 * Handle to the PEERINFO service. 327 * Handle to the PEERINFO service.
@@ -370,7 +370,7 @@ struct GNUNET_PEERINFO_NewIteratorContext
370static void 370static void
371peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) 371peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
372{ 372{
373 struct GNUNET_PEERINFO_NewIteratorContext *ic = cls; 373 struct GNUNET_PEERINFO_IteratorContext *ic = cls;
374 const struct InfoMessage *im; 374 const struct InfoMessage *im;
375 const struct GNUNET_HELLO_Message *hello; 375 const struct GNUNET_HELLO_Message *hello;
376 uint16_t ms; 376 uint16_t ms;
@@ -461,14 +461,14 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
461 * We've transmitted the iteration request. Now get ready to process 461 * We've transmitted the iteration request. Now get ready to process
462 * the results (or handle transmission error). 462 * the results (or handle transmission error).
463 * 463 *
464 * @param cls the 'struct GNUNET_PEERINFO_NewIteratorContext' 464 * @param cls the 'struct GNUNET_PEERINFO_IteratorContext'
465 * @param transmit_success GNUNET_OK if transmission worked 465 * @param transmit_success GNUNET_OK if transmission worked
466 */ 466 */
467static void 467static void
468iterator_start_receive (void *cls, 468iterator_start_receive (void *cls,
469 int transmit_success) 469 int transmit_success)
470{ 470{
471 struct GNUNET_PEERINFO_NewIteratorContext *ic = cls; 471 struct GNUNET_PEERINFO_IteratorContext *ic = cls;
472 472
473 if (GNUNET_OK != transmit_success) 473 if (GNUNET_OK != transmit_success)
474 { 474 {
@@ -491,14 +491,14 @@ iterator_start_receive (void *cls,
491/** 491/**
492 * Peerinfo iteration request has timed out. 492 * Peerinfo iteration request has timed out.
493 * 493 *
494 * @param cls the 'struct GNUNET_PEERINFO_NewIteratorContext*' 494 * @param cls the 'struct GNUNET_PEERINFO_IteratorContext*'
495 * @param tc scheduler context 495 * @param tc scheduler context
496 */ 496 */
497static void 497static void
498signal_timeout (void *cls, 498signal_timeout (void *cls,
499 const struct GNUNET_SCHEDULER_TaskContext *tc) 499 const struct GNUNET_SCHEDULER_TaskContext *tc)
500{ 500{
501 struct GNUNET_PEERINFO_NewIteratorContext *ic = cls; 501 struct GNUNET_PEERINFO_IteratorContext *ic = cls;
502 502
503 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; 503 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
504 ic->callback (ic->callback_cls, NULL, NULL, 1); 504 ic->callback (ic->callback_cls, NULL, NULL, 1);
@@ -535,17 +535,17 @@ signal_timeout (void *cls,
535 * @return NULL on error (in this case, 'callback' is never called!), 535 * @return NULL on error (in this case, 'callback' is never called!),
536 * otherwise an iterator context 536 * otherwise an iterator context
537 */ 537 */
538struct GNUNET_PEERINFO_NewIteratorContext * 538struct GNUNET_PEERINFO_IteratorContext *
539GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h, 539GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
540 const struct GNUNET_PeerIdentity *peer, 540 const struct GNUNET_PeerIdentity *peer,
541 int trust_delta, 541 int trust_delta,
542 struct GNUNET_TIME_Relative timeout, 542 struct GNUNET_TIME_Relative timeout,
543 GNUNET_PEERINFO_Processor callback, 543 GNUNET_PEERINFO_Processor callback,
544 void *callback_cls) 544 void *callback_cls)
545{ 545{
546 struct ListAllPeersMessage *lapm; 546 struct ListAllPeersMessage *lapm;
547 struct ListPeerMessage *lpm; 547 struct ListPeerMessage *lpm;
548 struct GNUNET_PEERINFO_NewIteratorContext *ic; 548 struct GNUNET_PEERINFO_IteratorContext *ic;
549 struct TransmissionQueueEntry *tqe; 549 struct TransmissionQueueEntry *tqe;
550 550
551#if DEBUG_PEERINFO 551#if DEBUG_PEERINFO
@@ -573,7 +573,7 @@ GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h,
573 lpm->trust_change = htonl (trust_delta); 573 lpm->trust_change = htonl (trust_delta);
574 memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity)); 574 memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity));
575 } 575 }
576 ic = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_NewIteratorContext)); 576 ic = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext));
577 ic->h = h; 577 ic->h = h;
578 ic->tqe = tqe; 578 ic->tqe = tqe;
579 ic->callback = callback; 579 ic->callback = callback;
@@ -603,7 +603,7 @@ GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h,
603 * @param ic context of the iterator to cancel 603 * @param ic context of the iterator to cancel
604 */ 604 */
605void 605void
606GNUNET_PEERINFO_iterate_cancel_new (struct GNUNET_PEERINFO_NewIteratorContext *ic) 606GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic)
607{ 607{
608 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) 608 if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
609 { 609 {
@@ -622,304 +622,4 @@ GNUNET_PEERINFO_iterate_cancel_new (struct GNUNET_PEERINFO_NewIteratorContext *i
622} 622}
623 623
624 624
625
626/* ***************************** OLD API ****************************** */
627
628
629
630
631#define ADD_PEER_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
632
633
634struct CAFContext
635{
636 struct GNUNET_CLIENT_Connection *client;
637 struct GNUNET_MessageHeader *msg;
638};
639
640
641static size_t
642copy_and_free (void *cls, size_t size, void *buf)
643{
644 struct CAFContext *cc = cls;
645 struct GNUNET_MessageHeader *msg = cc->msg;
646 uint16_t msize;
647
648 if (buf == NULL)
649 {
650#if DEBUG_PEERINFO
651 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
652 _
653 ("Failed to transmit message of type %u to `%s' service.\n"),
654 ntohs (msg->type), "peerinfo");
655#endif
656 GNUNET_free (msg);
657 GNUNET_CLIENT_disconnect (cc->client, GNUNET_NO);
658 GNUNET_free (cc);
659 return 0;
660 }
661 msize = ntohs (msg->size);
662 GNUNET_assert (size >= msize);
663 memcpy (buf, msg, msize);
664 GNUNET_free (msg);
665 GNUNET_CLIENT_disconnect (cc->client, GNUNET_YES);
666 GNUNET_free (cc);
667 return msize;
668}
669
670
671
672/**
673 * Add a host to the persistent list.
674 *
675 * @param cfg configuration to use
676 * @param sched scheduler to use
677 * @param peer identity of the peer
678 * @param hello the verified (!) HELLO message
679 */
680void
681GNUNET_PEERINFO_add_peer (const struct GNUNET_CONFIGURATION_Handle *cfg,
682 struct GNUNET_SCHEDULER_Handle *sched,
683 const struct GNUNET_PeerIdentity *peer,
684 const struct GNUNET_HELLO_Message *hello)
685{
686 struct GNUNET_CLIENT_Connection *client;
687 struct PeerAddMessage *pam;
688 uint16_t hs;
689 struct CAFContext *cc;
690
691#if DEBUG_PEERINFO
692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
693 "Adding peer `%s' to peerinfo database\n",
694 GNUNET_i2s(peer));
695#endif
696 client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg);
697 if (client == NULL)
698 {
699 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
700 _("Could not connect to `%s' service.\n"), "peerinfo");
701 return;
702 }
703 hs = GNUNET_HELLO_size (hello);
704#if DEBUG_PEERINFO
705 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
706 "Size of `%s' is %u bytes\n",
707 "HELLO",
708 (unsigned int) GNUNET_HELLO_size (hello));
709#endif
710 pam = GNUNET_malloc (sizeof (struct PeerAddMessage) + hs);
711 pam->header.size = htons (hs + sizeof (struct PeerAddMessage));
712 pam->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_ADD);
713 memcpy (&pam->peer, peer, sizeof (struct GNUNET_PeerIdentity));
714 memcpy (&pam[1], hello, hs);
715 cc = GNUNET_malloc (sizeof (struct CAFContext));
716 cc->client = client;
717 cc->msg = &pam->header;
718 GNUNET_CLIENT_notify_transmit_ready (client,
719 ntohs (pam->header.size),
720 ADD_PEER_TIMEOUT,
721 GNUNET_NO,
722 &copy_and_free, cc);
723}
724
725
726/**
727 * Context for the info handler.
728 */
729struct GNUNET_PEERINFO_IteratorContext
730{
731
732 /**
733 * Our connection to the PEERINFO service.
734 */
735 struct GNUNET_CLIENT_Connection *client;
736
737 /**
738 * Function to call with information.
739 */
740 GNUNET_PEERINFO_Processor callback;
741
742 /**
743 * Closure for callback.
744 */
745 void *callback_cls;
746
747 /**
748 * When should we time out?
749 */
750 struct GNUNET_TIME_Absolute timeout;
751
752};
753
754
755/**
756 * Type of a function to call when we receive a message
757 * from the service.
758 *
759 * @param cls closure
760 * @param msg message received, NULL on timeout or fatal error
761 */
762static void
763info_handler (void *cls, const struct GNUNET_MessageHeader *msg)
764{
765 struct GNUNET_PEERINFO_IteratorContext *ic = cls;
766 const struct InfoMessage *im;
767 const struct GNUNET_HELLO_Message *hello;
768 uint16_t ms;
769
770 if (msg == NULL)
771 {
772 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
773 _("Failed to receive response from `%s' service.\n"),
774 "peerinfo");
775 ic->callback (ic->callback_cls, NULL, NULL, 1);
776 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
777 GNUNET_free (ic);
778 return;
779 }
780 if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END)
781 {
782#if DEBUG_PEERINFO
783 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
784 "Received end of list of peers from peerinfo database\n");
785#endif
786 ic->callback (ic->callback_cls, NULL, NULL, 0);
787 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
788 GNUNET_free (ic);
789 return;
790 }
791 ms = ntohs (msg->size);
792 if ((ms < sizeof (struct InfoMessage)) ||
793 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_PEERINFO_INFO))
794 {
795 GNUNET_break (0);
796 ic->callback (ic->callback_cls, NULL, NULL, 2);
797 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
798 GNUNET_free (ic);
799 return;
800 }
801 im = (const struct InfoMessage *) msg;
802 hello = NULL;
803 if (ms > sizeof (struct InfoMessage) + sizeof (struct GNUNET_MessageHeader))
804 {
805 hello = (const struct GNUNET_HELLO_Message *) &im[1];
806 if (ms != sizeof (struct InfoMessage) + GNUNET_HELLO_size (hello))
807 {
808 GNUNET_break (0);
809 ic->callback (ic->callback_cls, NULL, NULL, 2);
810 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
811 GNUNET_free (ic);
812 return;
813 }
814 }
815#if DEBUG_PEERINFO
816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
817 "Received %u bytes of `%s' information about peer `%s' from PEERINFO database\n",
818 (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello),
819 "HELLO",
820 GNUNET_i2s (&im->peer));
821#endif
822 ic->callback (ic->callback_cls, &im->peer, hello, ntohl (im->trust));
823 GNUNET_CLIENT_receive (ic->client,
824 &info_handler,
825 ic,
826 GNUNET_TIME_absolute_get_remaining (ic->timeout));
827}
828
829
830/**
831 * Call a method for each known matching host and change
832 * its trust value. The method will be invoked once for
833 * each host and then finally once with a NULL pointer.
834 * Note that the last call can be triggered by timeout or
835 * by simply being done; however, the trust argument will
836 * be set to zero if we are done and to 1 if we timed out.
837 *
838 * @param cfg configuration to use
839 * @param sched scheduler to use
840 * @param peer restrict iteration to this peer only (can be NULL)
841 * @param trust_delta how much to change the trust in all matching peers
842 * @param timeout how long to wait until timing out
843 * @param callback the method to call for each peer
844 * @param callback_cls closure for callback
845 * @return NULL on error, otherwise an iterator context
846 */
847struct GNUNET_PEERINFO_IteratorContext *
848GNUNET_PEERINFO_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
849 struct GNUNET_SCHEDULER_Handle *sched,
850 const struct GNUNET_PeerIdentity *peer,
851 int trust_delta,
852 struct GNUNET_TIME_Relative timeout,
853 GNUNET_PEERINFO_Processor callback,
854 void *callback_cls)
855{
856 struct GNUNET_CLIENT_Connection *client;
857 struct ListAllPeersMessage *lapm;
858 struct ListPeerMessage *lpm;
859 struct GNUNET_PEERINFO_IteratorContext *ihc;
860
861 client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg);
862 if (client == NULL)
863 {
864 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
865 _("Could not connect to `%s' service.\n"), "peerinfo");
866 return NULL;
867 }
868#if DEBUG_PEERINFO
869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
870 "Requesting list of peers from peerinfo database\n");
871#endif
872 if (peer == NULL)
873 {
874 ihc = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext) +
875 sizeof (struct ListAllPeersMessage));
876 lapm = (struct ListAllPeersMessage *) &ihc[1];
877 lapm->header.size = htons (sizeof (struct ListAllPeersMessage));
878 lapm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL);
879 lapm->trust_change = htonl (trust_delta);
880 }
881 else
882 {
883 ihc = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext) +
884 sizeof (struct ListPeerMessage));
885 lpm = (struct ListPeerMessage *) &ihc[1];
886 lpm->header.size = htons (sizeof (struct ListPeerMessage));
887 lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET);
888 lpm->trust_change = htonl (trust_delta);
889 memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity));
890 }
891 ihc->client = client;
892 ihc->callback = callback;
893 ihc->callback_cls = callback_cls;
894 ihc->timeout = GNUNET_TIME_relative_to_absolute (timeout);
895 if (GNUNET_OK !=
896 GNUNET_CLIENT_transmit_and_get_response (client,
897 (const struct GNUNET_MessageHeader*) &ihc[1],
898 timeout,
899 GNUNET_YES,
900 &info_handler,
901 ihc))
902 {
903 GNUNET_break (0);
904 GNUNET_CLIENT_disconnect (ihc->client, GNUNET_NO);
905 GNUNET_free (ihc);
906 return NULL;
907 }
908 return ihc;
909}
910
911
912/**
913 * Cancel an iteration over peer information.
914 *
915 * @param ic context of the iterator to cancel
916 */
917void
918GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic)
919{
920 GNUNET_CLIENT_disconnect (ic->client, GNUNET_NO);
921 GNUNET_free (ic);
922}
923
924
925/* end of peerinfo_api.c */ 625/* end of peerinfo_api.c */
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c
index 10ea1fa81..3fa622f50 100644
--- a/src/peerinfo/test_peerinfo_api.c
+++ b/src/peerinfo/test_peerinfo_api.c
@@ -40,7 +40,7 @@ static struct GNUNET_SCHEDULER_Handle *sched;
40 40
41static const struct GNUNET_CONFIGURATION_Handle *cfg; 41static const struct GNUNET_CONFIGURATION_Handle *cfg;
42 42
43static struct GNUNET_PEERINFO_NewIteratorContext *ic; 43static struct GNUNET_PEERINFO_IteratorContext *ic;
44 44
45static struct GNUNET_PEERINFO_Handle *h; 45static struct GNUNET_PEERINFO_Handle *h;
46 46
@@ -93,7 +93,7 @@ add_peer ()
93 memset (&pkey, 32, sizeof (pkey)); 93 memset (&pkey, 32, sizeof (pkey));
94 GNUNET_CRYPTO_hash (&pkey, sizeof (pkey), &pid.hashPubKey); 94 GNUNET_CRYPTO_hash (&pkey, sizeof (pkey), &pid.hashPubKey);
95 h2 = GNUNET_HELLO_create (&pkey, &address_generator, &agc); 95 h2 = GNUNET_HELLO_create (&pkey, &address_generator, &agc);
96 GNUNET_PEERINFO_add_peer_new (h, h2); 96 GNUNET_PEERINFO_add_peer (h, h2);
97 GNUNET_free (h2); 97 GNUNET_free (h2);
98 98
99} 99}
@@ -116,12 +116,12 @@ process (void *cls,
116 /* try again */ 116 /* try again */
117 retries++; 117 retries++;
118 add_peer (); 118 add_peer ();
119 ic = GNUNET_PEERINFO_iterate_new (h, 119 ic = GNUNET_PEERINFO_iterate (h,
120 NULL, 120 NULL,
121 0, 121 0,
122 GNUNET_TIME_relative_multiply 122 GNUNET_TIME_relative_multiply
123 (GNUNET_TIME_UNIT_SECONDS, 15), 123 (GNUNET_TIME_UNIT_SECONDS, 15),
124 &process, cls); 124 &process, cls);
125 return; 125 return;
126 } 126 }
127 GNUNET_assert (peer == NULL); 127 GNUNET_assert (peer == NULL);
@@ -152,14 +152,14 @@ run (void *cls,
152{ 152{
153 sched = s; 153 sched = s;
154 cfg = c; 154 cfg = c;
155 h = GNUNET_PEERINFO_connect (cfg, sched); 155 h = GNUNET_PEERINFO_connect (sched, cfg);
156 add_peer (); 156 add_peer ();
157 ic = GNUNET_PEERINFO_iterate_new (h, 157 ic = GNUNET_PEERINFO_iterate (h,
158 NULL, 158 NULL,
159 0, 159 0,
160 GNUNET_TIME_relative_multiply 160 GNUNET_TIME_relative_multiply
161 (GNUNET_TIME_UNIT_SECONDS, 15), 161 (GNUNET_TIME_UNIT_SECONDS, 15),
162 &process, cls); 162 &process, cls);
163} 163}
164 164
165 165
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index ecf68719b..220879b3b 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -835,6 +835,11 @@ static struct TransportPlugin *plugins;
835static struct GNUNET_SERVER_Handle *server; 835static struct GNUNET_SERVER_Handle *server;
836 836
837/** 837/**
838 * Handle to peerinfo service.
839 */
840static struct GNUNET_PEERINFO_Handle *peerinfo;
841
842/**
838 * All known neighbours and their HELLOs. 843 * All known neighbours and their HELLOs.
839 */ 844 */
840static struct NeighbourList *neighbours; 845static struct NeighbourList *neighbours;
@@ -1775,7 +1780,7 @@ refresh_hello ()
1775 GNUNET_free_non_null (our_hello); 1780 GNUNET_free_non_null (our_hello);
1776 our_hello = hello; 1781 our_hello = hello;
1777 our_hello_version++; 1782 our_hello_version++;
1778 GNUNET_PEERINFO_add_peer (cfg, sched, &my_identity, our_hello); 1783 GNUNET_PEERINFO_add_peer (peerinfo, our_hello);
1779 npos = neighbours; 1784 npos = neighbours;
1780 while (npos != NULL) 1785 while (npos != NULL)
1781 { 1786 {
@@ -2567,7 +2572,7 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer,
2567 &neighbour_timeout_task, n); 2572 &neighbour_timeout_task, n);
2568 if (do_hello) 2573 if (do_hello)
2569 { 2574 {
2570 n->piter = GNUNET_PEERINFO_iterate (cfg, sched, peer, 2575 n->piter = GNUNET_PEERINFO_iterate (peerinfo, peer,
2571 0, GNUNET_TIME_UNIT_FOREVER_REL, 2576 0, GNUNET_TIME_UNIT_FOREVER_REL,
2572 &add_hello_for_peer, n); 2577 &add_hello_for_peer, n);
2573 transmit_to_peer (NULL, NULL, 0, 2578 transmit_to_peer (NULL, NULL, 0,
@@ -3245,8 +3250,7 @@ check_pending_validation (void *cls,
3245 hello = GNUNET_HELLO_create (&ve->publicKey, 3250 hello = GNUNET_HELLO_create (&ve->publicKey,
3246 &add_validated_address, 3251 &add_validated_address,
3247 &avac); 3252 &avac);
3248 GNUNET_PEERINFO_add_peer (cfg, sched, 3253 GNUNET_PEERINFO_add_peer (peerinfo,
3249 &target,
3250 hello); 3254 hello);
3251 GNUNET_free (hello); 3255 GNUNET_free (hello);
3252 } 3256 }
@@ -3596,7 +3600,7 @@ check_hello_validated (void *cls,
3596 plain_hello = GNUNET_HELLO_create (&pk, 3600 plain_hello = GNUNET_HELLO_create (&pk,
3597 NULL, 3601 NULL,
3598 NULL); 3602 NULL);
3599 GNUNET_PEERINFO_add_peer (cfg, sched, &target, plain_hello); 3603 GNUNET_PEERINFO_add_peer (peerinfo, plain_hello);
3600 GNUNET_free (plain_hello); 3604 GNUNET_free (plain_hello);
3601#if DEBUG_TRANSPORT 3605#if DEBUG_TRANSPORT
3602 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3606 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -3732,8 +3736,7 @@ process_hello (struct TransportPlugin *plugin,
3732 chvc); 3736 chvc);
3733 /* finally, check if HELLO was previously validated 3737 /* finally, check if HELLO was previously validated
3734 (continuation will then schedule actual validation) */ 3738 (continuation will then schedule actual validation) */
3735 chvc->piter = GNUNET_PEERINFO_iterate (cfg, 3739 chvc->piter = GNUNET_PEERINFO_iterate (peerinfo,
3736 sched,
3737 &target, 3740 &target,
3738 0, 3741 0,
3739 HELLO_VERIFICATION_TIMEOUT, 3742 HELLO_VERIFICATION_TIMEOUT,
@@ -4788,6 +4791,22 @@ run (void *cls,
4788 return; 4791 return;
4789 } 4792 }
4790 max_connect_per_transport = (uint32_t) tneigh; 4793 max_connect_per_transport = (uint32_t) tneigh;
4794 peerinfo = GNUNET_PEERINFO_connect (sched, cfg);
4795 if (peerinfo == NULL)
4796 {
4797 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4798 _("Could not access PEERINFO service. Exiting.\n"));
4799 GNUNET_SCHEDULER_shutdown (s);
4800 if (stats != NULL)
4801 {
4802 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
4803 stats = NULL;
4804 }
4805 GNUNET_CONTAINER_multihashmap_destroy (validation_map);
4806 validation_map = NULL;
4807 GNUNET_free (keyfile);
4808 return;
4809 }
4791 my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 4810 my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
4792 GNUNET_free (keyfile); 4811 GNUNET_free (keyfile);
4793 if (my_private_key == NULL) 4812 if (my_private_key == NULL)