aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-07-23 12:58:19 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-07-23 12:58:19 +0200
commitdbf604ad97fef5f9f1ecb468a174fbc81a2eb694 (patch)
treec5131fd4eaeca9b8a5b5717d68b9fdb77e6f6230 /src/testbed
parentb92650ab1d79cd1228dd2678bf87b9edbe37328b (diff)
downloadgnunet-dbf604ad97fef5f9f1ecb468a174fbc81a2eb694.tar.gz
gnunet-dbf604ad97fef5f9f1ecb468a174fbc81a2eb694.zip
fix #5816
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/gnunet-helper-testbed.c202
-rw-r--r--src/testbed/testbed_api.c747
2 files changed, 454 insertions, 495 deletions
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c
index aaa65ed61..72d7fe16f 100644
--- a/src/testbed/gnunet-helper-testbed.c
+++ b/src/testbed/gnunet-helper-testbed.c
@@ -49,14 +49,12 @@
49/** 49/**
50 * Generic logging shortcut 50 * Generic logging shortcut
51 */ 51 */
52#define LOG(kind, ...) \ 52#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
53 GNUNET_log (kind, __VA_ARGS__)
54 53
55/** 54/**
56 * Debug logging shorthand 55 * Debug logging shorthand
57 */ 56 */
58#define LOG_DEBUG(...) \ 57#define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
59 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
60 58
61 59
62/** 60/**
@@ -213,13 +211,12 @@ write_task (void *cls)
213 211
214 GNUNET_assert (NULL != wc); 212 GNUNET_assert (NULL != wc);
215 write_task_id = NULL; 213 write_task_id = NULL;
216 bytes_wrote = 214 bytes_wrote = GNUNET_DISK_file_write (stdout_fd,
217 GNUNET_DISK_file_write (stdout_fd, wc->data + wc->pos, 215 wc->data + wc->pos,
218 wc->length - wc->pos); 216 wc->length - wc->pos);
219 if (GNUNET_SYSERR == bytes_wrote) 217 if (GNUNET_SYSERR == bytes_wrote)
220 { 218 {
221 LOG (GNUNET_ERROR_TYPE_WARNING, 219 LOG (GNUNET_ERROR_TYPE_WARNING, "Cannot reply back configuration\n");
222 "Cannot reply back configuration\n");
223 GNUNET_free (wc->data); 220 GNUNET_free (wc->data);
224 GNUNET_free (wc); 221 GNUNET_free (wc);
225 return; 222 return;
@@ -231,10 +228,10 @@ write_task (void *cls)
231 GNUNET_free (wc); 228 GNUNET_free (wc);
232 return; 229 return;
233 } 230 }
234 write_task_id = 231 write_task_id = GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
235 GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, 232 stdout_fd,
236 stdout_fd, 233 &write_task,
237 &write_task, wc); 234 wc);
238} 235}
239 236
240 237
@@ -273,14 +270,16 @@ child_death_task (void *cls)
273 if (0 != PLIBC_KILL (0, GNUNET_TERM_SIG)) 270 if (0 != PLIBC_KILL (0, GNUNET_TERM_SIG))
274 { 271 {
275 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal"); 272 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal");
276 GNUNET_SCHEDULER_shutdown (); /* Couldn't send the signal, we shutdown frowning */ 273 GNUNET_SCHEDULER_shutdown (); /* Couldn't send the signal, we shutdown frowning */
277 } 274 }
278 return; 275 return;
279 } 276 }
280 LOG_DEBUG ("Child hasn't died. Resuming to monitor its status\n"); 277 LOG_DEBUG ("Child hasn't died. Resuming to monitor its status\n");
281 child_death_task_id = 278 child_death_task_id =
282 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 279 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
283 pr, &child_death_task, NULL); 280 pr,
281 &child_death_task,
282 NULL);
284} 283}
285 284
286 285
@@ -297,8 +296,7 @@ child_death_task (void *cls)
297 * #GNUNET_SYSERR to stop further processing with error 296 * #GNUNET_SYSERR to stop further processing with error
298 */ 297 */
299static int 298static int
300tokenizer_cb (void *cls, 299tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
301 const struct GNUNET_MessageHeader *message)
302{ 300{
303 const struct GNUNET_TESTBED_HelperInit *msg; 301 const struct GNUNET_TESTBED_HelperInit *msg;
304 struct GNUNET_TESTBED_HelperReply *reply; 302 struct GNUNET_TESTBED_HelperReply *reply;
@@ -322,8 +320,7 @@ tokenizer_cb (void *cls,
322 if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= msize) || 320 if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= msize) ||
323 (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) 321 (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type)))
324 { 322 {
325 LOG (GNUNET_ERROR_TYPE_WARNING, 323 LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n");
326 "Received unexpected message -- exiting\n");
327 goto error; 324 goto error;
328 } 325 }
329 msg = (const struct GNUNET_TESTBED_HelperInit *) message; 326 msg = (const struct GNUNET_TESTBED_HelperInit *) message;
@@ -344,28 +341,39 @@ tokenizer_cb (void *cls,
344 } 341 }
345 ul_config_size = (uLongf) ntohs (msg->config_size); 342 ul_config_size = (uLongf) ntohs (msg->config_size);
346 config = GNUNET_malloc (ul_config_size); 343 config = GNUNET_malloc (ul_config_size);
347 xconfig_size = 344 xconfig_size = msize - (trusted_ip_size + 1 + hostname_size +
348 msize - (trusted_ip_size + 1 + hostname_size + 345 sizeof (struct GNUNET_TESTBED_HelperInit));
349 sizeof (struct GNUNET_TESTBED_HelperInit)); 346 int ret = uncompress ((Bytef *) config,
350 if (Z_OK != 347 &ul_config_size,
351 uncompress ((Bytef *) config, &ul_config_size, 348 (const Bytef *) (trusted_ip + trusted_ip_size + 1 +
352 (const Bytef *) (trusted_ip + trusted_ip_size + 1 + 349 hostname_size),
353 hostname_size), (uLongf) xconfig_size)) 350 (uLongf) xconfig_size);
351 if (Z_OK != ret)
354 { 352 {
355 LOG (GNUNET_ERROR_TYPE_WARNING, 353 switch (ret)
354 {
355 case Z_MEM_ERROR:
356 LOG (GNUNET_ERROR_TYPE_ERROR, "Not enough memory for decompression\n");
357 break;
358 case Z_BUF_ERROR:
359 LOG (GNUNET_ERROR_TYPE_ERROR, "Output buffer too small\n");
360 break;
361 case Z_DATA_ERROR:
362 LOG (GNUNET_ERROR_TYPE_ERROR, "Data corrupted/incomplete\n");
363 break;
364 default:
365 GNUNET_break (0);
366 }
367 LOG (GNUNET_ERROR_TYPE_ERROR,
356 "Error while uncompressing config -- exiting\n"); 368 "Error while uncompressing config -- exiting\n");
357 GNUNET_free (config); 369 GNUNET_free (config);
358 goto error; 370 goto error;
359 } 371 }
360 cfg = GNUNET_CONFIGURATION_create (); 372 cfg = GNUNET_CONFIGURATION_create ();
361 if (GNUNET_OK != 373 if (GNUNET_OK !=
362 GNUNET_CONFIGURATION_deserialize (cfg, 374 GNUNET_CONFIGURATION_deserialize (cfg, config, ul_config_size, NULL))
363 config,
364 ul_config_size,
365 NULL))
366 { 375 {
367 LOG (GNUNET_ERROR_TYPE_WARNING, 376 LOG (GNUNET_ERROR_TYPE_ERROR, "Unable to deserialize config -- exiting\n");
368 "Unable to deserialize config -- exiting\n");
369 GNUNET_free (config); 377 GNUNET_free (config);
370 goto error; 378 goto error;
371 } 379 }
@@ -391,19 +399,15 @@ tokenizer_cb (void *cls,
391#endif 399#endif
392 } 400 }
393 test_system = 401 test_system =
394 GNUNET_TESTING_system_create ("testbed-helper", trusted_ip, hostname, 402 GNUNET_TESTING_system_create ("testbed-helper", trusted_ip, hostname, NULL);
395 NULL);
396 if (NULL != evstr) 403 if (NULL != evstr)
397 { 404 {
398#ifdef WINDOWS 405#ifdef WINDOWS
399 GNUNET_assert (0 != SetEnvironmentVariable (GNUNET_TESTING_PREFIX, 406 GNUNET_assert (0 != SetEnvironmentVariable (GNUNET_TESTING_PREFIX, evstr));
400 evstr));
401#else 407#else
402 char *evar; 408 char *evar;
403 409
404 GNUNET_asprintf (&evar, 410 GNUNET_asprintf (&evar, GNUNET_TESTING_PREFIX "=%s", evstr);
405 GNUNET_TESTING_PREFIX "=%s",
406 evstr);
407 GNUNET_assert (0 == putenv (evar)); /* consumes 'evar', 411 GNUNET_assert (0 == putenv (evar)); /* consumes 'evar',
408 see putenv(): becomes part of envrionment! */ 412 see putenv(): becomes part of envrionment! */
409#endif 413#endif
@@ -416,13 +420,15 @@ tokenizer_cb (void *cls,
416 GNUNET_assert (GNUNET_OK == 420 GNUNET_assert (GNUNET_OK ==
417 GNUNET_TESTING_configuration_create (test_system, cfg)); 421 GNUNET_TESTING_configuration_create (test_system, cfg));
418 GNUNET_assert (GNUNET_OK == 422 GNUNET_assert (GNUNET_OK ==
419 GNUNET_CONFIGURATION_get_value_filename (cfg, "PATHS", 423 GNUNET_CONFIGURATION_get_value_filename (cfg,
420 "DEFAULTCONFIG", 424 "PATHS",
421 &config)); 425 "DEFAULTCONFIG",
426 &config));
422 if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config)) 427 if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config))
423 { 428 {
424 LOG (GNUNET_ERROR_TYPE_WARNING, 429 LOG (GNUNET_ERROR_TYPE_WARNING,
425 "Unable to write config file: %s -- exiting\n", config); 430 "Unable to write config file: %s -- exiting\n",
431 config);
426 GNUNET_CONFIGURATION_destroy (cfg); 432 GNUNET_CONFIGURATION_destroy (cfg);
427 GNUNET_free (config); 433 GNUNET_free (config);
428 goto error; 434 goto error;
@@ -433,22 +439,21 @@ tokenizer_cb (void *cls,
433 char *evar; 439 char *evar;
434 440
435 /* expose testbed configuration through env variable */ 441 /* expose testbed configuration through env variable */
436 GNUNET_asprintf (&evar, 442 GNUNET_asprintf (&evar, "%s=%s", ENV_TESTBED_CONFIG, config);
437 "%s=%s", 443 GNUNET_assert (0 == putenv (evar)); /* consumes 'evar',
438 ENV_TESTBED_CONFIG,
439 config);
440 GNUNET_assert (0 == putenv (evar)); /* consumes 'evar',
441 see putenv(): becomes part of envrionment! */ 444 see putenv(): becomes part of envrionment! */
442 evstr = NULL; 445 evstr = NULL;
443 } 446 }
444 testbed = 447 testbed = GNUNET_OS_start_process (PIPE_CONTROL,
445 GNUNET_OS_start_process (PIPE_CONTROL, 448 GNUNET_OS_INHERIT_STD_ERR /*verbose? */,
446 GNUNET_OS_INHERIT_STD_ERR /*verbose? */ , 449 NULL,
447 NULL, NULL, NULL, 450 NULL,
448 binary, 451 NULL,
449 "gnunet-service-testbed", 452 binary,
450 "-c", config, 453 "gnunet-service-testbed",
451 NULL); 454 "-c",
455 config,
456 NULL);
452 GNUNET_free (binary); 457 GNUNET_free (binary);
453 GNUNET_free (config); 458 GNUNET_free (config);
454 if (NULL == testbed) 459 if (NULL == testbed)
@@ -463,7 +468,7 @@ tokenizer_cb (void *cls,
463 GNUNET_CONFIGURATION_destroy (cfg); 468 GNUNET_CONFIGURATION_destroy (cfg);
464 cfg = NULL; 469 cfg = NULL;
465 xconfig_size = 470 xconfig_size =
466 GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); 471 GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
467 GNUNET_free (config); 472 GNUNET_free (config);
468 wc = GNUNET_new (struct WriteContext); 473 wc = GNUNET_new (struct WriteContext);
469 wc->length = xconfig_size + sizeof (struct GNUNET_TESTBED_HelperReply); 474 wc->length = xconfig_size + sizeof (struct GNUNET_TESTBED_HelperReply);
@@ -473,15 +478,15 @@ tokenizer_cb (void *cls,
473 reply->header.size = htons ((uint16_t) wc->length); 478 reply->header.size = htons ((uint16_t) wc->length);
474 reply->config_size = htons ((uint16_t) config_size); 479 reply->config_size = htons ((uint16_t) config_size);
475 wc->data = reply; 480 wc->data = reply;
476 write_task_id = 481 write_task_id = GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
477 GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, 482 stdout_fd,
478 stdout_fd, 483 &write_task,
479 &write_task, wc); 484 wc);
480 child_death_task_id = 485 child_death_task_id = GNUNET_SCHEDULER_add_read_file (
481 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 486 GNUNET_TIME_UNIT_FOREVER_REL,
482 GNUNET_DISK_pipe_handle (sigpipe, 487 GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ),
483 GNUNET_DISK_PIPE_END_READ), 488 &child_death_task,
484 &child_death_task, NULL); 489 NULL);
485 return GNUNET_OK; 490 return GNUNET_OK;
486 491
487error: 492error:
@@ -503,11 +508,8 @@ read_task (void *cls)
503 ssize_t sread; 508 ssize_t sread;
504 509
505 read_task_id = NULL; 510 read_task_id = NULL;
506 sread = GNUNET_DISK_file_read (stdin_fd, 511 sread = GNUNET_DISK_file_read (stdin_fd, buf, sizeof (buf));
507 buf, 512 if ((GNUNET_SYSERR == sread) || (0 == sread))
508 sizeof (buf));
509 if ( (GNUNET_SYSERR == sread) ||
510 (0 == sread) )
511 { 513 {
512 LOG_DEBUG ("STDIN closed\n"); 514 LOG_DEBUG ("STDIN closed\n");
513 GNUNET_SCHEDULER_shutdown (); 515 GNUNET_SCHEDULER_shutdown ();
@@ -520,24 +522,19 @@ read_task (void *cls)
520 GNUNET_SCHEDULER_shutdown (); 522 GNUNET_SCHEDULER_shutdown ();
521 return; 523 return;
522 } 524 }
523 LOG_DEBUG ("Read %u bytes\n", 525 LOG_DEBUG ("Read %u bytes\n", (unsigned int) sread);
524 (unsigned int) sread);
525 /* FIXME: could introduce a GNUNET_MST_read2 to read 526 /* FIXME: could introduce a GNUNET_MST_read2 to read
526 directly from 'stdin_fd' and save a memcpy() here */ 527 directly from 'stdin_fd' and save a memcpy() here */
527 if (GNUNET_OK != 528 if (GNUNET_OK !=
528 GNUNET_MST_from_buffer (tokenizer, 529 GNUNET_MST_from_buffer (tokenizer, buf, sread, GNUNET_NO, GNUNET_NO))
529 buf,
530 sread,
531 GNUNET_NO,
532 GNUNET_NO))
533 { 530 {
534 GNUNET_break (0); 531 GNUNET_break (0);
535 GNUNET_SCHEDULER_shutdown (); 532 GNUNET_SCHEDULER_shutdown ();
536 return; 533 return;
537 } 534 }
538 read_task_id /* No timeout while reading */ 535 read_task_id /* No timeout while reading */
539 = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 536 = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
540 stdin_fd, 537 stdin_fd,
541 &read_task, 538 &read_task,
542 NULL); 539 NULL);
543} 540}
@@ -561,12 +558,11 @@ run (void *cls,
561 tokenizer = GNUNET_MST_create (&tokenizer_cb, NULL); 558 tokenizer = GNUNET_MST_create (&tokenizer_cb, NULL);
562 stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); 559 stdin_fd = GNUNET_DISK_get_handle_from_native (stdin);
563 stdout_fd = GNUNET_DISK_get_handle_from_native (stdout); 560 stdout_fd = GNUNET_DISK_get_handle_from_native (stdout);
564 read_task_id = 561 read_task_id = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
565 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 562 stdin_fd,
566 stdin_fd, 563 &read_task,
567 &read_task, NULL); 564 NULL);
568 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 565 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
569 NULL);
570} 566}
571 567
572 568
@@ -577,13 +573,15 @@ static void
577sighandler_child_death () 573sighandler_child_death ()
578{ 574{
579 static char c; 575 static char c;
580 int old_errno; /* back-up errno */ 576 int old_errno; /* back-up errno */
581 577
582 old_errno = errno; 578 old_errno = errno;
583 GNUNET_break (1 == 579 GNUNET_break (
584 GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle 580 1 ==
585 (sigpipe, GNUNET_DISK_PIPE_END_WRITE), 581 GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle (sigpipe,
586 &c, sizeof (c))); 582 GNUNET_DISK_PIPE_END_WRITE),
583 &c,
584 sizeof (c)));
587 errno = old_errno; 585 errno = old_errno;
588} 586}
589 587
@@ -596,25 +594,23 @@ sighandler_child_death ()
596 * @return return code 594 * @return return code
597 */ 595 */
598int 596int
599main (int argc, 597main (int argc, char **argv)
600 char **argv)
601{ 598{
602 struct GNUNET_SIGNAL_Context *shc_chld; 599 struct GNUNET_SIGNAL_Context *shc_chld;
603 struct GNUNET_GETOPT_CommandLineOption options[] = { 600 struct GNUNET_GETOPT_CommandLineOption options[] = {GNUNET_GETOPT_OPTION_END};
604 GNUNET_GETOPT_OPTION_END
605 };
606 int ret; 601 int ret;
607 602
608 status = GNUNET_OK; 603 status = GNUNET_OK;
609 if (NULL == (sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, 604 if (NULL ==
610 GNUNET_NO, GNUNET_NO))) 605 (sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO)))
611 { 606 {
612 GNUNET_break (0); 607 GNUNET_break (0);
613 return 1; 608 return 1;
614 } 609 }
615 shc_chld = GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, 610 shc_chld =
616 &sighandler_child_death); 611 GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
617 ret = GNUNET_PROGRAM_run (argc, argv, 612 ret = GNUNET_PROGRAM_run (argc,
613 argv,
618 "gnunet-helper-testbed", 614 "gnunet-helper-testbed",
619 "Helper for starting gnunet-service-testbed", 615 "Helper for starting gnunet-service-testbed",
620 options, 616 options,
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index ade1a93de..7df5f1270 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -44,14 +44,12 @@
44/** 44/**
45 * Generic logging shorthand 45 * Generic logging shorthand
46 */ 46 */
47#define LOG(kind, ...) \ 47#define LOG(kind, ...) GNUNET_log_from (kind, "testbed-api", __VA_ARGS__)
48 GNUNET_log_from (kind, "testbed-api", __VA_ARGS__)
49 48
50/** 49/**
51 * Debug logging 50 * Debug logging
52 */ 51 */
53#define LOG_DEBUG(...) \ 52#define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
54 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
55 53
56/** 54/**
57 * Relative time seconds shorthand 55 * Relative time seconds shorthand
@@ -63,7 +61,7 @@
63/** 61/**
64 * Default server message sending retry timeout 62 * Default server message sending retry timeout
65 */ 63 */
66#define TIMEOUT_REL TIME_REL_SECS(1) 64#define TIMEOUT_REL TIME_REL_SECS (1)
67 65
68 66
69/** 67/**
@@ -81,7 +79,6 @@ struct ForwardedOperationData
81 * The closure for the above callback 79 * The closure for the above callback
82 */ 80 */
83 void *cc_cls; 81 void *cc_cls;
84
85}; 82};
86 83
87 84
@@ -94,7 +91,6 @@ struct GetSlaveConfigData
94 * The id of the slave controller 91 * The id of the slave controller
95 */ 92 */
96 uint32_t slave_id; 93 uint32_t slave_id;
97
98}; 94};
99 95
100 96
@@ -112,7 +108,6 @@ struct ControllerLinkData
112 * The id of the host which is hosting the controller to be linked 108 * The id of the host which is hosting the controller to be linked
113 */ 109 */
114 uint32_t host_id; 110 uint32_t host_id;
115
116}; 111};
117 112
118 113
@@ -217,9 +212,7 @@ exop_check (const struct GNUNET_TESTBED_Operation *const op)
217 while (NULL != entry) 212 while (NULL != entry)
218 { 213 {
219 entry2 = entry->next; 214 entry2 = entry->next;
220 GNUNET_CONTAINER_DLL_remove (exop_head, 215 GNUNET_CONTAINER_DLL_remove (exop_head, exop_tail, entry);
221 exop_tail,
222 entry);
223 GNUNET_free (entry); 216 GNUNET_free (entry);
224 entry = entry2; 217 entry = entry2;
225 } 218 }
@@ -254,9 +247,7 @@ struct SearchContext
254 * #GNUNET_NO if not. 247 * #GNUNET_NO if not.
255 */ 248 */
256static int 249static int
257opc_search_iterator (void *cls, 250opc_search_iterator (void *cls, uint32_t key, void *value)
258 uint32_t key,
259 void *value)
260{ 251{
261 struct SearchContext *sc = cls; 252 struct SearchContext *sc = cls;
262 struct OperationContext *opc = value; 253 struct OperationContext *opc = value;
@@ -287,8 +278,10 @@ find_opc (const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
287 sc.opc = NULL; 278 sc.opc = NULL;
288 GNUNET_assert (NULL != c->opc_map); 279 GNUNET_assert (NULL != c->opc_map);
289 if (GNUNET_SYSERR != 280 if (GNUNET_SYSERR !=
290 GNUNET_CONTAINER_multihashmap32_get_multiple (c->opc_map, (uint32_t) id, 281 GNUNET_CONTAINER_multihashmap32_get_multiple (c->opc_map,
291 &opc_search_iterator, &sc)) 282 (uint32_t) id,
283 &opc_search_iterator,
284 &sc))
292 return NULL; 285 return NULL;
293 return sc.opc; 286 return sc.opc;
294} 287}
@@ -308,10 +301,11 @@ GNUNET_TESTBED_insert_opc_ (struct GNUNET_TESTBED_Controller *c,
308{ 301{
309 if (NULL == c->opc_map) 302 if (NULL == c->opc_map)
310 c->opc_map = GNUNET_CONTAINER_multihashmap32_create (256); 303 c->opc_map = GNUNET_CONTAINER_multihashmap32_create (256);
311 GNUNET_assert (GNUNET_OK == 304 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap32_put (
312 GNUNET_CONTAINER_multihashmap32_put (c->opc_map, 305 c->opc_map,
313 (uint32_t) opc->id, opc, 306 (uint32_t) opc->id,
314 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 307 opc,
308 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
315} 309}
316 310
317 311
@@ -331,13 +325,12 @@ GNUNET_TESTBED_remove_opc_ (const struct GNUNET_TESTBED_Controller *c,
331 GNUNET_CONTAINER_multihashmap32_remove (c->opc_map, 325 GNUNET_CONTAINER_multihashmap32_remove (c->opc_map,
332 (uint32_t) opc->id, 326 (uint32_t) opc->id,
333 opc)); 327 opc));
334 if ( (0 == GNUNET_CONTAINER_multihashmap32_size (c->opc_map)) 328 if ((0 == GNUNET_CONTAINER_multihashmap32_size (c->opc_map)) &&
335 && (NULL != c->opcq_empty_cb) ) 329 (NULL != c->opcq_empty_cb))
336 c->opcq_empty_cb (c->opcq_empty_cls); 330 c->opcq_empty_cb (c->opcq_empty_cls);
337} 331}
338 332
339 333
340
341/** 334/**
342 * Check #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message is well-formed. 335 * Check #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message is well-formed.
343 * 336 *
@@ -395,23 +388,19 @@ handle_add_host_confirm (void *cls,
395 msg_size = ntohs (msg->header.size) - sizeof (*msg); 388 msg_size = ntohs (msg->header.size) - sizeof (*msg);
396 if (0 == msg_size) 389 if (0 == msg_size)
397 { 390 {
398 LOG_DEBUG ("Host %u successfully registered\n", 391 LOG_DEBUG ("Host %u successfully registered\n", ntohl (msg->host_id));
399 ntohl (msg->host_id)); 392 GNUNET_TESTBED_mark_host_registered_at_ (rh->host, c);
400 GNUNET_TESTBED_mark_host_registered_at_ (rh->host, 393 rh->cc (rh->cc_cls, NULL);
401 c);
402 rh->cc (rh->cc_cls,
403 NULL);
404 GNUNET_free (rh); 394 GNUNET_free (rh);
405 return; 395 return;
406 } 396 }
407 /* We have an error message */ 397 /* We have an error message */
408 emsg = (const char *) &msg[1]; 398 emsg = (const char *) &msg[1];
409 LOG (GNUNET_ERROR_TYPE_ERROR, 399 LOG (GNUNET_ERROR_TYPE_ERROR,
410 _("Adding host %u failed with error: %s\n"), 400 _ ("Adding host %u failed with error: %s\n"),
411 ntohl (msg->host_id), 401 ntohl (msg->host_id),
412 emsg); 402 emsg);
413 rh->cc (rh->cc_cls, 403 rh->cc (rh->cc_cls, emsg);
414 emsg);
415 GNUNET_free (rh); 404 GNUNET_free (rh);
416} 405}
417 406
@@ -448,8 +437,9 @@ handle_forwarded_operation_msg (void *cls,
448 * @param msg message received 437 * @param msg message received
449 */ 438 */
450static void 439static void
451handle_opsuccess (void *cls, 440handle_opsuccess (
452 const struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg) 441 void *cls,
442 const struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg)
453{ 443{
454 struct GNUNET_TESTBED_Controller *c = cls; 444 struct GNUNET_TESTBED_Controller *c = cls;
455 struct OperationContext *opc; 445 struct OperationContext *opc;
@@ -474,15 +464,14 @@ handle_opsuccess (void *cls,
474 op_comp_cb_cls = NULL; 464 op_comp_cb_cls = NULL;
475 switch (opc->type) 465 switch (opc->type)
476 { 466 {
477 case OP_FORWARDED: 467 case OP_FORWARDED: {
478 { 468 handle_forwarded_operation_msg (c,
479 handle_forwarded_operation_msg (c, opc, 469 opc,
480 (const struct GNUNET_MessageHeader *) msg); 470 (const struct GNUNET_MessageHeader *) msg);
481 return; 471 return;
482 } 472 }
483 break; 473 break;
484 case OP_PEER_DESTROY: 474 case OP_PEER_DESTROY: {
485 {
486 struct GNUNET_TESTBED_Peer *peer; 475 struct GNUNET_TESTBED_Peer *peer;
487 476
488 peer = opc->data; 477 peer = opc->data;
@@ -491,9 +480,8 @@ handle_opsuccess (void *cls,
491 opc->data = NULL; 480 opc->data = NULL;
492 //PEERDESTROYDATA 481 //PEERDESTROYDATA
493 } 482 }
494 break; 483 break;
495 case OP_SHUTDOWN_PEERS: 484 case OP_SHUTDOWN_PEERS: {
496 {
497 struct ShutdownPeersData *data; 485 struct ShutdownPeersData *data;
498 486
499 data = opc->data; 487 data = opc->data;
@@ -503,9 +491,8 @@ handle_opsuccess (void *cls,
503 opc->data = NULL; 491 opc->data = NULL;
504 GNUNET_TESTBED_cleanup_peers_ (); 492 GNUNET_TESTBED_cleanup_peers_ ();
505 } 493 }
506 break; 494 break;
507 case OP_MANAGE_SERVICE: 495 case OP_MANAGE_SERVICE: {
508 {
509 struct ManageServiceData *data; 496 struct ManageServiceData *data;
510 497
511 GNUNET_assert (NULL != (data = opc->data)); 498 GNUNET_assert (NULL != (data = opc->data));
@@ -514,7 +501,7 @@ handle_opsuccess (void *cls,
514 GNUNET_free (data); 501 GNUNET_free (data);
515 opc->data = NULL; 502 opc->data = NULL;
516 } 503 }
517 break; 504 break;
518 case OP_PEER_RECONFIGURE: 505 case OP_PEER_RECONFIGURE:
519 break; 506 break;
520 default: 507 default:
@@ -534,7 +521,7 @@ handle_opsuccess (void *cls,
534 LOG_DEBUG ("Not calling callback\n"); 521 LOG_DEBUG ("Not calling callback\n");
535 if (NULL != op_comp_cb) 522 if (NULL != op_comp_cb)
536 op_comp_cb (op_comp_cb_cls, event.op, NULL); 523 op_comp_cb (op_comp_cb_cls, event.op, NULL);
537 /* You could have marked the operation as done by now */ 524 /* You could have marked the operation as done by now */
538 GNUNET_break (GNUNET_NO == exop_check (event.op)); 525 GNUNET_break (GNUNET_NO == exop_check (event.op));
539} 526}
540 527
@@ -547,8 +534,9 @@ handle_opsuccess (void *cls,
547 * @param msg message received 534 * @param msg message received
548 */ 535 */
549static void 536static void
550handle_peer_create_success (void *cls, 537handle_peer_create_success (
551 const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *msg) 538 void *cls,
539 const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *msg)
552{ 540{
553 struct GNUNET_TESTBED_Controller *c = cls; 541 struct GNUNET_TESTBED_Controller *c = cls;
554 struct OperationContext *opc; 542 struct OperationContext *opc;
@@ -569,7 +557,8 @@ handle_peer_create_success (void *cls,
569 } 557 }
570 if (OP_FORWARDED == opc->type) 558 if (OP_FORWARDED == opc->type)
571 { 559 {
572 handle_forwarded_operation_msg (c, opc, 560 handle_forwarded_operation_msg (c,
561 opc,
573 (const struct GNUNET_MessageHeader *) msg); 562 (const struct GNUNET_MessageHeader *) msg);
574 return; 563 return;
575 } 564 }
@@ -590,7 +579,7 @@ handle_peer_create_success (void *cls,
590 exop_insert (op); 579 exop_insert (op);
591 if (NULL != cb) 580 if (NULL != cb)
592 cb (cb_cls, peer, NULL); 581 cb (cb_cls, peer, NULL);
593 /* You could have marked the operation as done by now */ 582 /* You could have marked the operation as done by now */
594 GNUNET_break (GNUNET_NO == exop_check (op)); 583 GNUNET_break (GNUNET_NO == exop_check (op));
595} 584}
596 585
@@ -603,8 +592,7 @@ handle_peer_create_success (void *cls,
603 * @param msg message received 592 * @param msg message received
604 */ 593 */
605static void 594static void
606handle_peer_event (void *cls, 595handle_peer_event (void *cls, const struct GNUNET_TESTBED_PeerEventMessage *msg)
607 const struct GNUNET_TESTBED_PeerEventMessage *msg)
608{ 596{
609 struct GNUNET_TESTBED_Controller *c = cls; 597 struct GNUNET_TESTBED_Controller *c = cls;
610 struct OperationContext *opc; 598 struct OperationContext *opc;
@@ -626,7 +614,8 @@ handle_peer_event (void *cls,
626 } 614 }
627 if (OP_FORWARDED == opc->type) 615 if (OP_FORWARDED == opc->type)
628 { 616 {
629 handle_forwarded_operation_msg (c, opc, 617 handle_forwarded_operation_msg (c,
618 opc,
630 (const struct GNUNET_MessageHeader *) msg); 619 (const struct GNUNET_MessageHeader *) msg);
631 return; 620 return;
632 } 621 }
@@ -650,7 +639,7 @@ handle_peer_event (void *cls,
650 event.details.peer_stop.peer = peer; 639 event.details.peer_stop.peer = peer;
651 break; 640 break;
652 default: 641 default:
653 GNUNET_assert (0); /* We should never reach this state */ 642 GNUNET_assert (0); /* We should never reach this state */
654 } 643 }
655 pcc = data->pcc; 644 pcc = data->pcc;
656 pcc_cls = data->pcc_cls; 645 pcc_cls = data->pcc_cls;
@@ -669,7 +658,7 @@ handle_peer_event (void *cls,
669 } 658 }
670 if (NULL != pcc) 659 if (NULL != pcc)
671 pcc (pcc_cls, NULL); 660 pcc (pcc_cls, NULL);
672 /* You could have marked the operation as done by now */ 661 /* You could have marked the operation as done by now */
673 GNUNET_break (GNUNET_NO == exop_check (event.op)); 662 GNUNET_break (GNUNET_NO == exop_check (event.op));
674} 663}
675 664
@@ -702,7 +691,8 @@ handle_peer_conevent (void *cls,
702 } 691 }
703 if (OP_FORWARDED == opc->type) 692 if (OP_FORWARDED == opc->type)
704 { 693 {
705 handle_forwarded_operation_msg (c, opc, 694 handle_forwarded_operation_msg (c,
695 opc,
706 (const struct GNUNET_MessageHeader *) msg); 696 (const struct GNUNET_MessageHeader *) msg);
707 return; 697 return;
708 } 698 }
@@ -720,10 +710,10 @@ handle_peer_conevent (void *cls,
720 event.details.peer_connect.peer2 = data->p2; 710 event.details.peer_connect.peer2 = data->p2;
721 break; 711 break;
722 case GNUNET_TESTBED_ET_DISCONNECT: 712 case GNUNET_TESTBED_ET_DISCONNECT:
723 GNUNET_assert (0); /* FIXME: implement */ 713 GNUNET_assert (0); /* FIXME: implement */
724 break; 714 break;
725 default: 715 default:
726 GNUNET_assert (0); /* Should never reach here */ 716 GNUNET_assert (0); /* Should never reach here */
727 break; 717 break;
728 } 718 }
729 cb = data->cb; 719 cb = data->cb;
@@ -742,7 +732,7 @@ handle_peer_conevent (void *cls,
742 } 732 }
743 if (NULL != cb) 733 if (NULL != cb)
744 cb (cb_cls, opc->op, NULL); 734 cb (cb_cls, opc->op, NULL);
745 /* You could have marked the operation as done by now */ 735 /* You could have marked the operation as done by now */
746 GNUNET_break (GNUNET_NO == exop_check (event.op)); 736 GNUNET_break (GNUNET_NO == exop_check (event.op));
747} 737}
748 738
@@ -755,8 +745,9 @@ handle_peer_conevent (void *cls,
755 * @param msg message received 745 * @param msg message received
756 */ 746 */
757static int 747static int
758check_peer_config (void *cls, 748check_peer_config (
759 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg) 749 void *cls,
750 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg)
760{ 751{
761 /* anything goes? */ 752 /* anything goes? */
762 return GNUNET_OK; 753 return GNUNET_OK;
@@ -771,8 +762,9 @@ check_peer_config (void *cls,
771 * @param msg message received 762 * @param msg message received
772 */ 763 */
773static void 764static void
774handle_peer_config (void *cls, 765handle_peer_config (
775 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg) 766 void *cls,
767 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg)
776{ 768{
777 struct GNUNET_TESTBED_Controller *c = cls; 769 struct GNUNET_TESTBED_Controller *c = cls;
778 struct OperationContext *opc; 770 struct OperationContext *opc;
@@ -791,9 +783,7 @@ handle_peer_config (void *cls,
791 } 783 }
792 if (OP_FORWARDED == opc->type) 784 if (OP_FORWARDED == opc->type)
793 { 785 {
794 handle_forwarded_operation_msg (c, 786 handle_forwarded_operation_msg (c, opc, &msg->header);
795 opc,
796 &msg->header);
797 return; 787 return;
798 } 788 }
799 data = opc->data; 789 data = opc->data;
@@ -817,11 +807,11 @@ handle_peer_config (void *cls,
817 sizeof (struct GNUNET_PeerIdentity)); 807 sizeof (struct GNUNET_PeerIdentity));
818 break; 808 break;
819 case GNUNET_TESTBED_PIT_CONFIGURATION: 809 case GNUNET_TESTBED_PIT_CONFIGURATION:
820 pinfo->result.cfg = /* Freed in oprelease_peer_getinfo */ 810 pinfo->result.cfg = /* Freed in oprelease_peer_getinfo */
821 GNUNET_TESTBED_extract_config_ (&msg->header); 811 GNUNET_TESTBED_extract_config_ (&msg->header);
822 break; 812 break;
823 case GNUNET_TESTBED_PIT_GENERIC: 813 case GNUNET_TESTBED_PIT_GENERIC:
824 GNUNET_assert (0); /* never reach here */ 814 GNUNET_assert (0); /* never reach here */
825 break; 815 break;
826 } 816 }
827 opc->data = pinfo; 817 opc->data = pinfo;
@@ -843,8 +833,9 @@ handle_peer_config (void *cls,
843 * @return #GNUNET_OK if message is well-formed 833 * @return #GNUNET_OK if message is well-formed
844 */ 834 */
845static int 835static int
846check_op_fail_event (void *cls, 836check_op_fail_event (
847 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg) 837 void *cls,
838 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
848{ 839{
849 /* we accept anything as a valid error message */ 840 /* we accept anything as a valid error message */
850 return GNUNET_OK; 841 return GNUNET_OK;
@@ -859,8 +850,9 @@ check_op_fail_event (void *cls,
859 * @param msg message received 850 * @param msg message received
860 */ 851 */
861static void 852static void
862handle_op_fail_event (void *cls, 853handle_op_fail_event (
863 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg) 854 void *cls,
855 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
864{ 856{
865 struct GNUNET_TESTBED_Controller *c = cls; 857 struct GNUNET_TESTBED_Controller *c = cls;
866 struct OperationContext *opc; 858 struct OperationContext *opc;
@@ -877,7 +869,8 @@ handle_op_fail_event (void *cls,
877 } 869 }
878 if (OP_FORWARDED == opc->type) 870 if (OP_FORWARDED == opc->type)
879 { 871 {
880 handle_forwarded_operation_msg (c, opc, 872 handle_forwarded_operation_msg (c,
873 opc,
881 (const struct GNUNET_MessageHeader *) msg); 874 (const struct GNUNET_MessageHeader *) msg);
882 return; 875 return;
883 } 876 }
@@ -894,7 +887,7 @@ handle_op_fail_event (void *cls,
894 if (NULL != data->cb) 887 if (NULL != data->cb)
895 data->cb (data->cb_cls, opc->op, NULL, emsg); 888 data->cb (data->cb_cls, opc->op, NULL, emsg);
896 GNUNET_free (data); 889 GNUNET_free (data);
897 return; /* We do not call controller callback for peer info */ 890 return; /* We do not call controller callback for peer info */
898 } 891 }
899 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 892 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
900 event.op = opc->op; 893 event.op = opc->op;
@@ -911,73 +904,68 @@ handle_op_fail_event (void *cls,
911 } 904 }
912 switch (opc->type) 905 switch (opc->type)
913 { 906 {
914 case OP_PEER_CREATE: 907 case OP_PEER_CREATE: {
915 { 908 struct PeerCreateData *data;
916 struct PeerCreateData *data;
917 909
918 data = opc->data; 910 data = opc->data;
919 GNUNET_free (data->peer); 911 GNUNET_free (data->peer);
920 if (NULL != data->cb) 912 if (NULL != data->cb)
921 data->cb (data->cls, NULL, emsg); 913 data->cb (data->cls, NULL, emsg);
922 GNUNET_free (data); 914 GNUNET_free (data);
923 } 915 }
924 break; 916 break;
925 case OP_PEER_START: 917 case OP_PEER_START:
926 case OP_PEER_STOP: 918 case OP_PEER_STOP: {
927 { 919 struct PeerEventData *data;
928 struct PeerEventData *data;
929 920
930 data = opc->data; 921 data = opc->data;
931 if (NULL != data->pcc) 922 if (NULL != data->pcc)
932 data->pcc (data->pcc_cls, emsg); 923 data->pcc (data->pcc_cls, emsg);
933 GNUNET_free (data); 924 GNUNET_free (data);
934 } 925 }
935 break; 926 break;
936 case OP_PEER_DESTROY: 927 case OP_PEER_DESTROY:
937 break; 928 break;
938 case OP_PEER_INFO: 929 case OP_PEER_INFO:
939 GNUNET_assert (0); 930 GNUNET_assert (0);
940 case OP_OVERLAY_CONNECT: 931 case OP_OVERLAY_CONNECT: {
941 { 932 struct OverlayConnectData *data;
942 struct OverlayConnectData *data;
943 933
944 data = opc->data; 934 data = opc->data;
945 GNUNET_TESTBED_operation_mark_failed (opc->op); 935 GNUNET_TESTBED_operation_mark_failed (opc->op);
946 if (NULL != data->cb) 936 if (NULL != data->cb)
947 data->cb (data->cb_cls, opc->op, emsg); 937 data->cb (data->cb_cls, opc->op, emsg);
948 } 938 }
949 break; 939 break;
950 case OP_FORWARDED: 940 case OP_FORWARDED:
951 GNUNET_assert (0); 941 GNUNET_assert (0);
952 case OP_LINK_CONTROLLERS: /* No secondary callback */ 942 case OP_LINK_CONTROLLERS: /* No secondary callback */
953 break; 943 break;
954 case OP_SHUTDOWN_PEERS: 944 case OP_SHUTDOWN_PEERS: {
955 { 945 struct ShutdownPeersData *data;
956 struct ShutdownPeersData *data;
957 946
958 data = opc->data; 947 data = opc->data;
959 GNUNET_free (data); /* FIXME: Decide whether we call data->op_cb */ 948 GNUNET_free (data); /* FIXME: Decide whether we call data->op_cb */
960 opc->data = NULL; 949 opc->data = NULL;
961 } 950 }
962 break; 951 break;
963 case OP_MANAGE_SERVICE: 952 case OP_MANAGE_SERVICE: {
964 { 953 struct ManageServiceData *data = opc->data;
965 struct ManageServiceData *data = opc->data; 954 GNUNET_TESTBED_OperationCompletionCallback cb;
966 GNUNET_TESTBED_OperationCompletionCallback cb; 955 void *cb_cls;
967 void *cb_cls; 956
968 957 GNUNET_assert (NULL != data);
969 GNUNET_assert (NULL != data); 958 cb = data->cb;
970 cb = data->cb; 959 cb_cls = data->cb_cls;
971 cb_cls = data->cb_cls; 960 GNUNET_free (data);
972 GNUNET_free (data); 961 opc->data = NULL;
973 opc->data = NULL; 962 exop_insert (event.op);
974 exop_insert (event.op); 963 if (NULL != cb)
975 if (NULL != cb) 964 cb (cb_cls, opc->op, emsg);
976 cb (cb_cls, opc->op, emsg); 965 /* You could have marked the operation as done by now */
977 /* You could have marked the operation as done by now */ 966 GNUNET_break (GNUNET_NO == exop_check (event.op));
978 GNUNET_break (GNUNET_NO == exop_check (event.op)); 967 }
979 } 968 break;
980 break;
981 default: 969 default:
982 GNUNET_break (0); 970 GNUNET_break (0);
983 } 971 }
@@ -1001,14 +989,13 @@ GNUNET_TESTBED_generate_slavegetconfig_msg_ (uint64_t op_id, uint32_t slave_id)
1001 msg = GNUNET_malloc (msize); 989 msg = GNUNET_malloc (msize);
1002 msg->header.size = htons (msize); 990 msg->header.size = htons (msize);
1003 msg->header.type = 991 msg->header.type =
1004 htons (GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION); 992 htons (GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION);
1005 msg->operation_id = GNUNET_htonll (op_id); 993 msg->operation_id = GNUNET_htonll (op_id);
1006 msg->slave_id = htonl (slave_id); 994 msg->slave_id = htonl (slave_id);
1007 return msg; 995 return msg;
1008} 996}
1009 997
1010 998
1011
1012/** 999/**
1013 * Validate #GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_INFORMATION message from 1000 * Validate #GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_INFORMATION message from
1014 * controller (testbed service) 1001 * controller (testbed service)
@@ -1056,8 +1043,7 @@ handle_slave_config (void *cls,
1056 opc->state = OPC_STATE_FINISHED; 1043 opc->state = OPC_STATE_FINISHED;
1057 GNUNET_TESTBED_remove_opc_ (opc->c, opc); 1044 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1058 mask = 1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED; 1045 mask = 1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED;
1059 if ((0 != (mask & c->event_mask)) && 1046 if ((0 != (mask & c->event_mask)) && (NULL != c->cc))
1060 (NULL != c->cc))
1061 { 1047 {
1062 opc->data = GNUNET_TESTBED_extract_config_ (&msg->header); 1048 opc->data = GNUNET_TESTBED_extract_config_ (&msg->header);
1063 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 1049 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
@@ -1079,8 +1065,9 @@ handle_slave_config (void *cls,
1079 * @return #GNUNET_OK if @a msg is well-formed 1065 * @return #GNUNET_OK if @a msg is well-formed
1080 */ 1066 */
1081static int 1067static int
1082check_link_controllers_result (void *cls, 1068check_link_controllers_result (
1083 const struct GNUNET_TESTBED_ControllerLinkResponse *msg) 1069 void *cls,
1070 const struct GNUNET_TESTBED_ControllerLinkResponse *msg)
1084{ 1071{
1085 /* actual check to be implemented */ 1072 /* actual check to be implemented */
1086 return GNUNET_OK; 1073 return GNUNET_OK;
@@ -1095,8 +1082,9 @@ check_link_controllers_result (void *cls,
1095 * @param msg message received 1082 * @param msg message received
1096 */ 1083 */
1097static void 1084static void
1098handle_link_controllers_result (void *cls, 1085handle_link_controllers_result (
1099 const struct GNUNET_TESTBED_ControllerLinkResponse *msg) 1086 void *cls,
1087 const struct GNUNET_TESTBED_ControllerLinkResponse *msg)
1100{ 1088{
1101 struct GNUNET_TESTBED_Controller *c = cls; 1089 struct GNUNET_TESTBED_Controller *c = cls;
1102 struct OperationContext *opc; 1090 struct OperationContext *opc;
@@ -1115,7 +1103,8 @@ handle_link_controllers_result (void *cls,
1115 } 1103 }
1116 if (OP_FORWARDED == opc->type) 1104 if (OP_FORWARDED == opc->type)
1117 { 1105 {
1118 handle_forwarded_operation_msg (c, opc, 1106 handle_forwarded_operation_msg (c,
1107 opc,
1119 (const struct GNUNET_MessageHeader *) msg); 1108 (const struct GNUNET_MessageHeader *) msg);
1120 return; 1109 return;
1121 } 1110 }
@@ -1140,19 +1129,21 @@ handle_link_controllers_result (void *cls,
1140 cfg = NULL; 1129 cfg = NULL;
1141 if (GNUNET_NO == ntohs (msg->success)) 1130 if (GNUNET_NO == ntohs (msg->success))
1142 { 1131 {
1143 emsg = GNUNET_malloc (ntohs (msg->header.size) 1132 emsg =
1144 - sizeof (struct 1133 GNUNET_malloc (ntohs (msg->header.size) -
1145 GNUNET_TESTBED_ControllerLinkResponse) + 1); 1134 sizeof (struct GNUNET_TESTBED_ControllerLinkResponse) + 1);
1146 GNUNET_memcpy (emsg, 1135 GNUNET_memcpy (emsg,
1147 &msg[1], 1136 &msg[1],
1148 ntohs (msg->header.size)- sizeof (struct GNUNET_TESTBED_ControllerLinkResponse)); 1137 ntohs (msg->header.size) -
1138 sizeof (struct GNUNET_TESTBED_ControllerLinkResponse));
1149 event.details.operation_finished.emsg = emsg; 1139 event.details.operation_finished.emsg = emsg;
1150 } 1140 }
1151 else 1141 else
1152 { 1142 {
1153 if (0 != ntohs (msg->config_size)) 1143 if (0 != ntohs (msg->config_size))
1154 { 1144 {
1155 cfg = GNUNET_TESTBED_extract_config_ ((const struct GNUNET_MessageHeader *) msg); 1145 cfg = GNUNET_TESTBED_extract_config_ (
1146 (const struct GNUNET_MessageHeader *) msg);
1156 GNUNET_assert (NULL != cfg); 1147 GNUNET_assert (NULL != cfg);
1157 GNUNET_TESTBED_host_replace_cfg_ (host, cfg); 1148 GNUNET_TESTBED_host_replace_cfg_ (host, cfg);
1158 } 1149 }
@@ -1206,8 +1197,8 @@ check_barrier_status (void *cls,
1206 status = ntohs (msg->status); 1197 status = ntohs (msg->status);
1207 if (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status) 1198 if (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status)
1208 { 1199 {
1209 emsg_len = msize - (sizeof (struct GNUNET_TESTBED_BarrierStatusMsg) + name_len 1200 emsg_len = msize - (sizeof (struct GNUNET_TESTBED_BarrierStatusMsg) +
1210 + 1); /* +1!? */ 1201 name_len + 1); /* +1!? */
1211 if (0 == emsg_len) 1202 if (0 == emsg_len)
1212 { 1203 {
1213 GNUNET_break_op (0); 1204 GNUNET_break_op (0);
@@ -1249,8 +1240,8 @@ handle_barrier_status (void *cls,
1249 } 1240 }
1250 name = msg->data; 1241 name = msg->data;
1251 name_len = ntohs (msg->name_len); 1242 name_len = ntohs (msg->name_len);
1252 if (name_len >= //name_len is strlen(barrier_name) 1243 if (name_len >= //name_len is strlen(barrier_name)
1253 (msize - ((sizeof msg->header) + sizeof (msg->status)) ) ) 1244 (msize - ((sizeof msg->header) + sizeof (msg->status))))
1254 { 1245 {
1255 GNUNET_break_op (0); 1246 GNUNET_break_op (0);
1256 goto cleanup; 1247 goto cleanup;
@@ -1266,8 +1257,8 @@ handle_barrier_status (void *cls,
1266 { 1257 {
1267 status = -1; 1258 status = -1;
1268 //unlike name_len, emsg_len includes the trailing zero 1259 //unlike name_len, emsg_len includes the trailing zero
1269 emsg_len = msize - (sizeof (struct GNUNET_TESTBED_BarrierStatusMsg) 1260 emsg_len = msize - (sizeof (struct GNUNET_TESTBED_BarrierStatusMsg) +
1270 + (name_len + 1)); 1261 (name_len + 1));
1271 if (0 == emsg_len) 1262 if (0 == emsg_len)
1272 { 1263 {
1273 GNUNET_break_op (0); 1264 GNUNET_break_op (0);
@@ -1279,9 +1270,7 @@ handle_barrier_status (void *cls,
1279 goto cleanup; 1270 goto cleanup;
1280 } 1271 }
1281 emsg = GNUNET_malloc (emsg_len); 1272 emsg = GNUNET_malloc (emsg_len);
1282 GNUNET_memcpy (emsg, 1273 GNUNET_memcpy (emsg, msg->data + name_len + 1, emsg_len);
1283 msg->data + name_len + 1,
1284 emsg_len);
1285 } 1274 }
1286 if (NULL == c->barrier_map) 1275 if (NULL == c->barrier_map)
1287 { 1276 {
@@ -1298,17 +1287,12 @@ handle_barrier_status (void *cls,
1298 GNUNET_assert (NULL != barrier->cb); 1287 GNUNET_assert (NULL != barrier->cb);
1299 if ((GNUNET_YES == barrier->echo) && 1288 if ((GNUNET_YES == barrier->echo) &&
1300 (GNUNET_TESTBED_BARRIERSTATUS_CROSSED == status)) 1289 (GNUNET_TESTBED_BARRIERSTATUS_CROSSED == status))
1301 GNUNET_TESTBED_queue_message_ (c, 1290 GNUNET_TESTBED_queue_message_ (c, GNUNET_copy_message (&msg->header));
1302 GNUNET_copy_message (&msg->header)); 1291 barrier->cb (barrier->cls, name, barrier, status, emsg);
1303 barrier->cb (barrier->cls,
1304 name,
1305 barrier,
1306 status,
1307 emsg);
1308 if (GNUNET_TESTBED_BARRIERSTATUS_INITIALISED == status) 1292 if (GNUNET_TESTBED_BARRIERSTATUS_INITIALISED == status)
1309 return; /* just initialised; skip cleanup */ 1293 return; /* just initialised; skip cleanup */
1310 1294
1311 cleanup: 1295cleanup:
1312 GNUNET_free_non_null (emsg); 1296 GNUNET_free_non_null (emsg);
1313 /** 1297 /**
1314 * Do not remove the barrier if we did not echo the status back; this is 1298 * Do not remove the barrier if we did not echo the status back; this is
@@ -1340,13 +1324,10 @@ GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller,
1340 size = ntohs (msg->size); 1324 size = ntohs (msg->size);
1341 GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) && 1325 GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) &&
1342 (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type)); 1326 (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type));
1343 env = GNUNET_MQ_msg_extra (m2, 1327 env = GNUNET_MQ_msg_extra (m2, size - sizeof (*m2), type);
1344 size - sizeof (*m2),
1345 type);
1346 GNUNET_memcpy (m2, msg, size); 1328 GNUNET_memcpy (m2, msg, size);
1347 GNUNET_free (msg); 1329 GNUNET_free (msg);
1348 GNUNET_MQ_send (controller->mq, 1330 GNUNET_MQ_send (controller->mq, env);
1349 env);
1350} 1331}
1351 1332
1352 1333
@@ -1365,11 +1346,12 @@ GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller,
1365 * operation 1346 * operation
1366 */ 1347 */
1367struct OperationContext * 1348struct OperationContext *
1368GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller *controller, 1349GNUNET_TESTBED_forward_operation_msg_ (
1369 uint64_t operation_id, 1350 struct GNUNET_TESTBED_Controller *controller,
1370 const struct GNUNET_MessageHeader *msg, 1351 uint64_t operation_id,
1371 GNUNET_MQ_MessageCallback cc, 1352 const struct GNUNET_MessageHeader *msg,
1372 void *cc_cls) 1353 GNUNET_MQ_MessageCallback cc,
1354 void *cc_cls)
1373{ 1355{
1374 struct OperationContext *opc; 1356 struct OperationContext *opc;
1375 struct ForwardedOperationData *data; 1357 struct ForwardedOperationData *data;
@@ -1378,14 +1360,9 @@ GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller *control
1378 uint16_t type = ntohs (msg->type); 1360 uint16_t type = ntohs (msg->type);
1379 uint16_t size = ntohs (msg->size); 1361 uint16_t size = ntohs (msg->size);
1380 1362
1381 env = GNUNET_MQ_msg_extra (m2, 1363 env = GNUNET_MQ_msg_extra (m2, size - sizeof (*m2), type);
1382 size - sizeof (*m2), 1364 GNUNET_memcpy (m2, msg, size);
1383 type); 1365 GNUNET_MQ_send (controller->mq, env);
1384 GNUNET_memcpy (m2,
1385 msg,
1386 size);
1387 GNUNET_MQ_send (controller->mq,
1388 env);
1389 data = GNUNET_new (struct ForwardedOperationData); 1366 data = GNUNET_new (struct ForwardedOperationData);
1390 data->cc = cc; 1367 data->cc = cc;
1391 data->cc_cls = cc_cls; 1368 data->cc_cls = cc_cls;
@@ -1394,8 +1371,7 @@ GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller *control
1394 opc->type = OP_FORWARDED; 1371 opc->type = OP_FORWARDED;
1395 opc->data = data; 1372 opc->data = data;
1396 opc->id = operation_id; 1373 opc->id = operation_id;
1397 GNUNET_TESTBED_insert_opc_ (controller, 1374 GNUNET_TESTBED_insert_opc_ (controller, opc);
1398 opc);
1399 return opc; 1375 return opc;
1400} 1376}
1401 1377
@@ -1409,8 +1385,7 @@ GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller *control
1409void 1385void
1410GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc) 1386GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc)
1411{ 1387{
1412 GNUNET_TESTBED_remove_opc_ (opc->c, 1388 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1413 opc);
1414 GNUNET_free (opc->data); 1389 GNUNET_free (opc->data);
1415 GNUNET_free (opc); 1390 GNUNET_free (opc);
1416} 1391}
@@ -1526,14 +1501,11 @@ oprelease_get_slave_config (void *cls)
1526 * @param error error code 1501 * @param error error code
1527 */ 1502 */
1528static void 1503static void
1529mq_error_handler (void *cls, 1504mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
1530 enum GNUNET_MQ_Error error)
1531{ 1505{
1532 /* struct GNUNET_TESTBED_Controller *c = cls; */ 1506 /* struct GNUNET_TESTBED_Controller *c = cls; */
1533 1507
1534 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1508 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Encountered MQ error: %d\n", error);
1535 "Encountered MQ error: %d\n",
1536 error);
1537 /* now what? */ 1509 /* now what? */
1538 GNUNET_SCHEDULER_shutdown (); /* seems most reasonable */ 1510 GNUNET_SCHEDULER_shutdown (); /* seems most reasonable */
1539} 1511}
@@ -1560,51 +1532,53 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1560 GNUNET_TESTBED_ControllerCallback cc, 1532 GNUNET_TESTBED_ControllerCallback cc,
1561 void *cc_cls) 1533 void *cc_cls)
1562{ 1534{
1563 struct GNUNET_TESTBED_Controller *controller 1535 struct GNUNET_TESTBED_Controller *controller =
1564 = GNUNET_new (struct GNUNET_TESTBED_Controller); 1536 GNUNET_new (struct GNUNET_TESTBED_Controller);
1565 struct GNUNET_MQ_MessageHandler handlers[] = { 1537 struct GNUNET_MQ_MessageHandler handlers[] =
1566 GNUNET_MQ_hd_var_size (add_host_confirm, 1538 {GNUNET_MQ_hd_var_size (add_host_confirm,
1567 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS, 1539 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS,
1568 struct GNUNET_TESTBED_HostConfirmedMessage, 1540 struct GNUNET_TESTBED_HostConfirmedMessage,
1569 controller), 1541 controller),
1570 GNUNET_MQ_hd_fixed_size (peer_conevent, 1542 GNUNET_MQ_hd_fixed_size (peer_conevent,
1571 GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT, 1543 GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT,
1572 struct GNUNET_TESTBED_ConnectionEventMessage, 1544 struct GNUNET_TESTBED_ConnectionEventMessage,
1573 controller), 1545 controller),
1574 GNUNET_MQ_hd_fixed_size (opsuccess, 1546 GNUNET_MQ_hd_fixed_size (opsuccess,
1575 GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS, 1547 GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS,
1576 struct GNUNET_TESTBED_GenericOperationSuccessEventMessage, 1548 struct
1577 controller), 1549 GNUNET_TESTBED_GenericOperationSuccessEventMessage,
1578 GNUNET_MQ_hd_var_size (op_fail_event, 1550 controller),
1579 GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT, 1551 GNUNET_MQ_hd_var_size (op_fail_event,
1580 struct GNUNET_TESTBED_OperationFailureEventMessage, 1552 GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT,
1581 controller), 1553 struct GNUNET_TESTBED_OperationFailureEventMessage,
1582 GNUNET_MQ_hd_fixed_size (peer_create_success, 1554 controller),
1583 GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS, 1555 GNUNET_MQ_hd_fixed_size (peer_create_success,
1584 struct GNUNET_TESTBED_PeerCreateSuccessEventMessage, 1556 GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS,
1585 controller), 1557 struct
1586 GNUNET_MQ_hd_fixed_size (peer_event, 1558 GNUNET_TESTBED_PeerCreateSuccessEventMessage,
1587 GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT, 1559 controller),
1588 struct GNUNET_TESTBED_PeerEventMessage, 1560 GNUNET_MQ_hd_fixed_size (peer_event,
1589 controller), 1561 GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT,
1590 GNUNET_MQ_hd_var_size (peer_config, 1562 struct GNUNET_TESTBED_PeerEventMessage,
1591 GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, 1563 controller),
1592 struct GNUNET_TESTBED_PeerConfigurationInformationMessage, 1564 GNUNET_MQ_hd_var_size (peer_config,
1593 controller), 1565 GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION,
1594 GNUNET_MQ_hd_var_size (slave_config, 1566 struct
1595 GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, 1567 GNUNET_TESTBED_PeerConfigurationInformationMessage,
1596 struct GNUNET_TESTBED_SlaveConfiguration, 1568 controller),
1597 controller), 1569 GNUNET_MQ_hd_var_size (slave_config,
1598 GNUNET_MQ_hd_var_size (link_controllers_result, 1570 GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION,
1599 GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT, 1571 struct GNUNET_TESTBED_SlaveConfiguration,
1600 struct GNUNET_TESTBED_ControllerLinkResponse, 1572 controller),
1601 controller), 1573 GNUNET_MQ_hd_var_size (link_controllers_result,
1602 GNUNET_MQ_hd_var_size (barrier_status, 1574 GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT,
1603 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS, 1575 struct GNUNET_TESTBED_ControllerLinkResponse,
1604 struct GNUNET_TESTBED_BarrierStatusMsg, 1576 controller),
1605 controller), 1577 GNUNET_MQ_hd_var_size (barrier_status,
1606 GNUNET_MQ_handler_end () 1578 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS,
1607 }; 1579 struct GNUNET_TESTBED_BarrierStatusMsg,
1580 controller),
1581 GNUNET_MQ_handler_end ()};
1608 struct GNUNET_TESTBED_InitMessage *msg; 1582 struct GNUNET_TESTBED_InitMessage *msg;
1609 struct GNUNET_MQ_Envelope *env; 1583 struct GNUNET_MQ_Envelope *env;
1610 const struct GNUNET_CONFIGURATION_Handle *cfg; 1584 const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -1616,7 +1590,8 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1616 1590
1617 GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host))); 1591 GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
1618 if (GNUNET_OK != 1592 if (GNUNET_OK !=
1619 GNUNET_CONFIGURATION_get_value_number (cfg, "testbed", 1593 GNUNET_CONFIGURATION_get_value_number (cfg,
1594 "testbed",
1620 "MAX_PARALLEL_OPERATIONS", 1595 "MAX_PARALLEL_OPERATIONS",
1621 &max_parallel_operations)) 1596 &max_parallel_operations))
1622 { 1597 {
@@ -1625,7 +1600,8 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1625 return NULL; 1600 return NULL;
1626 } 1601 }
1627 if (GNUNET_OK != 1602 if (GNUNET_OK !=
1628 GNUNET_CONFIGURATION_get_value_number (cfg, "testbed", 1603 GNUNET_CONFIGURATION_get_value_number (cfg,
1604 "testbed",
1629 "MAX_PARALLEL_SERVICE_CONNECTIONS", 1605 "MAX_PARALLEL_SERVICE_CONNECTIONS",
1630 &max_parallel_service_connections)) 1606 &max_parallel_service_connections))
1631 { 1607 {
@@ -1633,10 +1609,11 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1633 GNUNET_free (controller); 1609 GNUNET_free (controller);
1634 return NULL; 1610 return NULL;
1635 } 1611 }
1636 if (GNUNET_OK != 1612 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (
1637 GNUNET_CONFIGURATION_get_value_number (cfg, "testbed", 1613 cfg,
1638 "MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS", 1614 "testbed",
1639 &max_parallel_topology_config_operations)) 1615 "MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS",
1616 &max_parallel_topology_config_operations))
1640 { 1617 {
1641 GNUNET_break (0); 1618 GNUNET_break (0);
1642 GNUNET_free (controller); 1619 GNUNET_free (controller);
@@ -1660,30 +1637,26 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1660 GNUNET_TESTBED_mark_host_registered_at_ (host, controller); 1637 GNUNET_TESTBED_mark_host_registered_at_ (host, controller);
1661 controller->host = host; 1638 controller->host = host;
1662 controller->opq_parallel_operations = 1639 controller->opq_parallel_operations =
1663 GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_FIXED, 1640 GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_FIXED,
1664 (unsigned int) max_parallel_operations); 1641 (unsigned int)
1642 max_parallel_operations);
1665 controller->opq_parallel_service_connections = 1643 controller->opq_parallel_service_connections =
1666 GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_FIXED, 1644 GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_FIXED,
1667 (unsigned int) 1645 (unsigned int)
1668 max_parallel_service_connections); 1646 max_parallel_service_connections);
1669 controller->opq_parallel_topology_config_operations = 1647 controller->opq_parallel_topology_config_operations =
1670 GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_FIXED, 1648 GNUNET_TESTBED_operation_queue_create_ (
1671 (unsigned int) 1649 OPERATION_QUEUE_TYPE_FIXED,
1672 max_parallel_topology_config_operations); 1650 (unsigned int) max_parallel_topology_config_operations);
1673 controller_hostname = GNUNET_TESTBED_host_get_hostname (host); 1651 controller_hostname = GNUNET_TESTBED_host_get_hostname (host);
1674 if (NULL == controller_hostname) 1652 if (NULL == controller_hostname)
1675 controller_hostname = "127.0.0.1"; 1653 controller_hostname = "127.0.0.1";
1676 slen = strlen (controller_hostname) + 1; 1654 slen = strlen (controller_hostname) + 1;
1677 env = GNUNET_MQ_msg_extra (msg, 1655 env = GNUNET_MQ_msg_extra (msg, slen, GNUNET_MESSAGE_TYPE_TESTBED_INIT);
1678 slen,
1679 GNUNET_MESSAGE_TYPE_TESTBED_INIT);
1680 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host)); 1656 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1681 msg->event_mask = GNUNET_htonll (controller->event_mask); 1657 msg->event_mask = GNUNET_htonll (controller->event_mask);
1682 GNUNET_memcpy (&msg[1], 1658 GNUNET_memcpy (&msg[1], controller_hostname, slen);
1683 controller_hostname, 1659 GNUNET_MQ_send (controller->mq, env);
1684 slen);
1685 GNUNET_MQ_send (controller->mq,
1686 env);
1687 return controller; 1660 return controller;
1688} 1661}
1689 1662
@@ -1731,10 +1704,9 @@ GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *c)
1731 GNUNET_TESTBED_deregister_host_at_ (c->host, c); 1704 GNUNET_TESTBED_deregister_host_at_ (c->host, c);
1732 GNUNET_CONFIGURATION_destroy (c->cfg); 1705 GNUNET_CONFIGURATION_destroy (c->cfg);
1733 GNUNET_TESTBED_operation_queue_destroy_ (c->opq_parallel_operations); 1706 GNUNET_TESTBED_operation_queue_destroy_ (c->opq_parallel_operations);
1734 GNUNET_TESTBED_operation_queue_destroy_ 1707 GNUNET_TESTBED_operation_queue_destroy_ (c->opq_parallel_service_connections);
1735 (c->opq_parallel_service_connections); 1708 GNUNET_TESTBED_operation_queue_destroy_ (
1736 GNUNET_TESTBED_operation_queue_destroy_ 1709 c->opq_parallel_topology_config_operations);
1737 (c->opq_parallel_topology_config_operations);
1738 if (NULL != c->opc_map) 1710 if (NULL != c->opc_map)
1739 { 1711 {
1740 GNUNET_assert (GNUNET_SYSERR != 1712 GNUNET_assert (GNUNET_SYSERR !=
@@ -1766,10 +1738,11 @@ GNUNET_TESTBED_compress_config_ (const char *config,
1766 1738
1767 xsize = compressBound ((uLong) size); 1739 xsize = compressBound ((uLong) size);
1768 *xconfig = GNUNET_malloc (xsize); 1740 *xconfig = GNUNET_malloc (xsize);
1769 GNUNET_assert (Z_OK == 1741 GNUNET_assert (Z_OK == compress2 ((Bytef *) *xconfig,
1770 compress2 ((Bytef *) * xconfig, (uLongf *) & xsize, 1742 (uLongf *) &xsize,
1771 (const Bytef *) config, (uLongf) size, 1743 (const Bytef *) config,
1772 Z_BEST_SPEED)); 1744 (uLongf) size,
1745 Z_BEST_SPEED));
1773 return xsize; 1746 return xsize;
1774} 1747}
1775 1748
@@ -1785,7 +1758,8 @@ GNUNET_TESTBED_compress_config_ (const char *config,
1785 */ 1758 */
1786char * 1759char *
1787GNUNET_TESTBED_compress_cfg_ (const struct GNUNET_CONFIGURATION_Handle *cfg, 1760GNUNET_TESTBED_compress_cfg_ (const struct GNUNET_CONFIGURATION_Handle *cfg,
1788 size_t *size, size_t *xsize) 1761 size_t *size,
1762 size_t *xsize)
1789{ 1763{
1790 char *config; 1764 char *config;
1791 char *xconfig; 1765 char *xconfig;
@@ -1845,9 +1819,8 @@ GNUNET_TESTBED_controller_link (void *op_cls,
1845 1819
1846 GNUNET_assert (GNUNET_YES == 1820 GNUNET_assert (GNUNET_YES ==
1847 GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); 1821 GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
1848 slave_host_id = 1822 slave_host_id = GNUNET_TESTBED_host_get_id_ (
1849 GNUNET_TESTBED_host_get_id_ ((NULL != 1823 (NULL != slave_host) ? slave_host : master->host);
1850 slave_host) ? slave_host : master->host);
1851 delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host); 1824 delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host);
1852 if ((NULL != slave_host) && (0 != slave_host_id)) 1825 if ((NULL != slave_host) && (0 != slave_host_id))
1853 GNUNET_assert (GNUNET_YES == 1826 GNUNET_assert (GNUNET_YES ==
@@ -1870,9 +1843,9 @@ GNUNET_TESTBED_controller_link (void *op_cls,
1870 opc->state = OPC_STATE_INIT; 1843 opc->state = OPC_STATE_INIT;
1871 opc->op_cls = op_cls; 1844 opc->op_cls = op_cls;
1872 msg->operation_id = GNUNET_htonll (opc->id); 1845 msg->operation_id = GNUNET_htonll (opc->id);
1873 opc->op = 1846 opc->op = GNUNET_TESTBED_operation_create_ (opc,
1874 GNUNET_TESTBED_operation_create_ (opc, &opstart_link_controllers, 1847 &opstart_link_controllers,
1875 &oprelease_link_controllers); 1848 &oprelease_link_controllers);
1876 GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, 1849 GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations,
1877 opc->op); 1850 opc->op);
1878 GNUNET_TESTBED_operation_begin_wait_ (opc->op); 1851 GNUNET_TESTBED_operation_begin_wait_ (opc->op);
@@ -1909,9 +1882,9 @@ GNUNET_TESTBED_get_slave_config_ (void *op_cls,
1909 opc->type = OP_GET_SLAVE_CONFIG; 1882 opc->type = OP_GET_SLAVE_CONFIG;
1910 opc->data = data; 1883 opc->data = data;
1911 opc->op_cls = op_cls; 1884 opc->op_cls = op_cls;
1912 opc->op = 1885 opc->op = GNUNET_TESTBED_operation_create_ (opc,
1913 GNUNET_TESTBED_operation_create_ (opc, &opstart_get_slave_config, 1886 &opstart_get_slave_config,
1914 &oprelease_get_slave_config); 1887 &oprelease_get_slave_config);
1915 GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, 1888 GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations,
1916 opc->op); 1889 opc->op);
1917 GNUNET_TESTBED_operation_begin_wait_ (opc->op); 1890 GNUNET_TESTBED_operation_begin_wait_ (opc->op);
@@ -1941,9 +1914,10 @@ GNUNET_TESTBED_get_slave_config (void *op_cls,
1941{ 1914{
1942 if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_ (slave_host, master)) 1915 if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_ (slave_host, master))
1943 return NULL; 1916 return NULL;
1944 return GNUNET_TESTBED_get_slave_config_ (op_cls, master, 1917 return GNUNET_TESTBED_get_slave_config_ (op_cls,
1945 GNUNET_TESTBED_host_get_id_ 1918 master,
1946 (slave_host)); 1919 GNUNET_TESTBED_host_get_id_ (
1920 slave_host));
1947} 1921}
1948 1922
1949 1923
@@ -1957,9 +1931,9 @@ GNUNET_TESTBED_get_slave_config (void *op_cls,
1957 * be written to. 1931 * be written to.
1958 */ 1932 */
1959void 1933void
1960GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller 1934GNUNET_TESTBED_overlay_write_topology_to_file (
1961 *controller, 1935 struct GNUNET_TESTBED_Controller *controller,
1962 const char *filename) 1936 const char *filename)
1963{ 1937{
1964 GNUNET_break (0); 1938 GNUNET_break (0);
1965} 1939}
@@ -1979,10 +1953,10 @@ GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller
1979 * @return the initialization message 1953 * @return the initialization message
1980 */ 1954 */
1981struct GNUNET_TESTBED_HelperInit * 1955struct GNUNET_TESTBED_HelperInit *
1982GNUNET_TESTBED_create_helper_init_msg_ (const char *trusted_ip, 1956GNUNET_TESTBED_create_helper_init_msg_ (
1983 const char *hostname, 1957 const char *trusted_ip,
1984 const struct GNUNET_CONFIGURATION_Handle 1958 const char *hostname,
1985 *cfg) 1959 const struct GNUNET_CONFIGURATION_Handle *cfg)
1986{ 1960{
1987 struct GNUNET_TESTBED_HelperInit *msg; 1961 struct GNUNET_TESTBED_HelperInit *msg;
1988 char *config; 1962 char *config;
@@ -1996,16 +1970,16 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *trusted_ip,
1996 config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); 1970 config = GNUNET_CONFIGURATION_serialize (cfg, &config_size);
1997 GNUNET_assert (NULL != config); 1971 GNUNET_assert (NULL != config);
1998 xconfig_size = 1972 xconfig_size =
1999 GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); 1973 GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
2000 GNUNET_free (config); 1974 GNUNET_free (config);
2001 trusted_ip_len = strlen (trusted_ip); 1975 trusted_ip_len = strlen (trusted_ip);
2002 hostname_len = (NULL == hostname) ? 0 : strlen (hostname); 1976 hostname_len = (NULL == hostname) ? 0 : strlen (hostname);
2003 msg_size = 1977 msg_size = xconfig_size + trusted_ip_len + 1 +
2004 xconfig_size + trusted_ip_len + 1 + 1978 sizeof (struct GNUNET_TESTBED_HelperInit);
2005 sizeof (struct GNUNET_TESTBED_HelperInit);
2006 msg_size += hostname_len; 1979 msg_size += hostname_len;
2007 msg = GNUNET_realloc (xconfig, msg_size); 1980 msg = GNUNET_realloc (xconfig, msg_size);
2008 (void) memmove (((void *) &msg[1]) + trusted_ip_len + 1 + hostname_len, msg, 1981 (void) memmove (((void *) &msg[1]) + trusted_ip_len + 1 + hostname_len,
1982 msg,
2009 xconfig_size); 1983 xconfig_size);
2010 msg->header.size = htons (msg_size); 1984 msg->header.size = htons (msg_size);
2011 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT); 1985 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT);
@@ -2014,7 +1988,7 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *trusted_ip,
2014 msg->config_size = htons (config_size); 1988 msg->config_size = htons (config_size);
2015 (void) strcpy ((char *) &msg[1], trusted_ip); 1989 (void) strcpy ((char *) &msg[1], trusted_ip);
2016 if (0 != hostname_len) 1990 if (0 != hostname_len)
2017 GNUNET_memcpy (&msg[1] + trusted_ip_len + 1, 1991 GNUNET_memcpy ((char *) &msg[1] + trusted_ip_len + 1,
2018 hostname, 1992 hostname,
2019 hostname_len); 1993 hostname_len);
2020 return msg; 1994 return msg;
@@ -2076,77 +2050,70 @@ GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg)
2076 2050
2077 switch (ntohs (msg->type)) 2051 switch (ntohs (msg->type))
2078 { 2052 {
2079 case GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION: 2053 case GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION: {
2080 {
2081 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg; 2054 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg;
2082 2055
2083 imsg = 2056 imsg =
2084 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg; 2057 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg;
2085 data_len = (uLong) ntohs (imsg->config_size); 2058 data_len = (uLong) ntohs (imsg->config_size);
2086 xdata_len = 2059 xdata_len =
2087 ntohs (imsg->header.size) - 2060 ntohs (imsg->header.size) -
2088 sizeof (struct GNUNET_TESTBED_PeerConfigurationInformationMessage); 2061 sizeof (struct GNUNET_TESTBED_PeerConfigurationInformationMessage);
2089 xdata = (const Bytef *) &imsg[1]; 2062 xdata = (const Bytef *) &imsg[1];
2090 } 2063 }
2091 break; 2064 break;
2092 case GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION: 2065 case GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION: {
2093 {
2094 const struct GNUNET_TESTBED_SlaveConfiguration *imsg; 2066 const struct GNUNET_TESTBED_SlaveConfiguration *imsg;
2095 2067
2096 imsg = (const struct GNUNET_TESTBED_SlaveConfiguration *) msg; 2068 imsg = (const struct GNUNET_TESTBED_SlaveConfiguration *) msg;
2097 data_len = (uLong) ntohs (imsg->config_size); 2069 data_len = (uLong) ntohs (imsg->config_size);
2098 xdata_len = 2070 xdata_len = ntohs (imsg->header.size) -
2099 ntohs (imsg->header.size) - 2071 sizeof (struct GNUNET_TESTBED_SlaveConfiguration);
2100 sizeof (struct GNUNET_TESTBED_SlaveConfiguration);
2101 xdata = (const Bytef *) &imsg[1]; 2072 xdata = (const Bytef *) &imsg[1];
2102 } 2073 }
2103 break; 2074 break;
2104 case GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST: 2075 case GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST: {
2105 { 2076 const struct GNUNET_TESTBED_AddHostMessage *imsg;
2106 const struct GNUNET_TESTBED_AddHostMessage *imsg; 2077 uint16_t osize;
2107 uint16_t osize;
2108
2109 imsg = (const struct GNUNET_TESTBED_AddHostMessage *) msg;
2110 data_len = (uLong) ntohs (imsg->config_size);
2111 osize = sizeof (struct GNUNET_TESTBED_AddHostMessage) +
2112 ntohs (imsg->username_length) + ntohs (imsg->hostname_length);
2113 xdata_len = ntohs (imsg->header.size) - osize;
2114 xdata = (const Bytef *) ((const void *) imsg + osize);
2115 }
2116 break;
2117 case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT:
2118 {
2119 const struct GNUNET_TESTBED_ControllerLinkResponse *imsg;
2120 2078
2121 imsg = (const struct GNUNET_TESTBED_ControllerLinkResponse *) msg; 2079 imsg = (const struct GNUNET_TESTBED_AddHostMessage *) msg;
2122 data_len = ntohs (imsg->config_size); 2080 data_len = (uLong) ntohs (imsg->config_size);
2123 xdata_len = ntohs (imsg->header.size) - 2081 osize = sizeof (struct GNUNET_TESTBED_AddHostMessage) +
2124 sizeof (const struct GNUNET_TESTBED_ControllerLinkResponse); 2082 ntohs (imsg->username_length) + ntohs (imsg->hostname_length);
2125 xdata = (const Bytef *) &imsg[1]; 2083 xdata_len = ntohs (imsg->header.size) - osize;
2126 } 2084 xdata = (const Bytef *) ((const void *) imsg + osize);
2127 break; 2085 }
2128 case GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER: 2086 break;
2129 { 2087 case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT: {
2130 const struct GNUNET_TESTBED_PeerCreateMessage *imsg; 2088 const struct GNUNET_TESTBED_ControllerLinkResponse *imsg;
2131 2089
2132 imsg = (const struct GNUNET_TESTBED_PeerCreateMessage *) msg; 2090 imsg = (const struct GNUNET_TESTBED_ControllerLinkResponse *) msg;
2133 data_len = ntohs (imsg->config_size); 2091 data_len = ntohs (imsg->config_size);
2134 xdata_len = ntohs (imsg->header.size) - 2092 xdata_len = ntohs (imsg->header.size) -
2135 sizeof (struct GNUNET_TESTBED_PeerCreateMessage); 2093 sizeof (const struct GNUNET_TESTBED_ControllerLinkResponse);
2136 xdata = (const Bytef *) &imsg[1]; 2094 xdata = (const Bytef *) &imsg[1];
2137 } 2095 }
2138 break; 2096 break;
2139 case GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER: 2097 case GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER: {
2140 { 2098 const struct GNUNET_TESTBED_PeerCreateMessage *imsg;
2141 const struct GNUNET_TESTBED_PeerReconfigureMessage *imsg;
2142 2099
2143 imsg = (const struct GNUNET_TESTBED_PeerReconfigureMessage *) msg; 2100 imsg = (const struct GNUNET_TESTBED_PeerCreateMessage *) msg;
2144 data_len = ntohs (imsg->config_size); 2101 data_len = ntohs (imsg->config_size);
2145 xdata_len = ntohs (imsg->header.size) - 2102 xdata_len = ntohs (imsg->header.size) -
2146 sizeof (struct GNUNET_TESTBED_PeerReconfigureMessage); 2103 sizeof (struct GNUNET_TESTBED_PeerCreateMessage);
2147 xdata = (const Bytef *) &imsg[1]; 2104 xdata = (const Bytef *) &imsg[1];
2148 } 2105 }
2149 break; 2106 break;
2107 case GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER: {
2108 const struct GNUNET_TESTBED_PeerReconfigureMessage *imsg;
2109
2110 imsg = (const struct GNUNET_TESTBED_PeerReconfigureMessage *) msg;
2111 data_len = ntohs (imsg->config_size);
2112 xdata_len = ntohs (imsg->header.size) -
2113 sizeof (struct GNUNET_TESTBED_PeerReconfigureMessage);
2114 xdata = (const Bytef *) &imsg[1];
2115 }
2116 break;
2150 default: 2117 default:
2151 GNUNET_assert (0); 2118 GNUNET_assert (0);
2152 } 2119 }
@@ -2154,18 +2121,17 @@ GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg)
2154 if (Z_OK != (ret = uncompress (data, &data_len, xdata, xdata_len))) 2121 if (Z_OK != (ret = uncompress (data, &data_len, xdata, xdata_len)))
2155 { 2122 {
2156 GNUNET_free (data); 2123 GNUNET_free (data);
2157 GNUNET_break_op (0); /* Un-compression failure */ 2124 GNUNET_break_op (0); /* Un-compression failure */
2158 return NULL; 2125 return NULL;
2159 } 2126 }
2160 cfg = GNUNET_CONFIGURATION_create (); 2127 cfg = GNUNET_CONFIGURATION_create ();
2161 if (GNUNET_OK != 2128 if (GNUNET_OK != GNUNET_CONFIGURATION_deserialize (cfg,
2162 GNUNET_CONFIGURATION_deserialize (cfg, 2129 (const char *) data,
2163 (const char *) data, 2130 (size_t) data_len,
2164 (size_t) data_len, 2131 NULL))
2165 NULL))
2166 { 2132 {
2167 GNUNET_free (data); 2133 GNUNET_free (data);
2168 GNUNET_break_op (0); /* De-serialization failure */ 2134 GNUNET_break_op (0); /* De-serialization failure */
2169 return NULL; 2135 return NULL;
2170 } 2136 }
2171 GNUNET_free (data); 2137 GNUNET_free (data);
@@ -2181,9 +2147,8 @@ GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg)
2181 * @return the error message 2147 * @return the error message
2182 */ 2148 */
2183const char * 2149const char *
2184GNUNET_TESTBED_parse_error_string_ (const struct 2150GNUNET_TESTBED_parse_error_string_ (
2185 GNUNET_TESTBED_OperationFailureEventMessage 2151 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
2186 *msg)
2187{ 2152{
2188 uint16_t msize; 2153 uint16_t msize;
2189 const char *emsg; 2154 const char *emsg;
@@ -2210,7 +2175,7 @@ GNUNET_TESTBED_parse_error_string_ (const struct
2210 * @return the incremented operation id. 2175 * @return the incremented operation id.
2211 */ 2176 */
2212uint64_t 2177uint64_t
2213GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller * controller) 2178GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller)
2214{ 2179{
2215 uint64_t op_id; 2180 uint64_t op_id;
2216 2181
@@ -2234,13 +2199,10 @@ opstart_shutdown_peers (void *cls)
2234 struct GNUNET_TESTBED_ShutdownPeersMessage *msg; 2199 struct GNUNET_TESTBED_ShutdownPeersMessage *msg;
2235 2200
2236 opc->state = OPC_STATE_STARTED; 2201 opc->state = OPC_STATE_STARTED;
2237 env = GNUNET_MQ_msg (msg, 2202 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS);
2238 GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS);
2239 msg->operation_id = GNUNET_htonll (opc->id); 2203 msg->operation_id = GNUNET_htonll (opc->id);
2240 GNUNET_TESTBED_insert_opc_ (opc->c, 2204 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
2241 opc); 2205 GNUNET_MQ_send (opc->c->mq, env);
2242 GNUNET_MQ_send (opc->c->mq,
2243 env);
2244} 2206}
2245 2207
2246 2208
@@ -2302,13 +2264,14 @@ GNUNET_TESTBED_shutdown_peers (struct GNUNET_TESTBED_Controller *c,
2302 opc->c = c; 2264 opc->c = c;
2303 opc->op_cls = op_cls; 2265 opc->op_cls = op_cls;
2304 opc->data = data; 2266 opc->data = data;
2305 opc->id = GNUNET_TESTBED_get_next_op_id (c); 2267 opc->id = GNUNET_TESTBED_get_next_op_id (c);
2306 opc->type = OP_SHUTDOWN_PEERS; 2268 opc->type = OP_SHUTDOWN_PEERS;
2307 opc->state = OPC_STATE_INIT; 2269 opc->state = OPC_STATE_INIT;
2308 opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_shutdown_peers, 2270 opc->op = GNUNET_TESTBED_operation_create_ (opc,
2271 &opstart_shutdown_peers,
2309 &oprelease_shutdown_peers); 2272 &oprelease_shutdown_peers);
2310 GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, 2273 GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations,
2311 opc->op); 2274 opc->op);
2312 GNUNET_TESTBED_operation_begin_wait_ (opc->op); 2275 GNUNET_TESTBED_operation_begin_wait_ (opc->op);
2313 return opc->op; 2276 return opc->op;
2314} 2277}
@@ -2375,7 +2338,8 @@ struct GNUNET_TESTBED_Barrier *
2375GNUNET_TESTBED_barrier_init_ (struct GNUNET_TESTBED_Controller *controller, 2338GNUNET_TESTBED_barrier_init_ (struct GNUNET_TESTBED_Controller *controller,
2376 const char *name, 2339 const char *name,
2377 unsigned int quorum, 2340 unsigned int quorum,
2378 GNUNET_TESTBED_barrier_status_cb cb, void *cls, 2341 GNUNET_TESTBED_barrier_status_cb cb,
2342 void *cls,
2379 int echo) 2343 int echo)
2380{ 2344{
2381 struct GNUNET_TESTBED_BarrierInit *msg; 2345 struct GNUNET_TESTBED_BarrierInit *msg;
@@ -2390,10 +2354,10 @@ GNUNET_TESTBED_barrier_init_ (struct GNUNET_TESTBED_Controller *controller,
2390 GNUNET_assert (0 < name_len); 2354 GNUNET_assert (0 < name_len);
2391 GNUNET_CRYPTO_hash (name, name_len, &key); 2355 GNUNET_CRYPTO_hash (name, name_len, &key);
2392 if (NULL == controller->barrier_map) 2356 if (NULL == controller->barrier_map)
2393 controller->barrier_map = GNUNET_CONTAINER_multihashmap_create (3, GNUNET_YES); 2357 controller->barrier_map =
2358 GNUNET_CONTAINER_multihashmap_create (3, GNUNET_YES);
2394 if (GNUNET_YES == 2359 if (GNUNET_YES ==
2395 GNUNET_CONTAINER_multihashmap_contains (controller->barrier_map, 2360 GNUNET_CONTAINER_multihashmap_contains (controller->barrier_map, &key))
2396 &key))
2397 { 2361 {
2398 GNUNET_break (0); 2362 GNUNET_break (0);
2399 return NULL; 2363 return NULL;
@@ -2407,20 +2371,18 @@ GNUNET_TESTBED_barrier_init_ (struct GNUNET_TESTBED_Controller *controller,
2407 barrier->echo = echo; 2371 barrier->echo = echo;
2408 GNUNET_memcpy (&barrier->key, &key, sizeof (struct GNUNET_HashCode)); 2372 GNUNET_memcpy (&barrier->key, &key, sizeof (struct GNUNET_HashCode));
2409 GNUNET_assert (GNUNET_OK == 2373 GNUNET_assert (GNUNET_OK ==
2410 GNUNET_CONTAINER_multihashmap_put (controller->barrier_map, 2374 GNUNET_CONTAINER_multihashmap_put (
2411 &barrier->key, 2375 controller->barrier_map,
2412 barrier, 2376 &barrier->key,
2413 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); 2377 barrier,
2378 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
2414 2379
2415 env = GNUNET_MQ_msg_extra (msg, 2380 env = GNUNET_MQ_msg_extra (msg,
2416 name_len, 2381 name_len,
2417 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT); 2382 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT);
2418 msg->quorum = (uint8_t) quorum; 2383 msg->quorum = (uint8_t) quorum;
2419 GNUNET_memcpy (msg->name, 2384 GNUNET_memcpy (msg->name, barrier->name, name_len);
2420 barrier->name, 2385 GNUNET_MQ_send (barrier->c->mq, env);
2421 name_len);
2422 GNUNET_MQ_send (barrier->c->mq,
2423 env);
2424 return barrier; 2386 return barrier;
2425} 2387}
2426 2388
@@ -2443,10 +2405,15 @@ struct GNUNET_TESTBED_Barrier *
2443GNUNET_TESTBED_barrier_init (struct GNUNET_TESTBED_Controller *controller, 2405GNUNET_TESTBED_barrier_init (struct GNUNET_TESTBED_Controller *controller,
2444 const char *name, 2406 const char *name,
2445 unsigned int quorum, 2407 unsigned int quorum,
2446 GNUNET_TESTBED_barrier_status_cb cb, void *cls) 2408 GNUNET_TESTBED_barrier_status_cb cb,
2409 void *cls)
2447{ 2410{
2448 return GNUNET_TESTBED_barrier_init_ (controller, 2411 return GNUNET_TESTBED_barrier_init_ (controller,
2449 name, quorum, cb, cls, GNUNET_YES); 2412 name,
2413 quorum,
2414 cb,
2415 cls,
2416 GNUNET_YES);
2450} 2417}
2451 2418
2452 2419
@@ -2463,14 +2430,10 @@ GNUNET_TESTBED_barrier_cancel (struct GNUNET_TESTBED_Barrier *barrier)
2463 size_t slen; 2430 size_t slen;
2464 2431
2465 slen = strlen (barrier->name); 2432 slen = strlen (barrier->name);
2466 env = GNUNET_MQ_msg_extra (msg, 2433 env =
2467 slen, 2434 GNUNET_MQ_msg_extra (msg, slen, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL);
2468 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL); 2435 GNUNET_memcpy (msg->name, barrier->name, slen);
2469 GNUNET_memcpy (msg->name, 2436 GNUNET_MQ_send (barrier->c->mq, env);
2470 barrier->name,
2471 slen);
2472 GNUNET_MQ_send (barrier->c->mq,
2473 env);
2474 GNUNET_TESTBED_barrier_remove_ (barrier); 2437 GNUNET_TESTBED_barrier_remove_ (barrier);
2475} 2438}
2476 2439