diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-07-17 22:25:44 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-07-17 22:25:44 +0000 |
commit | 253d546750130fc4471a7c53355b6f5d58326fc3 (patch) | |
tree | b7c567693f7a4c2e47782d3b05538d8586942dd4 /src/testbed/testbed_api_hosts.c | |
parent | 89daff335a418fb67ce8ea4d3e1e128e96d19877 (diff) | |
download | gnunet-253d546750130fc4471a7c53355b6f5d58326fc3.tar.gz gnunet-253d546750130fc4471a7c53355b6f5d58326fc3.zip |
helper reply with modified config
Diffstat (limited to 'src/testbed/testbed_api_hosts.c')
-rw-r--r-- | src/testbed/testbed_api_hosts.c | 127 |
1 files changed, 0 insertions, 127 deletions
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index f88da52b8..dd08d3a50 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c | |||
@@ -338,133 +338,6 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) | |||
338 | 338 | ||
339 | 339 | ||
340 | /** | 340 | /** |
341 | * Continuation function from GNUNET_HELPER_send() | ||
342 | * | ||
343 | * @param cls closure | ||
344 | * @param result GNUNET_OK on success, | ||
345 | * GNUNET_NO if helper process died | ||
346 | * GNUNET_SYSERR during GNUNET_HELPER_stop | ||
347 | */ | ||
348 | static void | ||
349 | clear_msg (void *cls, int result) | ||
350 | { | ||
351 | GNUNET_free (cls); | ||
352 | } | ||
353 | |||
354 | |||
355 | /** | ||
356 | * Callback that will be called when the helper process dies. This is not called | ||
357 | * when the helper process is stoped using GNUNET_HELPER_stop() | ||
358 | * | ||
359 | * @param cls the closure from GNUNET_HELPER_start() | ||
360 | */ | ||
361 | static void | ||
362 | helper_exp_cb (void *cls) | ||
363 | { | ||
364 | struct GNUNET_TESTBED_HelperHandle *handle = cls; | ||
365 | |||
366 | handle->is_stopped = GNUNET_YES; | ||
367 | GNUNET_TESTBED_host_stop_ (handle); | ||
368 | handle->exp_cb (handle->exp_cb_cls); | ||
369 | } | ||
370 | |||
371 | |||
372 | /** | ||
373 | * Run a given helper process at the given host. Communication | ||
374 | * with the helper will be via GNUnet messages on stdin/stdout. | ||
375 | * Runs the process via 'ssh' at the specified host, or locally. | ||
376 | * Essentially an SSH-wrapper around the 'gnunet_helper_lib.h' API. | ||
377 | * | ||
378 | * @param controller_ip the ip address of the controller. Will be set as TRUSTED | ||
379 | * host when starting testbed controller at host | ||
380 | * @param host host to use, use "NULL" for localhost | ||
381 | * @param binary_argv binary name and command-line arguments to give to the | ||
382 | * binary | ||
383 | * @param cfg template configuration to use for the remote controller; the | ||
384 | * remote controller will be started with a slightly modified | ||
385 | * configuration (port numbers, unix domain sockets and service home | ||
386 | * values are changed as per TESTING library on the remote host) | ||
387 | * @param cb the callback to run when helper process dies; cannot be NULL | ||
388 | * @param cb_cls the closure for the above callback | ||
389 | * @return handle to terminate the command, NULL on error | ||
390 | */ | ||
391 | struct GNUNET_TESTBED_HelperHandle * | ||
392 | GNUNET_TESTBED_host_run_ (const char *controller_ip, | ||
393 | const struct GNUNET_TESTBED_Host *host, | ||
394 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
395 | GNUNET_HELPER_ExceptionCallback cb, | ||
396 | void *cb_cls) | ||
397 | { | ||
398 | struct GNUNET_TESTBED_HelperHandle *h; | ||
399 | struct GNUNET_TESTBED_HelperInit *msg; | ||
400 | |||
401 | GNUNET_assert (NULL != cb); | ||
402 | h = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_HelperHandle)); | ||
403 | h->exp_cb = cb; | ||
404 | h->exp_cb_cls = cb_cls; | ||
405 | h->is_stopped = GNUNET_NO; | ||
406 | if ((NULL == host) || (0 == host->id)) | ||
407 | { | ||
408 | char * const binary_argv[] = { | ||
409 | "gnunet-testbed-helper", NULL | ||
410 | }; | ||
411 | |||
412 | h->helper = | ||
413 | GNUNET_HELPER_start ("gnunet-testbed-helper", binary_argv, NULL, &helper_exp_cb, h); | ||
414 | } | ||
415 | else | ||
416 | { | ||
417 | char *remote_args[6 + 1]; | ||
418 | unsigned int argp; | ||
419 | |||
420 | GNUNET_asprintf (&h->port, "%d", host->port); | ||
421 | if (NULL == host->username) | ||
422 | GNUNET_asprintf (&h->dst, "%s", host->hostname); | ||
423 | else | ||
424 | GNUNET_asprintf (&h->dst, "%s@%s", host->hostname, host->username); | ||
425 | argp = 0; | ||
426 | remote_args[argp++] = "ssh"; | ||
427 | remote_args[argp++] = "-p"; | ||
428 | remote_args[argp++] = h->port; | ||
429 | remote_args[argp++] = "-q"; | ||
430 | remote_args[argp++] = h->dst; | ||
431 | remote_args[argp++] = "gnunet-testbed-helper"; | ||
432 | remote_args[argp++] = NULL; | ||
433 | GNUNET_assert (argp == 6 + 1); | ||
434 | h->helper = GNUNET_HELPER_start ("ssh", remote_args, NULL, &helper_exp_cb, h); | ||
435 | } | ||
436 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg); | ||
437 | if ((NULL == h->helper) || | ||
438 | (NULL == (h->helper_shandle = GNUNET_HELPER_send (h->helper, &msg->header, GNUNET_NO, | ||
439 | &clear_msg, msg)))) | ||
440 | { | ||
441 | GNUNET_free (msg); | ||
442 | GNUNET_free_non_null (h->port); | ||
443 | GNUNET_free_non_null (h->dst); | ||
444 | GNUNET_free (h); | ||
445 | return NULL; | ||
446 | } | ||
447 | return h; | ||
448 | } | ||
449 | |||
450 | |||
451 | /** | ||
452 | * Stops a helper in the HelperHandle using GNUNET_HELPER_stop | ||
453 | * | ||
454 | * @param handle the handle returned from GNUNET_TESTBED_host_start_ | ||
455 | */ | ||
456 | void | ||
457 | GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle) | ||
458 | { | ||
459 | if (GNUNET_YES != handle->is_stopped) | ||
460 | GNUNET_HELPER_stop (handle->helper); | ||
461 | GNUNET_free_non_null (handle->port); | ||
462 | GNUNET_free_non_null (handle->dst); | ||
463 | GNUNET_free (handle); | ||
464 | } | ||
465 | |||
466 | |||
467 | /** | ||
468 | * Marks a host as registered with a controller | 341 | * Marks a host as registered with a controller |
469 | * | 342 | * |
470 | * @param host the host to mark | 343 | * @param host the host to mark |