GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
testbed_api_hosts.c File Reference

API for manipulating 'hosts' controlled by the GNUnet testing service; allows parsing hosts files, starting, stopping and communicating (via SSH/stdin/stdout) with the remote (or local) processes. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "gnunet_core_service.h"
#include "gnunet_transport_service.h"
#include "testbed_api.h"
#include "testbed_api_hosts.h"
#include "testbed_helper.h"
#include "testbed_api_operations.h"
#include <zlib.h>
#include <regex.h>
Include dependency graph for testbed_api_hosts.c:

Go to the source code of this file.

Data Structures

struct  RegisteredController
 A list entry for registered controllers list. More...
 
struct  GNUNET_TESTBED_Host
 Opaque handle to a host running experiments managed by the testing framework. More...
 
struct  GNUNET_TESTBED_ControllerProc
 Handle for controller process. More...
 
struct  GNUNET_TESTBED_HostHabitableCheckHandle
 The handle for whether a host is habitable or not. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__);
 Generic logging shorthand. More...
 
#define LOG_DEBUG(...)   LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);
 Debug logging shorthand. More...
 
#define API_VIOLATION(cond, errstr)
 Prints API violation message. More...
 
#define LOG_GAI(level, cmd, rc)   do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gai_strerror(rc)); } while(0)
 Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the message given by gai_strerror(rc). More...
 
#define HOST_LIST_GROW_STEP   10
 Number of extra elements we create space for when we grow host list. More...
 

Functions

struct GNUNET_TESTBED_HostGNUNET_TESTBED_host_lookup_by_id_ (uint32_t id)
 Lookup a host by ID. More...
 
struct GNUNET_TESTBED_HostGNUNET_TESTBED_host_create_by_id_ (uint32_t id, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create a host by ID; given this host handle, we could not run peers at the host, but we can talk about the host internally. More...
 
uint32_t GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host)
 Obtain the host's unique global ID. More...
 
const char * GNUNET_TESTBED_host_get_hostname (const struct GNUNET_TESTBED_Host *host)
 Obtain the host's hostname. More...
 
const char * GNUNET_TESTBED_host_get_username_ (const struct GNUNET_TESTBED_Host *host)
 Obtain the host's username. More...
 
uint16_t GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host)
 Obtain the host's ssh port. More...
 
int GNUNET_TESTBED_host_controller_started (const struct GNUNET_TESTBED_Host *host)
 Check whether a controller is already started on the given host. More...
 
const struct GNUNET_CONFIGURATION_HandleGNUNET_TESTBED_host_get_cfg_ (const struct GNUNET_TESTBED_Host *host)
 Obtain the host's configuration template. More...
 
void GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *new_cfg)
 Function to replace host's configuration. More...
 
struct GNUNET_TESTBED_HostGNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname, const char *username, const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t port)
 Create a host to run peers and controllers on. More...
 
struct GNUNET_TESTBED_HostGNUNET_TESTBED_host_create (const char *hostname, const char *username, const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t port)
 Create a host to run peers and controllers on. More...
 
unsigned int GNUNET_TESTBED_hosts_load_from_file (const char *filename, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTBED_Host ***hosts)
 Load a set of hosts from a configuration file. More...
 
const char * simple_resolve (const char *host)
 Resolves a hostname using getaddrinfo. More...
 
unsigned int GNUNET_TESTBED_hosts_load_from_loadleveler (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTBED_Host ***hosts)
 Loads the set of host allocated by the LoadLeveler Job Scheduler. More...
 
void GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
 Destroy a host handle. More...
 
void GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, const struct GNUNET_TESTBED_Controller *const controller)
 Marks a host as registered with a controller. More...
 
void GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host, const struct GNUNET_TESTBED_Controller *const controller)
 Unmarks a host registered at a controller. More...
 
int GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host, const struct GNUNET_TESTBED_Controller *const controller)
 Checks whether a host has been registered. More...
 
static char ** copy_argv (const char *const *argv)
 Function to copy NULL terminated list of arguments. More...
 
static char ** join_argv (const char *const *argv1, const char *const *argv2)
 Function to join NULL terminated list of arguments. More...
 
static void free_argv (char **argv)
 Frees the given NULL terminated arguments. More...
 
static char ** gen_rsh_args (const char *port, const char *hostname, const char *username)
 Generates arguments for opening a remote shell. More...
 
static char ** gen_rsh_suffix_args (const char *const *append_args)
 Generates the arguments needed for executing the given binary in a remote shell. More...
 
static int helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
 Functions with this signature are called whenever a complete message is received by the tokenizer. More...
 
static void clear_msg (void *cls, int result)
 Continuation function from GNUNET_HELPER_send() More...
 
static void helper_exp_cb (void *cls)
 Callback that will be called when the helper process dies. More...
 
struct GNUNET_TESTBED_ControllerProcGNUNET_TESTBED_controller_start (const char *trusted_ip, struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_ControllerStatusCallback cb, void *cls)
 Starts a controller process at the given host. More...
 
void GNUNET_TESTBED_controller_kill_ (struct GNUNET_TESTBED_ControllerProc *cproc)
 Sends termination signal to the controller's helper process. More...
 
void GNUNET_TESTBED_controller_destroy_ (struct GNUNET_TESTBED_ControllerProc *cproc)
 Cleans-up the controller's helper process handle. More...
 
void GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cproc)
 Stop the controller process (also will terminate all peers and controllers dependent on this controller). More...
 
static void habitability_check (void *cls)
 Task for checking whether a host is habitable or not. More...
 
struct GNUNET_TESTBED_HostHabitableCheckHandleGNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *config, GNUNET_TESTBED_HostHabitableCallback cb, void *cb_cls)
 Checks whether a host can be used to start testbed service. More...
 
void GNUNET_TESTBED_is_host_habitable_cancel (struct GNUNET_TESTBED_HostHabitableCheckHandle *handle)
 Function to cancel a request started using GNUNET_TESTBED_is_host_habitable() More...
 
struct GNUNET_TESTBED_HostRegistrationHandleGNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_HostRegistrationCompletion cc, void *cc_cls)
 Register a host with the controller. More...
 
void GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle *handle)
 Cancel the pending registration. More...
 
void GNUNET_TESTBED_host_queue_oc_ (struct GNUNET_TESTBED_Host *h, struct GNUNET_TESTBED_Operation *op)
 Queues the given operation in the queue for parallel overlay connects of the given host. More...
 
void GNUNET_TESTBED_host_resolve_ (struct GNUNET_TESTBED_Host *host)
 Resolves the hostname of the host to an ip address. More...
 

Variables

static struct GNUNET_TESTBED_Host ** host_list
 Array of available hosts. More...
 
static unsigned int host_list_size
 The size of the available hosts list. More...
 

Detailed Description

API for manipulating 'hosts' controlled by the GNUnet testing service; allows parsing hosts files, starting, stopping and communicating (via SSH/stdin/stdout) with the remote (or local) processes.

Author
Christian Grothoff

Definition in file testbed_api_hosts.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__);

◆ LOG_DEBUG

#define LOG_DEBUG (   ...)    LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);

Debug logging shorthand.

Definition at line 51 of file testbed_api_hosts.c.

Referenced by GNUNET_TESTBED_controller_start(), and simple_resolve().

◆ API_VIOLATION

#define API_VIOLATION (   cond,
  errstr 
)
Value:
do { \
if (cond) \
break; \
LOG (GNUNET_ERROR_TYPE_ERROR, "API violation detected: %s\n", errstr); \
GNUNET_assert (0); \
} while (0)

Prints API violation message.

Definition at line 57 of file testbed_api_hosts.c.

Referenced by GNUNET_TESTBED_controller_start().

◆ LOG_GAI

#define LOG_GAI (   level,
  cmd,
  rc 
)    do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gai_strerror(rc)); } while(0)

Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the message given by gai_strerror(rc).

Definition at line 69 of file testbed_api_hosts.c.

Referenced by simple_resolve().

◆ HOST_LIST_GROW_STEP

#define HOST_LIST_GROW_STEP   10

Number of extra elements we create space for when we grow host list.

Definition at line 74 of file testbed_api_hosts.c.

Referenced by GNUNET_TESTBED_host_create_with_id(), and GNUNET_TESTBED_host_destroy().

Function Documentation

◆ GNUNET_TESTBED_host_lookup_by_id_()

struct GNUNET_TESTBED_Host* GNUNET_TESTBED_host_lookup_by_id_ ( uint32_t  id)

Lookup a host by ID.

Parameters
idglobal host ID assigned to the host; 0 is reserved to always mean 'localhost'
Returns
handle to the host, NULL if host not found

Definition at line 183 of file testbed_api_hosts.c.

References host_list_size, and id.

Referenced by handle_link_controllers_result().

