aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/testing
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_testing.c12
-rw-r--r--src/testing/test_testing_connect.c32
-rw-r--r--src/testing/test_testing_group.c17
-rw-r--r--src/testing/test_testing_group_remote.c22
-rw-r--r--src/testing/test_testing_large_topology.c190
-rw-r--r--src/testing/test_testing_peergroup.c15
-rw-r--r--src/testing/test_testing_reconnect.c32
-rw-r--r--src/testing/test_testing_topology.c208
-rw-r--r--src/testing/test_testing_topology_blacklist.c90
-rw-r--r--src/testing/test_testing_topology_churn.c42
-rw-r--r--src/testing/testing.c484
-rw-r--r--src/testing/testing_group.c973
-rw-r--r--src/testing/testing_peergroup.c221
13 files changed, 1085 insertions, 1253 deletions
diff --git a/src/testing/test_testing.c b/src/testing/test_testing.c
index 88861a156..3e2cd65ee 100644
--- a/src/testing/test_testing.c
+++ b/src/testing/test_testing.c
@@ -59,8 +59,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
59 59
60 60
61static void 61static void
62my_cb (void *cls, 62my_cb (void *cls, const struct GNUNET_PeerIdentity *id,
63 const struct GNUNET_PeerIdentity *id,
64 const struct GNUNET_CONFIGURATION_Handle *cfg, 63 const struct GNUNET_CONFIGURATION_Handle *cfg,
65 struct GNUNET_TESTING_Daemon *d, const char *emsg) 64 struct GNUNET_TESTING_Daemon *d, const char *emsg)
66{ 65{
@@ -74,9 +73,8 @@ my_cb (void *cls,
74 73
75 74
76static void 75static void
77run (void *cls, 76run (void *cls, char *const *args, const char *cfgfile,
78 char *const *args, 77 const struct GNUNET_CONFIGURATION_Handle *cfg)
79 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
80{ 78{
81 struct GNUNET_TESTING_Daemon *d; 79 struct GNUNET_TESTING_Daemon *d;
82 80
@@ -103,8 +101,8 @@ check ()
103 struct GNUNET_GETOPT_CommandLineOption options[] = { 101 struct GNUNET_GETOPT_CommandLineOption options[] = {
104 GNUNET_GETOPT_OPTION_END 102 GNUNET_GETOPT_OPTION_END
105 }; 103 };
106 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 104 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
107 argv, "test-testing", "nohelp", options, &run, &ok); 105 "test-testing", "nohelp", options, &run, &ok);
108 return ok; 106 return ok;
109} 107}
110 108
diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c
index 19e3bb1c0..4fe3a1dd6 100644
--- a/src/testing/test_testing_connect.c
+++ b/src/testing/test_testing_connect.c
@@ -90,8 +90,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
90} 90}
91 91
92static void 92static void
93my_connect_complete (void *cls, 93my_connect_complete (void *cls, const struct GNUNET_PeerIdentity *first,
94 const struct GNUNET_PeerIdentity *first,
95 const struct GNUNET_PeerIdentity *second, 94 const struct GNUNET_PeerIdentity *second,
96 unsigned int distance, 95 unsigned int distance,
97 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 96 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
@@ -105,32 +104,29 @@ my_connect_complete (void *cls,
105 104
106 105
107static void 106static void
108my_cb2 (void *cls, 107my_cb2 (void *cls, const struct GNUNET_PeerIdentity *id,
109 const struct GNUNET_PeerIdentity *id,
110 const struct GNUNET_CONFIGURATION_Handle *cfg, 108 const struct GNUNET_CONFIGURATION_Handle *cfg,
111 struct GNUNET_TESTING_Daemon *d, const char *emsg) 109 struct GNUNET_TESTING_Daemon *d, const char *emsg)
112{ 110{
113 GNUNET_assert (id != NULL); 111 GNUNET_assert (id != NULL);
114#if VERBOSE 112#if VERBOSE
115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n",
116 "Daemon `%s' started.\n", GNUNET_i2s (id)); 114 GNUNET_i2s (id));
117#endif 115#endif
118 GNUNET_TESTING_daemons_connect (d1, d2, 116 GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, CONNECT_ATTEMPTS, GNUNET_YES,
119 TIMEOUT, CONNECT_ATTEMPTS, 117 &my_connect_complete, NULL);
120 GNUNET_YES, &my_connect_complete, NULL);
121} 118}
122 119
123 120
124static void 121static void
125my_cb1 (void *cls, 122my_cb1 (void *cls, const struct GNUNET_PeerIdentity *id,
126 const struct GNUNET_PeerIdentity *id,
127 const struct GNUNET_CONFIGURATION_Handle *cfg, 123 const struct GNUNET_CONFIGURATION_Handle *cfg,
128 struct GNUNET_TESTING_Daemon *d, const char *emsg) 124 struct GNUNET_TESTING_Daemon *d, const char *emsg)
129{ 125{
130 GNUNET_assert (id != NULL); 126 GNUNET_assert (id != NULL);
131#if VERBOSE 127#if VERBOSE
132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n",
133 "Daemon `%s' started.\n", GNUNET_i2s (id)); 129 GNUNET_i2s (id));
134#endif 130#endif
135 d2 = GNUNET_TESTING_daemon_start (c2, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL, 131 d2 = GNUNET_TESTING_daemon_start (c2, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL,
136 NULL, NULL, &my_cb2, NULL); 132 NULL, NULL, &my_cb2, NULL);
@@ -140,9 +136,8 @@ my_cb1 (void *cls,
140 136
141 137
142static void 138static void
143run (void *cls, 139run (void *cls, char *const *args, const char *cfgfile,
144 char *const *args, 140 const struct GNUNET_CONFIGURATION_Handle *cfg)
145 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
146{ 141{
147 ok = 1; 142 ok = 1;
148#if VERBOSE 143#if VERBOSE
@@ -171,9 +166,8 @@ check ()
171 struct GNUNET_GETOPT_CommandLineOption options[] = { 166 struct GNUNET_GETOPT_CommandLineOption options[] = {
172 GNUNET_GETOPT_OPTION_END 167 GNUNET_GETOPT_OPTION_END
173 }; 168 };
174 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 169 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
175 argv, "test-testing-connect", "nohelp", 170 "test-testing-connect", "nohelp", options, &run, &ok);
176 options, &run, &ok);
177 return ok; 171 return ok;
178} 172}
179 173
diff --git a/src/testing/test_testing_group.c b/src/testing/test_testing_group.c
index 88893f45d..f5df45b19 100644
--- a/src/testing/test_testing_group.c
+++ b/src/testing/test_testing_group.c
@@ -65,8 +65,7 @@ shutdown_callback (void *cls, const char *emsg)
65 65
66 66
67static void 67static void
68my_cb (void *cls, 68my_cb (void *cls, const struct GNUNET_PeerIdentity *id,
69 const struct GNUNET_PeerIdentity *id,
70 const struct GNUNET_CONFIGURATION_Handle *cfg, 69 const struct GNUNET_CONFIGURATION_Handle *cfg,
71 struct GNUNET_TESTING_Daemon *d, const char *emsg) 70 struct GNUNET_TESTING_Daemon *d, const char *emsg)
72{ 71{
@@ -105,9 +104,8 @@ my_cb (void *cls,
105 104
106 105
107static void 106static void
108run (void *cls, 107run (void *cls, char *const *args, const char *cfgfile,
109 char *const *args, 108 const struct GNUNET_CONFIGURATION_Handle *cfg)
110 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
111{ 109{
112 ok = 1; 110 ok = 1;
113#if VERBOSE 111#if VERBOSE
@@ -117,9 +115,8 @@ run (void *cls,
117 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ 115 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */
118 peers_left, /* Number of outstanding connections */ 116 peers_left, /* Number of outstanding connections */
119 peers_left, /* Number of parallel ssh connections, or peers being started at once */ 117 peers_left, /* Number of parallel ssh connections, or peers being started at once */
120 TIMEOUT, 118 TIMEOUT, NULL, NULL, &my_cb, NULL, NULL,
121 NULL, NULL, 119 NULL, NULL);
122 &my_cb, NULL, NULL, NULL, NULL);
123 GNUNET_assert (pg != NULL); 120 GNUNET_assert (pg != NULL);
124} 121}
125 122
@@ -137,8 +134,8 @@ check ()
137 struct GNUNET_GETOPT_CommandLineOption options[] = { 134 struct GNUNET_GETOPT_CommandLineOption options[] = {
138 GNUNET_GETOPT_OPTION_END 135 GNUNET_GETOPT_OPTION_END
139 }; 136 };
140 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 137 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
141 argv, "test-testing-group", "nohelp", options, &run, &ok); 138 "test-testing-group", "nohelp", options, &run, &ok);
142 return ok; 139 return ok;
143} 140}
144 141
diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c
index d43e7ed57..e300f95e3 100644
--- a/src/testing/test_testing_group_remote.c
+++ b/src/testing/test_testing_group_remote.c
@@ -72,8 +72,7 @@ shutdown_callback (void *cls, const char *emsg)
72 72
73 73
74static void 74static void
75my_cb (void *cls, 75my_cb (void *cls, const struct GNUNET_PeerIdentity *id,
76 const struct GNUNET_PeerIdentity *id,
77 const struct GNUNET_CONFIGURATION_Handle *cfg, 76 const struct GNUNET_CONFIGURATION_Handle *cfg,
78 struct GNUNET_TESTING_Daemon *d, const char *emsg) 77 struct GNUNET_TESTING_Daemon *d, const char *emsg)
79{ 78{
@@ -98,9 +97,8 @@ my_cb (void *cls,
98 97
99 98
100static void 99static void
101run (void *cls, 100run (void *cls, char *const *args, const char *cfgfile,
102 char *const *args, 101 const struct GNUNET_CONFIGURATION_Handle *cfg)
103 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
104{ 102{
105 struct GNUNET_TESTING_Host *hosts; 103 struct GNUNET_TESTING_Host *hosts;
106 struct GNUNET_TESTING_Host *hostpos; 104 struct GNUNET_TESTING_Host *hostpos;
@@ -133,8 +131,9 @@ run (void *cls,
133 if (hostfile != NULL) 131 if (hostfile != NULL)
134 { 132 {
135 if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) 133 if (GNUNET_OK != GNUNET_DISK_file_test (hostfile))
136 GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ 134 GNUNET_DISK_fn_write (hostfile, NULL, 0,
137 | GNUNET_DISK_PERM_USER_WRITE); 135 GNUNET_DISK_PERM_USER_READ |
136 GNUNET_DISK_PERM_USER_WRITE);
138 if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) 137 if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0))
139 { 138 {
140 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 139 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -202,9 +201,8 @@ run (void *cls,
202 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ 201 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */
203 peers_left, /* Number of outstanding connections */ 202 peers_left, /* Number of outstanding connections */
204 peers_left, /* Number of parallel ssh connections, or peers being started at once */ 203 peers_left, /* Number of parallel ssh connections, or peers being started at once */
205 TIMEOUT, 204 TIMEOUT, NULL, NULL, &my_cb, NULL, NULL,
206 NULL, 205 NULL, hosts);
207 NULL, &my_cb, NULL, NULL, NULL, hosts);
208 hostpos = hosts; 206 hostpos = hosts;
209 while (hostpos != NULL) 207 while (hostpos != NULL)
210 { 208 {
@@ -233,8 +231,8 @@ check ()
233 struct GNUNET_GETOPT_CommandLineOption options[] = { 231 struct GNUNET_GETOPT_CommandLineOption options[] = {
234 GNUNET_GETOPT_OPTION_END 232 GNUNET_GETOPT_OPTION_END
235 }; 233 };
236 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 234 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
237 argv, "test-testing-group", "nohelp", options, &run, &ok); 235 "test-testing-group", "nohelp", options, &run, &ok);
238 return ok; 236 return ok;
239} 237}
240 238
diff --git a/src/testing/test_testing_large_topology.c b/src/testing/test_testing_large_topology.c
index 62922e9e8..9581dc9b2 100644
--- a/src/testing/test_testing_large_topology.c
+++ b/src/testing/test_testing_large_topology.c
@@ -185,9 +185,9 @@ gather_log_data ()
185 185
186 GNUNET_asprintf (&peer_number, "%llu", num_peers); 186 GNUNET_asprintf (&peer_number, "%llu", num_peers);
187 GNUNET_asprintf (&connect_number, "%llu", expected_connections); 187 GNUNET_asprintf (&connect_number, "%llu", expected_connections);
188 mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", 188 mem_process =
189 "memsize.pl", "totals.txt", 189 GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", "memsize.pl",
190 peer_number, connect_number, NULL); 190 "totals.txt", peer_number, connect_number, NULL);
191 GNUNET_OS_process_wait (mem_process); 191 GNUNET_OS_process_wait (mem_process);
192 GNUNET_OS_process_close (mem_process); 192 GNUNET_OS_process_close (mem_process);
193 mem_process = NULL; 193 mem_process = NULL;
@@ -257,15 +257,13 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
257 257
258 /* Disconnect from the respective cores */ 258 /* Disconnect from the respective cores */
259#if VERBOSE > 1 259#if VERBOSE > 1
260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n",
261 "Disconnecting from peer 1 `%4s'\n",
262 GNUNET_i2s (&pos->peer1->id)); 261 GNUNET_i2s (&pos->peer1->id));
263#endif 262#endif
264 if (pos->peer1handle != NULL) 263 if (pos->peer1handle != NULL)
265 GNUNET_CORE_disconnect (pos->peer1handle); 264 GNUNET_CORE_disconnect (pos->peer1handle);
266#if VERBOSE > 1 265#if VERBOSE > 1
267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n",
268 "Disconnecting from peer 2 `%4s'\n",
269 GNUNET_i2s (&pos->peer2->id)); 267 GNUNET_i2s (&pos->peer2->id));
270#endif 268#endif
271 if (pos->peer2handle != NULL) 269 if (pos->peer2handle != NULL)
@@ -280,8 +278,7 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
280 278
281 279
282static void 280static void
283topology_cb (void *cls, 281topology_cb (void *cls, const struct GNUNET_PeerIdentity *first,
284 const struct GNUNET_PeerIdentity *first,
285 const struct GNUNET_PeerIdentity *second, const char *emsg) 282 const struct GNUNET_PeerIdentity *second, const char *emsg)
286{ 283{
287 FILE *outfile = cls; 284 FILE *outfile = cls;
@@ -310,8 +307,7 @@ topology_cb (void *cls,
310} 307}
311 308
312static int 309static int
313process_mtype (void *cls, 310process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
314 const struct GNUNET_PeerIdentity *peer,
315 const struct GNUNET_MessageHeader *message, 311 const struct GNUNET_MessageHeader *message,
316 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 312 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
317{ 313{
@@ -330,8 +326,8 @@ process_mtype (void *cls,
330 fprintf (stdout, "0%%"); 326 fprintf (stdout, "0%%");
331 else 327 else
332 fprintf (stdout, "%d%%", 328 fprintf (stdout, "%d%%",
333 (int) (((float) total_messages_received / 329 (int) (((float) total_messages_received / expected_messages) *
334 expected_messages) * 100)); 330 100));
335 331
336 } 332 }
337 else if (total_messages_received % dotnum == 0) 333 else if (total_messages_received % dotnum == 0)
@@ -462,8 +458,7 @@ static struct GNUNET_CORE_MessageHandler handlers[] = {
462}; 458};
463 459
464static void 460static void
465init_notify_peer2 (void *cls, 461init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server,
466 struct GNUNET_CORE_Handle *server,
467 const struct GNUNET_PeerIdentity *my_identity, 462 const struct GNUNET_PeerIdentity *my_identity,
468 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 463 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
469 *publicKey) 464 *publicKey)
@@ -481,13 +476,11 @@ init_notify_peer2 (void *cls,
481 GNUNET_i2s (my_identity), 476 GNUNET_i2s (my_identity),
482 GNUNET_h2s (&pos->peer1->id.hashPubKey)); 477 GNUNET_h2s (&pos->peer1->id.hashPubKey));
483#endif 478#endif
484 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 479 if (NULL ==
485 0, 480 GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 0, timeout,
486 timeout, 481 &pos->peer2->id,
487 &pos->peer2->id, 482 sizeof (struct GNUNET_TestMessage),
488 sizeof (struct 483 &transmit_ready, pos))
489 GNUNET_TestMessage),
490 &transmit_ready, pos))
491 { 484 {
492 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 485 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
493 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", 486 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
@@ -509,9 +502,7 @@ init_notify_peer2 (void *cls,
509 * @param atsi performance data for the connection 502 * @param atsi performance data for the connection
510 */ 503 */
511static void 504static void
512connect_notify_peers (void *cls, 505connect_notify_peers (void *cls, const struct GNUNET_PeerIdentity *peer,
513 const struct
514 GNUNET_PeerIdentity *peer,
515 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 506 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
516{ 507{
517 struct TestMessageContext *pos = cls; 508 struct TestMessageContext *pos = cls;
@@ -536,13 +527,11 @@ connect_notify_peers (void *cls,
536 GNUNET_i2s (&pos->peer2->id), 527 GNUNET_i2s (&pos->peer2->id),
537 GNUNET_h2s (&pos->peer1->id.hashPubKey)); 528 GNUNET_h2s (&pos->peer1->id.hashPubKey));
538#endif 529#endif
539 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 530 if (NULL ==
540 0, 531 GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 0, timeout,
541 timeout, 532 &pos->peer2->id,
542 &pos->peer2->id, 533 sizeof (struct GNUNET_TestMessage),
543 sizeof (struct 534 &transmit_ready, pos))
544 GNUNET_TestMessage),
545 &transmit_ready, pos))
546 { 535 {
547 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
548 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", 537 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
@@ -557,8 +546,7 @@ connect_notify_peers (void *cls,
557} 546}
558 547
559static void 548static void
560init_notify_peer1 (void *cls, 549init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server,
561 struct GNUNET_CORE_Handle *server,
562 const struct GNUNET_PeerIdentity *my_identity, 550 const struct GNUNET_PeerIdentity *my_identity,
563 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 551 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
564 *publicKey) 552 *publicKey)
@@ -576,15 +564,10 @@ init_notify_peer1 (void *cls,
576 /* 564 /*
577 * Connect to the receiving peer 565 * Connect to the receiving peer
578 */ 566 */
579 pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, 567 pos->peer2handle =
580 1, 568 GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2, NULL,
581 pos, 569 NULL, NULL, NULL, GNUNET_YES, NULL, GNUNET_YES,
582 &init_notify_peer2, 570 handlers);
583 NULL,
584 NULL,
585 NULL, NULL,
586 GNUNET_YES, NULL, GNUNET_YES,
587 handlers);
588 571
589} 572}
590 573
@@ -604,9 +587,9 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
604 587
605 if (die_task == GNUNET_SCHEDULER_NO_TASK) 588 if (die_task == GNUNET_SCHEDULER_NO_TASK)
606 { 589 {
607 die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, 590 die_task =
608 &end_badly, 591 GNUNET_SCHEDULER_add_delayed (test_timeout, &end_badly,
609 "from send test messages (timeout)"); 592 "from send test messages (timeout)");
610 } 593 }
611 594
612 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) 595 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)
@@ -620,15 +603,10 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
620 /* 603 /*
621 * Connect to the sending peer 604 * Connect to the sending peer
622 */ 605 */
623 pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, 606 pos->peer1handle =
624 1, 607 GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1,
625 pos, 608 &connect_notify_peers, NULL, NULL, NULL, GNUNET_NO,
626 &init_notify_peer1, 609 NULL, GNUNET_NO, no_handlers);
627 &connect_notify_peers, NULL,
628 NULL,
629 NULL,
630 GNUNET_NO, NULL, GNUNET_NO,
631 no_handlers);
632 610
633 GNUNET_assert (pos->peer1handle != NULL); 611 GNUNET_assert (pos->peer1handle != NULL);
634 612
@@ -646,10 +624,8 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
646 624
647 625
648void 626void
649topology_callback (void *cls, 627topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
650 const struct GNUNET_PeerIdentity *first, 628 const struct GNUNET_PeerIdentity *second, uint32_t distance,
651 const struct GNUNET_PeerIdentity *second,
652 uint32_t distance,
653 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 629 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
654 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 630 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
655 struct GNUNET_TESTING_Daemon *first_daemon, 631 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -667,8 +643,8 @@ topology_callback (void *cls,
667 fprintf (stdout, "0%%"); 643 fprintf (stdout, "0%%");
668 else 644 else
669 fprintf (stdout, "%d%%", 645 fprintf (stdout, "%d%%",
670 (int) (((float) total_connections / 646 (int) (((float) total_connections / expected_connections) *
671 expected_connections) * 100)); 647 100));
672 648
673 } 649 }
674 else if (total_connections % dotnum == 0) 650 else if (total_connections % dotnum == 0)
@@ -787,12 +763,11 @@ connect_topology ()
787 GNUNET_TESTING_connect_topology (pg, connection_topology, 763 GNUNET_TESTING_connect_topology (pg, connection_topology,
788 connect_topology_option, 764 connect_topology_option,
789 connect_topology_option_modifier, 765 connect_topology_option_modifier,
790 connect_timeout, 766 connect_timeout, connect_attempts,
791 connect_attempts,
792 &topology_creation_finished, NULL); 767 &topology_creation_finished, NULL);
793#if VERBOSE > 1 768#if VERBOSE > 1
794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 769 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n",
795 "Have %d expected connections\n", expected_connections); 770 expected_connections);
796#endif 771#endif
797 } 772 }
798 773
@@ -804,9 +779,9 @@ connect_topology ()
804 "from connect topology (bad return)"); 779 "from connect topology (bad return)");
805 } 780 }
806 781
807 die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, 782 die_task =
808 &end_badly, 783 GNUNET_SCHEDULER_add_delayed (test_timeout, &end_badly,
809 "from connect topology (timeout)"); 784 "from connect topology (timeout)");
810 modnum = expected_connections / 4; 785 modnum = expected_connections / 4;
811 dotnum = (expected_connections / 50) + 1; 786 dotnum = (expected_connections / 50) + 1;
812#if VERBOSE 787#if VERBOSE
@@ -836,15 +811,14 @@ create_topology ()
836 "from create topology (bad return)"); 811 "from create topology (bad return)");
837 } 812 }
838 GNUNET_SCHEDULER_cancel (die_task); 813 GNUNET_SCHEDULER_cancel (die_task);
839 die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, 814 die_task =
840 &end_badly, 815 GNUNET_SCHEDULER_add_delayed (test_timeout, &end_badly,
841 "from continue startup (timeout)"); 816 "from continue startup (timeout)");
842} 817}
843 818
844 819
845static void 820static void
846peers_started_callback (void *cls, 821peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
847 const struct GNUNET_PeerIdentity *id,
848 const struct GNUNET_CONFIGURATION_Handle *cfg, 822 const struct GNUNET_CONFIGURATION_Handle *cfg,
849 struct GNUNET_TESTING_Daemon *d, const char *emsg) 823 struct GNUNET_TESTING_Daemon *d, const char *emsg)
850{ 824{
@@ -888,9 +862,9 @@ peers_started_callback (void *cls,
888 GNUNET_SCHEDULER_cancel (die_task); 862 GNUNET_SCHEDULER_cancel (die_task);
889 /* Set up task in case topology creation doesn't finish 863 /* Set up task in case topology creation doesn't finish
890 * within a reasonable amount of time */ 864 * within a reasonable amount of time */
891 die_task = GNUNET_SCHEDULER_add_delayed (timeout, 865 die_task =
892 &end_badly, 866 GNUNET_SCHEDULER_add_delayed (timeout, &end_badly,
893 "from peers_started_callback"); 867 "from peers_started_callback");
894#if DELAY_FOR_LOGGING 868#if DELAY_FOR_LOGGING
895 fprintf (stdout, "Connecting topology in 10 seconds\n"); 869 fprintf (stdout, "Connecting topology in 10 seconds\n");
896 gather_log_data (); 870 gather_log_data ();
@@ -913,8 +887,7 @@ peers_started_callback (void *cls,
913 * @param emsg non-null on failure 887 * @param emsg non-null on failure
914 */ 888 */
915void 889void
916hostkey_callback (void *cls, 890hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
917 const struct GNUNET_PeerIdentity *id,
918 struct GNUNET_TESTING_Daemon *d, const char *emsg) 891 struct GNUNET_TESTING_Daemon *d, const char *emsg)
919{ 892{
920 if (emsg != NULL) 893 if (emsg != NULL)
@@ -925,8 +898,8 @@ hostkey_callback (void *cls,
925 898
926#if VERBOSE > 1 899#if VERBOSE > 1
927 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
928 "Hostkey (%d/%d) created for peer `%s'\n", 901 "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left,
929 num_peers - peers_left, num_peers, GNUNET_i2s (id)); 902 num_peers, GNUNET_i2s (id));
930#endif 903#endif
931 904
932#if VERBOSE 905#if VERBOSE
@@ -956,18 +929,17 @@ hostkey_callback (void *cls,
956 GNUNET_SCHEDULER_cancel (die_task); 929 GNUNET_SCHEDULER_cancel (die_task);
957 /* Set up task in case topology creation doesn't finish 930 /* Set up task in case topology creation doesn't finish
958 * within a reasonable amount of time */ 931 * within a reasonable amount of time */
959 die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, 932 die_task =
960 &end_badly, 933 GNUNET_SCHEDULER_add_delayed (test_timeout, &end_badly,
961 "from create_topology"); 934 "from create_topology");
962 GNUNET_SCHEDULER_add_now (&create_topology, NULL); 935 GNUNET_SCHEDULER_add_now (&create_topology, NULL);
963 ok = 0; 936 ok = 0;
964 } 937 }
965} 938}
966 939
967static void 940static void
968run (void *cls, 941run (void *cls, char *const *args, const char *cfgfile,
969 char *const *args, 942 const struct GNUNET_CONFIGURATION_Handle *cfg)
970 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
971{ 943{
972 char *topology_str; 944 char *topology_str;
973 char *connect_topology_str; 945 char *connect_topology_str;
@@ -999,8 +971,8 @@ run (void *cls,
999 971
1000 if ((GNUNET_YES == 972 if ((GNUNET_YES ==
1001 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", 973 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology",
1002 &topology_str)) 974 &topology_str)) &&
1003 && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) 975 (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str)))
1004 { 976 {
1005 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 977 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1006 "Invalid topology `%s' given for section %s option %s\n", 978 "Invalid topology `%s' given for section %s option %s\n",
@@ -1011,10 +983,10 @@ run (void *cls,
1011 if ((GNUNET_YES == 983 if ((GNUNET_YES ==
1012 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 984 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
1013 "connect_topology", 985 "connect_topology",
1014 &connect_topology_str)) 986 &connect_topology_str)) &&
1015 && (GNUNET_NO == 987 (GNUNET_NO ==
1016 GNUNET_TESTING_topology_get (&connection_topology, 988 GNUNET_TESTING_topology_get (&connection_topology,
1017 connect_topology_str))) 989 connect_topology_str)))
1018 { 990 {
1019 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 991 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1020 "Invalid connect topology `%s' given for section %s option %s\n", 992 "Invalid connect topology `%s' given for section %s option %s\n",
@@ -1024,10 +996,10 @@ run (void *cls,
1024 if ((GNUNET_YES == 996 if ((GNUNET_YES ==
1025 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 997 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
1026 "connect_topology_option", 998 "connect_topology_option",
1027 &connect_topology_option_str)) 999 &connect_topology_option_str)) &&
1028 && (GNUNET_NO == 1000 (GNUNET_NO ==
1029 GNUNET_TESTING_topology_option_get (&connect_topology_option, 1001 GNUNET_TESTING_topology_option_get (&connect_topology_option,
1030 connect_topology_option_str))) 1002 connect_topology_option_str)))
1031 { 1003 {
1032 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1004 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1033 "Invalid connect topology option `%s' given for section %s option %s\n", 1005 "Invalid connect topology option `%s' given for section %s option %s\n",
@@ -1063,10 +1035,10 @@ run (void *cls,
1063 if ((GNUNET_YES == 1035 if ((GNUNET_YES ==
1064 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 1036 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
1065 "blacklist_topology", 1037 "blacklist_topology",
1066 &blacklist_topology_str)) 1038 &blacklist_topology_str)) &&
1067 && (GNUNET_NO == 1039 (GNUNET_NO ==
1068 GNUNET_TESTING_topology_get (&blacklist_topology, 1040 GNUNET_TESTING_topology_get (&blacklist_topology,
1069 blacklist_topology_str))) 1041 blacklist_topology_str)))
1070 { 1042 {
1071 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1043 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1072 "Invalid topology `%s' given for section %s option %s\n", 1044 "Invalid topology `%s' given for section %s option %s\n",
@@ -1135,18 +1107,13 @@ run (void *cls,
1135#endif 1107#endif
1136 /* Set up a task to end testing if peer start fails */ 1108 /* Set up a task to end testing if peer start fails */
1137 die_task = 1109 die_task =
1138 GNUNET_SCHEDULER_add_delayed (timeout, 1110 GNUNET_SCHEDULER_add_delayed (timeout, &end_badly,
1139 &end_badly,
1140 "didn't generate all hostkeys within a reasonable amount of time!!!"); 1111 "didn't generate all hostkeys within a reasonable amount of time!!!");
1141 1112
1142 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); 1113 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
1143 pg = GNUNET_TESTING_daemons_start (cfg, 1114 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left / 2,
1144 peers_left, 1115 peers_left, timeout, &hostkey_callback,
1145 peers_left / 2, 1116 NULL, &peers_started_callback, NULL,
1146 peers_left,
1147 timeout,
1148 &hostkey_callback, NULL,
1149 &peers_started_callback, NULL,
1150 &topology_callback, NULL, NULL); 1117 &topology_callback, NULL, NULL);
1151 1118
1152} 1119}
@@ -1173,8 +1140,9 @@ check ()
1173 struct GNUNET_GETOPT_CommandLineOption options[] = { 1140 struct GNUNET_GETOPT_CommandLineOption options[] = {
1174 GNUNET_GETOPT_OPTION_END 1141 GNUNET_GETOPT_OPTION_END
1175 }; 1142 };
1176 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 1143 ret =
1177 argv, binary_name, "nohelp", options, &run, &ok); 1144 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
1145 binary_name, "nohelp", options, &run, &ok);
1178 if (ret != GNUNET_OK) 1146 if (ret != GNUNET_OK)
1179 { 1147 {
1180 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1148 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
diff --git a/src/testing/test_testing_peergroup.c b/src/testing/test_testing_peergroup.c
index f06864036..061a0ca75 100644
--- a/src/testing/test_testing_peergroup.c
+++ b/src/testing/test_testing_peergroup.c
@@ -99,9 +99,8 @@ my_cb (void *cls, const char *emsg)
99 99
100 100
101static void 101static void
102run (void *cls, 102run (void *cls, char *const *args, const char *cfgfile,
103 char *const *args, 103 const struct GNUNET_CONFIGURATION_Handle *cfg)
104 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
105{ 104{
106 struct GNUNET_CONFIGURATION_Handle *testing_cfg; 105 struct GNUNET_CONFIGURATION_Handle *testing_cfg;
107 106
@@ -114,9 +113,8 @@ run (void *cls,
114 "use_progressbars", "YES"); 113 "use_progressbars", "YES");
115#endif 114#endif
116 peers_left = NUM_PEERS; 115 peers_left = NUM_PEERS;
117 pg = GNUNET_TESTING_peergroup_start (testing_cfg, 116 pg = GNUNET_TESTING_peergroup_start (testing_cfg, peers_left, TIMEOUT, NULL,
118 peers_left, 117 &my_cb, NULL, NULL);
119 TIMEOUT, NULL, &my_cb, NULL, NULL);
120 GNUNET_assert (pg != NULL); 118 GNUNET_assert (pg != NULL);
121} 119}
122 120
@@ -134,9 +132,8 @@ check ()
134 struct GNUNET_GETOPT_CommandLineOption options[] = { 132 struct GNUNET_GETOPT_CommandLineOption options[] = {
135 GNUNET_GETOPT_OPTION_END 133 GNUNET_GETOPT_OPTION_END
136 }; 134 };
137 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 135 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
138 argv, "test-testing-peergroup", "nohelp", 136 "test-testing-peergroup", "nohelp", options, &run, &ok);
139 options, &run, &ok);
140 return ok; 137 return ok;
141} 138}
142 139
diff --git a/src/testing/test_testing_reconnect.c b/src/testing/test_testing_reconnect.c
index 1e028779f..480bafdc6 100644
--- a/src/testing/test_testing_reconnect.c
+++ b/src/testing/test_testing_reconnect.c
@@ -113,8 +113,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
113 113
114 114
115static void 115static void
116my_connect_complete (void *cls, 116my_connect_complete (void *cls, const struct GNUNET_PeerIdentity *first,
117 const struct GNUNET_PeerIdentity *first,
118 const struct GNUNET_PeerIdentity *second, 117 const struct GNUNET_PeerIdentity *second,
119 unsigned int distance, 118 unsigned int distance,
120 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 119 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
@@ -134,32 +133,29 @@ my_connect_complete (void *cls,
134 133
135 134
136static void 135static void
137my_cb2 (void *cls, 136my_cb2 (void *cls, const struct GNUNET_PeerIdentity *id,
138 const struct GNUNET_PeerIdentity *id,
139 const struct GNUNET_CONFIGURATION_Handle *cfg, 137 const struct GNUNET_CONFIGURATION_Handle *cfg,
140 struct GNUNET_TESTING_Daemon *d, const char *emsg) 138 struct GNUNET_TESTING_Daemon *d, const char *emsg)
141{ 139{
142 GNUNET_assert (id != NULL); 140 GNUNET_assert (id != NULL);
143#if VERBOSE 141#if VERBOSE
144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 142 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n",
145 "Daemon `%s' started.\n", GNUNET_i2s (id)); 143 GNUNET_i2s (id));
146#endif 144#endif
147 GNUNET_TESTING_daemons_connect (d1, d2, 145 GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, CONNECT_ATTEMPTS, GNUNET_YES,
148 TIMEOUT, CONNECT_ATTEMPTS, 146 &my_connect_complete, NULL);
149 GNUNET_YES, &my_connect_complete, NULL);
150} 147}
151 148
152 149
153static void 150static void
154my_cb1 (void *cls, 151my_cb1 (void *cls, const struct GNUNET_PeerIdentity *id,
155 const struct GNUNET_PeerIdentity *id,
156 const struct GNUNET_CONFIGURATION_Handle *cfg, 152 const struct GNUNET_CONFIGURATION_Handle *cfg,
157 struct GNUNET_TESTING_Daemon *d, const char *emsg) 153 struct GNUNET_TESTING_Daemon *d, const char *emsg)
158{ 154{
159 GNUNET_assert (id != NULL); 155 GNUNET_assert (id != NULL);
160#if VERBOSE 156#if VERBOSE
161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n",
162 "Daemon `%s' started.\n", GNUNET_i2s (id)); 158 GNUNET_i2s (id));
163#endif 159#endif
164 d2 = GNUNET_TESTING_daemon_start (c2, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL, 160 d2 = GNUNET_TESTING_daemon_start (c2, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL,
165 NULL, NULL, &my_cb2, NULL); 161 NULL, NULL, &my_cb2, NULL);
@@ -168,9 +164,8 @@ my_cb1 (void *cls,
168 164
169 165
170static void 166static void
171run (void *cls, 167run (void *cls, char *const *args, const char *cfgfile,
172 char *const *args, 168 const struct GNUNET_CONFIGURATION_Handle *cfg)
173 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
174{ 169{
175 ok = 1; 170 ok = 1;
176#if VERBOSE 171#if VERBOSE
@@ -206,9 +201,8 @@ check ()
206 struct GNUNET_GETOPT_CommandLineOption options[] = { 201 struct GNUNET_GETOPT_CommandLineOption options[] = {
207 GNUNET_GETOPT_OPTION_END 202 GNUNET_GETOPT_OPTION_END
208 }; 203 };
209 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 204 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
210 argv, "test-testing-reconnect", "nohelp", 205 "test-testing-reconnect", "nohelp", options, &run, &ok);
211 options, &run, &ok);
212 return ok; 206 return ok;
213} 207}
214 208
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index 73b49e469..27ad0a24c 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -193,9 +193,9 @@ gather_log_data ()
193 193
194 GNUNET_asprintf (&peer_number, "%llu", num_peers); 194 GNUNET_asprintf (&peer_number, "%llu", num_peers);
195 GNUNET_asprintf (&connect_number, "%llu", expected_connections); 195 GNUNET_asprintf (&connect_number, "%llu", expected_connections);
196 mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", 196 mem_process =
197 "memsize.pl", "totals.txt", 197 GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", "memsize.pl",
198 peer_number, connect_number, NULL); 198 "totals.txt", peer_number, connect_number, NULL);
199 GNUNET_OS_process_wait (mem_process); 199 GNUNET_OS_process_wait (mem_process);
200 GNUNET_OS_process_close (mem_process); 200 GNUNET_OS_process_close (mem_process);
201 mem_process = NULL; 201 mem_process = NULL;
@@ -265,15 +265,13 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
265 265
266 /* Disconnect from the respective cores */ 266 /* Disconnect from the respective cores */
267#if VERBOSE > 1 267#if VERBOSE > 1
268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n",
269 "Disconnecting from peer 1 `%4s'\n",
270 GNUNET_i2s (&pos->peer1->id)); 269 GNUNET_i2s (&pos->peer1->id));
271#endif 270#endif
272 if (pos->peer1handle != NULL) 271 if (pos->peer1handle != NULL)
273 GNUNET_CORE_disconnect (pos->peer1handle); 272 GNUNET_CORE_disconnect (pos->peer1handle);
274#if VERBOSE > 1 273#if VERBOSE > 1
275 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 274 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n",
276 "Disconnecting from peer 2 `%4s'\n",
277 GNUNET_i2s (&pos->peer2->id)); 275 GNUNET_i2s (&pos->peer2->id));
278#endif 276#endif
279 if (pos->peer2handle != NULL) 277 if (pos->peer2handle != NULL)
@@ -305,20 +303,18 @@ stats_finished (void *cls, int result)
305 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 303 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
306 */ 304 */
307static int 305static int
308stats_print (void *cls, 306stats_print (void *cls, const struct GNUNET_PeerIdentity *peer,
309 const struct GNUNET_PeerIdentity *peer, 307 const char *subsystem, const char *name, uint64_t value,
310 const char *subsystem, 308 int is_persistent)
311 const char *name, uint64_t value, int is_persistent)
312{ 309{
313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s:%s -- %llu\n", 310 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s:%s -- %llu\n", GNUNET_i2s (peer),
314 GNUNET_i2s (peer), subsystem, name, value); 311 subsystem, name, value);
315 return GNUNET_OK; 312 return GNUNET_OK;
316} 313}
317#endif 314#endif
318 315
319static void 316static void
320topology_cb (void *cls, 317topology_cb (void *cls, const struct GNUNET_PeerIdentity *first,
321 const struct GNUNET_PeerIdentity *first,
322 const struct GNUNET_PeerIdentity *second, const char *emsg) 318 const struct GNUNET_PeerIdentity *second, const char *emsg)
323{ 319{
324 FILE *outfile = cls; 320 FILE *outfile = cls;
@@ -350,8 +346,7 @@ topology_cb (void *cls,
350} 346}
351 347
352static int 348static int
353process_mtype (void *cls, 349process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
354 const struct GNUNET_PeerIdentity *peer,
355 const struct GNUNET_MessageHeader *message, 350 const struct GNUNET_MessageHeader *message,
356 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 351 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
357{ 352{
@@ -370,8 +365,8 @@ process_mtype (void *cls,
370 fprintf (stdout, "0%%"); 365 fprintf (stdout, "0%%");
371 else 366 else
372 fprintf (stdout, "%d%%", 367 fprintf (stdout, "%d%%",
373 (int) (((float) total_messages_received / 368 (int) (((float) total_messages_received / expected_messages) *
374 expected_messages) * 100)); 369 100));
375 370
376 } 371 }
377 else if (total_messages_received % dotnum == 0) 372 else if (total_messages_received % dotnum == 0)
@@ -502,8 +497,7 @@ static struct GNUNET_CORE_MessageHandler handlers[] = {
502}; 497};
503 498
504static void 499static void
505init_notify_peer2 (void *cls, 500init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server,
506 struct GNUNET_CORE_Handle *server,
507 const struct GNUNET_PeerIdentity *my_identity, 501 const struct GNUNET_PeerIdentity *my_identity,
508 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 502 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
509 *publicKey) 503 *publicKey)
@@ -521,14 +515,11 @@ init_notify_peer2 (void *cls,
521 GNUNET_i2s (my_identity), 515 GNUNET_i2s (my_identity),
522 GNUNET_h2s (&pos->peer1->id.hashPubKey)); 516 GNUNET_h2s (&pos->peer1->id.hashPubKey));
523#endif 517#endif
524 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 518 if (NULL ==
525 GNUNET_YES, 519 GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0,
526 0, 520 TIMEOUT, &pos->peer2->id,
527 TIMEOUT, 521 sizeof (struct GNUNET_TestMessage),
528 &pos->peer2->id, 522 &transmit_ready, pos))
529 sizeof (struct
530 GNUNET_TestMessage),
531 &transmit_ready, pos))
532 { 523 {
533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 524 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
534 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", 525 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
@@ -550,9 +541,7 @@ init_notify_peer2 (void *cls,
550 * @param atsi performance data for the connection 541 * @param atsi performance data for the connection
551 */ 542 */
552static void 543static void
553connect_notify_peers (void *cls, 544connect_notify_peers (void *cls, const struct GNUNET_PeerIdentity *peer,
554 const struct
555 GNUNET_PeerIdentity *peer,
556 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 545 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
557{ 546{
558 struct TestMessageContext *pos = cls; 547 struct TestMessageContext *pos = cls;
@@ -577,14 +566,11 @@ connect_notify_peers (void *cls,
577 GNUNET_i2s (&pos->peer2->id), 566 GNUNET_i2s (&pos->peer2->id),
578 GNUNET_h2s (&pos->peer1->id.hashPubKey)); 567 GNUNET_h2s (&pos->peer1->id.hashPubKey));
579#endif 568#endif
580 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 569 if (NULL ==
581 GNUNET_YES, 570 GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0,
582 0, 571 TIMEOUT, &pos->peer2->id,
583 TIMEOUT, 572 sizeof (struct GNUNET_TestMessage),
584 &pos->peer2->id, 573 &transmit_ready, pos))
585 sizeof (struct
586 GNUNET_TestMessage),
587 &transmit_ready, pos))
588 { 574 {
589 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 575 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
590 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", 576 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
@@ -599,8 +585,7 @@ connect_notify_peers (void *cls,
599} 585}
600 586
601static void 587static void
602init_notify_peer1 (void *cls, 588init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server,
603 struct GNUNET_CORE_Handle *server,
604 const struct GNUNET_PeerIdentity *my_identity, 589 const struct GNUNET_PeerIdentity *my_identity,
605 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 590 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
606 *publicKey) 591 *publicKey)
@@ -618,15 +603,10 @@ init_notify_peer1 (void *cls,
618 /* 603 /*
619 * Connect to the receiving peer 604 * Connect to the receiving peer
620 */ 605 */
621 pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, 606 pos->peer2handle =
622 1, 607 GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2, NULL,
623 pos, 608 NULL, NULL, NULL, GNUNET_YES, NULL, GNUNET_YES,
624 &init_notify_peer2, 609 handlers);
625 NULL,
626 NULL,
627 NULL, NULL,
628 GNUNET_YES, NULL, GNUNET_YES,
629 handlers);
630 610
631} 611}
632 612
@@ -646,9 +626,9 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
646 626
647 if (die_task == GNUNET_SCHEDULER_NO_TASK) 627 if (die_task == GNUNET_SCHEDULER_NO_TASK)
648 { 628 {
649 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, 629 die_task =
650 &end_badly, 630 GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
651 "from send test messages (timeout)"); 631 "from send test messages (timeout)");
652 } 632 }
653 633
654 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) 634 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)
@@ -662,15 +642,10 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
662 /* 642 /*
663 * Connect to the sending peer 643 * Connect to the sending peer
664 */ 644 */
665 pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, 645 pos->peer1handle =
666 1, 646 GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1,
667 pos, 647 &connect_notify_peers, NULL, NULL, NULL, GNUNET_NO,
668 &init_notify_peer1, 648 NULL, GNUNET_NO, no_handlers);
669 &connect_notify_peers, NULL,
670 NULL,
671 NULL,
672 GNUNET_NO, NULL, GNUNET_NO,
673 no_handlers);
674 649
675 GNUNET_assert (pos->peer1handle != NULL); 650 GNUNET_assert (pos->peer1handle != NULL);
676 651
@@ -688,10 +663,8 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
688 663
689 664
690void 665void
691topology_callback (void *cls, 666topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
692 const struct GNUNET_PeerIdentity *first, 667 const struct GNUNET_PeerIdentity *second, uint32_t distance,
693 const struct GNUNET_PeerIdentity *second,
694 uint32_t distance,
695 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 668 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
696 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 669 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
697 struct GNUNET_TESTING_Daemon *first_daemon, 670 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -709,8 +682,8 @@ topology_callback (void *cls,
709 fprintf (stdout, "0%%"); 682 fprintf (stdout, "0%%");
710 else 683 else
711 fprintf (stdout, "%d%%", 684 fprintf (stdout, "%d%%",
712 (int) (((float) total_connections / 685 (int) (((float) total_connections / expected_connections) *
713 expected_connections) * 100)); 686 100));
714 687
715 } 688 }
716 else if (total_connections % dotnum == 0) 689 else if (total_connections % dotnum == 0)
@@ -833,12 +806,11 @@ connect_topology ()
833 GNUNET_TESTING_connect_topology (pg, connection_topology, 806 GNUNET_TESTING_connect_topology (pg, connection_topology,
834 connect_topology_option, 807 connect_topology_option,
835 connect_topology_option_modifier, 808 connect_topology_option_modifier,
836 connect_timeout, 809 connect_timeout, connect_attempts,
837 connect_attempts,
838 &topology_creation_finished, NULL); 810 &topology_creation_finished, NULL);
839#if PROGRESS_BARS 811#if PROGRESS_BARS
840 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 812 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %d expected connections\n",
841 "Have %d expected connections\n", expected_connections); 813 expected_connections);
842#endif 814#endif
843 } 815 }
844 816
@@ -851,11 +823,12 @@ connect_topology ()
851 return; 823 return;
852 } 824 }
853 825
854 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 826 die_task =
855 (GNUNET_TIME_UNIT_SECONDS, 827 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
856 SECONDS_PER_PEER_START * num_peers), 828 (GNUNET_TIME_UNIT_SECONDS,
857 &end_badly, 829 SECONDS_PER_PEER_START * num_peers),
858 "from connect topology (timeout)"); 830 &end_badly,
831 "from connect topology (timeout)");
859 modnum = expected_connections / 4; 832 modnum = expected_connections / 4;
860 dotnum = (expected_connections / 50) + 1; 833 dotnum = (expected_connections / 50) + 1;
861 if (modnum == 0) 834 if (modnum == 0)
@@ -889,17 +862,17 @@ create_topology ()
889 "from create topology (bad return)"); 862 "from create topology (bad return)");
890 } 863 }
891 GNUNET_SCHEDULER_cancel (die_task); 864 GNUNET_SCHEDULER_cancel (die_task);
892 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 865 die_task =
893 (GNUNET_TIME_UNIT_SECONDS, 866 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
894 SECONDS_PER_PEER_START * num_peers), 867 (GNUNET_TIME_UNIT_SECONDS,
895 &end_badly, 868 SECONDS_PER_PEER_START * num_peers),
896 "from continue startup (timeout)"); 869 &end_badly,
870 "from continue startup (timeout)");
897} 871}
898 872
899 873
900static void 874static void
901peers_started_callback (void *cls, 875peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
902 const struct GNUNET_PeerIdentity *id,
903 const struct GNUNET_CONFIGURATION_Handle *cfg, 876 const struct GNUNET_CONFIGURATION_Handle *cfg,
904 struct GNUNET_TESTING_Daemon *d, const char *emsg) 877 struct GNUNET_TESTING_Daemon *d, const char *emsg)
905{ 878{
@@ -943,10 +916,10 @@ peers_started_callback (void *cls,
943 GNUNET_SCHEDULER_cancel (die_task); 916 GNUNET_SCHEDULER_cancel (die_task);
944 /* Set up task in case topology creation doesn't finish 917 /* Set up task in case topology creation doesn't finish
945 * within a reasonable amount of time */ 918 * within a reasonable amount of time */
946 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 919 die_task =
947 (GNUNET_TIME_UNIT_MINUTES, 8), 920 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
948 &end_badly, 921 (GNUNET_TIME_UNIT_MINUTES, 8), &end_badly,
949 "from peers_started_callback"); 922 "from peers_started_callback");
950#if DELAY_FOR_LOGGING 923#if DELAY_FOR_LOGGING
951 fprintf (stdout, "Connecting topology in 10 seconds\n"); 924 fprintf (stdout, "Connecting topology in 10 seconds\n");
952 gather_log_data (); 925 gather_log_data ();
@@ -969,8 +942,7 @@ peers_started_callback (void *cls,
969 * @param emsg non-null on failure 942 * @param emsg non-null on failure
970 */ 943 */
971void 944void
972hostkey_callback (void *cls, 945hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
973 const struct GNUNET_PeerIdentity *id,
974 struct GNUNET_TESTING_Daemon *d, const char *emsg) 946 struct GNUNET_TESTING_Daemon *d, const char *emsg)
975{ 947{
976 if (emsg != NULL) 948 if (emsg != NULL)
@@ -981,8 +953,8 @@ hostkey_callback (void *cls,
981 953
982#if VERBOSE > 1 954#if VERBOSE > 1
983 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 955 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
984 "Hostkey (%d/%d) created for peer `%s'\n", 956 "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left,
985 num_peers - peers_left, num_peers, GNUNET_i2s (id)); 957 num_peers, GNUNET_i2s (id));
986#endif 958#endif
987 959
988#if PROGRESS_BARS 960#if PROGRESS_BARS
@@ -1012,18 +984,17 @@ hostkey_callback (void *cls,
1012 GNUNET_SCHEDULER_cancel (die_task); 984 GNUNET_SCHEDULER_cancel (die_task);
1013 /* Set up task in case topology creation doesn't finish 985 /* Set up task in case topology creation doesn't finish
1014 * within a reasonable amount of time */ 986 * within a reasonable amount of time */
1015 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 987 die_task =
1016 &end_badly, 988 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
1017 "from create_topology"); 989 "from create_topology");
1018 GNUNET_SCHEDULER_add_now (&create_topology, NULL); 990 GNUNET_SCHEDULER_add_now (&create_topology, NULL);
1019 ok = 0; 991 ok = 0;
1020 } 992 }
1021} 993}
1022 994
1023static void 995static void
1024run (void *cls, 996run (void *cls, char *const *args, const char *cfgfile,
1025 char *const *args, 997 const struct GNUNET_CONFIGURATION_Handle *cfg)
1026 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
1027{ 998{
1028 char *topology_str; 999 char *topology_str;
1029 char *connect_topology_str; 1000 char *connect_topology_str;
@@ -1056,8 +1027,8 @@ run (void *cls,
1056 1027
1057 if ((GNUNET_YES == 1028 if ((GNUNET_YES ==
1058 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", 1029 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology",
1059 &topology_str)) 1030 &topology_str)) &&
1060 && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) 1031 (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str)))
1061 { 1032 {
1062 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1033 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1063 "Invalid topology `%s' given for section %s option %s\n", 1034 "Invalid topology `%s' given for section %s option %s\n",
@@ -1068,10 +1039,10 @@ run (void *cls,
1068 if ((GNUNET_YES == 1039 if ((GNUNET_YES ==
1069 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 1040 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
1070 "connect_topology", 1041 "connect_topology",
1071 &connect_topology_str)) 1042 &connect_topology_str)) &&
1072 && (GNUNET_NO == 1043 (GNUNET_NO ==
1073 GNUNET_TESTING_topology_get (&connection_topology, 1044 GNUNET_TESTING_topology_get (&connection_topology,
1074 connect_topology_str))) 1045 connect_topology_str)))
1075 { 1046 {
1076 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1047 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1077 "Invalid connect topology `%s' given for section %s option %s\n", 1048 "Invalid connect topology `%s' given for section %s option %s\n",
@@ -1081,10 +1052,10 @@ run (void *cls,
1081 if ((GNUNET_YES == 1052 if ((GNUNET_YES ==
1082 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 1053 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
1083 "connect_topology_option", 1054 "connect_topology_option",
1084 &connect_topology_option_str)) 1055 &connect_topology_option_str)) &&
1085 && (GNUNET_NO == 1056 (GNUNET_NO ==
1086 GNUNET_TESTING_topology_option_get (&connect_topology_option, 1057 GNUNET_TESTING_topology_option_get (&connect_topology_option,
1087 connect_topology_option_str))) 1058 connect_topology_option_str)))
1088 { 1059 {
1089 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1060 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1090 "Invalid connect topology option `%s' given for section %s option %s\n", 1061 "Invalid connect topology option `%s' given for section %s option %s\n",
@@ -1120,10 +1091,10 @@ run (void *cls,
1120 if ((GNUNET_YES == 1091 if ((GNUNET_YES ==
1121 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 1092 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
1122 "blacklist_topology", 1093 "blacklist_topology",
1123 &blacklist_topology_str)) 1094 &blacklist_topology_str)) &&
1124 && (GNUNET_NO == 1095 (GNUNET_NO ==
1125 GNUNET_TESTING_topology_get (&blacklist_topology, 1096 GNUNET_TESTING_topology_get (&blacklist_topology,
1126 blacklist_topology_str))) 1097 blacklist_topology_str)))
1127 { 1098 {
1128 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1099 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1129 "Invalid topology `%s' given for section %s option %s\n", 1100 "Invalid topology `%s' given for section %s option %s\n",
@@ -1196,10 +1167,8 @@ run (void *cls,
1196 "didn't generate all hostkeys within a reasonable amount of time!!!"); 1167 "didn't generate all hostkeys within a reasonable amount of time!!!");
1197 1168
1198 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); 1169 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
1199 pg = GNUNET_TESTING_daemons_start (cfg, 1170 pg = GNUNET_TESTING_daemons_start (cfg, peers_left,
1200 peers_left, 1171 max_outstanding_connections, peers_left,
1201 max_outstanding_connections,
1202 peers_left,
1203 GNUNET_TIME_relative_multiply 1172 GNUNET_TIME_relative_multiply
1204 (GNUNET_TIME_UNIT_SECONDS, 1173 (GNUNET_TIME_UNIT_SECONDS,
1205 SECONDS_PER_PEER_START * num_peers), 1174 SECONDS_PER_PEER_START * num_peers),
@@ -1231,8 +1200,9 @@ check ()
1231 struct GNUNET_GETOPT_CommandLineOption options[] = { 1200 struct GNUNET_GETOPT_CommandLineOption options[] = {
1232 GNUNET_GETOPT_OPTION_END 1201 GNUNET_GETOPT_OPTION_END
1233 }; 1202 };
1234 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 1203 ret =
1235 argv, binary_name, "nohelp", options, &run, &ok); 1204 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
1205 binary_name, "nohelp", options, &run, &ok);
1236 if (ret != GNUNET_OK) 1206 if (ret != GNUNET_OK)
1237 { 1207 {
1238 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1208 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c
index f9185b6fc..d60e3a8fb 100644
--- a/src/testing/test_testing_topology_blacklist.c
+++ b/src/testing/test_testing_topology_blacklist.c
@@ -173,10 +173,8 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
173 173
174 174
175void 175void
176topology_callback (void *cls, 176topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
177 const struct GNUNET_PeerIdentity *first, 177 const struct GNUNET_PeerIdentity *second, uint32_t distance,
178 const struct GNUNET_PeerIdentity *second,
179 uint32_t distance,
180 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 178 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
181 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 179 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
182 struct GNUNET_TESTING_Daemon *first_daemon, 180 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -222,9 +220,9 @@ topology_callback (void *cls,
222 } 220 }
223 else if (total_connections + failed_connections == expected_connections) 221 else if (total_connections + failed_connections == expected_connections)
224 { 222 {
225 if ((failed_connections == expected_failed_connections) 223 if ((failed_connections == expected_failed_connections) &&
226 && (total_connections == 224 (total_connections ==
227 expected_connections - expected_failed_connections)) 225 expected_connections - expected_failed_connections))
228 { 226 {
229 GNUNET_SCHEDULER_cancel (die_task); 227 GNUNET_SCHEDULER_cancel (die_task);
230 die_task = GNUNET_SCHEDULER_NO_TASK; 228 die_task = GNUNET_SCHEDULER_NO_TASK;
@@ -260,11 +258,11 @@ connect_topology ()
260 GNUNET_TESTING_connect_topology (pg, connection_topology, 258 GNUNET_TESTING_connect_topology (pg, connection_topology,
261 connect_topology_option, 259 connect_topology_option,
262 connect_topology_option_modifier, 260 connect_topology_option_modifier,
263 connect_timeout, 261 connect_timeout, connect_attempts,
264 connect_attempts, NULL, NULL); 262 NULL, NULL);
265#if VERBOSE 263#if VERBOSE
266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n",
267 "Have %d expected connections\n", expected_connections); 265 expected_connections);
268#endif 266#endif
269 } 267 }
270 268
@@ -276,9 +274,9 @@ connect_topology ()
276 "from connect topology (bad return)"); 274 "from connect topology (bad return)");
277 } 275 }
278 276
279 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, 277 die_task =
280 &end_badly, 278 GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
281 "from connect topology (timeout)"); 279 "from connect topology (timeout)");
282} 280}
283 281
284static void 282static void
@@ -302,15 +300,14 @@ create_topology ()
302 "from create topology (bad return)"); 300 "from create topology (bad return)");
303 } 301 }
304 GNUNET_SCHEDULER_cancel (die_task); 302 GNUNET_SCHEDULER_cancel (die_task);
305 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, 303 die_task =
306 &end_badly, 304 GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
307 "from continue startup (timeout)"); 305 "from continue startup (timeout)");
308} 306}
309 307
310 308
311static void 309static void
312peers_started_callback (void *cls, 310peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
313 const struct GNUNET_PeerIdentity *id,
314 const struct GNUNET_CONFIGURATION_Handle *cfg, 311 const struct GNUNET_CONFIGURATION_Handle *cfg,
315 struct GNUNET_TESTING_Daemon *d, const char *emsg) 312 struct GNUNET_TESTING_Daemon *d, const char *emsg)
316{ 313{
@@ -335,10 +332,10 @@ peers_started_callback (void *cls,
335 GNUNET_SCHEDULER_cancel (die_task); 332 GNUNET_SCHEDULER_cancel (die_task);
336 /* Set up task in case topology creation doesn't finish 333 /* Set up task in case topology creation doesn't finish
337 * within a reasonable amount of time */ 334 * within a reasonable amount of time */
338 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 335 die_task =
339 (GNUNET_TIME_UNIT_MINUTES, 5), 336 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
340 &end_badly, 337 (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly,
341 "from peers_started_callback"); 338 "from peers_started_callback");
342 connect_topology (); 339 connect_topology ();
343 ok = 0; 340 ok = 0;
344 } 341 }
@@ -353,8 +350,7 @@ peers_started_callback (void *cls,
353 * @param emsg non-null on failure 350 * @param emsg non-null on failure
354 */ 351 */
355void 352void
356hostkey_callback (void *cls, 353hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
357 const struct GNUNET_PeerIdentity *id,
358 struct GNUNET_TESTING_Daemon *d, const char *emsg) 354 struct GNUNET_TESTING_Daemon *d, const char *emsg)
359{ 355{
360 if (emsg != NULL) 356 if (emsg != NULL)
@@ -364,8 +360,8 @@ hostkey_callback (void *cls,
364 } 360 }
365 361
366#if VERBOSE 362#if VERBOSE
367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 363 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostkey created for peer `%s'\n",
368 "Hostkey created for peer `%s'\n", GNUNET_i2s (id)); 364 GNUNET_i2s (id));
369#endif 365#endif
370 peers_left--; 366 peers_left--;
371 if (peers_left == 0) 367 if (peers_left == 0)
@@ -377,19 +373,18 @@ hostkey_callback (void *cls,
377 GNUNET_SCHEDULER_cancel (die_task); 373 GNUNET_SCHEDULER_cancel (die_task);
378 /* Set up task in case topology creation doesn't finish 374 /* Set up task in case topology creation doesn't finish
379 * within a reasonable amount of time */ 375 * within a reasonable amount of time */
380 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 376 die_task =
381 (GNUNET_TIME_UNIT_MINUTES, 5), 377 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
382 &end_badly, 378 (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly,
383 "from hostkey_callback"); 379 "from hostkey_callback");
384 GNUNET_SCHEDULER_add_now (&create_topology, NULL); 380 GNUNET_SCHEDULER_add_now (&create_topology, NULL);
385 ok = 0; 381 ok = 0;
386 } 382 }
387} 383}
388 384
389static void 385static void
390run (void *cls, 386run (void *cls, char *const *args, const char *cfgfile,
391 char *const *args, 387 const struct GNUNET_CONFIGURATION_Handle *cfg)
392 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
393{ 388{
394 unsigned long long topology_num; 389 unsigned long long topology_num;
395 unsigned long long connect_topology_num; 390 unsigned long long connect_topology_num;
@@ -429,8 +424,7 @@ run (void *cls,
429 topology = topology_num; 424 topology = topology_num;
430 425
431 if (GNUNET_YES == 426 if (GNUNET_YES ==
432 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", 427 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_topology",
433 "connect_topology",
434 &connect_topology_num)) 428 &connect_topology_num))
435 connection_topology = connect_topology_num; 429 connection_topology = connect_topology_num;
436 430
@@ -528,15 +522,14 @@ run (void *cls,
528 522
529 523
530 /* Set up a task to end testing if peer start fails */ 524 /* Set up a task to end testing if peer start fails */
531 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 525 die_task =
532 (GNUNET_TIME_UNIT_MINUTES, 5), 526 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
533 &end_badly, 527 (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly,
534 "didn't start all daemons in reasonable amount of time!!!"); 528 "didn't start all daemons in reasonable amount of time!!!");
535 529
536 pg = GNUNET_TESTING_daemons_start (cfg, 530 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left, peers_left,
537 peers_left, peers_left, peers_left, 531 TIMEOUT, &hostkey_callback, NULL,
538 TIMEOUT, &hostkey_callback, 532 &peers_started_callback, NULL,
539 NULL, &peers_started_callback, NULL,
540 &topology_callback, NULL, NULL); 533 &topology_callback, NULL, NULL);
541 534
542} 535}
@@ -557,9 +550,10 @@ check ()
557 struct GNUNET_GETOPT_CommandLineOption options[] = { 550 struct GNUNET_GETOPT_CommandLineOption options[] = {
558 GNUNET_GETOPT_OPTION_END 551 GNUNET_GETOPT_OPTION_END
559 }; 552 };
560 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 553 ret =
561 argv, "test-testing-topology-blacklist", "nohelp", 554 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
562 options, &run, &ok); 555 "test-testing-topology-blacklist", "nohelp", options,
556 &run, &ok);
563 if (ret != GNUNET_OK) 557 if (ret != GNUNET_OK)
564 { 558 {
565 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 559 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
diff --git a/src/testing/test_testing_topology_churn.c b/src/testing/test_testing_topology_churn.c
index ee800c52c..5a348642c 100644
--- a/src/testing/test_testing_topology_churn.c
+++ b/src/testing/test_testing_topology_churn.c
@@ -198,8 +198,7 @@ churn_peers_off ()
198} 198}
199 199
200static void 200static void
201peers_started_callback (void *cls, 201peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
202 const struct GNUNET_PeerIdentity *id,
203 const struct GNUNET_CONFIGURATION_Handle *cfg, 202 const struct GNUNET_CONFIGURATION_Handle *cfg,
204 struct GNUNET_TESTING_Daemon *d, const char *emsg) 203 struct GNUNET_TESTING_Daemon *d, const char *emsg)
205{ 204{
@@ -224,10 +223,10 @@ peers_started_callback (void *cls,
224 GNUNET_SCHEDULER_cancel (die_task); 223 GNUNET_SCHEDULER_cancel (die_task);
225 /* Set up task in case topology creation doesn't finish 224 /* Set up task in case topology creation doesn't finish
226 * within a reasonable amount of time */ 225 * within a reasonable amount of time */
227 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 226 die_task =
228 (GNUNET_TIME_UNIT_MINUTES, 5), 227 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
229 &end_badly, 228 (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly,
230 "from peers_started_callback"); 229 "from peers_started_callback");
231 churn_peers_off (); 230 churn_peers_off ();
232 ok = 0; 231 ok = 0;
233 } 232 }
@@ -235,9 +234,8 @@ peers_started_callback (void *cls,
235 234
236 235
237static void 236static void
238run (void *cls, 237run (void *cls, char *const *args, const char *cfgfile,
239 char *const *args, 238 const struct GNUNET_CONFIGURATION_Handle *cfg)
240 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
241{ 239{
242 ok = 1; 240 ok = 1;
243 241
@@ -274,18 +272,15 @@ run (void *cls,
274 272
275 273
276 /* Set up a task to end testing if peer start fails */ 274 /* Set up a task to end testing if peer start fails */
277 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 275 die_task =
278 (GNUNET_TIME_UNIT_MINUTES, 5), 276 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
279 &end_badly, 277 (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly,
280 "didn't start all daemons in reasonable amount of time!!!"); 278 "didn't start all daemons in reasonable amount of time!!!");
281 279
282 pg = GNUNET_TESTING_daemons_start (cfg, 280 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left, peers_left,
283 peers_left,
284 peers_left,
285 peers_left,
286 TIMEOUT, NULL, NULL, 281 TIMEOUT, NULL, NULL,
287 &peers_started_callback, NULL, NULL, 282 &peers_started_callback, NULL, NULL, NULL,
288 NULL, NULL); 283 NULL);
289 284
290} 285}
291 286
@@ -305,9 +300,10 @@ check ()
305 struct GNUNET_GETOPT_CommandLineOption options[] = { 300 struct GNUNET_GETOPT_CommandLineOption options[] = {
306 GNUNET_GETOPT_OPTION_END 301 GNUNET_GETOPT_OPTION_END
307 }; 302 };
308 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 303 ret =
309 argv, "test-testing-topology-churn", "nohelp", 304 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
310 options, &run, &ok); 305 "test-testing-topology-churn", "nohelp", options,
306 &run, &ok);
311 if (ret != GNUNET_OK) 307 if (ret != GNUNET_OK)
312 { 308 {
313 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 309 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
diff --git a/src/testing/testing.c b/src/testing/testing.c
index c21166775..c107ec593 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -67,10 +67,9 @@ static struct GNUNET_CORE_MessageHandler no_handlers[] = { {NULL, 0, 0} };
67 67
68#if EMPTY_HACK 68#if EMPTY_HACK
69static int 69static int
70test_address (void *cls, 70test_address (void *cls, const char *tname,
71 const char *tname, 71 struct GNUNET_TIME_Absolute expiration, const void *addr,
72 struct GNUNET_TIME_Absolute expiration, 72 uint16_t addrlen)
73 const void *addr, uint16_t addrlen)
74{ 73{
75 int *empty = cls; 74 int *empty = cls;
76 75
@@ -144,8 +143,8 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
144 } 143 }
145#if DEBUG_TESTING 144#if DEBUG_TESTING
146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
147 "Received `%s' from transport service of `%4s'\n", 146 "Received `%s' from transport service of `%4s'\n", "HELLO",
148 "HELLO", GNUNET_i2s (&daemon->id)); 147 GNUNET_i2s (&daemon->id));
149#endif 148#endif
150 149
151 GNUNET_free_non_null (daemon->hello); 150 GNUNET_free_non_null (daemon->hello);
@@ -165,8 +164,8 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
165#endif 164#endif
166} 165}
167 166
168static void 167static void start_fsm (void *cls,
169start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 168 const struct GNUNET_SCHEDULER_TaskContext *tc);
170 169
171#if WAIT_FOR_HELLO 170#if WAIT_FOR_HELLO
172/** 171/**
@@ -182,8 +181,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
182 * @param publicKey public key of this peer, NULL if we failed 181 * @param publicKey public key of this peer, NULL if we failed
183 */ 182 */
184static void 183static void
185testing_init (void *cls, 184testing_init (void *cls, struct GNUNET_CORE_Handle *server,
186 struct GNUNET_CORE_Handle *server,
187 const struct GNUNET_PeerIdentity *my_identity, 185 const struct GNUNET_PeerIdentity *my_identity,
188 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 186 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
189{ 187{
@@ -197,17 +195,18 @@ testing_init (void *cls,
197 d->server = NULL; 195 d->server = NULL;
198 if (GNUNET_YES == d->dead) 196 if (GNUNET_YES == d->dead)
199 GNUNET_TESTING_daemon_stop (d, 197 GNUNET_TESTING_daemon_stop (d,
200 GNUNET_TIME_absolute_get_remaining 198 GNUNET_TIME_absolute_get_remaining (d->
201 (d->max_timeout), d->dead_cb, 199 max_timeout),
202 d->dead_cb_cls, GNUNET_YES, GNUNET_NO); 200 d->dead_cb, d->dead_cb_cls, GNUNET_YES,
201 GNUNET_NO);
203 else if (NULL != d->cb) 202 else if (NULL != d->cb)
204 d->cb (d->cb_cls, NULL, d->cfg, d, 203 d->cb (d->cb_cls, NULL, d->cfg, d,
205 _("Failed to connect to core service\n")); 204 _("Failed to connect to core service\n"));
206 return; 205 return;
207 } 206 }
208#if DEBUG_TESTING 207#if DEBUG_TESTING
209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started peer `%4s'.\n",
210 "Successfully started peer `%4s'.\n", GNUNET_i2s (my_identity)); 209 GNUNET_i2s (my_identity));
211#endif 210#endif
212 d->id = *my_identity; /* FIXME: shouldn't we already have this from reading the hostkey file? */ 211 d->id = *my_identity; /* FIXME: shouldn't we already have this from reading the hostkey file? */
213 if (d->shortname == NULL) 212 if (d->shortname == NULL)
@@ -234,9 +233,10 @@ testing_init (void *cls,
234 { 233 {
235 if (GNUNET_YES == d->dead) 234 if (GNUNET_YES == d->dead)
236 GNUNET_TESTING_daemon_stop (d, 235 GNUNET_TESTING_daemon_stop (d,
237 GNUNET_TIME_absolute_get_remaining 236 GNUNET_TIME_absolute_get_remaining (d->
238 (d->max_timeout), d->dead_cb, 237 max_timeout),
239 d->dead_cb_cls, GNUNET_YES, GNUNET_NO); 238 d->dead_cb, d->dead_cb_cls, GNUNET_YES,
239 GNUNET_NO);
240 else if (NULL != d->cb) 240 else if (NULL != d->cb)
241 d->cb (d->cb_cls, &d->id, d->cfg, d, 241 d->cb (d->cb_cls, &d->id, d->cfg, d,
242 _("Failed to connect to transport service!\n")); 242 _("Failed to connect to transport service!\n"));
@@ -252,9 +252,8 @@ testing_init (void *cls,
252 /* wait some more */ 252 /* wait some more */
253 if (d->task != GNUNET_SCHEDULER_NO_TASK) 253 if (d->task != GNUNET_SCHEDULER_NO_TASK)
254 GNUNET_SCHEDULER_cancel (d->task); 254 GNUNET_SCHEDULER_cancel (d->task);
255 d->task 255 d->task =
256 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 256 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d);
257 &start_fsm, d);
258} 257}
259#endif 258#endif
260 259
@@ -312,17 +311,15 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
312 cb = d->cb; 311 cb = d->cb;
313 d->cb = NULL; 312 d->cb = NULL;
314 if (NULL != cb) 313 if (NULL != cb)
315 cb (d->cb_cls, 314 cb (d->cb_cls, NULL, d->cfg, d,
316 NULL,
317 d->cfg, d,
318 _ 315 _
319 ("`scp' does not seem to terminate (timeout copying config).\n")); 316 ("`scp' does not seem to terminate (timeout copying config).\n"));
320 return; 317 return;
321 } 318 }
322 /* wait some more */ 319 /* wait some more */
323 d->task 320 d->task =
324 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 321 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
325 &start_fsm, d); 322 d);
326 return; 323 return;
327 } 324 }
328 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) 325 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
@@ -350,13 +347,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
350 cb = d->cb; 347 cb = d->cb;
351 d->cb = NULL; 348 d->cb = NULL;
352 if (NULL != cb) 349 if (NULL != cb)
353 cb (d->cb_cls, 350 cb (d->cb_cls, NULL, d->cfg, d,
354 NULL, 351 (NULL ==
355 d->cfg, 352 d->
356 d, 353 hostname) ?
357 (NULL == d->hostname) 354 _("Failed to create pipe for `gnunet-peerinfo' process.\n") :
358 ? _("Failed to create pipe for `gnunet-peerinfo' process.\n") 355 _("Failed to create pipe for `ssh' process.\n"));
359 : _("Failed to create pipe for `ssh' process.\n"));
360 return; 356 return;
361 } 357 }
362 if (NULL == d->hostname) 358 if (NULL == d->hostname)
@@ -369,8 +365,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
369#endif 365#endif
370 d->proc = 366 d->proc =
371 GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo", 367 GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo",
372 "gnunet-peerinfo", "-c", d->cfgfile, 368 "gnunet-peerinfo", "-c", d->cfgfile, "-sq",
373 "-sq", NULL); 369 NULL);
374 GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); 370 GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);
375 } 371 }
376 else 372 else
@@ -392,20 +388,19 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
392#if !DEBUG_TESTING 388#if !DEBUG_TESTING
393 "-q", 389 "-q",
394#endif 390#endif
395 dst, 391 dst, "gnunet-peerinfo", "-c",
396 "gnunet-peerinfo", 392 d->cfgfile, "-sq", NULL);
397 "-c", d->cfgfile, "-sq", NULL);
398 } 393 }
399 else 394 else
400 { 395 {
401 d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", 396 d->proc =
402 "ssh", "-p", d->ssh_port_str, 397 GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", "ssh", "-p",
398 d->ssh_port_str,
403#if !DEBUG_TESTING 399#if !DEBUG_TESTING
404 "-q", 400 "-q",
405#endif 401#endif
406 dst, 402 dst, "gnunet-peerinfo", "-c", d->cfgfile,
407 "gnunet-peerinfo", 403 "-sq", NULL);
408 "-c", d->cfgfile, "-sq", NULL);
409 } 404 }
410 GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); 405 GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);
411 GNUNET_free (dst); 406 GNUNET_free (dst);
@@ -418,13 +413,11 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
418 cb = d->cb; 413 cb = d->cb;
419 d->cb = NULL; 414 d->cb = NULL;
420 if (NULL != cb) 415 if (NULL != cb)
421 cb (d->cb_cls, 416 cb (d->cb_cls, NULL, d->cfg, d,
422 NULL, 417 (NULL ==
423 d->cfg, 418 d->
424 d, 419 hostname) ? _("Failed to start `gnunet-peerinfo' process.\n") :
425 (NULL == d->hostname) 420 _("Failed to start `ssh' process.\n"));
426 ? _("Failed to start `gnunet-peerinfo' process.\n")
427 : _("Failed to start `ssh' process.\n"));
428 GNUNET_DISK_pipe_close (d->pipe_stdout); 421 GNUNET_DISK_pipe_close (d->pipe_stdout);
429 return; 422 return;
430 } 423 }
@@ -433,13 +426,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
433 "Started `%s', waiting for hostkey.\n", "gnunet-peerinfo"); 426 "Started `%s', waiting for hostkey.\n", "gnunet-peerinfo");
434#endif 427#endif
435 d->phase = SP_HOSTKEY_CREATE; 428 d->phase = SP_HOSTKEY_CREATE;
436 d->task 429 d->task =
437 =
438 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining 430 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining
439 (d->max_timeout), 431 (d->max_timeout),
440 GNUNET_DISK_pipe_handle 432 GNUNET_DISK_pipe_handle (d->
441 (d->pipe_stdout, 433 pipe_stdout,
442 GNUNET_DISK_PIPE_END_READ), 434 GNUNET_DISK_PIPE_END_READ),
443 &start_fsm, d); 435 &start_fsm, d);
444 } 436 }
445 else /* Already have a hostkey! */ 437 else /* Already have a hostkey! */
@@ -469,21 +461,20 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
469 if ((d->hostkeybufpos < 104) && (bytes_read > 0)) 461 if ((d->hostkeybufpos < 104) && (bytes_read > 0))
470 { 462 {
471 /* keep reading */ 463 /* keep reading */
472 d->task 464 d->task =
473 =
474 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining 465 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining
475 (d->max_timeout), 466 (d->max_timeout),
476 GNUNET_DISK_pipe_handle 467 GNUNET_DISK_pipe_handle (d->
477 (d->pipe_stdout, 468 pipe_stdout,
478 GNUNET_DISK_PIPE_END_READ), 469 GNUNET_DISK_PIPE_END_READ),
479 &start_fsm, d); 470 &start_fsm, d);
480 return; 471 return;
481 } 472 }
482 d->hostkeybuf[103] = '\0'; 473 d->hostkeybuf[103] = '\0';
483 474
484 if ((bytes_read < 0) || 475 if ((bytes_read < 0) ||
485 (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (d->hostkeybuf, 476 (GNUNET_OK !=
486 &d->id.hashPubKey))) 477 GNUNET_CRYPTO_hash_from_string (d->hostkeybuf, &d->id.hashPubKey)))
487 { 478 {
488 /* error */ 479 /* error */
489 if (bytes_read < 0) 480 if (bytes_read < 0)
@@ -529,20 +520,20 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
529 /* Fall through */ 520 /* Fall through */
530 case SP_HOSTKEY_CREATED: 521 case SP_HOSTKEY_CREATED:
531 /* wait for topology finished */ 522 /* wait for topology finished */
532 if ((GNUNET_YES == d->dead) 523 if ((GNUNET_YES == d->dead) ||
533 || (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0)) 524 (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0))
534 { 525 {
535 cb = d->cb; 526 cb = d->cb;
536 d->cb = NULL; 527 d->cb = NULL;
537 if (NULL != cb) 528 if (NULL != cb)
538 cb (d->cb_cls, 529 cb (d->cb_cls, NULL, d->cfg, d,
539 NULL, d->cfg, d, _("`Failed while waiting for topology setup!\n")); 530 _("`Failed while waiting for topology setup!\n"));
540 return; 531 return;
541 } 532 }
542 533
543 d->task 534 d->task =
544 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 535 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
545 &start_fsm, d); 536 d);
546 break; 537 break;
547 case SP_TOPOLOGY_SETUP: /* Indicates topology setup has completed! */ 538 case SP_TOPOLOGY_SETUP: /* Indicates topology setup has completed! */
548 /* start GNUnet on remote host */ 539 /* start GNUnet on remote host */
@@ -551,18 +542,19 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
551#if DEBUG_TESTING 542#if DEBUG_TESTING
552 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 543 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
553 "Starting `%s', with command `%s %s %s %s %s %s'.\n", 544 "Starting `%s', with command `%s %s %s %s %s %s'.\n",
554 "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, 545 "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-L", "DEBUG",
555 "-L", "DEBUG", "-s"); 546 "-s");
556#endif 547#endif
557 d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", 548 d->proc =
558 "gnunet-arm", "-c", d->cfgfile, 549 GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm", "-c",
550 d->cfgfile,
559#if DEBUG_TESTING 551#if DEBUG_TESTING
560 "-L", "DEBUG", 552 "-L", "DEBUG",
561#endif 553#endif
562 "-s", "-q", "-T", 554 "-s", "-q", "-T",
563 GNUNET_TIME_relative_to_string 555 GNUNET_TIME_relative_to_string
564 (GNUNET_TIME_absolute_get_remaining 556 (GNUNET_TIME_absolute_get_remaining
565 (d->max_timeout)), NULL); 557 (d->max_timeout)), NULL);
566 } 558 }
567 else 559 else
568 { 560 {
@@ -574,8 +566,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
574#if DEBUG_TESTING 566#if DEBUG_TESTING
575 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 567 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
576 "Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n", 568 "Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n",
577 "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", 569 "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile,
578 d->cfgfile, "-L", "DEBUG", "-s", "-q"); 570 "-L", "DEBUG", "-s", "-q");
579#endif 571#endif
580 if (d->ssh_port_str == NULL) 572 if (d->ssh_port_str == NULL)
581 { 573 {
@@ -587,8 +579,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
587#if DEBUG_TESTING 579#if DEBUG_TESTING
588 "-L", "DEBUG", 580 "-L", "DEBUG",
589#endif 581#endif
590 "-c", d->cfgfile, "-s", "-q", 582 "-c", d->cfgfile, "-s", "-q", "-T",
591 "-T",
592 GNUNET_TIME_relative_to_string 583 GNUNET_TIME_relative_to_string
593 (GNUNET_TIME_absolute_get_remaining 584 (GNUNET_TIME_absolute_get_remaining
594 (d->max_timeout)), NULL); 585 (d->max_timeout)), NULL);
@@ -596,20 +587,20 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
596 else 587 else
597 { 588 {
598 589
599 d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", 590 d->proc =
600 "ssh", "-p", d->ssh_port_str, 591 GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-p",
592 d->ssh_port_str,
601#if !DEBUG_TESTING 593#if !DEBUG_TESTING
602 "-q", 594 "-q",
603#endif 595#endif
604 dst, "gnunet-arm", 596 dst, "gnunet-arm",
605#if DEBUG_TESTING 597#if DEBUG_TESTING
606 "-L", "DEBUG", 598 "-L", "DEBUG",
607#endif 599#endif
608 "-c", d->cfgfile, "-s", "-q", 600 "-c", d->cfgfile, "-s", "-q", "-T",
609 "-T", 601 GNUNET_TIME_relative_to_string
610 GNUNET_TIME_relative_to_string 602 (GNUNET_TIME_absolute_get_remaining
611 (GNUNET_TIME_absolute_get_remaining 603 (d->max_timeout)), NULL);
612 (d->max_timeout)), NULL);
613 } 604 }
614 GNUNET_free (dst); 605 GNUNET_free (dst);
615 } 606 }
@@ -621,24 +612,22 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
621 cb = d->cb; 612 cb = d->cb;
622 d->cb = NULL; 613 d->cb = NULL;
623 if (NULL != cb) 614 if (NULL != cb)
624 cb (d->cb_cls, 615 cb (d->cb_cls, NULL, d->cfg, d,
625 NULL, 616 (NULL ==
626 d->cfg, 617 d->
627 d, 618 hostname) ? _("Failed to start `gnunet-arm' process.\n") :
628 (NULL == d->hostname) 619 _("Failed to start `ssh' process.\n"));
629 ? _("Failed to start `gnunet-arm' process.\n")
630 : _("Failed to start `ssh' process.\n"));
631 return; 620 return;
632 } 621 }
633#if DEBUG_TESTING 622#if DEBUG_TESTING
634 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 623 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
635 "Started `%s', waiting for `%s' to be up.\n", 624 "Started `%s', waiting for `%s' to be up.\n", "gnunet-arm",
636 "gnunet-arm", "gnunet-service-core"); 625 "gnunet-service-core");
637#endif 626#endif
638 d->phase = SP_START_ARMING; 627 d->phase = SP_START_ARMING;
639 d->task 628 d->task =
640 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 629 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
641 &start_fsm, d); 630 d);
642 break; 631 break;
643 case SP_START_ARMING: 632 case SP_START_ARMING:
644 if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) 633 if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
@@ -648,13 +637,11 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
648 cb = d->cb; 637 cb = d->cb;
649 d->cb = NULL; 638 d->cb = NULL;
650 if (NULL != cb) 639 if (NULL != cb)
651 cb (d->cb_cls, 640 cb (d->cb_cls, NULL, d->cfg, d,
652 NULL, 641 (NULL ==
653 d->cfg, 642 d->
654 d, 643 hostname) ? _("`gnunet-arm' does not seem to terminate.\n") :
655 (NULL == d->hostname) 644 _("`ssh' does not seem to terminate.\n"));
656 ? _("`gnunet-arm' does not seem to terminate.\n")
657 : _("`ssh' does not seem to terminate.\n"));
658 GNUNET_CONFIGURATION_destroy (d->cfg); 645 GNUNET_CONFIGURATION_destroy (d->cfg);
659 GNUNET_free (d->cfgfile); 646 GNUNET_free (d->cfgfile);
660 GNUNET_free_non_null (d->hostname); 647 GNUNET_free_non_null (d->hostname);
@@ -664,14 +651,14 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
664 return; 651 return;
665 } 652 }
666 /* wait some more */ 653 /* wait some more */
667 d->task 654 d->task =
668 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 655 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
669 &start_fsm, d); 656 d);
670 return; 657 return;
671 } 658 }
672#if DEBUG_TESTING 659#if DEBUG_TESTING
673 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 660 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Successfully started `%s'.\n",
674 "Successfully started `%s'.\n", "gnunet-arm"); 661 "gnunet-arm");
675#endif 662#endif
676 GNUNET_free (d->proc); 663 GNUNET_free (d->proc);
677 d->phase = SP_START_CORE; 664 d->phase = SP_START_CORE;
@@ -689,9 +676,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
689 cb = d->cb; 676 cb = d->cb;
690 d->cb = NULL; 677 d->cb = NULL;
691 if (NULL != cb) 678 if (NULL != cb)
692 cb (d->cb_cls, 679 cb (d->cb_cls, NULL, d->cfg, d,
693 NULL, 680 _("Unable to connect to CORE service for peer!\n"));
694 d->cfg, d, _("Unable to connect to CORE service for peer!\n"));
695 GNUNET_CONFIGURATION_destroy (d->cfg); 681 GNUNET_CONFIGURATION_destroy (d->cfg);
696 GNUNET_free (d->cfgfile); 682 GNUNET_free (d->cfgfile);
697 GNUNET_free_non_null (d->hostname); 683 GNUNET_free_non_null (d->hostname);
@@ -699,14 +685,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
699 GNUNET_free (d); 685 GNUNET_free (d);
700 return; 686 return;
701 } 687 }
702 d->server = GNUNET_CORE_connect (d->cfg, 1, 688 d->server =
703 d, 689 GNUNET_CORE_connect (d->cfg, 1, d, &testing_init, NULL, NULL, NULL,
704 &testing_init, 690 NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers);
705 NULL, NULL, NULL, 691 d->task =
706 NULL, GNUNET_NO,
707 NULL, GNUNET_NO, no_handlers);
708 d->task
709 =
710 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 692 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
711 (GNUNET_CONSTANTS_SERVICE_RETRY, 2), 693 (GNUNET_CONSTANTS_SERVICE_RETRY, 2),
712 &start_fsm, d); 694 &start_fsm, d);
@@ -716,9 +698,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
716 { 698 {
717 if (GNUNET_YES == d->dead) 699 if (GNUNET_YES == d->dead)
718 GNUNET_TESTING_daemon_stop (d, 700 GNUNET_TESTING_daemon_stop (d,
719 GNUNET_TIME_absolute_get_remaining 701 GNUNET_TIME_absolute_get_remaining (d->
720 (d->max_timeout), d->dead_cb, 702 max_timeout),
721 d->dead_cb_cls, GNUNET_YES, GNUNET_NO); 703 d->dead_cb, d->dead_cb_cls, GNUNET_YES,
704 GNUNET_NO);
722 else if (NULL != d->cb) 705 else if (NULL != d->cb)
723 d->cb (d->cb_cls, &d->id, d->cfg, d, 706 d->cb (d->cb_cls, &d->id, d->cfg, d,
724 _("Failed to connect to transport service!\n")); 707 _("Failed to connect to transport service!\n"));
@@ -761,8 +744,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
761 if (d->hello != NULL) 744 if (d->hello != NULL)
762 return; 745 return;
763 GNUNET_assert (d->task == GNUNET_SCHEDULER_NO_TASK); 746 GNUNET_assert (d->task == GNUNET_SCHEDULER_NO_TASK);
764 d->task 747 d->task =
765 =
766 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 748 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
767 (GNUNET_CONSTANTS_SERVICE_RETRY, 2), 749 (GNUNET_CONSTANTS_SERVICE_RETRY, 2),
768 &start_fsm, d); 750 &start_fsm, d);
@@ -779,19 +761,17 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
779 cb = d->cb; 761 cb = d->cb;
780 d->cb = NULL; 762 d->cb = NULL;
781 if (NULL != cb) 763 if (NULL != cb)
782 cb (d->cb_cls, 764 cb (d->cb_cls, NULL, d->cfg, d,
783 NULL, 765 (NULL ==
784 d->cfg, 766 d->
785 d, 767 hostname) ? _("`gnunet-arm' does not seem to terminate.\n") :
786 (NULL == d->hostname) 768 _("`ssh' does not seem to terminate.\n"));
787 ? _("`gnunet-arm' does not seem to terminate.\n")
788 : _("`ssh' does not seem to terminate.\n"));
789 return; 769 return;
790 } 770 }
791 /* wait some more */ 771 /* wait some more */
792 d->task 772 d->task =
793 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 773 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
794 &start_fsm, d); 774 d);
795 return; 775 return;
796 } 776 }
797#if EXTRA_CHECKS 777#if EXTRA_CHECKS
@@ -800,12 +780,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
800 cb = d->cb; 780 cb = d->cb;
801 d->cb = NULL; 781 d->cb = NULL;
802 if (NULL != cb) 782 if (NULL != cb)
803 cb (d->cb_cls, 783 cb (d->cb_cls, NULL, d->cfg, d,
804 NULL, 784 (NULL ==
805 d->cfg, 785 d->
806 d, 786 hostname) ?
807 (NULL == d->hostname)
808 ?
809 _ 787 _
810 ("`gnunet-arm' terminated with non-zero exit status (or timed out)!\n") 788 ("`gnunet-arm' terminated with non-zero exit status (or timed out)!\n")
811 : _("`ssh' does not seem to terminate.\n")); 789 : _("`ssh' does not seem to terminate.\n"));
@@ -834,9 +812,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
834 return; 812 return;
835 } 813 }
836 /* wait some more */ 814 /* wait some more */
837 d->task 815 d->task =
838 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 816 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
839 &start_fsm, d); 817 d);
840 return; 818 return;
841 } 819 }
842#if EXTRA_CHECKS 820#if EXTRA_CHECKS
@@ -883,9 +861,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
883 return; 861 return;
884 } 862 }
885 /* wait some more */ 863 /* wait some more */
886 d->task 864 d->task =
887 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 865 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
888 &start_fsm, d); 866 d);
889 return; 867 return;
890 } 868 }
891 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) 869 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
@@ -963,14 +941,14 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
963 cb = d->cb; 941 cb = d->cb;
964 d->cb = NULL; 942 d->cb = NULL;
965 if (NULL != cb) 943 if (NULL != cb)
966 cb (d->cb_cls, 944 cb (d->cb_cls, NULL, d->cfg, d,
967 NULL, d->cfg, d, _("`scp' does not seem to terminate.\n")); 945 _("`scp' does not seem to terminate.\n"));
968 return; 946 return;
969 } 947 }
970 /* wait some more */ 948 /* wait some more */
971 d->task 949 d->task =
972 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 950 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
973 &start_fsm, d); 951 d);
974 return; 952 return;
975 } 953 }
976 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) 954 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
@@ -1231,8 +1209,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
1231 daemon->phase = SP_TOPOLOGY_SETUP; 1209 daemon->phase = SP_TOPOLOGY_SETUP;
1232 daemon->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); 1210 daemon->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
1233 1211
1234 GNUNET_SCHEDULER_add_continuation (&start_fsm, 1212 GNUNET_SCHEDULER_add_continuation (&start_fsm, daemon,
1235 daemon,
1236 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1213 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1237} 1214}
1238 1215
@@ -1261,12 +1238,9 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
1261 */ 1238 */
1262struct GNUNET_TESTING_Daemon * 1239struct GNUNET_TESTING_Daemon *
1263GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 1240GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1264 struct GNUNET_TIME_Relative timeout, 1241 struct GNUNET_TIME_Relative timeout, int pretend,
1265 int pretend, 1242 const char *hostname, const char *ssh_username,
1266 const char *hostname, 1243 uint16_t sshport, const char *hostkey,
1267 const char *ssh_username,
1268 uint16_t sshport,
1269 const char *hostkey,
1270 GNUNET_TESTING_NotifyHostkeyCreated 1244 GNUNET_TESTING_NotifyHostkeyCreated
1271 hostkey_callback, void *hostkey_cls, 1245 hostkey_callback, void *hostkey_cls,
1272 GNUNET_TESTING_NotifyDaemonRunning cb, 1246 GNUNET_TESTING_NotifyDaemonRunning cb,
@@ -1295,8 +1269,7 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1295 1269
1296 /* Find service home and base service home directories, create it if it doesn't exist */ 1270 /* Find service home and base service home directories, create it if it doesn't exist */
1297 GNUNET_assert (GNUNET_OK == 1271 GNUNET_assert (GNUNET_OK ==
1298 GNUNET_CONFIGURATION_get_value_string (cfg, 1272 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS",
1299 "PATHS",
1300 "SERVICEHOME", 1273 "SERVICEHOME",
1301 &servicehome)); 1274 &servicehome));
1302 1275
@@ -1321,9 +1294,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1321 ret->cb_cls = cb_cls; 1294 ret->cb_cls = cb_cls;
1322 ret->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); 1295 ret->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
1323 ret->cfg = GNUNET_CONFIGURATION_dup (cfg); 1296 ret->cfg = GNUNET_CONFIGURATION_dup (cfg);
1324 GNUNET_CONFIGURATION_set_value_string (ret->cfg, 1297 GNUNET_CONFIGURATION_set_value_string (ret->cfg, "PATHS", "DEFAULTCONFIG",
1325 "PATHS", 1298 ret->cfgfile);
1326 "DEFAULTCONFIG", ret->cfgfile);
1327 1299
1328 if (hostkey != NULL) /* Get the peer identity from the hostkey */ 1300 if (hostkey != NULL) /* Get the peer identity from the hostkey */
1329 { 1301 {
@@ -1344,8 +1316,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1344 { 1316 {
1345 GNUNET_asprintf (&hostkeyfile, "%s/.hostkey", servicehome); 1317 GNUNET_asprintf (&hostkeyfile, "%s/.hostkey", servicehome);
1346 fn = GNUNET_DISK_file_open (hostkeyfile, 1318 fn = GNUNET_DISK_file_open (hostkeyfile,
1347 GNUNET_DISK_OPEN_READWRITE 1319 GNUNET_DISK_OPEN_READWRITE |
1348 | GNUNET_DISK_OPEN_CREATE, 1320 GNUNET_DISK_OPEN_CREATE,
1349 GNUNET_DISK_PERM_USER_READ | 1321 GNUNET_DISK_PERM_USER_READ |
1350 GNUNET_DISK_PERM_USER_WRITE); 1322 GNUNET_DISK_PERM_USER_WRITE);
1351 GNUNET_assert (fn != NULL); 1323 GNUNET_assert (fn != NULL);
@@ -1358,8 +1330,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1358 if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile)) 1330 if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile))
1359 { 1331 {
1360 if (0 != UNLINK (ret->cfgfile)) 1332 if (0 != UNLINK (ret->cfgfile))
1361 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 1333 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
1362 "unlink", ret->cfgfile); 1334 ret->cfgfile);
1363 GNUNET_CONFIGURATION_destroy (ret->cfg); 1335 GNUNET_CONFIGURATION_destroy (ret->cfg);
1364 GNUNET_free_non_null (ret->hostname); 1336 GNUNET_free_non_null (ret->hostname);
1365 GNUNET_free (ret->cfgfile); 1337 GNUNET_free (ret->cfgfile);
@@ -1368,11 +1340,10 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1368 } 1340 }
1369 if (ssh_username != NULL) 1341 if (ssh_username != NULL)
1370 username = GNUNET_strdup (ssh_username); 1342 username = GNUNET_strdup (ssh_username);
1371 if ((ssh_username == NULL) && (GNUNET_OK != 1343 if ((ssh_username == NULL) &&
1372 GNUNET_CONFIGURATION_get_value_string (cfg, 1344 (GNUNET_OK !=
1373 "TESTING", 1345 GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "USERNAME",
1374 "USERNAME", 1346 &username)))
1375 &username)))
1376 { 1347 {
1377 if (NULL != getenv ("USER")) 1348 if (NULL != getenv ("USER"))
1378 username = GNUNET_strdup (getenv ("USER")); 1349 username = GNUNET_strdup (getenv ("USER"));
@@ -1420,13 +1391,13 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1420 } 1391 }
1421 else 1392 else
1422 { 1393 {
1423 ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp", 1394 ret->proc =
1424 "scp", "-r", "-P", 1395 GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r", "-P",
1425 ret->ssh_port_str, 1396 ret->ssh_port_str,
1426#if !DEBUG_TESTING 1397#if !DEBUG_TESTING
1427 "-q", 1398 "-q",
1428#endif 1399#endif
1429 servicehome, arg, NULL); 1400 servicehome, arg, NULL);
1430 } 1401 }
1431 GNUNET_free (arg); 1402 GNUNET_free (arg);
1432 if (NULL == ret->proc) 1403 if (NULL == ret->proc)
@@ -1436,25 +1407,25 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1436 ("Could not start `%s' process to copy configuration directory.\n"), 1407 ("Could not start `%s' process to copy configuration directory.\n"),
1437 "scp"); 1408 "scp");
1438 if (0 != UNLINK (ret->cfgfile)) 1409 if (0 != UNLINK (ret->cfgfile))
1439 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 1410 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
1440 "unlink", ret->cfgfile); 1411 ret->cfgfile);
1441 GNUNET_CONFIGURATION_destroy (ret->cfg); 1412 GNUNET_CONFIGURATION_destroy (ret->cfg);
1442 GNUNET_free_non_null (ret->hostname); 1413 GNUNET_free_non_null (ret->hostname);
1443 GNUNET_free_non_null (ret->username); 1414 GNUNET_free_non_null (ret->username);
1444 GNUNET_free (ret->cfgfile); 1415 GNUNET_free (ret->cfgfile);
1445 GNUNET_free (ret); 1416 GNUNET_free (ret);
1446 if ((hostkey != NULL) && (0 != UNLINK (hostkeyfile))) 1417 if ((hostkey != NULL) && (0 != UNLINK (hostkeyfile)))
1447 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 1418 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
1448 "unlink", hostkeyfile); 1419 hostkeyfile);
1449 GNUNET_free_non_null (hostkeyfile); 1420 GNUNET_free_non_null (hostkeyfile);
1450 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (servicehome)); 1421 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (servicehome));
1451 GNUNET_free (servicehome); 1422 GNUNET_free (servicehome);
1452 return NULL; 1423 return NULL;
1453 } 1424 }
1454 1425
1455 ret->task 1426 ret->task =
1456 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 1427 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
1457 &start_fsm, ret); 1428 ret);
1458 GNUNET_free_non_null (hostkeyfile); 1429 GNUNET_free_non_null (hostkeyfile);
1459 GNUNET_free (servicehome); 1430 GNUNET_free (servicehome);
1460 return ret; 1431 return ret;
@@ -1464,8 +1435,7 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1464 "No need to copy configuration file since we are running locally.\n"); 1435 "No need to copy configuration file since we are running locally.\n");
1465#endif 1436#endif
1466 ret->phase = SP_COPIED; 1437 ret->phase = SP_COPIED;
1467 GNUNET_SCHEDULER_add_continuation (&start_fsm, 1438 GNUNET_SCHEDULER_add_continuation (&start_fsm, ret,
1468 ret,
1469 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1439 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1470 } 1440 }
1471 GNUNET_free_non_null (hostkeyfile); 1441 GNUNET_free_non_null (hostkeyfile);
@@ -1520,8 +1490,8 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
1520 GNUNET_free_non_null (d->hello); 1490 GNUNET_free_non_null (d->hello);
1521 1491
1522#if DEBUG_TESTING 1492#if DEBUG_TESTING
1523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1493 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
1524 _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); 1494 GNUNET_i2s (&d->id));
1525#endif 1495#endif
1526 1496
1527 d->phase = SP_START_ARMING; 1497 d->phase = SP_START_ARMING;
@@ -1567,9 +1537,8 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
1567 } 1537 }
1568 1538
1569 GNUNET_free_non_null (del_arg); 1539 GNUNET_free_non_null (del_arg);
1570 d->task 1540 d->task =
1571 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 1541 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d);
1572 &start_fsm, d);
1573 1542
1574} 1543}
1575 1544
@@ -1608,8 +1577,8 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d,
1608 } 1577 }
1609 1578
1610#if DEBUG_TESTING 1579#if DEBUG_TESTING
1611 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1580 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
1612 _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); 1581 GNUNET_i2s (&d->id));
1613#endif 1582#endif
1614 if (d->churned_services != NULL) 1583 if (d->churned_services != NULL)
1615 { 1584 {
@@ -1698,8 +1667,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1698 if (NULL != d->cb) 1667 if (NULL != d->cb)
1699 { 1668 {
1700#if DEBUG_TESTING 1669#if DEBUG_TESTING
1701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1670 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Setting d->dead on peer `%4s'\n"),
1702 _("Setting d->dead on peer `%4s'\n"), GNUNET_i2s (&d->id)); 1671 GNUNET_i2s (&d->id));
1703#endif 1672#endif
1704 d->dead = GNUNET_YES; 1673 d->dead = GNUNET_YES;
1705 return; 1674 return;
@@ -1746,8 +1715,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1746 */ 1715 */
1747 /* shutdown ARM process (will terminate others) */ 1716 /* shutdown ARM process (will terminate others) */
1748#if DEBUG_TESTING 1717#if DEBUG_TESTING
1749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1718 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
1750 _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); 1719 GNUNET_i2s (&d->id));
1751#endif 1720#endif
1752 d->phase = SP_SHUTDOWN_START; 1721 d->phase = SP_SHUTDOWN_START;
1753 d->running = GNUNET_NO; 1722 d->running = GNUNET_NO;
@@ -1781,8 +1750,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1781#if DEBUG_TESTING 1750#if DEBUG_TESTING
1782 "-L", "DEBUG", 1751 "-L", "DEBUG",
1783#endif 1752#endif
1784 "-c", d->cfgfile, "-e", "-q", 1753 "-c", d->cfgfile, "-e", "-q", "-T",
1785 "-T",
1786 GNUNET_TIME_relative_to_string (timeout), 1754 GNUNET_TIME_relative_to_string (timeout),
1787 del_arg, NULL); 1755 del_arg, NULL);
1788 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1801,8 +1769,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1801#if DEBUG_TESTING 1769#if DEBUG_TESTING
1802 "-L", "DEBUG", 1770 "-L", "DEBUG",
1803#endif 1771#endif
1804 "-c", d->cfgfile, "-e", "-q", 1772 "-c", d->cfgfile, "-e", "-q", "-T",
1805 "-T",
1806 GNUNET_TIME_relative_to_string (timeout), 1773 GNUNET_TIME_relative_to_string (timeout),
1807 del_arg, NULL); 1774 del_arg, NULL);
1808 } 1775 }
@@ -1873,8 +1840,7 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
1873 if (NULL == d->proc) 1840 if (NULL == d->proc)
1874 { 1841 {
1875 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1842 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1876 _ 1843 _("Could not start `%s' process to copy configuration file.\n"),
1877 ("Could not start `%s' process to copy configuration file.\n"),
1878 "scp"); 1844 "scp");
1879 if (NULL != cb) 1845 if (NULL != cb)
1880 cb (cb_cls, _("Failed to copy new configuration to remote machine.")); 1846 cb (cb_cls, _("Failed to copy new configuration to remote machine."));
@@ -1883,9 +1849,8 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
1883 } 1849 }
1884 d->update_cb = cb; 1850 d->update_cb = cb;
1885 d->update_cb_cls = cb_cls; 1851 d->update_cb_cls = cb_cls;
1886 d->task 1852 d->task =
1887 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 1853 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d);
1888 &start_fsm, d);
1889} 1854}
1890 1855
1891 1856
@@ -1981,9 +1946,9 @@ struct ConnectContext
1981 1946
1982 1947
1983/** Forward declaration **/ 1948/** Forward declaration **/
1984static void 1949static void reattempt_daemons_connect (void *cls,
1985reattempt_daemons_connect (void *cls, 1950 const struct GNUNET_SCHEDULER_TaskContext
1986 const struct GNUNET_SCHEDULER_TaskContext *tc); 1951 *tc);
1987 1952
1988 1953
1989/** 1954/**
@@ -2039,10 +2004,7 @@ notify_connect_result (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2039 { 2004 {
2040 if (ctx->cb != NULL) 2005 if (ctx->cb != NULL)
2041 { 2006 {
2042 ctx->cb (ctx->cb_cls, 2007 ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->distance,
2043 &ctx->d1->id,
2044 &ctx->d2->id,
2045 ctx->distance,
2046 ctx->d1->cfg, ctx->d2->cfg, ctx->d1, ctx->d2, NULL); 2008 ctx->d1->cfg, ctx->d2->cfg, ctx->d1, ctx->d2, NULL);
2047 } 2009 }
2048 } 2010 }
@@ -2081,15 +2043,13 @@ notify_connect_result (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2081 * 2043 *
2082 */ 2044 */
2083static void 2045static void
2084connect_notify (void *cls, 2046connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
2085 const struct GNUNET_PeerIdentity *peer,
2086 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 2047 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
2087{ 2048{
2088 struct ConnectContext *ctx = cls; 2049 struct ConnectContext *ctx = cls;
2089 2050
2090#if DEBUG_TESTING 2051#if DEBUG_TESTING
2091 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2052 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Connected peer %s to peer %s\n",
2092 "Connected peer %s to peer %s\n",
2093 ctx->d1->shortname, GNUNET_i2s (peer)); 2053 ctx->d1->shortname, GNUNET_i2s (peer));
2094#endif 2054#endif
2095 2055
@@ -2118,8 +2078,7 @@ connect_notify (void *cls,
2118 * 2078 *
2119 */ 2079 */
2120static void 2080static void
2121connect_notify_core2 (void *cls, 2081connect_notify_core2 (void *cls, const struct GNUNET_PeerIdentity *peer,
2122 const struct GNUNET_PeerIdentity *peer,
2123 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 2082 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
2124{ 2083{
2125 struct ConnectContext *ctx = cls; 2084 struct ConnectContext *ctx = cls;
@@ -2158,9 +2117,9 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2158 ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK; 2117 ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK;
2159 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 2118 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
2160 return; 2119 return;
2161 if ((ctx->d1core_ready == GNUNET_YES) && (ctx->d2->hello != NULL) 2120 if ((ctx->d1core_ready == GNUNET_YES) && (ctx->d2->hello != NULL) &&
2162 && (NULL != GNUNET_HELLO_get_header (ctx->d2->hello)) 2121 (NULL != GNUNET_HELLO_get_header (ctx->d2->hello)) &&
2163 && (ctx->d1->phase == SP_START_DONE) && (ctx->d2->phase == SP_START_DONE)) 2122 (ctx->d1->phase == SP_START_DONE) && (ctx->d2->phase == SP_START_DONE))
2164 { 2123 {
2165 hello = GNUNET_HELLO_get_header (ctx->d2->hello); 2124 hello = GNUNET_HELLO_get_header (ctx->d2->hello);
2166 GNUNET_assert (hello != NULL); 2125 GNUNET_assert (hello != NULL);
@@ -2171,8 +2130,7 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2171 GNUNET_TRANSPORT_offer_hello (ctx->d1th, hello, NULL, NULL); 2130 GNUNET_TRANSPORT_offer_hello (ctx->d1th, hello, NULL, NULL);
2172 GNUNET_assert (ctx->d1core != NULL); 2131 GNUNET_assert (ctx->d1core != NULL);
2173 ctx->connect_request_handle = 2132 ctx->connect_request_handle =
2174 GNUNET_CORE_peer_request_connect (ctx->d1core, 2133 GNUNET_CORE_peer_request_connect (ctx->d1core, &ctx->d2->id,
2175 &ctx->d2->id,
2176 &core_connect_request_cont, ctx); 2134 &core_connect_request_cont, ctx);
2177 2135
2178#if DEBUG_TESTING 2136#if DEBUG_TESTING
@@ -2186,8 +2144,8 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2186 GNUNET_TIME_relative_multiply 2144 GNUNET_TIME_relative_multiply
2187 (GNUNET_TIME_UNIT_MILLISECONDS, 500)); 2145 (GNUNET_TIME_UNIT_MILLISECONDS, 500));
2188 } 2146 }
2189 ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed (ctx->timeout_hello, 2147 ctx->hello_send_task =
2190 &send_hello, ctx); 2148 GNUNET_SCHEDULER_add_delayed (ctx->timeout_hello, &send_hello, ctx);
2191} 2149}
2192 2150
2193/** 2151/**
@@ -2199,11 +2157,10 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2199 * @param publicKey the public key of the peer 2157 * @param publicKey the public key of the peer
2200 */ 2158 */
2201void 2159void
2202core_init_notify (void *cls, 2160core_init_notify (void *cls, struct GNUNET_CORE_Handle *server,
2203 struct GNUNET_CORE_Handle *server,
2204 const struct GNUNET_PeerIdentity *my_identity, 2161 const struct GNUNET_PeerIdentity *my_identity,
2205 const struct 2162 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
2206 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 2163 *publicKey)
2207{ 2164{
2208 struct ConnectContext *connect_ctx = cls; 2165 struct ConnectContext *connect_ctx = cls;
2209 2166
@@ -2246,12 +2203,10 @@ reattempt_daemons_connect (void *cls,
2246 ctx->connect_attempts--; 2203 ctx->connect_attempts--;
2247 GNUNET_assert (ctx->d1core == NULL); 2204 GNUNET_assert (ctx->d1core == NULL);
2248 ctx->d1core_ready = GNUNET_NO; 2205 ctx->d1core_ready = GNUNET_NO;
2249 ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, 1, 2206 ctx->d1core =
2250 ctx, 2207 GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify,
2251 &core_init_notify, 2208 &connect_notify, NULL, NULL, NULL, GNUNET_NO, NULL,
2252 &connect_notify, NULL, NULL, 2209 GNUNET_NO, no_handlers);
2253 NULL, GNUNET_NO,
2254 NULL, GNUNET_NO, no_handlers);
2255 if (ctx->d1core == NULL) 2210 if (ctx->d1core == NULL)
2256 { 2211 {
2257 if (NULL != ctx->cb) 2212 if (NULL != ctx->cb)
@@ -2299,9 +2254,9 @@ reattempt_daemons_connect (void *cls,
2299 2254
2300 if (ctx->send_hello == GNUNET_YES) 2255 if (ctx->send_hello == GNUNET_YES)
2301 { 2256 {
2302 ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, 2257 ctx->d1th =
2303 &ctx->d1->id, 2258 GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL,
2304 ctx->d1, NULL, NULL, NULL); 2259 NULL, NULL);
2305 if (ctx->d1th == NULL) 2260 if (ctx->d1th == NULL)
2306 { 2261 {
2307 GNUNET_CORE_disconnect (ctx->d1core); 2262 GNUNET_CORE_disconnect (ctx->d1core);
@@ -2317,8 +2272,7 @@ reattempt_daemons_connect (void *cls,
2317 else 2272 else
2318 { 2273 {
2319 ctx->connect_request_handle = 2274 ctx->connect_request_handle =
2320 GNUNET_CORE_peer_request_connect (ctx->d1core, 2275 GNUNET_CORE_peer_request_connect (ctx->d1core, &ctx->d2->id,
2321 &ctx->d2->id,
2322 &core_connect_request_cont, ctx); 2276 &core_connect_request_cont, ctx);
2323 } 2277 }
2324 ctx->timeout_task = 2278 ctx->timeout_task =
@@ -2338,8 +2292,7 @@ reattempt_daemons_connect (void *cls,
2338 * 2292 *
2339 */ 2293 */
2340static void 2294static void
2341core_initial_iteration (void *cls, 2295core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer,
2342 const struct GNUNET_PeerIdentity *peer,
2343 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 2296 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
2344{ 2297{
2345 struct ConnectContext *ctx = cls; 2298 struct ConnectContext *ctx = cls;
@@ -2355,8 +2308,8 @@ core_initial_iteration (void *cls,
2355 { 2308 {
2356 if (ctx->connected == GNUNET_YES) 2309 if (ctx->connected == GNUNET_YES)
2357 { 2310 {
2358 ctx->timeout_task = GNUNET_SCHEDULER_add_now (&notify_connect_result, 2311 ctx->timeout_task =
2359 ctx); 2312 GNUNET_SCHEDULER_add_now (&notify_connect_result, ctx);
2360 return; 2313 return;
2361 } 2314 }
2362 2315
@@ -2367,12 +2320,10 @@ core_initial_iteration (void *cls,
2367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2368 "Peers are NOT connected, connecting to core!\n"); 2321 "Peers are NOT connected, connecting to core!\n");
2369#endif 2322#endif
2370 ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, 1, 2323 ctx->d1core =
2371 ctx, 2324 GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify,
2372 &core_init_notify, 2325 &connect_notify, NULL, NULL, NULL, GNUNET_NO,
2373 &connect_notify, NULL, NULL, 2326 NULL, GNUNET_NO, no_handlers);
2374 NULL, GNUNET_NO,
2375 NULL, GNUNET_NO, no_handlers);
2376 } 2327 }
2377 2328
2378 if (ctx->d1core == NULL) 2329 if (ctx->d1core == NULL)
@@ -2405,9 +2356,9 @@ core_initial_iteration (void *cls,
2405 2356
2406 if (ctx->send_hello == GNUNET_YES) 2357 if (ctx->send_hello == GNUNET_YES)
2407 { 2358 {
2408 ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, 2359 ctx->d1th =
2409 &ctx->d1->id, ctx->d1, NULL, NULL, 2360 GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL,
2410 NULL); 2361 NULL, NULL);
2411 if (ctx->d1th == NULL) 2362 if (ctx->d1th == NULL)
2412 { 2363 {
2413 GNUNET_CORE_disconnect (ctx->d1core); 2364 GNUNET_CORE_disconnect (ctx->d1core);
@@ -2475,8 +2426,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
2475 ctx->connected = GNUNET_NO; 2426 ctx->connected = GNUNET_NO;
2476 ctx->send_hello = send_hello; 2427 ctx->send_hello = send_hello;
2477#if DEBUG_TESTING 2428#if DEBUG_TESTING
2478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2429 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to connect peer %s to peer %s\n",
2479 "Asked to connect peer %s to peer %s\n",
2480 d1->shortname, d2->shortname); 2430 d1->shortname, d2->shortname);
2481#endif 2431#endif
2482 2432
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 723afd456..d03cb307b 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -87,12 +87,13 @@ enum PeerLists
87 * Prototype of a function called whenever two peers would be connected 87 * Prototype of a function called whenever two peers would be connected
88 * in a certain topology. 88 * in a certain topology.
89 */ 89 */
90typedef unsigned int 90typedef unsigned int (*GNUNET_TESTING_ConnectionProcessor) (struct
91 (*GNUNET_TESTING_ConnectionProcessor) (struct GNUNET_TESTING_PeerGroup * pg, 91 GNUNET_TESTING_PeerGroup
92 unsigned int first, 92 * pg,
93 unsigned int second, 93 unsigned int first,
94 enum PeerLists list, 94 unsigned int second,
95 unsigned int check); 95 enum PeerLists list,
96 unsigned int check);
96 97
97/** 98/**
98 * Context for handling churning a peer group 99 * Context for handling churning a peer group
@@ -1091,8 +1092,8 @@ update_meter (struct ProgressMeter *meter)
1091 fprintf (stdout, "%sProgress: [0%%", meter->startup_string); 1092 fprintf (stdout, "%sProgress: [0%%", meter->startup_string);
1092 } 1093 }
1093 else 1094 else
1094 fprintf (stdout, "%d%%", (int) (((float) meter->completed 1095 fprintf (stdout, "%d%%",
1095 / meter->total) * 100)); 1096 (int) (((float) meter->completed / meter->total) * 100));
1096 } 1097 }
1097 else if (meter->completed % meter->dotnum == 0) 1098 else if (meter->completed % meter->dotnum == 0)
1098 fprintf (stdout, "."); 1099 fprintf (stdout, ".");
@@ -1332,24 +1333,24 @@ update_config (void *cls, const char *section, const char *option,
1332 1333
1333 if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival))) 1334 if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival)))
1334 { 1335 {
1335 if ((ival != 0) && (GNUNET_YES 1336 if ((ival != 0) &&
1336 != GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, 1337 (GNUNET_YES !=
1337 "testing", 1338 GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
1338 single_variable))) 1339 single_variable)))
1339 { 1340 {
1340 GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++); 1341 GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++);
1341 value = cval; 1342 value = cval;
1342 } 1343 }
1343 else if ((ival != 0) && (GNUNET_YES 1344 else if ((ival != 0) &&
1344 == GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, 1345 (GNUNET_YES ==
1345 "testing", 1346 GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
1346 single_variable)) 1347 single_variable)) &&
1347 && GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing", 1348 GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing",
1348 per_host_variable, 1349 per_host_variable,
1349 &num_per_host)) 1350 &num_per_host))
1350 { 1351 {
1351 GNUNET_snprintf (cval, sizeof (cval), "%u", ival + ctx->fdnum 1352 GNUNET_snprintf (cval, sizeof (cval), "%u",
1352 % num_per_host); 1353 ival + ctx->fdnum % num_per_host);
1353 value = cval; 1354 value = cval;
1354 } 1355 }
1355 1356
@@ -1361,23 +1362,23 @@ update_config (void *cls, const char *section, const char *option,
1361 1362
1362 if (0 == strcmp (option, "UNIXPATH")) 1363 if (0 == strcmp (option, "UNIXPATH"))
1363 { 1364 {
1364 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, 1365 if (GNUNET_YES !=
1365 "testing", 1366 GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
1366 single_variable)) 1367 single_variable))
1367 { 1368 {
1368 GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", 1369 GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", section,
1369 section, ctx->upnum++); 1370 ctx->upnum++);
1370 value = uval; 1371 value = uval;
1371 } 1372 }
1372 else if ((GNUNET_YES 1373 else if ((GNUNET_YES ==
1373 == GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing", 1374 GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing",
1374 per_host_variable, 1375 per_host_variable,
1375 &num_per_host)) 1376 &num_per_host)) &&
1376 && (num_per_host > 0)) 1377 (num_per_host > 0))
1377 1378
1378 { 1379 {
1379 GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", 1380 GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", section,
1380 section, ctx->fdnum % num_per_host); 1381 ctx->fdnum % num_per_host);
1381 value = uval; 1382 value = uval;
1382 } 1383 }
1383 } 1384 }
@@ -1437,10 +1438,10 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
1437 return NULL; 1438 return NULL;
1438 } 1439 }
1439 1440
1440 if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", 1441 if ((GNUNET_OK ==
1441 "skew_variance", 1442 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "skew_variance",
1442 &skew_variance)) 1443 &skew_variance)) &&
1443 && (skew_variance > 0)) 1444 (skew_variance > 0))
1444 { 1445 {
1445 skew_offset = 1446 skew_offset =
1446 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 1447 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
@@ -1454,8 +1455,8 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
1454 skew_offset); 1455 skew_offset);
1455 } 1456 }
1456 1457
1457 if (GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "control_host", 1458 if (GNUNET_CONFIGURATION_get_value_string
1458 &control_host) == GNUNET_OK) 1459 (cfg, "testing", "control_host", &control_host) == GNUNET_OK)
1459 { 1460 {
1460 if (hostname != NULL) 1461 if (hostname != NULL)
1461 GNUNET_asprintf (&allowed_hosts, "%s; 127.0.0.1; %s;", control_host, 1462 GNUNET_asprintf (&allowed_hosts, "%s; 127.0.0.1; %s;", control_host,
@@ -1469,12 +1470,12 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
1469 GNUNET_CONFIGURATION_set_value_string (uc.ret, "nse", "ACCEPT_FROM", 1470 GNUNET_CONFIGURATION_set_value_string (uc.ret, "nse", "ACCEPT_FROM",
1470 allowed_hosts); 1471 allowed_hosts);
1471 1472
1472 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", 1473 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "ACCEPT_FROM",
1473 "ACCEPT_FROM", allowed_hosts); 1474 allowed_hosts);
1474 GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "ACCEPT_FROM", 1475 GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "ACCEPT_FROM",
1475 allowed_hosts); 1476 allowed_hosts);
1476 GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", 1477 GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "ACCEPT_FROM",
1477 "ACCEPT_FROM", allowed_hosts); 1478 allowed_hosts);
1478 1479
1479 GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", ""); 1480 GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", "");
1480 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", ""); 1481 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", "");
@@ -1629,23 +1630,19 @@ remove_connections (struct GNUNET_TESTING_PeerGroup *pg, unsigned int first,
1629 } 1630 }
1630#else 1631#else
1631 if (GNUNET_YES == 1632 if (GNUNET_YES ==
1632 GNUNET_CONTAINER_multihashmap_contains (pg-> 1633 GNUNET_CONTAINER_multihashmap_contains (pg->peers[first].
1633 peers[first].blacklisted_peers, 1634 blacklisted_peers, &hash_second))
1634 &hash_second))
1635 { 1635 {
1636 GNUNET_CONTAINER_multihashmap_remove_all (pg-> 1636 GNUNET_CONTAINER_multihashmap_remove_all (pg->peers[first].
1637 peers[first].blacklisted_peers, 1637 blacklisted_peers, &hash_second);
1638 &hash_second);
1639 } 1638 }
1640 1639
1641 if (GNUNET_YES == 1640 if (GNUNET_YES ==
1642 GNUNET_CONTAINER_multihashmap_contains (pg-> 1641 GNUNET_CONTAINER_multihashmap_contains (pg->peers[second].
1643 peers[second].blacklisted_peers, 1642 blacklisted_peers, &hash_first))
1644 &hash_first))
1645 { 1643 {
1646 GNUNET_CONTAINER_multihashmap_remove_all (pg-> 1644 GNUNET_CONTAINER_multihashmap_remove_all (pg->peers[second].
1647 peers[second].blacklisted_peers, 1645 blacklisted_peers, &hash_first);
1648 &hash_first);
1649 } 1646 }
1650#endif 1647#endif
1651 1648
@@ -1801,22 +1798,22 @@ create_scale_free (struct GNUNET_TESTING_PeerGroup *pg,
1801 previous_total_connections = total_connections; 1798 previous_total_connections = total_connections;
1802 for (i = 0; i < outer_count; i++) 1799 for (i = 0; i < outer_count; i++)
1803 { 1800 {
1804 probability = pg->peers[i].num_connections 1801 probability =
1805 / (double) previous_total_connections; 1802 pg->peers[i].num_connections / (double) previous_total_connections;
1806 random 1803 random =
1807 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 1804 ((double)
1808 UINT64_MAX)) 1805 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
1809 / ((double) UINT64_MAX); 1806 UINT64_MAX)) / ((double) UINT64_MAX);
1810#if VERBOSE_TESTING 1807#if VERBOSE_TESTING
1811 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1808 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1812 "Considering connecting peer %d to peer %d\n", 1809 "Considering connecting peer %d to peer %d\n", outer_count,
1813 outer_count, i); 1810 i);
1814#endif 1811#endif
1815 if (random < probability) 1812 if (random < probability)
1816 { 1813 {
1817#if VERBOSE_TESTING 1814#if VERBOSE_TESTING
1818 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1815 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
1819 "Connecting peer %d to peer %d\n", outer_count, i); 1816 outer_count, i);
1820#endif 1817#endif
1821 total_connections += proc (pg, outer_count, i, list, GNUNET_YES); 1818 total_connections += proc (pg, outer_count, i, list, GNUNET_YES);
1822 } 1819 }
@@ -1872,9 +1869,9 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg,
1872 int connect_attempts; 1869 int connect_attempts;
1873 1870
1874 logNModifier = 0.5; /* FIXME: default value? */ 1871 logNModifier = 0.5; /* FIXME: default value? */
1875 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 1872 if (GNUNET_OK ==
1876 "PERCENTAGE", 1873 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
1877 &p_string)) 1874 &p_string))
1878 { 1875 {
1879 if (sscanf (p_string, "%lf", &logNModifier) != 1) 1876 if (sscanf (p_string, "%lf", &logNModifier) != 1)
1880 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1877 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1884,9 +1881,9 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg,
1884 GNUNET_free (p_string); 1881 GNUNET_free (p_string);
1885 } 1882 }
1886 probability = 0.5; /* FIXME: default percentage? */ 1883 probability = 0.5; /* FIXME: default percentage? */
1887 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 1884 if (GNUNET_OK ==
1888 "PROBABILITY", 1885 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY",
1889 &p_string)) 1886 &p_string))
1890 { 1887 {
1891 if (sscanf (p_string, "%lf", &probability) != 1) 1888 if (sscanf (p_string, "%lf", &probability) != 1)
1892 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1889 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1926,22 +1923,20 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg,
1926 1923
1927 for (j = 0; j < connsPerPeer / 2; j++) 1924 for (j = 0; j < connsPerPeer / 2; j++)
1928 { 1925 {
1929 random 1926 random =
1930 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 1927 ((double)
1931 UINT64_MAX) 1928 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
1932 / ((double) UINT64_MAX)); 1929 UINT64_MAX) / ((double) UINT64_MAX));
1933 if (random < probability) 1930 if (random < probability)
1934 { 1931 {
1935 /* Connect to uniformly selected random peer */ 1932 /* Connect to uniformly selected random peer */
1936 randomPeer 1933 randomPeer =
1937 = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); 1934 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
1938 while ((((randomPeer < max) && (randomPeer > min)) && (useAnd 1935 while ((((randomPeer < max) && (randomPeer > min)) && (useAnd == 0)) ||
1939 == 0)) ||
1940 (((randomPeer > min) || (randomPeer < max)) && (useAnd == 1))) 1936 (((randomPeer > min) || (randomPeer < max)) && (useAnd == 1)))
1941 { 1937 {
1942 randomPeer 1938 randomPeer =
1943 = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1939 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
1944 pg->total);
1945 } 1940 }
1946 smallWorldConnections += proc (pg, i, randomPeer, list, GNUNET_YES); 1941 smallWorldConnections += proc (pg, i, randomPeer, list, GNUNET_YES);
1947 } 1942 }
@@ -1987,9 +1982,9 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg,
1987 char *p_string; 1982 char *p_string;
1988 1983
1989 nat_percentage = 0.6; /* FIXME: default percentage? */ 1984 nat_percentage = 0.6; /* FIXME: default percentage? */
1990 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 1985 if (GNUNET_OK ==
1991 "PERCENTAGE", 1986 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
1992 &p_string)) 1987 &p_string))
1993 { 1988 {
1994 if (sscanf (p_string, "%lf", &nat_percentage) != 1) 1989 if (sscanf (p_string, "%lf", &nat_percentage) != 1)
1995 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1990 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2008,12 +2003,11 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg,
2008 if ((outer_count > cutoff) || (inner_count > cutoff)) 2003 if ((outer_count > cutoff) || (inner_count > cutoff))
2009 { 2004 {
2010#if VERBOSE_TESTING 2005#if VERBOSE_TESTING
2011 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2006 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2012 "Connecting peer %d to peer %d\n",
2013 outer_count, inner_count); 2007 outer_count, inner_count);
2014#endif 2008#endif
2015 connect_attempts += proc (pg, outer_count, inner_count, list, 2009 connect_attempts +=
2016 GNUNET_YES); 2010 proc (pg, outer_count, inner_count, list, GNUNET_YES);
2017 } 2011 }
2018 } 2012 }
2019 } 2013 }
@@ -2047,9 +2041,9 @@ create_nated_internet_copy (struct GNUNET_TESTING_PeerGroup *pg,
2047 struct ProgressMeter *conn_meter; 2041 struct ProgressMeter *conn_meter;
2048 2042
2049 nat_percentage = 0.6; /* FIXME: default percentage? */ 2043 nat_percentage = 0.6; /* FIXME: default percentage? */
2050 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 2044 if (GNUNET_OK ==
2051 "PERCENTAGE", 2045 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
2052 &p_string)) 2046 &p_string))
2053 { 2047 {
2054 if (sscanf (p_string, "%lf", &nat_percentage) != 1) 2048 if (sscanf (p_string, "%lf", &nat_percentage) != 1)
2055 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2049 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2080,12 +2074,11 @@ create_nated_internet_copy (struct GNUNET_TESTING_PeerGroup *pg,
2080 if ((outer_count > cutoff) || (inner_count > cutoff)) 2074 if ((outer_count > cutoff) || (inner_count > cutoff))
2081 { 2075 {
2082#if VERBOSE_TESTING 2076#if VERBOSE_TESTING
2083 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2077 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2084 "Connecting peer %d to peer %d\n",
2085 outer_count, inner_count); 2078 outer_count, inner_count);
2086#endif 2079#endif
2087 connect_attempts += proc (pg, outer_count, inner_count, list, 2080 connect_attempts +=
2088 GNUNET_YES); 2081 proc (pg, outer_count, inner_count, list, GNUNET_YES);
2089 add_connections (pg, outer_count, inner_count, ALLOWED, GNUNET_NO); 2082 add_connections (pg, outer_count, inner_count, ALLOWED, GNUNET_NO);
2090 update_meter (conn_meter); 2083 update_meter (conn_meter);
2091 } 2084 }
@@ -2137,9 +2130,9 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2137 cols = square; 2130 cols = square;
2138 2131
2139 percentage = 0.5; /* FIXME: default percentage? */ 2132 percentage = 0.5; /* FIXME: default percentage? */
2140 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 2133 if (GNUNET_OK ==
2141 "PERCENTAGE", 2134 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
2142 &p_string)) 2135 &p_string))
2143 { 2136 {
2144 if (sscanf (p_string, "%lf", &percentage) != 1) 2137 if (sscanf (p_string, "%lf", &percentage) != 1)
2145 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2138 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2157,9 +2150,9 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2157 percentage = 0.5; 2150 percentage = 0.5;
2158 } 2151 }
2159 probability = 0.5; /* FIXME: default percentage? */ 2152 probability = 0.5; /* FIXME: default percentage? */
2160 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 2153 if (GNUNET_OK ==
2161 "PROBABILITY", 2154 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY",
2162 &p_string)) 2155 &p_string))
2163 { 2156 {
2164 if (sscanf (p_string, "%lf", &probability) != 1) 2157 if (sscanf (p_string, "%lf", &probability) != 1)
2165 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2158 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2182,8 +2175,7 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2182 } 2175 }
2183#if VERBOSE_TESTING 2176#if VERBOSE_TESTING
2184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2185 _ 2178 _("Connecting nodes in 2d torus topology: %u rows %u columns\n"),
2186 ("Connecting nodes in 2d torus topology: %u rows %u columns\n"),
2187 rows, cols); 2179 rows, cols);
2188#endif 2180#endif
2189 2181
@@ -2220,8 +2212,8 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2220 natLog = log (pg->total); 2212 natLog = log (pg->total);
2221#if VERBOSE_TESTING > 2 2213#if VERBOSE_TESTING > 2
2222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2223 _("natural log of %d is %d, will run %d iterations\n"), 2215 _("natural log of %d is %d, will run %d iterations\n"), pg->total,
2224 pg->total, natLog, (int) (natLog * percentage)); 2216 natLog, (int) (natLog * percentage));
2225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2226 _("Total connections added thus far: %u!\n"), connect_attempts); 2218 _("Total connections added thus far: %u!\n"), connect_attempts);
2227#endif 2219#endif
@@ -2249,10 +2241,10 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2249 /* Calculate probability as 1 over the square of the distance */ 2241 /* Calculate probability as 1 over the square of the distance */
2250 probability = 1.0 / (distance * distance); 2242 probability = 1.0 / (distance * distance);
2251 /* Choose a random value between 0 and 1 */ 2243 /* Choose a random value between 0 and 1 */
2252 random 2244 random =
2253 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 2245 ((double)
2254 UINT64_MAX)) 2246 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
2255 / ((double) UINT64_MAX); 2247 UINT64_MAX)) / ((double) UINT64_MAX);
2256 /* If random < probability, then connect the two nodes */ 2248 /* If random < probability, then connect the two nodes */
2257 if (random < probability) 2249 if (random < probability)
2258 smallWorldConnections += proc (pg, j, k, list, GNUNET_YES); 2250 smallWorldConnections += proc (pg, j, k, list, GNUNET_YES);
@@ -2295,9 +2287,9 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg,
2295 char *p_string; 2287 char *p_string;
2296 2288
2297 probability = 0.5; /* FIXME: default percentage? */ 2289 probability = 0.5; /* FIXME: default percentage? */
2298 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 2290 if (GNUNET_OK ==
2299 "PROBABILITY", 2291 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY",
2300 &p_string)) 2292 &p_string))
2301 { 2293 {
2302 if (sscanf (p_string, "%lf", &probability) != 1) 2294 if (sscanf (p_string, "%lf", &probability) != 1)
2303 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2295 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2311,18 +2303,18 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg,
2311 { 2303 {
2312 for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++) 2304 for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++)
2313 { 2305 {
2314 temp_rand 2306 temp_rand =
2315 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 2307 ((double)
2316 UINT64_MAX)) 2308 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
2317 / ((double) UINT64_MAX); 2309 UINT64_MAX)) / ((double) UINT64_MAX);
2318#if VERBOSE_TESTING 2310#if VERBOSE_TESTING
2319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2311 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("rand is %f probability is %f\n"),
2320 _("rand is %f probability is %f\n"), temp_rand, probability); 2312 temp_rand, probability);
2321#endif 2313#endif
2322 if (temp_rand < probability) 2314 if (temp_rand < probability)
2323 { 2315 {
2324 connect_attempts += proc (pg, outer_count, inner_count, list, 2316 connect_attempts +=
2325 GNUNET_YES); 2317 proc (pg, outer_count, inner_count, list, GNUNET_YES);
2326 } 2318 }
2327 } 2319 }
2328 } 2320 }
@@ -2376,8 +2368,7 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg,
2376 } 2368 }
2377#if VERBOSE_TESTING 2369#if VERBOSE_TESTING
2378 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2379 _ 2371 _("Connecting nodes in 2d torus topology: %u rows %u columns\n"),
2380 ("Connecting nodes in 2d torus topology: %u rows %u columns\n"),
2381 rows, cols); 2372 rows, cols);
2382#endif 2373#endif
2383 /* Rows and columns are all sorted out, now iterate over all nodes and connect each 2374 /* Rows and columns are all sorted out, now iterate over all nodes and connect each
@@ -2395,8 +2386,8 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg,
2395 else 2386 else
2396 nodeToConnect = i - cols + 1; 2387 nodeToConnect = i - cols + 1;
2397#if VERBOSE_TESTING 2388#if VERBOSE_TESTING
2398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i,
2399 "Connecting peer %d to peer %d\n", i, nodeToConnect); 2390 nodeToConnect);
2400#endif 2391#endif
2401 connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); 2392 connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES);
2402 2393
@@ -2413,8 +2404,8 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg,
2413 if (nodeToConnect < pg->total) 2404 if (nodeToConnect < pg->total)
2414 { 2405 {
2415#if VERBOSE_TESTING 2406#if VERBOSE_TESTING
2416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i,
2417 "Connecting peer %d to peer %d\n", i, nodeToConnect); 2408 nodeToConnect);
2418#endif 2409#endif
2419 connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); 2410 connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES);
2420 } 2411 }
@@ -2450,15 +2441,16 @@ create_clique (struct GNUNET_TESTING_PeerGroup *pg,
2450 2441
2451 connect_attempts = 0; 2442 connect_attempts = 0;
2452 2443
2453 conn_meter = create_meter ((((pg->total * pg->total) + pg->total) / 2) 2444 conn_meter =
2454 - pg->total, "Create Clique ", GNUNET_NO); 2445 create_meter ((((pg->total * pg->total) + pg->total) / 2) - pg->total,
2446 "Create Clique ", GNUNET_NO);
2455 for (outer_count = 0; outer_count < pg->total - 1; outer_count++) 2447 for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
2456 { 2448 {
2457 for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++) 2449 for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++)
2458 { 2450 {
2459#if VERBOSE_TESTING 2451#if VERBOSE_TESTING
2460 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2461 "Connecting peer %d to peer %d\n", outer_count, inner_count); 2453 outer_count, inner_count);
2462#endif 2454#endif
2463 connect_attempts += proc (pg, outer_count, inner_count, list, check); 2455 connect_attempts += proc (pg, outer_count, inner_count, list, check);
2464 update_meter (conn_meter); 2456 update_meter (conn_meter);
@@ -2568,8 +2560,8 @@ create_line (struct GNUNET_TESTING_PeerGroup *pg,
2568 for (count = 0; count < pg->total - 1; count++) 2560 for (count = 0; count < pg->total - 1; count++)
2569 { 2561 {
2570#if VERBOSE_TESTING 2562#if VERBOSE_TESTING
2571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2572 "Connecting peer %d to peer %d\n", count, count + 1); 2564 count, count + 1);
2573#endif 2565#endif
2574 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); 2566 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
2575 } 2567 }
@@ -2691,12 +2683,11 @@ create_from_file (struct GNUNET_TESTING_PeerGroup *pg, char *filename,
2691 return connect_attempts; 2683 return connect_attempts;
2692 } 2684 }
2693 /* Assume file is written with first peer 1, but array index is 0 */ 2685 /* Assume file is written with first peer 1, but array index is 0 */
2694 connect_attempts += proc (pg, first_peer_index - 1, second_peer_index 2686 connect_attempts +=
2695 - 1, list, GNUNET_YES); 2687 proc (pg, first_peer_index - 1, second_peer_index - 1, list,
2696 while ((buf[count] != '\n') && (buf[count] != ',') && (count 2688 GNUNET_YES);
2697 < 2689 while ((buf[count] != '\n') && (buf[count] != ',') &&
2698 frstat.st_size - 2690 (count < frstat.st_size - 1))
2699 1))
2700 count++; 2691 count++;
2701 if (buf[count] == '\n') 2692 if (buf[count] == '\n')
2702 { 2693 {
@@ -2746,8 +2737,8 @@ create_ring (struct GNUNET_TESTING_PeerGroup *pg,
2746 for (count = 0; count < pg->total - 1; count++) 2737 for (count = 0; count < pg->total - 1; count++)
2747 { 2738 {
2748#if VERBOSE_TESTING 2739#if VERBOSE_TESTING
2749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2740 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2750 "Connecting peer %d to peer %d\n", count, count + 1); 2741 count, count + 1);
2751#endif 2742#endif
2752 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); 2743 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
2753 } 2744 }
@@ -2873,8 +2864,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2873 conn_iter = pg->peers[pg_iter].allowed_peers_head; 2864 conn_iter = pg->peers[pg_iter].allowed_peers_head;
2874 while (conn_iter != NULL) 2865 while (conn_iter != NULL)
2875 { 2866 {
2876 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon-> 2867 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->id.
2877 id.hashPubKey, &peer_enc); 2868 hashPubKey, &peer_enc);
2878 fprintf (temp_friend_handle, "%s\n", (char *) &peer_enc); 2869 fprintf (temp_friend_handle, "%s\n", (char *) &peer_enc);
2879 conn_iter = conn_iter->next; 2870 conn_iter = conn_iter->next;
2880 } 2871 }
@@ -2885,8 +2876,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2885#endif 2876#endif
2886 fclose (temp_friend_handle); 2877 fclose (temp_friend_handle);
2887 2878
2888 if (GNUNET_OK 2879 if (GNUNET_OK !=
2889 !=
2890 GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg, 2880 GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg,
2891 "PATHS", "SERVICEHOME", 2881 "PATHS", "SERVICEHOME",
2892 &temp_service_path)) 2882 &temp_service_path))
@@ -2904,8 +2894,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2904 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ 2894 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
2905 { 2895 {
2906 GNUNET_asprintf (&arg, "%s/friends", temp_service_path); 2896 GNUNET_asprintf (&arg, "%s/friends", temp_service_path);
2907 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", "mv", 2897 procarr[pg_iter] =
2908 mytemp, arg, NULL); 2898 GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
2909 GNUNET_assert (procarr[pg_iter] != NULL); 2899 GNUNET_assert (procarr[pg_iter] != NULL);
2910#if VERBOSE_TESTING 2900#if VERBOSE_TESTING
2911 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2901 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2926,8 +2916,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2926 GNUNET_asprintf (&arg, "%s:%s/friends", 2916 GNUNET_asprintf (&arg, "%s:%s/friends",
2927 pg->peers[pg_iter].daemon->hostname, 2917 pg->peers[pg_iter].daemon->hostname,
2928 temp_service_path); 2918 temp_service_path);
2929 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", 2919 procarr[pg_iter] =
2930 mytemp, arg, NULL); 2920 GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL);
2931 GNUNET_assert (procarr[pg_iter] != NULL); 2921 GNUNET_assert (procarr[pg_iter] != NULL);
2932 ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */ 2922 ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */
2933 GNUNET_OS_process_close (procarr[pg_iter]); 2923 GNUNET_OS_process_close (procarr[pg_iter]);
@@ -2960,13 +2950,13 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2960 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 2950 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
2961 { 2951 {
2962#if VERBOSE_TESTING 2952#if VERBOSE_TESTING
2963 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking copy status of file %d\n",
2964 "Checking copy status of file %d\n", pg_iter); 2954 pg_iter);
2965#endif 2955#endif
2966 if (procarr[pg_iter] != NULL) /* Check for already completed! */ 2956 if (procarr[pg_iter] != NULL) /* Check for already completed! */
2967 { 2957 {
2968 if (GNUNET_OS_process_status 2958 if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) !=
2969 (procarr[pg_iter], &type, &return_code) != GNUNET_OK) 2959 GNUNET_OK)
2970 { 2960 {
2971 ret = GNUNET_SYSERR; 2961 ret = GNUNET_SYSERR;
2972 } 2962 }
@@ -3061,15 +3051,15 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3061 conn_iter = pg->peers[pg_iter].blacklisted_peers_head; 3051 conn_iter = pg->peers[pg_iter].blacklisted_peers_head;
3062 while (conn_iter != NULL) 3052 while (conn_iter != NULL)
3063 { 3053 {
3064 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon-> 3054 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->id.
3065 id.hashPubKey, &peer_enc); 3055 hashPubKey, &peer_enc);
3066 fprintf (temp_file_handle, "%s:%s\n", pos, (char *) &peer_enc); 3056 fprintf (temp_file_handle, "%s:%s\n", pos, (char *) &peer_enc);
3067 conn_iter = conn_iter->next; 3057 conn_iter = conn_iter->next;
3068 } 3058 }
3069#else 3059#else
3070 blacklist_ctx.transport = pos; 3060 blacklist_ctx.transport = pos;
3071 (void) GNUNET_CONTAINER_multihashmap_iterate (pg->peers 3061 (void) GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].
3072 [pg_iter].blacklisted_peers, 3062 blacklisted_peers,
3073 &blacklist_file_iterator, 3063 &blacklist_file_iterator,
3074 &blacklist_ctx); 3064 &blacklist_ctx);
3075#endif 3065#endif
@@ -3084,8 +3074,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3084 GNUNET_free (temp_transports); 3074 GNUNET_free (temp_transports);
3085 fclose (temp_file_handle); 3075 fclose (temp_file_handle);
3086 3076
3087 if (GNUNET_OK 3077 if (GNUNET_OK !=
3088 !=
3089 GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg, 3078 GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg,
3090 "PATHS", "SERVICEHOME", 3079 "PATHS", "SERVICEHOME",
3091 &temp_service_path)) 3080 &temp_service_path))
@@ -3103,8 +3092,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3103 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ 3092 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
3104 { 3093 {
3105 GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path); 3094 GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path);
3106 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", "mv", 3095 procarr[pg_iter] =
3107 mytemp, arg, NULL); 3096 GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
3108#if VERBOSE_TESTING 3097#if VERBOSE_TESTING
3109 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3098 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3110 _("Copying file with command cp %s %s\n"), mytemp, arg); 3099 _("Copying file with command cp %s %s\n"), mytemp, arg);
@@ -3123,8 +3112,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3123 GNUNET_asprintf (&arg, "%s:%s/blacklist", 3112 GNUNET_asprintf (&arg, "%s:%s/blacklist",
3124 pg->peers[pg_iter].daemon->hostname, 3113 pg->peers[pg_iter].daemon->hostname,
3125 temp_service_path); 3114 temp_service_path);
3126 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", 3115 procarr[pg_iter] =
3127 mytemp, arg, NULL); 3116 GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL);
3128 GNUNET_assert (procarr[pg_iter] != NULL); 3117 GNUNET_assert (procarr[pg_iter] != NULL);
3129 GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add scheduled blacklist file copy that parallelizes file copying! */ 3118 GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add scheduled blacklist file copy that parallelizes file copying! */
3130 3119
@@ -3151,8 +3140,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3151#endif 3140#endif
3152 if (procarr[pg_iter] != NULL) /* Check for already completed! */ 3141 if (procarr[pg_iter] != NULL) /* Check for already completed! */
3153 { 3142 {
3154 if (GNUNET_OS_process_status (procarr[pg_iter], &type, 3143 if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) !=
3155 &return_code) != GNUNET_OK) 3144 GNUNET_OK)
3156 { 3145 {
3157 ret = GNUNET_SYSERR; 3146 ret = GNUNET_SYSERR;
3158 } 3147 }
@@ -3187,8 +3176,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3187} 3176}
3188 3177
3189/* Forward Declaration */ 3178/* Forward Declaration */
3190static void 3179static void schedule_connect (void *cls,
3191schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 3180 const struct GNUNET_SCHEDULER_TaskContext *tc);
3192 3181
3193/** 3182/**
3194 * Choose a random peer's next connection to create, and 3183 * Choose a random peer's next connection to create, and
@@ -3206,11 +3195,11 @@ preschedule_connect (struct GNUNET_TESTING_PeerGroup *pg)
3206 3195
3207 if (ct_ctx->remaining_connections == 0) 3196 if (ct_ctx->remaining_connections == 0)
3208 return; 3197 return;
3209 random_peer 3198 random_peer =
3210 = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); 3199 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
3211 while (pg->peers[random_peer].connect_peers_head == NULL) 3200 while (pg->peers[random_peer].connect_peers_head == NULL)
3212 random_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 3201 random_peer =
3213 pg->total); 3202 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
3214 3203
3215 connection_iter = pg->peers[random_peer].connect_peers_head; 3204 connection_iter = pg->peers[random_peer].connect_peers_head;
3216 connect_context = GNUNET_malloc (sizeof (struct ConnectContext)); 3205 connect_context = GNUNET_malloc (sizeof (struct ConnectContext));
@@ -3330,19 +3319,19 @@ send_core_connect_requests (void *cls,
3330 conn = send_hello_context->peer->connect_peers_head; 3319 conn = send_hello_context->peer->connect_peers_head;
3331 while (conn != NULL) 3320 while (conn != NULL)
3332 { 3321 {
3333 GNUNET_CORE_peer_request_connect (send_hello_context->peer-> 3322 GNUNET_CORE_peer_request_connect (send_hello_context->peer->daemon->
3334 daemon->server, 3323 server,
3335 &send_hello_context->pg-> 3324 &send_hello_context->pg->peers[conn->
3336 peers[conn->index].daemon->id, NULL, 3325 index].
3337 NULL); 3326 daemon->id, NULL, NULL);
3338 conn = conn->next; 3327 conn = conn->next;
3339 } 3328 }
3340 send_hello_context->core_connect_task = 3329 send_hello_context->core_connect_task =
3341 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide 3330 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
3342 (send_hello_context->pg-> 3331 (send_hello_context->pg->ct_ctx.
3343 ct_ctx.connect_timeout, 3332 connect_timeout,
3344 send_hello_context->pg-> 3333 send_hello_context->pg->ct_ctx.
3345 ct_ctx.connect_attempts), 3334 connect_attempts),
3346 &send_core_connect_requests, 3335 &send_core_connect_requests,
3347 send_hello_context); 3336 send_hello_context);
3348 } 3337 }
@@ -3368,8 +3357,7 @@ send_core_connect_requests (void *cls,
3368 * doesn't take too long! 3357 * doesn't take too long!
3369 */ 3358 */
3370static void 3359static void
3371core_connect_notify (void *cls, 3360core_connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
3372 const struct GNUNET_PeerIdentity *peer,
3373 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 3361 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
3374{ 3362{
3375 struct SendHelloContext *send_hello_context = cls; 3363 struct SendHelloContext *send_hello_context = cls;
@@ -3380,8 +3368,7 @@ core_connect_notify (void *cls,
3380 struct PeerData *other_peer; 3368 struct PeerData *other_peer;
3381#endif 3369#endif
3382#if DEBUG_TESTING 3370#if DEBUG_TESTING
3383 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3371 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Connected peer %s to peer %s\n",
3384 "Connected peer %s to peer %s\n",
3385 ctx->d1->shortname, GNUNET_i2s (peer)); 3372 ctx->d1->shortname, GNUNET_i2s (peer));
3386#endif 3373#endif
3387 3374
@@ -3474,8 +3461,7 @@ core_connect_notify (void *cls,
3474 * @param publicKey the public key of the peer 3461 * @param publicKey the public key of the peer
3475 */ 3462 */
3476void 3463void
3477core_init (void *cls, 3464core_init (void *cls, struct GNUNET_CORE_Handle *server,
3478 struct GNUNET_CORE_Handle *server,
3479 const struct GNUNET_PeerIdentity *my_identity, 3465 const struct GNUNET_PeerIdentity *my_identity,
3480 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 3466 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
3481{ 3467{
@@ -3536,10 +3522,10 @@ hello_sent_callback (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3536 3522
3537 send_hello_context->core_connect_task = 3523 send_hello_context->core_connect_task =
3538 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide 3524 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
3539 (send_hello_context->pg-> 3525 (send_hello_context->pg->ct_ctx.
3540 ct_ctx.connect_timeout, 3526 connect_timeout,
3541 send_hello_context->pg-> 3527 send_hello_context->pg->ct_ctx.
3542 ct_ctx.connect_attempts), 3528 connect_attempts),
3543 &send_core_connect_requests, 3529 &send_core_connect_requests,
3544 send_hello_context); 3530 send_hello_context);
3545 } 3531 }
@@ -3590,22 +3576,22 @@ schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3590 if (send_hello_context->peer->daemon->th == NULL) 3576 if (send_hello_context->peer->daemon->th == NULL)
3591 { 3577 {
3592 pg->outstanding_connects++; /* Actual TRANSPORT, CORE connections! */ 3578 pg->outstanding_connects++; /* Actual TRANSPORT, CORE connections! */
3593 send_hello_context->peer->daemon->th 3579 send_hello_context->peer->daemon->th =
3594 = GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL, 3580 GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL,
3595 send_hello_context, NULL, NULL, NULL); 3581 send_hello_context, NULL, NULL, NULL);
3596 } 3582 }
3597#if DEBUG_TESTING 3583#if DEBUG_TESTING
3598 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3584 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3599 _("Offering Hello of peer %s to peer %s\n"), 3585 _("Offering Hello of peer %s to peer %s\n"),
3600 send_hello_context->peer->daemon->shortname, 3586 send_hello_context->peer->daemon->shortname,
3601 pg->peers[send_hello_context->peer_pos->index]. 3587 pg->peers[send_hello_context->peer_pos->index].daemon->
3602 daemon->shortname); 3588 shortname);
3603#endif 3589#endif
3604 GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th, 3590 GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th,
3605 (const struct GNUNET_MessageHeader *) 3591 (const struct GNUNET_MessageHeader *) pg->
3606 pg->peers[send_hello_context->peer_pos-> 3592 peers[send_hello_context->peer_pos->index].
3607 index].daemon->hello, 3593 daemon->hello, &hello_sent_callback,
3608 &hello_sent_callback, send_hello_context); 3594 send_hello_context);
3609 send_hello_context->peer_pos = send_hello_context->peer_pos->next; 3595 send_hello_context->peer_pos = send_hello_context->peer_pos->next;
3610 GNUNET_assert (send_hello_context->peer->daemon->th != NULL); 3596 GNUNET_assert (send_hello_context->peer->daemon->th != NULL);
3611 } 3597 }
@@ -3644,12 +3630,10 @@ internal_connect_notify (void *cls, const struct GNUNET_PeerIdentity *first,
3644 other_peer = NULL; 3630 other_peer = NULL;
3645#endif 3631#endif
3646 3632
3647 while ((connection != NULL) && (0 3633 while ((connection != NULL) &&
3648 != memcmp (first, 3634 (0 !=
3649 &pg->peers[connection-> 3635 memcmp (first, &pg->peers[connection->index].daemon->id,
3650 index].daemon->id, 3636 sizeof (struct GNUNET_PeerIdentity))))
3651 sizeof (struct
3652 GNUNET_PeerIdentity))))
3653 { 3637 {
3654 connection = connection->next; 3638 connection = connection->next;
3655 } 3639 }
@@ -3659,16 +3643,14 @@ internal_connect_notify (void *cls, const struct GNUNET_PeerIdentity *first,
3659 GNUNET_assert (0 < ct_ctx->remaining_connections); 3643 GNUNET_assert (0 < ct_ctx->remaining_connections);
3660 ct_ctx->remaining_connections--; 3644 ct_ctx->remaining_connections--;
3661 if (pg->notify_connection != NULL) /* Notify of reverse connection */ 3645 if (pg->notify_connection != NULL) /* Notify of reverse connection */
3662 pg->notify_connection (pg->notify_connection_cls, second, first, 3646 pg->notify_connection (pg->notify_connection_cls, second, first, distance,
3663 distance, second_cfg, first_cfg, second_daemon, 3647 second_cfg, first_cfg, second_daemon, first_daemon,
3664 first_daemon, emsg); 3648 emsg);
3665 3649
3666 GNUNET_CONTAINER_DLL_remove (pg-> 3650 GNUNET_CONTAINER_DLL_remove (pg->peers[connect_ctx->second_index].
3667 peers[connect_ctx-> 3651 connect_peers_head,
3668 second_index].connect_peers_head, 3652 pg->peers[connect_ctx->second_index].
3669 pg->peers[connect_ctx-> 3653 connect_peers_tail, connection);
3670 second_index].connect_peers_tail,
3671 connection);
3672 GNUNET_free (connection); 3654 GNUNET_free (connection);
3673 } 3655 }
3674 3656
@@ -3707,8 +3689,8 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3707 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 3689 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
3708 return; 3690 return;
3709 3691
3710 if ((pg->outstanding_connects > pg->max_outstanding_connections) 3692 if ((pg->outstanding_connects > pg->max_outstanding_connections) ||
3711 || (pg->stop_connects == GNUNET_YES)) 3693 (pg->stop_connects == GNUNET_YES))
3712 { 3694 {
3713#if VERBOSE_TESTING 3695#if VERBOSE_TESTING
3714 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3696 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -3729,10 +3711,10 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3729#endif 3711#endif
3730 pg->outstanding_connects++; 3712 pg->outstanding_connects++;
3731 pg->total_connects_scheduled++; 3713 pg->total_connects_scheduled++;
3732 GNUNET_TESTING_daemons_connect (pg-> 3714 GNUNET_TESTING_daemons_connect (pg->peers[connect_context->first_index].
3733 peers[connect_context->first_index].daemon, 3715 daemon,
3734 pg->peers[connect_context-> 3716 pg->peers[connect_context->second_index].
3735 second_index].daemon, 3717 daemon,
3736 connect_context->ct_ctx->connect_timeout, 3718 connect_context->ct_ctx->connect_timeout,
3737 connect_context->ct_ctx->connect_attempts, 3719 connect_context->ct_ctx->connect_attempts,
3738#if USE_SEND_HELLOS 3720#if USE_SEND_HELLOS
@@ -4032,11 +4014,11 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4032#if VERBOSE_TESTING 4014#if VERBOSE_TESTING
4033 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating topology from file!\n")); 4015 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating topology from file!\n"));
4034#endif 4016#endif
4035 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing", 4017 if (GNUNET_OK ==
4036 "topology_file", 4018 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing",
4037 &filename)) 4019 "topology_file", &filename))
4038 num_connections = create_from_file (pg, filename, &add_connections, 4020 num_connections =
4039 ALLOWED); 4021 create_from_file (pg, filename, &add_connections, ALLOWED);
4040 else 4022 else
4041 { 4023 {
4042 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 4024 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -4057,8 +4039,8 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4057 break; 4039 break;
4058 } 4040 }
4059 4041
4060 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", 4042 if (GNUNET_YES ==
4061 "F2F")) 4043 GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F"))
4062 { 4044 {
4063 ret = create_and_copy_friend_files (pg); 4045 ret = create_and_copy_friend_files (pg);
4064 if (ret != GNUNET_OK) 4046 if (ret != GNUNET_OK)
@@ -4079,9 +4061,8 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4079 } 4061 }
4080 4062
4081 /* Use the create clique method to initially set all connections as blacklisted. */ 4063 /* Use the create clique method to initially set all connections as blacklisted. */
4082 if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) && (restrict_topology 4064 if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) &&
4083 != 4065 (restrict_topology != GNUNET_TESTING_TOPOLOGY_FROM_FILE))
4084 GNUNET_TESTING_TOPOLOGY_FROM_FILE))
4085 create_clique (pg, &add_connections, BLACKLIST, GNUNET_NO); 4066 create_clique (pg, &add_connections, BLACKLIST, GNUNET_NO);
4086 else 4067 else
4087 return num_connections; 4068 return num_connections;
@@ -4095,49 +4076,48 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4095 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4076 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4096 _("Blacklisting all but clique topology\n")); 4077 _("Blacklisting all but clique topology\n"));
4097#endif 4078#endif
4098 unblacklisted_connections = create_clique (pg, &remove_connections, 4079 unblacklisted_connections =
4099 BLACKLIST, GNUNET_NO); 4080 create_clique (pg, &remove_connections, BLACKLIST, GNUNET_NO);
4100 break; 4081 break;
4101 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: 4082 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
4102#if VERBOSE_TESTING 4083#if VERBOSE_TESTING
4103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4084 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4104 _("Blacklisting all but small world (ring) topology\n")); 4085 _("Blacklisting all but small world (ring) topology\n"));
4105#endif 4086#endif
4106 unblacklisted_connections = create_small_world_ring (pg, 4087 unblacklisted_connections =
4107 &remove_connections, 4088 create_small_world_ring (pg, &remove_connections, BLACKLIST);
4108 BLACKLIST);
4109 break; 4089 break;
4110 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: 4090 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
4111#if VERBOSE_TESTING 4091#if VERBOSE_TESTING
4112 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4092 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4113 _("Blacklisting all but small world (2d-torus) topology\n")); 4093 _("Blacklisting all but small world (2d-torus) topology\n"));
4114#endif 4094#endif
4115 unblacklisted_connections = create_small_world (pg, &remove_connections, 4095 unblacklisted_connections =
4116 BLACKLIST); 4096 create_small_world (pg, &remove_connections, BLACKLIST);
4117 break; 4097 break;
4118 case GNUNET_TESTING_TOPOLOGY_RING: 4098 case GNUNET_TESTING_TOPOLOGY_RING:
4119#if VERBOSE_TESTING 4099#if VERBOSE_TESTING
4120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4121 _("Blacklisting all but ring topology\n")); 4101 _("Blacklisting all but ring topology\n"));
4122#endif 4102#endif
4123 unblacklisted_connections 4103 unblacklisted_connections =
4124 = create_ring (pg, &remove_connections, BLACKLIST); 4104 create_ring (pg, &remove_connections, BLACKLIST);
4125 break; 4105 break;
4126 case GNUNET_TESTING_TOPOLOGY_2D_TORUS: 4106 case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
4127#if VERBOSE_TESTING 4107#if VERBOSE_TESTING
4128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4129 _("Blacklisting all but 2d torus topology\n")); 4109 _("Blacklisting all but 2d torus topology\n"));
4130#endif 4110#endif
4131 unblacklisted_connections = create_2d_torus (pg, &remove_connections, 4111 unblacklisted_connections =
4132 BLACKLIST); 4112 create_2d_torus (pg, &remove_connections, BLACKLIST);
4133 break; 4113 break;
4134 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: 4114 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
4135#if VERBOSE_TESTING 4115#if VERBOSE_TESTING
4136 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4137 _("Blacklisting all but Erdos-Renyi topology\n")); 4117 _("Blacklisting all but Erdos-Renyi topology\n"));
4138#endif 4118#endif
4139 unblacklisted_connections = create_erdos_renyi (pg, &remove_connections, 4119 unblacklisted_connections =
4140 BLACKLIST); 4120 create_erdos_renyi (pg, &remove_connections, BLACKLIST);
4141 break; 4121 break;
4142 case GNUNET_TESTING_TOPOLOGY_INTERNAT: 4122 case GNUNET_TESTING_TOPOLOGY_INTERNAT:
4143#if VERBOSE_TESTING 4123#if VERBOSE_TESTING
@@ -4168,8 +4148,8 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4168 pg->peers[off].connect_peers_head = NULL; 4148 pg->peers[off].connect_peers_head = NULL;
4169 pg->peers[off].connect_peers_tail = NULL; 4149 pg->peers[off].connect_peers_tail = NULL;
4170 } 4150 }
4171 unblacklisted_connections 4151 unblacklisted_connections =
4172 = create_nated_internet_copy (pg, &remove_connections, BLACKLIST); 4152 create_nated_internet_copy (pg, &remove_connections, BLACKLIST);
4173#else 4153#else
4174 unblacklisted_connections = 4154 unblacklisted_connections =
4175 create_nated_internet (pg, &remove_connections, BLACKLIST); 4155 create_nated_internet (pg, &remove_connections, BLACKLIST);
@@ -4181,16 +4161,16 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4182 _("Blacklisting all but Scale Free topology\n")); 4162 _("Blacklisting all but Scale Free topology\n"));
4183#endif 4163#endif
4184 unblacklisted_connections = create_scale_free (pg, &remove_connections, 4164 unblacklisted_connections =
4185 BLACKLIST); 4165 create_scale_free (pg, &remove_connections, BLACKLIST);
4186 break; 4166 break;
4187 case GNUNET_TESTING_TOPOLOGY_LINE: 4167 case GNUNET_TESTING_TOPOLOGY_LINE:
4188#if VERBOSE_TESTING 4168#if VERBOSE_TESTING
4189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4190 _("Blacklisting all but straight line topology\n")); 4170 _("Blacklisting all but straight line topology\n"));
4191#endif 4171#endif
4192 unblacklisted_connections 4172 unblacklisted_connections =
4193 = create_line (pg, &remove_connections, BLACKLIST); 4173 create_line (pg, &remove_connections, BLACKLIST);
4194 default: 4174 default:
4195 break; 4175 break;
4196 } 4176 }
@@ -4244,8 +4224,8 @@ random_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4244 if (random_number < random_ctx->percentage) 4224 if (random_number < random_ctx->percentage)
4245 { 4225 {
4246 GNUNET_assert (GNUNET_OK == 4226 GNUNET_assert (GNUNET_OK ==
4247 GNUNET_CONTAINER_multihashmap_put (random_ctx-> 4227 GNUNET_CONTAINER_multihashmap_put (random_ctx->first->
4248 first->connect_peers_working_set, 4228 connect_peers_working_set,
4249 key, value, 4229 key, value,
4250 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4230 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4251 } 4231 }
@@ -4255,11 +4235,12 @@ random_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4255 hash_from_uid (random_ctx->first_uid, &first_hash); 4235 hash_from_uid (random_ctx->first_uid, &first_hash);
4256 GNUNET_assert (random_ctx->pg->total > second_pos); 4236 GNUNET_assert (random_ctx->pg->total > second_pos);
4257 GNUNET_assert (GNUNET_YES == 4237 GNUNET_assert (GNUNET_YES ==
4258 GNUNET_CONTAINER_multihashmap_remove (random_ctx->pg->peers 4238 GNUNET_CONTAINER_multihashmap_remove (random_ctx->pg->
4259 [second_pos].connect_peers, 4239 peers[second_pos].
4240 connect_peers,
4260 &first_hash, 4241 &first_hash,
4261 random_ctx-> 4242 random_ctx->first->
4262 first->daemon)); 4243 daemon));
4263 4244
4264 return GNUNET_YES; 4245 return GNUNET_YES;
4265} 4246}
@@ -4289,25 +4270,29 @@ minimum_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4289 if (min_ctx->pg_array[i] == min_ctx->current) 4270 if (min_ctx->pg_array[i] == min_ctx->current)
4290 { 4271 {
4291 GNUNET_assert (GNUNET_OK == 4272 GNUNET_assert (GNUNET_OK ==
4292 GNUNET_CONTAINER_multihashmap_put 4273 GNUNET_CONTAINER_multihashmap_put (min_ctx->first->
4293 (min_ctx->first->connect_peers_working_set, key, 4274 connect_peers_working_set,
4294 value, 4275 key, value,
4295 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4276 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4296 uid_from_hash (key, &second_pos); 4277 uid_from_hash (key, &second_pos);
4297 hash_from_uid (min_ctx->first_uid, &first_hash); 4278 hash_from_uid (min_ctx->first_uid, &first_hash);
4298 GNUNET_assert (min_ctx->pg->total > second_pos); 4279 GNUNET_assert (min_ctx->pg->total > second_pos);
4299 GNUNET_assert (GNUNET_OK == 4280 GNUNET_assert (GNUNET_OK ==
4300 GNUNET_CONTAINER_multihashmap_put (min_ctx->pg->peers 4281 GNUNET_CONTAINER_multihashmap_put (min_ctx->pg->
4301 [second_pos].connect_peers_working_set, 4282 peers[second_pos].
4283 connect_peers_working_set,
4302 &first_hash, 4284 &first_hash,
4303 min_ctx->first-> 4285 min_ctx->
4304 daemon, 4286 first->daemon,
4305 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4287 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4306 /* Now we have added this particular connection, remove it from the second peer's map so it's not double counted */ 4288 /* Now we have added this particular connection, remove it from the second peer's map so it's not double counted */
4307 GNUNET_assert (GNUNET_YES == 4289 GNUNET_assert (GNUNET_YES ==
4308 GNUNET_CONTAINER_multihashmap_remove 4290 GNUNET_CONTAINER_multihashmap_remove (min_ctx->pg->
4309 (min_ctx->pg->peers[second_pos].connect_peers, 4291 peers[second_pos].
4310 &first_hash, min_ctx->first->daemon)); 4292 connect_peers,
4293 &first_hash,
4294 min_ctx->first->
4295 daemon));
4311 } 4296 }
4312 } 4297 }
4313 min_ctx->current++; 4298 min_ctx->current++;
@@ -4336,26 +4321,28 @@ dfs_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4336 if (dfs_ctx->current == dfs_ctx->chosen) 4321 if (dfs_ctx->current == dfs_ctx->chosen)
4337 { 4322 {
4338 GNUNET_assert (GNUNET_OK == 4323 GNUNET_assert (GNUNET_OK ==
4339 GNUNET_CONTAINER_multihashmap_put (dfs_ctx-> 4324 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->first->
4340 first->connect_peers_working_set, 4325 connect_peers_working_set,
4341 key, value, 4326 key, value,
4342 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4327 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4343 uid_from_hash (key, &dfs_ctx->second_uid); 4328 uid_from_hash (key, &dfs_ctx->second_uid);
4344 hash_from_uid (dfs_ctx->first_uid, &first_hash); 4329 hash_from_uid (dfs_ctx->first_uid, &first_hash);
4345 GNUNET_assert (GNUNET_OK == 4330 GNUNET_assert (GNUNET_OK ==
4346 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->pg->peers 4331 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->pg->
4347 [dfs_ctx-> 4332 peers
4348 second_uid].connect_peers_working_set, 4333 [dfs_ctx->second_uid].
4334 connect_peers_working_set,
4349 &first_hash, 4335 &first_hash,
4350 dfs_ctx->first->daemon, 4336 dfs_ctx->first->daemon,
4351 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4337 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4352 GNUNET_assert (GNUNET_YES == 4338 GNUNET_assert (GNUNET_YES ==
4353 GNUNET_CONTAINER_multihashmap_remove (dfs_ctx-> 4339 GNUNET_CONTAINER_multihashmap_remove (dfs_ctx->pg->
4354 pg->peers 4340 peers[dfs_ctx->
4355 [dfs_ctx->second_uid].connect_peers, 4341 second_uid].
4342 connect_peers,
4356 &first_hash, 4343 &first_hash,
4357 dfs_ctx-> 4344 dfs_ctx->first->
4358 first->daemon)); 4345 daemon));
4359 /* Can't remove second from first yet because we are currently iterating, hence the return value in the DFSContext! */ 4346 /* Can't remove second from first yet because we are currently iterating, hence the return value in the DFSContext! */
4360 return GNUNET_NO; /* We have found our peer, don't iterate more */ 4347 return GNUNET_NO; /* We have found our peer, don't iterate more */
4361 } 4348 }
@@ -4391,10 +4378,10 @@ choose_random_connections (struct GNUNET_TESTING_PeerGroup *pg,
4391 conn_iter = pg->peers[pg_iter].connect_peers_head; 4378 conn_iter = pg->peers[pg_iter].connect_peers_head;
4392 while (conn_iter != NULL) 4379 while (conn_iter != NULL)
4393 { 4380 {
4394 random_number 4381 random_number =
4395 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 4382 ((double)
4396 UINT64_MAX)) 4383 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
4397 / ((double) UINT64_MAX); 4384 UINT64_MAX)) / ((double) UINT64_MAX);
4398 if (random_number < percentage) 4385 if (random_number < percentage)
4399 { 4386 {
4400 add_connections (pg, pg_iter, conn_iter->index, WORKING_SET, 4387 add_connections (pg, pg_iter, conn_iter->index, WORKING_SET,
@@ -4407,16 +4394,16 @@ choose_random_connections (struct GNUNET_TESTING_PeerGroup *pg,
4407 random_ctx.first = &pg->peers[pg_iter]; 4394 random_ctx.first = &pg->peers[pg_iter];
4408 random_ctx.percentage = percentage; 4395 random_ctx.percentage = percentage;
4409 random_ctx.pg = pg; 4396 random_ctx.pg = pg;
4410 pg->peers[pg_iter].connect_peers_working_set 4397 pg->peers[pg_iter].connect_peers_working_set =
4411 = GNUNET_CONTAINER_multihashmap_create (pg->total); 4398 GNUNET_CONTAINER_multihashmap_create (pg->total);
4412 GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].connect_peers, 4399 GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].connect_peers,
4413 &random_connect_iterator, 4400 &random_connect_iterator,
4414 &random_ctx); 4401 &random_ctx);
4415 /* Now remove the old connections */ 4402 /* Now remove the old connections */
4416 GNUNET_CONTAINER_multihashmap_destroy (pg->peers[pg_iter].connect_peers); 4403 GNUNET_CONTAINER_multihashmap_destroy (pg->peers[pg_iter].connect_peers);
4417 /* And replace with the random set */ 4404 /* And replace with the random set */
4418 pg->peers[pg_iter].connect_peers 4405 pg->peers[pg_iter].connect_peers =
4419 = pg->peers[pg_iter].connect_peers_working_set; 4406 pg->peers[pg_iter].connect_peers_working_set;
4420#endif 4407#endif
4421 } 4408 }
4422 4409
@@ -4425,13 +4412,13 @@ choose_random_connections (struct GNUNET_TESTING_PeerGroup *pg,
4425 conn_iter = pg->peers[pg_iter].connect_peers_head; 4412 conn_iter = pg->peers[pg_iter].connect_peers_head;
4426 while (pg->peers[pg_iter].connect_peers_head != NULL) 4413 while (pg->peers[pg_iter].connect_peers_head != NULL)
4427 remove_connections (pg, pg_iter, 4414 remove_connections (pg, pg_iter,
4428 pg->peers[pg_iter].connect_peers_head->index, 4415 pg->peers[pg_iter].connect_peers_head->index, CONNECT,
4429 CONNECT, GNUNET_YES); 4416 GNUNET_YES);
4430 4417
4431 pg->peers[pg_iter].connect_peers_head 4418 pg->peers[pg_iter].connect_peers_head =
4432 = pg->peers[pg_iter].connect_peers_working_set_head; 4419 pg->peers[pg_iter].connect_peers_working_set_head;
4433 pg->peers[pg_iter].connect_peers_tail 4420 pg->peers[pg_iter].connect_peers_tail =
4434 = pg->peers[pg_iter].connect_peers_working_set_tail; 4421 pg->peers[pg_iter].connect_peers_working_set_tail;
4435 pg->peers[pg_iter].connect_peers_working_set_head = NULL; 4422 pg->peers[pg_iter].connect_peers_working_set_head = NULL;
4436 pg->peers[pg_iter].connect_peers_working_set_tail = NULL; 4423 pg->peers[pg_iter].connect_peers_working_set_tail = NULL;
4437 } 4424 }
@@ -4482,8 +4469,8 @@ count_workingset_connections (struct GNUNET_TESTING_PeerGroup *pg)
4482 } 4469 }
4483#else 4470#else
4484 count += 4471 count +=
4485 GNUNET_CONTAINER_multihashmap_size (pg->peers 4472 GNUNET_CONTAINER_multihashmap_size (pg->peers[pg_iter].
4486 [pg_iter].connect_peers_working_set); 4473 connect_peers_working_set);
4487#endif 4474#endif
4488 } 4475 }
4489 4476
@@ -4546,14 +4533,14 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4546 temp_list_size = count_connections (pg->peers[pg_iter].connect_peers_head); 4533 temp_list_size = count_connections (pg->peers[pg_iter].connect_peers_head);
4547 if (temp_list_size == 0) 4534 if (temp_list_size == 0)
4548 { 4535 {
4549 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 4536 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Peer %d has 0 connections!?!?\n",
4550 "Peer %d has 0 connections!?!?\n", pg_iter); 4537 pg_iter);
4551 break; 4538 break;
4552 } 4539 }
4553 for (i = 0; i < num; i++) 4540 for (i = 0; i < num; i++)
4554 { 4541 {
4555 random = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 4542 random =
4556 temp_list_size); 4543 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, temp_list_size);
4557 conn_iter = pg->peers[pg_iter].connect_peers_head; 4544 conn_iter = pg->peers[pg_iter].connect_peers_head;
4558 for (count = 0; count < random; count++) 4545 for (count = 0; count < random; count++)
4559 conn_iter = conn_iter->next; 4546 conn_iter = conn_iter->next;
@@ -4574,8 +4561,10 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4574 minimum_ctx.first_uid = pg_iter; 4561 minimum_ctx.first_uid = pg_iter;
4575 minimum_ctx.pg_array = 4562 minimum_ctx.pg_array =
4576 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, 4563 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK,
4577 GNUNET_CONTAINER_multihashmap_size 4564 GNUNET_CONTAINER_multihashmap_size (pg->
4578 (pg->peers[pg_iter].connect_peers)); 4565 peers
4566 [pg_iter].
4567 connect_peers));
4579 minimum_ctx.first = &pg->peers[pg_iter]; 4568 minimum_ctx.first = &pg->peers[pg_iter];
4580 minimum_ctx.pg = pg; 4569 minimum_ctx.pg = pg;
4581 minimum_ctx.num_to_add = num; 4570 minimum_ctx.num_to_add = num;
@@ -4606,10 +4595,10 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4606 /*remove_connections(pg, pg_iter, pg->peers[pg_iter].connect_peers_head->index, CONNECT, GNUNET_YES); */ 4595 /*remove_connections(pg, pg_iter, pg->peers[pg_iter].connect_peers_head->index, CONNECT, GNUNET_YES); */
4607 } 4596 }
4608 4597
4609 pg->peers[pg_iter].connect_peers_head 4598 pg->peers[pg_iter].connect_peers_head =
4610 = pg->peers[pg_iter].connect_peers_working_set_head; 4599 pg->peers[pg_iter].connect_peers_working_set_head;
4611 pg->peers[pg_iter].connect_peers_tail 4600 pg->peers[pg_iter].connect_peers_tail =
4612 = pg->peers[pg_iter].connect_peers_working_set_tail; 4601 pg->peers[pg_iter].connect_peers_working_set_tail;
4613 pg->peers[pg_iter].connect_peers_working_set_head = NULL; 4602 pg->peers[pg_iter].connect_peers_working_set_head = NULL;
4614 pg->peers[pg_iter].connect_peers_working_set_tail = NULL; 4603 pg->peers[pg_iter].connect_peers_working_set_tail = NULL;
4615 } 4604 }
@@ -4663,16 +4652,15 @@ find_closest_peers (void *cls, const GNUNET_HashCode * key, void *value)
4663 (GNUNET_CRYPTO_hash_matching_bits 4652 (GNUNET_CRYPTO_hash_matching_bits
4664 (&daemon->id.hashPubKey, 4653 (&daemon->id.hashPubKey,
4665 &closest_ctx->curr_peer->daemon->id.hashPubKey) > 4654 &closest_ctx->curr_peer->daemon->id.hashPubKey) >
4666 closest_ctx->closest_dist)) 4655 closest_ctx->closest_dist)) &&
4667 && (GNUNET_YES != 4656 (GNUNET_YES !=
4668 GNUNET_CONTAINER_multihashmap_contains (closest_ctx-> 4657 GNUNET_CONTAINER_multihashmap_contains (closest_ctx->curr_peer->
4669 curr_peer->connect_peers, 4658 connect_peers, key)))
4670 key)))
4671 { 4659 {
4672 closest_ctx->closest_dist = 4660 closest_ctx->closest_dist =
4673 GNUNET_CRYPTO_hash_matching_bits (&daemon->id.hashPubKey, 4661 GNUNET_CRYPTO_hash_matching_bits (&daemon->id.hashPubKey,
4674 &closest_ctx->curr_peer->daemon-> 4662 &closest_ctx->curr_peer->daemon->id.
4675 id.hashPubKey); 4663 hashPubKey);
4676 closest_ctx->closest = daemon; 4664 closest_ctx->closest = daemon;
4677 uid_from_hash (key, &closest_ctx->closest_num); 4665 uid_from_hash (key, &closest_ctx->closest_num);
4678 } 4666 }
@@ -4750,18 +4738,17 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4750#if OLD 4738#if OLD
4751 starting_peer = 0; 4739 starting_peer = 0;
4752 dfs_count = 0; 4740 dfs_count = 0;
4753 while ((count_workingset_connections (pg) < num * pg->total) 4741 while ((count_workingset_connections (pg) < num * pg->total) &&
4754 && (count_allowed_connections (pg) > 0)) 4742 (count_allowed_connections (pg) > 0))
4755 { 4743 {
4756 if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */ 4744 if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */
4757 { 4745 {
4758 least_connections = -1; /* Set to very high number */ 4746 least_connections = -1; /* Set to very high number */
4759 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 4747 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
4760 { 4748 {
4761 temp_count 4749 temp_count =
4762 = 4750 count_connections (pg->peers[pg_iter].
4763 count_connections (pg-> 4751 connect_peers_working_set_head);
4764 peers[pg_iter].connect_peers_working_set_head);
4765 if (temp_count < least_connections) 4752 if (temp_count < least_connections)
4766 { 4753 {
4767 starting_peer = pg_iter; 4754 starting_peer = pg_iter;
@@ -4770,13 +4757,13 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4770 } 4757 }
4771 } 4758 }
4772 4759
4773 temp_count 4760 temp_count =
4774 = count_connections (pg->peers[starting_peer].connect_peers_head); 4761 count_connections (pg->peers[starting_peer].connect_peers_head);
4775 if (temp_count == 0) 4762 if (temp_count == 0)
4776 continue; /* FIXME: infinite loop? */ 4763 continue; /* FIXME: infinite loop? */
4777 4764
4778 random_connection = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 4765 random_connection =
4779 temp_count); 4766 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, temp_count);
4780 temp_count = 0; 4767 temp_count = 0;
4781 peer_iter = pg->peers[starting_peer].connect_peers_head; 4768 peer_iter = pg->peers[starting_peer].connect_peers_head;
4782 while (temp_count < random_connection) 4769 while (temp_count < random_connection)
@@ -4802,8 +4789,8 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4802 4789
4803 starting_peer = 0; 4790 starting_peer = 0;
4804 dfs_count = 0; 4791 dfs_count = 0;
4805 while ((count_workingset_connections (pg) < num * pg->total) 4792 while ((count_workingset_connections (pg) < num * pg->total) &&
4806 && (count_allowed_connections (pg) > 0)) 4793 (count_allowed_connections (pg) > 0))
4807 { 4794 {
4808 if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */ 4795 if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */
4809 { 4796 {
@@ -4815,8 +4802,8 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4815 { 4802 {
4816 starting_peer = pg_iter; 4803 starting_peer = pg_iter;
4817 least_connections = 4804 least_connections =
4818 GNUNET_CONTAINER_multihashmap_size (pg->peers 4805 GNUNET_CONTAINER_multihashmap_size (pg->peers[pg_iter].
4819 [pg_iter].connect_peers_working_set); 4806 connect_peers_working_set);
4820 } 4807 }
4821 } 4808 }
4822 } 4809 }
@@ -4830,25 +4817,28 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4830 /* Choose a random peer from the chosen peers set of connections to add */ 4817 /* Choose a random peer from the chosen peers set of connections to add */
4831 dfs_ctx.chosen = 4818 dfs_ctx.chosen =
4832 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 4819 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
4833 GNUNET_CONTAINER_multihashmap_size 4820 GNUNET_CONTAINER_multihashmap_size (pg->
4834 (pg->peers[starting_peer].connect_peers)); 4821 peers
4822 [starting_peer].
4823 connect_peers));
4835 dfs_ctx.first_uid = starting_peer; 4824 dfs_ctx.first_uid = starting_peer;
4836 dfs_ctx.first = &pg->peers[starting_peer]; 4825 dfs_ctx.first = &pg->peers[starting_peer];
4837 dfs_ctx.pg = pg; 4826 dfs_ctx.pg = pg;
4838 dfs_ctx.current = 0; 4827 dfs_ctx.current = 0;
4839 4828
4840 GNUNET_CONTAINER_multihashmap_iterate (pg->peers 4829 GNUNET_CONTAINER_multihashmap_iterate (pg->peers[starting_peer].
4841 [starting_peer].connect_peers, 4830 connect_peers, &dfs_connect_iterator,
4842 &dfs_connect_iterator, &dfs_ctx); 4831 &dfs_ctx);
4843 /* Remove the second from the first, since we will be continuing the search and may encounter the first peer again! */ 4832 /* Remove the second from the first, since we will be continuing the search and may encounter the first peer again! */
4844 hash_from_uid (dfs_ctx.second_uid, &second_hash); 4833 hash_from_uid (dfs_ctx.second_uid, &second_hash);
4845 GNUNET_assert (GNUNET_YES == 4834 GNUNET_assert (GNUNET_YES ==
4846 GNUNET_CONTAINER_multihashmap_remove (pg->peers 4835 GNUNET_CONTAINER_multihashmap_remove (pg->
4847 [starting_peer].connect_peers, 4836 peers[starting_peer].
4837 connect_peers,
4848 &second_hash, 4838 &second_hash,
4849 pg-> 4839 pg->peers[dfs_ctx.
4850 peers 4840 second_uid].
4851 [dfs_ctx.second_uid].daemon)); 4841 daemon));
4852 starting_peer = dfs_ctx.second_uid; 4842 starting_peer = dfs_ctx.second_uid;
4853 } 4843 }
4854 4844
@@ -4906,8 +4896,8 @@ schedule_get_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
4906 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 4896 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
4907 return; 4897 return;
4908 4898
4909 if (topology_context->connected 4899 if (topology_context->connected >
4910 > topology_context->pg->max_outstanding_connections) 4900 topology_context->pg->max_outstanding_connections)
4911 { 4901 {
4912#if VERBOSE_TESTING > 2 4902#if VERBOSE_TESTING > 2
4913 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4903 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4927,9 +4917,9 @@ schedule_get_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
4927#endif 4917#endif
4928 topology_context->connected++; 4918 topology_context->connected++;
4929 4919
4930 if (GNUNET_OK != GNUNET_CORE_iterate_peers (core_context->daemon->cfg, 4920 if (GNUNET_OK !=
4931 &internal_topology_callback, 4921 GNUNET_CORE_iterate_peers (core_context->daemon->cfg,
4932 core_context)) 4922 &internal_topology_callback, core_context))
4933 { 4923 {
4934 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Topology iteration failed.\n"); 4924 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Topology iteration failed.\n");
4935 internal_topology_callback (core_context, NULL, NULL); 4925 internal_topology_callback (core_context, NULL, NULL);
@@ -5068,19 +5058,19 @@ schedule_get_statistics (void *cls,
5068#endif 5058#endif
5069 5059
5070 stats_context->connected++; 5060 stats_context->connected++;
5071 core_context->stats_handle 5061 core_context->stats_handle =
5072 = GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg); 5062 GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg);
5073 if (core_context->stats_handle == NULL) 5063 if (core_context->stats_handle == NULL)
5074 { 5064 {
5075 internal_stats_cont (core_context, GNUNET_NO); 5065 internal_stats_cont (core_context, GNUNET_NO);
5076 return; 5066 return;
5077 } 5067 }
5078 5068
5079 core_context->stats_get_handle 5069 core_context->stats_get_handle =
5080 = GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL, 5070 GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL,
5081 GNUNET_TIME_relative_get_forever (), 5071 GNUNET_TIME_relative_get_forever (),
5082 &internal_stats_cont, 5072 &internal_stats_cont, &internal_stats_callback,
5083 &internal_stats_callback, core_context); 5073 core_context);
5084 if (core_context->stats_get_handle == NULL) 5074 if (core_context->stats_get_handle == NULL)
5085 internal_stats_cont (core_context, GNUNET_NO); 5075 internal_stats_cont (core_context, GNUNET_NO);
5086 5076
@@ -5121,21 +5111,20 @@ stats_check_existing (struct GNUNET_TESTING_PeerGroup *pg,
5121 unsigned long long port; 5111 unsigned long long port;
5122 char *to_match; 5112 char *to_match;
5123 5113
5124 if (GNUNET_YES 5114 if (GNUNET_YES !=
5125 != GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "testing", 5115 GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "testing",
5126 "single_statistics_per_host")) 5116 "single_statistics_per_host"))
5127 return GNUNET_NO; /* Each peer has its own statistics instance, do nothing! */ 5117 return GNUNET_NO; /* Each peer has its own statistics instance, do nothing! */
5128 5118
5129 pos = *stats_list; 5119 pos = *stats_list;
5130 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (specific_peer->cfg, 5120 if (GNUNET_OK !=
5131 "statistics", 5121 GNUNET_CONFIGURATION_get_value_string (specific_peer->cfg, "statistics",
5132 "unixpath", 5122 "unixpath", &unix_domain_socket))
5133 &unix_domain_socket))
5134 return GNUNET_NO; 5123 return GNUNET_NO;
5135 5124
5136 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (specific_peer->cfg, 5125 if (GNUNET_OK !=
5137 "statistics", "port", 5126 GNUNET_CONFIGURATION_get_value_number (specific_peer->cfg, "statistics",
5138 &port)) 5127 "port", &port))
5139 { 5128 {
5140 GNUNET_free (unix_domain_socket); 5129 GNUNET_free (unix_domain_socket);
5141 return GNUNET_NO; 5130 return GNUNET_NO;
@@ -5200,11 +5189,8 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
5200 5189
5201 for (i = 0; i < pg->total; i++) 5190 for (i = 0; i < pg->total; i++)
5202 { 5191 {
5203 if ((pg->peers[i].daemon->running == GNUNET_YES) && (GNUNET_NO 5192 if ((pg->peers[i].daemon->running == GNUNET_YES) &&
5204 == 5193 (GNUNET_NO == stats_check_existing (pg, &pg->peers[i], &stats_list)))
5205 stats_check_existing
5206 (pg, &pg->peers[i],
5207 &stats_list)))
5208 { 5194 {
5209 /* Allocate one core context per core we need to connect to */ 5195 /* Allocate one core context per core we need to connect to */
5210 core_ctx = GNUNET_malloc (sizeof (struct StatsCoreContext)); 5196 core_ctx = GNUNET_malloc (sizeof (struct StatsCoreContext));
@@ -5358,8 +5344,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
5358 copy_allowed_topology (pg); 5344 copy_allowed_topology (pg);
5359 break; 5345 break;
5360 default: 5346 default:
5361 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ 5347 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
5362 ("Unknown topology specification, can't connect peers!\n")); 5348 _("Unknown topology specification, can't connect peers!\n"));
5363 return GNUNET_SYSERR; 5349 return GNUNET_SYSERR;
5364 } 5350 }
5365 5351
@@ -5367,7 +5353,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
5367 { 5353 {
5368 case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM: 5354 case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM:
5369#if VERBOSE_TOPOLOGY 5355#if VERBOSE_TOPOLOGY
5370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ 5356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5357 _
5371 ("Connecting random subset (%'.2f percent) of possible peers\n"), 5358 ("Connecting random subset (%'.2f percent) of possible peers\n"),
5372 100 * option_modifier); 5359 100 * option_modifier);
5373#endif 5360#endif
@@ -5383,7 +5370,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
5383 break; 5370 break;
5384 case GNUNET_TESTING_TOPOLOGY_OPTION_DFS: 5371 case GNUNET_TESTING_TOPOLOGY_OPTION_DFS:
5385#if VERBOSE_TOPOLOGY 5372#if VERBOSE_TOPOLOGY
5386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ 5373 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5374 _
5387 ("Using DFS to connect a minimum of %u peers each (if possible)\n"), 5375 ("Using DFS to connect a minimum of %u peers each (if possible)\n"),
5388 (unsigned int) option_modifier); 5376 (unsigned int) option_modifier);
5389#endif 5377#endif
@@ -5393,8 +5381,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
5393 break; 5381 break;
5394 case GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST: 5382 case GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST:
5395#if VERBOSE_TOPOLOGY 5383#if VERBOSE_TOPOLOGY
5396 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ 5384 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
5397 ("Finding additional %u closest peers each (if possible)\n"), 5385 _("Finding additional %u closest peers each (if possible)\n"),
5398 (unsigned int) option_modifier); 5386 (unsigned int) option_modifier);
5399#endif 5387#endif
5400#if FIXME 5388#if FIXME
@@ -5498,8 +5486,8 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
5498 if (internal_context->hostkey_callback != NULL) 5486 if (internal_context->hostkey_callback != NULL)
5499 internal_context->hostkey_callback (internal_context->hostkey_cls, id, d, 5487 internal_context->hostkey_callback (internal_context->hostkey_cls, id, d,
5500 emsg); 5488 emsg);
5501 else if (internal_context->peer->pg->started 5489 else if (internal_context->peer->pg->started ==
5502 == internal_context->peer->pg->total) 5490 internal_context->peer->pg->total)
5503 { 5491 {
5504 internal_context->peer->pg->started = 0; /* Internal startup may use this counter! */ 5492 internal_context->peer->pg->started = 0; /* Internal startup may use this counter! */
5505 GNUNET_TESTING_daemons_continue_startup (internal_context->peer->pg); 5493 GNUNET_TESTING_daemons_continue_startup (internal_context->peer->pg);
@@ -5544,12 +5532,13 @@ internal_continue_startup (void *cls,
5544 return; 5532 return;
5545 } 5533 }
5546 5534
5547 if ((internal_context->peer->pg->starting 5535 if ((internal_context->peer->pg->starting <
5548 < internal_context->peer->pg->max_concurrent_ssh) 5536 internal_context->peer->pg->max_concurrent_ssh) ||
5549 || ((internal_context->hostname != NULL) 5537 ((internal_context->hostname != NULL) &&
5550 && (count_outstanding_at_host (internal_context->hostname, 5538 (count_outstanding_at_host
5551 internal_context->peer->pg) 5539 (internal_context->hostname,
5552 < internal_context->peer->pg->max_concurrent_ssh))) 5540 internal_context->peer->pg) <
5541 internal_context->peer->pg->max_concurrent_ssh)))
5553 { 5542 {
5554 if (internal_context->hostname != NULL) 5543 if (internal_context->hostname != NULL)
5555 increment_outstanding_at_host (internal_context->hostname, 5544 increment_outstanding_at_host (internal_context->hostname,
@@ -5599,8 +5588,9 @@ churn_start_callback (void *cls, const struct GNUNET_PeerIdentity *id,
5599 churn_ctx->num_to_start--; 5588 churn_ctx->num_to_start--;
5600 } 5589 }
5601 5590
5602 total_left = (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) 5591 total_left =
5603 + (churn_ctx->num_to_start - churn_ctx->num_failed_start); 5592 (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) +
5593 (churn_ctx->num_to_start - churn_ctx->num_failed_start);
5604 5594
5605 if (total_left == 0) 5595 if (total_left == 0)
5606 { 5596 {
@@ -5630,8 +5620,8 @@ schedule_churn_restart (void *cls,
5630 { 5620 {
5631 if (startup_ctx->churn_ctx->service != NULL) 5621 if (startup_ctx->churn_ctx->service != NULL)
5632 GNUNET_TESTING_daemon_start_stopped_service (peer_restart_ctx->daemon, 5622 GNUNET_TESTING_daemon_start_stopped_service (peer_restart_ctx->daemon,
5633 startup_ctx-> 5623 startup_ctx->churn_ctx->
5634 churn_ctx->service, 5624 service,
5635 startup_ctx->timeout, 5625 startup_ctx->timeout,
5636 &churn_start_callback, 5626 &churn_start_callback,
5637 startup_ctx); 5627 startup_ctx);
@@ -5655,8 +5645,7 @@ schedule_churn_restart (void *cls,
5655 * 5645 *
5656 */ 5646 */
5657void 5647void
5658service_start_callback (void *cls, 5648service_start_callback (void *cls, const struct GNUNET_PeerIdentity *id,
5659 const struct GNUNET_PeerIdentity *id,
5660 const struct GNUNET_CONFIGURATION_Handle *cfg, 5649 const struct GNUNET_CONFIGURATION_Handle *cfg,
5661 struct GNUNET_TESTING_Daemon *d, const char *emsg) 5650 struct GNUNET_TESTING_Daemon *d, const char *emsg)
5662{ 5651{
@@ -5693,8 +5682,7 @@ schedule_service_start (void *cls,
5693 else 5682 else
5694 { 5683 {
5695 5684
5696 GNUNET_TESTING_daemon_start_service (peer_ctx->daemon, 5685 GNUNET_TESTING_daemon_start_service (peer_ctx->daemon, startup_ctx->service,
5697 startup_ctx->service,
5698 startup_ctx->timeout, 5686 startup_ctx->timeout,
5699 &service_start_callback, startup_ctx); 5687 &service_start_callback, startup_ctx);
5700 GNUNET_free (peer_ctx); 5688 GNUNET_free (peer_ctx);
@@ -5712,29 +5700,29 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5712 return; 5700 return;
5713 } 5701 }
5714 5702
5715 if ((internal_context->peer->pg->starting 5703 if ((internal_context->peer->pg->starting <
5716 < internal_context->peer->pg->max_concurrent_ssh) 5704 internal_context->peer->pg->max_concurrent_ssh) ||
5717 || ((internal_context->hostname != NULL) 5705 ((internal_context->hostname != NULL) &&
5718 && (count_outstanding_at_host (internal_context->hostname, 5706 (count_outstanding_at_host
5719 internal_context->peer->pg) 5707 (internal_context->hostname,
5720 < internal_context->peer->pg->max_concurrent_ssh))) 5708 internal_context->peer->pg) <
5709 internal_context->peer->pg->max_concurrent_ssh)))
5721 { 5710 {
5722 if (internal_context->hostname != NULL) 5711 if (internal_context->hostname != NULL)
5723 increment_outstanding_at_host (internal_context->hostname, 5712 increment_outstanding_at_host (internal_context->hostname,
5724 internal_context->peer->pg); 5713 internal_context->peer->pg);
5725 internal_context->peer->pg->starting++; 5714 internal_context->peer->pg->starting++;
5726 internal_context->peer->daemon 5715 internal_context->peer->daemon =
5727 = GNUNET_TESTING_daemon_start (internal_context->peer->cfg, 5716 GNUNET_TESTING_daemon_start (internal_context->peer->cfg,
5728 internal_context->timeout, 5717 internal_context->timeout, GNUNET_NO,
5729 GNUNET_NO, 5718 internal_context->hostname,
5730 internal_context->hostname, 5719 internal_context->username,
5731 internal_context->username, 5720 internal_context->sshport,
5732 internal_context->sshport, 5721 internal_context->hostkey,
5733 internal_context->hostkey, 5722 &internal_hostkey_callback,
5734 &internal_hostkey_callback, 5723 internal_context,
5735 internal_context, 5724 &internal_startup_callback,
5736 &internal_startup_callback, 5725 internal_context);
5737 internal_context);
5738 } 5726 }
5739 else 5727 else
5740 { 5728 {
@@ -5822,8 +5810,9 @@ start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5822 GNUNET_asprintf (&arg, "%s", helper->host->hostname); 5810 GNUNET_asprintf (&arg, "%s", helper->host->hostname);
5823 5811
5824 /* FIXME: Doesn't support ssh_port option! */ 5812 /* FIXME: Doesn't support ssh_port option! */
5825 helper->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, 5813 helper->proc =
5826 "peerStartHelper.pl", tempdir, NULL); 5814 GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg,
5815 "peerStartHelper.pl", tempdir, NULL);
5827 GNUNET_assert (helper->proc != NULL); 5816 GNUNET_assert (helper->proc != NULL);
5828 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 5817 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
5829 "starting peers with cmd ssh %s %s %s\n", arg, 5818 "starting peers with cmd ssh %s %s %s\n", arg,
@@ -5891,9 +5880,9 @@ call_hostkey_callbacks (void *cls,
5891 for (i = 0; i < pg->total; i++) 5880 for (i = 0; i < pg->total; i++)
5892 { 5881 {
5893 if (pg->peers[i].internal_context.hostkey_callback != NULL) 5882 if (pg->peers[i].internal_context.hostkey_callback != NULL)
5894 pg->peers[i].internal_context.hostkey_callback (pg->peers 5883 pg->peers[i].internal_context.hostkey_callback (pg->
5895 [i]. 5884 peers[i].internal_context.
5896 internal_context.hostkey_cls, 5885 hostkey_cls,
5897 &pg->peers[i].daemon->id, 5886 &pg->peers[i].daemon->id,
5898 pg->peers[i].daemon, 5887 pg->peers[i].daemon,
5899 NULL); 5888 NULL);
@@ -6044,16 +6033,17 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6044 if (pg->hosts[i].sshport != 0) 6033 if (pg->hosts[i].sshport != 0)
6045 { 6034 {
6046 GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport); 6035 GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport);
6047 proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-P", 6036 proc =
6048 ssh_port_str, 6037 GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-P", ssh_port_str,
6049#if !DEBUG_TESTING 6038#if !DEBUG_TESTING
6050 "-q", 6039 "-q",
6051#endif 6040#endif
6052 arg, "mkdir -p", tmpdir, NULL); 6041 arg, "mkdir -p", tmpdir, NULL);
6053 } 6042 }
6054 else 6043 else
6055 proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, 6044 proc =
6056 "mkdir -p", tmpdir, NULL); 6045 GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, "mkdir -p",
6046 tmpdir, NULL);
6057 GNUNET_assert (proc != NULL); 6047 GNUNET_assert (proc != NULL);
6058 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 6048 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6059 "Creating remote dir with command ssh %s %s %s\n", arg, 6049 "Creating remote dir with command ssh %s %s %s\n", arg,
@@ -6066,9 +6056,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6066 GNUNET_free (baseservicehome); 6056 GNUNET_free (baseservicehome);
6067 baseservicehome = NULL; 6057 baseservicehome = NULL;
6068 6058
6069 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", 6059 if (GNUNET_YES ==
6070 "HOSTKEYSFILE", 6060 GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "HOSTKEYSFILE",
6071 &hostkeys_file)) 6061 &hostkeys_file))
6072 { 6062 {
6073 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) 6063 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
6074 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 6064 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -6076,12 +6066,12 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6076 else 6066 else
6077 { 6067 {
6078 /* Check hostkey file size, read entire thing into memory */ 6068 /* Check hostkey file size, read entire thing into memory */
6079 fd = GNUNET_DISK_file_open (hostkeys_file, 6069 fd = GNUNET_DISK_file_open (hostkeys_file, GNUNET_DISK_OPEN_READ,
6080 GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); 6070 GNUNET_DISK_PERM_NONE);
6081 if (NULL == fd) 6071 if (NULL == fd)
6082 { 6072 {
6083 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 6073 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
6084 "open", hostkeys_file); 6074 hostkeys_file);
6085 GNUNET_free (hostkeys_file); 6075 GNUNET_free (hostkeys_file);
6086 for (i = 0; i < pg->num_hosts; i++) 6076 for (i = 0; i < pg->num_hosts; i++)
6087 { 6077 {
@@ -6126,8 +6116,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6126 hostname = pg->hosts[off % hostcnt].hostname; 6116 hostname = pg->hosts[off % hostcnt].hostname;
6127 username = pg->hosts[off % hostcnt].username; 6117 username = pg->hosts[off % hostcnt].username;
6128 sshport = pg->hosts[off % hostcnt].sshport; 6118 sshport = pg->hosts[off % hostcnt].sshport;
6129 pcfg = make_config (cfg, off, &pg->hosts[off % hostcnt].minport, 6119 pcfg =
6130 &upnum, hostname, &fdnum); 6120 make_config (cfg, off, &pg->hosts[off % hostcnt].minport, &upnum,
6121 hostname, &fdnum);
6131 } 6122 }
6132 else 6123 else
6133 { 6124 {
@@ -6146,10 +6137,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6146 continue; 6137 continue;
6147 } 6138 }
6148 6139
6149 if (GNUNET_YES 6140 if (GNUNET_YES ==
6150 == GNUNET_CONFIGURATION_get_value_string (pcfg, "PATHS", 6141 GNUNET_CONFIGURATION_get_value_string (pcfg, "PATHS", "SERVICEHOME",
6151 "SERVICEHOME", 6142 &baseservicehome))
6152 &baseservicehome))
6153 { 6143 {
6154 if (hostname != NULL) 6144 if (hostname != NULL)
6155 GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome, 6145 GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome,
@@ -6181,9 +6171,8 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6181 pg->peers[off].internal_context.username = username; 6171 pg->peers[off].internal_context.username = username;
6182 pg->peers[off].internal_context.sshport = sshport; 6172 pg->peers[off].internal_context.sshport = sshport;
6183 if (pg->hostkey_data != NULL) 6173 if (pg->hostkey_data != NULL)
6184 pg->peers[off].internal_context.hostkey = &pg->hostkey_data[off 6174 pg->peers[off].internal_context.hostkey =
6185 * 6175 &pg->hostkey_data[off * HOSTKEYFILESIZE];
6186 HOSTKEYFILESIZE];
6187 pg->peers[off].internal_context.hostkey_callback = hostkey_callback; 6176 pg->peers[off].internal_context.hostkey_callback = hostkey_callback;
6188 pg->peers[off].internal_context.hostkey_cls = hostkey_cls; 6177 pg->peers[off].internal_context.hostkey_cls = hostkey_cls;
6189 pg->peers[off].internal_context.start_cb = cb; 6178 pg->peers[off].internal_context.start_cb = cb;
@@ -6194,19 +6183,14 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6194#else 6183#else
6195 if ((pg->hostkey_data != NULL) && (hostcnt > 0)) 6184 if ((pg->hostkey_data != NULL) && (hostcnt > 0))
6196 { 6185 {
6197 pg->peers[off].daemon 6186 pg->peers[off].daemon =
6198 = GNUNET_TESTING_daemon_start (pcfg, 6187 GNUNET_TESTING_daemon_start (pcfg, timeout, GNUNET_YES, hostname,
6199 timeout, 6188 username, sshport,
6200 GNUNET_YES, 6189 pg->peers[off].internal_context.hostkey,
6201 hostname, 6190 &internal_hostkey_callback,
6202 username, 6191 &pg->peers[off].internal_context,
6203 sshport, 6192 &internal_startup_callback,
6204 pg->peers[off]. 6193 &pg->peers[off].internal_context);
6205 internal_context.hostkey,
6206 &internal_hostkey_callback,
6207 &pg->peers[off].internal_context,
6208 &internal_startup_callback,
6209 &pg->peers[off].internal_context);
6210 /** 6194 /**
6211 * At this point, given that we had a hostkeyfile, 6195 * At this point, given that we had a hostkeyfile,
6212 * we can call the hostkey callback! 6196 * we can call the hostkey callback!
@@ -6245,10 +6229,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6245 sshport = 0; 6229 sshport = 0;
6246 } 6230 }
6247 6231
6248 if (GNUNET_YES 6232 if (GNUNET_YES ==
6249 == GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", 6233 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME",
6250 "SERVICEHOME", 6234 &baseservicehome))
6251 &baseservicehome))
6252 { 6235 {
6253 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "baseservice home is %s\n", 6236 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "baseservice home is %s\n",
6254 baseservicehome); 6237 baseservicehome);
@@ -6273,17 +6256,16 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6273 } 6256 }
6274 6257
6275 if (NULL != username) 6258 if (NULL != username)
6276 GNUNET_asprintf (&arg, 6259 GNUNET_asprintf (&arg, "%s@%s:%s", username, pg->hosts[off].hostname,
6277 "%s@%s:%s", 6260 newservicehome);
6278 username, pg->hosts[off].hostname, newservicehome);
6279 else 6261 else
6280 GNUNET_asprintf (&arg, 6262 GNUNET_asprintf (&arg, "%s:%s", pg->hosts[off].hostname,
6281 "%s:%s", pg->hosts[off].hostname, newservicehome); 6263 newservicehome);
6282 6264
6283 /* FIXME: Doesn't support ssh_port option! */ 6265 /* FIXME: Doesn't support ssh_port option! */
6284 proc = GNUNET_OS_start_process (NULL, NULL, 6266 proc =
6285 "rsync", 6267 GNUNET_OS_start_process (NULL, NULL, "rsync", "rsync", "-r",
6286 "rsync", "-r", newservicehome, arg, NULL); 6268 newservicehome, arg, NULL);
6287 6269
6288 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 6270 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
6289 "copying directory with command rsync -r %s %s\n", 6271 "copying directory with command rsync -r %s %s\n",
@@ -6338,8 +6320,9 @@ GNUNET_TESTING_daemon_get_by_id (struct GNUNET_TESTING_PeerGroup *pg,
6338 6320
6339 for (i = 0; i < pg->total; i++) 6321 for (i = 0; i < pg->total; i++)
6340 { 6322 {
6341 if (0 == memcmp (&pg->peers[i].daemon->id, peer_id, 6323 if (0 ==
6342 sizeof (struct GNUNET_PeerIdentity))) 6324 memcmp (&pg->peers[i].daemon->id, peer_id,
6325 sizeof (struct GNUNET_PeerIdentity)))
6343 return pg->peers[i].daemon; 6326 return pg->peers[i].daemon;
6344 } 6327 }
6345 return NULL; 6328 return NULL;
@@ -6376,8 +6359,8 @@ restart_callback (void *cls, const struct GNUNET_PeerIdentity *id,
6376 restart_context->callback (restart_context->callback_cls, NULL); 6359 restart_context->callback (restart_context->callback_cls, NULL);
6377 GNUNET_free (restart_context); 6360 GNUNET_free (restart_context);
6378 } 6361 }
6379 else if (restart_context->peers_restart_failed 6362 else if (restart_context->peers_restart_failed +
6380 + restart_context->peers_restarted == 6363 restart_context->peers_restarted ==
6381 restart_context->peer_group->total) 6364 restart_context->peer_group->total)
6382 { 6365 {
6383 restart_context->callback (restart_context->callback_cls, 6366 restart_context->callback (restart_context->callback_cls,
@@ -6417,8 +6400,9 @@ churn_stop_callback (void *cls, const char *emsg)
6417 churn_ctx->num_to_stop--; 6400 churn_ctx->num_to_stop--;
6418 } 6401 }
6419 6402
6420 total_left = (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) 6403 total_left =
6421 + (churn_ctx->num_to_start - churn_ctx->num_failed_start); 6404 (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) +
6405 (churn_ctx->num_to_start - churn_ctx->num_failed_start);
6422 6406
6423 if (total_left == 0) 6407 if (total_left == 0)
6424 { 6408 {
@@ -6523,8 +6507,8 @@ schedule_churn_shutdown_task (void *cls,
6523 */ 6507 */
6524void 6508void
6525GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, 6509GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
6526 char *service, 6510 char *service, unsigned int voff,
6527 unsigned int voff, unsigned int von, 6511 unsigned int von,
6528 struct GNUNET_TIME_Relative timeout, 6512 struct GNUNET_TIME_Relative timeout,
6529 GNUNET_TESTING_NotifyCompletion cb, void *cb_cls) 6513 GNUNET_TESTING_NotifyCompletion cb, void *cb_cls)
6530{ 6514{
@@ -6634,11 +6618,11 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
6634 stopped_permute = NULL; 6618 stopped_permute = NULL;
6635 6619
6636 if (running > 0) 6620 if (running > 0)
6637 running_permute = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, 6621 running_permute =
6638 running); 6622 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, running);
6639 if (stopped > 0) 6623 if (stopped > 0)
6640 stopped_permute = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, 6624 stopped_permute =
6641 stopped); 6625 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, stopped);
6642 6626
6643 total_running = running; 6627 total_running = running;
6644 total_stopped = stopped; 6628 total_stopped = stopped;
@@ -6707,8 +6691,8 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
6707#endif 6691#endif
6708 GNUNET_assert (running_arr != NULL); 6692 GNUNET_assert (running_arr != NULL);
6709 peer_shutdown_ctx = GNUNET_malloc (sizeof (struct PeerShutdownContext)); 6693 peer_shutdown_ctx = GNUNET_malloc (sizeof (struct PeerShutdownContext));
6710 peer_shutdown_ctx->daemon 6694 peer_shutdown_ctx->daemon =
6711 = pg->peers[running_arr[running_permute[i]]].daemon; 6695 pg->peers[running_arr[running_permute[i]]].daemon;
6712 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx; 6696 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx;
6713 GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task, peer_shutdown_ctx); 6697 GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task, peer_shutdown_ctx);
6714 } 6698 }
@@ -6730,8 +6714,8 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
6730 GNUNET_assert (stopped_arr != NULL); 6714 GNUNET_assert (stopped_arr != NULL);
6731 peer_restart_ctx = GNUNET_malloc (sizeof (struct PeerRestartContext)); 6715 peer_restart_ctx = GNUNET_malloc (sizeof (struct PeerRestartContext));
6732 peer_restart_ctx->churn_restart_ctx = churn_startup_ctx; 6716 peer_restart_ctx->churn_restart_ctx = churn_startup_ctx;
6733 peer_restart_ctx->daemon 6717 peer_restart_ctx->daemon =
6734 = pg->peers[stopped_arr[stopped_permute[i]]].daemon; 6718 pg->peers[stopped_arr[stopped_permute[i]]].daemon;
6735 GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx); 6719 GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx);
6736 } 6720 }
6737 6721
@@ -6812,8 +6796,8 @@ GNUNET_TESTING_daemons_restart (struct GNUNET_TESTING_PeerGroup *pg,
6812 6796
6813 for (off = 0; off < pg->total; off++) 6797 for (off = 0; off < pg->total; off++)
6814 { 6798 {
6815 GNUNET_TESTING_daemon_restart (pg->peers[off].daemon, 6799 GNUNET_TESTING_daemon_restart (pg->peers[off].daemon, &restart_callback,
6816 &restart_callback, restart_context); 6800 restart_context);
6817 } 6801 }
6818 } 6802 }
6819} 6803}
@@ -6851,8 +6835,8 @@ GNUNET_TESTING_daemons_vary (struct GNUNET_TESTING_PeerGroup *pg,
6851 churn_ctx->cb_cls = cb_cls; 6835 churn_ctx->cb_cls = cb_cls;
6852 shutdown_ctx->cb_cls = churn_ctx; 6836 shutdown_ctx->cb_cls = churn_ctx;
6853 GNUNET_TESTING_daemon_stop (pg->peers[offset].daemon, timeout, 6837 GNUNET_TESTING_daemon_stop (pg->peers[offset].daemon, timeout,
6854 &churn_stop_callback, shutdown_ctx, 6838 &churn_stop_callback, shutdown_ctx, GNUNET_NO,
6855 GNUNET_NO, GNUNET_YES); 6839 GNUNET_YES);
6856 } 6840 }
6857 } 6841 }
6858 else if (GNUNET_YES == desired_status) 6842 else if (GNUNET_YES == desired_status)
@@ -6866,9 +6850,8 @@ GNUNET_TESTING_daemons_vary (struct GNUNET_TESTING_PeerGroup *pg,
6866 churn_ctx->cb = cb; 6850 churn_ctx->cb = cb;
6867 churn_ctx->cb_cls = cb_cls; 6851 churn_ctx->cb_cls = cb_cls;
6868 startup_ctx->churn_ctx = churn_ctx; 6852 startup_ctx->churn_ctx = churn_ctx;
6869 GNUNET_TESTING_daemon_start_stopped (pg->peers[offset].daemon, 6853 GNUNET_TESTING_daemon_start_stopped (pg->peers[offset].daemon, timeout,
6870 timeout, &churn_start_callback, 6854 &churn_start_callback, startup_ctx);
6871 startup_ctx);
6872 } 6855 }
6873 } 6856 }
6874 else 6857 else
@@ -6908,9 +6891,9 @@ internal_shutdown_callback (void *cls, const char *emsg)
6908 shutdown_ctx->peers_failed++; 6891 shutdown_ctx->peers_failed++;
6909 } 6892 }
6910 6893
6911 if ((shutdown_ctx->cb != NULL) && (shutdown_ctx->peers_down 6894 if ((shutdown_ctx->cb != NULL) &&
6912 + shutdown_ctx->peers_failed == 6895 (shutdown_ctx->peers_down + shutdown_ctx->peers_failed ==
6913 shutdown_ctx->total_peers)) 6896 shutdown_ctx->total_peers))
6914 { 6897 {
6915 if (shutdown_ctx->peers_failed > 0) 6898 if (shutdown_ctx->peers_failed > 0)
6916 shutdown_ctx->cb (shutdown_ctx->cb_cls, 6899 shutdown_ctx->cb (shutdown_ctx->cb_cls,
@@ -6957,11 +6940,11 @@ schedule_shutdown_task (void *cls,
6957 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; 6940 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
6958 GNUNET_assert (shutdown_ctx != NULL); 6941 GNUNET_assert (shutdown_ctx != NULL);
6959 6942
6960 if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) 6943 if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) ||
6961 || ((peer_shutdown_ctx->daemon->hostname != NULL) 6944 ((peer_shutdown_ctx->daemon->hostname != NULL) &&
6962 && (count_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, 6945 (count_outstanding_at_host
6963 shutdown_ctx->pg) 6946 (peer_shutdown_ctx->daemon->hostname,
6964 < shutdown_ctx->pg->max_concurrent_ssh))) 6947 shutdown_ctx->pg) < shutdown_ctx->pg->max_concurrent_ssh)))
6965 { 6948 {
6966 if (peer_shutdown_ctx->daemon->hostname != NULL) 6949 if (peer_shutdown_ctx->daemon->hostname != NULL)
6967 increment_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, 6950 increment_outstanding_at_host (peer_shutdown_ctx->daemon->hostname,
@@ -7001,9 +6984,9 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
7001 int ret; 6984 int ret;
7002 6985
7003 /* Check for a hostfile containing user@host:port triples */ 6986 /* Check for a hostfile containing user@host:port triples */
7004 if (GNUNET_OK 6987 if (GNUNET_OK !=
7005 != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", 6988 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile",
7006 &hostfile)) 6989 &hostfile))
7007 return NULL; 6990 return NULL;
7008 6991
7009 hosts = NULL; 6992 hosts = NULL;
@@ -7012,8 +6995,9 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
7012 if (hostfile != NULL) 6995 if (hostfile != NULL)
7013 { 6996 {
7014 if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) 6997 if (GNUNET_OK != GNUNET_DISK_file_test (hostfile))
7015 GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ 6998 GNUNET_DISK_fn_write (hostfile, NULL, 0,
7016 | GNUNET_DISK_PERM_USER_WRITE); 6999 GNUNET_DISK_PERM_USER_READ |
7000 GNUNET_DISK_PERM_USER_WRITE);
7017 if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) 7001 if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0))
7018 { 7002 {
7019 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 7003 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -7045,9 +7029,9 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
7045 { 7029 {
7046 data[count] = '\0'; 7030 data[count] = '\0';
7047 temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); 7031 temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host));
7048 ret = sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", 7032 ret =
7049 &temphost->username, &temphost->hostname, 7033 sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd",
7050 &temphost->port); 7034 &temphost->username, &temphost->hostname, &temphost->port);
7051 if (3 == ret) 7035 if (3 == ret)
7052 { 7036 {
7053 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 7037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -7100,9 +7084,8 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg,
7100 GNUNET_assert (pg->total > 0); 7084 GNUNET_assert (pg->total > 0);
7101 7085
7102 shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext)); 7086 shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext));
7103 shutdown_ctx->delete_files = GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, 7087 shutdown_ctx->delete_files =
7104 "TESTING", 7088 GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "DELETE_FILES");
7105 "DELETE_FILES");
7106 shutdown_ctx->cb = cb; 7089 shutdown_ctx->cb = cb;
7107 shutdown_ctx->cb_cls = cb_cls; 7090 shutdown_ctx->cb_cls = cb_cls;
7108 shutdown_ctx->total_peers = pg->total; 7091 shutdown_ctx->total_peers = pg->total;
diff --git a/src/testing/testing_peergroup.c b/src/testing/testing_peergroup.c
index e81e9fad8..a76c7cc26 100644
--- a/src/testing/testing_peergroup.c
+++ b/src/testing/testing_peergroup.c
@@ -203,8 +203,8 @@ update_meter (struct ProgressMeter *meter)
203 fprintf (stdout, "%sProgress: [0%%", meter->startup_string); 203 fprintf (stdout, "%sProgress: [0%%", meter->startup_string);
204 } 204 }
205 else 205 else
206 fprintf (stdout, "%d%%", (int) (((float) meter->completed 206 fprintf (stdout, "%d%%",
207 / meter->total) * 100)); 207 (int) (((float) meter->completed / meter->total) * 100));
208 } 208 }
209 else if (meter->completed % meter->dotnum == 0) 209 else if (meter->completed % meter->dotnum == 0)
210 fprintf (stdout, "."); 210 fprintf (stdout, ".");
@@ -304,8 +304,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
304 * failure (peers failed to connect). 304 * failure (peers failed to connect).
305 */ 305 */
306static void 306static void
307internal_topology_callback (void *cls, 307internal_topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
308 const struct GNUNET_PeerIdentity *first,
309 const struct GNUNET_PeerIdentity *second, 308 const struct GNUNET_PeerIdentity *second,
310 uint32_t distance, 309 uint32_t distance,
311 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 310 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
@@ -332,9 +331,9 @@ internal_topology_callback (void *cls,
332#endif 331#endif
333 332
334#if TIMING 333#if TIMING
335 if (GNUNET_TIME_absolute_get_difference (connect_last_time, 334 if (GNUNET_TIME_absolute_get_difference
336 GNUNET_TIME_absolute_get 335 (connect_last_time,
337 ()).rel_value > 336 GNUNET_TIME_absolute_get ()).rel_value >
338 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 337 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
339 CONN_UPDATE_DURATION).rel_value) 338 CONN_UPDATE_DURATION).rel_value)
340 { 339 {
@@ -345,14 +344,14 @@ internal_topology_callback (void *cls,
345 new_failed_connections = failed_connections - previous_failed_connections; 344 new_failed_connections = failed_connections - previous_failed_connections;
346 345
347 /* Get duration in seconds */ 346 /* Get duration in seconds */
348 duration 347 duration =
349 = GNUNET_TIME_absolute_get_difference (connect_last_time, 348 GNUNET_TIME_absolute_get_difference (connect_last_time,
350 GNUNET_TIME_absolute_get 349 GNUNET_TIME_absolute_get ()).
351 ()).rel_value / 1000; 350 rel_value / 1000;
352 total_duration = 351 total_duration =
353 GNUNET_TIME_absolute_get_difference (connect_start_time, 352 GNUNET_TIME_absolute_get_difference (connect_start_time,
354 GNUNET_TIME_absolute_get 353 GNUNET_TIME_absolute_get ()).
355 ()).rel_value / 1000; 354 rel_value / 1000;
356 355
357 failed_conns_per_sec_recent = (double) new_failed_connections / duration; 356 failed_conns_per_sec_recent = (double) new_failed_connections / duration;
358 failed_conns_per_sec_total = (double) failed_connections / total_duration; 357 failed_conns_per_sec_total = (double) failed_connections / total_duration;
@@ -360,9 +359,8 @@ internal_topology_callback (void *cls,
360 conns_per_sec_total = (double) total_connections / total_duration; 359 conns_per_sec_total = (double) total_connections / total_duration;
361 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 360 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
362 "Recent: %.2f/s, Total: %.2f/s, Recent failed: %.2f/s, total failed %.2f/s\n", 361 "Recent: %.2f/s, Total: %.2f/s, Recent failed: %.2f/s, total failed %.2f/s\n",
363 conns_per_sec_recent, CONN_UPDATE_DURATION, 362 conns_per_sec_recent, CONN_UPDATE_DURATION, conns_per_sec_total,
364 conns_per_sec_total, failed_conns_per_sec_recent, 363 failed_conns_per_sec_recent, failed_conns_per_sec_total);
365 failed_conns_per_sec_total);
366 connect_last_time = GNUNET_TIME_absolute_get (); 364 connect_last_time = GNUNET_TIME_absolute_get ();
367 previous_connections = total_connections; 365 previous_connections = total_connections;
368 previous_failed_connections = failed_connections; 366 previous_failed_connections = failed_connections;
@@ -410,11 +408,9 @@ internal_topology_callback (void *cls,
410 408
411 GNUNET_assert (pg_start_ctx->connect_meter != NULL); 409 GNUNET_assert (pg_start_ctx->connect_meter != NULL);
412 if (pg_start_ctx->connect_cb != NULL) 410 if (pg_start_ctx->connect_cb != NULL)
413 pg_start_ctx->connect_cb (pg_start_ctx->cls, first, 411 pg_start_ctx->connect_cb (pg_start_ctx->cls, first, second, distance,
414 second, 412 first_cfg, second_cfg, first_daemon,
415 distance, 413 second_daemon, emsg);
416 first_cfg,
417 second_cfg, first_daemon, second_daemon, emsg);
418 if (GNUNET_YES == update_meter (pg_start_ctx->connect_meter)) 414 if (GNUNET_YES == update_meter (pg_start_ctx->connect_meter))
419 { 415 {
420#if VERBOSE 416#if VERBOSE
@@ -424,10 +420,10 @@ internal_topology_callback (void *cls,
424#endif 420#endif
425 421
426#if TIMING 422#if TIMING
427 total_duration 423 total_duration =
428 = GNUNET_TIME_absolute_get_difference (connect_start_time, 424 GNUNET_TIME_absolute_get_difference (connect_start_time,
429 GNUNET_TIME_absolute_get 425 GNUNET_TIME_absolute_get ()).
430 ()).rel_value / 1000; 426 rel_value / 1000;
431 failed_conns_per_sec_total = (double) failed_connections / total_duration; 427 failed_conns_per_sec_total = (double) failed_connections / total_duration;
432 conns_per_sec_total = (double) total_connections / total_duration; 428 conns_per_sec_total = (double) total_connections / total_duration;
433 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 429 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -494,20 +490,21 @@ internal_peers_started_callback (void *cls,
494 if ((pg_start_ctx->pg != NULL) && (pg_start_ctx->peers_left == 0)) 490 if ((pg_start_ctx->pg != NULL) && (pg_start_ctx->peers_left == 0))
495 { 491 {
496 pg_start_ctx->connect_start_time = GNUNET_TIME_absolute_get (); 492 pg_start_ctx->connect_start_time = GNUNET_TIME_absolute_get ();
497 pg_start_ctx->expected_connections 493 pg_start_ctx->expected_connections =
498 = GNUNET_TESTING_connect_topology (pg_start_ctx->pg, 494 GNUNET_TESTING_connect_topology (pg_start_ctx->pg,
499 pg_start_ctx->connect_topology, 495 pg_start_ctx->connect_topology,
500 pg_start_ctx->connect_topology_option, 496 pg_start_ctx->
501 pg_start_ctx->connect_topology_option_modifier, 497 connect_topology_option,
502 DEFAULT_CONNECT_TIMEOUT, 498 pg_start_ctx->
503 pg_start_ctx->connect_attempts, 499 connect_topology_option_modifier,
504 NULL, NULL); 500 DEFAULT_CONNECT_TIMEOUT,
505 501 pg_start_ctx->connect_attempts, NULL,
506 pg_start_ctx->connect_meter 502 NULL);
507 = create_meter (pg_start_ctx->expected_connections, 503
508 "Peer connection ", pg_start_ctx->verbose); 504 pg_start_ctx->connect_meter =
509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 505 create_meter (pg_start_ctx->expected_connections, "Peer connection ",
510 "Have %d expected connections\n", 506 pg_start_ctx->verbose);
507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n",
511 pg_start_ctx->expected_connections); 508 pg_start_ctx->expected_connections);
512 } 509 }
513 510
@@ -553,8 +550,8 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
553 550
554#if VERBOSE > 1 551#if VERBOSE > 1
555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
556 "Hostkey (%d/%d) created for peer `%s'\n", 553 "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left,
557 num_peers - peers_left, num_peers, GNUNET_i2s (id)); 554 num_peers, GNUNET_i2s (id));
558#endif 555#endif
559 556
560 pg_start_ctx->peers_left--; 557 pg_start_ctx->peers_left--;
@@ -583,13 +580,13 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
583 else 580 else
584 { 581 {
585 GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); 582 GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task);
586 pg_start_ctx->die_task = GNUNET_SCHEDULER_add_now (&end_badly, 583 pg_start_ctx->die_task =
587 "from create topology (bad return)"); 584 GNUNET_SCHEDULER_add_now (&end_badly,
585 "from create topology (bad return)");
588 } 586 }
589 587
590 GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); 588 GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task);
591 pg_start_ctx->die_task 589 pg_start_ctx->die_task =
592 =
593 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining 590 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
594 (pg_start_ctx->timeout), &end_badly, 591 (pg_start_ctx->timeout), &end_badly,
595 "from continue startup (timeout)"); 592 "from continue startup (timeout)");
@@ -608,8 +605,7 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
608 * @param emsg error message (NULL on success) 605 * @param emsg error message (NULL on success)
609 */ 606 */
610void 607void
611write_topology_cb (void *cls, 608write_topology_cb (void *cls, const struct GNUNET_PeerIdentity *first,
612 const struct GNUNET_PeerIdentity *first,
613 const struct GNUNET_PeerIdentity *second, const char *emsg) 609 const struct GNUNET_PeerIdentity *second, const char *emsg)
614{ 610{
615 struct TopologyOutputContext *topo_ctx; 611 struct TopologyOutputContext *topo_ctx;
@@ -727,9 +723,9 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
727 723
728 pg_start_ctx = GNUNET_malloc (sizeof (struct PeerGroupStartupContext)); 724 pg_start_ctx = GNUNET_malloc (sizeof (struct PeerGroupStartupContext));
729 725
730 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", 726 if (GNUNET_OK !=
731 "connect_attempts", 727 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
732 &pg_start_ctx->connect_attempts)) 728 &pg_start_ctx->connect_attempts))
733 { 729 {
734 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", 730 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
735 "testing", "connect_attempts"); 731 "testing", "connect_attempts");
@@ -737,10 +733,11 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
737 return NULL; 733 return NULL;
738 } 734 }
739 735
740 if (GNUNET_OK 736 if (GNUNET_OK !=
741 != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", 737 GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
742 "max_outstanding_connections", 738 "max_outstanding_connections",
743 &pg_start_ctx->max_concurrent_connections)) 739 &pg_start_ctx->
740 max_concurrent_connections))
744 { 741 {
745 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", 742 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
746 "testing", "max_outstanding_connections"); 743 "testing", "max_outstanding_connections");
@@ -748,9 +745,10 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
748 return NULL; 745 return NULL;
749 } 746 }
750 747
751 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", 748 if (GNUNET_OK !=
752 "max_concurrent_ssh", 749 GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
753 &pg_start_ctx->max_concurrent_ssh)) 750 "max_concurrent_ssh",
751 &pg_start_ctx->max_concurrent_ssh))
754 { 752 {
755 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", 753 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
756 "testing", "max_concurrent_ssh"); 754 "testing", "max_concurrent_ssh");
@@ -769,9 +767,10 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
769 return NULL; 767 return NULL;
770 } 768 }
771 769
772 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", 770 if (GNUNET_OK ==
773 "peergroup_timeout", 771 GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
774 &temp_config_number)) 772 "peergroup_timeout",
773 &temp_config_number))
775 pg_start_ctx->timeout = 774 pg_start_ctx->timeout =
776 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply 775 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply
777 (GNUNET_TIME_UNIT_SECONDS, 776 (GNUNET_TIME_UNIT_SECONDS,
@@ -787,11 +786,11 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
787 786
788 /* Read topology related options from the configuration file */ 787 /* Read topology related options from the configuration file */
789 temp_str = NULL; 788 temp_str = NULL;
790 if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 789 if ((GNUNET_YES ==
791 "topology", 790 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology",
792 &temp_str)) 791 &temp_str)) &&
793 && (GNUNET_NO == 792 (GNUNET_NO ==
794 GNUNET_TESTING_topology_get (&pg_start_ctx->topology, temp_str))) 793 GNUNET_TESTING_topology_get (&pg_start_ctx->topology, temp_str)))
795 { 794 {
796 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 795 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
797 "Invalid topology `%s' given for section %s option %s\n", 796 "Invalid topology `%s' given for section %s option %s\n",
@@ -821,9 +820,9 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
821 GNUNET_free (temp_str); 820 GNUNET_free (temp_str);
822 } 821 }
823 822
824 if (GNUNET_OK 823 if (GNUNET_OK !=
825 != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage", 824 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage",
826 &temp_str)) 825 &temp_str))
827 pg_start_ctx->topology_percentage = 0.5; 826 pg_start_ctx->topology_percentage = 0.5;
828 else 827 else
829 { 828 {
@@ -831,9 +830,9 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
831 GNUNET_free (temp_str); 830 GNUNET_free (temp_str);
832 } 831 }
833 832
834 if (GNUNET_OK 833 if (GNUNET_OK !=
835 != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability", 834 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability",
836 &temp_str)) 835 &temp_str))
837 pg_start_ctx->topology_probability = 0.5; 836 pg_start_ctx->topology_probability = 0.5;
838 else 837 else
839 { 838 {
@@ -841,13 +840,11 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
841 GNUNET_free (temp_str); 840 GNUNET_free (temp_str);
842 } 841 }
843 842
844 if ((GNUNET_YES 843 if ((GNUNET_YES ==
845 == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 844 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
846 "connect_topology", 845 "connect_topology", &temp_str)) &&
847 &temp_str)) 846 (GNUNET_NO ==
848 && (GNUNET_NO == 847 GNUNET_TESTING_topology_get (&pg_start_ctx->connect_topology, temp_str)))
849 GNUNET_TESTING_topology_get (&pg_start_ctx->connect_topology,
850 temp_str)))
851 { 848 {
852 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 849 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
853 "Invalid connect topology `%s' given for section %s option %s\n", 850 "Invalid connect topology `%s' given for section %s option %s\n",
@@ -855,14 +852,13 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
855 } 852 }
856 GNUNET_free_non_null (temp_str); 853 GNUNET_free_non_null (temp_str);
857 854
858 if ((GNUNET_YES 855 if ((GNUNET_YES ==
859 == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 856 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
860 "connect_topology_option", 857 "connect_topology_option",
861 &temp_str)) 858 &temp_str)) &&
862 && (GNUNET_NO 859 (GNUNET_NO ==
863 == 860 GNUNET_TESTING_topology_option_get (&pg_start_ctx->
864 GNUNET_TESTING_topology_option_get 861 connect_topology_option, temp_str)))
865 (&pg_start_ctx->connect_topology_option, temp_str)))
866 { 862 {
867 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 863 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
868 "Invalid connect topology option `%s' given for section %s option %s\n", 864 "Invalid connect topology option `%s' given for section %s option %s\n",
@@ -871,14 +867,13 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
871 } 867 }
872 GNUNET_free_non_null (temp_str); 868 GNUNET_free_non_null (temp_str);
873 869
874 if (GNUNET_YES 870 if (GNUNET_YES ==
875 == GNUNET_CONFIGURATION_get_value_string (cfg, 871 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
876 "testing", 872 "connect_topology_option_modifier",
877 "connect_topology_option_modifier", 873 &temp_str))
878 &temp_str))
879 { 874 {
880 if (sscanf (temp_str, "%lf", 875 if (sscanf
881 &pg_start_ctx->connect_topology_option_modifier) != 1) 876 (temp_str, "%lf", &pg_start_ctx->connect_topology_option_modifier) != 1)
882 { 877 {
883 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 878 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
884 _ 879 _
@@ -891,17 +886,17 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
891 GNUNET_free (temp_str); 886 GNUNET_free (temp_str);
892 } 887 }
893 888
894 if (GNUNET_YES 889 if (GNUNET_YES !=
895 != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 890 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
896 "blacklist_transports", 891 "blacklist_transports",
897 &pg_start_ctx->restrict_transports)) 892 &pg_start_ctx->
893 restrict_transports))
898 pg_start_ctx->restrict_transports = NULL; 894 pg_start_ctx->restrict_transports = NULL;
899 895
900 pg_start_ctx->restrict_topology = GNUNET_TESTING_TOPOLOGY_NONE; 896 pg_start_ctx->restrict_topology = GNUNET_TESTING_TOPOLOGY_NONE;
901 if ((GNUNET_YES 897 if ((GNUNET_YES ==
902 == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 898 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
903 "blacklist_topology", 899 "blacklist_topology", &temp_str))
904 &temp_str))
905 && (GNUNET_NO == 900 && (GNUNET_NO ==
906 GNUNET_TESTING_topology_get (&pg_start_ctx->restrict_topology, 901 GNUNET_TESTING_topology_get (&pg_start_ctx->restrict_topology,
907 temp_str))) 902 temp_str)))
@@ -928,23 +923,21 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
928 pg_start_ctx->verbose); 923 pg_start_ctx->verbose);
929 /* Make compilers happy */ 924 /* Make compilers happy */
930 reset_meter (pg_start_ctx->peer_start_meter); 925 reset_meter (pg_start_ctx->peer_start_meter);
931 pg_start_ctx->die_task 926 pg_start_ctx->die_task =
932 =
933 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining 927 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
934 (pg_start_ctx->timeout), &end_badly, 928 (pg_start_ctx->timeout), &end_badly,
935 "didn't generate all hostkeys within allowed startup time!"); 929 "didn't generate all hostkeys within allowed startup time!");
936 930
937 pg_start_ctx->pg 931 pg_start_ctx->pg =
938 = GNUNET_TESTING_daemons_start (pg_start_ctx->cfg, 932 GNUNET_TESTING_daemons_start (pg_start_ctx->cfg, pg_start_ctx->peers_left,
939 pg_start_ctx->peers_left, 933 pg_start_ctx->max_concurrent_connections,
940 pg_start_ctx->max_concurrent_connections, 934 pg_start_ctx->max_concurrent_ssh,
941 pg_start_ctx->max_concurrent_ssh, 935 GNUNET_TIME_absolute_get_remaining
942 GNUNET_TIME_absolute_get_remaining 936 (pg_start_ctx->timeout),
943 (pg_start_ctx->timeout), 937 &internal_hostkey_callback, pg_start_ctx,
944 &internal_hostkey_callback, pg_start_ctx, 938 &internal_peers_started_callback,
945 &internal_peers_started_callback, 939 pg_start_ctx, &internal_topology_callback,
946 pg_start_ctx, &internal_topology_callback, 940 pg_start_ctx, pg_start_ctx->hostnames);
947 pg_start_ctx, pg_start_ctx->hostnames);
948 941
949 return pg_start_ctx->pg; 942 return pg_start_ctx->pg;
950} 943}