aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-01-25 15:28:08 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-01-25 15:28:08 +0000
commit30c5c323f28ade8a1e7c6c593778793e44accb3a (patch)
tree845955ec895d221338b44f0cadce7932932e78cc /src
parent43d558efd13a3245e65efd0acdc9c4ba59cd2bee (diff)
downloadgnunet-30c5c323f28ade8a1e7c6c593778793e44accb3a.tar.gz
gnunet-30c5c323f28ade8a1e7c6c593778793e44accb3a.zip
- indent
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-helper-testbed.c23
-rw-r--r--src/testbed/gnunet-service-testbed.c256
-rw-r--r--src/testbed/gnunet-service-testbed.h46
-rw-r--r--src/testbed/gnunet-service-testbed_hc.c24
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c358
-rw-r--r--src/testbed/gnunet-testbed-profiler.c60
-rw-r--r--src/testbed/gnunet_mpi_test.c35
-rw-r--r--src/testbed/ll_master.c16
-rw-r--r--src/testbed/ll_monitor.c4
-rw-r--r--src/testbed/standard_deviation.c20
-rw-r--r--src/testbed/test_testbed_api.c32
-rw-r--r--src/testbed/test_testbed_api_2peers_1controller.c19
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c188
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c66
-rw-r--r--src/testbed/test_testbed_api_hosts.c3
-rw-r--r--src/testbed/test_testbed_api_operations.c39
-rw-r--r--src/testbed/test_testbed_api_test.c28
-rw-r--r--src/testbed/test_testbed_api_testbed_run.c9
-rw-r--r--src/testbed/test_testbed_api_topology.c21
-rw-r--r--src/testbed/test_testbed_api_topology_clique.c21
-rw-r--r--src/testbed/testbed.h6
-rw-r--r--src/testbed/testbed_api.c377
-rw-r--r--src/testbed/testbed_api.h36
-rw-r--r--src/testbed/testbed_api_hosts.c37
-rw-r--r--src/testbed/testbed_api_operations.c19
-rw-r--r--src/testbed/testbed_api_operations.h5
-rw-r--r--src/testbed/testbed_api_peers.c36
-rw-r--r--src/testbed/testbed_api_peers.h10
-rw-r--r--src/testbed/testbed_api_services.c35
-rw-r--r--src/testbed/testbed_api_statistics.c4
-rw-r--r--src/testbed/testbed_api_test.c17
-rw-r--r--src/testbed/testbed_api_testbed.c221
-rw-r--r--src/testbed/testbed_api_topology.c270
-rw-r--r--src/testbed/testbed_api_topology.h8
-rw-r--r--src/testbed/testbed_helper.h7
35 files changed, 1146 insertions, 1210 deletions
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c
index 8f94d5ce5..7d0bf873d 100644
--- a/src/testbed/gnunet-helper-testbed.c
+++ b/src/testbed/gnunet-helper-testbed.c
@@ -252,7 +252,7 @@ tokenizer_cb (void *cls, void *client,
252 uint16_t trusted_ip_size; 252 uint16_t trusted_ip_size;
253 uint16_t hostname_size; 253 uint16_t hostname_size;
254 uint16_t msize; 254 uint16_t msize;
255 255
256 msize = ntohs (message->size); 256 msize = ntohs (message->size);
257 if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= msize) || 257 if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= msize) ||
258 (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) 258 (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type)))
@@ -265,8 +265,7 @@ tokenizer_cb (void *cls, void *client,
265 trusted_ip = (char *) &msg[1]; 265 trusted_ip = (char *) &msg[1];
266 if ('\0' != trusted_ip[trusted_ip_size]) 266 if ('\0' != trusted_ip[trusted_ip_size])
267 { 267 {
268 LOG (GNUNET_ERROR_TYPE_WARNING, 268 LOG (GNUNET_ERROR_TYPE_WARNING, "Trusted IP cannot be empty -- exiting\n");
269 "Trusted IP cannot be empty -- exiting\n");
270 goto error; 269 goto error;
271 } 270 }
272 hostname_size = ntohs (msg->hostname_size); 271 hostname_size = ntohs (msg->hostname_size);
@@ -276,7 +275,7 @@ tokenizer_cb (void *cls, void *client,
276 GNUNET_break (0); 275 GNUNET_break (0);
277 LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); 276 LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n");
278 goto error; 277 goto error;
279 } 278 }
280 ul_config_size = (uLongf) ntohs (msg->config_size); 279 ul_config_size = (uLongf) ntohs (msg->config_size);
281 config = GNUNET_malloc (ul_config_size); 280 config = GNUNET_malloc (ul_config_size);
282 xconfig_size = 281 xconfig_size =
@@ -284,8 +283,8 @@ tokenizer_cb (void *cls, void *client,
284 sizeof (struct GNUNET_TESTBED_HelperInit)); 283 sizeof (struct GNUNET_TESTBED_HelperInit));
285 if (Z_OK != 284 if (Z_OK !=
286 uncompress ((Bytef *) config, &ul_config_size, 285 uncompress ((Bytef *) config, &ul_config_size,
287 (const Bytef *) (trusted_ip + trusted_ip_size + 1 + hostname_size), 286 (const Bytef *) (trusted_ip + trusted_ip_size + 1 +
288 (uLongf) xconfig_size)) 287 hostname_size), (uLongf) xconfig_size))
289 { 288 {
290 LOG (GNUNET_ERROR_TYPE_WARNING, 289 LOG (GNUNET_ERROR_TYPE_WARNING,
291 "Error while uncompressing config -- exiting\n"); 290 "Error while uncompressing config -- exiting\n");
@@ -306,11 +305,12 @@ tokenizer_cb (void *cls, void *client,
306 if (0 != hostname_size) 305 if (0 != hostname_size)
307 { 306 {
308 hostname = GNUNET_malloc (hostname_size + 1); 307 hostname = GNUNET_malloc (hostname_size + 1);
309 (void) strncpy (hostname, ((char *) &msg[1]) + trusted_ip_size + 1, hostname_size); 308 (void) strncpy (hostname, ((char *) &msg[1]) + trusted_ip_size + 1,
309 hostname_size);
310 hostname[hostname_size] = '\0'; 310 hostname[hostname_size] = '\0';
311 } 311 }
312 test_system = GNUNET_TESTING_system_create ("testbed-helper", trusted_ip, 312 test_system =
313 hostname); 313 GNUNET_TESTING_system_create ("testbed-helper", trusted_ip, hostname);
314 GNUNET_free_non_null (hostname); 314 GNUNET_free_non_null (hostname);
315 hostname = NULL; 315 hostname = NULL;
316 GNUNET_assert (NULL != test_system); 316 GNUNET_assert (NULL != test_system);
@@ -333,9 +333,8 @@ tokenizer_cb (void *cls, void *client,
333 testbed = 333 testbed =
334 GNUNET_OS_start_process (PIPE_CONTROL, 334 GNUNET_OS_start_process (PIPE_CONTROL,
335 GNUNET_OS_INHERIT_STD_ERR /*verbose? */ , NULL, 335 GNUNET_OS_INHERIT_STD_ERR /*verbose? */ , NULL,
336 NULL, 336 NULL, binary, "gnunet-service-testbed", "-c",
337 binary, 337 config, NULL);
338 "gnunet-service-testbed", "-c", config, NULL);
339 GNUNET_free (binary); 338 GNUNET_free (binary);
340 GNUNET_free (config); 339 GNUNET_free (config);
341 if (NULL == testbed) 340 if (NULL == testbed)
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index e767413ee..56bac51c9 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -226,7 +226,7 @@ transmit_ready_notify (void *cls, size_t size, void *buf)
226 */ 226 */
227void 227void
228GST_queue_message (struct GNUNET_SERVER_Client *client, 228GST_queue_message (struct GNUNET_SERVER_Client *client,
229 struct GNUNET_MessageHeader *msg) 229 struct GNUNET_MessageHeader *msg)
230{ 230{
231 struct MessageQueue *mq_entry; 231 struct MessageQueue *mq_entry;
232 uint16_t type; 232 uint16_t type;
@@ -324,7 +324,8 @@ static void
324slave_list_add (struct Slave *slave) 324slave_list_add (struct Slave *slave)
325{ 325{
326 if (slave->host_id >= GST_slave_list_size) 326 if (slave->host_id >= GST_slave_list_size)
327 array_grow_large_enough (GST_slave_list, GST_slave_list_size, slave->host_id); 327 array_grow_large_enough (GST_slave_list, GST_slave_list_size,
328 slave->host_id);
328 GNUNET_assert (NULL == GST_slave_list[slave->host_id]); 329 GNUNET_assert (NULL == GST_slave_list[slave->host_id]);
329 GST_slave_list[slave->host_id] = slave; 330 GST_slave_list[slave->host_id] = slave;
330} 331}
@@ -361,7 +362,8 @@ peer_list_remove (struct Peer *peer)
361 while (GST_peer_list_size >= LIST_GROW_STEP) 362 while (GST_peer_list_size >= LIST_GROW_STEP)
362 { 363 {
363 for (id = GST_peer_list_size - 1; 364 for (id = GST_peer_list_size - 1;
364 (id >= GST_peer_list_size - LIST_GROW_STEP) && (id != UINT32_MAX); id--) 365 (id >= GST_peer_list_size - LIST_GROW_STEP) && (id != UINT32_MAX);
366 id--)
365 if (NULL != GST_peer_list[id]) 367 if (NULL != GST_peer_list[id])
366 break; 368 break;
367 if (id != ((GST_peer_list_size - LIST_GROW_STEP) - 1)) 369 if (id != ((GST_peer_list_size - LIST_GROW_STEP) - 1))
@@ -371,7 +373,8 @@ peer_list_remove (struct Peer *peer)
371 if (orig_size == GST_peer_list_size) 373 if (orig_size == GST_peer_list_size)
372 return; 374 return;
373 GST_peer_list = 375 GST_peer_list =
374 GNUNET_realloc (GST_peer_list, sizeof (struct Peer *) * GST_peer_list_size); 376 GNUNET_realloc (GST_peer_list,
377 sizeof (struct Peer *) * GST_peer_list_size);
375} 378}
376 379
377 380
@@ -422,7 +425,7 @@ route_message (uint32_t host_id, const struct GNUNET_MessageHeader *msg)
422 */ 425 */
423void 426void
424GST_send_operation_fail_msg (struct GNUNET_SERVER_Client *client, 427GST_send_operation_fail_msg (struct GNUNET_SERVER_Client *client,
425 uint64_t operation_id, const char *emsg) 428 uint64_t operation_id, const char *emsg)
426{ 429{
427 struct GNUNET_TESTBED_OperationFailureEventMessage *msg; 430 struct GNUNET_TESTBED_OperationFailureEventMessage *msg;
428 uint16_t msize; 431 uint16_t msize;
@@ -471,7 +474,7 @@ send_operation_success_msg (struct GNUNET_SERVER_Client *client,
471 * @param cls the handle to the slave at which the registration is completed 474 * @param cls the handle to the slave at which the registration is completed
472 * @param emsg the error message; NULL if host registration is successful 475 * @param emsg the error message; NULL if host registration is successful
473 */ 476 */
474static void 477static void
475hr_completion (void *cls, const char *emsg); 478hr_completion (void *cls, const char *emsg);
476 479
477 480
@@ -485,18 +488,16 @@ static void
485register_next_host (struct Slave *slave) 488register_next_host (struct Slave *slave)
486{ 489{
487 struct HostRegistration *hr; 490 struct HostRegistration *hr;
488 491
489 hr = slave->hr_dll_head; 492 hr = slave->hr_dll_head;
490 GNUNET_assert (NULL != hr); 493 GNUNET_assert (NULL != hr);
491 GNUNET_assert (NULL == slave->rhandle); 494 GNUNET_assert (NULL == slave->rhandle);
492 LOG (GNUNET_ERROR_TYPE_DEBUG, 495 LOG (GNUNET_ERROR_TYPE_DEBUG, "Registering host %u at %u\n",
493 "Registering host %u at %u\n",
494 GNUNET_TESTBED_host_get_id_ (hr->host), 496 GNUNET_TESTBED_host_get_id_ (hr->host),
495 GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id])); 497 GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id]));
496 slave->rhandle = GNUNET_TESTBED_register_host (slave->controller, 498 slave->rhandle =
497 hr->host, 499 GNUNET_TESTBED_register_host (slave->controller, hr->host, hr_completion,
498 hr_completion, 500 slave);
499 slave);
500} 501}
501 502
502 503
@@ -506,7 +507,7 @@ register_next_host (struct Slave *slave)
506 * @param cls the handle to the slave at which the registration is completed 507 * @param cls the handle to the slave at which the registration is completed
507 * @param emsg the error message; NULL if host registration is successful 508 * @param emsg the error message; NULL if host registration is successful
508 */ 509 */
509static void 510static void
510hr_completion (void *cls, const char *emsg) 511hr_completion (void *cls, const char *emsg)
511{ 512{
512 struct Slave *slave = cls; 513 struct Slave *slave = cls;
@@ -515,13 +516,10 @@ hr_completion (void *cls, const char *emsg)
515 slave->rhandle = NULL; 516 slave->rhandle = NULL;
516 hr = slave->hr_dll_head; 517 hr = slave->hr_dll_head;
517 GNUNET_assert (NULL != hr); 518 GNUNET_assert (NULL != hr);
518 LOG (GNUNET_ERROR_TYPE_DEBUG, 519 LOG (GNUNET_ERROR_TYPE_DEBUG, "Registering host %u at %u successful\n",
519 "Registering host %u at %u successful\n",
520 GNUNET_TESTBED_host_get_id_ (hr->host), 520 GNUNET_TESTBED_host_get_id_ (hr->host),
521 GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id])); 521 GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id]));
522 GNUNET_CONTAINER_DLL_remove (slave->hr_dll_head, 522 GNUNET_CONTAINER_DLL_remove (slave->hr_dll_head, slave->hr_dll_tail, hr);
523 slave->hr_dll_tail,
524 hr);
525 if (NULL != hr->cb) 523 if (NULL != hr->cb)
526 hr->cb (hr->cb_cls, emsg); 524 hr->cb (hr->cb_cls, emsg);
527 GNUNET_free (hr); 525 GNUNET_free (hr);
@@ -534,16 +532,15 @@ hr_completion (void *cls, const char *emsg)
534 * Adds a host registration's request to a slave's registration queue 532 * Adds a host registration's request to a slave's registration queue
535 * 533 *
536 * @param slave the slave controller at which the given host has to be 534 * @param slave the slave controller at which the given host has to be
537 * registered 535 * registered
538 * @param cb the host registration completion callback 536 * @param cb the host registration completion callback
539 * @param cb_cls the closure for the host registration completion callback 537 * @param cb_cls the closure for the host registration completion callback
540 * @param host the host which has to be registered 538 * @param host the host which has to be registered
541 */ 539 */
542void 540void
543GST_queue_host_registration (struct Slave *slave, 541GST_queue_host_registration (struct Slave *slave,
544 GNUNET_TESTBED_HostRegistrationCompletion cb, 542 GNUNET_TESTBED_HostRegistrationCompletion cb,
545 void *cb_cls, 543 void *cb_cls, struct GNUNET_TESTBED_Host *host)
546 struct GNUNET_TESTBED_Host *host)
547{ 544{
548 struct HostRegistration *hr; 545 struct HostRegistration *hr;
549 int call_register; 546 int call_register;
@@ -557,9 +554,7 @@ GST_queue_host_registration (struct Slave *slave,
557 hr->cb_cls = cb_cls; 554 hr->cb_cls = cb_cls;
558 hr->host = host; 555 hr->host = host;
559 call_register = (NULL == slave->hr_dll_head) ? GNUNET_YES : GNUNET_NO; 556 call_register = (NULL == slave->hr_dll_head) ? GNUNET_YES : GNUNET_NO;
560 GNUNET_CONTAINER_DLL_insert_tail (slave->hr_dll_head, 557 GNUNET_CONTAINER_DLL_insert_tail (slave->hr_dll_head, slave->hr_dll_tail, hr);
561 slave->hr_dll_tail,
562 hr);
563 if (GNUNET_YES == call_register) 558 if (GNUNET_YES == call_register)
564 register_next_host (slave); 559 register_next_host (slave);
565} 560}
@@ -606,7 +601,7 @@ lcf_proc_cc (void *cls, const char *emsg)
606 } 601 }
607 return; 602 return;
608 603
609 registration_error: 604registration_error:
610 LOG (GNUNET_ERROR_TYPE_WARNING, "Host registration failed with message: %s\n", 605 LOG (GNUNET_ERROR_TYPE_WARNING, "Host registration failed with message: %s\n",
611 emsg); 606 emsg);
612 lcf->state = FINISHED; 607 lcf->state = FINISHED;
@@ -622,7 +617,7 @@ lcf_proc_cc (void *cls, const char *emsg)
622 */ 617 */
623void 618void
624GST_forwarded_operation_reply_relay (void *cls, 619GST_forwarded_operation_reply_relay (void *cls,
625 const struct GNUNET_MessageHeader *msg) 620 const struct GNUNET_MessageHeader *msg)
626{ 621{
627 struct ForwardedOperationContext *fopc = cls; 622 struct ForwardedOperationContext *fopc = cls;
628 struct GNUNET_MessageHeader *dup_msg; 623 struct GNUNET_MessageHeader *dup_msg;
@@ -648,7 +643,7 @@ GST_forwarded_operation_reply_relay (void *cls,
648 */ 643 */
649void 644void
650GST_forwarded_operation_timeout (void *cls, 645GST_forwarded_operation_timeout (void *cls,
651 const struct GNUNET_SCHEDULER_TaskContext *tc) 646 const struct GNUNET_SCHEDULER_TaskContext *tc)
652{ 647{
653 struct ForwardedOperationContext *fopc = cls; 648 struct ForwardedOperationContext *fopc = cls;
654 649
@@ -730,12 +725,12 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
730 { 725 {
731 case INIT: 726 case INIT:
732 if (GNUNET_NO == 727 if (GNUNET_NO ==
733 GNUNET_TESTBED_is_host_registered_ (GST_host_list[lcf->delegated_host_id], 728 GNUNET_TESTBED_is_host_registered_ (GST_host_list
729 [lcf->delegated_host_id],
734 lcf->gateway->controller)) 730 lcf->gateway->controller))
735 { 731 {
736 GST_queue_host_registration (lcf->gateway, 732 GST_queue_host_registration (lcf->gateway, lcf_proc_cc, lcf,
737 lcf_proc_cc, lcf, 733 GST_host_list[lcf->delegated_host_id]);
738 GST_host_list[lcf->delegated_host_id]);
739 } 734 }
740 else 735 else
741 { 736 {
@@ -748,9 +743,8 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
748 GNUNET_TESTBED_is_host_registered_ (GST_host_list[lcf->slave_host_id], 743 GNUNET_TESTBED_is_host_registered_ (GST_host_list[lcf->slave_host_id],
749 lcf->gateway->controller)) 744 lcf->gateway->controller))
750 { 745 {
751 GST_queue_host_registration (lcf->gateway, 746 GST_queue_host_registration (lcf->gateway, lcf_proc_cc, lcf,
752 lcf_proc_cc, lcf, 747 GST_host_list[lcf->slave_host_id]);
753 GST_host_list[lcf->slave_host_id]);
754 } 748 }
755 else 749 else
756 { 750 {
@@ -802,7 +796,7 @@ slave_event_callback (void *cls,
802 struct RegisteredHostContext *rhc; 796 struct RegisteredHostContext *rhc;
803 struct GNUNET_CONFIGURATION_Handle *cfg; 797 struct GNUNET_CONFIGURATION_Handle *cfg;
804 struct GNUNET_TESTBED_Operation *old_op; 798 struct GNUNET_TESTBED_Operation *old_op;
805 799
806 /* We currently only get here when working on RegisteredHostContexts */ 800 /* We currently only get here when working on RegisteredHostContexts */
807 GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type); 801 GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type);
808 rhc = event->details.operation_finished.op_cls; 802 rhc = event->details.operation_finished.op_cls;
@@ -814,11 +808,8 @@ slave_event_callback (void *cls,
814 old_op = rhc->sub_op; 808 old_op = rhc->sub_op;
815 rhc->state = RHC_LINK; 809 rhc->state = RHC_LINK;
816 rhc->sub_op = 810 rhc->sub_op =
817 GNUNET_TESTBED_controller_link (rhc, 811 GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller,
818 rhc->gateway->controller, 812 rhc->reg_host, rhc->host, cfg,
819 rhc->reg_host,
820 rhc->host,
821 cfg,
822 GNUNET_NO); 813 GNUNET_NO);
823 GNUNET_TESTBED_operation_done (old_op); 814 GNUNET_TESTBED_operation_done (old_op);
824 break; 815 break;
@@ -866,8 +857,8 @@ slave_status_callback (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
866 } 857 }
867 slave->controller = 858 slave->controller =
868 GNUNET_TESTBED_controller_connect (cfg, GST_host_list[slave->host_id], 859 GNUNET_TESTBED_controller_connect (cfg, GST_host_list[slave->host_id],
869 event_mask, 860 event_mask, &slave_event_callback,
870 &slave_event_callback, slave); 861 slave);
871 if (NULL != slave->controller) 862 if (NULL != slave->controller)
872 { 863 {
873 send_operation_success_msg (lcc->client, lcc->operation_id); 864 send_operation_success_msg (lcc->client, lcc->operation_id);
@@ -876,14 +867,14 @@ slave_status_callback (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
876 else 867 else
877 { 868 {
878 GST_send_operation_fail_msg (lcc->client, lcc->operation_id, 869 GST_send_operation_fail_msg (lcc->client, lcc->operation_id,
879 "Could not connect to delegated controller"); 870 "Could not connect to delegated controller");
880 GNUNET_TESTBED_controller_stop (slave->controller_proc); 871 GNUNET_TESTBED_controller_stop (slave->controller_proc);
881 GST_slave_list[slave->host_id] = NULL; 872 GST_slave_list[slave->host_id] = NULL;
882 GNUNET_free (slave); 873 GNUNET_free (slave);
883 slave = NULL; 874 slave = NULL;
884 } 875 }
885 876
886 clean_lcc: 877clean_lcc:
887 if (NULL != lcc) 878 if (NULL != lcc)
888 { 879 {
889 if (NULL != lcc->client) 880 if (NULL != lcc->client)
@@ -944,15 +935,13 @@ handle_init (void *cls, struct GNUNET_SERVER_Client *client,
944 GST_context->master_ip = GNUNET_strdup (controller_hostname); 935 GST_context->master_ip = GNUNET_strdup (controller_hostname);
945 LOG_DEBUG ("Our IP: %s\n", GST_context->master_ip); 936 LOG_DEBUG ("Our IP: %s\n", GST_context->master_ip);
946 GST_context->system = 937 GST_context->system =
947 GNUNET_TESTING_system_create ("testbed", GST_context->master_ip, hostname); 938 GNUNET_TESTING_system_create ("testbed", GST_context->master_ip,
939 hostname);
948 host = 940 host =
949 GNUNET_TESTBED_host_create_with_id (GST_context->host_id, 941 GNUNET_TESTBED_host_create_with_id (GST_context->host_id,
950 GST_context->master_ip, 942 GST_context->master_ip, NULL, 0);
951 NULL,
952 0);
953 host_list_add (host); 943 host_list_add (host);
954 LOG_DEBUG ("Created master context with host ID: %u\n", 944 LOG_DEBUG ("Created master context with host ID: %u\n", GST_context->host_id);
955 GST_context->host_id);
956 GNUNET_SERVER_receive_done (client, GNUNET_OK); 945 GNUNET_SERVER_receive_done (client, GNUNET_OK);
957} 946}
958 947
@@ -987,8 +976,9 @@ handle_add_host (void *cls, struct GNUNET_SERVER_Client *client,
987 if (0 != username_length) 976 if (0 != username_length)
988 username_length++; 977 username_length++;
989 /* msg must contain hostname */ 978 /* msg must contain hostname */
990 GNUNET_assert (msize > (sizeof (struct GNUNET_TESTBED_AddHostMessage) + 979 GNUNET_assert (msize >
991 username_length + 1)); 980 (sizeof (struct GNUNET_TESTBED_AddHostMessage) +
981 username_length + 1));
992 if (0 != username_length) 982 if (0 != username_length)
993 GNUNET_assert ('\0' == username[username_length - 1]); 983 GNUNET_assert ('\0' == username[username_length - 1]);
994 hostname = username + username_length; 984 hostname = username + username_length;
@@ -1025,8 +1015,7 @@ handle_add_host (void *cls, struct GNUNET_SERVER_Client *client,
1025 } 1015 }
1026 else 1016 else
1027 { 1017 {
1028 LOG_DEBUG ("Added host %u at %u\n", 1018 LOG_DEBUG ("Added host %u at %u\n", host_id, GST_context->host_id);
1029 host_id, GST_context->host_id);
1030 reply = GNUNET_malloc (reply_size); 1019 reply = GNUNET_malloc (reply_size);
1031 } 1020 }
1032 reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM); 1021 reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM);
@@ -1173,15 +1162,16 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client,
1173 (NULL == GST_host_list[delegated_host_id])) 1162 (NULL == GST_host_list[delegated_host_id]))
1174 { 1163 {
1175 LOG (GNUNET_ERROR_TYPE_WARNING, 1164 LOG (GNUNET_ERROR_TYPE_WARNING,
1176 "Delegated host %u not registered with us\n", delegated_host_id); 1165 "Delegated host %u not registered with us\n", delegated_host_id);
1177 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1166 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1178 return; 1167 return;
1179 } 1168 }
1180 slave_host_id = ntohl (msg->slave_host_id); 1169 slave_host_id = ntohl (msg->slave_host_id);
1181 if ((slave_host_id >= GST_host_list_size) || (NULL == GST_host_list[slave_host_id])) 1170 if ((slave_host_id >= GST_host_list_size) ||
1171 (NULL == GST_host_list[slave_host_id]))
1182 { 1172 {
1183 LOG (GNUNET_ERROR_TYPE_WARNING, "Slave host %u not registered with us\n", 1173 LOG (GNUNET_ERROR_TYPE_WARNING, "Slave host %u not registered with us\n",
1184 slave_host_id); 1174 slave_host_id);
1185 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1175 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1186 return; 1176 return;
1187 } 1177 }
@@ -1192,7 +1182,7 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client,
1192 return; 1182 return;
1193 } 1183 }
1194 1184
1195 if (slave_host_id == GST_context->host_id) /* Link from us */ 1185 if (slave_host_id == GST_context->host_id) /* Link from us */
1196 { 1186 {
1197 struct Slave *slave; 1187 struct Slave *slave;
1198 struct LinkControllersContext *lcc; 1188 struct LinkControllersContext *lcc;
@@ -1249,14 +1239,14 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client,
1249 { 1239 {
1250 slave->controller = 1240 slave->controller =
1251 GNUNET_TESTBED_controller_connect (cfg, GST_host_list[slave->host_id], 1241 GNUNET_TESTBED_controller_connect (cfg, GST_host_list[slave->host_id],
1252 event_mask, 1242 event_mask, &slave_event_callback,
1253 &slave_event_callback, slave); 1243 slave);
1254 slave->cfg = cfg; 1244 slave->cfg = cfg;
1255 if (NULL != slave->controller) 1245 if (NULL != slave->controller)
1256 send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id)); 1246 send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id));
1257 else 1247 else
1258 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), 1248 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
1259 "Could not connect to delegated controller"); 1249 "Could not connect to delegated controller");
1260 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1250 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1261 return; 1251 return;
1262 } 1252 }
@@ -1266,9 +1256,9 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client,
1266 lcc->client = client; 1256 lcc->client = client;
1267 slave->lcc = lcc; 1257 slave->lcc = lcc;
1268 slave->controller_proc = 1258 slave->controller_proc =
1269 GNUNET_TESTBED_controller_start (GST_context->master_ip, 1259 GNUNET_TESTBED_controller_start (GST_context->master_ip,
1270 GST_host_list[slave->host_id], cfg, 1260 GST_host_list[slave->host_id], cfg,
1271 &slave_status_callback, slave); 1261 &slave_status_callback, slave);
1272 GNUNET_CONFIGURATION_destroy (cfg); 1262 GNUNET_CONFIGURATION_destroy (cfg);
1273 new_route = GNUNET_malloc (sizeof (struct Route)); 1263 new_route = GNUNET_malloc (sizeof (struct Route));
1274 new_route->dest = delegated_host_id; 1264 new_route->dest = delegated_host_id;
@@ -1314,11 +1304,11 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client,
1314 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1304 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1315 return; 1305 return;
1316 } 1306 }
1317 if ((delegated_host_id < route_list_size) 1307 if ((delegated_host_id < route_list_size) &&
1318 && (NULL != route_list[delegated_host_id])) 1308 (NULL != route_list[delegated_host_id]))
1319 { 1309 {
1320 GNUNET_break_op (0); /* Are you trying to link delegated host twice 1310 GNUNET_break_op (0); /* Are you trying to link delegated host twice
1321 with is subordinate flag set to GNUNET_YES? */ 1311 * with is subordinate flag set to GNUNET_YES? */
1322 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1312 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1323 return; 1313 return;
1324 } 1314 }
@@ -1463,7 +1453,7 @@ handle_peer_create (void *cls, struct GNUNET_SERVER_Client *client,
1463 if (UINT32_MAX == peer_id) 1453 if (UINT32_MAX == peer_id)
1464 { 1454 {
1465 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), 1455 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
1466 "Cannot create peer with given ID"); 1456 "Cannot create peer with given ID");
1467 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1457 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1468 return; 1458 return;
1469 } 1459 }
@@ -1502,16 +1492,13 @@ handle_peer_create (void *cls, struct GNUNET_SERVER_Client *client,
1502 return; 1492 return;
1503 } 1493 }
1504 GNUNET_free (config); 1494 GNUNET_free (config);
1505 GNUNET_CONFIGURATION_set_value_number (cfg, 1495 GNUNET_CONFIGURATION_set_value_number (cfg, "TESTBED", "PEERID",
1506 "TESTBED", 1496 (unsigned long long) peer_id);
1507 "PEERID",
1508 (unsigned long long) peer_id);
1509 peer = GNUNET_malloc (sizeof (struct Peer)); 1497 peer = GNUNET_malloc (sizeof (struct Peer));
1510 peer->is_remote = GNUNET_NO; 1498 peer->is_remote = GNUNET_NO;
1511 peer->details.local.cfg = cfg; 1499 peer->details.local.cfg = cfg;
1512 peer->id = peer_id; 1500 peer->id = peer_id;
1513 LOG_DEBUG ("Creating peer with id: %u\n", 1501 LOG_DEBUG ("Creating peer with id: %u\n", (unsigned int) peer->id);
1514 (unsigned int) peer->id);
1515 peer->details.local.peer = 1502 peer->details.local.peer =
1516 GNUNET_TESTING_peer_configure (GST_context->system, 1503 GNUNET_TESTING_peer_configure (GST_context->system,
1517 peer->details.local.cfg, peer->id, 1504 peer->details.local.cfg, peer->id,
@@ -1559,10 +1546,11 @@ handle_peer_create (void *cls, struct GNUNET_SERVER_Client *client,
1559 GNUNET_SERVER_client_keep (client); 1546 GNUNET_SERVER_client_keep (client);
1560 fo_ctxt->client = client; 1547 fo_ctxt->client = client;
1561 fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id); 1548 fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
1562 fo_ctxt->cls = peer; //GST_slave_list[route->dest]->controller; 1549 fo_ctxt->cls = peer; //GST_slave_list[route->dest]->controller;
1563 fo_ctxt->type = OP_PEER_CREATE; 1550 fo_ctxt->type = OP_PEER_CREATE;
1564 fo_ctxt->opc = 1551 fo_ctxt->opc =
1565 GNUNET_TESTBED_forward_operation_msg_ (GST_slave_list [route->dest]->controller, 1552 GNUNET_TESTBED_forward_operation_msg_ (GST_slave_list
1553 [route->dest]->controller,
1566 fo_ctxt->operation_id, 1554 fo_ctxt->operation_id,
1567 &msg->header, 1555 &msg->header,
1568 peer_create_success_cb, fo_ctxt); 1556 peer_create_success_cb, fo_ctxt);
@@ -1599,7 +1587,7 @@ handle_peer_destroy (void *cls, struct GNUNET_SERVER_Client *client,
1599 LOG (GNUNET_ERROR_TYPE_ERROR, 1587 LOG (GNUNET_ERROR_TYPE_ERROR,
1600 "Asked to destroy a non existent peer with id: %u\n", peer_id); 1588 "Asked to destroy a non existent peer with id: %u\n", peer_id);
1601 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), 1589 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
1602 "Peer doesn't exist"); 1590 "Peer doesn't exist");
1603 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1591 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1604 return; 1592 return;
1605 } 1593 }
@@ -1612,12 +1600,12 @@ handle_peer_destroy (void *cls, struct GNUNET_SERVER_Client *client,
1612 fopc->client = client; 1600 fopc->client = client;
1613 fopc->cls = peer; 1601 fopc->cls = peer;
1614 fopc->type = OP_PEER_DESTROY; 1602 fopc->type = OP_PEER_DESTROY;
1615 fopc->operation_id = GNUNET_ntohll (msg->operation_id); 1603 fopc->operation_id = GNUNET_ntohll (msg->operation_id);
1616 fopc->opc = 1604 fopc->opc =
1617 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller, 1605 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.
1606 slave->controller,
1618 fopc->operation_id, &msg->header, 1607 fopc->operation_id, &msg->header,
1619 &peer_destroy_success_cb, 1608 &peer_destroy_success_cb, fopc);
1620 fopc);
1621 fopc->timeout_task = 1609 fopc->timeout_task =
1622 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &GST_forwarded_operation_timeout, 1610 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &GST_forwarded_operation_timeout,
1623 fopc); 1611 fopc);
@@ -1672,7 +1660,8 @@ handle_peer_start (void *cls, struct GNUNET_SERVER_Client *client,
1672 fopc->operation_id = GNUNET_ntohll (msg->operation_id); 1660 fopc->operation_id = GNUNET_ntohll (msg->operation_id);
1673 fopc->type = OP_PEER_START; 1661 fopc->type = OP_PEER_START;
1674 fopc->opc = 1662 fopc->opc =
1675 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller, 1663 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.
1664 slave->controller,
1676 fopc->operation_id, &msg->header, 1665 fopc->operation_id, &msg->header,
1677 &GST_forwarded_operation_reply_relay, 1666 &GST_forwarded_operation_reply_relay,
1678 fopc); 1667 fopc);
@@ -1686,7 +1675,7 @@ handle_peer_start (void *cls, struct GNUNET_SERVER_Client *client,
1686 if (GNUNET_OK != GNUNET_TESTING_peer_start (peer->details.local.peer)) 1675 if (GNUNET_OK != GNUNET_TESTING_peer_start (peer->details.local.peer))
1687 { 1676 {
1688 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), 1677 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
1689 "Failed to start"); 1678 "Failed to start");
1690 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1679 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1691 return; 1680 return;
1692 } 1681 }
@@ -1726,21 +1715,23 @@ handle_peer_stop (void *cls, struct GNUNET_SERVER_Client *client,
1726 if ((peer_id >= GST_peer_list_size) || (NULL == GST_peer_list[peer_id])) 1715 if ((peer_id >= GST_peer_list_size) || (NULL == GST_peer_list[peer_id]))
1727 { 1716 {
1728 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), 1717 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
1729 "Peer not found"); 1718 "Peer not found");
1730 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1719 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1731 return; 1720 return;
1732 } 1721 }
1733 peer = GST_peer_list[peer_id]; 1722 peer = GST_peer_list[peer_id];
1734 if (GNUNET_YES == peer->is_remote) 1723 if (GNUNET_YES == peer->is_remote)
1735 { 1724 {
1736 LOG (GNUNET_ERROR_TYPE_DEBUG, "Forwarding PEER_STOP for peer %u\n", peer_id); 1725 LOG (GNUNET_ERROR_TYPE_DEBUG, "Forwarding PEER_STOP for peer %u\n",
1726 peer_id);
1737 fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); 1727 fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
1738 GNUNET_SERVER_client_keep (client); 1728 GNUNET_SERVER_client_keep (client);
1739 fopc->client = client; 1729 fopc->client = client;
1740 fopc->operation_id = GNUNET_ntohll (msg->operation_id); 1730 fopc->operation_id = GNUNET_ntohll (msg->operation_id);
1741 fopc->type = OP_PEER_STOP; 1731 fopc->type = OP_PEER_STOP;
1742 fopc->opc = 1732 fopc->opc =
1743 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller, 1733 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.
1734 slave->controller,
1744 fopc->operation_id, &msg->header, 1735 fopc->operation_id, &msg->header,
1745 &GST_forwarded_operation_reply_relay, 1736 &GST_forwarded_operation_reply_relay,
1746 fopc); 1737 fopc);
@@ -1755,7 +1746,7 @@ handle_peer_stop (void *cls, struct GNUNET_SERVER_Client *client,
1755 { 1746 {
1756 LOG (GNUNET_ERROR_TYPE_WARNING, "Stopping peer %u failed\n", peer_id); 1747 LOG (GNUNET_ERROR_TYPE_WARNING, "Stopping peer %u failed\n", peer_id);
1757 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), 1748 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
1758 "Peer not running"); 1749 "Peer not running");
1759 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1750 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1760 return; 1751 return;
1761 } 1752 }
@@ -1799,7 +1790,7 @@ handle_peer_get_config (void *cls, struct GNUNET_SERVER_Client *client,
1799 if ((peer_id >= GST_peer_list_size) || (NULL == GST_peer_list[peer_id])) 1790 if ((peer_id >= GST_peer_list_size) || (NULL == GST_peer_list[peer_id]))
1800 { 1791 {
1801 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), 1792 GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id),
1802 "Peer not found"); 1793 "Peer not found");
1803 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1794 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1804 return; 1795 return;
1805 } 1796 }
@@ -1807,7 +1798,7 @@ handle_peer_get_config (void *cls, struct GNUNET_SERVER_Client *client,
1807 if (GNUNET_YES == peer->is_remote) 1798 if (GNUNET_YES == peer->is_remote)
1808 { 1799 {
1809 struct ForwardedOperationContext *fopc; 1800 struct ForwardedOperationContext *fopc;
1810 1801
1811 LOG_DEBUG ("Forwarding PEER_GET_CONFIG for peer: %u\n", peer_id); 1802 LOG_DEBUG ("Forwarding PEER_GET_CONFIG for peer: %u\n", peer_id);
1812 fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); 1803 fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
1813 GNUNET_SERVER_client_keep (client); 1804 GNUNET_SERVER_client_keep (client);
@@ -1815,14 +1806,15 @@ handle_peer_get_config (void *cls, struct GNUNET_SERVER_Client *client,
1815 fopc->operation_id = GNUNET_ntohll (msg->operation_id); 1806 fopc->operation_id = GNUNET_ntohll (msg->operation_id);
1816 fopc->type = OP_PEER_INFO; 1807 fopc->type = OP_PEER_INFO;
1817 fopc->opc = 1808 fopc->opc =
1818 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller, 1809 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.
1810 slave->controller,
1819 fopc->operation_id, &msg->header, 1811 fopc->operation_id, &msg->header,
1820 &GST_forwarded_operation_reply_relay, 1812 &GST_forwarded_operation_reply_relay,
1821 fopc); 1813 fopc);
1822 fopc->timeout_task = 1814 fopc->timeout_task =
1823 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &GST_forwarded_operation_timeout, 1815 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &GST_forwarded_operation_timeout,
1824 fopc); 1816 fopc);
1825 GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc); 1817 GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc);
1826 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1818 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1827 return; 1819 return;
1828 } 1820 }
@@ -1858,10 +1850,10 @@ handle_peer_get_config (void *cls, struct GNUNET_SERVER_Client *client,
1858 */ 1850 */
1859static void 1851static void
1860handle_slave_get_config (void *cls, struct GNUNET_SERVER_Client *client, 1852handle_slave_get_config (void *cls, struct GNUNET_SERVER_Client *client,
1861 const struct GNUNET_MessageHeader *message) 1853 const struct GNUNET_MessageHeader *message)
1862{ 1854{
1863 struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; 1855 struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg;
1864 struct Slave *slave; 1856 struct Slave *slave;
1865 struct GNUNET_TESTBED_SlaveConfiguration *reply; 1857 struct GNUNET_TESTBED_SlaveConfiguration *reply;
1866 char *config; 1858 char *config;
1867 char *xconfig; 1859 char *xconfig;
@@ -1885,14 +1877,14 @@ handle_slave_get_config (void *cls, struct GNUNET_SERVER_Client *client,
1885 if (NULL == slave->cfg) 1877 if (NULL == slave->cfg)
1886 { 1878 {
1887 GST_send_operation_fail_msg (client, op_id, 1879 GST_send_operation_fail_msg (client, op_id,
1888 "Configuration not found (slave not started by me)"); 1880 "Configuration not found (slave not started by me)");
1889 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1881 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1890 return; 1882 return;
1891 } 1883 }
1892 config = GNUNET_CONFIGURATION_serialize (slave->cfg, &config_size); 1884 config = GNUNET_CONFIGURATION_serialize (slave->cfg, &config_size);
1893 xconfig_size = GNUNET_TESTBED_compress_config_ (config, config_size, 1885 xconfig_size =
1894 &xconfig); 1886 GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
1895 GNUNET_free (config); 1887 GNUNET_free (config);
1896 reply_size = xconfig_size + sizeof (struct GNUNET_TESTBED_SlaveConfiguration); 1888 reply_size = xconfig_size + sizeof (struct GNUNET_TESTBED_SlaveConfiguration);
1897 GNUNET_break (reply_size <= UINT16_MAX); 1889 GNUNET_break (reply_size <= UINT16_MAX);
1898 GNUNET_break (config_size <= UINT16_MAX); 1890 GNUNET_break (config_size <= UINT16_MAX);
@@ -1941,9 +1933,8 @@ ss_map_free_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
1941 * iterate, 1933 * iterate,
1942 * GNUNET_NO if not. 1934 * GNUNET_NO if not.
1943 */ 1935 */
1944static int 1936static int
1945reghost_free_iterator (void *cls, 1937reghost_free_iterator (void *cls, const struct GNUNET_HashCode *key,
1946 const struct GNUNET_HashCode * key,
1947 void *value) 1938 void *value)
1948{ 1939{
1949 struct Slave *slave = cls; 1940 struct Slave *slave = cls;
@@ -1951,19 +1942,17 @@ reghost_free_iterator (void *cls,
1951 struct ForwardedOverlayConnectContext *focc; 1942 struct ForwardedOverlayConnectContext *focc;
1952 1943
1953 GNUNET_assert (GNUNET_YES == 1944 GNUNET_assert (GNUNET_YES ==
1954 GNUNET_CONTAINER_multihashmap_remove (slave->reghost_map, 1945 GNUNET_CONTAINER_multihashmap_remove (slave->reghost_map, key,
1955 key, value)); 1946 value));
1956 while (NULL != (focc = rhc->focc_dll_head)) 1947 while (NULL != (focc = rhc->focc_dll_head))
1957 { 1948 {
1958 GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, 1949 GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc);
1959 rhc->focc_dll_tail,
1960 focc);
1961 GST_cleanup_focc (focc); 1950 GST_cleanup_focc (focc);
1962 } 1951 }
1963 if (NULL != rhc->sub_op) 1952 if (NULL != rhc->sub_op)
1964 GNUNET_TESTBED_operation_done (rhc->sub_op); 1953 GNUNET_TESTBED_operation_done (rhc->sub_op);
1965 if (NULL != rhc->client) 1954 if (NULL != rhc->client)
1966 GNUNET_SERVER_client_drop (rhc->client); 1955 GNUNET_SERVER_client_drop (rhc->client);
1967 GNUNET_free (value); 1956 GNUNET_free (value);
1968 return GNUNET_YES; 1957 return GNUNET_YES;
1969} 1958}
@@ -2037,12 +2026,12 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2037 if (NULL != GST_peer_list[id]) 2026 if (NULL != GST_peer_list[id])
2038 { 2027 {
2039 /* If destroy flag is set it means that this peer should have been 2028 /* If destroy flag is set it means that this peer should have been
2040 destroyed by a context which we destroy before */ 2029 * destroyed by a context which we destroy before */
2041 GNUNET_break (GNUNET_NO == GST_peer_list[id]->destroy_flag); 2030 GNUNET_break (GNUNET_NO == GST_peer_list[id]->destroy_flag);
2042 /* counter should be zero as we free all contexts before */ 2031 /* counter should be zero as we free all contexts before */
2043 GNUNET_break (0 == GST_peer_list[id]->reference_cnt); 2032 GNUNET_break (0 == GST_peer_list[id]->reference_cnt);
2044 if ( (GNUNET_NO == GST_peer_list[id]->is_remote) 2033 if ((GNUNET_NO == GST_peer_list[id]->is_remote) &&
2045 && (GNUNET_YES == GST_peer_list[id]->details.local.is_running)) 2034 (GNUNET_YES == GST_peer_list[id]->details.local.is_running))
2046 GNUNET_TESTING_peer_kill (GST_peer_list[id]->details.local.peer); 2035 GNUNET_TESTING_peer_kill (GST_peer_list[id]->details.local.peer);
2047 } 2036 }
2048 for (id = 0; id < GST_peer_list_size; id++) 2037 for (id = 0; id < GST_peer_list_size; id++)
@@ -2050,8 +2039,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2050 { 2039 {
2051 if (GNUNET_NO == GST_peer_list[id]->is_remote) 2040 if (GNUNET_NO == GST_peer_list[id]->is_remote)
2052 { 2041 {
2053 if (GNUNET_YES == GST_peer_list[id]->details.local.is_running) 2042 if (GNUNET_YES == GST_peer_list[id]->details.local.is_running)
2054 GNUNET_TESTING_peer_wait (GST_peer_list[id]->details.local.peer); 2043 GNUNET_TESTING_peer_wait (GST_peer_list[id]->details.local.peer);
2055 GNUNET_TESTING_peer_destroy (GST_peer_list[id]->details.local.peer); 2044 GNUNET_TESTING_peer_destroy (GST_peer_list[id]->details.local.peer);
2056 GNUNET_CONFIGURATION_destroy (GST_peer_list[id]->details.local.cfg); 2045 GNUNET_CONFIGURATION_destroy (GST_peer_list[id]->details.local.cfg);
2057 } 2046 }
@@ -2073,22 +2062,23 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2073 if (NULL != GST_slave_list[id]) 2062 if (NULL != GST_slave_list[id])
2074 { 2063 {
2075 struct HostRegistration *hr_entry; 2064 struct HostRegistration *hr_entry;
2076 2065
2077 while (NULL != (hr_entry = GST_slave_list[id]->hr_dll_head)) 2066 while (NULL != (hr_entry = GST_slave_list[id]->hr_dll_head))
2078 { 2067 {
2079 GNUNET_CONTAINER_DLL_remove (GST_slave_list[id]->hr_dll_head, 2068 GNUNET_CONTAINER_DLL_remove (GST_slave_list[id]->hr_dll_head,
2080 GST_slave_list[id]->hr_dll_tail, 2069 GST_slave_list[id]->hr_dll_tail, hr_entry);
2081 hr_entry);
2082 GNUNET_free (hr_entry); 2070 GNUNET_free (hr_entry);
2083 } 2071 }
2084 if (NULL != GST_slave_list[id]->rhandle) 2072 if (NULL != GST_slave_list[id]->rhandle)
2085 GNUNET_TESTBED_cancel_registration (GST_slave_list[id]->rhandle); 2073 GNUNET_TESTBED_cancel_registration (GST_slave_list[id]->rhandle);
2086 (void) GNUNET_CONTAINER_multihashmap_iterate (GST_slave_list[id]->reghost_map, 2074 (void)
2087 reghost_free_iterator, 2075 GNUNET_CONTAINER_multihashmap_iterate (GST_slave_list
2088 GST_slave_list[id]); 2076 [id]->reghost_map,
2077 reghost_free_iterator,
2078 GST_slave_list[id]);
2089 GNUNET_CONTAINER_multihashmap_destroy (GST_slave_list[id]->reghost_map); 2079 GNUNET_CONTAINER_multihashmap_destroy (GST_slave_list[id]->reghost_map);
2090 if (NULL != GST_slave_list[id]->cfg) 2080 if (NULL != GST_slave_list[id]->cfg)
2091 GNUNET_CONFIGURATION_destroy (GST_slave_list[id]->cfg); 2081 GNUNET_CONFIGURATION_destroy (GST_slave_list[id]->cfg);
2092 if (NULL != GST_slave_list[id]->controller) 2082 if (NULL != GST_slave_list[id]->controller)
2093 GNUNET_TESTBED_controller_disconnect (GST_slave_list[id]->controller); 2083 GNUNET_TESTBED_controller_disconnect (GST_slave_list[id]->controller);
2094 if (NULL != GST_slave_list[id]->controller_proc) 2084 if (NULL != GST_slave_list[id]->controller_proc)
@@ -2106,14 +2096,14 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2106 GST_context = NULL; 2096 GST_context = NULL;
2107 } 2097 }
2108 if (NULL != transmit_handle) 2098 if (NULL != transmit_handle)
2109 GNUNET_SERVER_notify_transmit_ready_cancel (transmit_handle); 2099 GNUNET_SERVER_notify_transmit_ready_cancel (transmit_handle);
2110 while (NULL != (mq_entry = mq_head)) 2100 while (NULL != (mq_entry = mq_head))
2111 { 2101 {
2112 GNUNET_free (mq_entry->msg); 2102 GNUNET_free (mq_entry->msg);
2113 GNUNET_SERVER_client_drop (mq_entry->client); 2103 GNUNET_SERVER_client_drop (mq_entry->client);
2114 GNUNET_CONTAINER_DLL_remove (mq_head, mq_tail, mq_entry); 2104 GNUNET_CONTAINER_DLL_remove (mq_head, mq_tail, mq_entry);
2115 GNUNET_free (mq_entry); 2105 GNUNET_free (mq_entry);
2116 } 2106 }
2117 GNUNET_free_non_null (hostname); 2107 GNUNET_free_non_null (hostname);
2118 GNUNET_CONFIGURATION_destroy (our_config); 2108 GNUNET_CONFIGURATION_destroy (our_config);
2119 /* Free hello cache */ 2109 /* Free hello cache */
@@ -2185,21 +2175,21 @@ testbed_run (void *cls, struct GNUNET_SERVER_Handle *server,
2185 char *logfile; 2175 char *logfile;
2186 unsigned long long num; 2176 unsigned long long num;
2187 2177
2188 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg, 2178 if (GNUNET_OK ==
2189 "TESTBED", 2179 GNUNET_CONFIGURATION_get_value_filename (cfg, "TESTBED", "LOG_FILE",
2190 "LOG_FILE", 2180 &logfile))
2191 &logfile))
2192 { 2181 {
2193 GNUNET_break (GNUNET_OK == GNUNET_log_setup ("testbed", "DEBUG", logfile)); 2182 GNUNET_break (GNUNET_OK == GNUNET_log_setup ("testbed", "DEBUG", logfile));
2194 GNUNET_free (logfile); 2183 GNUNET_free (logfile);
2195 } 2184 }
2196 GNUNET_assert (GNUNET_OK == 2185 GNUNET_assert (GNUNET_OK ==
2197 GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED", 2186 GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED",
2198 "HELLO_CACHE_SIZE", 2187 "HELLO_CACHE_SIZE",
2199 &num)); 2188 &num));
2200 GST_cache_init ((unsigned int) num); 2189 GST_cache_init ((unsigned int) num);
2201 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string 2190 GNUNET_assert (GNUNET_OK ==
2202 (cfg, "testbed", "HOSTNAME", &hostname)); 2191 GNUNET_CONFIGURATION_get_value_string (cfg, "testbed",
2192 "HOSTNAME", &hostname));
2203 our_config = GNUNET_CONFIGURATION_dup (cfg); 2193 our_config = GNUNET_CONFIGURATION_dup (cfg);
2204 GNUNET_SERVER_add_handlers (server, message_handlers); 2194 GNUNET_SERVER_add_handlers (server, message_handlers);
2205 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL); 2195 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL);
diff --git a/src/testbed/gnunet-service-testbed.h b/src/testbed/gnunet-service-testbed.h
index b3e917144..6165c91e5 100644
--- a/src/testbed/gnunet-service-testbed.h
+++ b/src/testbed/gnunet-service-testbed.h
@@ -96,7 +96,7 @@ struct ForwardedOperationContext
96 * The prev pointer for DLL 96 * The prev pointer for DLL
97 */ 97 */
98 struct ForwardedOperationContext *prev; 98 struct ForwardedOperationContext *prev;
99 99
100 /** 100 /**
101 * The generated operation context 101 * The generated operation context
102 */ 102 */
@@ -240,7 +240,7 @@ struct Slave
240 240
241struct Peer 241struct Peer
242{ 242{
243 243
244 union 244 union
245 { 245 {
246 struct 246 struct
@@ -255,7 +255,7 @@ struct Peer
255 * peer is configured with 255 * peer is configured with
256 */ 256 */
257 struct GNUNET_CONFIGURATION_Handle *cfg; 257 struct GNUNET_CONFIGURATION_Handle *cfg;
258 258
259 /** 259 /**
260 * Is the peer running 260 * Is the peer running
261 */ 261 */
@@ -329,7 +329,7 @@ struct Context
329 * The TESTING system handle for starting peers locally 329 * The TESTING system handle for starting peers locally
330 */ 330 */
331 struct GNUNET_TESTING_System *system; 331 struct GNUNET_TESTING_System *system;
332 332
333 /** 333 /**
334 * Our host id according to this context 334 * Our host id according to this context
335 */ 335 */
@@ -389,12 +389,12 @@ struct ForwardedOverlayConnectContext
389 * the id of peer 1 389 * the id of peer 1
390 */ 390 */
391 uint32_t peer1; 391 uint32_t peer1;
392 392
393 /** 393 /**
394 * The id of peer 2 394 * The id of peer 2
395 */ 395 */
396 uint32_t peer2; 396 uint32_t peer2;
397 397
398 /** 398 /**
399 * Id of the host where peer2 is running 399 * Id of the host where peer2 is running
400 */ 400 */
@@ -447,11 +447,12 @@ struct RegisteredHostContext
447 * Tail of the ForwardedOverlayConnectContext DLL 447 * Tail of the ForwardedOverlayConnectContext DLL
448 */ 448 */
449 struct ForwardedOverlayConnectContext *focc_dll_tail; 449 struct ForwardedOverlayConnectContext *focc_dll_tail;
450 450
451 /** 451 /**
452 * Enumeration of states for this context 452 * Enumeration of states for this context
453 */ 453 */
454 enum RHCState { 454 enum RHCState
455 {
455 456
456 /** 457 /**
457 * The initial state 458 * The initial state
@@ -473,7 +474,6 @@ struct RegisteredHostContext
473 * State where we attempt to do the overlay connection again 474 * State where we attempt to do the overlay connection again
474 */ 475 */
475 RHC_OL_CONNECT 476 RHC_OL_CONNECT
476
477 } state; 477 } state;
478 478
479}; 479};
@@ -493,12 +493,12 @@ enum LCFContextState
493 * Delegated host has been registered at the forwarding controller 493 * Delegated host has been registered at the forwarding controller
494 */ 494 */
495 DELEGATED_HOST_REGISTERED, 495 DELEGATED_HOST_REGISTERED,
496 496
497 /** 497 /**
498 * The slave host has been registred at the forwarding controller 498 * The slave host has been registred at the forwarding controller
499 */ 499 */
500 SLAVE_HOST_REGISTERED, 500 SLAVE_HOST_REGISTERED,
501 501
502 /** 502 /**
503 * The context has been finished (may have error) 503 * The context has been finished (may have error)
504 */ 504 */
@@ -639,7 +639,7 @@ extern unsigned int GST_slave_list_size;
639 */ 639 */
640void 640void
641GST_queue_message (struct GNUNET_SERVER_Client *client, 641GST_queue_message (struct GNUNET_SERVER_Client *client,
642 struct GNUNET_MessageHeader *msg); 642 struct GNUNET_MessageHeader *msg);
643 643
644 644
645/** 645/**
@@ -669,7 +669,7 @@ GST_hello_cache_lookup (const struct GNUNET_PeerIdentity *id);
669 */ 669 */
670void 670void
671GST_hello_cache_add (const struct GNUNET_PeerIdentity *id, 671GST_hello_cache_add (const struct GNUNET_PeerIdentity *id,
672 const struct GNUNET_MessageHeader *hello); 672 const struct GNUNET_MessageHeader *hello);
673 673
674 674
675/** 675/**
@@ -709,23 +709,22 @@ GST_find_dest_route (uint32_t host_id);
709 */ 709 */
710void 710void
711GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, 711GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
712 const struct GNUNET_MessageHeader *message); 712 const struct GNUNET_MessageHeader *message);
713 713
714 714
715/** 715/**
716 * Adds a host registration's request to a slave's registration queue 716 * Adds a host registration's request to a slave's registration queue
717 * 717 *
718 * @param slave the slave controller at which the given host has to be 718 * @param slave the slave controller at which the given host has to be
719 * registered 719 * registered
720 * @param cb the host registration completion callback 720 * @param cb the host registration completion callback
721 * @param cb_cls the closure for the host registration completion callback 721 * @param cb_cls the closure for the host registration completion callback
722 * @param host the host which has to be registered 722 * @param host the host which has to be registered
723 */ 723 */
724void 724void
725GST_queue_host_registration (struct Slave *slave, 725GST_queue_host_registration (struct Slave *slave,
726 GNUNET_TESTBED_HostRegistrationCompletion cb, 726 GNUNET_TESTBED_HostRegistrationCompletion cb,
727 void *cb_cls, 727 void *cb_cls, struct GNUNET_TESTBED_Host *host);
728 struct GNUNET_TESTBED_Host *host);
729 728
730 729
731/** 730/**
@@ -736,7 +735,7 @@ GST_queue_host_registration (struct Slave *slave,
736 */ 735 */
737void 736void
738GST_forwarded_operation_reply_relay (void *cls, 737GST_forwarded_operation_reply_relay (void *cls,
739 const struct GNUNET_MessageHeader *msg); 738 const struct GNUNET_MessageHeader *msg);
740 739
741 740
742/** 741/**
@@ -747,7 +746,7 @@ GST_forwarded_operation_reply_relay (void *cls,
747 */ 746 */
748void 747void
749GST_forwarded_operation_timeout (void *cls, 748GST_forwarded_operation_timeout (void *cls,
750 const struct GNUNET_SCHEDULER_TaskContext *tc); 749 const struct GNUNET_SCHEDULER_TaskContext *tc);
751 750
752 751
753/** 752/**
@@ -759,7 +758,7 @@ GST_forwarded_operation_timeout (void *cls,
759 */ 758 */
760void 759void
761GST_send_operation_fail_msg (struct GNUNET_SERVER_Client *client, 760GST_send_operation_fail_msg (struct GNUNET_SERVER_Client *client,
762 uint64_t operation_id, const char *emsg); 761 uint64_t operation_id, const char *emsg);
763 762
764 763
765/** 764/**
@@ -771,9 +770,8 @@ GST_send_operation_fail_msg (struct GNUNET_SERVER_Client *client,
771 */ 770 */
772void 771void
773GST_handle_overlay_request_connect (void *cls, 772GST_handle_overlay_request_connect (void *cls,
774 struct GNUNET_SERVER_Client *client, 773 struct GNUNET_SERVER_Client *client,
775 const struct GNUNET_MessageHeader 774 const struct GNUNET_MessageHeader *message);
776 *message);
777 775
778 776
779/** 777/**
diff --git a/src/testbed/gnunet-service-testbed_hc.c b/src/testbed/gnunet-service-testbed_hc.c
index ac430fb1e..4637f59af 100644
--- a/src/testbed/gnunet-service-testbed_hc.c
+++ b/src/testbed/gnunet-service-testbed_hc.c
@@ -45,7 +45,7 @@ struct HelloCacheEntry
45 * The key for this entry 45 * The key for this entry
46 */ 46 */
47 struct GNUNET_HashCode key; 47 struct GNUNET_HashCode key;
48 48
49 /** 49 /**
50 * The HELLO message 50 * The HELLO message
51 */ 51 */
@@ -106,9 +106,8 @@ static void
106GST_hello_cache_remove (struct HelloCacheEntry *entry) 106GST_hello_cache_remove (struct HelloCacheEntry *entry)
107{ 107{
108 GNUNET_CONTAINER_DLL_remove (lru_hcache_head, lru_hcache_tail, entry); 108 GNUNET_CONTAINER_DLL_remove (lru_hcache_head, lru_hcache_tail, entry);
109 GNUNET_assert (GNUNET_YES == 109 GNUNET_assert (GNUNET_YES ==
110 GNUNET_CONTAINER_multihashmap_remove (hello_cache, 110 GNUNET_CONTAINER_multihashmap_remove (hello_cache, &entry->key,
111 &entry->key,
112 entry)); 111 entry));
113 GNUNET_free (entry->hello); 112 GNUNET_free (entry->hello);
114 GNUNET_free (entry); 113 GNUNET_free (entry);
@@ -124,10 +123,10 @@ GST_hello_cache_remove (struct HelloCacheEntry *entry)
124 */ 123 */
125void 124void
126GST_hello_cache_add (const struct GNUNET_PeerIdentity *id, 125GST_hello_cache_add (const struct GNUNET_PeerIdentity *id,
127 const struct GNUNET_MessageHeader *hello) 126 const struct GNUNET_MessageHeader *hello)
128{ 127{
129 struct HelloCacheEntry *entry; 128 struct HelloCacheEntry *entry;
130 129
131 if (NULL == hello_cache) 130 if (NULL == hello_cache)
132 return; 131 return;
133 entry = GNUNET_CONTAINER_multihashmap_get (hello_cache, &id->hashPubKey); 132 entry = GNUNET_CONTAINER_multihashmap_get (hello_cache, &id->hashPubKey);
@@ -140,11 +139,10 @@ GST_hello_cache_add (const struct GNUNET_PeerIdentity *id,
140 GNUNET_assert (NULL != lru_hcache_head); 139 GNUNET_assert (NULL != lru_hcache_head);
141 GST_hello_cache_remove (lru_hcache_head); 140 GST_hello_cache_remove (lru_hcache_head);
142 } 141 }
143 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put 142 GNUNET_assert (GNUNET_OK ==
144 (hello_cache, 143 GNUNET_CONTAINER_multihashmap_put (hello_cache, &entry->key,
145 &entry->key, 144 entry,
146 entry, 145 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
147 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
148 } 146 }
149 else 147 else
150 { 148 {
@@ -180,8 +178,8 @@ void
180GST_cache_clear () 178GST_cache_clear ()
181{ 179{
182 if (NULL != hello_cache) 180 if (NULL != hello_cache)
183 GNUNET_assert 181 GNUNET_assert (GNUNET_CONTAINER_multihashmap_size (hello_cache) <=
184 (GNUNET_CONTAINER_multihashmap_size (hello_cache) <= hello_cache_size); 182 hello_cache_size);
185 while (NULL != lru_hcache_head) 183 while (NULL != lru_hcache_head)
186 GST_hello_cache_remove (lru_hcache_head); 184 GST_hello_cache_remove (lru_hcache_head);
187 if (NULL != hello_cache) 185 if (NULL != hello_cache)
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index f5811194b..000e670b6 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -80,7 +80,7 @@ struct OverlayConnectContext
80 * The prev pointer for maintaining a DLL 80 * The prev pointer for maintaining a DLL
81 */ 81 */
82 struct OverlayConnectContext *prev; 82 struct OverlayConnectContext *prev;
83 83
84 /** 84 /**
85 * The client which has requested for overlay connection 85 * The client which has requested for overlay connection
86 */ 86 */
@@ -202,7 +202,7 @@ struct RequestOverlayConnectContext
202 * The peer handle of peer B 202 * The peer handle of peer B
203 */ 203 */
204 struct Peer *peer; 204 struct Peer *peer;
205 205
206 /** 206 /**
207 * Peer A's HELLO 207 * Peer A's HELLO
208 */ 208 */
@@ -227,12 +227,12 @@ struct RequestOverlayConnectContext
227 * Task for offering HELLO of A to B and doing try_connect 227 * Task for offering HELLO of A to B and doing try_connect
228 */ 228 */
229 GNUNET_SCHEDULER_TaskIdentifier attempt_connect_task_id; 229 GNUNET_SCHEDULER_TaskIdentifier attempt_connect_task_id;
230 230
231 /** 231 /**
232 * Task to timeout RequestOverlayConnect 232 * Task to timeout RequestOverlayConnect
233 */ 233 */
234 GNUNET_SCHEDULER_TaskIdentifier timeout_rocc_task_id; 234 GNUNET_SCHEDULER_TaskIdentifier timeout_rocc_task_id;
235 235
236 /** 236 /**
237 * The id of the operation responsible for creating this context 237 * The id of the operation responsible for creating this context
238 */ 238 */
@@ -289,13 +289,13 @@ forwarded_overlay_connect_timeout (void *cls,
289 struct ForwardedOperationContext *fopc = cls; 289 struct ForwardedOperationContext *fopc = cls;
290 struct RegisteredHostContext *rhc; 290 struct RegisteredHostContext *rhc;
291 struct ForwardedOverlayConnectContext *focc; 291 struct ForwardedOverlayConnectContext *focc;
292 292
293 rhc = fopc->cls; 293 rhc = fopc->cls;
294 focc = rhc->focc_dll_head; 294 focc = rhc->focc_dll_head;
295 GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc); 295 GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc);
296 GST_cleanup_focc (focc); 296 GST_cleanup_focc (focc);
297 LOG_DEBUG ("Overlay linking between peers %u and %u failed\n", 297 LOG_DEBUG ("Overlay linking between peers %u and %u failed\n", focc->peer1,
298 focc->peer1, focc->peer2); 298 focc->peer2);
299 GST_forwarded_operation_timeout (cls, tc); 299 GST_forwarded_operation_timeout (cls, tc);
300 if (NULL != rhc->focc_dll_head) 300 if (NULL != rhc->focc_dll_head)
301 GST_process_next_focc (rhc); 301 GST_process_next_focc (rhc);
@@ -317,7 +317,7 @@ forwarded_overlay_connect_listener (void *cls,
317 struct ForwardedOperationContext *fopc = cls; 317 struct ForwardedOperationContext *fopc = cls;
318 struct RegisteredHostContext *rhc; 318 struct RegisteredHostContext *rhc;
319 struct ForwardedOverlayConnectContext *focc; 319 struct ForwardedOverlayConnectContext *focc;
320 320
321 rhc = fopc->cls; 321 rhc = fopc->cls;
322 GST_forwarded_operation_reply_relay (cls, msg); 322 GST_forwarded_operation_reply_relay (cls, msg);
323 focc = rhc->focc_dll_head; 323 focc = rhc->focc_dll_head;
@@ -344,7 +344,7 @@ GST_process_next_focc (struct RegisteredHostContext *rhc)
344 GNUNET_assert (RHC_OL_CONNECT == rhc->state); 344 GNUNET_assert (RHC_OL_CONNECT == rhc->state);
345 fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); 345 fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
346 GNUNET_SERVER_client_keep (rhc->client); 346 GNUNET_SERVER_client_keep (rhc->client);
347 fopc->client = rhc->client; 347 fopc->client = rhc->client;
348 fopc->operation_id = focc->operation_id; 348 fopc->operation_id = focc->operation_id;
349 fopc->cls = rhc; 349 fopc->cls = rhc;
350 fopc->type = OP_OVERLAY_CONNECT; 350 fopc->type = OP_OVERLAY_CONNECT;
@@ -405,13 +405,13 @@ cleanup_occ (struct OverlayConnectContext *occ)
405 GNUNET_TRANSPORT_disconnect (occ->tcc.th); 405 GNUNET_TRANSPORT_disconnect (occ->tcc.th);
406 GST_peer_list[occ->other_peer_id]->reference_cnt--; 406 GST_peer_list[occ->other_peer_id]->reference_cnt--;
407 } 407 }
408 if ((GNUNET_YES == occ->peer->destroy_flag) 408 if ((GNUNET_YES == occ->peer->destroy_flag) &&
409 && (0 == occ->peer->reference_cnt)) 409 (0 == occ->peer->reference_cnt))
410 GST_destroy_peer (occ->peer); 410 GST_destroy_peer (occ->peer);
411 if ((NULL == occ->peer2_controller) 411 if ((NULL == occ->peer2_controller) &&
412 && (GNUNET_YES == GST_peer_list[occ->other_peer_id]->destroy_flag) 412 (GNUNET_YES == GST_peer_list[occ->other_peer_id]->destroy_flag) &&
413 && (0 == GST_peer_list[occ->other_peer_id]->reference_cnt)) 413 (0 == GST_peer_list[occ->other_peer_id]->reference_cnt))
414 GST_destroy_peer (GST_peer_list[occ->other_peer_id]); 414 GST_destroy_peer (GST_peer_list[occ->other_peer_id]);
415 GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ); 415 GNUNET_CONTAINER_DLL_remove (occq_head, occq_tail, occ);
416 GNUNET_free (occ); 416 GNUNET_free (occ);
417} 417}
@@ -427,7 +427,7 @@ static void
427do_cleanup_occ (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 427do_cleanup_occ (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
428{ 428{
429 struct OverlayConnectContext *occ = cls; 429 struct OverlayConnectContext *occ = cls;
430 430
431 occ->cleanup_task = GNUNET_SCHEDULER_NO_TASK; 431 occ->cleanup_task = GNUNET_SCHEDULER_NO_TASK;
432 cleanup_occ (occ); 432 cleanup_occ (occ);
433} 433}
@@ -447,8 +447,8 @@ timeout_overlay_connect (void *cls,
447 447
448 occ->timeout_task = GNUNET_SCHEDULER_NO_TASK; 448 occ->timeout_task = GNUNET_SCHEDULER_NO_TASK;
449 LOG (GNUNET_ERROR_TYPE_WARNING, 449 LOG (GNUNET_ERROR_TYPE_WARNING,
450 "0x%llx: Timeout while connecting peers %u and %u\n", 450 "0x%llx: Timeout while connecting peers %u and %u\n", occ->op_id,
451 occ->op_id, occ->peer_id, occ->other_peer_id); 451 occ->peer_id, occ->other_peer_id);
452 GST_send_operation_fail_msg (occ->client, occ->op_id, occ->emsg); 452 GST_send_operation_fail_msg (occ->client, occ->op_id, occ->emsg);
453 cleanup_occ (occ); 453 cleanup_occ (occ);
454} 454}
@@ -485,7 +485,7 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer,
485 sizeof (struct GNUNET_PeerIdentity))) 485 sizeof (struct GNUNET_PeerIdentity)))
486 { 486 {
487 /* LOG_DEBUG ("Unexpected peer %4s connected when expecting peer %4s\n", */ 487 /* LOG_DEBUG ("Unexpected peer %4s connected when expecting peer %4s\n", */
488 /* new_peer_str, other_peer_str); */ 488 /* new_peer_str, other_peer_str); */
489 GNUNET_free (new_peer_str); 489 GNUNET_free (new_peer_str);
490 GNUNET_free (other_peer_str); 490 GNUNET_free (other_peer_str);
491 return; 491 return;
@@ -542,17 +542,18 @@ try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
542 * @param result GNUNET_OK if message was transmitted to transport service 542 * @param result GNUNET_OK if message was transmitted to transport service
543 * GNUNET_SYSERR if message was not transmitted to transport service 543 * GNUNET_SYSERR if message was not transmitted to transport service
544 */ 544 */
545static void 545static void
546try_connect_cb (void *cls, const int result) 546try_connect_cb (void *cls, const int result)
547{ 547{
548 struct TryConnectContext *tcc = cls; 548 struct TryConnectContext *tcc = cls;
549 549
550 tcc->tch = NULL; 550 tcc->tch = NULL;
551 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tcc->task); 551 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tcc->task);
552 tcc->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 552 tcc->task =
553 (GNUNET_TIME_UNIT_MILLISECONDS, 553 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
554 500 + pow(2, ++tcc->retries)), 554 (GNUNET_TIME_UNIT_MILLISECONDS,
555 &try_connect_task, tcc); 555 500 + pow (2, ++tcc->retries)),
556 &try_connect_task, tcc);
556} 557}
557 558
558 559
@@ -569,13 +570,14 @@ try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
569 570
570 tcc->task = GNUNET_SCHEDULER_NO_TASK; 571 tcc->task = GNUNET_SCHEDULER_NO_TASK;
571 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 572 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
572 return; 573 return;
573 GNUNET_assert (NULL == tcc->tch); 574 GNUNET_assert (NULL == tcc->tch);
574 GNUNET_assert (NULL != tcc->pid); 575 GNUNET_assert (NULL != tcc->pid);
575 GNUNET_assert (NULL != tcc->th); 576 GNUNET_assert (NULL != tcc->th);
576 LOG_DEBUG ("0x%llx: Trail %u to connect to peer %s\n", tcc->op_id, tcc->retries, 577 LOG_DEBUG ("0x%llx: Trail %u to connect to peer %s\n", tcc->op_id,
577 GNUNET_i2s(tcc->pid)); 578 tcc->retries, GNUNET_i2s (tcc->pid));
578 tcc->tch = GNUNET_TRANSPORT_try_connect (tcc->th, tcc->pid, &try_connect_cb, tcc); 579 tcc->tch =
580 GNUNET_TRANSPORT_try_connect (tcc->th, tcc->pid, &try_connect_cb, tcc);
579} 581}
580 582
581 583
@@ -617,9 +619,8 @@ occ_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
617 if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason) 619 if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason)
618 return; 620 return;
619 GNUNET_free_non_null (occ->emsg); 621 GNUNET_free_non_null (occ->emsg);
620 GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while try connect", 622 GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while try connect", occ->op_id);
621 occ->op_id); 623 occ->tcc.pid = &occ->peer_identity;
622 occ->tcc.pid = &occ->peer_identity;
623 occ->tcc.op_id = occ->op_id; 624 occ->tcc.op_id = occ->op_id;
624 occ->tcc.task = GNUNET_SCHEDULER_add_now (&try_connect_task, &occ->tcc); 625 occ->tcc.task = GNUNET_SCHEDULER_add_now (&try_connect_task, &occ->tcc);
625} 626}
@@ -650,11 +651,9 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
650 uint16_t hello_size; 651 uint16_t hello_size;
651 652
652 LOG_DEBUG ("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote " 653 LOG_DEBUG ("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote "
653 "Overlay Request\n", 654 "Overlay Request\n", occ->op_id,
654 occ->op_id, 655 GNUNET_i2s (&occ->peer_identity), ntohs (occ->hello->size),
655 GNUNET_i2s (&occ->peer_identity), 656 other_peer_str);
656 ntohs (occ->hello->size),
657 other_peer_str);
658 hello_size = ntohs (occ->hello->size); 657 hello_size = ntohs (occ->hello->size);
659 msize = sizeof (struct GNUNET_TESTBED_RequestConnectMessage) + hello_size; 658 msize = sizeof (struct GNUNET_TESTBED_RequestConnectMessage) + hello_size;
660 msg = GNUNET_malloc (msize); 659 msg = GNUNET_malloc (msize);
@@ -663,31 +662,30 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
663 msg->peer = htonl (occ->other_peer_id); 662 msg->peer = htonl (occ->other_peer_id);
664 msg->operation_id = GNUNET_htonll (occ->op_id); 663 msg->operation_id = GNUNET_htonll (occ->op_id);
665 (void) memcpy (&msg->peer_identity, &occ->peer_identity, 664 (void) memcpy (&msg->peer_identity, &occ->peer_identity,
666 sizeof (struct GNUNET_PeerIdentity)); 665 sizeof (struct GNUNET_PeerIdentity));
667 memcpy (msg->hello, occ->hello, hello_size); 666 memcpy (msg->hello, occ->hello, hello_size);
668 GNUNET_TESTBED_queue_message_ (occ->peer2_controller, &msg->header); 667 GNUNET_TESTBED_queue_message_ (occ->peer2_controller, &msg->header);
669 } 668 }
670 else 669 else
671 { 670 {
672 LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n", 671 LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n", occ->op_id,
673 occ->op_id, 672 GNUNET_i2s (&occ->peer_identity), other_peer_str);
674 GNUNET_i2s (&occ->peer_identity), other_peer_str); 673 occ->ohh =
675 occ->ohh = GNUNET_TRANSPORT_offer_hello (occ->tcc.th, 674 GNUNET_TRANSPORT_offer_hello (occ->tcc.th, occ->hello,
676 occ->hello, 675 occ_hello_sent_cb, occ);
677 occ_hello_sent_cb,
678 occ);
679 if (NULL == occ->ohh) 676 if (NULL == occ->ohh)
680 { 677 {
681 GNUNET_break (0); 678 GNUNET_break (0);
682 occ->send_hello_task = 679 occ->send_hello_task =
683 GNUNET_SCHEDULER_add_delayed 680 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
684 (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 681 (GNUNET_TIME_UNIT_MILLISECONDS,
685 100 + GNUNET_CRYPTO_random_u32 682 100 +
686 (GNUNET_CRYPTO_QUALITY_WEAK, 500)), 683 GNUNET_CRYPTO_random_u32
687 &send_hello, occ); 684 (GNUNET_CRYPTO_QUALITY_WEAK, 500)),
685 &send_hello, occ);
688 } 686 }
689 } 687 }
690 GNUNET_free (other_peer_str); 688 GNUNET_free (other_peer_str);
691} 689}
692 690
693 691
@@ -708,15 +706,16 @@ p2_transport_connect (struct OverlayConnectContext *occ)
708 { 706 {
709 GST_peer_list[occ->other_peer_id]->reference_cnt++; 707 GST_peer_list[occ->other_peer_id]->reference_cnt++;
710 occ->tcc.th = 708 occ->tcc.th =
711 GNUNET_TRANSPORT_connect (GST_peer_list[occ->other_peer_id]->details.local.cfg, 709 GNUNET_TRANSPORT_connect (GST_peer_list[occ->other_peer_id]->
712 &occ->other_peer_identity, NULL, NULL, NULL, 710 details.local.cfg, &occ->other_peer_identity,
713 NULL); 711 NULL, NULL, NULL, NULL);
714 if (NULL == occ->tcc.th) 712 if (NULL == occ->tcc.th)
715 { 713 {
716 GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s", 714 GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s",
717 occ->op_id, GNUNET_i2s (&occ->other_peer_identity)); 715 occ->op_id, GNUNET_i2s (&occ->other_peer_identity));
718 GNUNET_SCHEDULER_cancel (occ->timeout_task); 716 GNUNET_SCHEDULER_cancel (occ->timeout_task);
719 occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); 717 occ->timeout_task =
718 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
720 return; 719 return;
721 } 720 }
722 } 721 }
@@ -767,12 +766,12 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
767 &empty); 766 &empty);
768 if (GNUNET_YES == empty) 767 if (GNUNET_YES == empty)
769 { 768 {
770 LOG_DEBUG ("0x%llx: HELLO of %s is empty\n", 769 LOG_DEBUG ("0x%llx: HELLO of %s is empty\n", occ->op_id,
771 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 770 GNUNET_i2s (&occ->peer_identity));
772 return; 771 return;
773 } 772 }
774 LOG_DEBUG ("0x%llx: Received HELLO of %s\n", 773 LOG_DEBUG ("0x%llx: Received HELLO of %s\n", occ->op_id,
775 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 774 GNUNET_i2s (&occ->peer_identity));
776 occ->hello = GNUNET_malloc (msize); 775 occ->hello = GNUNET_malloc (msize);
777 GST_hello_cache_add (&occ->peer_identity, hello); 776 GST_hello_cache_add (&occ->peer_identity, hello);
778 memcpy (occ->hello, hello, msize); 777 memcpy (occ->hello, hello, msize);
@@ -816,13 +815,13 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server,
816 occ->emsg = NULL; 815 occ->emsg = NULL;
817 memcpy (&occ->peer_identity, my_identity, 816 memcpy (&occ->peer_identity, my_identity,
818 sizeof (struct GNUNET_PeerIdentity)); 817 sizeof (struct GNUNET_PeerIdentity));
819 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", 818 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id,
820 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 819 GNUNET_i2s (&occ->peer_identity));
821 /* Lookup for HELLO in hello cache */ 820 /* Lookup for HELLO in hello cache */
822 if (NULL != (hello = GST_hello_cache_lookup (&occ->peer_identity))) 821 if (NULL != (hello = GST_hello_cache_lookup (&occ->peer_identity)))
823 { 822 {
824 LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", 823 LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n", occ->op_id,
825 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 824 GNUNET_i2s (&occ->peer_identity));
826 occ->hello = GNUNET_copy_message (hello); 825 occ->hello = GNUNET_copy_message (hello);
827 p2_transport_connect (occ); 826 p2_transport_connect (occ);
828 return; 827 return;
@@ -837,14 +836,14 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server,
837 "0x%llx: Cannot connect to TRANSPORT of peer %4s", 836 "0x%llx: Cannot connect to TRANSPORT of peer %4s",
838 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 837 occ->op_id, GNUNET_i2s (&occ->peer_identity));
839 goto error_return; 838 goto error_return;
840 } 839 }
841 GNUNET_asprintf (&occ->emsg, 840 GNUNET_asprintf (&occ->emsg,
842 "0x%llx: Timeout while acquiring HELLO of peer %4s", 841 "0x%llx: Timeout while acquiring HELLO of peer %4s",
843 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 842 occ->op_id, GNUNET_i2s (&occ->peer_identity));
844 occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th, &hello_update_cb, occ); 843 occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th, &hello_update_cb, occ);
845 return; 844 return;
846 845
847 error_return: 846error_return:
848 GNUNET_SCHEDULER_cancel (occ->timeout_task); 847 GNUNET_SCHEDULER_cancel (occ->timeout_task);
849 occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); 848 occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
850 return; 849 return;
@@ -864,6 +863,7 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
864{ 863{
865 struct OverlayConnectContext *occ = cls; 864 struct OverlayConnectContext *occ = cls;
866 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *cmsg; 865 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *cmsg;
866
867 const struct GNUNET_CORE_MessageHandler no_handlers[] = { 867 const struct GNUNET_CORE_MessageHandler no_handlers[] = {
868 {NULL, 0, 0} 868 {NULL, 0, 0}
869 }; 869 };
@@ -871,10 +871,10 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
871 occ->opc = NULL; 871 occ->opc = NULL;
872 if (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG != ntohs (msg->type)) 872 if (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG != ntohs (msg->type))
873 goto error_return; 873 goto error_return;
874 cmsg = (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) 874 cmsg =
875 msg; 875 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg;
876 memcpy (&occ->other_peer_identity, &cmsg->peer_identity, 876 memcpy (&occ->other_peer_identity, &cmsg->peer_identity,
877 sizeof (struct GNUNET_PeerIdentity)); 877 sizeof (struct GNUNET_PeerIdentity));
878 GNUNET_free_non_null (occ->emsg); 878 GNUNET_free_non_null (occ->emsg);
879 GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while connecting to CORE", 879 GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while connecting to CORE",
880 occ->op_id); 880 occ->op_id);
@@ -887,10 +887,9 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
887 goto error_return; 887 goto error_return;
888 return; 888 return;
889 889
890 error_return: 890error_return:
891 GNUNET_SCHEDULER_cancel (occ->timeout_task); 891 GNUNET_SCHEDULER_cancel (occ->timeout_task);
892 occ->timeout_task = 892 occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
893 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
894} 893}
895 894
896 895
@@ -900,7 +899,7 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
900 * @param cls the RegisteredHostContext 899 * @param cls the RegisteredHostContext
901 * @param emsg the error message; NULL if host registration is successful 900 * @param emsg the error message; NULL if host registration is successful
902 */ 901 */
903static void 902static void
904registeredhost_registration_completion (void *cls, const char *emsg) 903registeredhost_registration_completion (void *cls, const char *emsg)
905{ 904{
906 struct RegisteredHostContext *rhc = cls; 905 struct RegisteredHostContext *rhc = cls;
@@ -912,25 +911,23 @@ registeredhost_registration_completion (void *cls, const char *emsg)
912 peer2_host_id = GNUNET_TESTBED_host_get_id_ (rhc->reg_host); 911 peer2_host_id = GNUNET_TESTBED_host_get_id_ (rhc->reg_host);
913 GNUNET_assert (RHC_INIT == rhc->state); 912 GNUNET_assert (RHC_INIT == rhc->state);
914 GNUNET_assert (NULL == rhc->sub_op); 913 GNUNET_assert (NULL == rhc->sub_op);
915 if ((NULL == rhc->gateway2) 914 if ((NULL == rhc->gateway2) || ((peer2_host_id < GST_slave_list_size) /* Check if we have the needed config */
916 || ((peer2_host_id < GST_slave_list_size) /* Check if we have the needed config */ 915 && (NULL != GST_slave_list[peer2_host_id])))
917 && (NULL != GST_slave_list[peer2_host_id])))
918 { 916 {
919 rhc->state = RHC_LINK; 917 rhc->state = RHC_LINK;
920 cfg = (NULL == rhc->gateway2) ? our_config : GST_slave_list[peer2_host_id]->cfg; 918 cfg =
919 (NULL ==
920 rhc->gateway2) ? our_config : GST_slave_list[peer2_host_id]->cfg;
921 rhc->sub_op = 921 rhc->sub_op =
922 GNUNET_TESTBED_controller_link (rhc, 922 GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller,
923 rhc->gateway->controller, 923 rhc->reg_host, rhc->host, cfg,
924 rhc->reg_host,
925 rhc->host,
926 cfg,
927 GNUNET_NO); 924 GNUNET_NO);
928 return; 925 return;
929 } 926 }
930 rhc->state = RHC_GET_CFG; 927 rhc->state = RHC_GET_CFG;
931 rhc->sub_op = GNUNET_TESTBED_get_slave_config (rhc, 928 rhc->sub_op =
932 rhc->gateway2->controller, 929 GNUNET_TESTBED_get_slave_config (rhc, rhc->gateway2->controller,
933 rhc->reg_host); 930 rhc->reg_host);
934} 931}
935 932
936 933
@@ -944,9 +941,8 @@ registeredhost_registration_completion (void *cls, const char *emsg)
944 * iterate, 941 * iterate,
945 * GNUNET_NO if not. 942 * GNUNET_NO if not.
946 */ 943 */
947static int 944static int
948reghost_match_iterator (void *cls, 945reghost_match_iterator (void *cls, const struct GNUNET_HashCode *key,
949 const struct GNUNET_HashCode * key,
950 void *value) 946 void *value)
951{ 947{
952 struct RegisteredHostContext **rh = cls; 948 struct RegisteredHostContext **rh = cls;
@@ -992,9 +988,10 @@ hash_hosts (struct GNUNET_TESTBED_Host *reg_host,
992 */ 988 */
993void 989void
994GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, 990GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
995 const struct GNUNET_MessageHeader *message) 991 const struct GNUNET_MessageHeader *message)
996{ 992{
997 const struct GNUNET_TESTBED_OverlayConnectMessage *msg; 993 const struct GNUNET_TESTBED_OverlayConnectMessage *msg;
994
998 const struct GNUNET_CORE_MessageHandler no_handlers[] = { 995 const struct GNUNET_CORE_MessageHandler no_handlers[] = {
999 {NULL, 0, 0} 996 {NULL, 0, 0}
1000 }; 997 };
@@ -1003,11 +1000,11 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1003 struct GNUNET_TESTBED_Controller *peer2_controller; 1000 struct GNUNET_TESTBED_Controller *peer2_controller;
1004 uint64_t operation_id; 1001 uint64_t operation_id;
1005 uint32_t p1; 1002 uint32_t p1;
1006 uint32_t p2; 1003 uint32_t p2;
1007 uint32_t peer2_host_id; 1004 uint32_t peer2_host_id;
1008 1005
1009 if (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage) 1006 if (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage) !=
1010 != ntohs (message->size)) 1007 ntohs (message->size))
1011 { 1008 {
1012 GNUNET_break (0); 1009 GNUNET_break (0);
1013 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1010 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -1024,9 +1021,10 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1024 } 1021 }
1025 peer = GST_peer_list[p1]; 1022 peer = GST_peer_list[p1];
1026 peer2_host_id = ntohl (msg->peer2_host_id); 1023 peer2_host_id = ntohl (msg->peer2_host_id);
1027 operation_id = GNUNET_ntohll (msg->operation_id); 1024 operation_id = GNUNET_ntohll (msg->operation_id);
1028 LOG_DEBUG ("Received overlay connect for peers %u and %u with op id: 0x%llx\n", 1025 LOG_DEBUG
1029 p1, p2, operation_id); 1026 ("Received overlay connect for peers %u and %u with op id: 0x%llx\n", p1,
1027 p2, operation_id);
1030 if (GNUNET_YES == peer->is_remote) 1028 if (GNUNET_YES == peer->is_remote)
1031 { 1029 {
1032 struct ForwardedOperationContext *fopc; 1030 struct ForwardedOperationContext *fopc;
@@ -1037,20 +1035,20 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1037 route_to_peer2_host = NULL; 1035 route_to_peer2_host = NULL;
1038 route_to_peer1_host = NULL; 1036 route_to_peer1_host = NULL;
1039 route_to_peer2_host = GST_find_dest_route (peer2_host_id); 1037 route_to_peer2_host = GST_find_dest_route (peer2_host_id);
1040 if ((NULL != route_to_peer2_host) 1038 if ((NULL != route_to_peer2_host) ||
1041 || (peer2_host_id == GST_context->host_id)) 1039 (peer2_host_id == GST_context->host_id))
1042 { 1040 {
1043 /* Peer 2 either below us OR with us */ 1041 /* Peer 2 either below us OR with us */
1044 route_to_peer1_host = 1042 route_to_peer1_host =
1045 GST_find_dest_route 1043 GST_find_dest_route (GST_peer_list[p1]->details.
1046 (GST_peer_list[p1]->details.remote.remote_host_id); 1044 remote.remote_host_id);
1047 /* Because we get this message only if we know where peer 1 is */ 1045 /* Because we get this message only if we know where peer 1 is */
1048 GNUNET_assert (NULL != route_to_peer1_host); 1046 GNUNET_assert (NULL != route_to_peer1_host);
1049 if ((peer2_host_id == GST_context->host_id) 1047 if ((peer2_host_id == GST_context->host_id) ||
1050 || (route_to_peer2_host->dest != route_to_peer1_host->dest)) 1048 (route_to_peer2_host->dest != route_to_peer1_host->dest))
1051 { 1049 {
1052 /* Peer2 is either with us OR peer1 and peer2 can be reached through 1050 /* Peer2 is either with us OR peer1 and peer2 can be reached through
1053 different gateways */ 1051 * different gateways */
1054 struct GNUNET_HashCode hash; 1052 struct GNUNET_HashCode hash;
1055 struct RegisteredHostContext *rhc; 1053 struct RegisteredHostContext *rhc;
1056 int skip_focc; 1054 int skip_focc;
@@ -1064,36 +1062,42 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1064 GNUNET_assert (NULL != rhc->reg_host); 1062 GNUNET_assert (NULL != rhc->reg_host);
1065 GNUNET_assert (NULL != rhc->host); 1063 GNUNET_assert (NULL != rhc->host);
1066 rhc->gateway = peer->details.remote.slave; 1064 rhc->gateway = peer->details.remote.slave;
1067 rhc->gateway2 = (NULL == route_to_peer2_host) ? NULL : 1065 rhc->gateway2 =
1066 (NULL ==
1067 route_to_peer2_host) ? NULL :
1068 GST_slave_list[route_to_peer2_host->dest]; 1068 GST_slave_list[route_to_peer2_host->dest];
1069 rhc->state = RHC_INIT; 1069 rhc->state = RHC_INIT;
1070 GNUNET_SERVER_client_keep (client); 1070 GNUNET_SERVER_client_keep (client);
1071 rhc->client = client; 1071 rhc->client = client;
1072 hash = hash_hosts (rhc->reg_host, rhc->host); 1072 hash = hash_hosts (rhc->reg_host, rhc->host);
1073 skip_focc = GNUNET_NO; 1073 skip_focc = GNUNET_NO;
1074 if ((GNUNET_NO == 1074 if ((GNUNET_NO ==
1075 GNUNET_CONTAINER_multihashmap_contains 1075 GNUNET_CONTAINER_multihashmap_contains (peer->details.
1076 (peer->details.remote.slave->reghost_map, &hash)) 1076 remote.slave->reghost_map,
1077 || (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_get_multiple 1077 &hash)) ||
1078 (peer->details.remote.slave->reghost_map, &hash, 1078 (GNUNET_SYSERR !=
1079 reghost_match_iterator, &rhc))) 1079 GNUNET_CONTAINER_multihashmap_get_multiple (peer->details.remote.
1080 slave->reghost_map,
1081 &hash,
1082 reghost_match_iterator,
1083 &rhc)))
1080 { 1084 {
1081 /* create and add a new registerd host context */ 1085 /* create and add a new registerd host context */
1082 /* add the focc to its queue */ 1086 /* add the focc to its queue */
1083 GNUNET_CONTAINER_multihashmap_put 1087 GNUNET_CONTAINER_multihashmap_put (peer->details.remote.
1084 (peer->details.remote.slave->reghost_map, 1088 slave->reghost_map, &hash, rhc,
1085 &hash, rhc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1089 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
1086 GNUNET_assert (NULL != GST_host_list[peer2_host_id]); 1090 GNUNET_assert (NULL != GST_host_list[peer2_host_id]);
1087 GST_queue_host_registration (peer->details.remote.slave, 1091 GST_queue_host_registration (peer->details.remote.slave,
1088 registeredhost_registration_completion, 1092 registeredhost_registration_completion,
1089 rhc, 1093 rhc, GST_host_list[peer2_host_id]);
1090 GST_host_list[peer2_host_id]);
1091 } 1094 }
1092 else { 1095 else
1096 {
1093 /* rhc is now set to the existing one from the hash map by 1097 /* rhc is now set to the existing one from the hash map by
1094 reghost_match_iterator() */ 1098 * reghost_match_iterator() */
1095 /* if queue is empty then ignore creating focc and proceed with 1099 /* if queue is empty then ignore creating focc and proceed with
1096 normal forwarding */ 1100 * normal forwarding */
1097 if (RHC_OL_CONNECT == rhc->state) 1101 if (RHC_OL_CONNECT == rhc->state)
1098 skip_focc = GNUNET_YES; 1102 skip_focc = GNUNET_YES;
1099 } 1103 }
@@ -1108,8 +1112,7 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1108 focc->orig_msg = GNUNET_copy_message (message); 1112 focc->orig_msg = GNUNET_copy_message (message);
1109 focc->operation_id = operation_id; 1113 focc->operation_id = operation_id;
1110 GNUNET_CONTAINER_DLL_insert_tail (rhc->focc_dll_head, 1114 GNUNET_CONTAINER_DLL_insert_tail (rhc->focc_dll_head,
1111 rhc->focc_dll_tail, 1115 rhc->focc_dll_tail, focc);
1112 focc);
1113 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1116 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1114 return; 1117 return;
1115 } 1118 }
@@ -1120,14 +1123,15 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1120 fopc->client = client; 1123 fopc->client = client;
1121 fopc->operation_id = operation_id; 1124 fopc->operation_id = operation_id;
1122 fopc->type = OP_OVERLAY_CONNECT; 1125 fopc->type = OP_OVERLAY_CONNECT;
1123 fopc->opc = 1126 fopc->opc =
1124 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.slave->controller, 1127 GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.
1125 operation_id, message, 1128 slave->controller, operation_id,
1126 &GST_forwarded_operation_reply_relay, 1129 message,
1127 fopc); 1130 &GST_forwarded_operation_reply_relay,
1131 fopc);
1128 fopc->timeout_task = 1132 fopc->timeout_task =
1129 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &GST_forwarded_operation_timeout, 1133 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &GST_forwarded_operation_timeout,
1130 fopc); 1134 fopc);
1131 GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc); 1135 GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc);
1132 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1136 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1133 return; 1137 return;
@@ -1135,20 +1139,20 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1135 1139
1136 peer2_controller = NULL; 1140 peer2_controller = NULL;
1137 if ((p2 >= GST_peer_list_size) || (NULL == GST_peer_list[p2])) 1141 if ((p2 >= GST_peer_list_size) || (NULL == GST_peer_list[p2]))
1138 { 1142 {
1139 if ((peer2_host_id >= GST_slave_list_size) 1143 if ((peer2_host_id >= GST_slave_list_size) ||
1140 || (NULL ==GST_slave_list[peer2_host_id])) 1144 (NULL == GST_slave_list[peer2_host_id]))
1141 { 1145 {
1142 LOG (GNUNET_ERROR_TYPE_WARNING, 1146 LOG (GNUNET_ERROR_TYPE_WARNING,
1143 "0x%llx: Configuration of peer2's controller missing for connecting peers" 1147 "0x%llx: Configuration of peer2's controller missing for connecting peers"
1144 "%u and %u\n", operation_id, p1, p2); 1148 "%u and %u\n", operation_id, p1, p2);
1145 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1149 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1146 return; 1150 return;
1147 } 1151 }
1148 peer2_controller = GST_slave_list[peer2_host_id]->controller; 1152 peer2_controller = GST_slave_list[peer2_host_id]->controller;
1149 if (NULL == peer2_controller) 1153 if (NULL == peer2_controller)
1150 { 1154 {
1151 GNUNET_break (0); /* What's going on? */ 1155 GNUNET_break (0); /* What's going on? */
1152 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1156 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1153 return; 1157 return;
1154 } 1158 }
@@ -1172,27 +1176,27 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1172 { 1176 {
1173 struct GNUNET_TESTBED_PeerGetConfigurationMessage cmsg; 1177 struct GNUNET_TESTBED_PeerGetConfigurationMessage cmsg;
1174 1178
1175 cmsg.header.size = 1179 cmsg.header.size =
1176 htons (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage)); 1180 htons (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage));
1177 cmsg.header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG); 1181 cmsg.header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG);
1178 cmsg.peer_id = msg->peer2; 1182 cmsg.peer_id = msg->peer2;
1179 cmsg.operation_id = msg->operation_id; 1183 cmsg.operation_id = msg->operation_id;
1180 occ->opc = 1184 occ->opc =
1181 GNUNET_TESTBED_forward_operation_msg_ (occ->peer2_controller, 1185 GNUNET_TESTBED_forward_operation_msg_ (occ->peer2_controller,
1182 occ->op_id, &cmsg.header, 1186 occ->op_id, &cmsg.header,
1183 &overlay_connect_get_config, 1187 &overlay_connect_get_config,
1184 occ); 1188 occ);
1185 GNUNET_asprintf (&occ->emsg, 1189 GNUNET_asprintf (&occ->emsg,
1186 "0x%llx: Timeout while getting peer identity of peer " 1190 "0x%llx: Timeout while getting peer identity of peer "
1187 "with id: %u", occ->op_id, occ->other_peer_id); 1191 "with id: %u", occ->op_id, occ->other_peer_id);
1188 occ->timeout_task = 1192 occ->timeout_task =
1189 GNUNET_SCHEDULER_add_delayed (TIMEOUT, 1193 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_overlay_connect, occ);
1190 &timeout_overlay_connect, occ);
1191 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1194 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1192 return; 1195 return;
1193 } 1196 }
1194 GNUNET_TESTING_peer_get_identity (GST_peer_list[occ->other_peer_id]->details.local.peer, 1197 GNUNET_TESTING_peer_get_identity (GST_peer_list[occ->other_peer_id]->
1195 &occ->other_peer_identity); 1198 details.local.peer,
1199 &occ->other_peer_identity);
1196 /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ 1200 /* Connect to the core of 1st peer and wait for the 2nd peer to connect */
1197 occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); 1201 occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE");
1198 GNUNET_asprintf (&occ->emsg, 1202 GNUNET_asprintf (&occ->emsg,
@@ -1204,12 +1208,11 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1204 &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL, 1208 &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL,
1205 GNUNET_NO, no_handlers); 1209 GNUNET_NO, no_handlers);
1206 if (NULL == occ->ch) 1210 if (NULL == occ->ch)
1207 occ->timeout_task = 1211 occ->timeout_task =
1208 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); 1212 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
1209 else 1213 else
1210 occ->timeout_task = 1214 occ->timeout_task =
1211 GNUNET_SCHEDULER_add_delayed (TIMEOUT, 1215 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_overlay_connect, occ);
1212 &timeout_overlay_connect, occ);
1213 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1216 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1214} 1217}
1215 1218
@@ -1236,8 +1239,8 @@ cleanup_rocc (struct RequestOverlayConnectContext *rocc)
1236 GNUNET_SCHEDULER_cancel (rocc->tcc.task); 1239 GNUNET_SCHEDULER_cancel (rocc->tcc.task);
1237 GNUNET_TRANSPORT_disconnect (rocc->tcc.th); 1240 GNUNET_TRANSPORT_disconnect (rocc->tcc.th);
1238 rocc->peer->reference_cnt--; 1241 rocc->peer->reference_cnt--;
1239 if ((GNUNET_YES == rocc->peer->destroy_flag) 1242 if ((GNUNET_YES == rocc->peer->destroy_flag) &&
1240 && (0 == rocc->peer->reference_cnt)) 1243 (0 == rocc->peer->reference_cnt))
1241 GST_destroy_peer (rocc->peer); 1244 GST_destroy_peer (rocc->peer);
1242 GNUNET_free_non_null (rocc->hello); 1245 GNUNET_free_non_null (rocc->hello);
1243 GNUNET_CONTAINER_DLL_remove (roccq_head, roccq_tail, rocc); 1246 GNUNET_CONTAINER_DLL_remove (roccq_head, roccq_tail, rocc);
@@ -1255,7 +1258,7 @@ static void
1255timeout_rocc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1258timeout_rocc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1256{ 1259{
1257 struct RequestOverlayConnectContext *rocc = cls; 1260 struct RequestOverlayConnectContext *rocc = cls;
1258 1261
1259 GNUNET_assert (rocc->timeout_rocc_task_id != GNUNET_SCHEDULER_NO_TASK); 1262 GNUNET_assert (rocc->timeout_rocc_task_id != GNUNET_SCHEDULER_NO_TASK);
1260 rocc->timeout_rocc_task_id = GNUNET_SCHEDULER_NO_TASK; 1263 rocc->timeout_rocc_task_id = GNUNET_SCHEDULER_NO_TASK;
1261 LOG_DEBUG ("0x%llx: rocc timed out\n", rocc->op_id); 1264 LOG_DEBUG ("0x%llx: rocc timed out\n", rocc->op_id);
@@ -1272,9 +1275,9 @@ timeout_rocc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1272 * @param ats performance data 1275 * @param ats performance data
1273 * @param ats_count number of entries in ats (excluding 0-termination) 1276 * @param ats_count number of entries in ats (excluding 0-termination)
1274 */ 1277 */
1275static void 1278static void
1276transport_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, 1279transport_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer,
1277 const struct GNUNET_ATS_Information * ats, 1280 const struct GNUNET_ATS_Information *ats,
1278 uint32_t ats_count) 1281 uint32_t ats_count)
1279{ 1282{
1280 struct RequestOverlayConnectContext *rocc = cls; 1283 struct RequestOverlayConnectContext *rocc = cls;
@@ -1311,7 +1314,7 @@ static void
1311rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1314rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1312{ 1315{
1313 struct RequestOverlayConnectContext *rocc = cls; 1316 struct RequestOverlayConnectContext *rocc = cls;
1314 1317
1315 rocc->ohh = NULL; 1318 rocc->ohh = NULL;
1316 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rocc->attempt_connect_task_id); 1319 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rocc->attempt_connect_task_id);
1317 LOG_DEBUG ("0x%llx: HELLO of peer %4s sent to local peer with id: %u\n", 1320 LOG_DEBUG ("0x%llx: HELLO of peer %4s sent to local peer with id: %u\n",
@@ -1320,8 +1323,7 @@ rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1320 { 1323 {
1321 GNUNET_break (0); 1324 GNUNET_break (0);
1322 rocc->attempt_connect_task_id = 1325 rocc->attempt_connect_task_id =
1323 GNUNET_SCHEDULER_add_now (&attempt_connect_task, 1326 GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc);
1324 rocc);
1325 return; 1327 return;
1326 } 1328 }
1327 if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason) 1329 if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason)
@@ -1346,15 +1348,17 @@ attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1346 rocc->attempt_connect_task_id = GNUNET_SCHEDULER_NO_TASK; 1348 rocc->attempt_connect_task_id = GNUNET_SCHEDULER_NO_TASK;
1347 LOG_DEBUG ("0x%llx: Offering HELLO of peer %4s to local peer with id: %u\n", 1349 LOG_DEBUG ("0x%llx: Offering HELLO of peer %4s to local peer with id: %u\n",
1348 rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id); 1350 rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id);
1349 rocc->ohh = GNUNET_TRANSPORT_offer_hello (rocc->tcc.th, rocc->hello, 1351 rocc->ohh =
1350 rocc_hello_sent_cb, rocc); 1352 GNUNET_TRANSPORT_offer_hello (rocc->tcc.th, rocc->hello,
1353 rocc_hello_sent_cb, rocc);
1351 if (NULL == rocc->ohh) 1354 if (NULL == rocc->ohh)
1352 rocc->attempt_connect_task_id = 1355 rocc->attempt_connect_task_id =
1353 GNUNET_SCHEDULER_add_delayed 1356 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
1354 (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1357 (GNUNET_TIME_UNIT_MILLISECONDS,
1355 100 + GNUNET_CRYPTO_random_u32 1358 100 +
1356 (GNUNET_CRYPTO_QUALITY_WEAK, 500)), 1359 GNUNET_CRYPTO_random_u32
1357 &attempt_connect_task, rocc); 1360 (GNUNET_CRYPTO_QUALITY_WEAK, 500)),
1361 &attempt_connect_task, rocc);
1358} 1362}
1359 1363
1360 1364
@@ -1367,9 +1371,8 @@ attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1367 */ 1371 */
1368void 1372void
1369GST_handle_overlay_request_connect (void *cls, 1373GST_handle_overlay_request_connect (void *cls,
1370 struct GNUNET_SERVER_Client *client, 1374 struct GNUNET_SERVER_Client *client,
1371 const struct GNUNET_MessageHeader 1375 const struct GNUNET_MessageHeader *message)
1372 *message)
1373{ 1376{
1374 const struct GNUNET_TESTBED_RequestConnectMessage *msg; 1377 const struct GNUNET_TESTBED_RequestConnectMessage *msg;
1375 struct RequestOverlayConnectContext *rocc; 1378 struct RequestOverlayConnectContext *rocc;
@@ -1377,16 +1380,16 @@ GST_handle_overlay_request_connect (void *cls,
1377 uint32_t peer_id; 1380 uint32_t peer_id;
1378 uint16_t msize; 1381 uint16_t msize;
1379 uint16_t hsize; 1382 uint16_t hsize;
1380 1383
1381 msize = ntohs (message->size); 1384 msize = ntohs (message->size);
1382 if (sizeof (struct GNUNET_TESTBED_RequestConnectMessage) >= msize) 1385 if (sizeof (struct GNUNET_TESTBED_RequestConnectMessage) >= msize)
1383 { 1386 {
1384 GNUNET_break (0); 1387 GNUNET_break (0);
1385 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1388 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1386 return; 1389 return;
1387 } 1390 }
1388 msg = (const struct GNUNET_TESTBED_RequestConnectMessage *) message; 1391 msg = (const struct GNUNET_TESTBED_RequestConnectMessage *) message;
1389 if ((NULL == msg->hello) || 1392 if ((NULL == msg->hello) ||
1390 (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type))) 1393 (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type)))
1391 { 1394 {
1392 GNUNET_break (0); 1395 GNUNET_break (0);
@@ -1401,7 +1404,8 @@ GST_handle_overlay_request_connect (void *cls,
1401 return; 1404 return;
1402 } 1405 }
1403 peer_id = ntohl (msg->peer); 1406 peer_id = ntohl (msg->peer);
1404 if ((peer_id >= GST_peer_list_size) || (NULL == (peer = GST_peer_list[peer_id]))) 1407 if ((peer_id >= GST_peer_list_size) ||
1408 (NULL == (peer = GST_peer_list[peer_id])))
1405 { 1409 {
1406 GNUNET_break_op (0); 1410 GNUNET_break_op (0);
1407 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1411 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -1410,7 +1414,7 @@ GST_handle_overlay_request_connect (void *cls,
1410 if (GNUNET_YES == peer->is_remote) 1414 if (GNUNET_YES == peer->is_remote)
1411 { 1415 {
1412 struct GNUNET_MessageHeader *msg2; 1416 struct GNUNET_MessageHeader *msg2;
1413 1417
1414 msg2 = GNUNET_copy_message (message); 1418 msg2 = GNUNET_copy_message (message);
1415 GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller, 1419 GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller,
1416 msg2); 1420 msg2);
@@ -1424,15 +1428,13 @@ GST_handle_overlay_request_connect (void *cls,
1424 sizeof (struct GNUNET_PeerIdentity)); 1428 sizeof (struct GNUNET_PeerIdentity));
1425 LOG_DEBUG ("Received request for overlay connection with op_id: 0x%llx " 1429 LOG_DEBUG ("Received request for overlay connection with op_id: 0x%llx "
1426 "from local peer %u to peer %4s with hello size: %u\n", 1430 "from local peer %u to peer %4s with hello size: %u\n",
1427 rocc->op_id, 1431 rocc->op_id, peer_id, GNUNET_i2s (&rocc->a_id), hsize);
1428 peer_id,
1429 GNUNET_i2s (&rocc->a_id),
1430 hsize);
1431 rocc->peer = peer; 1432 rocc->peer = peer;
1432 rocc->peer->reference_cnt++; 1433 rocc->peer->reference_cnt++;
1433 rocc->tcc.op_id = rocc->op_id; 1434 rocc->tcc.op_id = rocc->op_id;
1434 rocc->tcc.th = GNUNET_TRANSPORT_connect (rocc->peer->details.local.cfg, NULL, rocc, 1435 rocc->tcc.th =
1435 NULL, &transport_connect_notify, NULL); 1436 GNUNET_TRANSPORT_connect (rocc->peer->details.local.cfg, NULL, rocc, NULL,
1437 &transport_connect_notify, NULL);
1436 if (NULL == rocc->tcc.th) 1438 if (NULL == rocc->tcc.th)
1437 { 1439 {
1438 GNUNET_break (0); 1440 GNUNET_break (0);
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c
index e5282a5e0..ebb82dfcf 100644
--- a/src/testbed/gnunet-testbed-profiler.c
+++ b/src/testbed/gnunet-testbed-profiler.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file testbed/gnunet-testbed-profiler.c 22 * @file testbed/gnunet-testbed-profiler.c
23 * @brief Profiling driver for the testbed. 23 * @brief Profiling driver for the testbed.
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */ 25 */
26 26
27#include "platform.h" 27#include "platform.h"
@@ -107,7 +107,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
107 GNUNET_SCHEDULER_cancel (abort_task); 107 GNUNET_SCHEDULER_cancel (abort_task);
108 if (NULL != cfg) 108 if (NULL != cfg)
109 GNUNET_CONFIGURATION_destroy (cfg); 109 GNUNET_CONFIGURATION_destroy (cfg);
110 GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */ 110 GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */
111} 111}
112 112
113 113
@@ -168,7 +168,7 @@ controller_event_cb (void *cls,
168 if (++cont_fails > num_cont_fails) 168 if (++cont_fails > num_cont_fails)
169 { 169 {
170 printf ("\nAborting due to very high failure rate\n"); 170 printf ("\nAborting due to very high failure rate\n");
171 print_overlay_links_summary (); 171 print_overlay_links_summary ();
172 GNUNET_SCHEDULER_cancel (abort_task); 172 GNUNET_SCHEDULER_cancel (abort_task);
173 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); 173 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
174 return; 174 return;
@@ -176,15 +176,15 @@ controller_event_cb (void *cls,
176 } 176 }
177 break; 177 break;
178 case GNUNET_TESTBED_ET_CONNECT: 178 case GNUNET_TESTBED_ET_CONNECT:
179 { 179 {
180 if (0 != cont_fails) 180 if (0 != cont_fails)
181 cont_fails--; 181 cont_fails--;
182 if (0 == established_links) 182 if (0 == established_links)
183 printf ("Establishing links. Please wait\n"); 183 printf ("Establishing links. Please wait\n");
184 printf ("."); 184 printf (".");
185 fflush (stdout); 185 fflush (stdout);
186 established_links++; 186 established_links++;
187 } 187 }
188 break; 188 break;
189 default: 189 default:
190 GNUNET_break (0); 190 GNUNET_break (0);
@@ -199,9 +199,8 @@ controller_event_cb (void *cls,
199 * @param num_peers number of peers in 'peers' 199 * @param num_peers number of peers in 'peers'
200 * @param peers handle to peers run in the testbed 200 * @param peers handle to peers run in the testbed
201 */ 201 */
202static void test_run (void *cls, 202static void
203 unsigned int num_peers, 203test_run (void *cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers)
204 struct GNUNET_TESTBED_Peer **peers)
205{ 204{
206 result = GNUNET_OK; 205 result = GNUNET_OK;
207 fprintf (stdout, "\n"); 206 fprintf (stdout, "\n");
@@ -241,13 +240,10 @@ run (void *cls, char *const *args, const char *cfgfile,
241 event_mask = 0; 240 event_mask = 0;
242 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 241 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
243 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 242 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
244 GNUNET_TESTBED_run (args[0], cfg, 243 GNUNET_TESTBED_run (args[0], cfg, num_peers, event_mask, controller_event_cb,
245 num_peers, event_mask, 244 NULL, &test_run, NULL);
246 controller_event_cb, NULL,
247 &test_run, NULL);
248 abort_task = 245 abort_task =
249 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 246 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_abort,
250 &do_abort,
251 NULL); 247 NULL);
252} 248}
253 249
@@ -261,24 +257,24 @@ int
261main (int argc, char *const *argv) 257main (int argc, char *const *argv)
262{ 258{
263 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 259 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
264 { 'p', "num-peers", "COUNT", 260 {'p', "num-peers", "COUNT",
265 gettext_noop ("create COUNT number of peers"), 261 gettext_noop ("create COUNT number of peers"),
266 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers }, 262 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers},
267 { 'e', "num-errors", "COUNT", 263 {'e', "num-errors", "COUNT",
268 gettext_noop ("tolerate COUNT number of continious timeout failures"), 264 gettext_noop ("tolerate COUNT number of continious timeout failures"),
269 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_cont_fails }, 265 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_cont_fails},
270 GNUNET_GETOPT_OPTION_END 266 GNUNET_GETOPT_OPTION_END
271 }; 267 };
272 int ret; 268 int ret;
273 269
274 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 270 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
275 return 2; 271 return 2;
276 result = GNUNET_SYSERR; 272 result = GNUNET_SYSERR;
277 ret = 273 ret =
278 GNUNET_PROGRAM_run (argc, argv, "gnunet-testbed-profiler [OPTIONS] hosts-file", 274 GNUNET_PROGRAM_run (argc, argv,
279 _("Profiler for testbed"), 275 "gnunet-testbed-profiler [OPTIONS] hosts-file",
280 options, &run, NULL); 276 _("Profiler for testbed"), options, &run, NULL);
281 GNUNET_free ((void*) argv); 277 GNUNET_free ((void *) argv);
282 if (GNUNET_OK != ret) 278 if (GNUNET_OK != ret)
283 return ret; 279 return ret;
284 if (GNUNET_OK != result) 280 if (GNUNET_OK != result)
diff --git a/src/testbed/gnunet_mpi_test.c b/src/testbed/gnunet_mpi_test.c
index e08144a3c..fded9e2c2 100644
--- a/src/testbed/gnunet_mpi_test.c
+++ b/src/testbed/gnunet_mpi_test.c
@@ -8,7 +8,8 @@
8#define LOG(kind,...) \ 8#define LOG(kind,...) \
9 GNUNET_log_from (kind, "gnunet-mpi-test", __VA_ARGS__) 9 GNUNET_log_from (kind, "gnunet-mpi-test", __VA_ARGS__)
10 10
11int main (int argc, char *argv[]) 11int
12main (int argc, char *argv[])
12{ 13{
13 char *msg; 14 char *msg;
14 char *filename; 15 char *filename;
@@ -44,16 +45,16 @@ int main (int argc, char *argv[])
44 GNUNET_break (0); 45 GNUNET_break (0);
45 goto finalize; 46 goto finalize;
46 } 47 }
47 pid = getpid(); 48 pid = getpid ();
48 (void) GNUNET_asprintf (&filename, "%d-%d.mpiout", (int) pid, rank); 49 (void) GNUNET_asprintf (&filename, "%d-%d.mpiout", (int) pid, rank);
49 msg_size = GNUNET_asprintf (&msg, "My rank is: %d\n", rank); 50 msg_size = GNUNET_asprintf (&msg, "My rank is: %d\n", rank);
50 printf ("%s", msg); 51 printf ("%s", msg);
51 if (msg_size == GNUNET_DISK_fn_write (filename, 52 if (msg_size ==
52 msg, msg_size, 53 GNUNET_DISK_fn_write (filename, msg, msg_size,
53 GNUNET_DISK_PERM_USER_READ 54 GNUNET_DISK_PERM_USER_READ |
54 | GNUNET_DISK_PERM_GROUP_READ 55 GNUNET_DISK_PERM_GROUP_READ |
55 | GNUNET_DISK_PERM_USER_WRITE 56 GNUNET_DISK_PERM_USER_WRITE |
56 | GNUNET_DISK_PERM_GROUP_WRITE)) 57 GNUNET_DISK_PERM_GROUP_WRITE))
57 ret = GNUNET_OK; 58 ret = GNUNET_OK;
58 GNUNET_free (filename); 59 GNUNET_free (filename);
59 GNUNET_free (msg); 60 GNUNET_free (msg);
@@ -62,26 +63,26 @@ int main (int argc, char *argv[])
62 GNUNET_break (0); 63 GNUNET_break (0);
63 goto finalize; 64 goto finalize;
64 } 65 }
65 66
66 ret = GNUNET_SYSERR; 67 ret = GNUNET_SYSERR;
67 argv2 = GNUNET_malloc (sizeof (char *) * (argc)); 68 argv2 = GNUNET_malloc (sizeof (char *) * (argc));
68 for (cnt = 1; cnt < argc; cnt++) 69 for (cnt = 1; cnt < argc; cnt++)
69 argv2[cnt - 1] = argv[cnt]; 70 argv2[cnt - 1] = argv[cnt];
70 proc = GNUNET_OS_start_process_vap (GNUNET_NO, 71 proc =
71 GNUNET_OS_INHERIT_STD_ALL, 72 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
72 NULL, 73 NULL, argv2[0], argv2);
73 NULL,
74 argv2[0], argv2);
75 if (NULL == proc) 74 if (NULL == proc)
76 { 75 {
77 printf ("Cannot exec\n"); 76 printf ("Cannot exec\n");
78 GNUNET_free (argv2); 77 GNUNET_free (argv2);
79 goto finalize; 78 goto finalize;
80 } 79 }
81 do { 80 do
81 {
82 (void) sleep (1); 82 (void) sleep (1);
83 ret = GNUNET_OS_process_status (proc, &proc_status, &code); 83 ret = GNUNET_OS_process_status (proc, &proc_status, &code);
84 } while (GNUNET_NO == ret); 84 }
85 while (GNUNET_NO == ret);
85 GNUNET_free (argv2); 86 GNUNET_free (argv2);
86 GNUNET_assert (GNUNET_NO != ret); 87 GNUNET_assert (GNUNET_NO != ret);
87 if (GNUNET_OK == ret) 88 if (GNUNET_OK == ret)
@@ -97,7 +98,7 @@ int main (int argc, char *argv[])
97 else 98 else
98 GNUNET_break (0); 99 GNUNET_break (0);
99 100
100 finalize: 101finalize:
101 (void) MPI_Finalize (); 102 (void) MPI_Finalize ();
102 if (GNUNET_OK == ret) 103 if (GNUNET_OK == ret)
103 return 0; 104 return 0;
diff --git a/src/testbed/ll_master.c b/src/testbed/ll_master.c
index 23d121582..98cef42fa 100644
--- a/src/testbed/ll_master.c
+++ b/src/testbed/ll_master.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file testbed/ll_master.c 22 * @file testbed/ll_master.c
23 * @brief The load level master. Creates child processes through LoadLeveler 23 * @brief The load level master. Creates child processes through LoadLeveler
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */ 25 */
26 26
27#include "platform.h" 27#include "platform.h"
@@ -56,12 +56,10 @@ run (void *cls, char *const *args, const char *cfgfile,
56 { 56 {
57 fprintf (stderr, _("Job command file not given. Exiting\n")); 57 fprintf (stderr, _("Job command file not given. Exiting\n"));
58 return; 58 return;
59 } 59 }
60 ret = llsubmit (args[0], 60 ret = llsubmit (args[0], NULL, //char *monitor_program,
61 NULL, //char *monitor_program, 61 NULL, //char *monitor_arg,
62 NULL, //char *monitor_arg, 62 &job_info, LL_JOB_VERSION);
63 &job_info,
64 LL_JOB_VERSION);
65 if (0 != ret) 63 if (0 != ret)
66 return; 64 return;
67 status = GNUNET_OK; 65 status = GNUNET_OK;
@@ -86,8 +84,8 @@ main (int argc, char **argv)
86 status = GNUNET_SYSERR; 84 status = GNUNET_SYSERR;
87 ret = 85 ret =
88 GNUNET_PROGRAM_run (argc, argv, "ll-master", 86 GNUNET_PROGRAM_run (argc, argv, "ll-master",
89 "LoadLeveler master process for starting child processes", options, 87 "LoadLeveler master process for starting child processes",
90 &run, NULL); 88 options, &run, NULL);
91 if (GNUNET_OK != ret) 89 if (GNUNET_OK != ret)
92 return 1; 90 return 1;
93 return (GNUNET_OK == status) ? 0 : 1; 91 return (GNUNET_OK == status) ? 0 : 1;
diff --git a/src/testbed/ll_monitor.c b/src/testbed/ll_monitor.c
index 695655056..3a43b490b 100644
--- a/src/testbed/ll_monitor.c
+++ b/src/testbed/ll_monitor.c
@@ -23,7 +23,7 @@
23 * @brief The load level monitor process. This is called whenever a job event 23 * @brief The load level monitor process. This is called whenever a job event
24 * happens. This file is called with the following syntax: 24 * happens. This file is called with the following syntax:
25 * "monitor_program job_id user_arg state exit_status" 25 * "monitor_program job_id user_arg state exit_status"
26 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 26 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
27 */ 27 */
28 28
29#include "platform.h" 29#include "platform.h"
@@ -63,7 +63,7 @@ main (int argc, char **argv)
63 PRINTF ("\t Exit status: %s \n", exit_status); 63 PRINTF ("\t Exit status: %s \n", exit_status);
64 64
65 if (-1 == asprintf (&outfile, "job-%s.status", job_id)) 65 if (-1 == asprintf (&outfile, "job-%s.status", job_id))
66 return 1; 66 return 1;
67 out = fopen (outfile, "a"); 67 out = fopen (outfile, "a");
68 if (NULL == out) 68 if (NULL == out)
69 return 1; 69 return 1;
diff --git a/src/testbed/standard_deviation.c b/src/testbed/standard_deviation.c
index 4bdd6cef2..f233a7174 100644
--- a/src/testbed/standard_deviation.c
+++ b/src/testbed/standard_deviation.c
@@ -32,7 +32,7 @@ struct SDEntry
32 * DLL prev pointer 32 * DLL prev pointer
33 */ 33 */
34 struct SDEntry *prev; 34 struct SDEntry *prev;
35 35
36 /** 36 /**
37 * The value to store 37 * The value to store
38 */ 38 */
@@ -46,12 +46,12 @@ struct SDHandle
46 * DLL head for storing entries 46 * DLL head for storing entries
47 */ 47 */
48 struct SDEntry *head; 48 struct SDEntry *head;
49 49
50 /** 50 /**
51 * DLL tail for storing entries 51 * DLL tail for storing entries
52 */ 52 */
53 struct SDEntry *tail; 53 struct SDEntry *tail;
54 54
55 /** 55 /**
56 * Squared sum of data values 56 * Squared sum of data values
57 */ 57 */
@@ -76,7 +76,7 @@ struct SDHandle
76 * Number of data values; also the length of DLL containing SDEntries 76 * Number of data values; also the length of DLL containing SDEntries
77 */ 77 */
78 unsigned int cnt; 78 unsigned int cnt;
79 79
80 /** 80 /**
81 * max number of entries we can have in the DLL 81 * max number of entries we can have in the DLL
82 */ 82 */
@@ -88,7 +88,7 @@ struct SDHandle *
88SD_init (unsigned int max_cnt) 88SD_init (unsigned int max_cnt)
89{ 89{
90 struct SDHandle *h; 90 struct SDHandle *h;
91 91
92 GNUNET_assert (1 < max_cnt); 92 GNUNET_assert (1 < max_cnt);
93 h = GNUNET_malloc (sizeof (struct SDHandle)); 93 h = GNUNET_malloc (sizeof (struct SDHandle));
94 h->max_cnt = max_cnt; 94 h->max_cnt = max_cnt;
@@ -99,7 +99,7 @@ void
99SD_destroy (struct SDHandle *h) 99SD_destroy (struct SDHandle *h)
100{ 100{
101 struct SDEntry *entry; 101 struct SDEntry *entry;
102 102
103 while (NULL != (entry = h->head)) 103 while (NULL != (entry = h->head))
104 { 104 {
105 GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry); 105 GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry);
@@ -121,8 +121,8 @@ SD_add_data (struct SDHandle *h, unsigned int amount)
121 entry = h->head; 121 entry = h->head;
122 GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry); 122 GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry);
123 h->sum -= entry->amount; 123 h->sum -= entry->amount;
124 h->sqsum -= ((unsigned long) entry->amount) * 124 h->sqsum -=
125 ((unsigned long) entry->amount); 125 ((unsigned long) entry->amount) * ((unsigned long) entry->amount);
126 h->cnt--; 126 h->cnt--;
127 } 127 }
128 GNUNET_assert (h->cnt < h->max_cnt); 128 GNUNET_assert (h->cnt < h->max_cnt);
@@ -172,8 +172,8 @@ SD_deviation_factor (struct SDHandle *h, unsigned int amount)
172int 172int
173main () 173main ()
174{ 174{
175 struct SDHandle * h = SD_init (20); 175 struct SDHandle *h = SD_init (20);
176 176
177 SD_add_data (h, 40); 177 SD_add_data (h, 40);
178 SD_add_data (h, 30); 178 SD_add_data (h, 30);
179 SD_add_data (h, 40); 179 SD_add_data (h, 40);
diff --git a/src/testbed/test_testbed_api.c b/src/testbed/test_testbed_api.c
index 310b2f36c..c5c448669 100644
--- a/src/testbed/test_testbed_api.c
+++ b/src/testbed/test_testbed_api.c
@@ -218,9 +218,9 @@ dht_disconnect_adapter (void *cls, void *op_result)
218 * @param emsg error message in case the operation has failed; will be NULL if 218 * @param emsg error message in case the operation has failed; will be NULL if
219 * operation has executed successfully. 219 * operation has executed successfully.
220 */ 220 */
221static void 221static void
222service_connect_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, 222service_connect_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
223 void *ca_result, const char *emsg) 223 void *ca_result, const char *emsg)
224{ 224{
225 switch (sub_test) 225 switch (sub_test)
226 { 226 {
@@ -229,8 +229,8 @@ service_connect_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
229 GNUNET_assert (NULL == emsg); 229 GNUNET_assert (NULL == emsg);
230 GNUNET_assert (NULL == cls); 230 GNUNET_assert (NULL == cls);
231 GNUNET_assert (ca_result == dht_handle); 231 GNUNET_assert (ca_result == dht_handle);
232 GNUNET_TESTBED_operation_done (operation); /* This results in call to 232 GNUNET_TESTBED_operation_done (operation); /* This results in call to
233 * disconnect adapter */ 233 * disconnect adapter */
234 break; 234 break;
235 default: 235 default:
236 GNUNET_assert (0); 236 GNUNET_assert (0);
@@ -248,10 +248,10 @@ service_connect_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
248 * @param emsg error message if the operation has failed; will be NULL if the 248 * @param emsg error message if the operation has failed; will be NULL if the
249 * operation is successfull 249 * operation is successfull
250 */ 250 */
251static void 251static void
252peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op, 252peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op,
253 const struct GNUNET_TESTBED_PeerInformation *pinfo, 253 const struct GNUNET_TESTBED_PeerInformation *pinfo,
254 const char *emsg) 254 const char *emsg)
255{ 255{
256 switch (sub_test) 256 switch (sub_test)
257 { 257 {
@@ -300,7 +300,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
300 GNUNET_assert (NULL == event->details.operation_finished.op_cls); 300 GNUNET_assert (NULL == event->details.operation_finished.op_cls);
301 GNUNET_assert (NULL == event->details.operation_finished.emsg); 301 GNUNET_assert (NULL == event->details.operation_finished.emsg);
302 GNUNET_assert (NULL != dht_handle); 302 GNUNET_assert (NULL != dht_handle);
303 GNUNET_assert (event->details.operation_finished.generic == dht_handle); 303 GNUNET_assert (event->details.operation_finished.generic == dht_handle);
304 break; 304 break;
305 default: 305 default:
306 GNUNET_assert (0); 306 GNUNET_assert (0);
@@ -313,10 +313,10 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
313 GNUNET_assert (OTHER == sub_test); 313 GNUNET_assert (OTHER == sub_test);
314 GNUNET_TESTBED_operation_done (operation); 314 GNUNET_TESTBED_operation_done (operation);
315 operation = 315 operation =
316 GNUNET_TESTBED_service_connect (NULL, peer, "dht", 316 GNUNET_TESTBED_service_connect (NULL, peer, "dht",
317 &service_connect_comp_cb, NULL, 317 &service_connect_comp_cb, NULL,
318 &dht_connect_adapter, 318 &dht_connect_adapter,
319 &dht_disconnect_adapter, NULL); 319 &dht_disconnect_adapter, NULL);
320 GNUNET_assert (NULL != operation); 320 GNUNET_assert (NULL != operation);
321 break; 321 break;
322 case GNUNET_TESTBED_ET_PEER_STOP: 322 case GNUNET_TESTBED_ET_PEER_STOP:
@@ -325,10 +325,10 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
325 result = GNUNET_YES; 325 result = GNUNET_YES;
326 sub_test = PEER_GETCONFIG; 326 sub_test = PEER_GETCONFIG;
327 GNUNET_TESTBED_operation_done (operation); 327 GNUNET_TESTBED_operation_done (operation);
328 operation = 328 operation =
329 GNUNET_TESTBED_peer_get_information (peer, 329 GNUNET_TESTBED_peer_get_information (peer,
330 GNUNET_TESTBED_PIT_CONFIGURATION, 330 GNUNET_TESTBED_PIT_CONFIGURATION,
331 &peerinfo_cb, NULL); 331 &peerinfo_cb, NULL);
332 break; 332 break;
333 default: 333 default:
334 GNUNET_assert (0); /* We should never reach this state */ 334 GNUNET_assert (0); /* We should never reach this state */
diff --git a/src/testbed/test_testbed_api_2peers_1controller.c b/src/testbed/test_testbed_api_2peers_1controller.c
index 084df1007..d5616c233 100644
--- a/src/testbed/test_testbed_api_2peers_1controller.c
+++ b/src/testbed/test_testbed_api_2peers_1controller.c
@@ -227,7 +227,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
227 * @param emsg error message in case the operation has failed; will be NULL if 227 * @param emsg error message in case the operation has failed; will be NULL if
228 * operation has executed successfully. 228 * operation has executed successfully.
229 */ 229 */
230static void 230static void
231op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg); 231op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg);
232 232
233 233
@@ -242,8 +242,9 @@ do_delayed_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
242{ 242{
243 delayed_connect_task = GNUNET_SCHEDULER_NO_TASK; 243 delayed_connect_task = GNUNET_SCHEDULER_NO_TASK;
244 FAIL_TEST (NULL == common_operation); 244 FAIL_TEST (NULL == common_operation);
245 common_operation = GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, 245 common_operation =
246 peer1.peer, peer2.peer); 246 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer,
247 peer2.peer);
247} 248}
248 249
249 250
@@ -255,11 +256,11 @@ do_delayed_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
255 * @param emsg error message in case the operation has failed; will be NULL if 256 * @param emsg error message in case the operation has failed; will be NULL if
256 * operation has executed successfully. 257 * operation has executed successfully.
257 */ 258 */
258static void 259static void
259op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) 260op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
260{ 261{
261 FAIL_TEST (common_operation == op); 262 FAIL_TEST (common_operation == op);
262 switch(result) 263 switch (result)
263 { 264 {
264 case PEERS_STARTED: 265 case PEERS_STARTED:
265 FAIL_TEST (NULL == peer1.operation); 266 FAIL_TEST (NULL == peer1.operation);
@@ -336,7 +337,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
336 result = PEERS_STARTED; 337 result = PEERS_STARTED;
337 common_operation = 338 common_operation =
338 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer, 339 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer,
339 peer2.peer); 340 peer2.peer);
340 } 341 }
341 break; 342 break;
342 case GNUNET_TESTBED_ET_PEER_STOP: 343 case GNUNET_TESTBED_ET_PEER_STOP:
@@ -366,14 +367,14 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
366 FAIL_TEST (NULL == peer2.operation); 367 FAIL_TEST (NULL == peer2.operation);
367 FAIL_TEST (NULL != common_operation); 368 FAIL_TEST (NULL != common_operation);
368 FAIL_TEST ((event->details.peer_connect.peer1 == peer1.peer) && 369 FAIL_TEST ((event->details.peer_connect.peer1 == peer1.peer) &&
369 (event->details.peer_connect.peer2 == peer2.peer)); 370 (event->details.peer_connect.peer2 == peer2.peer));
370 GNUNET_TESTBED_operation_done (common_operation); 371 GNUNET_TESTBED_operation_done (common_operation);
371 common_operation = NULL; 372 common_operation = NULL;
372 result = PEERS_CONNECTED; 373 result = PEERS_CONNECTED;
373 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); 374 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n");
374 delayed_connect_task = 375 delayed_connect_task =
375 GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), 376 GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), &do_delayed_connect,
376 &do_delayed_connect, NULL); 377 NULL);
377 break; 378 break;
378 case PEERS_CONNECTED: 379 case PEERS_CONNECTED:
379 FAIL_TEST (NULL == peer1.operation); 380 FAIL_TEST (NULL == peer1.operation);
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c
index 2f08fb475..47ad81021 100644
--- a/src/testbed/test_testbed_api_3peers_3controllers.c
+++ b/src/testbed/test_testbed_api_3peers_3controllers.c
@@ -31,7 +31,7 @@
31 * A 31 * A
32 * / \ 32 * / \
33 * / \ 33 * / \
34 * B === C 34 * B === C
35 * A is the master controller and B, C are slave controllers. B links to C 35 * A is the master controller and B, C are slave controllers. B links to C
36 * laterally. 36 * laterally.
37 * Peers are mapped to controllers in the following relations: 37 * Peers are mapped to controllers in the following relations:
@@ -320,7 +320,7 @@ abort_test ()
320 * @param emsg error message in case the operation has failed; will be NULL if 320 * @param emsg error message in case the operation has failed; will be NULL if
321 * operation has executed successfully. 321 * operation has executed successfully.
322 */ 322 */
323static void 323static void
324op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg); 324op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg);
325 325
326 326
@@ -337,11 +337,12 @@ do_delayed_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
337 if (NULL != common_operation) 337 if (NULL != common_operation)
338 { 338 {
339 GNUNET_break (0); 339 GNUNET_break (0);
340 abort_test(); 340 abort_test ();
341 return; 341 return;
342 } 342 }
343 common_operation = GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, 343 common_operation =
344 peer1.peer, peer2.peer); 344 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer,
345 peer2.peer);
345} 346}
346 347
347 348
@@ -353,33 +354,32 @@ do_delayed_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
353 * @param emsg error message in case the operation has failed; will be NULL if 354 * @param emsg error message in case the operation has failed; will be NULL if
354 * operation has executed successfully. 355 * operation has executed successfully.
355 */ 356 */
356static void 357static void
357op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) 358op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
358{ 359{
359 if (common_operation != op) 360 if (common_operation != op)
360 { 361 {
361 GNUNET_break (0); 362 GNUNET_break (0);
362 abort_test(); 363 abort_test ();
363 return; 364 return;
364 } 365 }
365 366
366 switch(result) 367 switch (result)
367 { 368 {
368 case PEER3_STARTED: 369 case PEER3_STARTED:
369 case PEERS_2_3_CONNECTED: 370 case PEERS_2_3_CONNECTED:
370 case PEERS_1_2_CONNECTED: 371 case PEERS_1_2_CONNECTED:
371 break; 372 break;
372 default: 373 default:
373 GNUNET_break (0); 374 GNUNET_break (0);
374 abort_test(); 375 abort_test ();
375 return; 376 return;
376 } 377 }
377 if ((NULL != peer1.operation) || 378 if ((NULL != peer1.operation) || (NULL != peer2.operation) ||
378 (NULL != peer2.operation) ||
379 (NULL != peer3.operation)) 379 (NULL != peer3.operation))
380 { 380 {
381 GNUNET_break (0); 381 GNUNET_break (0);
382 abort_test(); 382 abort_test ();
383 return; 383 return;
384 } 384 }
385} 385}
@@ -400,12 +400,10 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
400 switch (result) 400 switch (result)
401 { 401 {
402 case CONTROLLER1_UP: 402 case CONTROLLER1_UP:
403 if ((NULL == peer1.operation) || 403 if ((NULL == peer1.operation) || (NULL == peer) || (NULL != peer1.peer))
404 (NULL == peer) ||
405 (NULL != peer1.peer))
406 { 404 {
407 GNUNET_break (0); 405 GNUNET_break (0);
408 abort_test(); 406 abort_test ();
409 return; 407 return;
410 } 408 }
411 peer1.peer = peer; 409 peer1.peer = peer;
@@ -414,12 +412,10 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
414 peer1.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL); 412 peer1.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL);
415 break; 413 break;
416 case CONTROLLER2_UP: 414 case CONTROLLER2_UP:
417 if ((NULL == peer2.operation) || 415 if ((NULL == peer2.operation) || (NULL == peer) || (NULL != peer2.peer))
418 (NULL == peer) ||
419 (NULL != peer2.peer))
420 { 416 {
421 GNUNET_break (0); 417 GNUNET_break (0);
422 abort_test(); 418 abort_test ();
423 return; 419 return;
424 } 420 }
425 peer2.peer = peer; 421 peer2.peer = peer;
@@ -428,12 +424,10 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
428 peer2.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL); 424 peer2.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL);
429 break; 425 break;
430 case CONTROLLER3_UP: 426 case CONTROLLER3_UP:
431 if ((NULL == peer3.operation) || 427 if ((NULL == peer3.operation) || (NULL == peer) || (NULL != peer3.peer))
432 (NULL == peer) ||
433 (NULL != peer3.peer))
434 { 428 {
435 GNUNET_break (0); 429 GNUNET_break (0);
436 abort_test(); 430 abort_test ();
437 return; 431 return;
438 } 432 }
439 peer3.peer = peer; 433 peer3.peer = peer;
@@ -443,9 +437,9 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
443 break; 437 break;
444 default: 438 default:
445 GNUNET_break (0); 439 GNUNET_break (0);
446 abort_test(); 440 abort_test ();
447 return; 441 return;
448 } 442 }
449} 443}
450 444
451 445
@@ -462,20 +456,20 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
462 switch (event->type) 456 switch (event->type)
463 { 457 {
464 case GNUNET_TESTBED_ET_OPERATION_FINISHED: 458 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
465 if ((NULL != event->details.operation_finished.op_cls) 459 if ((NULL != event->details.operation_finished.op_cls) ||
466 || (NULL != event->details.operation_finished.emsg)) 460 (NULL != event->details.operation_finished.emsg))
467 { 461 {
468 GNUNET_break (0); 462 GNUNET_break (0);
469 abort_test(); 463 abort_test ();
470 return; 464 return;
471 } 465 }
472 switch (result) 466 switch (result)
473 { 467 {
474 case PEERS_STOPPED: 468 case PEERS_STOPPED:
475 if (NULL != event->details.operation_finished.generic) 469 if (NULL != event->details.operation_finished.generic)
476 { 470 {
477 GNUNET_break (0); 471 GNUNET_break (0);
478 abort_test(); 472 abort_test ();
479 return; 473 return;
480 } 474 }
481 if (event->details.operation_finished.operation == peer1.operation) 475 if (event->details.operation_finished.operation == peer1.operation)
@@ -499,7 +493,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
499 else 493 else
500 { 494 {
501 GNUNET_break (0); 495 GNUNET_break (0);
502 abort_test(); 496 abort_test ();
503 return; 497 return;
504 } 498 }
505 if ((NULL == peer1.peer) && (NULL == peer2.peer) && (NULL == peer3.peer)) 499 if ((NULL == peer1.peer) && (NULL == peer2.peer) && (NULL == peer3.peer))
@@ -513,7 +507,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
513 (NULL == common_operation)) 507 (NULL == common_operation))
514 { 508 {
515 GNUNET_break (0); 509 GNUNET_break (0);
516 abort_test(); 510 abort_test ();
517 return; 511 return;
518 } 512 }
519 GNUNET_TESTBED_operation_done (common_operation); 513 GNUNET_TESTBED_operation_done (common_operation);
@@ -525,7 +519,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
525 if (NULL == peer2.operation) 519 if (NULL == peer2.operation)
526 { 520 {
527 GNUNET_break (0); 521 GNUNET_break (0);
528 abort_test(); 522 abort_test ();
529 return; 523 return;
530 } 524 }
531 break; 525 break;
@@ -534,7 +528,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
534 (NULL == common_operation)) 528 (NULL == common_operation))
535 { 529 {
536 GNUNET_break (0); 530 GNUNET_break (0);
537 abort_test(); 531 abort_test ();
538 return; 532 return;
539 } 533 }
540 GNUNET_TESTBED_operation_done (common_operation); 534 GNUNET_TESTBED_operation_done (common_operation);
@@ -546,24 +540,24 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
546 if (NULL == peer3.operation) 540 if (NULL == peer3.operation)
547 { 541 {
548 GNUNET_break (0); 542 GNUNET_break (0);
549 abort_test(); 543 abort_test ();
550 return; 544 return;
551 } 545 }
552 break; 546 break;
553 default: 547 default:
554 GNUNET_break (0); 548 GNUNET_break (0);
555 abort_test(); 549 abort_test ();
556 return; 550 return;
557 } 551 }
558 break; 552 break;
559 case GNUNET_TESTBED_ET_PEER_START: 553 case GNUNET_TESTBED_ET_PEER_START:
560 switch (result) 554 switch (result)
561 { 555 {
562 case PEER1_CREATED: 556 case PEER1_CREATED:
563 if (event->details.peer_start.host != host) 557 if (event->details.peer_start.host != host)
564 { 558 {
565 GNUNET_break (0); 559 GNUNET_break (0);
566 abort_test(); 560 abort_test ();
567 return; 561 return;
568 } 562 }
569 peer1.is_running = GNUNET_YES; 563 peer1.is_running = GNUNET_YES;
@@ -571,14 +565,14 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
571 peer1.operation = NULL; 565 peer1.operation = NULL;
572 result = PEER1_STARTED; 566 result = PEER1_STARTED;
573 common_operation = 567 common_operation =
574 GNUNET_TESTBED_controller_link (NULL, controller1, neighbour1, NULL, cfg, 568 GNUNET_TESTBED_controller_link (NULL, controller1, neighbour1, NULL,
575 GNUNET_YES); 569 cfg, GNUNET_YES);
576 break; 570 break;
577 case PEER2_CREATED: 571 case PEER2_CREATED:
578 if (event->details.peer_start.host != neighbour1) 572 if (event->details.peer_start.host != neighbour1)
579 { 573 {
580 GNUNET_break (0); 574 GNUNET_break (0);
581 abort_test(); 575 abort_test ();
582 return; 576 return;
583 } 577 }
584 peer2.is_running = GNUNET_YES; 578 peer2.is_running = GNUNET_YES;
@@ -588,16 +582,16 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
588 if (NULL != common_operation) 582 if (NULL != common_operation)
589 { 583 {
590 GNUNET_break (0); 584 GNUNET_break (0);
591 abort_test(); 585 abort_test ();
592 return; 586 return;
593 } 587 }
594 common_operation = 588 common_operation =
595 GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2, NULL, cfg, 589 GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2, NULL,
596 GNUNET_YES); 590 cfg, GNUNET_YES);
597 if (NULL == common_operation) 591 if (NULL == common_operation)
598 { 592 {
599 GNUNET_break (0); 593 GNUNET_break (0);
600 abort_test(); 594 abort_test ();
601 return; 595 return;
602 } 596 }
603 break; 597 break;
@@ -605,7 +599,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
605 if (event->details.peer_start.host != neighbour2) 599 if (event->details.peer_start.host != neighbour2)
606 { 600 {
607 GNUNET_break (0); 601 GNUNET_break (0);
608 abort_test(); 602 abort_test ();
609 return; 603 return;
610 } 604 }
611 peer3.is_running = GNUNET_YES; 605 peer3.is_running = GNUNET_YES;
@@ -618,15 +612,15 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
618 break; 612 break;
619 default: 613 default:
620 GNUNET_break (0); 614 GNUNET_break (0);
621 abort_test(); 615 abort_test ();
622 return; 616 return;
623 } 617 }
624 break; 618 break;
625 case GNUNET_TESTBED_ET_PEER_STOP: 619 case GNUNET_TESTBED_ET_PEER_STOP:
626 if (PEERS_CONNECTED_2 != result) 620 if (PEERS_CONNECTED_2 != result)
627 { 621 {
628 GNUNET_break (0); 622 GNUNET_break (0);
629 abort_test(); 623 abort_test ();
630 return; 624 return;
631 } 625 }
632 if (event->details.peer_stop.peer == peer1.peer) 626 if (event->details.peer_stop.peer == peer1.peer)
@@ -647,11 +641,10 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
647 else 641 else
648 { 642 {
649 GNUNET_break (0); 643 GNUNET_break (0);
650 abort_test(); 644 abort_test ();
651 return; 645 return;
652 } 646 }
653 if ((GNUNET_NO == peer1.is_running) && 647 if ((GNUNET_NO == peer1.is_running) && (GNUNET_NO == peer2.is_running) &&
654 (GNUNET_NO == peer2.is_running) &&
655 (GNUNET_NO == peer3.is_running)) 648 (GNUNET_NO == peer3.is_running))
656 { 649 {
657 result = PEERS_STOPPED; 650 result = PEERS_STOPPED;
@@ -661,13 +654,11 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
661 } 654 }
662 break; 655 break;
663 case GNUNET_TESTBED_ET_CONNECT: 656 case GNUNET_TESTBED_ET_CONNECT:
664 if ((NULL != peer1.operation) || 657 if ((NULL != peer1.operation) || (NULL != peer2.operation) ||
665 (NULL != peer2.operation) || 658 (NULL != peer3.operation) || (NULL == common_operation))
666 (NULL != peer3.operation) ||
667 (NULL == common_operation))
668 { 659 {
669 GNUNET_break (0); 660 GNUNET_break (0);
670 abort_test(); 661 abort_test ();
671 return; 662 return;
672 } 663 }
673 switch (result) 664 switch (result)
@@ -677,38 +668,38 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
677 (event->details.peer_connect.peer2 != peer1.peer)) 668 (event->details.peer_connect.peer2 != peer1.peer))
678 { 669 {
679 GNUNET_break (0); 670 GNUNET_break (0);
680 abort_test(); 671 abort_test ();
681 return; 672 return;
682 } 673 }
683 GNUNET_TESTBED_operation_done (common_operation); 674 GNUNET_TESTBED_operation_done (common_operation);
684 common_operation = NULL; 675 common_operation = NULL;
685 result = PEERS_1_2_CONNECTED; 676 result = PEERS_1_2_CONNECTED;
686 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); 677 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n");
687 common_operation = 678 common_operation =
688 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer, 679 GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer,
689 peer3.peer); 680 peer3.peer);
690 break; 681 break;
691 case PEERS_1_2_CONNECTED: 682 case PEERS_1_2_CONNECTED:
692 if ((event->details.peer_connect.peer1 != peer2.peer) || 683 if ((event->details.peer_connect.peer1 != peer2.peer) ||
693 (event->details.peer_connect.peer2 != peer3.peer)) 684 (event->details.peer_connect.peer2 != peer3.peer))
694 { 685 {
695 GNUNET_break (0); 686 GNUNET_break (0);
696 abort_test(); 687 abort_test ();
697 return; 688 return;
698 } 689 }
699 GNUNET_TESTBED_operation_done (common_operation); 690 GNUNET_TESTBED_operation_done (common_operation);
700 common_operation = NULL; 691 common_operation = NULL;
701 result = PEERS_2_3_CONNECTED; 692 result = PEERS_2_3_CONNECTED;
702 delayed_connect_task = 693 delayed_connect_task =
703 GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), 694 GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), &do_delayed_connect,
704 &do_delayed_connect, NULL); 695 NULL);
705 break; 696 break;
706 case PEERS_2_3_CONNECTED: 697 case PEERS_2_3_CONNECTED:
707 if ((event->details.peer_connect.peer1 != peer1.peer) || 698 if ((event->details.peer_connect.peer1 != peer1.peer) ||
708 (event->details.peer_connect.peer2 != peer2.peer)) 699 (event->details.peer_connect.peer2 != peer2.peer))
709 { 700 {
710 GNUNET_break (0); 701 GNUNET_break (0);
711 abort_test(); 702 abort_test ();
712 return; 703 return;
713 } 704 }
714 GNUNET_TESTBED_operation_done (common_operation); 705 GNUNET_TESTBED_operation_done (common_operation);
@@ -721,13 +712,13 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
721 break; 712 break;
722 default: 713 default:
723 GNUNET_break (0); 714 GNUNET_break (0);
724 abort_test(); 715 abort_test ();
725 return; 716 return;
726 } 717 }
727 break; 718 break;
728 default: 719 default:
729 GNUNET_break (0); 720 GNUNET_break (0);
730 abort_test(); 721 abort_test ();
731 return; 722 return;
732 } 723 }
733} 724}
@@ -749,16 +740,16 @@ registration_comp (void *cls, const char *emsg)
749 if (NULL == neighbour2) 740 if (NULL == neighbour2)
750 { 741 {
751 GNUNET_break (0); 742 GNUNET_break (0);
752 abort_test(); 743 abort_test ();
753 return; 744 return;
754 } 745 }
755 reg_handle = 746 reg_handle =
756 GNUNET_TESTBED_register_host (controller1, neighbour2, &registration_comp, 747 GNUNET_TESTBED_register_host (controller1, neighbour2,
757 neighbour2); 748 &registration_comp, neighbour2);
758 if (NULL == reg_handle) 749 if (NULL == reg_handle)
759 { 750 {
760 GNUNET_break (0); 751 GNUNET_break (0);
761 abort_test(); 752 abort_test ();
762 return; 753 return;
763 } 754 }
764 return; 755 return;
@@ -766,7 +757,7 @@ registration_comp (void *cls, const char *emsg)
766 if (cls != neighbour2) 757 if (cls != neighbour2)
767 { 758 {
768 GNUNET_break (0); 759 GNUNET_break (0);
769 abort_test(); 760 abort_test ();
770 return; 761 return;
771 } 762 }
772 peer1.operation = 763 peer1.operation =
@@ -775,7 +766,7 @@ registration_comp (void *cls, const char *emsg)
775 if (NULL == peer1.operation) 766 if (NULL == peer1.operation)
776 { 767 {
777 GNUNET_break (0); 768 GNUNET_break (0);
778 abort_test(); 769 abort_test ();
779 return; 770 return;
780 } 771 }
781} 772}
@@ -791,15 +782,16 @@ registration_comp (void *cls, const char *emsg)
791 * GNUNET_TESTBED_controller_stop() shouldn't be called in this case 782 * GNUNET_TESTBED_controller_stop() shouldn't be called in this case
792 */ 783 */
793static void 784static void
794status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int status) 785status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
786 int status)
795{ 787{
796 uint64_t event_mask; 788 uint64_t event_mask;
797 789
798 if (GNUNET_OK != status) 790 if (GNUNET_OK != status)
799 { 791 {
800 GNUNET_break (0); 792 GNUNET_break (0);
801 cp1 = NULL; 793 cp1 = NULL;
802 abort_test(); 794 abort_test ();
803 return; 795 return;
804 } 796 }
805 event_mask = 0; 797 event_mask = 0;
@@ -811,12 +803,12 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int stat
811 { 803 {
812 case INIT: 804 case INIT:
813 controller1 = 805 controller1 =
814 GNUNET_TESTBED_controller_connect (config, host, event_mask, &controller_cb, 806 GNUNET_TESTBED_controller_connect (config, host, event_mask,
815 NULL); 807 &controller_cb, NULL);
816 if (NULL == controller1) 808 if (NULL == controller1)
817 { 809 {
818 GNUNET_break (0); 810 GNUNET_break (0);
819 abort_test(); 811 abort_test ();
820 return; 812 return;
821 } 813 }
822 result = CONTROLLER1_UP; 814 result = CONTROLLER1_UP;
@@ -824,24 +816,24 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int stat
824 if (NULL == neighbour1) 816 if (NULL == neighbour1)
825 { 817 {
826 GNUNET_break (0); 818 GNUNET_break (0);
827 abort_test(); 819 abort_test ();
828 return; 820 return;
829 } 821 }
830 reg_handle = 822 reg_handle =
831 GNUNET_TESTBED_register_host (controller1, neighbour1, &registration_comp, 823 GNUNET_TESTBED_register_host (controller1, neighbour1,
832 neighbour1); 824 &registration_comp, neighbour1);
833 if (NULL == reg_handle) 825 if (NULL == reg_handle)
834 { 826 {
835 GNUNET_break (0); 827 GNUNET_break (0);
836 abort_test(); 828 abort_test ();
837 return; 829 return;
838 } 830 }
839 break; 831 break;
840 default: 832 default:
841 GNUNET_break (0); 833 GNUNET_break (0);
842 abort_test(); 834 abort_test ();
843 return; 835 return;
844 } 836 }
845} 837}
846 838
847 839
@@ -855,8 +847,9 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int stat
855 * given to GNUNET_TESTBED_is_host_habitable() is NULL 847 * given to GNUNET_TESTBED_is_host_habitable() is NULL
856 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not 848 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not
857 */ 849 */
858static void 850static void
859host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host, int status) 851host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host,
852 int status)
860{ 853{
861 hc_handle = NULL; 854 hc_handle = NULL;
862 if (GNUNET_NO == status) 855 if (GNUNET_NO == status)
@@ -871,8 +864,8 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host, int statu
871 result = SKIP; 864 result = SKIP;
872 return; 865 return;
873 } 866 }
874 cp1 = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, 867 cp1 =
875 NULL); 868 GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, NULL);
876} 869}
877 870
878 871
@@ -892,12 +885,13 @@ run (void *cls, char *const *args, const char *cfgfile,
892 if (NULL == host) 885 if (NULL == host)
893 { 886 {
894 GNUNET_break (0); 887 GNUNET_break (0);
895 abort_test(); 888 abort_test ();
896 return; 889 return;
897 } 890 }
898 if (NULL == (hc_handle = GNUNET_TESTBED_is_host_habitable (host, config, 891 if (NULL ==
899 &host_habitable_cb, 892 (hc_handle =
900 NULL))) 893 GNUNET_TESTBED_is_host_habitable (host, config, &host_habitable_cb,
894 NULL)))
901 { 895 {
902 GNUNET_TESTBED_host_destroy (host); 896 GNUNET_TESTBED_host_destroy (host);
903 host = NULL; 897 host = NULL;
@@ -923,8 +917,8 @@ int
923main (int argc, char **argv) 917main (int argc, char **argv)
924{ 918{
925 char *const argv2[] = { "test_testbed_api_3peers_3controllers", 919 char *const argv2[] = { "test_testbed_api_3peers_3controllers",
926 "-c", "test_testbed_api.conf", 920 "-c", "test_testbed_api.conf",
927 NULL 921 NULL
928 }; 922 };
929 struct GNUNET_GETOPT_CommandLineOption options[] = { 923 struct GNUNET_GETOPT_CommandLineOption options[] = {
930 GNUNET_GETOPT_OPTION_END 924 GNUNET_GETOPT_OPTION_END
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c
index 10235b884..eadc6c9ff 100644
--- a/src/testbed/test_testbed_api_controllerlink.c
+++ b/src/testbed/test_testbed_api_controllerlink.c
@@ -28,12 +28,12 @@
28/** 28/**
29 * The controller architecture we try to achieve in this test case: 29 * The controller architecture we try to achieve in this test case:
30 * 30 *
31 * Master Controller 31 * Master Controller
32 * // \\ 32 * // \\
33 * // \\ 33 * // \\
34 * Slave Controller 1---------Slave Controller 3 34 * Slave Controller 1---------Slave Controller 3
35 * || 35 * ||
36 * || 36 * ||
37 * Slave Controller 2 37 * Slave Controller 2
38 */ 38 */
39 39
@@ -64,7 +64,7 @@ enum Stage
64 * Initial stage 64 * Initial stage
65 */ 65 */
66 INIT, 66 INIT,
67 67
68 /** 68 /**
69 * Master controller has started 69 * Master controller has started
70 */ 70 */
@@ -314,8 +314,8 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
314/** 314/**
315 * Calls abort now 315 * Calls abort now
316 * 316 *
317 * @param 317 * @param
318 * @return 318 * @return
319 */ 319 */
320static void 320static void
321do_abort_now (void *cls) 321do_abort_now (void *cls)
@@ -376,7 +376,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
376 case SLAVE1_LINK_SUCCESS: 376 case SLAVE1_LINK_SUCCESS:
377 result = SLAVE1_PEER_CREATE_SUCCESS; 377 result = SLAVE1_PEER_CREATE_SUCCESS;
378 slave1_peer = peer; 378 slave1_peer = peer;
379 GNUNET_TESTBED_operation_done (op); 379 GNUNET_TESTBED_operation_done (op);
380 op = GNUNET_TESTBED_peer_start (NULL, slave1_peer, NULL, NULL); 380 op = GNUNET_TESTBED_peer_start (NULL, slave1_peer, NULL, NULL);
381 break; 381 break;
382 case SLAVE2_LINK_SUCCESS: 382 case SLAVE2_LINK_SUCCESS:
@@ -448,7 +448,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
448 check_operation_success (event); 448 check_operation_success (event);
449 GNUNET_TESTBED_operation_done (op); 449 GNUNET_TESTBED_operation_done (op);
450 result = SLAVE2_LINK_SUCCESS; 450 result = SLAVE2_LINK_SUCCESS;
451 op = GNUNET_TESTBED_peer_create (mc, slave2, cfg, peer_create_cb, NULL); 451 op = GNUNET_TESTBED_peer_create (mc, slave2, cfg, peer_create_cb, NULL);
452 GNUNET_assert (NULL != op); 452 GNUNET_assert (NULL != op);
453 break; 453 break;
454 case MASTER_PEER_CREATE_SUCCESS: 454 case MASTER_PEER_CREATE_SUCCESS:
@@ -469,7 +469,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
469 GNUNET_TESTBED_operation_done (op); 469 GNUNET_TESTBED_operation_done (op);
470 result = SLAVE1_PEER_START_SUCCESS; 470 result = SLAVE1_PEER_START_SUCCESS;
471 op = GNUNET_TESTBED_controller_link (NULL, mc, slave2, slave, cfg, 471 op = GNUNET_TESTBED_controller_link (NULL, mc, slave2, slave, cfg,
472 GNUNET_YES); 472 GNUNET_YES);
473 break; 473 break;
474 case SLAVE2_PEER_CREATE_SUCCESS: 474 case SLAVE2_PEER_CREATE_SUCCESS:
475 GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type); 475 GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type);
@@ -529,7 +529,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
529 op = NULL; 529 op = NULL;
530 result = SLAVE3_STARTED; 530 result = SLAVE3_STARTED;
531 op = GNUNET_TESTBED_get_slave_config (NULL, mc, slave3); 531 op = GNUNET_TESTBED_get_slave_config (NULL, mc, slave3);
532 GNUNET_assert (NULL != op); 532 GNUNET_assert (NULL != op);
533 break; 533 break;
534 case SLAVE3_STARTED: 534 case SLAVE3_STARTED:
535 GNUNET_assert (NULL != event); 535 GNUNET_assert (NULL != event);
@@ -540,22 +540,23 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
540 cfg3 = GNUNET_CONFIGURATION_dup (event->details.operation_finished.generic); 540 cfg3 = GNUNET_CONFIGURATION_dup (event->details.operation_finished.generic);
541 GNUNET_TESTBED_operation_done (op); 541 GNUNET_TESTBED_operation_done (op);
542 result = SLAVE3_GET_CONFIG_SUCCESS; 542 result = SLAVE3_GET_CONFIG_SUCCESS;
543 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, slave, cfg3, GNUNET_NO); 543 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, slave, cfg3,
544 GNUNET_NO);
544 break; 545 break;
545 case SLAVE3_GET_CONFIG_SUCCESS: 546 case SLAVE3_GET_CONFIG_SUCCESS:
546 result = SLAVE3_LINK_SUCCESS; 547 result = SLAVE3_LINK_SUCCESS;
547 GNUNET_TESTBED_operation_done (op); 548 GNUNET_TESTBED_operation_done (op);
548 op = GNUNET_TESTBED_peer_destroy (master_peer); 549 op = GNUNET_TESTBED_peer_destroy (master_peer);
549 break; 550 break;
550 case SLAVE3_LINK_SUCCESS: 551 case SLAVE3_LINK_SUCCESS:
551 check_operation_success (event); 552 check_operation_success (event);
552 result = SUCCESS; 553 result = SUCCESS;
553 GNUNET_TESTBED_operation_done (op); 554 GNUNET_TESTBED_operation_done (op);
554 op = NULL; 555 op = NULL;
555 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 556 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
556 (GNUNET_TIME_UNIT_SECONDS, 3), 557 (GNUNET_TIME_UNIT_SECONDS, 3), &do_shutdown,
557 &do_shutdown, NULL); 558 NULL);
558 break; 559 break;
559 default: 560 default:
560 GNUNET_assert (0); 561 GNUNET_assert (0);
561 } 562 }
@@ -588,7 +589,8 @@ registration_cont (void *cls, const char *emsg)
588 GNUNET_assert (NULL != mc); 589 GNUNET_assert (NULL != mc);
589 result = SLAVE2_REGISTERED; 590 result = SLAVE2_REGISTERED;
590 GNUNET_assert (NULL != cfg); 591 GNUNET_assert (NULL != cfg);
591 op = GNUNET_TESTBED_controller_link (NULL, mc, slave, NULL, cfg, GNUNET_YES); 592 op = GNUNET_TESTBED_controller_link (NULL, mc, slave, NULL, cfg,
593 GNUNET_YES);
592 GNUNET_assert (NULL != op); 594 GNUNET_assert (NULL != op);
593 break; 595 break;
594 case SLAVE2_PEER_DESTROY_SUCCESS: 596 case SLAVE2_PEER_DESTROY_SUCCESS:
@@ -596,7 +598,8 @@ registration_cont (void *cls, const char *emsg)
596 GNUNET_assert (NULL != mc); 598 GNUNET_assert (NULL != mc);
597 GNUNET_assert (NULL == op); 599 GNUNET_assert (NULL == op);
598 result = SLAVE3_REGISTERED; 600 result = SLAVE3_REGISTERED;
599 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, NULL, cfg, GNUNET_YES); 601 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, NULL, cfg,
602 GNUNET_YES);
600 GNUNET_assert (NULL != op); 603 GNUNET_assert (NULL != op);
601 break; 604 break;
602 default: 605 default:
@@ -634,7 +637,7 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
634 op = GNUNET_TESTBED_peer_create (mc, host, cfg, peer_create_cb, NULL); 637 op = GNUNET_TESTBED_peer_create (mc, host, cfg, peer_create_cb, NULL);
635 GNUNET_assert (NULL != op); 638 GNUNET_assert (NULL != op);
636 break; 639 break;
637 default: 640 default:
638 GNUNET_break (0); 641 GNUNET_break (0);
639 cp = NULL; 642 cp = NULL;
640 do_abort_now (NULL); 643 do_abort_now (NULL);
@@ -652,8 +655,9 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
652 * given to GNUNET_TESTBED_is_host_habitable() is NULL 655 * given to GNUNET_TESTBED_is_host_habitable() is NULL
653 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not 656 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not
654 */ 657 */
655static void 658static void
656host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host, int status) 659host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host,
660 int status)
657{ 661{
658 hc_handle = NULL; 662 hc_handle = NULL;
659 if (GNUNET_NO == status) 663 if (GNUNET_NO == status)
@@ -669,7 +673,7 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host, int statu
669 return; 673 return;
670 } 674 }
671 cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, 675 cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,
672 NULL); 676 NULL);
673} 677}
674 678
675 679
@@ -687,9 +691,10 @@ run (void *cls, char *const *args, const char *cfgfile,
687{ 691{
688 host = GNUNET_TESTBED_host_create (NULL, NULL, 0); 692 host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
689 GNUNET_assert (NULL != host); 693 GNUNET_assert (NULL != host);
690 if (NULL == (hc_handle = GNUNET_TESTBED_is_host_habitable (host, config, 694 if (NULL ==
691 &host_habitable_cb, 695 (hc_handle =
692 NULL))) 696 GNUNET_TESTBED_is_host_habitable (host, config, &host_habitable_cb,
697 NULL)))
693 { 698 {
694 GNUNET_TESTBED_host_destroy (host); 699 GNUNET_TESTBED_host_destroy (host);
695 host = NULL; 700 host = NULL;
@@ -700,7 +705,7 @@ run (void *cls, char *const *args, const char *cfgfile,
700 result = SKIP; 705 result = SKIP;
701 return; 706 return;
702 } 707 }
703 cfg = GNUNET_CONFIGURATION_dup (config); 708 cfg = GNUNET_CONFIGURATION_dup (config);
704 abort_task = 709 abort_task =
705 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 710 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
706 (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, 711 (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort,
@@ -742,4 +747,3 @@ main (int argc, char **argv)
742} 747}
743 748
744/* end of test_testbed_api_controllerlink.c */ 749/* end of test_testbed_api_controllerlink.c */
745
diff --git a/src/testbed/test_testbed_api_hosts.c b/src/testbed/test_testbed_api_hosts.c
index 12f0b61c7..51284eaab 100644
--- a/src/testbed/test_testbed_api_hosts.c
+++ b/src/testbed/test_testbed_api_hosts.c
@@ -98,8 +98,7 @@ run (void *cls, char *const *args, const char *cfgfile,
98 GNUNET_assert (0 == GNUNET_TESTBED_host_get_id_ (host)); 98 GNUNET_assert (0 == GNUNET_TESTBED_host_get_id_ (host));
99 GNUNET_assert (host == GNUNET_TESTBED_host_lookup_by_id_ (0)); 99 GNUNET_assert (host == GNUNET_TESTBED_host_lookup_by_id_ (0));
100 hosts = NULL; 100 hosts = NULL;
101 num_hosts = GNUNET_TESTBED_hosts_load_from_file ("sample_hosts.txt", 101 num_hosts = GNUNET_TESTBED_hosts_load_from_file ("sample_hosts.txt", &hosts);
102 &hosts);
103 GNUNET_assert (15 == num_hosts); 102 GNUNET_assert (15 == num_hosts);
104 GNUNET_assert (NULL != hosts); 103 GNUNET_assert (NULL != hosts);
105 status = GNUNET_YES; 104 status = GNUNET_YES;
diff --git a/src/testbed/test_testbed_api_operations.c b/src/testbed/test_testbed_api_operations.c
index 2320c4d1b..24f23be23 100644
--- a/src/testbed/test_testbed_api_operations.c
+++ b/src/testbed/test_testbed_api_operations.c
@@ -60,7 +60,7 @@ struct GNUNET_TESTBED_Operation *op2;
60 * This operation should go into both queues and should consume 2 units of 60 * This operation should go into both queues and should consume 2 units of
61 * resources on both queues. Since op2 needs a resource from both queues and is 61 * resources on both queues. Since op2 needs a resource from both queues and is
62 * queues before this operation, it will be blocked until op2 is released even 62 * queues before this operation, it will be blocked until op2 is released even
63 * though q1 has 63 * though q1 has
64 */ 64 */
65struct GNUNET_TESTBED_Operation *op3; 65struct GNUNET_TESTBED_Operation *op3;
66 66
@@ -145,7 +145,7 @@ enum Test
145 * op4 has started 145 * op4 has started
146 */ 146 */
147 TEST_OP4_STARTED, 147 TEST_OP4_STARTED,
148 148
149 /** 149 /**
150 * op4 has released 150 * op4 has released
151 */ 151 */
@@ -258,39 +258,42 @@ start_cb (void *cls)
258 GNUNET_assert (&op1 == cls); 258 GNUNET_assert (&op1 == cls);
259 result = TEST_OP1_STARTED; 259 result = TEST_OP1_STARTED;
260 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task); 260 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task);
261 step_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL); 261 step_task =
262 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL);
262 break; 263 break;
263 case TEST_PAUSE: 264 case TEST_PAUSE:
264 GNUNET_assert (&op2 == cls); 265 GNUNET_assert (&op2 == cls);
265 result = TEST_OP2_STARTED; 266 result = TEST_OP2_STARTED;
266 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task); 267 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task);
267 step_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL); 268 step_task =
269 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL);
268 break; 270 break;
269 case TEST_OP2_RELEASED: 271 case TEST_OP2_RELEASED:
270 GNUNET_assert (&op3 == cls); 272 GNUNET_assert (&op3 == cls);
271 result = TEST_OP3_STARTED; 273 result = TEST_OP3_STARTED;
272 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task); 274 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task);
273 step_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL); 275 step_task =
276 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL);
274 break; 277 break;
275 case TEST_OP3_RELEASED: 278 case TEST_OP3_RELEASED:
276 GNUNET_assert (&op4 == cls); 279 GNUNET_assert (&op4 == cls);
277 result = TEST_OP4_STARTED; 280 result = TEST_OP4_STARTED;
278 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task); 281 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == step_task);
279 step_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, 282 step_task =
280 NULL); 283 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL);
281 break; 284 break;
282 case TEST_OP4_RELEASED: 285 case TEST_OP4_RELEASED:
286 {
287 static int nops;
288
289 nops++;
290 if (nops == 3)
283 { 291 {
284 static int nops; 292 result = TEST_OP5_6_7_STARTED;
285 293 GNUNET_TESTBED_operation_release_ (op5);
286 nops++; 294 op5 = NULL;
287 if (nops == 3)
288 {
289 result = TEST_OP5_6_7_STARTED;
290 GNUNET_TESTBED_operation_release_ (op5);
291 op5 = NULL;
292 }
293 } 295 }
296 }
294 break; 297 break;
295 default: 298 default:
296 GNUNET_assert (0); 299 GNUNET_assert (0);
@@ -316,8 +319,8 @@ release_cb (void *cls)
316 GNUNET_assert (&op1 == cls); 319 GNUNET_assert (&op1 == cls);
317 result = TEST_OP1_RELEASED; 320 result = TEST_OP1_RELEASED;
318 op1 = NULL; 321 op1 = NULL;
319 step_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, 322 step_task =
320 NULL); 323 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &step, NULL);
321 break; 324 break;
322 case TEST_OP2_STARTED: 325 case TEST_OP2_STARTED:
323 GNUNET_assert (&op2 == cls); 326 GNUNET_assert (&op2 == cls);
diff --git a/src/testbed/test_testbed_api_test.c b/src/testbed/test_testbed_api_test.c
index e4cee9ab0..705f52fa3 100644
--- a/src/testbed/test_testbed_api_test.c
+++ b/src/testbed/test_testbed_api_test.c
@@ -74,7 +74,7 @@ static int result;
74 */ 74 */
75static void 75static void
76do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 76do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
77{ 77{
78 shutdown_task = GNUNET_SCHEDULER_NO_TASK; 78 shutdown_task = GNUNET_SCHEDULER_NO_TASK;
79 if (GNUNET_SCHEDULER_NO_TASK != abort_task) 79 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
80 GNUNET_SCHEDULER_cancel (abort_task); 80 GNUNET_SCHEDULER_cancel (abort_task);
@@ -111,7 +111,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
111 LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n"); 111 LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
112 abort_task = GNUNET_SCHEDULER_NO_TASK; 112 abort_task = GNUNET_SCHEDULER_NO_TASK;
113 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) 113 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
114 GNUNET_SCHEDULER_cancel (shutdown_task); 114 GNUNET_SCHEDULER_cancel (shutdown_task);
115 shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL); 115 shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL);
116} 116}
117 117
@@ -125,10 +125,10 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
125 * @param emsg error message if the operation has failed; will be NULL if the 125 * @param emsg error message if the operation has failed; will be NULL if the
126 * operation is successfull 126 * operation is successfull
127 */ 127 */
128static void 128static void
129peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_, 129peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
130 const struct GNUNET_TESTBED_PeerInformation *pinfo, 130 const struct GNUNET_TESTBED_PeerInformation *pinfo,
131 const char *emsg) 131 const char *emsg)
132{ 132{
133 FAIL_TEST (op == op_); 133 FAIL_TEST (op == op_);
134 FAIL_TEST (NULL == cb_cls); 134 FAIL_TEST (NULL == cb_cls);
@@ -150,7 +150,7 @@ peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
150 * @param emsg error message in case the operation has failed; will be NULL if 150 * @param emsg error message in case the operation has failed; will be NULL if
151 * operation has executed successfully. 151 * operation has executed successfully.
152 */ 152 */
153static void 153static void
154op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op_, const char *emsg) 154op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op_, const char *emsg)
155{ 155{
156 FAIL_TEST (NULL == cls); 156 FAIL_TEST (NULL == cls);
@@ -162,8 +162,8 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op_, const char *emsg)
162 } 162 }
163 GNUNET_TESTBED_operation_done (op); 163 GNUNET_TESTBED_operation_done (op);
164 op = GNUNET_TESTBED_peer_get_information (peers[0], 164 op = GNUNET_TESTBED_peer_get_information (peers[0],
165 GNUNET_TESTBED_PIT_IDENTITY, 165 GNUNET_TESTBED_PIT_IDENTITY,
166 &peerinfo_cb, NULL); 166 &peerinfo_cb, NULL);
167} 167}
168 168
169 169
@@ -181,11 +181,11 @@ controller_event_cb (void *cls,
181 { 181 {
182 case GNUNET_TESTBED_ET_CONNECT: 182 case GNUNET_TESTBED_ET_CONNECT:
183 FAIL_TEST (event->details.peer_connect.peer1 == peers[0]); 183 FAIL_TEST (event->details.peer_connect.peer1 == peers[0]);
184 FAIL_TEST (event->details.peer_connect.peer2 == peers[1]); 184 FAIL_TEST (event->details.peer_connect.peer2 == peers[1]);
185 break; 185 break;
186 default: 186 default:
187 FAIL_TEST (0); 187 FAIL_TEST (0);
188 } 188 }
189} 189}
190 190
191 191
@@ -208,7 +208,8 @@ test_master (void *cls, unsigned int num_peers,
208 for (peer = 0; peer < num_peers; peer++) 208 for (peer = 0; peer < num_peers; peer++)
209 FAIL_TEST (NULL != peers_[peer]); 209 FAIL_TEST (NULL != peers_[peer]);
210 peers = peers_; 210 peers = peers_;
211 op = GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peers[0], peers[1]); 211 op = GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peers[0],
212 peers[1]);
212 abort_task = 213 abort_task =
213 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 214 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
214 (GNUNET_TIME_UNIT_MINUTES, 3), &do_abort, 215 (GNUNET_TIME_UNIT_MINUTES, 3), &do_abort,
@@ -229,9 +230,8 @@ main (int argc, char **argv)
229 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 230 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
230 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 231 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
231 (void) GNUNET_TESTBED_test_run ("test_testbed_api_test", 232 (void) GNUNET_TESTBED_test_run ("test_testbed_api_test",
232 "test_testbed_api.conf", 233 "test_testbed_api.conf", NUM_PEERS,
233 NUM_PEERS, event_mask, &controller_event_cb, 234 event_mask, &controller_event_cb, NULL,
234 NULL,
235 &test_master, NULL); 235 &test_master, NULL);
236 if (GNUNET_OK != result) 236 if (GNUNET_OK != result)
237 return 1; 237 return 1;
diff --git a/src/testbed/test_testbed_api_testbed_run.c b/src/testbed/test_testbed_api_testbed_run.c
index d41e33772..9cad74a7b 100644
--- a/src/testbed/test_testbed_api_testbed_run.c
+++ b/src/testbed/test_testbed_api_testbed_run.c
@@ -70,7 +70,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
70{ 70{
71 if (GNUNET_SCHEDULER_NO_TASK != abort_task) 71 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
72 GNUNET_SCHEDULER_cancel (abort_task); 72 GNUNET_SCHEDULER_cancel (abort_task);
73 GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */ 73 GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */
74} 74}
75 75
76 76
@@ -97,7 +97,8 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
97 * @param peers handle to peers run in the testbed 97 * @param peers handle to peers run in the testbed
98 */ 98 */
99static void 99static void
100test_master (void *cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers_) 100test_master (void *cls, unsigned int num_peers,
101 struct GNUNET_TESTBED_Peer **peers_)
101{ 102{
102 result = GNUNET_OK; 103 result = GNUNET_OK;
103 GNUNET_assert (NULL != peers[0]); 104 GNUNET_assert (NULL != peers[0]);
@@ -201,8 +202,8 @@ main (int argc, char **argv)
201#endif 202#endif
202 if (0 != strcmp ("run", testname)) 203 if (0 != strcmp ("run", testname))
203 { 204 {
204 GNUNET_asprintf (&config_filename, 205 GNUNET_asprintf (&config_filename, "test_testbed_api_testbed_run_%s.conf",
205 "test_testbed_api_testbed_run_%s.conf", testname); 206 testname);
206 } 207 }
207 else 208 else
208 config_filename = GNUNET_strdup ("test_testbed_api.conf"); 209 config_filename = GNUNET_strdup ("test_testbed_api.conf");
diff --git a/src/testbed/test_testbed_api_topology.c b/src/testbed/test_testbed_api_topology.c
index d3ce82895..a63ae1b1a 100644
--- a/src/testbed/test_testbed_api_topology.c
+++ b/src/testbed/test_testbed_api_topology.c
@@ -102,7 +102,7 @@ controller_event_cb (void *cls,
102 break; 102 break;
103 default: 103 default:
104 GNUNET_break (0); 104 GNUNET_break (0);
105 if ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) && 105 if ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) &&
106 (NULL != event->details.operation_finished.emsg)) 106 (NULL != event->details.operation_finished.emsg))
107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
108 "An operation failed with error: %s\n", 108 "An operation failed with error: %s\n",
@@ -110,7 +110,7 @@ controller_event_cb (void *cls,
110 result = GNUNET_SYSERR; 110 result = GNUNET_SYSERR;
111 GNUNET_SCHEDULER_cancel (shutdown_task); 111 GNUNET_SCHEDULER_cancel (shutdown_task);
112 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 112 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
113 } 113 }
114} 114}
115 115
116 116
@@ -135,12 +135,14 @@ test_master (void *cls, unsigned int num_peers,
135 peers = peers_; 135 peers = peers_;
136 overlay_connects = 0; 136 overlay_connects = 0;
137 op = GNUNET_TESTBED_overlay_configure_topology (NULL, NUM_PEERS, peers, NULL, 137 op = GNUNET_TESTBED_overlay_configure_topology (NULL, NUM_PEERS, peers, NULL,
138 GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, 138 GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
139 NUM_PEERS, GNUNET_TESTBED_TOPOLOGY_OPTION_END); 139 NUM_PEERS,
140 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
140 GNUNET_assert (NULL != op); 141 GNUNET_assert (NULL != op);
141 shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 142 shutdown_task =
142 (GNUNET_TIME_UNIT_SECONDS, 300), 143 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
143 do_shutdown, NULL); 144 (GNUNET_TIME_UNIT_SECONDS, 300),
145 do_shutdown, NULL);
144} 146}
145 147
146 148
@@ -157,9 +159,8 @@ main (int argc, char **argv)
157 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 159 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
158 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 160 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
159 (void) GNUNET_TESTBED_test_run ("test_testbed_api_test", 161 (void) GNUNET_TESTBED_test_run ("test_testbed_api_test",
160 "test_testbed_api.conf", 162 "test_testbed_api.conf", NUM_PEERS,
161 NUM_PEERS, event_mask, &controller_event_cb, 163 event_mask, &controller_event_cb, NULL,
162 NULL,
163 &test_master, NULL); 164 &test_master, NULL);
164 if (GNUNET_OK != result) 165 if (GNUNET_OK != result)
165 return 1; 166 return 1;
diff --git a/src/testbed/test_testbed_api_topology_clique.c b/src/testbed/test_testbed_api_topology_clique.c
index 0304fe33e..eb6254b10 100644
--- a/src/testbed/test_testbed_api_topology_clique.c
+++ b/src/testbed/test_testbed_api_topology_clique.c
@@ -105,7 +105,7 @@ controller_event_cb (void *cls,
105 result = GNUNET_SYSERR; 105 result = GNUNET_SYSERR;
106 GNUNET_SCHEDULER_cancel (shutdown_task); 106 GNUNET_SCHEDULER_cancel (shutdown_task);
107 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 107 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
108 } 108 }
109} 109}
110 110
111 111
@@ -129,16 +129,16 @@ test_master (void *cls, unsigned int num_peers,
129 GNUNET_assert (NULL != peers_[peer]); 129 GNUNET_assert (NULL != peers_[peer]);
130 peers = peers_; 130 peers = peers_;
131 overlay_connects = 0; 131 overlay_connects = 0;
132 op = GNUNET_TESTBED_overlay_configure_topology (NULL, NUM_PEERS, peers, 132 op = GNUNET_TESTBED_overlay_configure_topology (NULL, NUM_PEERS, peers, NULL,
133 NULL,
134 GNUNET_TESTBED_TOPOLOGY_CLIQUE, 133 GNUNET_TESTBED_TOPOLOGY_CLIQUE,
135 /* GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, */ 134 /* GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, */
136 /* NUM_PEERS, */ 135 /* NUM_PEERS, */
137 GNUNET_TESTBED_TOPOLOGY_OPTION_END); 136 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
138 GNUNET_assert (NULL != op); 137 GNUNET_assert (NULL != op);
139 shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 138 shutdown_task =
140 (GNUNET_TIME_UNIT_SECONDS, 300), 139 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
141 do_shutdown, NULL); 140 (GNUNET_TIME_UNIT_SECONDS, 300),
141 do_shutdown, NULL);
142} 142}
143 143
144 144
@@ -155,9 +155,8 @@ main (int argc, char **argv)
155 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 155 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
156 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 156 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
157 (void) GNUNET_TESTBED_test_run ("test_testbed_api_test", 157 (void) GNUNET_TESTBED_test_run ("test_testbed_api_test",
158 "test_testbed_api.conf", 158 "test_testbed_api.conf", NUM_PEERS,
159 NUM_PEERS, event_mask, &controller_event_cb, 159 event_mask, &controller_event_cb, NULL,
160 NULL,
161 &test_master, NULL); 160 &test_master, NULL);
162 if (GNUNET_OK != result) 161 if (GNUNET_OK != result)
163 return 1; 162 return 1;
diff --git a/src/testbed/testbed.h b/src/testbed/testbed.h
index 1e0cd2b4e..04e63dcb3 100644
--- a/src/testbed/testbed.h
+++ b/src/testbed/testbed.h
@@ -30,7 +30,6 @@
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31 31
32GNUNET_NETWORK_STRUCT_BEGIN 32GNUNET_NETWORK_STRUCT_BEGIN
33
34/** 33/**
35 * Initial message from a client to a testing control service. 34 * Initial message from a client to a testing control service.
36 */ 35 */
@@ -430,12 +429,12 @@ struct GNUNET_TESTBED_RequestConnectMessage
430 * Identity of A 429 * Identity of A
431 */ 430 */
432 struct GNUNET_PeerIdentity peer_identity; 431 struct GNUNET_PeerIdentity peer_identity;
433 432
434 /** 433 /**
435 * To be followed by the HELLO message of A 434 * To be followed by the HELLO message of A
436 */ 435 */
437 struct GNUNET_MessageHeader hello[0]; 436 struct GNUNET_MessageHeader hello[0];
438 437
439}; 438};
440 439
441 440
@@ -702,6 +701,5 @@ struct GNUNET_TESTBED_SlaveConfiguration
702 701
703 702
704GNUNET_NETWORK_STRUCT_END 703GNUNET_NETWORK_STRUCT_END
705
706#endif 704#endif
707/* end of testbed.h */ 705/* end of testbed.h */
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index fa218db02..b0db6160d 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -259,7 +259,7 @@ struct SDEntry
259 * DLL prev pointer 259 * DLL prev pointer
260 */ 260 */
261 struct SDEntry *prev; 261 struct SDEntry *prev;
262 262
263 /** 263 /**
264 * The value to store 264 * The value to store
265 */ 265 */
@@ -273,12 +273,12 @@ struct SDHandle
273 * DLL head for storing entries 273 * DLL head for storing entries
274 */ 274 */
275 struct SDEntry *head; 275 struct SDEntry *head;
276 276
277 /** 277 /**
278 * DLL tail for storing entries 278 * DLL tail for storing entries
279 */ 279 */
280 struct SDEntry *tail; 280 struct SDEntry *tail;
281 281
282 /** 282 /**
283 * Squared sum of data values 283 * Squared sum of data values
284 */ 284 */
@@ -303,7 +303,7 @@ struct SDHandle
303 * Number of data values; also the length of DLL containing SDEntries 303 * Number of data values; also the length of DLL containing SDEntries
304 */ 304 */
305 unsigned int cnt; 305 unsigned int cnt;
306 306
307 /** 307 /**
308 * max number of entries we can have in the DLL 308 * max number of entries we can have in the DLL
309 */ 309 */
@@ -321,7 +321,7 @@ static struct SDHandle *
321SD_init (unsigned int max_cnt) 321SD_init (unsigned int max_cnt)
322{ 322{
323 struct SDHandle *h; 323 struct SDHandle *h;
324 324
325 GNUNET_assert (1 < max_cnt); 325 GNUNET_assert (1 < max_cnt);
326 h = GNUNET_malloc (sizeof (struct SDHandle)); 326 h = GNUNET_malloc (sizeof (struct SDHandle));
327 h->max_cnt = max_cnt; 327 h->max_cnt = max_cnt;
@@ -338,7 +338,7 @@ static void
338SD_destroy (struct SDHandle *h) 338SD_destroy (struct SDHandle *h)
339{ 339{
340 struct SDEntry *entry; 340 struct SDEntry *entry;
341 341
342 while (NULL != (entry = h->head)) 342 while (NULL != (entry = h->head))
343 { 343 {
344 GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry); 344 GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry);
@@ -367,8 +367,8 @@ SD_add_data (struct SDHandle *h, unsigned int amount)
367 entry = h->head; 367 entry = h->head;
368 GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry); 368 GNUNET_CONTAINER_DLL_remove (h->head, h->tail, entry);
369 h->sum -= entry->amount; 369 h->sum -= entry->amount;
370 h->sqsum -= ((unsigned long) entry->amount) * 370 h->sqsum -=
371 ((unsigned long) entry->amount); 371 ((unsigned long) entry->amount) * ((unsigned long) entry->amount);
372 h->cnt--; 372 h->cnt--;
373 } 373 }
374 GNUNET_assert (h->cnt < h->max_cnt); 374 GNUNET_assert (h->cnt < h->max_cnt);
@@ -407,7 +407,7 @@ SD_deviation_factor (struct SDHandle *h, unsigned int amount)
407 if (((float) amount) > h->avg) 407 if (((float) amount) > h->avg)
408 diff = ((float) amount) - h->avg; 408 diff = ((float) amount) - h->avg;
409 else 409 else
410 return 0; //diff = h->avg - ((float) amount); 410 return 0; //diff = h->avg - ((float) amount);
411 diff *= diff; 411 diff *= diff;
412 for (n = 1; n < 4; n++) 412 for (n = 1; n < 4; n++)
413 if (diff < (((double) (n * n)) * h->vr)) 413 if (diff < (((double) (n * n)) * h->vr))
@@ -502,8 +502,8 @@ handle_addhostconfirm (struct GNUNET_TESTBED_Controller *c,
502 */ 502 */
503static void 503static void
504handle_forwarded_operation_msg (struct GNUNET_TESTBED_Controller *c, 504handle_forwarded_operation_msg (struct GNUNET_TESTBED_Controller *c,
505 struct OperationContext *opc, 505 struct OperationContext *opc,
506 const struct GNUNET_MessageHeader *msg) 506 const struct GNUNET_MessageHeader *msg)
507{ 507{
508 struct ForwardedOperationData *fo_data; 508 struct ForwardedOperationData *fo_data;
509 509
@@ -549,35 +549,35 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c,
549 switch (opc->type) 549 switch (opc->type)
550 { 550 {
551 case OP_FORWARDED: 551 case OP_FORWARDED:
552 { 552 {
553 handle_forwarded_operation_msg 553 handle_forwarded_operation_msg (c, opc,
554 (c, opc, (const struct GNUNET_MessageHeader *) msg); 554 (const struct GNUNET_MessageHeader *) msg);
555 return GNUNET_YES; 555 return GNUNET_YES;
556 } 556 }
557 break; 557 break;
558 case OP_PEER_DESTROY: 558 case OP_PEER_DESTROY:
559 { 559 {
560 struct GNUNET_TESTBED_Peer *peer; 560 struct GNUNET_TESTBED_Peer *peer;
561 561
562 peer = opc->data; 562 peer = opc->data;
563 GNUNET_free (peer); 563 GNUNET_free (peer);
564 opc->data = NULL; 564 opc->data = NULL;
565 //PEERDESTROYDATA 565 //PEERDESTROYDATA
566 } 566 }
567 break; 567 break;
568 case OP_LINK_CONTROLLERS: 568 case OP_LINK_CONTROLLERS:
569 { 569 {
570 struct ControllerLinkData *data; 570 struct ControllerLinkData *data;
571 571
572 data = opc->data; 572 data = opc->data;
573 GNUNET_assert (NULL != data); 573 GNUNET_assert (NULL != data);
574 GNUNET_free (data); 574 GNUNET_free (data);
575 opc->data = NULL; 575 opc->data = NULL;
576 } 576 }
577 break; 577 break;
578 default: 578 default:
579 GNUNET_assert (0); 579 GNUNET_assert (0);
580 } 580 }
581 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); 581 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
582 opc->state = OPC_STATE_FINISHED; 582 opc->state = OPC_STATE_FINISHED;
583 if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED))) 583 if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED)))
@@ -623,7 +623,7 @@ handle_peer_create_success (struct GNUNET_TESTBED_Controller *c,
623 if (OP_FORWARDED == opc->type) 623 if (OP_FORWARDED == opc->type)
624 { 624 {
625 handle_forwarded_operation_msg (c, opc, 625 handle_forwarded_operation_msg (c, opc,
626 (const struct GNUNET_MessageHeader *) msg); 626 (const struct GNUNET_MessageHeader *) msg);
627 return GNUNET_YES; 627 return GNUNET_YES;
628 } 628 }
629 GNUNET_assert (OP_PEER_CREATE == opc->type); 629 GNUNET_assert (OP_PEER_CREATE == opc->type);
@@ -676,7 +676,7 @@ handle_peer_event (struct GNUNET_TESTBED_Controller *c,
676 if (OP_FORWARDED == opc->type) 676 if (OP_FORWARDED == opc->type)
677 { 677 {
678 handle_forwarded_operation_msg (c, opc, 678 handle_forwarded_operation_msg (c, opc,
679 (const struct GNUNET_MessageHeader *) msg); 679 (const struct GNUNET_MessageHeader *) msg);
680 return GNUNET_YES; 680 return GNUNET_YES;
681 } 681 }
682 GNUNET_assert ((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type)); 682 GNUNET_assert ((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type));
@@ -746,7 +746,7 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c,
746 if (OP_FORWARDED == opc->type) 746 if (OP_FORWARDED == opc->type)
747 { 747 {
748 handle_forwarded_operation_msg (c, opc, 748 handle_forwarded_operation_msg (c, opc,
749 (const struct GNUNET_MessageHeader *) msg); 749 (const struct GNUNET_MessageHeader *) msg);
750 return GNUNET_YES; 750 return GNUNET_YES;
751 } 751 }
752 GNUNET_assert (OP_OVERLAY_CONNECT == opc->type); 752 GNUNET_assert (OP_OVERLAY_CONNECT == opc->type);
@@ -816,7 +816,7 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c,
816 if (OP_FORWARDED == opc->type) 816 if (OP_FORWARDED == opc->type)
817 { 817 {
818 handle_forwarded_operation_msg (c, opc, 818 handle_forwarded_operation_msg (c, opc,
819 (const struct GNUNET_MessageHeader *) msg); 819 (const struct GNUNET_MessageHeader *) msg);
820 return GNUNET_YES; 820 return GNUNET_YES;
821 } 821 }
822 data = opc->data; 822 data = opc->data;
@@ -835,11 +835,11 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c,
835 case GNUNET_TESTBED_PIT_IDENTITY: 835 case GNUNET_TESTBED_PIT_IDENTITY:
836 pinfo->result.id = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)); 836 pinfo->result.id = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
837 (void) memcpy (pinfo->result.id, &msg->peer_identity, 837 (void) memcpy (pinfo->result.id, &msg->peer_identity,
838 sizeof (struct GNUNET_PeerIdentity)); 838 sizeof (struct GNUNET_PeerIdentity));
839 break; 839 break;
840 case GNUNET_TESTBED_PIT_CONFIGURATION: 840 case GNUNET_TESTBED_PIT_CONFIGURATION:
841 pinfo->result.cfg = /* Freed in oprelease_peer_getinfo */ 841 pinfo->result.cfg = /* Freed in oprelease_peer_getinfo */
842 GNUNET_TESTBED_extract_config_ (&msg->header); 842 GNUNET_TESTBED_extract_config_ (&msg->header);
843 break; 843 break;
844 case GNUNET_TESTBED_PIT_GENERIC: 844 case GNUNET_TESTBED_PIT_GENERIC:
845 GNUNET_assert (0); /* never reach here */ 845 GNUNET_assert (0); /* never reach here */
@@ -882,7 +882,7 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c,
882 if (OP_FORWARDED == opc->type) 882 if (OP_FORWARDED == opc->type)
883 { 883 {
884 handle_forwarded_operation_msg (c, opc, 884 handle_forwarded_operation_msg (c, opc,
885 (const struct GNUNET_MessageHeader *) msg); 885 (const struct GNUNET_MessageHeader *) msg);
886 return GNUNET_YES; 886 return GNUNET_YES;
887 } 887 }
888 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); 888 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
@@ -893,11 +893,12 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c,
893 if (OP_PEER_INFO == opc->type) 893 if (OP_PEER_INFO == opc->type)
894 { 894 {
895 struct PeerInfoData *data; 895 struct PeerInfoData *data;
896
896 data = opc->data; 897 data = opc->data;
897 if (NULL != data->cb) 898 if (NULL != data->cb)
898 data->cb (data->cb_cls, opc->op, NULL, emsg); 899 data->cb (data->cb_cls, opc->op, NULL, emsg);
899 GNUNET_free (data); 900 GNUNET_free (data);
900 return GNUNET_YES; /* We do not call controller callback for peer info */ 901 return GNUNET_YES; /* We do not call controller callback for peer info */
901 } 902 }
902 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) && 903 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) &&
903 (NULL != c->cc)) 904 (NULL != c->cc))
@@ -912,45 +913,48 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c,
912 switch (opc->type) 913 switch (opc->type)
913 { 914 {
914 case OP_PEER_CREATE: 915 case OP_PEER_CREATE:
915 { 916 {
916 struct PeerCreateData *data; 917 struct PeerCreateData *data;
917 data = opc->data; 918
918 GNUNET_free (data->peer); 919 data = opc->data;
919 if (NULL != data->cb) 920 GNUNET_free (data->peer);
920 data->cb (data->cls, NULL, emsg); 921 if (NULL != data->cb)
921 GNUNET_free (data); 922 data->cb (data->cls, NULL, emsg);
922 } 923 GNUNET_free (data);
924 }
923 break; 925 break;
924 case OP_PEER_START: 926 case OP_PEER_START:
925 case OP_PEER_STOP: 927 case OP_PEER_STOP:
926 { 928 {
927 struct PeerEventData *data; 929 struct PeerEventData *data;
928 data = opc->data; 930
929 if (NULL != data->pcc) 931 data = opc->data;
930 data->pcc (data->pcc_cls, emsg); 932 if (NULL != data->pcc)
931 GNUNET_free (data); 933 data->pcc (data->pcc_cls, emsg);
932 } 934 GNUNET_free (data);
935 }
933 break; 936 break;
934 case OP_PEER_DESTROY: 937 case OP_PEER_DESTROY:
935 break; 938 break;
936 case OP_PEER_INFO: 939 case OP_PEER_INFO:
937 GNUNET_assert (0); 940 GNUNET_assert (0);
938 case OP_OVERLAY_CONNECT: 941 case OP_OVERLAY_CONNECT:
939 { 942 {
940 struct OverlayConnectData *data; 943 struct OverlayConnectData *data;
941 data = opc->data; 944
942 data->failed = GNUNET_YES; 945 data = opc->data;
943 if (NULL != data->cb) 946 data->failed = GNUNET_YES;
944 data->cb (data->cb_cls, opc->op, emsg); 947 if (NULL != data->cb)
945 } 948 data->cb (data->cb_cls, opc->op, emsg);
949 }
946 break; 950 break;
947 case OP_FORWARDED: 951 case OP_FORWARDED:
948 GNUNET_assert (0); 952 GNUNET_assert (0);
949 case OP_LINK_CONTROLLERS: /* No secondary callback */ 953 case OP_LINK_CONTROLLERS: /* No secondary callback */
950 break; 954 break;
951 default: 955 default:
952 GNUNET_break (0); 956 GNUNET_break (0);
953 } 957 }
954 return GNUNET_YES; 958 return GNUNET_YES;
955} 959}
956 960
@@ -967,7 +971,7 @@ GNUNET_TESTBED_generate_slavegetconfig_msg_ (uint64_t op_id, uint32_t slave_id)
967{ 971{
968 struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; 972 struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg;
969 uint16_t msize; 973 uint16_t msize;
970 974
971 msize = sizeof (struct GNUNET_TESTBED_SlaveGetConfigurationMessage); 975 msize = sizeof (struct GNUNET_TESTBED_SlaveGetConfigurationMessage);
972 msg = GNUNET_malloc (msize); 976 msg = GNUNET_malloc (msize);
973 msg->header.size = htons (msize); 977 msg->header.size = htons (msize);
@@ -989,11 +993,11 @@ GNUNET_TESTBED_generate_slavegetconfig_msg_ (uint64_t op_id, uint32_t slave_id)
989 */ 993 */
990static int 994static int
991handle_slave_config (struct GNUNET_TESTBED_Controller *c, 995handle_slave_config (struct GNUNET_TESTBED_Controller *c,
992 const struct GNUNET_TESTBED_SlaveConfiguration * msg) 996 const struct GNUNET_TESTBED_SlaveConfiguration *msg)
993{ 997{
994 struct OperationContext *opc; 998 struct OperationContext *opc;
995 uint64_t op_id; 999 uint64_t op_id;
996 struct GNUNET_TESTBED_EventInformation event; 1000 struct GNUNET_TESTBED_EventInformation event;
997 1001
998 op_id = GNUNET_ntohll (msg->operation_id); 1002 op_id = GNUNET_ntohll (msg->operation_id);
999 if (NULL == (opc = find_opc (c, op_id))) 1003 if (NULL == (opc = find_opc (c, op_id)))
@@ -1014,7 +1018,7 @@ handle_slave_config (struct GNUNET_TESTBED_Controller *c,
1014 (NULL != c->cc)) 1018 (NULL != c->cc))
1015 { 1019 {
1016 opc->data = GNUNET_TESTBED_extract_config_ (&msg->header); 1020 opc->data = GNUNET_TESTBED_extract_config_ (&msg->header);
1017 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 1021 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
1018 event.details.operation_finished.generic = opc->data; 1022 event.details.operation_finished.generic = opc->data;
1019 event.details.operation_finished.operation = opc->op; 1023 event.details.operation_finished.operation = opc->op;
1020 event.details.operation_finished.op_cls = opc->op_cls; 1024 event.details.operation_finished.op_cls = opc->op_cls;
@@ -1113,11 +1117,11 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
1113 msg); 1117 msg);
1114 break; 1118 break;
1115 case GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG: 1119 case GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG:
1116 GNUNET_assert (msize > 1120 GNUNET_assert (msize > sizeof (struct GNUNET_TESTBED_SlaveConfiguration));
1117 sizeof (struct GNUNET_TESTBED_SlaveConfiguration)); 1121 status =
1118 status = 1122 handle_slave_config (c,
1119 handle_slave_config (c, (const struct 1123 (const struct GNUNET_TESTBED_SlaveConfiguration *)
1120 GNUNET_TESTBED_SlaveConfiguration *) msg); 1124 msg);
1121 break; 1125 break;
1122 default: 1126 default:
1123 GNUNET_assert (0); 1127 GNUNET_assert (0);
@@ -1482,10 +1486,10 @@ GNUNET_TESTBED_set_num_parallel_overlay_connects_ (struct
1482{ 1486{
1483 fprintf (stderr, "%d", npoc); 1487 fprintf (stderr, "%d", npoc);
1484 GNUNET_free_non_null (c->tslots); 1488 GNUNET_free_non_null (c->tslots);
1485 c->tslots_filled = 0; 1489 c->tslots_filled = 0;
1486 c->num_parallel_connects = npoc; 1490 c->num_parallel_connects = npoc;
1487 c->tslots = GNUNET_malloc (npoc * sizeof (struct TimeSlot)); 1491 c->tslots = GNUNET_malloc (npoc * sizeof (struct TimeSlot));
1488 GNUNET_TESTBED_operation_queue_reset_max_active_ 1492 GNUNET_TESTBED_operation_queue_reset_max_active_
1489 (c->opq_parallel_overlay_connect_operations, npoc); 1493 (c->opq_parallel_overlay_connect_operations, npoc);
1490} 1494}
1491 1495
@@ -1503,7 +1507,7 @@ copy_argv (const char *const *argv)
1503 unsigned int argp; 1507 unsigned int argp;
1504 1508
1505 GNUNET_assert (NULL != argv); 1509 GNUNET_assert (NULL != argv);
1506 for (argp = 0; NULL != argv[argp]; argp++); 1510 for (argp = 0; NULL != argv[argp]; argp++) ;
1507 argv_dup = GNUNET_malloc (sizeof (char *) * (argp + 1)); 1511 argv_dup = GNUNET_malloc (sizeof (char *) * (argp + 1));
1508 for (argp = 0; NULL != argv[argp]; argp++) 1512 for (argp = 0; NULL != argv[argp]; argp++)
1509 argv_dup[argp] = strdup (argv[argp]); 1513 argv_dup[argp] = strdup (argv[argp]);
@@ -1552,7 +1556,7 @@ static void
1552free_argv (char **argv) 1556free_argv (char **argv)
1553{ 1557{
1554 unsigned int argp; 1558 unsigned int argp;
1555 1559
1556 for (argp = 0; NULL != argv[argp]; argp++) 1560 for (argp = 0; NULL != argv[argp]; argp++)
1557 GNUNET_free (argv[argp]); 1561 GNUNET_free (argv[argp]);
1558 GNUNET_free (argv); 1562 GNUNET_free (argv);
@@ -1588,22 +1592,20 @@ gen_rsh_args (const char *port, const char *dst)
1588 char *arg; 1592 char *arg;
1589 unsigned int cnt; 1593 unsigned int cnt;
1590 1594
1591 ssh_args = NULL; 1595 ssh_args = NULL;
1592 if (NULL != (ssh_cmd = getenv ("GNUNET_TESTBED_RSH_CMD"))) 1596 if (NULL != (ssh_cmd = getenv ("GNUNET_TESTBED_RSH_CMD")))
1593 { 1597 {
1594 ssh_cmd = GNUNET_strdup (ssh_cmd); 1598 ssh_cmd = GNUNET_strdup (ssh_cmd);
1595 ssh_cmd_cp = ssh_cmd; 1599 ssh_cmd_cp = ssh_cmd;
1596 for (cnt = 0; 1600 for (cnt = 0; NULL != (arg = strtok (ssh_cmd, " ")); ssh_cmd = NULL)
1597 NULL != (arg = strtok (ssh_cmd, " "));
1598 ssh_cmd = NULL)
1599 GNUNET_array_append (ssh_args, cnt, GNUNET_strdup (arg)); 1601 GNUNET_array_append (ssh_args, cnt, GNUNET_strdup (arg));
1600 GNUNET_free (ssh_cmd_cp); 1602 GNUNET_free (ssh_cmd_cp);
1601 } 1603 }
1602 else 1604 else
1603 { 1605 {
1604 ssh_args = copy_argv (default_ssh_args); 1606 ssh_args = copy_argv (default_ssh_args);
1605 cnt = (sizeof (default_ssh_args)) / (sizeof (const char *)); 1607 cnt = (sizeof (default_ssh_args)) / (sizeof (const char *));
1606 GNUNET_array_grow (ssh_args, cnt, cnt - 1); 1608 GNUNET_array_grow (ssh_args, cnt, cnt - 1);
1607 } 1609 }
1608 GNUNET_array_append (ssh_args, cnt, GNUNET_strdup ("-p")); 1610 GNUNET_array_append (ssh_args, cnt, GNUNET_strdup ("-p"));
1609 GNUNET_array_append (ssh_args, cnt, GNUNET_strdup (port)); 1611 GNUNET_array_append (ssh_args, cnt, GNUNET_strdup (port));
@@ -1630,19 +1632,17 @@ gen_rsh_suffix_args (const char *helper_binary_path)
1630 char *rshell_cmd_cp; 1632 char *rshell_cmd_cp;
1631 char *arg; 1633 char *arg;
1632 unsigned int cnt; 1634 unsigned int cnt;
1633 1635
1634 rshell_args = NULL; 1636 rshell_args = NULL;
1635 cnt = 0; 1637 cnt = 0;
1636 if (NULL != (rshell_cmd = getenv ("GNUNET_TESTBED_RSH_CMD_SUFFIX"))) 1638 if (NULL != (rshell_cmd = getenv ("GNUNET_TESTBED_RSH_CMD_SUFFIX")))
1637 { 1639 {
1638 rshell_cmd = GNUNET_strdup (rshell_cmd); 1640 rshell_cmd = GNUNET_strdup (rshell_cmd);
1639 rshell_cmd_cp = rshell_cmd; 1641 rshell_cmd_cp = rshell_cmd;
1640 for (; 1642 for (; NULL != (arg = strtok (rshell_cmd, " ")); rshell_cmd = NULL)
1641 NULL != (arg = strtok (rshell_cmd, " "));
1642 rshell_cmd = NULL)
1643 GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (arg)); 1643 GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (arg));
1644 GNUNET_free (rshell_cmd_cp); 1644 GNUNET_free (rshell_cmd_cp);
1645 } 1645 }
1646 GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (helper_binary_path)); 1646 GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (helper_binary_path));
1647 GNUNET_array_append (rshell_args, cnt, NULL); 1647 GNUNET_array_append (rshell_args, cnt, NULL);
1648 return rshell_args; 1648 return rshell_args;
@@ -1681,9 +1681,10 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
1681 struct GNUNET_TESTBED_ControllerProc *cp; 1681 struct GNUNET_TESTBED_ControllerProc *cp;
1682 struct GNUNET_TESTBED_HelperInit *msg; 1682 struct GNUNET_TESTBED_HelperInit *msg;
1683 const char *hostname; 1683 const char *hostname;
1684
1684 static char *const binary_argv[] = { 1685 static char *const binary_argv[] = {
1685 HELPER_TESTBED_BINARY, NULL 1686 HELPER_TESTBED_BINARY, NULL
1686 }; 1687 };
1687 1688
1688 hostname = NULL; 1689 hostname = NULL;
1689 cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc)); 1690 cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc));
@@ -1711,15 +1712,16 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
1711 GNUNET_asprintf (&dst, "%s@%s", username, hostname); 1712 GNUNET_asprintf (&dst, "%s@%s", username, hostname);
1712 LOG_DEBUG ("Starting SSH to destination %s\n", dst); 1713 LOG_DEBUG ("Starting SSH to destination %s\n", dst);
1713 1714
1714 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed", 1715 if (GNUNET_OK !=
1715 "HELPER_BINARY_PATH", 1716 GNUNET_CONFIGURATION_get_value_string (cfg, "testbed",
1716 &helper_binary_path)) 1717 "HELPER_BINARY_PATH",
1717 helper_binary_path = GNUNET_OS_get_libexec_binary_path 1718 &helper_binary_path))
1718 (HELPER_TESTBED_BINARY); 1719 helper_binary_path =
1720 GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
1719 ssh_args = gen_rsh_args (port, dst); 1721 ssh_args = gen_rsh_args (port, dst);
1720 rshell_args = gen_rsh_suffix_args (helper_binary_path); 1722 rshell_args = gen_rsh_suffix_args (helper_binary_path);
1721 cp->helper_argv = join_argv ((const char **) ssh_args, 1723 cp->helper_argv =
1722 (const char **)rshell_args); 1724 join_argv ((const char **) ssh_args, (const char **) rshell_args);
1723 free_argv (ssh_args); 1725 free_argv (ssh_args);
1724 free_argv (rshell_args); 1726 free_argv (rshell_args);
1725 GNUNET_free (port); 1727 GNUNET_free (port);
@@ -1865,10 +1867,10 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle
1865 controller->opq_parallel_service_connections = 1867 controller->opq_parallel_service_connections =
1866 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1868 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1867 max_parallel_service_connections); 1869 max_parallel_service_connections);
1868 controller->opq_parallel_topology_config_operations= 1870 controller->opq_parallel_topology_config_operations =
1869 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1871 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1870 max_parallel_topology_config_operations); 1872 max_parallel_topology_config_operations);
1871 controller->opq_parallel_overlay_connect_operations= 1873 controller->opq_parallel_overlay_connect_operations =
1872 GNUNET_TESTBED_operation_queue_create_ (0); 1874 GNUNET_TESTBED_operation_queue_create_ (0);
1873 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (controller, 1); 1875 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (controller, 1);
1874 controller->poc_sd = SD_init (10); 1876 controller->poc_sd = SD_init (10);
@@ -1927,7 +1929,7 @@ GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller
1927 GNUNET_TESTBED_queue_message_ (controller, 1929 GNUNET_TESTBED_queue_message_ (controller,
1928 (struct GNUNET_MessageHeader *) msg); 1930 (struct GNUNET_MessageHeader *) msg);
1929 GNUNET_break (0); /* This function is not yet implemented on the 1931 GNUNET_break (0); /* This function is not yet implemented on the
1930 testbed service */ 1932 * testbed service */
1931} 1933}
1932 1934
1933 1935
@@ -2084,9 +2086,9 @@ struct GNUNET_TESTBED_Operation *
2084GNUNET_TESTBED_controller_link_2_ (void *op_cls, 2086GNUNET_TESTBED_controller_link_2_ (void *op_cls,
2085 struct GNUNET_TESTBED_Controller *master, 2087 struct GNUNET_TESTBED_Controller *master,
2086 uint32_t delegated_host_id, 2088 uint32_t delegated_host_id,
2087 uint32_t slave_host_id, 2089 uint32_t slave_host_id, const char *sxcfg,
2088 const char *sxcfg, size_t sxcfg_size, 2090 size_t sxcfg_size, size_t scfg_size,
2089 size_t scfg_size, int is_subordinate) 2091 int is_subordinate)
2090{ 2092{
2091 struct OperationContext *opc; 2093 struct OperationContext *opc;
2092 struct GNUNET_TESTBED_ControllerLinkMessage *msg; 2094 struct GNUNET_TESTBED_ControllerLinkMessage *msg;
@@ -2143,30 +2145,27 @@ GNUNET_TESTBED_controller_link_2_ (void *op_cls,
2143 */ 2145 */
2144struct GNUNET_TESTBED_Operation * 2146struct GNUNET_TESTBED_Operation *
2145GNUNET_TESTBED_controller_link_2 (void *op_cls, 2147GNUNET_TESTBED_controller_link_2 (void *op_cls,
2146 struct GNUNET_TESTBED_Controller *master, 2148 struct GNUNET_TESTBED_Controller *master,
2147 struct GNUNET_TESTBED_Host *delegated_host, 2149 struct GNUNET_TESTBED_Host *delegated_host,
2148 struct GNUNET_TESTBED_Host *slave_host, 2150 struct GNUNET_TESTBED_Host *slave_host,
2149 const char *sxcfg, size_t sxcfg_size, 2151 const char *sxcfg, size_t sxcfg_size,
2150 size_t scfg_size, int is_subordinate) 2152 size_t scfg_size, int is_subordinate)
2151{ 2153{
2152 uint32_t delegated_host_id; 2154 uint32_t delegated_host_id;
2153 uint32_t slave_host_id; 2155 uint32_t slave_host_id;
2154 2156
2155 GNUNET_assert (GNUNET_YES == 2157 GNUNET_assert (GNUNET_YES ==
2156 GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); 2158 GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
2157 delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host); 2159 delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host);
2158 slave_host_id = 2160 slave_host_id =
2159 GNUNET_TESTBED_host_get_id_ ((NULL != slave_host) 2161 GNUNET_TESTBED_host_get_id_ ((NULL !=
2160 ? slave_host : master->host); 2162 slave_host) ? slave_host : master->host);
2161 if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host))) 2163 if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host)))
2162 GNUNET_assert (GNUNET_YES == 2164 GNUNET_assert (GNUNET_YES ==
2163 GNUNET_TESTBED_is_host_registered_ (slave_host, master)); 2165 GNUNET_TESTBED_is_host_registered_ (slave_host, master));
2164 2166
2165 return GNUNET_TESTBED_controller_link_2_ (op_cls, 2167 return GNUNET_TESTBED_controller_link_2_ (op_cls, master, delegated_host_id,
2166 master, 2168 slave_host_id, sxcfg, sxcfg_size,
2167 delegated_host_id,
2168 slave_host_id,
2169 sxcfg, sxcfg_size,
2170 scfg_size, is_subordinate); 2169 scfg_size, is_subordinate);
2171} 2170}
2172 2171
@@ -2217,12 +2216,11 @@ GNUNET_TESTBED_compress_config_ (const char *config, size_t size,
2217 */ 2216 */
2218struct GNUNET_TESTBED_Operation * 2217struct GNUNET_TESTBED_Operation *
2219GNUNET_TESTBED_controller_link_ (void *op_cls, 2218GNUNET_TESTBED_controller_link_ (void *op_cls,
2220 struct GNUNET_TESTBED_Controller *master, 2219 struct GNUNET_TESTBED_Controller *master,
2221 uint32_t delegated_host_id, 2220 uint32_t delegated_host_id,
2222 uint32_t slave_host_id, 2221 uint32_t slave_host_id,
2223 const struct GNUNET_CONFIGURATION_Handle 2222 const struct GNUNET_CONFIGURATION_Handle
2224 *slave_cfg, 2223 *slave_cfg, int is_subordinate)
2225 int is_subordinate)
2226{ 2224{
2227 struct GNUNET_TESTBED_Operation *op; 2225 struct GNUNET_TESTBED_Operation *op;
2228 char *config; 2226 char *config;
@@ -2234,8 +2232,8 @@ GNUNET_TESTBED_controller_link_ (void *op_cls,
2234 cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig); 2232 cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig);
2235 GNUNET_free (config); 2233 GNUNET_free (config);
2236 /* Configuration doesn't fit in 1 message */ 2234 /* Configuration doesn't fit in 1 message */
2237 GNUNET_assert ((UINT16_MAX - 2235 GNUNET_assert ((UINT16_MAX -
2238 sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) >= 2236 sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) >=
2239 cc_size); 2237 cc_size);
2240 op = GNUNET_TESTBED_controller_link_2_ (op_cls, master, delegated_host_id, 2238 op = GNUNET_TESTBED_controller_link_2_ (op_cls, master, delegated_host_id,
2241 slave_host_id, (const char *) cconfig, 2239 slave_host_id, (const char *) cconfig,
@@ -2276,7 +2274,7 @@ GNUNET_TESTBED_controller_link_ (void *op_cls,
2276 */ 2274 */
2277struct GNUNET_TESTBED_Operation * 2275struct GNUNET_TESTBED_Operation *
2278GNUNET_TESTBED_controller_link (void *op_cls, 2276GNUNET_TESTBED_controller_link (void *op_cls,
2279 struct GNUNET_TESTBED_Controller *master, 2277 struct GNUNET_TESTBED_Controller *master,
2280 struct GNUNET_TESTBED_Host *delegated_host, 2278 struct GNUNET_TESTBED_Host *delegated_host,
2281 struct GNUNET_TESTBED_Host *slave_host, 2279 struct GNUNET_TESTBED_Host *slave_host,
2282 const struct GNUNET_CONFIGURATION_Handle 2280 const struct GNUNET_CONFIGURATION_Handle
@@ -2287,19 +2285,17 @@ GNUNET_TESTBED_controller_link (void *op_cls,
2287 2285
2288 GNUNET_assert (GNUNET_YES == 2286 GNUNET_assert (GNUNET_YES ==
2289 GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); 2287 GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
2290 slave_host_id = 2288 slave_host_id =
2291 GNUNET_TESTBED_host_get_id_ ((NULL != slave_host) 2289 GNUNET_TESTBED_host_get_id_ ((NULL !=
2292 ? slave_host : master->host); 2290 slave_host) ? slave_host : master->host);
2293 delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host); 2291 delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host);
2294 if ((NULL != slave_host) && (0 != slave_host_id)) 2292 if ((NULL != slave_host) && (0 != slave_host_id))
2295 GNUNET_assert (GNUNET_YES == 2293 GNUNET_assert (GNUNET_YES ==
2296 GNUNET_TESTBED_is_host_registered_ (slave_host, master)); 2294 GNUNET_TESTBED_is_host_registered_ (slave_host, master));
2297 return GNUNET_TESTBED_controller_link_ (op_cls, master, 2295 return GNUNET_TESTBED_controller_link_ (op_cls, master, delegated_host_id,
2298 delegated_host_id, 2296 slave_host_id, slave_cfg,
2299 slave_host_id,
2300 slave_cfg,
2301 is_subordinate); 2297 is_subordinate);
2302 2298
2303} 2299}
2304 2300
2305 2301
@@ -2319,7 +2315,7 @@ struct GNUNET_TESTBED_Operation *
2319GNUNET_TESTBED_get_slave_config_ (void *op_cls, 2315GNUNET_TESTBED_get_slave_config_ (void *op_cls,
2320 struct GNUNET_TESTBED_Controller *master, 2316 struct GNUNET_TESTBED_Controller *master,
2321 uint32_t slave_host_id) 2317 uint32_t slave_host_id)
2322{ 2318{
2323 struct OperationContext *opc; 2319 struct OperationContext *opc;
2324 struct GetSlaveConfigData *data; 2320 struct GetSlaveConfigData *data;
2325 2321
@@ -2336,7 +2332,7 @@ GNUNET_TESTBED_get_slave_config_ (void *op_cls,
2336 GNUNET_TESTBED_operation_create_ (opc, &opstart_get_slave_config, 2332 GNUNET_TESTBED_operation_create_ (opc, &opstart_get_slave_config,
2337 &oprelease_get_slave_config); 2333 &oprelease_get_slave_config);
2338 GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, 2334 GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations,
2339 opc->op); 2335 opc->op);
2340 GNUNET_TESTBED_operation_begin_wait_ (opc->op); 2336 GNUNET_TESTBED_operation_begin_wait_ (opc->op);
2341 return opc->op; 2337 return opc->op;
2342} 2338}
@@ -2365,7 +2361,8 @@ GNUNET_TESTBED_get_slave_config (void *op_cls,
2365 if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_ (slave_host, master)) 2361 if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_ (slave_host, master))
2366 return NULL; 2362 return NULL;
2367 return GNUNET_TESTBED_get_slave_config_ (op_cls, master, 2363 return GNUNET_TESTBED_get_slave_config_ (op_cls, master,
2368 GNUNET_TESTBED_host_get_id_ (slave_host)); 2364 GNUNET_TESTBED_host_get_id_
2365 (slave_host));
2369} 2366}
2370 2367
2371 2368
@@ -2402,7 +2399,7 @@ GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller
2402 */ 2399 */
2403struct GNUNET_TESTBED_HelperInit * 2400struct GNUNET_TESTBED_HelperInit *
2404GNUNET_TESTBED_create_helper_init_msg_ (const char *trusted_ip, 2401GNUNET_TESTBED_create_helper_init_msg_ (const char *trusted_ip,
2405 const char *hostname, 2402 const char *hostname,
2406 const struct GNUNET_CONFIGURATION_Handle 2403 const struct GNUNET_CONFIGURATION_Handle
2407 *cfg) 2404 *cfg)
2408{ 2405{
@@ -2423,12 +2420,12 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *trusted_ip,
2423 trusted_ip_len = strlen (trusted_ip); 2420 trusted_ip_len = strlen (trusted_ip);
2424 hostname_len = (NULL == hostname) ? 0 : strlen (hostname); 2421 hostname_len = (NULL == hostname) ? 0 : strlen (hostname);
2425 msg_size = 2422 msg_size =
2426 xconfig_size + trusted_ip_len + 1 + sizeof (struct GNUNET_TESTBED_HelperInit); 2423 xconfig_size + trusted_ip_len + 1 +
2424 sizeof (struct GNUNET_TESTBED_HelperInit);
2427 msg_size += hostname_len; 2425 msg_size += hostname_len;
2428 msg = GNUNET_realloc (xconfig, msg_size); 2426 msg = GNUNET_realloc (xconfig, msg_size);
2429 (void) memmove (((void *) &msg[1]) + trusted_ip_len + 1 + hostname_len, 2427 (void) memmove (((void *) &msg[1]) + trusted_ip_len + 1 + hostname_len, msg,
2430 msg, 2428 xconfig_size);
2431 xconfig_size);
2432 msg->header.size = htons (msg_size); 2429 msg->header.size = htons (msg_size);
2433 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT); 2430 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT);
2434 msg->trusted_ip_size = htons (trusted_ip_len); 2431 msg->trusted_ip_size = htons (trusted_ip_len);
@@ -2436,7 +2433,8 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *trusted_ip,
2436 msg->config_size = htons (config_size); 2433 msg->config_size = htons (config_size);
2437 (void) strcpy ((char *) &msg[1], trusted_ip); 2434 (void) strcpy ((char *) &msg[1], trusted_ip);
2438 if (0 != hostname_len) 2435 if (0 != hostname_len)
2439 (void) strncpy (((char *) &msg[1]) + trusted_ip_len + 1, hostname, hostname_len); 2436 (void) strncpy (((char *) &msg[1]) + trusted_ip_len + 1, hostname,
2437 hostname_len);
2440 return msg; 2438 return msg;
2441} 2439}
2442 2440
@@ -2469,7 +2467,7 @@ GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation)
2469void 2467void
2470GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation) 2468GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation)
2471{ 2469{
2472 GNUNET_TESTBED_operation_release_ (operation); 2470 GNUNET_TESTBED_operation_release_ (operation);
2473} 2471}
2474 2472
2475 2473
@@ -2484,7 +2482,7 @@ GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation)
2484 */ 2482 */
2485struct GNUNET_CONFIGURATION_Handle * 2483struct GNUNET_CONFIGURATION_Handle *
2486GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg) 2484GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg)
2487{ 2485{
2488 struct GNUNET_CONFIGURATION_Handle *cfg; 2486 struct GNUNET_CONFIGURATION_Handle *cfg;
2489 Bytef *data; 2487 Bytef *data;
2490 const Bytef *xdata; 2488 const Bytef *xdata;
@@ -2495,35 +2493,35 @@ GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg)
2495 switch (ntohs (msg->type)) 2493 switch (ntohs (msg->type))
2496 { 2494 {
2497 case GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG: 2495 case GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG:
2498 { 2496 {
2499 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg; 2497 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg;
2500 2498
2501 imsg = (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) 2499 imsg =
2502 msg; 2500 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg;
2503 data_len = (uLong) ntohs (imsg->config_size); 2501 data_len = (uLong) ntohs (imsg->config_size);
2504 xdata_len = ntohs (imsg->header.size) 2502 xdata_len =
2505 - sizeof (struct GNUNET_TESTBED_PeerConfigurationInformationMessage); 2503 ntohs (imsg->header.size) -
2506 xdata = (const Bytef *) &imsg[1]; 2504 sizeof (struct GNUNET_TESTBED_PeerConfigurationInformationMessage);
2507 } 2505 xdata = (const Bytef *) &imsg[1];
2506 }
2508 break; 2507 break;
2509 case GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG: 2508 case GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG:
2510 { 2509 {
2511 const struct GNUNET_TESTBED_SlaveConfiguration *imsg; 2510 const struct GNUNET_TESTBED_SlaveConfiguration *imsg;
2512 2511
2513 imsg = (const struct GNUNET_TESTBED_SlaveConfiguration *) msg; 2512 imsg = (const struct GNUNET_TESTBED_SlaveConfiguration *) msg;
2514 data_len = (uLong) ntohs (imsg->config_size); 2513 data_len = (uLong) ntohs (imsg->config_size);
2515 xdata_len = ntohs (imsg->header.size) 2514 xdata_len =
2516 - sizeof (struct GNUNET_TESTBED_SlaveConfiguration); 2515 ntohs (imsg->header.size) -
2517 xdata = (const Bytef *) &imsg[1]; 2516 sizeof (struct GNUNET_TESTBED_SlaveConfiguration);
2518 } 2517 xdata = (const Bytef *) &imsg[1];
2518 }
2519 break; 2519 break;
2520 default: 2520 default:
2521 GNUNET_assert (0); 2521 GNUNET_assert (0);
2522 } 2522 }
2523 data = GNUNET_malloc (data_len); 2523 data = GNUNET_malloc (data_len);
2524 if (Z_OK != 2524 if (Z_OK != (ret = uncompress (data, &data_len, xdata, xdata_len)))
2525 (ret =
2526 uncompress (data, &data_len, xdata, xdata_len)))
2527 GNUNET_assert (0); 2525 GNUNET_assert (0);
2528 cfg = GNUNET_CONFIGURATION_create (); 2526 cfg = GNUNET_CONFIGURATION_create ();
2529 GNUNET_assert (GNUNET_OK == 2527 GNUNET_assert (GNUNET_OK ==
@@ -2549,7 +2547,7 @@ GNUNET_TESTBED_parse_error_string_ (const struct
2549{ 2547{
2550 uint16_t msize; 2548 uint16_t msize;
2551 const char *emsg; 2549 const char *emsg;
2552 2550
2553 msize = ntohs (msg->header.size); 2551 msize = ntohs (msg->header.size);
2554 if (sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage) >= msize) 2552 if (sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage) >= msize)
2555 return NULL; 2553 return NULL;
@@ -2572,12 +2570,12 @@ GNUNET_TESTBED_parse_error_string_ (const struct
2572 * @return the incremented operation id. 2570 * @return the incremented operation id.
2573 */ 2571 */
2574uint64_t 2572uint64_t
2575GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller) 2573GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller * controller)
2576{ 2574{
2577 uint64_t op_id; 2575 uint64_t op_id;
2578 2576
2579 op_id = (uint64_t) GNUNET_TESTBED_host_get_id_ (controller->host); 2577 op_id = (uint64_t) GNUNET_TESTBED_host_get_id_ (controller->host);
2580 op_id = op_id << 32; 2578 op_id = op_id << 32;
2581 op_id |= (uint64_t) controller->operation_counter++; 2579 op_id |= (uint64_t) controller->operation_counter++;
2582 return op_id; 2580 return op_id;
2583} 2581}
@@ -2639,24 +2637,27 @@ decide_npoc (struct GNUNET_TESTBED_Controller *c)
2639 if (GNUNET_SYSERR == sd) 2637 if (GNUNET_SYSERR == sd)
2640 { 2638 {
2641 SD_add_data (c->poc_sd, (unsigned int) avg.rel_value); 2639 SD_add_data (c->poc_sd, (unsigned int) avg.rel_value);
2642 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c, c->num_parallel_connects); 2640 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
2641 c->num_parallel_connects);
2643 return; 2642 return;
2644 } 2643 }
2645 GNUNET_assert (0 <= sd); 2644 GNUNET_assert (0 <= sd);
2646 if (0 == sd) 2645 if (0 == sd)
2647 { 2646 {
2648 SD_add_data (c->poc_sd, (unsigned int) avg.rel_value); 2647 SD_add_data (c->poc_sd, (unsigned int) avg.rel_value);
2649 GNUNET_TESTBED_set_num_parallel_overlay_connects_ 2648 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
2650 (c, c->num_parallel_connects * 2); 2649 c->num_parallel_connects
2650 * 2);
2651 return; 2651 return;
2652 } 2652 }
2653 if (1 == sd) 2653 if (1 == sd)
2654 { 2654 {
2655 SD_add_data (c->poc_sd, (unsigned int) avg.rel_value); 2655 SD_add_data (c->poc_sd, (unsigned int) avg.rel_value);
2656 GNUNET_TESTBED_set_num_parallel_overlay_connects_ 2656 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
2657 (c, c->num_parallel_connects + 1); 2657 c->num_parallel_connects
2658 + 1);
2658 return; 2659 return;
2659 } 2660 }
2660 if (1 == c->num_parallel_connects) 2661 if (1 == c->num_parallel_connects)
2661 { 2662 {
2662 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c, 1); 2663 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c, 1);
@@ -2665,12 +2666,14 @@ decide_npoc (struct GNUNET_TESTBED_Controller *c)
2665 if (2 == sd) 2666 if (2 == sd)
2666 { 2667 {
2667 SD_add_data (c->poc_sd, (unsigned int) avg.rel_value); 2668 SD_add_data (c->poc_sd, (unsigned int) avg.rel_value);
2668 GNUNET_TESTBED_set_num_parallel_overlay_connects_ 2669 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
2669 (c, c->num_parallel_connects - 1); 2670 c->num_parallel_connects
2671 - 1);
2670 return; 2672 return;
2671 } 2673 }
2672 GNUNET_TESTBED_set_num_parallel_overlay_connects_ 2674 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
2673 (c, c->num_parallel_connects / 2); 2675 c->num_parallel_connects /
2676 2);
2674} 2677}
2675 2678
2676 2679
@@ -2686,8 +2689,7 @@ decide_npoc (struct GNUNET_TESTBED_Controller *c)
2686 */ 2689 */
2687int 2690int
2688GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Controller *c, 2691GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Controller *c,
2689 unsigned int index, 2692 unsigned int index, void *key)
2690 void *key)
2691{ 2693{
2692 struct TimeSlot *slot; 2694 struct TimeSlot *slot;
2693 2695
@@ -2713,10 +2715,8 @@ GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Controller *c,
2713 */ 2715 */
2714void 2716void
2715GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c, 2717GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c,
2716 unsigned int index, 2718 unsigned int index, void *key,
2717 void *key, 2719 struct GNUNET_TIME_Relative time, int failed)
2718 struct GNUNET_TIME_Relative time,
2719 int failed)
2720{ 2720{
2721 struct TimeSlot *slot; 2721 struct TimeSlot *slot;
2722 2722
@@ -2727,8 +2727,9 @@ GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c,
2727 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c, 1); 2727 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c, 1);
2728 return; 2728 return;
2729 } 2729 }
2730 GNUNET_TESTBED_set_num_parallel_overlay_connects_ 2730 GNUNET_TESTBED_set_num_parallel_overlay_connects_ (c,
2731 (c, c->num_parallel_connects - 1); 2731 c->num_parallel_connects
2732 - 1);
2732 } 2733 }
2733 if (GNUNET_NO == GNUNET_TESTBED_release_time_slot_ (c, index, key)) 2734 if (GNUNET_NO == GNUNET_TESTBED_release_time_slot_ (c, index, key))
2734 return; 2735 return;
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index 7586ed28d..d6c04a6a2 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -86,7 +86,6 @@ enum OperationType
86 * Get slave config operation 86 * Get slave config operation
87 */ 87 */
88 OP_GET_SLAVE_CONFIG 88 OP_GET_SLAVE_CONFIG
89
90}; 89};
91 90
92 91
@@ -193,7 +192,7 @@ struct TimeSlot
193 * A key to identify this timeslot 192 * A key to identify this timeslot
194 */ 193 */
195 void *key; 194 void *key;
196 195
197 /** 196 /**
198 * Time 197 * Time
199 */ 198 */
@@ -305,7 +304,7 @@ struct GNUNET_TESTBED_Controller
305 304
306 /** 305 /**
307 * An array of timing slots; size should be equal to the current number of parallel 306 * An array of timing slots; size should be equal to the current number of parallel
308 * overlay connects 307 * overlay connects
309 */ 308 */
310 struct TimeSlot *tslots; 309 struct TimeSlot *tslots;
311 310
@@ -319,7 +318,7 @@ struct GNUNET_TESTBED_Controller
319 * The controller event mask 318 * The controller event mask
320 */ 319 */
321 uint64_t event_mask; 320 uint64_t event_mask;
322 321
323 /** 322 /**
324 * Did we start the receive loop yet? 323 * Did we start the receive loop yet?
325 */ 324 */
@@ -396,8 +395,7 @@ GNUNET_TESTBED_operation_add_ (struct GNUNET_TESTBED_Operation *op);
396 * @return the initialization message 395 * @return the initialization message
397 */ 396 */
398struct GNUNET_TESTBED_HelperInit * 397struct GNUNET_TESTBED_HelperInit *
399GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, 398GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, const char *hostname,
400 const char *hostname,
401 const struct GNUNET_CONFIGURATION_Handle 399 const struct GNUNET_CONFIGURATION_Handle
402 *cfg); 400 *cfg);
403 401
@@ -510,9 +508,9 @@ struct GNUNET_TESTBED_Operation *
510GNUNET_TESTBED_controller_link_2_ (void *op_cls, 508GNUNET_TESTBED_controller_link_2_ (void *op_cls,
511 struct GNUNET_TESTBED_Controller *master, 509 struct GNUNET_TESTBED_Controller *master,
512 uint32_t delegated_host_id, 510 uint32_t delegated_host_id,
513 uint32_t slave_host_id, 511 uint32_t slave_host_id, const char *sxcfg,
514 const char *sxcfg, size_t sxcfg_size, 512 size_t sxcfg_size, size_t scfg_size,
515 size_t scfg_size, int is_subordinate); 513 int is_subordinate);
516 514
517 515
518/** 516/**
@@ -536,12 +534,11 @@ GNUNET_TESTBED_controller_link_2_ (void *op_cls,
536 */ 534 */
537struct GNUNET_TESTBED_Operation * 535struct GNUNET_TESTBED_Operation *
538GNUNET_TESTBED_controller_link_ (void *op_cls, 536GNUNET_TESTBED_controller_link_ (void *op_cls,
539 struct GNUNET_TESTBED_Controller *master, 537 struct GNUNET_TESTBED_Controller *master,
540 uint32_t delegated_host_id, 538 uint32_t delegated_host_id,
541 uint32_t slave_host_id, 539 uint32_t slave_host_id,
542 const struct GNUNET_CONFIGURATION_Handle 540 const struct GNUNET_CONFIGURATION_Handle
543 *slave_cfg, 541 *slave_cfg, int is_subordinate);
544 int is_subordinate);
545 542
546 543
547/** 544/**
@@ -568,10 +565,8 @@ GNUNET_TESTBED_get_tslot_ (struct GNUNET_TESTBED_Controller *c, void *key);
568 */ 565 */
569void 566void
570GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c, 567GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c,
571 unsigned int index, 568 unsigned int index, void *key,
572 void *key, 569 struct GNUNET_TIME_Relative time, int failed);
573 struct GNUNET_TIME_Relative time,
574 int failed);
575 570
576 571
577/** 572/**
@@ -586,8 +581,7 @@ GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Controller *c,
586 */ 581 */
587int 582int
588GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Controller *c, 583GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Controller *c,
589 unsigned int index, 584 unsigned int index, void *key);
590 void *key);
591 585
592 586
593 587
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 8bba56d6c..293f3493b 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -332,18 +332,18 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
332 if (((data[offset] == '\n')) && (buf != &data[offset])) 332 if (((data[offset] == '\n')) && (buf != &data[offset]))
333 { 333 {
334 data[offset] = '\0'; 334 data[offset] = '\0';
335 ret = SSCANF (buf, "%255[a-zA-Z0-9_]@%255[a-zA-Z0-9.]:%5hd", 335 ret =
336 username, hostname, &port); 336 SSCANF (buf, "%255[a-zA-Z0-9_]@%255[a-zA-Z0-9.]:%5hd", username,
337 if (3 == ret) 337 hostname, &port);
338 if (3 == ret)
338 { 339 {
339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
340 "Successfully read host %s, port %d and user %s from file\n", 341 "Successfully read host %s, port %d and user %s from file\n",
341 hostname, port, username); 342 hostname, port, username);
342 /* We store hosts in a static list; hence we only require the starting 343 /* We store hosts in a static list; hence we only require the starting
343 host pointer in that list to access the newly created list of hosts */ 344 * host pointer in that list to access the newly created list of hosts */
344 if (NULL == starting_host) 345 if (NULL == starting_host)
345 starting_host = GNUNET_TESTBED_host_create (hostname, username, 346 starting_host = GNUNET_TESTBED_host_create (hostname, username, port);
346 port);
347 else 347 else
348 (void) GNUNET_TESTBED_host_create (hostname, username, port); 348 (void) GNUNET_TESTBED_host_create (hostname, username, port);
349 count++; 349 count++;
@@ -360,8 +360,7 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
360 if (NULL == starting_host) 360 if (NULL == starting_host)
361 return 0; 361 return 0;
362 *hosts = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * count); 362 *hosts = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * count);
363 memcpy (*hosts, 363 memcpy (*hosts, &host_list[GNUNET_TESTBED_host_get_id_ (starting_host)],
364 &host_list[GNUNET_TESTBED_host_get_id_ (starting_host)],
365 sizeof (struct GNUNET_TESTBED_Host *) * count); 364 sizeof (struct GNUNET_TESTBED_Host *) * count);
366 return count; 365 return count;
367} 366}
@@ -475,7 +474,7 @@ struct GNUNET_TESTBED_HostHabitableCheckHandle
475 /* * the configuration handle to lookup the path of the testbed helper */ 474 /* * the configuration handle to lookup the path of the testbed helper */
476 /* *\/ */ 475 /* *\/ */
477 /* const struct GNUNET_CONFIGURATION_Handle *cfg; */ 476 /* const struct GNUNET_CONFIGURATION_Handle *cfg; */
478 477
479 /** 478 /**
480 * The callback to call once we have the status 479 * The callback to call once we have the status
481 */ 480 */
@@ -549,15 +548,14 @@ habitability_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
549 { 548 {
550 h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time); 549 h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time);
551 h->habitability_check_task = 550 h->habitability_check_task =
552 GNUNET_SCHEDULER_add_delayed (h->wait_time, 551 GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
553 &habitability_check, h);
554 return; 552 return;
555 } 553 }
556 GNUNET_OS_process_destroy (h->auxp); 554 GNUNET_OS_process_destroy (h->auxp);
557 h->auxp = NULL; 555 h->auxp = NULL;
558 ret = (0 != code) ? GNUNET_NO : GNUNET_YES; 556 ret = (0 != code) ? GNUNET_NO : GNUNET_YES;
559 557
560 call_cb: 558call_cb:
561 GNUNET_free (h->ssh_addr); 559 GNUNET_free (h->ssh_addr);
562 GNUNET_free (h->portstr); 560 GNUNET_free (h->portstr);
563 GNUNET_free (h->helper_binary_path); 561 GNUNET_free (h->helper_binary_path);
@@ -604,9 +602,10 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
604 h->ssh_addr = GNUNET_strdup (hostname); 602 h->ssh_addr = GNUNET_strdup (hostname);
605 else 603 else
606 GNUNET_asprintf (&h->ssh_addr, "%s@%s", host->username, hostname); 604 GNUNET_asprintf (&h->ssh_addr, "%s@%s", host->username, hostname);
607 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (config, "testbed", 605 if (GNUNET_OK !=
608 "HELPER_BINARY_PATH", 606 GNUNET_CONFIGURATION_get_value_string (config, "testbed",
609 &h->helper_binary_path)) 607 "HELPER_BINARY_PATH",
608 &h->helper_binary_path))
610 h->helper_binary_path = 609 h->helper_binary_path =
611 GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY); 610 GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
612 argp = 0; 611 argp = 0;
@@ -628,7 +627,7 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
628 NULL, "ssh", remote_args); 627 NULL, "ssh", remote_args);
629 if (NULL == h->auxp) 628 if (NULL == h->auxp)
630 { 629 {
631 GNUNET_break (0); /* Cannot exec SSH? */ 630 GNUNET_break (0); /* Cannot exec SSH? */
632 GNUNET_free (h->ssh_addr); 631 GNUNET_free (h->ssh_addr);
633 GNUNET_free (h->portstr); 632 GNUNET_free (h->portstr);
634 GNUNET_free (h->helper_binary_path); 633 GNUNET_free (h->helper_binary_path);
@@ -637,8 +636,7 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
637 } 636 }
638 h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time); 637 h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time);
639 h->habitability_check_task = 638 h->habitability_check_task =
640 GNUNET_SCHEDULER_add_delayed (h->wait_time, 639 GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
641 &habitability_check, h);
642 return h; 640 return h;
643} 641}
644 642
@@ -662,4 +660,5 @@ GNUNET_TESTBED_is_host_habitable_cancel (struct
662 GNUNET_free (handle->helper_binary_path); 660 GNUNET_free (handle->helper_binary_path);
663 GNUNET_free (handle); 661 GNUNET_free (handle);
664} 662}
663
665/* end of testbed_api_hosts.c */ 664/* end of testbed_api_hosts.c */
diff --git a/src/testbed/testbed_api_operations.c b/src/testbed/testbed_api_operations.c
index 139448d91..3e7eb91bd 100644
--- a/src/testbed/testbed_api_operations.c
+++ b/src/testbed/testbed_api_operations.c
@@ -92,17 +92,17 @@ enum OperationState
92 * The operation is just created and is in initial state 92 * The operation is just created and is in initial state
93 */ 93 */
94 OP_STATE_INIT, 94 OP_STATE_INIT,
95 95
96 /** 96 /**
97 * The operation is currently waiting for resources 97 * The operation is currently waiting for resources
98 */ 98 */
99 OP_STATE_WAITING, 99 OP_STATE_WAITING,
100 100
101 /** 101 /**
102 * The operation is ready to be started 102 * The operation is ready to be started
103 */ 103 */
104 OP_STATE_READY, 104 OP_STATE_READY,
105 105
106 /** 106 /**
107 * The operation has started 107 * The operation has started
108 */ 108 */
@@ -292,14 +292,13 @@ GNUNET_TESTBED_operation_queue_reset_max_active_ (struct OperationQueue *queue,
292 unsigned int max_active) 292 unsigned int max_active)
293{ 293{
294 struct QueueEntry *entry; 294 struct QueueEntry *entry;
295 295
296 queue->max_active = max_active; 296 queue->max_active = max_active;
297 /* if (queue->active >= queue->max_active) */ 297 /* if (queue->active >= queue->max_active) */
298 /* return; */ 298 /* return; */
299 299
300 entry = queue->head; 300 entry = queue->head;
301 while ( (queue->active > queue->max_active) && 301 while ((queue->active > queue->max_active) && (NULL != entry))
302 (NULL != entry))
303 { 302 {
304 if (entry->op->state == OP_STATE_READY) 303 if (entry->op->state == OP_STATE_READY)
305 defer (entry->op); 304 defer (entry->op);
@@ -307,8 +306,7 @@ GNUNET_TESTBED_operation_queue_reset_max_active_ (struct OperationQueue *queue,
307 } 306 }
308 307
309 entry = queue->head; 308 entry = queue->head;
310 while ( (NULL != entry) && 309 while ((NULL != entry) && (queue->active < queue->max_active))
311 (queue->active < queue->max_active) )
312 { 310 {
313 if (OP_STATE_WAITING == entry->op->state) 311 if (OP_STATE_WAITING == entry->op->state)
314 check_readiness (entry->op); 312 check_readiness (entry->op);
@@ -331,8 +329,7 @@ GNUNET_TESTBED_operation_queue_reset_max_active_ (struct OperationQueue *queue,
331void 329void
332GNUNET_TESTBED_operation_queue_insert2_ (struct OperationQueue *queue, 330GNUNET_TESTBED_operation_queue_insert2_ (struct OperationQueue *queue,
333 struct GNUNET_TESTBED_Operation 331 struct GNUNET_TESTBED_Operation
334 *operation, 332 *operation, unsigned int nres)
335 unsigned int nres)
336{ 333{
337 struct QueueEntry *entry; 334 struct QueueEntry *entry;
338 unsigned int qsize; 335 unsigned int qsize;
@@ -380,7 +377,7 @@ GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue,
380 */ 377 */
381void 378void
382GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation 379GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation
383 *operation) 380 *operation)
384{ 381{
385 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == operation->start_task_id); 382 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == operation->start_task_id);
386 operation->state = OP_STATE_WAITING; 383 operation->state = OP_STATE_WAITING;
diff --git a/src/testbed/testbed_api_operations.h b/src/testbed/testbed_api_operations.h
index 2f0ef19b6..61b45e236 100644
--- a/src/testbed/testbed_api_operations.h
+++ b/src/testbed/testbed_api_operations.h
@@ -85,8 +85,7 @@ GNUNET_TESTBED_operation_queue_reset_max_active_ (struct OperationQueue *queue,
85void 85void
86GNUNET_TESTBED_operation_queue_insert2_ (struct OperationQueue *queue, 86GNUNET_TESTBED_operation_queue_insert2_ (struct OperationQueue *queue,
87 struct GNUNET_TESTBED_Operation 87 struct GNUNET_TESTBED_Operation
88 *operation, 88 *operation, unsigned int nres);
89 unsigned int nres);
90 89
91 90
92/** 91/**
@@ -115,7 +114,7 @@ GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue,
115 */ 114 */
116void 115void
117GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation 116GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation
118 *operation); 117 *operation);
119 118
120 119
121/** 120/**
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c
index 1c0e87557..9105793f1 100644
--- a/src/testbed/testbed_api_peers.c
+++ b/src/testbed/testbed_api_peers.c
@@ -378,8 +378,8 @@ oprelease_overlay_connect (void *cls)
378 break; 378 break;
379 case OPC_STATE_FINISHED: 379 case OPC_STATE_FINISHED:
380 duration = GNUNET_TIME_absolute_get_duration (data->tstart); 380 duration = GNUNET_TIME_absolute_get_duration (data->tstart);
381 GNUNET_TESTBED_update_time_slot_ (opc->c, data->tslot_index, 381 GNUNET_TESTBED_update_time_slot_ (opc->c, data->tslot_index, data, duration,
382 data, duration, data->failed); 382 data->failed);
383 } 383 }
384 GNUNET_free (data); 384 GNUNET_free (data);
385 GNUNET_free (opc); 385 GNUNET_free (opc);
@@ -435,7 +435,7 @@ GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller,
435 const struct GNUNET_CONFIGURATION_Handle *cfg, 435 const struct GNUNET_CONFIGURATION_Handle *cfg,
436 GNUNET_TESTBED_PeerCreateCallback cb, void *cls) 436 GNUNET_TESTBED_PeerCreateCallback cb, void *cls)
437{ 437{
438 438
439 struct GNUNET_TESTBED_Peer *peer; 439 struct GNUNET_TESTBED_Peer *peer;
440 struct PeerCreateData *data; 440 struct PeerCreateData *data;
441 struct OperationContext *opc; 441 struct OperationContext *opc;
@@ -478,14 +478,12 @@ GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller,
478 * @return handle to the operation 478 * @return handle to the operation
479 */ 479 */
480struct GNUNET_TESTBED_Operation * 480struct GNUNET_TESTBED_Operation *
481GNUNET_TESTBED_peer_start (void *op_cls, 481GNUNET_TESTBED_peer_start (void *op_cls, struct GNUNET_TESTBED_Peer *peer,
482 struct GNUNET_TESTBED_Peer *peer, 482 GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
483 GNUNET_TESTBED_PeerChurnCallback pcc,
484 void *pcc_cls)
485{ 483{
486 struct OperationContext *opc; 484 struct OperationContext *opc;
487 struct PeerEventData *data; 485 struct PeerEventData *data;
488 486
489 data = GNUNET_malloc (sizeof (struct PeerEventData)); 487 data = GNUNET_malloc (sizeof (struct PeerEventData));
490 data->peer = peer; 488 data->peer = peer;
491 data->pcc = pcc; 489 data->pcc = pcc;
@@ -518,12 +516,11 @@ GNUNET_TESTBED_peer_start (void *op_cls,
518 */ 516 */
519struct GNUNET_TESTBED_Operation * 517struct GNUNET_TESTBED_Operation *
520GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer, 518GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer,
521 GNUNET_TESTBED_PeerChurnCallback pcc, 519 GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
522 void *pcc_cls)
523{ 520{
524 struct OperationContext *opc; 521 struct OperationContext *opc;
525 struct PeerEventData *data; 522 struct PeerEventData *data;
526 523
527 data = GNUNET_malloc (sizeof (struct PeerEventData)); 524 data = GNUNET_malloc (sizeof (struct PeerEventData));
528 data->peer = peer; 525 data->peer = peer;
529 data->pcc = pcc; 526 data->pcc = pcc;
@@ -558,10 +555,9 @@ GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer,
558 */ 555 */
559struct GNUNET_TESTBED_Operation * 556struct GNUNET_TESTBED_Operation *
560GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, 557GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
561 enum GNUNET_TESTBED_PeerInformationType 558 enum GNUNET_TESTBED_PeerInformationType
562 pit, 559 pit, GNUNET_TESTBED_PeerInfoCallback cb,
563 GNUNET_TESTBED_PeerInfoCallback cb, 560 void *cb_cls)
564 void *cb_cls)
565{ 561{
566 struct OperationContext *opc; 562 struct OperationContext *opc;
567 struct PeerInfoData *data; 563 struct PeerInfoData *data;
@@ -676,9 +672,8 @@ GNUNET_TESTBED_underlay_configure_link (void *op_cls,
676struct GNUNET_TESTBED_Operation * 672struct GNUNET_TESTBED_Operation *
677GNUNET_TESTBED_overlay_connect (void *op_cls, 673GNUNET_TESTBED_overlay_connect (void *op_cls,
678 GNUNET_TESTBED_OperationCompletionCallback cb, 674 GNUNET_TESTBED_OperationCompletionCallback cb,
679 void *cb_cls, 675 void *cb_cls, struct GNUNET_TESTBED_Peer *p1,
680 struct GNUNET_TESTBED_Peer *p1, 676 struct GNUNET_TESTBED_Peer *p2)
681 struct GNUNET_TESTBED_Peer *p2)
682{ 677{
683 struct OperationContext *opc; 678 struct OperationContext *opc;
684 struct OverlayConnectData *data; 679 struct OverlayConnectData *data;
@@ -698,8 +693,9 @@ GNUNET_TESTBED_overlay_connect (void *op_cls,
698 opc->op = 693 opc->op =
699 GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect, 694 GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect,
700 &oprelease_overlay_connect); 695 &oprelease_overlay_connect);
701 GNUNET_TESTBED_operation_queue_insert_ 696 GNUNET_TESTBED_operation_queue_insert_ (opc->
702 (opc->c->opq_parallel_overlay_connect_operations, opc->op); 697 c->opq_parallel_overlay_connect_operations,
698 opc->op);
703 GNUNET_TESTBED_operation_begin_wait_ (opc->op); 699 GNUNET_TESTBED_operation_begin_wait_ (opc->op);
704 return opc->op; 700 return opc->op;
705} 701}
diff --git a/src/testbed/testbed_api_peers.h b/src/testbed/testbed_api_peers.h
index b1f226214..8598cc177 100644
--- a/src/testbed/testbed_api_peers.h
+++ b/src/testbed/testbed_api_peers.h
@@ -130,17 +130,17 @@ struct PeerEventData
130 * The handle of the peer to start 130 * The handle of the peer to start
131 */ 131 */
132 struct GNUNET_TESTBED_Peer *peer; 132 struct GNUNET_TESTBED_Peer *peer;
133 133
134 /** 134 /**
135 * The Peer churn callback to call when this operation is completed 135 * The Peer churn callback to call when this operation is completed
136 */ 136 */
137 GNUNET_TESTBED_PeerChurnCallback pcc; 137 GNUNET_TESTBED_PeerChurnCallback pcc;
138 138
139 /** 139 /**
140 * Closure for the above callback 140 * Closure for the above callback
141 */ 141 */
142 void *pcc_cls; 142 void *pcc_cls;
143 143
144}; 144};
145 145
146 146
@@ -172,7 +172,7 @@ struct PeerInfoData
172 * The Peer info callback to call when this operation has completed 172 * The Peer info callback to call when this operation has completed
173 */ 173 */
174 GNUNET_TESTBED_PeerInfoCallback cb; 174 GNUNET_TESTBED_PeerInfoCallback cb;
175 175
176 /** 176 /**
177 * The closure for peer info callback 177 * The closure for peer info callback
178 */ 178 */
@@ -205,7 +205,7 @@ struct OverlayConnectData
205 * The operation completion callback to call once this operation is done 205 * The operation completion callback to call once this operation is done
206 */ 206 */
207 GNUNET_TESTBED_OperationCompletionCallback cb; 207 GNUNET_TESTBED_OperationCompletionCallback cb;
208 208
209 /** 209 /**
210 * The closure for the above callback 210 * The closure for the above callback
211 */ 211 */
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c
index c755a13a5..0c3d63de7 100644
--- a/src/testbed/testbed_api_services.c
+++ b/src/testbed/testbed_api_services.c
@@ -43,12 +43,11 @@ enum State
43 * The configuration request has been sent 43 * The configuration request has been sent
44 */ 44 */
45 CFG_REQUEST_QUEUED, 45 CFG_REQUEST_QUEUED,
46 46
47 /** 47 /**
48 * connected to service 48 * connected to service
49 */ 49 */
50 SERVICE_CONNECTED 50 SERVICE_CONNECTED
51
52}; 51};
53 52
54 53
@@ -149,23 +148,24 @@ configuration_receiver (void *cls, const struct GNUNET_MessageHeader *msg)
149 info.details.operation_finished.op_cls = data->op_cls; 148 info.details.operation_finished.op_cls = data->op_cls;
150 if (GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONFAILEVENT == mtype) 149 if (GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONFAILEVENT == mtype)
151 { 150 {
152 emsg = GNUNET_TESTBED_parse_error_string_ ((const struct 151 emsg =
153 GNUNET_TESTBED_OperationFailureEventMessage 152 GNUNET_TESTBED_parse_error_string_ ((const struct
154 *) msg); 153 GNUNET_TESTBED_OperationFailureEventMessage
154 *) msg);
155 if (NULL == emsg) 155 if (NULL == emsg)
156 emsg = "Unknown error"; 156 emsg = "Unknown error";
157 info.details.operation_finished.emsg = emsg; 157 info.details.operation_finished.emsg = emsg;
158 info.details.operation_finished.generic = NULL; 158 info.details.operation_finished.generic = NULL;
159 goto call_cb; 159 goto call_cb;
160 } 160 }
161 data->cfg = GNUNET_TESTBED_extract_config_ (msg); 161 data->cfg = GNUNET_TESTBED_extract_config_ (msg);
162 GNUNET_assert (NULL == data->op_result); 162 GNUNET_assert (NULL == data->op_result);
163 data->op_result = data->ca (data->cada_cls, data->cfg); 163 data->op_result = data->ca (data->cada_cls, data->cfg);
164 info.details.operation_finished.emsg = NULL; 164 info.details.operation_finished.emsg = NULL;
165 info.details.operation_finished.generic = data->op_result; 165 info.details.operation_finished.generic = data->op_result;
166 data->state = SERVICE_CONNECTED; 166 data->state = SERVICE_CONNECTED;
167 167
168 call_cb: 168call_cb:
169 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) && 169 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) &&
170 (NULL != c->cc)) 170 (NULL != c->cc))
171 c->cc (c->cc_cls, &info); 171 c->cc (c->cc_cls, &info);
@@ -237,7 +237,7 @@ oprelease_service_connect (void *cls)
237 * maintain connections with other systems. The actual service 237 * maintain connections with other systems. The actual service
238 * handle is then returned via the 'op_result' member in the event 238 * handle is then returned via the 'op_result' member in the event
239 * callback. The 'ca' callback is used to create the connection 239 * callback. The 'ca' callback is used to create the connection
240 * when the time is right; the 'da' callback will be used to 240 * when the time is right; the 'da' callback will be used to
241 * destroy the connection (upon 'GNUNET_TESTBED_operation_done'). 241 * destroy the connection (upon 'GNUNET_TESTBED_operation_done').
242 * 'GNUNET_TESTBED_operation_cancel' can be used to abort this 242 * 'GNUNET_TESTBED_operation_cancel' can be used to abort this
243 * operation until the event callback has been called. 243 * operation until the event callback has been called.
@@ -253,14 +253,13 @@ oprelease_service_connect (void *cls)
253 * @return handle for the operation 253 * @return handle for the operation
254 */ 254 */
255struct GNUNET_TESTBED_Operation * 255struct GNUNET_TESTBED_Operation *
256GNUNET_TESTBED_service_connect (void *op_cls, 256GNUNET_TESTBED_service_connect (void *op_cls, struct GNUNET_TESTBED_Peer *peer,
257 struct GNUNET_TESTBED_Peer *peer, 257 const char *service_name,
258 const char *service_name, 258 GNUNET_TESTBED_ServiceConnectCompletionCallback
259 GNUNET_TESTBED_ServiceConnectCompletionCallback cb, 259 cb, void *cb_cls,
260 void *cb_cls, 260 GNUNET_TESTBED_ConnectAdapter ca,
261 GNUNET_TESTBED_ConnectAdapter ca, 261 GNUNET_TESTBED_DisconnectAdapter da,
262 GNUNET_TESTBED_DisconnectAdapter da, 262 void *cada_cls)
263 void *cada_cls)
264{ 263{
265 struct ServiceConnectData *data; 264 struct ServiceConnectData *data;
266 265
diff --git a/src/testbed/testbed_api_statistics.c b/src/testbed/testbed_api_statistics.c
index 0ee36151d..f013c0302 100644
--- a/src/testbed/testbed_api_statistics.c
+++ b/src/testbed/testbed_api_statistics.c
@@ -29,7 +29,7 @@
29 29
30 30
31/** 31/**
32 * Convenience method that iterates over all (running) peers 32 * Convenience method that iterates over all (running) peers
33 * and retrieves all statistics from each peer. 33 * and retrieves all statistics from each peer.
34 * 34 *
35 * @param num_peers number of peers to iterate over 35 * @param num_peers number of peers to iterate over
@@ -41,7 +41,7 @@
41 */ 41 */
42struct GNUNET_TESTBED_Operation * 42struct GNUNET_TESTBED_Operation *
43GNUNET_TESTBED_get_statistics (unsigned int num_peers, 43GNUNET_TESTBED_get_statistics (unsigned int num_peers,
44 struct GNUNET_TESTBED_Peer **peers, 44 struct GNUNET_TESTBED_Peer **peers,
45 GNUNET_TESTBED_StatisticsIterator proc, 45 GNUNET_TESTBED_StatisticsIterator proc,
46 GNUNET_TESTBED_OperationCompletionCallback cont, 46 GNUNET_TESTBED_OperationCompletionCallback cont,
47 void *cls) 47 void *cls)
diff --git a/src/testbed/testbed_api_test.c b/src/testbed/testbed_api_test.c
index 834f23c76..af91cec65 100644
--- a/src/testbed/testbed_api_test.c
+++ b/src/testbed/testbed_api_test.c
@@ -52,7 +52,7 @@ struct TestRunContext
52 * Closure for the above callback 52 * Closure for the above callback
53 */ 53 */
54 void *cc_cls; 54 void *cc_cls;
55 55
56 /** 56 /**
57 * event mask for the controller callback 57 * event mask for the controller callback
58 */ 58 */
@@ -79,8 +79,8 @@ run (void *cls, char *const *args, const char *cfgfile,
79{ 79{
80 struct TestRunContext *rc = cls; 80 struct TestRunContext *rc = cls;
81 81
82 GNUNET_TESTBED_run (NULL, config, rc->num_peers, rc->event_mask, 82 GNUNET_TESTBED_run (NULL, config, rc->num_peers, rc->event_mask, rc->cc,
83 rc->cc, rc->cc_cls, rc->test_master, rc->test_master_cls); 83 rc->cc_cls, rc->test_master, rc->test_master_cls);
84} 84}
85 85
86 86
@@ -119,10 +119,8 @@ run (void *cls, char *const *args, const char *cfgfile,
119 */ 119 */
120int 120int
121GNUNET_TESTBED_test_run (const char *testname, const char *cfg_filename, 121GNUNET_TESTBED_test_run (const char *testname, const char *cfg_filename,
122 unsigned int num_peers, 122 unsigned int num_peers, uint64_t event_mask,
123 uint64_t event_mask, 123 GNUNET_TESTBED_ControllerCallback cc, void *cc_cls,
124 GNUNET_TESTBED_ControllerCallback cc,
125 void *cc_cls,
126 GNUNET_TESTBED_TestMaster test_master, 124 GNUNET_TESTBED_TestMaster test_master,
127 void *test_master_cls) 125 void *test_master_cls)
128{ 126{
@@ -150,8 +148,9 @@ GNUNET_TESTBED_test_run (const char *testname, const char *cfg_filename,
150 rc->event_mask = event_mask; 148 rc->event_mask = event_mask;
151 rc->cc = cc; 149 rc->cc = cc;
152 rc->cc_cls = cc_cls; 150 rc->cc_cls = cc_cls;
153 ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 151 ret =
154 testname, "nohelp", options, &run, rc); 152 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
153 testname, "nohelp", options, &run, rc);
155 GNUNET_free (rc); 154 GNUNET_free (rc);
156 GNUNET_free (argv2[0]); 155 GNUNET_free (argv2[0]);
157 GNUNET_free (argv2[2]); 156 GNUNET_free (argv2[2]);
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index 24f17bc75..3177f8df8 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -156,7 +156,7 @@ struct RunContext
156 * TestMaster callback to call when testbed initialization is done 156 * TestMaster callback to call when testbed initialization is done
157 */ 157 */
158 GNUNET_TESTBED_TestMaster test_master; 158 GNUNET_TESTBED_TestMaster test_master;
159 159
160 /** 160 /**
161 * The closure for the TestMaster callback 161 * The closure for the TestMaster callback
162 */ 162 */
@@ -275,7 +275,7 @@ struct RunContext
275 * Number of random links to established 275 * Number of random links to established
276 */ 276 */
277 unsigned int random_links; 277 unsigned int random_links;
278 278
279}; 279};
280 280
281 281
@@ -394,7 +394,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
394 if (NULL != rc->h) 394 if (NULL != rc->h)
395 GNUNET_TESTBED_host_destroy (rc->h); 395 GNUNET_TESTBED_host_destroy (rc->h);
396 for (hid = 0; hid < rc->num_hosts; hid++) 396 for (hid = 0; hid < rc->num_hosts; hid++)
397 GNUNET_TESTBED_host_destroy (rc->hosts[hid]); 397 GNUNET_TESTBED_host_destroy (rc->hosts[hid]);
398 GNUNET_free_non_null (rc->hosts); 398 GNUNET_free_non_null (rc->hosts);
399 if (NULL != rc->cfg) 399 if (NULL != rc->cfg)
400 GNUNET_CONFIGURATION_destroy (rc->cfg); 400 GNUNET_CONFIGURATION_destroy (rc->cfg);
@@ -530,7 +530,7 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
530 return; 530 return;
531 GNUNET_free (rc->peers); 531 GNUNET_free (rc->peers);
532 rc->peers = NULL; 532 rc->peers = NULL;
533 } 533 }
534 } 534 }
535 rc->state = RC_PEERS_DESTROYED; /* No peers are present so we consider the 535 rc->state = RC_PEERS_DESTROYED; /* No peers are present so we consider the
536 * state where all peers are destroyed */ 536 * state where all peers are destroyed */
@@ -548,11 +548,11 @@ static void
548call_master (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 548call_master (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
549{ 549{
550 struct RunContext *rc = cls; 550 struct RunContext *rc = cls;
551 551
552 if (NULL != rc->topology_operation) 552 if (NULL != rc->topology_operation)
553 { 553 {
554 DEBUG ("Overlay topology generated in %s\n", prof_time (rc)); 554 DEBUG ("Overlay topology generated in %s\n", prof_time (rc));
555 GNUNET_TESTBED_operation_done (rc->topology_operation); 555 GNUNET_TESTBED_operation_done (rc->topology_operation);
556 rc->topology_operation = NULL; 556 rc->topology_operation = NULL;
557 } 557 }
558 if (NULL != rc->test_master) 558 if (NULL != rc->test_master)
@@ -570,7 +570,7 @@ create_peers (struct RunContext *rc)
570{ 570{
571 struct DLLOperation *dll_op; 571 struct DLLOperation *dll_op;
572 unsigned int peer; 572 unsigned int peer;
573 573
574 DEBUG ("Creating peers\n"); 574 DEBUG ("Creating peers\n");
575 rc->pstart_time = GNUNET_TIME_absolute_get (); 575 rc->pstart_time = GNUNET_TIME_absolute_get ();
576 rc->peers = 576 rc->peers =
@@ -582,11 +582,11 @@ create_peers (struct RunContext *rc)
582 dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); 582 dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
583 dll_op->rc = rc; 583 dll_op->rc = rc;
584 dll_op->op = 584 dll_op->op =
585 GNUNET_TESTBED_peer_create (rc->c, 585 GNUNET_TESTBED_peer_create (rc->c,
586 (0 == rc->num_hosts) 586 (0 ==
587 ? rc->h : rc->hosts[peer % rc->num_hosts], 587 rc->num_hosts) ? rc->h : rc->hosts[peer %
588 rc->cfg, 588 rc->num_hosts],
589 peer_create_cb, dll_op); 589 rc->cfg, peer_create_cb, dll_op);
590 GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail, dll_op); 590 GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail, dll_op);
591 } 591 }
592} 592}
@@ -614,8 +614,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
614 dll_op = event->details.operation_finished.op_cls; 614 dll_op = event->details.operation_finished.op_cls;
615 if (NULL != event->details.operation_finished.emsg) 615 if (NULL != event->details.operation_finished.emsg)
616 { 616 {
617 LOG (GNUNET_ERROR_TYPE_ERROR, 617 LOG (GNUNET_ERROR_TYPE_ERROR, _("Linking controllers failed. Exiting"));
618 _("Linking controllers failed. Exiting"));
619 shutdown_now (rc); 618 shutdown_now (rc);
620 } 619 }
621 else 620 else
@@ -719,20 +718,17 @@ call_cc:
719 GNUNET_free (dll_op); 718 GNUNET_free (dll_op);
720 rc->peer_count++; 719 rc->peer_count++;
721 if (rc->peer_count < rc->num_peers) 720 if (rc->peer_count < rc->num_peers)
722 return; 721 return;
723 DEBUG ("%u peers started in %s\n", rc->num_peers, 722 DEBUG ("%u peers started in %s\n", rc->num_peers, prof_time (rc));
724 prof_time (rc));
725 if (GNUNET_TESTBED_TOPOLOGY_NONE != rc->topology) 723 if (GNUNET_TESTBED_TOPOLOGY_NONE != rc->topology)
726 { 724 {
727 if ( (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology) 725 if ((GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology) ||
728 || (GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING == rc->topology) 726 (GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING == rc->topology) ||
729 || (GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD == rc->topology)) 727 (GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD == rc->topology))
730 { 728 {
731 rc->topology_operation = 729 rc->topology_operation =
732 GNUNET_TESTBED_overlay_configure_topology (NULL, 730 GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers,
733 rc->num_peers, 731 rc->peers, &rc->num_oc,
734 rc->peers,
735 &rc->num_oc,
736 rc->topology, 732 rc->topology,
737 rc->random_links, 733 rc->random_links,
738 GNUNET_TESTBED_TOPOLOGY_OPTION_END); 734 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
@@ -741,20 +737,16 @@ call_cc:
741 { 737 {
742 GNUNET_assert (NULL != rc->topo_file); 738 GNUNET_assert (NULL != rc->topo_file);
743 rc->topology_operation = 739 rc->topology_operation =
744 GNUNET_TESTBED_overlay_configure_topology (NULL, 740 GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers,
745 rc->num_peers, 741 rc->peers, &rc->num_oc,
746 rc->peers,
747 &rc->num_oc,
748 rc->topology, 742 rc->topology,
749 rc->topo_file, 743 rc->topo_file,
750 GNUNET_TESTBED_TOPOLOGY_OPTION_END); 744 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
751 } 745 }
752 else 746 else
753 rc->topology_operation = 747 rc->topology_operation =
754 GNUNET_TESTBED_overlay_configure_topology (NULL, 748 GNUNET_TESTBED_overlay_configure_topology (NULL, rc->num_peers,
755 rc->num_peers, 749 rc->peers, &rc->num_oc,
756 rc->peers,
757 &rc->num_oc,
758 rc->topology, 750 rc->topology,
759 GNUNET_TESTBED_TOPOLOGY_OPTION_END); 751 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
760 if (NULL == rc->topology_operation) 752 if (NULL == rc->topology_operation)
@@ -763,7 +755,7 @@ call_cc:
763 else 755 else
764 { 756 {
765 DEBUG ("Creating overlay topology\n"); 757 DEBUG ("Creating overlay topology\n");
766 rc->pstart_time = GNUNET_TIME_absolute_get (); 758 rc->pstart_time = GNUNET_TIME_absolute_get ();
767 return; 759 return;
768 } 760 }
769 } 761 }
@@ -828,21 +820,18 @@ register_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
828 { 820 {
829 dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); 821 dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
830 dll_op->rc = rc; 822 dll_op->rc = rc;
831 dll_op->op = GNUNET_TESTBED_controller_link (dll_op, 823 dll_op->op =
832 rc->c, 824 GNUNET_TESTBED_controller_link (dll_op, rc->c, rc->hosts[slave],
833 rc->hosts[slave], 825 rc->h, rc->cfg, GNUNET_YES);
834 rc->h, 826 GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail,
835 rc->cfg, 827 dll_op);
836 GNUNET_YES);
837 GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail, dll_op);
838 } 828 }
839 rc->reg_hosts = 0; 829 rc->reg_hosts = 0;
840 return; 830 return;
841 } 831 }
842 rc->reg_handle = GNUNET_TESTBED_register_host (rc->c, 832 rc->reg_handle =
843 rc->hosts[rc->reg_hosts++], 833 GNUNET_TESTBED_register_host (rc->c, rc->hosts[rc->reg_hosts++],
844 host_registration_completion, 834 host_registration_completion, rc);
845 rc);
846} 835}
847 836
848 837
@@ -871,7 +860,7 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
871 return; 860 return;
872 default: 861 default:
873 rc->cproc = NULL; 862 rc->cproc = NULL;
874 shutdown_now (rc); 863 shutdown_now (rc);
875 return; 864 return;
876 } 865 }
877 } 866 }
@@ -884,7 +873,8 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
884 if (rc->topology < GNUNET_TESTBED_TOPOLOGY_NONE) 873 if (rc->topology < GNUNET_TESTBED_TOPOLOGY_NONE)
885 event_mask |= GNUNET_TESTBED_ET_CONNECT; 874 event_mask |= GNUNET_TESTBED_ET_CONNECT;
886 rc->c = 875 rc->c =
887 GNUNET_TESTBED_controller_connect (rc->cfg, rc->h, event_mask, &event_cb, rc); 876 GNUNET_TESTBED_controller_connect (rc->cfg, rc->h, event_mask, &event_cb,
877 rc);
888 if (0 < rc->num_hosts) 878 if (0 < rc->num_hosts)
889 { 879 {
890 rc->register_hosts_task = GNUNET_SCHEDULER_add_now (&register_hosts, rc); 880 rc->register_hosts_task = GNUNET_SCHEDULER_add_now (&register_hosts, rc);
@@ -908,32 +898,28 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
908 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort 898 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
909 */ 899 */
910static int 900static int
911netint_proc (void *cls, const char *name, 901netint_proc (void *cls, const char *name, int isDefault,
912 int isDefault, 902 const struct sockaddr *addr, const struct sockaddr *broadcast_addr,
913 const struct sockaddr *addr, 903 const struct sockaddr *netmask, socklen_t addrlen)
914 const struct sockaddr *broadcast_addr,
915 const struct sockaddr *netmask,
916 socklen_t addrlen)
917{ 904{
918 struct RunContext *rc = cls; 905 struct RunContext *rc = cls;
919 char hostip[NI_MAXHOST]; 906 char hostip[NI_MAXHOST];
920 char *buf; 907 char *buf;
921 908
922 if (sizeof (struct sockaddr_in) != addrlen) 909 if (sizeof (struct sockaddr_in) != addrlen)
923 return GNUNET_OK; /* Only consider IPv4 for now */ 910 return GNUNET_OK; /* Only consider IPv4 for now */
924 if (0 != getnameinfo(addr, addrlen, 911 if (0 !=
925 hostip, NI_MAXHOST, 912 getnameinfo (addr, addrlen, hostip, NI_MAXHOST, NULL, 0, NI_NUMERICHOST))
926 NULL, 0, NI_NUMERICHOST)) 913 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "getnameinfo");
927 GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "getnameinfo"); 914 if (NULL == rc->trusted_ip)
928 if (NULL == rc->trusted_ip) 915 {
929 { 916 rc->trusted_ip = GNUNET_strdup (hostip);
930 rc->trusted_ip = GNUNET_strdup (hostip); 917 return GNUNET_YES;
931 return GNUNET_YES; 918 }
932 } 919 (void) GNUNET_asprintf (&buf, "%s; %s", rc->trusted_ip, hostip);
933 (void) GNUNET_asprintf (&buf, "%s; %s", rc->trusted_ip, hostip); 920 GNUNET_free (rc->trusted_ip);
934 GNUNET_free (rc->trusted_ip); 921 rc->trusted_ip = buf;
935 rc->trusted_ip = buf; 922 return GNUNET_YES;
936 return GNUNET_YES;
937} 923}
938 924
939 925
@@ -947,12 +933,13 @@ netint_proc (void *cls, const char *name,
947 * given to GNUNET_TESTBED_is_host_habitable() is NULL 933 * given to GNUNET_TESTBED_is_host_habitable() is NULL
948 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not 934 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not
949 */ 935 */
950static void 936static void
951host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host, int status) 937host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host,
938 int status)
952{ 939{
953 struct RunContext *rc = cls; 940 struct RunContext *rc = cls;
954 unsigned int nhost; 941 unsigned int nhost;
955 942
956 for (nhost = 0; nhost < rc->num_hosts; nhost++) 943 for (nhost = 0; nhost < rc->num_hosts; nhost++)
957 { 944 {
958 if (host == rc->hosts[nhost]) 945 if (host == rc->hosts[nhost])
@@ -966,7 +953,8 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host, int status
966 LOG (GNUNET_ERROR_TYPE_ERROR, _("Host %s cannot start testbed\n"), 953 LOG (GNUNET_ERROR_TYPE_ERROR, _("Host %s cannot start testbed\n"),
967 GNUNET_TESTBED_host_get_hostname (host)); 954 GNUNET_TESTBED_host_get_hostname (host));
968 else 955 else
969 LOG (GNUNET_ERROR_TYPE_ERROR, _("Testbed cannot be started on localhost\n")); 956 LOG (GNUNET_ERROR_TYPE_ERROR,
957 _("Testbed cannot be started on localhost\n"));
970 shutdown_now (rc); 958 shutdown_now (rc);
971 return; 959 return;
972 } 960 }
@@ -1040,7 +1028,7 @@ GNUNET_TESTBED_run (const char *host_filename,
1040 unsigned long long random_links; 1028 unsigned long long random_links;
1041 unsigned int hid; 1029 unsigned int hid;
1042 unsigned int nhost; 1030 unsigned int nhost;
1043 1031
1044 GNUNET_assert (num_peers > 0); 1032 GNUNET_assert (num_peers > 0);
1045 rc = GNUNET_malloc (sizeof (struct RunContext)); 1033 rc = GNUNET_malloc (sizeof (struct RunContext));
1046 if (NULL != host_filename) 1034 if (NULL != host_filename)
@@ -1064,17 +1052,17 @@ GNUNET_TESTBED_run (const char *host_filename,
1064 rc->test_master = test_master; 1052 rc->test_master = test_master;
1065 rc->test_master_cls = test_master_cls; 1053 rc->test_master_cls = test_master_cls;
1066 rc->state = RC_INIT; 1054 rc->state = RC_INIT;
1067 rc->topology = GNUNET_TESTBED_TOPOLOGY_NONE; 1055 rc->topology = GNUNET_TESTBED_TOPOLOGY_NONE;
1068 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (rc->cfg, "testbed", 1056 if (GNUNET_OK ==
1069 "OVERLAY_TOPOLOGY", 1057 GNUNET_CONFIGURATION_get_value_string (rc->cfg, "testbed",
1070 &topology)) 1058 "OVERLAY_TOPOLOGY", &topology))
1071 { 1059 {
1072 if (GNUNET_NO == GNUNET_TESTBED_topology_get_ (&rc->topology, 1060 if (GNUNET_NO == GNUNET_TESTBED_topology_get_ (&rc->topology, topology))
1073 topology))
1074 { 1061 {
1075 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, 1062 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "testbed",
1076 "testbed", "OVERLAY_TOPLOGY", 1063 "OVERLAY_TOPLOGY",
1077 _("Specified topology must be supported by testbed")); 1064 _
1065 ("Specified topology must be supported by testbed"));
1078 } 1066 }
1079 GNUNET_free (topology); 1067 GNUNET_free (topology);
1080 } 1068 }
@@ -1083,51 +1071,54 @@ GNUNET_TESTBED_run (const char *host_filename,
1083 case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI: 1071 case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI:
1084 case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING: 1072 case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING:
1085 case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD: 1073 case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD:
1086 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (rc->cfg, "testbed", 1074 if (GNUNET_OK !=
1087 "OVERLAY_RANDOM_LINKS", 1075 GNUNET_CONFIGURATION_get_value_number (rc->cfg, "testbed",
1088 &random_links)) 1076 "OVERLAY_RANDOM_LINKS",
1077 &random_links))
1089 { 1078 {
1090 /* OVERLAY option RANDOM & SMALL_WORLD_RING requires OVERLAY_RANDOM_LINKS 1079 /* OVERLAY option RANDOM & SMALL_WORLD_RING requires OVERLAY_RANDOM_LINKS
1091 option to be set to the number of random links to be established */ 1080 * option to be set to the number of random links to be established */
1092 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 1081 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "testbed",
1093 "testbed", "OVERLAY_RANDOM_LINKS"); 1082 "OVERLAY_RANDOM_LINKS");
1094 goto error_cleanup; 1083 goto error_cleanup;
1095 } 1084 }
1096 if (random_links > UINT32_MAX) 1085 if (random_links > UINT32_MAX)
1097 { 1086 {
1098 GNUNET_break (0); /* Too big number */ 1087 GNUNET_break (0); /* Too big number */
1099 goto error_cleanup; 1088 goto error_cleanup;
1100 } 1089 }
1101 rc->random_links = (unsigned int) random_links; 1090 rc->random_links = (unsigned int) random_links;
1102 break; 1091 break;
1103 case GNUNET_TESTBED_TOPOLOGY_FROM_FILE: 1092 case GNUNET_TESTBED_TOPOLOGY_FROM_FILE:
1104 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (rc->cfg, "testbed", 1093 if (GNUNET_OK !=
1105 "OVERLAY_TOPOLOGY_FILE", 1094 GNUNET_CONFIGURATION_get_value_string (rc->cfg, "testbed",
1106 &rc->topo_file)) 1095 "OVERLAY_TOPOLOGY_FILE",
1096 &rc->topo_file))
1107 { 1097 {
1108 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 1098 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "testbed",
1109 "testbed", "OVERLAY_TOPOLOGY_FILE"); 1099 "OVERLAY_TOPOLOGY_FILE");
1110 goto error_cleanup; 1100 goto error_cleanup;
1111 } 1101 }
1112 default: 1102 default:
1113 /* Warn if OVERLAY_RANDOM_LINKS is present that it will be ignored */ 1103 /* Warn if OVERLAY_RANDOM_LINKS is present that it will be ignored */
1114 if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (rc->cfg, "testbed", 1104 if (GNUNET_YES ==
1115 "OVERLAY_RANDOM_LINKS")) 1105 GNUNET_CONFIGURATION_have_value (rc->cfg, "testbed",
1106 "OVERLAY_RANDOM_LINKS"))
1116 LOG (GNUNET_ERROR_TYPE_WARNING, 1107 LOG (GNUNET_ERROR_TYPE_WARNING,
1117 "Ignoring value of `OVERLAY_RANDOM_LINKS' in given configuration\n"); 1108 "Ignoring value of `OVERLAY_RANDOM_LINKS' in given configuration\n");
1118 break; 1109 break;
1119 } 1110 }
1120 if (NULL != host_filename) 1111 if (NULL != host_filename)
1121 { 1112 {
1122 rc->hc_handles = GNUNET_malloc (sizeof (struct 1113 rc->hc_handles =
1123 GNUNET_TESTBED_HostHabitableCheckHandle *) 1114 GNUNET_malloc (sizeof (struct GNUNET_TESTBED_HostHabitableCheckHandle *)
1124 * rc->num_hosts); 1115 * rc->num_hosts);
1125 for (nhost = 0; nhost < rc->num_hosts; nhost++) 1116 for (nhost = 0; nhost < rc->num_hosts; nhost++)
1126 { 1117 {
1127 if (NULL == (rc->hc_handles[nhost] = 1118 if (NULL ==
1128 GNUNET_TESTBED_is_host_habitable (rc->hosts[nhost], rc->cfg, 1119 (rc->hc_handles[nhost] =
1129 &host_habitable_cb, 1120 GNUNET_TESTBED_is_host_habitable (rc->hosts[nhost], rc->cfg,
1130 rc))) 1121 &host_habitable_cb, rc)))
1131 { 1122 {
1132 GNUNET_break (0); 1123 GNUNET_break (0);
1133 for (nhost = 0; nhost < rc->num_hosts; nhost++) 1124 for (nhost = 0; nhost < rc->num_hosts; nhost++)
@@ -1141,14 +1132,14 @@ GNUNET_TESTBED_run (const char *host_filename,
1141 } 1132 }
1142 else 1133 else
1143 rc->cproc = 1134 rc->cproc =
1144 GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h, rc->cfg, 1135 GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h, rc->cfg,
1145 &controller_status_cb, rc); 1136 &controller_status_cb, rc);
1146 rc->shutdown_run_task = 1137 rc->shutdown_run_task =
1147 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 1138 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_run,
1148 &shutdown_run, rc); 1139 rc);
1149 return; 1140 return;
1150 1141
1151 error_cleanup: 1142error_cleanup:
1152 if (NULL != rc->h) 1143 if (NULL != rc->h)
1153 GNUNET_TESTBED_host_destroy (rc->h); 1144 GNUNET_TESTBED_host_destroy (rc->h);
1154 if (NULL != rc->hosts) 1145 if (NULL != rc->hosts)
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c
index 0b949d3aa..95ac7ae70 100644
--- a/src/testbed/testbed_api_topology.c
+++ b/src/testbed/testbed_api_topology.c
@@ -56,7 +56,7 @@ struct OverlayLink
56 56
57 /** 57 /**
58 * The topology context this link is a part of 58 * The topology context this link is a part of
59 */ 59 */
60 struct TopologyContext *tc; 60 struct TopologyContext *tc;
61 61
62 /** 62 /**
@@ -106,7 +106,7 @@ struct TopologyContext
106 * should the automatic retry be disabled 106 * should the automatic retry be disabled
107 */ 107 */
108 int disable_retry; 108 int disable_retry;
109 109
110}; 110};
111 111
112 112
@@ -114,75 +114,74 @@ struct TopologyContext
114 * A array of names representing topologies. Should be in sync with enum 114 * A array of names representing topologies. Should be in sync with enum
115 * GNUNET_TESTBED_TopologyOption 115 * GNUNET_TESTBED_TopologyOption
116 */ 116 */
117const char * topology_strings[] = { 117const char *topology_strings[] = {
118 118
119 /** 119 /**
120 * A clique (everyone connected to everyone else). No options. If there are N 120 * A clique (everyone connected to everyone else). No options. If there are N
121 * peers this topology results in (N * (N -1)) connections. 121 * peers this topology results in (N * (N -1)) connections.
122 */ 122 */
123 "CLIQUE", 123 "CLIQUE",
124 124
125 /** 125 /**
126 * Small-world network (2d torus plus random links). Followed 126 * Small-world network (2d torus plus random links). Followed
127 * by the number of random links to add (unsigned int). 127 * by the number of random links to add (unsigned int).
128 */ 128 */
129 "SMALL_WORLD", 129 "SMALL_WORLD",
130 130
131 /** 131 /**
132 * Small-world network (ring plus random links). Followed 132 * Small-world network (ring plus random links). Followed
133 * by the number of random links to add (unsigned int). 133 * by the number of random links to add (unsigned int).
134 */ 134 */
135 "SMALL_WORLD_RING", 135 "SMALL_WORLD_RING",
136 136
137 /** 137 /**
138 * Ring topology. No options. 138 * Ring topology. No options.
139 */ 139 */
140 "RING", 140 "RING",
141 141
142 /** 142 /**
143 * 2-d torus. No options. 143 * 2-d torus. No options.
144 */ 144 */
145 "2D_TORUS", 145 "2D_TORUS",
146 146
147 /** 147 /**
148 * Random graph. Followed by the number of random links to be established 148 * Random graph. Followed by the number of random links to be established
149 * (unsigned int) 149 * (unsigned int)
150 */ 150 */
151 "RANDOM", // GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI 151 "RANDOM", // GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI
152 152
153 /** 153 /**
154 * Certain percentage of peers are unable to communicate directly 154 * Certain percentage of peers are unable to communicate directly
155 * replicating NAT conditions. Followed by the fraction of 155 * replicating NAT conditions. Followed by the fraction of
156 * NAT'ed peers (float). 156 * NAT'ed peers (float).
157 */ 157 */
158 "INTERNAT", 158 "INTERNAT",
159 159
160 /** 160 /**
161 * Scale free topology. No options. 161 * Scale free topology. No options.
162 */ 162 */
163 "SCALE_FREE", 163 "SCALE_FREE",
164 164
165 /** 165 /**
166 * Straight line topology. No options. 166 * Straight line topology. No options.
167 */ 167 */
168 "LINE", 168 "LINE",
169 169
170 /** 170 /**
171 * Read a topology from a given file. Followed by the name of the file (const char *). 171 * Read a topology from a given file. Followed by the name of the file (const char *).
172 */ 172 */
173 "FROM_FILE", 173 "FROM_FILE",
174 174
175 /** 175 /**
176 * All peers are disconnected. No options. 176 * All peers are disconnected. No options.
177 */ 177 */
178 "NONE", 178 "NONE",
179 179
180 /** 180 /**
181 * End of strings 181 * End of strings
182 */ 182 */
183 NULL 183 NULL
184 184};
185 };
186 185
187 186
188/** 187/**
@@ -193,10 +192,9 @@ const char * topology_strings[] = {
193 * @param emsg error message in case the operation has failed; will be NULL if 192 * @param emsg error message in case the operation has failed; will be NULL if
194 * operation has executed successfully. 193 * operation has executed successfully.
195 */ 194 */
196static void 195static void
197overlay_link_completed (void *cls, 196overlay_link_completed (void *cls, struct GNUNET_TESTBED_Operation *op,
198 struct GNUNET_TESTBED_Operation *op, 197 const char *emsg)
199 const char *emsg)
200{ 198{
201 struct OverlayLink *link = cls; 199 struct OverlayLink *link = cls;
202 struct TopologyContext *tc; 200 struct TopologyContext *tc;
@@ -208,12 +206,10 @@ overlay_link_completed (void *cls,
208 if ((NULL != emsg) && (GNUNET_NO == tc->disable_retry)) 206 if ((NULL != emsg) && (GNUNET_NO == tc->disable_retry))
209 { 207 {
210 LOG (GNUNET_ERROR_TYPE_WARNING, 208 LOG (GNUNET_ERROR_TYPE_WARNING,
211 "Error while establishing a link: %s -- Retrying\n", emsg); 209 "Error while establishing a link: %s -- Retrying\n", emsg);
212 link->op = 210 link->op =
213 GNUNET_TESTBED_overlay_connect (tc->op_cls, 211 GNUNET_TESTBED_overlay_connect (tc->op_cls, &overlay_link_completed,
214 &overlay_link_completed, 212 link, tc->peers[link->A],
215 link,
216 tc->peers[link->A],
217 tc->peers[link->B]); 213 tc->peers[link->B]);
218 return; 214 return;
219 } 215 }
@@ -231,14 +227,14 @@ opstart_overlay_configure_topology (void *cls)
231{ 227{
232 struct TopologyContext *tc = cls; 228 struct TopologyContext *tc = cls;
233 unsigned int p; 229 unsigned int p;
234 230
235 for (p = 0; p < tc->link_array_size; p++) 231 for (p = 0; p < tc->link_array_size; p++)
236 { 232 {
237 tc->link_array[p].op = 233 tc->link_array[p].op =
238 GNUNET_TESTBED_overlay_connect (tc->op_cls, &overlay_link_completed, 234 GNUNET_TESTBED_overlay_connect (tc->op_cls, &overlay_link_completed,
239 &tc->link_array[p], 235 &tc->link_array[p],
240 tc->peers[tc->link_array[p].A], 236 tc->peers[tc->link_array[p].A],
241 tc->peers[tc->link_array[p].B]); 237 tc->peers[tc->link_array[p].B]);
242 } 238 }
243} 239}
244 240
@@ -253,7 +249,7 @@ oprelease_overlay_configure_topology (void *cls)
253{ 249{
254 struct TopologyContext *tc = cls; 250 struct TopologyContext *tc = cls;
255 unsigned int p; 251 unsigned int p;
256 252
257 if (NULL != tc->link_array) 253 if (NULL != tc->link_array)
258 { 254 {
259 for (p = 0; p < tc->link_array_size; p++) 255 for (p = 0; p < tc->link_array_size; p++)
@@ -272,12 +268,10 @@ oprelease_overlay_configure_topology (void *cls)
272 * @param A the peer A. Should be different from B 268 * @param A the peer A. Should be different from B
273 * @param B the peer B. Should be different from A 269 * @param B the peer B. Should be different from A
274 * @param tc the TopologyContext 270 * @param tc the TopologyContext
275 * @return 271 * @return
276 */ 272 */
277static void 273static void
278make_link (struct OverlayLink *link, 274make_link (struct OverlayLink *link, uint32_t A, uint32_t B,
279 uint32_t A,
280 uint32_t B,
281 struct TopologyContext *tc) 275 struct TopologyContext *tc)
282{ 276{
283 GNUNET_assert (A != B); 277 GNUNET_assert (A != B);
@@ -300,9 +294,9 @@ gen_topo_line (struct TopologyContext *tc)
300 unsigned int cnt; 294 unsigned int cnt;
301 295
302 tc->link_array_size = tc->num_peers - 1; 296 tc->link_array_size = tc->num_peers - 1;
303 tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * 297 tc->link_array =
304 tc->link_array_size); 298 GNUNET_malloc (sizeof (struct OverlayLink) * tc->link_array_size);
305 for (cnt=0; cnt < (tc->num_peers - 1); cnt++) 299 for (cnt = 0; cnt < (tc->num_peers - 1); cnt++)
306 make_link (&tc->link_array[cnt], cnt, cnt + 1, tc); 300 make_link (&tc->link_array[cnt], cnt, cnt + 1, tc);
307} 301}
308 302
@@ -317,12 +311,10 @@ gen_topo_ring (struct TopologyContext *tc)
317{ 311{
318 gen_topo_line (tc); 312 gen_topo_line (tc);
319 tc->link_array_size++; 313 tc->link_array_size++;
320 tc->link_array = GNUNET_realloc (tc->link_array, 314 tc->link_array =
321 sizeof (struct OverlayLink) * 315 GNUNET_realloc (tc->link_array,
322 tc->link_array_size); 316 sizeof (struct OverlayLink) * tc->link_array_size);
323 make_link (&tc->link_array[tc->link_array_size - 1], 317 make_link (&tc->link_array[tc->link_array_size - 1], tc->num_peers - 1, 0,
324 tc->num_peers - 1,
325 0,
326 tc); 318 tc);
327} 319}
328 320
@@ -338,8 +330,7 @@ gen_topo_ring (struct TopologyContext *tc)
338 * fresh. The caller should free it. Can be NULL 330 * fresh. The caller should free it. Can be NULL
339 */ 331 */
340unsigned int 332unsigned int
341GNUNET_TESTBED_2dtorus_calc_links (unsigned int num_peers, 333GNUNET_TESTBED_2dtorus_calc_links (unsigned int num_peers, unsigned int *rows,
342 unsigned int *rows,
343 unsigned int **rows_len) 334 unsigned int **rows_len)
344{ 335{
345 double sq; 336 double sq;
@@ -350,12 +341,12 @@ GNUNET_TESTBED_2dtorus_calc_links (unsigned int num_peers,
350 unsigned int y; 341 unsigned int y;
351 unsigned int _num_peers; 342 unsigned int _num_peers;
352 unsigned int cnt; 343 unsigned int cnt;
353 344
354 sq = sqrt (num_peers); 345 sq = sqrt (num_peers);
355 sq = floor (sq); 346 sq = floor (sq);
356 sq_floor = (unsigned int) sq; 347 sq_floor = (unsigned int) sq;
357 _rows = (sq_floor + 1); 348 _rows = (sq_floor + 1);
358 _rows_len = GNUNET_malloc (sizeof (unsigned int) * _rows); 349 _rows_len = GNUNET_malloc (sizeof (unsigned int) * _rows);
359 for (y = 0; y < _rows - 1; y++) 350 for (y = 0; y < _rows - 1; y++)
360 _rows_len[y] = sq_floor; 351 _rows_len[y] = sq_floor;
361 _num_peers = sq_floor * sq_floor; 352 _num_peers = sq_floor * sq_floor;
@@ -399,28 +390,22 @@ gen_topo_2dtorus (struct TopologyContext *tc)
399 unsigned int cnt; 390 unsigned int cnt;
400 unsigned int offset; 391 unsigned int offset;
401 392
402 tc->link_array_size = GNUNET_TESTBED_2dtorus_calc_links (tc->num_peers, &rows, 393 tc->link_array_size =
403 &rows_len); 394 GNUNET_TESTBED_2dtorus_calc_links (tc->num_peers, &rows, &rows_len);
404 tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * 395 tc->link_array =
405 tc->link_array_size); 396 GNUNET_malloc (sizeof (struct OverlayLink) * tc->link_array_size);
406 cnt = 0; 397 cnt = 0;
407 offset = 0; 398 offset = 0;
408 for (y = 0; y < rows; y++) 399 for (y = 0; y < rows; y++)
409 { 400 {
410 for (x = 0; x < rows_len[y] - 1; x++) 401 for (x = 0; x < rows_len[y] - 1; x++)
411 { 402 {
412 make_link (&tc->link_array[cnt], 403 make_link (&tc->link_array[cnt], offset + x, offset + x + 1, tc);
413 offset + x,
414 offset + x + 1,
415 tc);
416 cnt++; 404 cnt++;
417 } 405 }
418 if (0 == x) 406 if (0 == x)
419 break; 407 break;
420 make_link (&tc->link_array[cnt], 408 make_link (&tc->link_array[cnt], offset + x, offset, tc);
421 offset + x,
422 offset,
423 tc);
424 cnt++; 409 cnt++;
425 offset += rows_len[y]; 410 offset += rows_len[y];
426 } 411 }
@@ -429,22 +414,17 @@ gen_topo_2dtorus (struct TopologyContext *tc)
429 offset = 0; 414 offset = 0;
430 for (y = 0; y < rows - 1; y++) 415 for (y = 0; y < rows - 1; y++)
431 { 416 {
432 if (x == rows_len[y+1]) 417 if (x == rows_len[y + 1])
433 break; 418 break;
434 GNUNET_assert (x < rows_len[y+1]); 419 GNUNET_assert (x < rows_len[y + 1]);
435 make_link (&tc->link_array[cnt], 420 make_link (&tc->link_array[cnt], offset + x, offset + rows_len[y] + x,
436 offset + x,
437 offset + rows_len[y] + x,
438 tc); 421 tc);
439 offset += rows_len[y]; 422 offset += rows_len[y];
440 cnt++; 423 cnt++;
441 } 424 }
442 if (0 == offset) 425 if (0 == offset)
443 break; 426 break;
444 make_link (&tc->link_array[cnt], 427 make_link (&tc->link_array[cnt], offset + x, x, tc);
445 offset + x,
446 x,
447 tc);
448 cnt++; 428 cnt++;
449 } 429 }
450 GNUNET_assert (cnt == tc->link_array_size); 430 GNUNET_assert (cnt == tc->link_array_size);
@@ -467,33 +447,35 @@ gen_topo_random (struct TopologyContext *tc, unsigned int links, int append)
467 unsigned int index; 447 unsigned int index;
468 uint32_t A_rand; 448 uint32_t A_rand;
469 uint32_t B_rand; 449 uint32_t B_rand;
470 450
471 if (GNUNET_YES == append) 451 if (GNUNET_YES == append)
472 { 452 {
473 GNUNET_assert ((0 < tc->link_array_size) && (NULL != tc->link_array)); 453 GNUNET_assert ((0 < tc->link_array_size) && (NULL != tc->link_array));
474 index = tc->link_array_size; 454 index = tc->link_array_size;
475 tc->link_array_size += links; 455 tc->link_array_size += links;
476 tc->link_array = GNUNET_realloc (tc->link_array, 456 tc->link_array =
477 sizeof (struct OverlayLink) * 457 GNUNET_realloc (tc->link_array,
478 tc->link_array_size); 458 sizeof (struct OverlayLink) * tc->link_array_size);
479 } 459 }
480 else 460 else
481 { 461 {
482 GNUNET_assert ((0 == tc->link_array_size) && (NULL == tc->link_array)); 462 GNUNET_assert ((0 == tc->link_array_size) && (NULL == tc->link_array));
483 index = 0; 463 index = 0;
484 tc->link_array_size = links; 464 tc->link_array_size = links;
485 tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * 465 tc->link_array =
486 tc->link_array_size); 466 GNUNET_malloc (sizeof (struct OverlayLink) * tc->link_array_size);
487 } 467 }
488 for (cnt = 0; cnt < links; cnt++) 468 for (cnt = 0; cnt < links; cnt++)
489 { 469 {
490 do { 470 do
491 A_rand = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 471 {
492 tc->num_peers); 472 A_rand =
493 B_rand = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 473 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, tc->num_peers);
494 tc->num_peers); 474 B_rand =
495 } while (A_rand == B_rand); 475 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, tc->num_peers);
496 make_link (&tc->link_array[index + cnt], A_rand, B_rand, tc); 476 }
477 while (A_rand == B_rand);
478 make_link (&tc->link_array[index + cnt], A_rand, B_rand, tc);
497 } 479 }
498} 480}
499 481
@@ -518,24 +500,26 @@ gen_scale_free (struct TopologyContext *tc)
518 popularity = GNUNET_malloc (sizeof (uint16_t) * tc->num_peers); 500 popularity = GNUNET_malloc (sizeof (uint16_t) * tc->num_peers);
519 /* Initially connect peer 1 to peer 0 */ 501 /* Initially connect peer 1 to peer 0 */
520 tc->link_array_size = 1; 502 tc->link_array_size = 1;
521 tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink)); 503 tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink));
522 make_link (&tc->link_array[0], 0, 1, tc); 504 make_link (&tc->link_array[0], 0, 1, tc);
523 popularity[0]++; /* increase popularity of 0 as 1 connected to it*/ 505 popularity[0]++; /* increase popularity of 0 as 1 connected to it */
524 for (cnt = 1; cnt < tc->num_peers; cnt++) 506 for (cnt = 1; cnt < tc->num_peers; cnt++)
525 { 507 {
526 previous_connections = tc->link_array_size; 508 previous_connections = tc->link_array_size;
527 for (i = 0; i < cnt; i++) 509 for (i = 0; i < cnt; i++)
528 { 510 {
529 probability = ((double) popularity[i]) / ((double) previous_connections); 511 probability = ((double) popularity[i]) / ((double) previous_connections);
530 random = ((double) 512 random =
513 ((double)
531 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 514 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
532 UINT64_MAX)) / ((double) UINT64_MAX); 515 UINT64_MAX)) / ((double) UINT64_MAX);
533 if (random < probability) 516 if (random < probability)
534 { 517 {
535 tc->link_array_size++; 518 tc->link_array_size++;
536 tc->link_array = GNUNET_realloc (tc->link_array, 519 tc->link_array =
537 (sizeof (struct OverlayLink) * 520 GNUNET_realloc (tc->link_array,
538 tc->link_array_size)); 521 (sizeof (struct OverlayLink) *
522 tc->link_array_size));
539 make_link (&tc->link_array[tc->link_array_size - 1], cnt, i, tc); 523 make_link (&tc->link_array[tc->link_array_size - 1], cnt, i, tc);
540 popularity[cnt]++; 524 popularity[cnt]++;
541 } 525 }
@@ -561,8 +545,9 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
561 uint64_t offset; 545 uint64_t offset;
562 unsigned long int peer_id; 546 unsigned long int peer_id;
563 unsigned long int other_peer_id; 547 unsigned long int other_peer_id;
564 enum ParseState { 548 enum ParseState
565 549 {
550
566 /** 551 /**
567 * We read the peer index 552 * We read the peer index
568 */ 553 */
@@ -585,7 +570,8 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
585 if (GNUNET_OK != 570 if (GNUNET_OK !=
586 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES)) 571 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
587 { 572 {
588 LOG (GNUNET_ERROR_TYPE_ERROR, _("Topology file %s has no data\n"), filename); 573 LOG (GNUNET_ERROR_TYPE_ERROR, _("Topology file %s has no data\n"),
574 filename);
589 return; 575 return;
590 } 576 }
591 data = GNUNET_malloc (fs); 577 data = GNUNET_malloc (fs);
@@ -635,8 +621,7 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
635 if (tc->num_peers <= peer_id) 621 if (tc->num_peers <= peer_id)
636 { 622 {
637 LOG (GNUNET_ERROR_TYPE_ERROR, 623 LOG (GNUNET_ERROR_TYPE_ERROR,
638 _("Topology file needs more peers than given ones\n"), 624 _("Topology file needs more peers than given ones\n"), filename);
639 filename);
640 goto _exit; 625 goto _exit;
641 } 626 }
642 state = OTHER_PEER_INDEX; 627 state = OTHER_PEER_INDEX;
@@ -644,7 +629,7 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
644 break; 629 break;
645 case OTHER_PEER_INDEX: 630 case OTHER_PEER_INDEX:
646 errno = 0; 631 errno = 0;
647 other_peer_id = (unsigned int) strtoul (&data[offset], &end, 10); 632 other_peer_id = (unsigned int) strtoul (&data[offset], &end, 10);
648 if (0 != errno) 633 if (0 != errno)
649 { 634 {
650 LOG (GNUNET_ERROR_TYPE_ERROR, 635 LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -660,25 +645,24 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
660 if (tc->num_peers <= other_peer_id) 645 if (tc->num_peers <= other_peer_id)
661 { 646 {
662 LOG (GNUNET_ERROR_TYPE_ERROR, 647 LOG (GNUNET_ERROR_TYPE_ERROR,
663 _("Topology file needs more peers than given ones\n"), 648 _("Topology file needs more peers than given ones\n"), filename);
664 filename);
665 goto _exit; 649 goto _exit;
666 } 650 }
667 if (peer_id != other_peer_id) 651 if (peer_id != other_peer_id)
668 { 652 {
669 tc->link_array_size++; 653 tc->link_array_size++;
670 tc->link_array = GNUNET_realloc (tc->link_array, 654 tc->link_array =
671 sizeof (struct OverlayLink) * 655 GNUNET_realloc (tc->link_array,
672 tc->link_array_size); 656 sizeof (struct OverlayLink) * tc->link_array_size);
673 offset += end - &data[offset]; 657 offset += end - &data[offset];
674 make_link (&tc->link_array[tc->link_array_size - 1], peer_id, 658 make_link (&tc->link_array[tc->link_array_size - 1], peer_id,
675 other_peer_id, tc); 659 other_peer_id, tc);
676 } 660 }
677 else 661 else
678 LOG (GNUNET_ERROR_TYPE_WARNING, 662 LOG (GNUNET_ERROR_TYPE_WARNING,
679 _("Ignoring to connect peer %u to peer %u\n"), peer_id, other_peer_id); 663 _("Ignoring to connect peer %u to peer %u\n"), peer_id,
680 while (('\n' != data[offset]) && ('|' != data[offset]) 664 other_peer_id);
681 && (offset < fs)) 665 while (('\n' != data[offset]) && ('|' != data[offset]) && (offset < fs))
682 offset++; 666 offset++;
683 if ('\n' == data[offset]) 667 if ('\n' == data[offset])
684 state = PEER_INDEX; 668 state = PEER_INDEX;
@@ -691,13 +675,12 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
691 } 675 }
692 } 676 }
693 status = GNUNET_OK; 677 status = GNUNET_OK;
694 678
695 _exit: 679_exit:
696 GNUNET_free (data); 680 GNUNET_free (data);
697 if (GNUNET_OK != status) 681 if (GNUNET_OK != status)
698 { 682 {
699 LOG (GNUNET_ERROR_TYPE_WARNING, 683 LOG (GNUNET_ERROR_TYPE_WARNING, "Removing link data read from the file\n");
700 "Removing link data read from the file\n");
701 tc->link_array_size = 0; 684 tc->link_array_size = 0;
702 GNUNET_free_non_null (tc->link_array); 685 GNUNET_free_non_null (tc->link_array);
703 tc->link_array = NULL; 686 tc->link_array = NULL;
@@ -772,7 +755,8 @@ GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
772struct GNUNET_TESTBED_Operation * 755struct GNUNET_TESTBED_Operation *
773GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, 756GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
774 unsigned int num_peers, 757 unsigned int num_peers,
775 struct GNUNET_TESTBED_Peer **peers, 758 struct GNUNET_TESTBED_Peer
759 **peers,
776 unsigned int *max_connections, 760 unsigned int *max_connections,
777 enum GNUNET_TESTBED_TopologyOption 761 enum GNUNET_TESTBED_TopologyOption
778 topo, va_list va) 762 topo, va_list va)
@@ -799,29 +783,27 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
799 gen_topo_ring (tc); 783 gen_topo_ring (tc);
800 break; 784 break;
801 case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI: 785 case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI:
802 gen_topo_random (tc, 786 gen_topo_random (tc, va_arg (va, unsigned int), GNUNET_NO);
803 va_arg (va, unsigned int), 787
804 GNUNET_NO);
805 break; 788 break;
806 case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING: 789 case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING:
807 gen_topo_ring (tc); 790 gen_topo_ring (tc);
808 gen_topo_random (tc, 791 gen_topo_random (tc, va_arg (va, unsigned int), GNUNET_YES);
809 va_arg (va, unsigned int), 792
810 GNUNET_YES);
811 break; 793 break;
812 case GNUNET_TESTBED_TOPOLOGY_CLIQUE: 794 case GNUNET_TESTBED_TOPOLOGY_CLIQUE:
813 tc->link_array_size = num_peers * (num_peers - 1); 795 tc->link_array_size = num_peers * (num_peers - 1);
814 tc->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * 796 tc->link_array =
815 tc->link_array_size); 797 GNUNET_malloc (sizeof (struct OverlayLink) * tc->link_array_size);
816 { 798 {
817 unsigned int offset; 799 unsigned int offset;
818 800
819 offset = 0; 801 offset = 0;
820 for (cnt=0; cnt < num_peers; cnt++) 802 for (cnt = 0; cnt < num_peers; cnt++)
821 { 803 {
822 unsigned int neighbour; 804 unsigned int neighbour;
823 805
824 for (neighbour=0; neighbour < num_peers; neighbour++) 806 for (neighbour = 0; neighbour < num_peers; neighbour++)
825 { 807 {
826 if (neighbour == cnt) 808 if (neighbour == cnt)
827 continue; 809 continue;
@@ -838,21 +820,21 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
838 break; 820 break;
839 case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD: 821 case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD:
840 gen_topo_2dtorus (tc); 822 gen_topo_2dtorus (tc);
841 gen_topo_random (tc, 823 gen_topo_random (tc, va_arg (va, unsigned int), GNUNET_YES);
842 va_arg (va, unsigned int), 824
843 GNUNET_YES);
844 break; 825 break;
845 case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE: 826 case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE:
846 gen_scale_free (tc); 827 gen_scale_free (tc);
847 break; 828 break;
848 case GNUNET_TESTBED_TOPOLOGY_FROM_FILE: 829 case GNUNET_TESTBED_TOPOLOGY_FROM_FILE:
849 { 830 {
850 const char *filename; 831 const char *filename;
851 832
852 filename = va_arg (va, const char *); 833 filename = va_arg (va, const char *);
853 GNUNET_assert (NULL != filename); 834
854 gen_topo_from_file (tc, filename); 835 GNUNET_assert (NULL != filename);
855 } 836 gen_topo_from_file (tc, filename);
837 }
856 break; 838 break;
857 default: 839 default:
858 GNUNET_break (0); 840 GNUNET_break (0);
@@ -862,6 +844,7 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
862 do 844 do
863 { 845 {
864 secondary_option = va_arg (va, enum GNUNET_TESTBED_TopologyOption); 846 secondary_option = va_arg (va, enum GNUNET_TESTBED_TopologyOption);
847
865 switch (secondary_option) 848 switch (secondary_option)
866 { 849 {
867 case GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY: 850 case GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY:
@@ -871,20 +854,21 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
871 break; 854 break;
872 default: 855 default:
873 GNUNET_break (0); /* Should not use any other option apart from 856 GNUNET_break (0); /* Should not use any other option apart from
874 the ones handled here */ 857 * the ones handled here */
875 GNUNET_free_non_null (tc->link_array); 858 GNUNET_free_non_null (tc->link_array);
876 GNUNET_free (tc); 859 GNUNET_free (tc);
877 return NULL; 860 return NULL;
878 } 861 }
879 } while (GNUNET_TESTBED_TOPOLOGY_OPTION_END != secondary_option); 862 }
863 while (GNUNET_TESTBED_TOPOLOGY_OPTION_END != secondary_option);
880 op = GNUNET_TESTBED_operation_create_ (tc, 864 op = GNUNET_TESTBED_operation_create_ (tc,
881 &opstart_overlay_configure_topology, 865 &opstart_overlay_configure_topology,
882 &oprelease_overlay_configure_topology); 866 &oprelease_overlay_configure_topology);
883 GNUNET_TESTBED_operation_queue_insert_ 867 GNUNET_TESTBED_operation_queue_insert_
884 (c->opq_parallel_topology_config_operations, op); 868 (c->opq_parallel_topology_config_operations, op);
885 GNUNET_TESTBED_operation_begin_wait_ (op); 869 GNUNET_TESTBED_operation_begin_wait_ (op);
886 LOG (GNUNET_ERROR_TYPE_DEBUG, 870 LOG (GNUNET_ERROR_TYPE_DEBUG, "Generated %u connections\n",
887 "Generated %u connections\n", tc->link_array_size); 871 tc->link_array_size);
888 if (NULL != max_connections) 872 if (NULL != max_connections)
889 *max_connections = tc->link_array_size; 873 *max_connections = tc->link_array_size;
890 return op; 874 return op;
@@ -920,8 +904,8 @@ GNUNET_TESTBED_overlay_configure_topology (void *op_cls, unsigned int num_peers,
920 GNUNET_assert (topo < GNUNET_TESTBED_TOPOLOGY_OPTION_END); 904 GNUNET_assert (topo < GNUNET_TESTBED_TOPOLOGY_OPTION_END);
921 va_start (vargs, topo); 905 va_start (vargs, topo);
922 op = GNUNET_TESTBED_overlay_configure_topology_va (op_cls, num_peers, peers, 906 op = GNUNET_TESTBED_overlay_configure_topology_va (op_cls, num_peers, peers,
923 max_connections, 907 max_connections, topo,
924 topo, vargs); 908 vargs);
925 va_end (vargs); 909 va_end (vargs);
926 return op; 910 return op;
927} 911}
@@ -939,7 +923,7 @@ GNUNET_TESTBED_overlay_configure_topology (void *op_cls, unsigned int num_peers,
939int 923int
940GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology, 924GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology,
941 const char *topology_string) 925 const char *topology_string)
942{ 926{
943 unsigned int cnt; 927 unsigned int cnt;
944 928
945 for (cnt = 0; NULL != topology_strings[cnt]; cnt++) 929 for (cnt = 0; NULL != topology_strings[cnt]; cnt++)
diff --git a/src/testbed/testbed_api_topology.h b/src/testbed/testbed_api_topology.h
index b3430f5f3..b5f36859d 100644
--- a/src/testbed/testbed_api_topology.h
+++ b/src/testbed/testbed_api_topology.h
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file testbed/testbed_api_topology.h 22 * @file testbed/testbed_api_topology.h
23 * @brief header for intra library exported functions 23 * @brief header for intra library exported functions
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */ 25 */
26 26
27#ifndef TESTBED_API_TOPOLOGY_H 27#ifndef TESTBED_API_TOPOLOGY_H
@@ -38,8 +38,7 @@
38 * fresh. The caller should free it. Can be NULL. 38 * fresh. The caller should free it. Can be NULL.
39 */ 39 */
40unsigned int 40unsigned int
41GNUNET_TESTBED_2dtorus_calc_links (unsigned int num_peers, 41GNUNET_TESTBED_2dtorus_calc_links (unsigned int num_peers, unsigned int *rows,
42 unsigned int *rows,
43 unsigned int **rows_len); 42 unsigned int **rows_len);
44 43
45 44
@@ -67,6 +66,5 @@ GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology,
67char * 66char *
68GNUNET_TESTBED_topology_to_str_ (enum GNUNET_TESTBED_TopologyOption topology); 67GNUNET_TESTBED_topology_to_str_ (enum GNUNET_TESTBED_TopologyOption topology);
69 68
70#endif 69#endif
71/* end of testbed_api_topology.h */ 70/* end of testbed_api_topology.h */
72
diff --git a/src/testbed/testbed_helper.h b/src/testbed/testbed_helper.h
index 4bed996da..6b476cddf 100644
--- a/src/testbed/testbed_helper.h
+++ b/src/testbed/testbed_helper.h
@@ -29,11 +29,10 @@
29#define TESTBED_HELPER_H 29#define TESTBED_HELPER_H
30 30
31GNUNET_NETWORK_STRUCT_BEGIN 31GNUNET_NETWORK_STRUCT_BEGIN
32
33/** 32/**
34 * Initialization message for gnunet-helper-testbed to start testbed service 33 * Initialization message for gnunet-helper-testbed to start testbed service
35 */ 34 */
36struct GNUNET_TESTBED_HelperInit 35 struct GNUNET_TESTBED_HelperInit
37{ 36{
38 /** 37 /**
39 * Type is GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT 38 * Type is GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT
@@ -60,7 +59,7 @@ struct GNUNET_TESTBED_HelperInit
60 /* Followed by NULL terminated trusted ip */ 59 /* Followed by NULL terminated trusted ip */
61 60
62 /* Followed by hostname of the machine on which helper runs. This is not NULL 61 /* Followed by hostname of the machine on which helper runs. This is not NULL
63 terminated */ 62 * terminated */
64 63
65 /* Followed by serialized and compressed configuration which should be 64 /* Followed by serialized and compressed configuration which should be
66 * config_size long when un-compressed */ 65 * config_size long when un-compressed */
@@ -86,7 +85,5 @@ struct GNUNET_TESTBED_HelperReply
86}; 85};
87 86
88GNUNET_NETWORK_STRUCT_END 87GNUNET_NETWORK_STRUCT_END
89
90#endif 88#endif
91
92/* end of testbed_helper.h */ 89/* end of testbed_helper.h */