184 {
185  if (host_list_size <= id)
186  return NULL;
187  return host_list[id];
188 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
static unsigned int host_list_size
The size of the available hosts list.
static struct GNUNET_TESTBED_Host ** host_list
Array of available hosts.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_create_by_id_()

struct GNUNET_TESTBED_Host* GNUNET_TESTBED_host_create_by_id_ ( uint32_t  id,
const struct GNUNET_CONFIGURATION_Handle cfg 
)

Create a host by ID; given this host handle, we could not run peers at the host, but we can talk about the host internally.

Parameters
idglobal host ID assigned to the host; 0 is reserved to always mean 'localhost'
cfgthe configuration to use as a template while starting a controller on this host. Operation queue sizes specific to a host are also read from this configuration handle
Returns
handle to the host, NULL on error

Definition at line 204 of file testbed_api_hosts.c.

References GNUNET_TESTBED_host_create_with_id().

206 {
207  return GNUNET_TESTBED_host_create_with_id (id, NULL, NULL, cfg, 0);
208 }
struct GNUNET_TESTBED_Host * GNUNET_TESTBED_host_create_with_id(uint32_t id, const char *hostname, const char *username, const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t port)
Create a host to run peers and controllers on.
Here is the call graph for this function:

◆ GNUNET_TESTBED_host_get_id_()

uint32_t GNUNET_TESTBED_host_get_id_ ( const struct GNUNET_TESTBED_Host host)

Obtain the host's unique global ID.

Obtain a host's unique global ID.

Parameters
hosthandle to the host, NULL means 'localhost'
Returns
id global host ID assigned to the host (0 is 'localhost', but then obviously not globally unique)

Definition at line 219 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::id.

Referenced by GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_controller_start(), GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_get_slave_config(), GNUNET_TESTBED_hosts_load_from_file(), GNUNET_TESTBED_register_host(), GST_create_neighbour(), GST_queue_host_registration(), handle_add_host_confirm(), hash_hosts(), host_list_add(), hr_completion(), opstart_overlay_connect(), opstart_peer_create(), and register_next_host().

220 {
221  return host->id;
222 }
uint32_t id
Global ID we use to refer to a host on the network.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_get_username_()

const char* GNUNET_TESTBED_host_get_username_ ( const struct GNUNET_TESTBED_Host host)

Obtain the host's username.

Parameters
hosthandle to the host, NULL means 'localhost'
Returns
username to login to the host

Definition at line 245 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_register_host().

246 {
247  return host->username;
248 }
const char * username
The username to be used for SSH login.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_get_ssh_port_()

uint16_t GNUNET_TESTBED_host_get_ssh_port_ ( const struct GNUNET_TESTBED_Host host)

Obtain the host's ssh port.

Parameters
hosthandle to the host, NULL means 'localhost'
Returns
username to login to the host

Definition at line 258 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::port.

Referenced by GNUNET_TESTBED_register_host().

259 {
260  return host->port;
261 }
uint16_t port
The port which is to be used for SSH.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_controller_started()

int GNUNET_TESTBED_host_controller_started ( const struct GNUNET_TESTBED_Host host)

Check whether a controller is already started on the given host.

Parameters
hostthe handle to the host
Returns
GNUNET_YES if the controller is already started; GNUNET_NO if not

Definition at line 271 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::controller_started.

272 {
273  return host->controller_started;
274 }
int controller_started
Is a controller started on this host? FIXME: Is this needed?

◆ GNUNET_TESTBED_host_get_cfg_()

const struct GNUNET_CONFIGURATION_Handle* GNUNET_TESTBED_host_get_cfg_ ( const struct GNUNET_TESTBED_Host host)

Obtain the host's configuration template.

Parameters
hosthandle to the host
Returns
the host's configuration template

Definition at line 284 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::cfg.

Referenced by GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_controller_start(), handle_slave_get_config(), and slave_event_cb().

285 {
286  return host->cfg;
287 }
struct GNUNET_CONFIGURATION_Handle * cfg
the configuration to use as a template while starting a controller on this host.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_replace_cfg_()

void GNUNET_TESTBED_host_replace_cfg_ ( struct GNUNET_TESTBED_Host host,
const struct GNUNET_CONFIGURATION_Handle new_cfg 
)

Function to replace host's configuration.

Parameters
hostthe host handle
new_cfgthe new configuration to replace the old one

Definition at line 297 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::cfg, GNUNET_CONFIGURATION_destroy(), and GNUNET_CONFIGURATION_dup().

Referenced by handle_link_controllers_result().

299 {
301  host->cfg = GNUNET_CONFIGURATION_dup (new_cfg);
302 }
struct GNUNET_CONFIGURATION_Handle * cfg
the configuration to use as a template while starting a controller on this host.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ simple_resolve()

const char* simple_resolve ( const char *  host)

Resolves a hostname using getaddrinfo.

Parameters
hostthe hostname
Returns
the string representing the IPv4 address of the given host; NULL upon error

Definition at line 517 of file testbed_api_hosts.c.

References AI_NUMERICSERV, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, LOG_DEBUG, LOG_GAI, and res.

Referenced by GNUNET_TESTBED_host_resolve_().

518 {
519  struct addrinfo *res;
520  const struct sockaddr_in *in_addr;
521  char *hostip;
522  struct addrinfo hint;
523  unsigned int rc;
524 
525  hint.ai_family = AF_INET; /* IPv4 */
526  hint.ai_socktype = 0;
527  hint.ai_protocol = 0;
528  hint.ai_addrlen = 0;
529  hint.ai_addr = NULL;
530  hint.ai_canonname = NULL;
531  hint.ai_next = NULL;
532  hint.ai_flags = AI_NUMERICSERV;
533  res = NULL;
534  LOG_DEBUG ("Resolving [%s]\n", host);
535  if (0 != (rc = getaddrinfo (host, "22", &hint, &res)))
536  {
537  LOG_GAI (GNUNET_ERROR_TYPE_ERROR, "getaddrinfo", rc);
538  return NULL;
539  }
540  GNUNET_assert (NULL != res);
541  GNUNET_assert (NULL != res->ai_addr);
542  GNUNET_assert (sizeof (struct sockaddr_in) == res->ai_addrlen);
543  in_addr = (const struct sockaddr_in *) res->ai_addr;
544  hostip = inet_ntoa (in_addr->sin_addr);
545  GNUNET_assert (NULL != hostip);
546  freeaddrinfo (res);
547  LOG_DEBUG ("Resolved [%s] to [%s]\n", host, hostip);
548  return hostip;
549 }
#define AI_NUMERICSERV
AI_NUMERICSERV not defined in windows.
Definition: platform.h:261
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define LOG_GAI(level, cmd, rc)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static int res
#define LOG_DEBUG(...)
Debug logging shorthand.
GUID host
Here is the caller graph for this function:

◆ GNUNET_TESTBED_mark_host_registered_at_()

void GNUNET_TESTBED_mark_host_registered_at_ ( struct GNUNET_TESTBED_Host host,
const struct GNUNET_TESTBED_Controller *const  controller 
)

Marks a host as registered with a controller.

Parameters
hostthe host to mark
controllerthe controller at which this host is registered

Definition at line 639 of file testbed_api_hosts.c.

References RegisteredController::controller, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, RegisteredController::next, GNUNET_TESTBED_Host::rc_head, and GNUNET_TESTBED_Host::rc_tail.

Referenced by GNUNET_TESTBED_controller_connect(), and handle_add_host_confirm().

642 {
643  struct RegisteredController *rc;
644 
645  for (rc = host->rc_head; NULL != rc; rc = rc->next)
646  {
647  if (controller == rc->controller) /* already registered at controller */
648  {
649  GNUNET_break (0);
650  return;
651  }
652  }
653  rc = GNUNET_new (struct RegisteredController);
654  rc->controller = controller;
656 }
A list entry for registered controllers list.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct RegisteredController * rc_head
The head for the list of controllers where this host is registered.
struct RegisteredController * next
The next ptr for DLL.
struct RegisteredController * rc_tail
The tail for the list of controllers where this host is registered.
const struct GNUNET_TESTBED_Controller * controller
The controller at which this host is registered.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_deregister_host_at_()

void GNUNET_TESTBED_deregister_host_at_ ( struct GNUNET_TESTBED_Host host,
const struct GNUNET_TESTBED_Controller *const  controller 
)

Unmarks a host registered at a controller.

Parameters
hostthe host to unmark
controllerthe controller at which this host has to be unmarked

Definition at line 666 of file testbed_api_hosts.c.

References RegisteredController::controller, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, RegisteredController::next, GNUNET_TESTBED_Host::rc_head, and GNUNET_TESTBED_Host::rc_tail.

Referenced by GNUNET_TESTBED_controller_disconnect().

669 {
670  struct RegisteredController *rc;
671 
672  for (rc = host->rc_head; NULL != rc; rc=rc->next)
673  if (controller == rc->controller)
674  break;
675  if (NULL == rc)
676  {
677  GNUNET_break (0);
678  return;
679  }
680  GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
681  GNUNET_free (rc);
682 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
A list entry for registered controllers list.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct RegisteredController * rc_head
The head for the list of controllers where this host is registered.
struct RegisteredController * next
The next ptr for DLL.
struct RegisteredController * rc_tail
The tail for the list of controllers where this host is registered.
const struct GNUNET_TESTBED_Controller * controller
The controller at which this host is registered.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_is_host_registered_()

int GNUNET_TESTBED_is_host_registered_ ( const struct GNUNET_TESTBED_Host host,
const struct GNUNET_TESTBED_Controller *const  controller 
)

Checks whether a host has been registered.

Checks whether a host has been registered with the given controller.

Parameters
hostthe host to check
controllerthe controller at which host's registration is checked
Returns
GNUNET_YES if registered; GNUNET_NO if not

Definition at line 693 of file testbed_api_hosts.c.

References RegisteredController::controller, GNUNET_NO, GNUNET_YES, RegisteredController::next, and GNUNET_TESTBED_Host::rc_head.

Referenced by GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_get_slave_config(), GNUNET_TESTBED_register_host(), and lcf_proc_task().

696 {
697  struct RegisteredController *rc;
698 
699  for (rc = host->rc_head; NULL != rc; rc = rc->next)
700  {
701  if (controller == rc->controller) /* already registered at controller */
702  {
703  return GNUNET_YES;
704  }
705  }
706  return GNUNET_NO;
707 }
A list entry for registered controllers list.
#define GNUNET_NO
Definition: gnunet_common.h:81
struct RegisteredController * rc_head
The head for the list of controllers where this host is registered.
struct RegisteredController * next
The next ptr for DLL.
const struct GNUNET_TESTBED_Controller * controller
The controller at which this host is registered.
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the caller graph for this function:

◆ copy_argv()

static char** copy_argv ( const char *const *  argv)
static

Function to copy NULL terminated list of arguments.

Parameters
argvthe NULL terminated list of arguments. Cannot be NULL.
Returns
the copied NULL terminated arguments

Definition at line 760 of file testbed_api_hosts.c.

References GNUNET_assert, GNUNET_malloc, and GNUNET_strdup.

Referenced by gen_rsh_args().

761 {
762  char **argv_dup;
763  unsigned int argp;
764 
765  GNUNET_assert (NULL != argv);
766  for (argp = 0; NULL != argv[argp]; argp++) ;
767  argv_dup = GNUNET_malloc (sizeof (char *) * (argp + 1));
768  for (argp = 0; NULL != argv[argp]; argp++)
769  argv_dup[argp] = GNUNET_strdup (argv[argp]);
770  return argv_dup;
771 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ join_argv()

static char** join_argv ( const char *const *  argv1,
const char *const *  argv2 
)
static

Function to join NULL terminated list of arguments.

Parameters
argv1the NULL terminated list of arguments. Cannot be NULL.
argv2the NULL terminated list of arguments. Cannot be NULL.
Returns
the joined NULL terminated arguments

Definition at line 782 of file testbed_api_hosts.c.

References GNUNET_array_append, and GNUNET_strdup.

Referenced by GNUNET_TESTBED_controller_start(), and GNUNET_TESTBED_is_host_habitable().

783 {
784  char **argvj;
785  char *argv;
786  unsigned int carg;
787  unsigned int cnt;
788 
789  carg = 0;
790  argvj = NULL;
791  for (cnt = 0; NULL != argv1[cnt]; cnt++)
792  {
793  argv = GNUNET_strdup (argv1[cnt]);
794  GNUNET_array_append (argvj, carg, argv);
795  }
796  for (cnt = 0; NULL != argv2[cnt]; cnt++)
797  {
798  argv = GNUNET_strdup (argv2[cnt]);
799  GNUNET_array_append (argvj, carg, argv);
800  }
801  GNUNET_array_append (argvj, carg, NULL);
802  return argvj;
803 }
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char ** argv2
The arguments including the binary to spawn.
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
Here is the caller graph for this function:

◆ free_argv()

static void free_argv ( char **  argv)
static

Frees the given NULL terminated arguments.

Parameters
argvthe NULL terminated list of arguments

Definition at line 812 of file testbed_api_hosts.c.

References GNUNET_free.

Referenced by GNUNET_TESTBED_controller_destroy_(), GNUNET_TESTBED_controller_start(), GNUNET_TESTBED_is_host_habitable(), GNUNET_TESTBED_is_host_habitable_cancel(), and habitability_check().

813 {
814  unsigned int argp;
815 
816  for (argp = 0; NULL != argv[argp]; argp++)
817  GNUNET_free (argv[argp]);
818  GNUNET_free (argv);
819 }
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ gen_rsh_args()

static char** gen_rsh_args ( const char *  port,
const char *  hostname,
const char *  username 
)
static

Generates arguments for opening a remote shell.

Builds up the arguments from the environment variable GNUNET_TESTBED_RSH_CMD. The variable should not mention `-p' (port) option and destination address as these will be set locally in the function from its parameteres. If the environmental variable is not found then it defaults to `ssh -o BatchMode=yes -o NoHostAuthenticationForLocalhost=yes -o StrictHostkeyChecking=no -o PasswordAuthentication=noc'

Parameters
portthe destination port number
hostnamethe hostname of the target host
usernamethe username to use while connecting to target host
Returns
NULL terminated list of arguments

Definition at line 837 of file testbed_api_hosts.c.

References find_typedefs::arg, copy_argv(), getenv(), GNUNET_array_append, GNUNET_array_grow, GNUNET_free, GNUNET_strdup, hostname, port, and size.

Referenced by GNUNET_TESTBED_controller_start(), and GNUNET_TESTBED_is_host_habitable().

838 {
839  static const char *default_ssh_args[] = {
840  "ssh",
841  "-o",
842  "BatchMode=yes",
843  "-o",
844  "NoHostAuthenticationForLocalhost=yes",
845  "-o",
846  "StrictHostKeyChecking=no",
847  "-o",
848  "PasswordAuthentication=no",
849  "%h",
850  NULL
851  };
852  char **ssh_args;
853  char *ssh_cmd;
854  char *ssh_cmd_cp;
855  char *arg;
856  const char *new_arg;
857  unsigned int size;
858  unsigned int cnt;
859 
860  ssh_args = NULL;
861  if (NULL != (ssh_cmd = getenv ("GNUNET_TESTBED_RSH_CMD")))
862  {
863  ssh_cmd = GNUNET_strdup (ssh_cmd);
864  ssh_cmd_cp = ssh_cmd;
865  for (size = 0; NULL != (arg = strtok (ssh_cmd, " ")); ssh_cmd = NULL)
866  GNUNET_array_append (ssh_args, size, GNUNET_strdup (arg));
867  GNUNET_free (ssh_cmd_cp);
868  }
869  else
870  {
871  ssh_args = copy_argv (default_ssh_args);
872  size = (sizeof (default_ssh_args)) / (sizeof (const char *));
873  GNUNET_array_grow (ssh_args, size, size - 1);
874  }
875  for (cnt = 0; cnt < size; cnt++)
876  {
877  arg = ssh_args[cnt];
878  if ('%' != arg[0])
879  continue;
880  switch (arg[1])
881  {
882  case 'p':
883  new_arg = port;
884  break;
885 
886  case 'u':
887  new_arg = username;
888  break;
889 
890  case 'h':
891  new_arg = hostname;
892  break;
893 
894  default:
895  continue;
896  }
897  if (NULL == new_arg)
898  continue;
899  GNUNET_free (arg);
900  ssh_args[cnt] = GNUNET_strdup (new_arg);
901  }
902  GNUNET_array_append (ssh_args, size, NULL);
903  return ssh_args;
904 }
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
static char ** copy_argv(const char *const *argv)
Function to copy NULL terminated list of arguments.
static unsigned int size
Size of the "table".
Definition: peer.c:67
char * getenv()
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
static char * hostname
Our hostname; we give this to all the peers we start.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:79
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gen_rsh_suffix_args()

static char** gen_rsh_suffix_args ( const char *const *  append_args)
static

Generates the arguments needed for executing the given binary in a remote shell.

Builds the arguments from the environmental variable GNUNET_TETSBED_RSH_CMD_SUFFIX. If the environmental variable is not found, only the given binary name will be present in the returned arguments

Parameters
append_argsthe arguments to append after generating the suffix arguments. Can be NULL; if not must be NULL terminated 'char *' array
Returns
NULL-terminated args

Definition at line 918 of file testbed_api_hosts.c.

References find_typedefs::arg, getenv(), GNUNET_array_append, GNUNET_free, and GNUNET_strdup.

Referenced by GNUNET_TESTBED_controller_start(), and GNUNET_TESTBED_is_host_habitable().

919 {
920  char **rshell_args;
921  char *rshell_cmd;
922  char *rshell_cmd_cp;
923  char *arg;
924  unsigned int cnt;
925  unsigned int append_cnt;
926 
927  rshell_args = NULL;
928  cnt = 0;
929  if (NULL != (rshell_cmd = getenv ("GNUNET_TESTBED_RSH_CMD_SUFFIX")))
930  {
931  rshell_cmd = GNUNET_strdup (rshell_cmd);
932  rshell_cmd_cp = rshell_cmd;
933  for (; NULL != (arg = strtok (rshell_cmd, " ")); rshell_cmd = NULL)
934  GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (arg));
935  GNUNET_free (rshell_cmd_cp);
936  }
937  if (NULL != append_args)
938  {
939  for (append_cnt = 0; NULL != append_args[append_cnt]; append_cnt++)
940  GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (append_args[append_cnt]));
941  }
942  GNUNET_array_append (rshell_args, cnt, NULL);
943  return rshell_args;
944 }
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
char * getenv()
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ helper_mst()

static int helper_mst ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Functions with this signature are called whenever a complete message is received by the tokenizer.

Do not call GNUNET_SERVER_mst_destroy in callback

Parameters
clsclosure
clientidentification of the client
messagethe actual message
Returns
GNUNET_OK on success, GNUNET_SYSERR to stop further processing

Definition at line 960 of file testbed_api_hosts.c.

References GNUNET_TESTBED_ControllerProc::cb, GNUNET_TESTBED_Host::cfg, GNUNET_TESTBED_ControllerProc::cls, config, GNUNET_TESTBED_HelperReply::config_size, GNUNET_TESTBED_Host::controller_started, GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_deserialize(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_malloc, GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY, GNUNET_NO, GNUNET_OK, GNUNET_TESTBED_host_get_hostname(), GNUNET_YES, GNUNET_TESTBED_HelperReply::header, GNUNET_TESTBED_ControllerProc::host, hostname, GNUNET_TESTBED_Host::locked, msg, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by GNUNET_TESTBED_controller_start().

962 {
963  struct GNUNET_TESTBED_ControllerProc *cp = cls;
964  const struct GNUNET_TESTBED_HelperReply *msg;
965  const char *hostname;
966  char *config;
967  uLongf config_size;
968  uLongf xconfig_size;
969 
970  msg = (const struct GNUNET_TESTBED_HelperReply *) message;
971  GNUNET_assert (sizeof (struct GNUNET_TESTBED_HelperReply) <
972  ntohs (msg->header.size));
974  ntohs (msg->header.type));
975  config_size = (uLongf) ntohs (msg->config_size);
976  xconfig_size =
977  (uLongf) (ntohs (msg->header.size) -
978  sizeof (struct GNUNET_TESTBED_HelperReply));
979  config = GNUNET_malloc (config_size);
980  GNUNET_assert (Z_OK ==
981  uncompress ((Bytef *) config, &config_size,
982  (const Bytef *) &msg[1], xconfig_size));
983  /* Replace the configuration template present in the host with the
984  controller's running configuration */
988  (cp->host->cfg,
989  config,
990  config_size,
991  NULL));
992  GNUNET_free (config);
993  if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host)))
994  hostname = "localhost";
995  /* Change the hostname so that we can connect to it */
996  GNUNET_CONFIGURATION_set_value_string (cp->host->cfg, "testbed", "hostname",
997  hostname);
998  cp->host->locked = GNUNET_NO;
1000  cp->cb (cp->cls, cp->host->cfg, GNUNET_OK);
1001  return GNUNET_OK;
1002 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
int locked
Is this host locked by GNUNET_TESTBED_controller_start()?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int controller_started
Is a controller started on this host? FIXME: Is this needed?
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Handle for controller process.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct GNUNET_CONFIGURATION_Handle * cfg
the configuration to use as a template while starting a controller on this host.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static const struct GNUNET_CONFIGURATION_Handle * config
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
Reply message from helper process.
#define GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY
The reply message from gnunet-testbed-helper.
GNUNET_TESTBED_ControllerStatusCallback cb
The controller error callback.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY.
const char * GNUNET_TESTBED_host_get_hostname(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s hostname.
static char * hostname
Our hostname; we give this to all the peers we start.
struct GNUNET_TESTBED_Host * host
The host where the helper is run.
void * cls
The closure for the above callback.
#define GNUNET_YES
Definition: gnunet_common.h:80
int GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *basedir)
De-serializes configuration.
uint16_t config_size
Size of the uncompressed configuration.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_msg()

static void clear_msg ( void *  cls,
int  result 
)
static

Continuation function from GNUNET_HELPER_send()

Parameters
clsclosure
resultGNUNET_OK on success, GNUNET_NO if helper process died GNUNET_SYSERR during GNUNET_HELPER_stop

Definition at line 1014 of file testbed_api_hosts.c.

References GNUNET_TESTBED_ControllerProc::cls, GNUNET_assert, GNUNET_free, GNUNET_TESTBED_ControllerProc::msg, and GNUNET_TESTBED_ControllerProc::shandle.

Referenced by GNUNET_TESTBED_controller_start().

1015 {
1016  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1017 
1018  GNUNET_assert (NULL != cp->shandle);
1019  cp->shandle = NULL;
1020  GNUNET_free (cp->msg);
1021  cp->msg = NULL;
1022 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
Handle for controller process.
void * cls
The closure for the above callback.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MessageHeader * msg
The message corresponding to send handle.
Here is the caller graph for this function:

◆ helper_exp_cb()

static void helper_exp_cb ( void *  cls)
static

Callback that will be called when the helper process dies.

This is not called when the helper process is stoped using GNUNET_HELPER_stop()

Parameters
clsthe closure from GNUNET_HELPER_start()

Definition at line 1032 of file testbed_api_hosts.c.

References GNUNET_TESTBED_ControllerProc::cb, GNUNET_TESTBED_ControllerProc::cls, GNUNET_SYSERR, GNUNET_TESTBED_controller_stop(), and GNUNET_TESTBED_ControllerProc::helper.

Referenced by GNUNET_TESTBED_controller_start().

1033 {
1034  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1036  void *cb_cls;
1037 
1038  cb = cp->cb;
1039  cb_cls = cp->cls;
1040  cp->helper = NULL;
1042  if (NULL != cb)
1043  cb (cb_cls, NULL, GNUNET_SYSERR);
1044 }
struct GNUNET_HELPER_Handle * helper
The process handle.
void GNUNET_TESTBED_controller_stop(struct GNUNET_TESTBED_ControllerProc *cproc)
Stop the controller process (also will terminate all peers and controllers dependent on this controll...
Handle for controller process.
void(* GNUNET_TESTBED_ControllerStatusCallback)(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status)
Callback to signal successfull startup of the controller process.
GNUNET_TESTBED_ControllerStatusCallback cb
The controller error callback.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
void * cls
The closure for the above callback.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_controller_kill_()

void GNUNET_TESTBED_controller_kill_ ( struct GNUNET_TESTBED_ControllerProc cproc)

Sends termination signal to the controller's helper process.

Parameters
cprocthe handle to the controller's helper process

Definition at line 1172 of file testbed_api_hosts.c.

References GNUNET_HELPER_kill(), GNUNET_HELPER_send_cancel(), GNUNET_YES, GNUNET_TESTBED_ControllerProc::helper, and GNUNET_TESTBED_ControllerProc::shandle.

Referenced by GNUNET_TESTBED_controller_stop(), and kill_slave().

1173 {
1174  if (NULL != cproc->shandle)
1176  if (NULL != cproc->helper)
1178 }
int GNUNET_HELPER_kill(struct GNUNET_HELPER_Handle *h, int soft_kill)
Sends termination signal to the helper process.
Definition: helper.c:180
struct GNUNET_HELPER_Handle * helper
The process handle.
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
Definition: helper.c:701
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_controller_destroy_()

void GNUNET_TESTBED_controller_destroy_ ( struct GNUNET_TESTBED_ControllerProc cproc)

Cleans-up the controller's helper process handle.

Parameters
cprocthe handle to the controller's helper process

Definition at line 1187 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::controller_started, free_argv(), GNUNET_break, GNUNET_free, GNUNET_free_non_null, GNUNET_HELPER_destroy(), GNUNET_HELPER_wait(), GNUNET_NO, GNUNET_OK, GNUNET_TESTBED_ControllerProc::helper, GNUNET_TESTBED_ControllerProc::helper_argv, GNUNET_TESTBED_ControllerProc::host, GNUNET_TESTBED_Host::locked, and GNUNET_TESTBED_ControllerProc::msg.

Referenced by destroy_slave(), and GNUNET_TESTBED_controller_stop().

1188 {
1189  if (NULL != cproc->helper)
1190  {
1192  GNUNET_HELPER_destroy (cproc->helper);
1193  }
1194  if (NULL != cproc->helper_argv)
1195  free_argv (cproc->helper_argv);
1196  cproc->host->controller_started = GNUNET_NO;
1197  cproc->host->locked = GNUNET_NO;
1198  GNUNET_free_non_null (cproc->msg);
1199  GNUNET_free (cproc);
1200 }
char ** helper_argv
The arguments used to start the helper.
int locked
Is this host locked by GNUNET_TESTBED_controller_start()?
struct GNUNET_HELPER_Handle * helper
The process handle.
int controller_started
Is a controller started on this host? FIXME: Is this needed?
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void free_argv(char **argv)
Frees the given NULL terminated arguments.
struct GNUNET_TESTBED_Host * host
The host where the helper is run.
void GNUNET_HELPER_destroy(struct GNUNET_HELPER_Handle *h)
Free&#39;s the resources occupied by the helper handle.
Definition: helper.c:530
int GNUNET_HELPER_wait(struct GNUNET_HELPER_Handle *h)
Reap the helper process.
Definition: helper.c:231
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MessageHeader * msg
The message corresponding to send handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ habitability_check()

static void habitability_check ( void *  cls)
static

Task for checking whether a host is habitable or not.

Parameters
clsGNUNET_TESTBED_HostHabitableCheckHandle

Definition at line 1269 of file testbed_api_hosts.c.

References GNUNET_TESTBED_HostHabitableCheckHandle::auxp, GNUNET_TESTBED_HostHabitableCheckHandle::cb, GNUNET_TESTBED_HostHabitableCheckHandle::cb_cls, free_argv(), GNUNET_break, GNUNET_free, GNUNET_NO, GNUNET_OS_process_destroy(), GNUNET_OS_process_status(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SYSERR, GNUNET_TIME_STD_BACKOFF, GNUNET_YES, h, GNUNET_TESTBED_HostHabitableCheckHandle::habitability_check_task, GNUNET_TESTBED_HostHabitableCheckHandle::helper_argv, host, GNUNET_TESTBED_HostHabitableCheckHandle::host, ret, type, and GNUNET_TESTBED_HostHabitableCheckHandle::wait_time.

Referenced by GNUNET_TESTBED_is_host_habitable().

1270 {
1272  void *cb_cls;
1274  const struct GNUNET_TESTBED_Host *host;
1275  unsigned long code;
1277  int ret;
1278 
1279  h->habitability_check_task = NULL;
1280  ret = GNUNET_OS_process_status (h->auxp, &type, &code);
1281  if (GNUNET_SYSERR == ret)
1282  {
1283  GNUNET_break (0);
1284  ret = GNUNET_NO;
1285  goto call_cb;
1286  }
1287  if (GNUNET_NO == ret)
1288  {
1292  return;
1293  }
1295  h->auxp = NULL;
1296  ret = (0 != code) ? GNUNET_NO : GNUNET_YES;
1297 
1298 call_cb:
1299  if (NULL != h->auxp)
1301  cb = h->cb;
1302  cb_cls = h->cb_cls;
1303  host = h->host;
1304  free_argv (h->helper_argv);
1305  GNUNET_free (h);
1306  if (NULL != cb)
1307  cb (cb_cls, host, ret);
1308 }
struct GNUNET_OS_Process * auxp
The process handle for the SSH process.
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
Definition: os_priority.c:364
int GNUNET_OS_process_status(struct GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type, unsigned long *code)
Retrieve the status of a process, waiting on it if dead.
Definition: os_priority.c:1719
const struct GNUNET_TESTBED_Host * host
The host to check.
struct GNUNET_SCHEDULER_Task * habitability_check_task
Task id for the habitability check task.
#define GNUNET_NO
Definition: gnunet_common.h:81
Opaque handle to a host running experiments managed by the testing framework.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
GNUNET_TESTBED_HostHabitableCallback cb
The callback to call once we have the status.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
static void free_argv(char **argv)
Frees the given NULL terminated arguments.
GNUNET_OS_ProcessStatusType
Process status types.
void(* GNUNET_TESTBED_HostHabitableCallback)(void *cls, const struct GNUNET_TESTBED_Host *host, int status)
Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to inform whether the given hos...
The handle for whether a host is habitable or not.
struct GNUNET_TIME_Relative wait_time
How long we wait before checking the process status.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
GUID host
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static void habitability_check(void *cls)
Task for checking whether a host is habitable or not.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:80
char ** helper_argv
The arguments used to start the helper.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_queue_oc_()

void GNUNET_TESTBED_host_queue_oc_ ( struct GNUNET_TESTBED_Host h,
struct GNUNET_TESTBED_Operation op 
)

Queues the given operation in the queue for parallel overlay connects of the given host.

Parameters
hthe host handle
opthe operation to queue in the given host's parally overlay connect queue

Definition at line 1511 of file testbed_api_hosts.c.

References GNUNET_TESTBED_operation_queue_insert_(), and GNUNET_TESTBED_Host::opq_parallel_overlay_connect_operations.

Referenced by GNUNET_TESTBED_overlay_connect().

1513 {
1516 }
struct OperationQueue * opq_parallel_overlay_connect_operations
Operation queue for simultaneous overlay connect operations target at this host.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_resolve_()

void GNUNET_TESTBED_host_resolve_ ( struct GNUNET_TESTBED_Host host)

Resolves the hostname of the host to an ip address.

Parameters
hostthe host whose hostname is to be resolved

Definition at line 1525 of file testbed_api_hosts.c.

References GNUNET_break, GNUNET_free, GNUNET_strdup, hostname, GNUNET_TESTBED_Host::hostname, and simple_resolve().

Referenced by host_habitable_cb().

1526 {
1527  char *hostname;
1528 
1529  hostname = (char *) host->hostname;
1530  host->hostname = simple_resolve (hostname);
1531  if (NULL == host->hostname)
1532  {
1533  GNUNET_break (0);
1534  host->hostname = hostname;
1535  return;
1536  }
1537  GNUNET_free (hostname);
1538  host->hostname = GNUNET_strdup (host->hostname);
1539 }
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
const char * simple_resolve(const char *host)
Resolves a hostname using getaddrinfo.
const char * hostname
The hostname of the host; NULL for localhost.
static char * hostname
Our hostname; we give this to all the peers we start.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ host_list

struct GNUNET_TESTBED_Host** host_list
static

Array of available hosts.

Definition at line 167 of file testbed_api_hosts.c.

◆ host_list_size

unsigned int host_list_size
static

The size of the available hosts list.

Definition at line 172 of file testbed_api_hosts.c.

Referenced by GNUNET_TESTBED_host_create_with_id(), GNUNET_TESTBED_host_destroy(), and GNUNET_TESTBED_host_lookup_by_id_().