GNUnet  0.11.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)
 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 50 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 55 of file testbed_api_hosts.c.

Referenced by GNUNET_TESTBED_controller_start().

◆ LOG_GAI

#define LOG_GAI (   level,
  cmd,
  rc 
)
Value:
do \
{ \
LOG (level, \
_ ("`%s' failed at %s:%d with error: %s\n"), \
cmd, \
__FILE__, \
__LINE__, \
gai_strerror (rc)); \
} while (0)
#define _(String)
GNU gettext support macro.
Definition: platform.h:181

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 68 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 82 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 189 of file testbed_api_hosts.c.

References host_list_size, and id.

Referenced by handle_link_controllers_result().

190 {
191  if (host_list_size <= id)
192  return NULL;
193  return host_list[id];
194 }
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 210 of file testbed_api_hosts.c.

References GNUNET_TESTBED_host_create_with_id().

213 {
214  return GNUNET_TESTBED_host_create_with_id (id, NULL, NULL, cfg, 0);
215 }
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 226 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().

227 {
228  return host->id;
229 }
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 252 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_register_host().

253 {
254  return host->username;
255 }
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 265 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::port.

Referenced by GNUNET_TESTBED_register_host().

266 {
267  return host->port;
268 }
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 278 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::controller_started.

279 {
280  return host->controller_started;
281 }
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 291 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().

292 {
293  return host->cfg;
294 }
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 304 of file testbed_api_hosts.c.

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

Referenced by handle_link_controllers_result().

307 {
309  host->cfg = GNUNET_CONFIGURATION_dup (new_cfg);
310 }
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 535 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_().

536 {
537  struct addrinfo *res;
538  const struct sockaddr_in *in_addr;
539  char *hostip;
540  struct addrinfo hint;
541  unsigned int rc;
542 
543  hint.ai_family = AF_INET; /* IPv4 */
544  hint.ai_socktype = 0;
545  hint.ai_protocol = 0;
546  hint.ai_addrlen = 0;
547  hint.ai_addr = NULL;
548  hint.ai_canonname = NULL;
549  hint.ai_next = NULL;
550  hint.ai_flags = AI_NUMERICSERV;
551  res = NULL;
552  LOG_DEBUG ("Resolving [%s]\n", host);
553  if (0 != (rc = getaddrinfo (host, "22", &hint, &res)))
554  {
555  LOG_GAI (GNUNET_ERROR_TYPE_ERROR, "getaddrinfo", rc);
556  return NULL;
557  }
558  GNUNET_assert (NULL != res);
559  GNUNET_assert (NULL != res->ai_addr);
560  GNUNET_assert (sizeof(struct sockaddr_in) == res->ai_addrlen);
561  in_addr = (const struct sockaddr_in *) res->ai_addr;
562  hostip = inet_ntoa (in_addr->sin_addr);
563  GNUNET_assert (NULL != hostip);
564  freeaddrinfo (res);
565  LOG_DEBUG ("Resolved [%s] to [%s]\n", host, hostip);
566  return hostip;
567 }
#define AI_NUMERICSERV
AI_NUMERICSERV not defined in windows.
Definition: platform.h:227
#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.
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 657 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().

660 {
661  struct RegisteredController *rc;
662 
663  for (rc = host->rc_head; NULL != rc; rc = rc->next)
664  {
665  if (controller == rc->controller) /* already registered at controller */
666  {
667  GNUNET_break (0);
668  return;
669  }
670  }
671  rc = GNUNET_new (struct RegisteredController);
672  rc->controller = controller;
674 }
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 684 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().

687 {
688  struct RegisteredController *rc;
689 
690  for (rc = host->rc_head; NULL != rc; rc = rc->next)
691  if (controller == rc->controller)
692  break;
693  if (NULL == rc)
694  {
695  GNUNET_break (0);
696  return;
697  }
698  GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
699  GNUNET_free (rc);
700 }
#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 711 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().

714 {
715  struct RegisteredController *rc;
716 
717  for (rc = host->rc_head; NULL != rc; rc = rc->next)
718  {
719  if (controller == rc->controller) /* already registered at controller */
720  {
721  return GNUNET_YES;
722  }
723  }
724  return GNUNET_NO;
725 }
A list entry for registered controllers list.
#define GNUNET_NO
Definition: gnunet_common.h:78
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:77
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 777 of file testbed_api_hosts.c.

References GNUNET_assert, GNUNET_malloc, and GNUNET_strdup.

Referenced by gen_rsh_args().

778 {
779  char **argv_dup;
780  unsigned int argp;
781 
782  GNUNET_assert (NULL != argv);
783  for (argp = 0; NULL != argv[argp]; argp++)
784  ;
785  argv_dup = GNUNET_malloc (sizeof(char *) * (argp + 1));
786  for (argp = 0; NULL != argv[argp]; argp++)
787  argv_dup[argp] = GNUNET_strdup (argv[argp]);
788  return argv_dup;
789 }
#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 800 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().

801 {
802  char **argvj;
803  char *argv;
804  unsigned int carg;
805  unsigned int cnt;
806 
807  carg = 0;
808  argvj = NULL;
809  for (cnt = 0; NULL != argv1[cnt]; cnt++)
810  {
811  argv = GNUNET_strdup (argv1[cnt]);
812  GNUNET_array_append (argvj, carg, argv);
813  }
814  for (cnt = 0; NULL != argv2[cnt]; cnt++)
815  {
816  argv = GNUNET_strdup (argv2[cnt]);
817  GNUNET_array_append (argvj, carg, argv);
818  }
819  GNUNET_array_append (argvj, carg, NULL);
820  return argvj;
821 }
#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 830 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().

831 {
832  unsigned int argp;
833 
834  for (argp = 0; NULL != argv[argp]; argp++)
835  GNUNET_free (argv[argp]);
836  GNUNET_free (argv);
837 }
#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 855 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().

856 {
857  static const char *default_ssh_args[] =
858  { "ssh",
859  "-o",
860  "BatchMode=yes",
861  "-o",
862  "NoHostAuthenticationForLocalhost=yes",
863  "-o",
864  "StrictHostKeyChecking=no",
865  "-o",
866  "PasswordAuthentication=no",
867  "%h",
868  NULL };
869  char **ssh_args;
870  char *ssh_cmd;
871  char *ssh_cmd_cp;
872  char *arg;
873  const char *new_arg;
874  unsigned int size;
875  unsigned int cnt;
876 
877  ssh_args = NULL;
878  if (NULL != (ssh_cmd = getenv ("GNUNET_TESTBED_RSH_CMD")))
879  {
880  ssh_cmd = GNUNET_strdup (ssh_cmd);
881  ssh_cmd_cp = ssh_cmd;
882  for (size = 0; NULL != (arg = strtok (ssh_cmd, " ")); ssh_cmd = NULL)
883  GNUNET_array_append (ssh_args, size, GNUNET_strdup (arg));
884  GNUNET_free (ssh_cmd_cp);
885  }
886  else
887  {
888  ssh_args = copy_argv (default_ssh_args);
889  size = (sizeof(default_ssh_args)) / (sizeof(const char *));
890  GNUNET_array_grow (ssh_args, size, size - 1);
891  }
892  for (cnt = 0; cnt < size; cnt++)
893  {
894  arg = ssh_args[cnt];
895  if ('%' != arg[0])
896  continue;
897  switch (arg[1])
898  {
899  case 'p':
900  new_arg = port;
901  break;
902 
903  case 'u':
904  new_arg = username;
905  break;
906 
907  case 'h':
908  new_arg = hostname;
909  break;
910 
911  default:
912  continue;
913  }
914  if (NULL == new_arg)
915  continue;
916  GNUNET_free (arg);
917  ssh_args[cnt] = GNUNET_strdup (new_arg);
918  }
919  GNUNET_array_append (ssh_args, size, NULL);
920  return ssh_args;
921 }
#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:81
#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 935 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().

936 {
937  char **rshell_args;
938  char *rshell_cmd;
939  char *rshell_cmd_cp;
940  char *arg;
941  unsigned int cnt;
942  unsigned int append_cnt;
943 
944  rshell_args = NULL;
945  cnt = 0;
946  if (NULL != (rshell_cmd = getenv ("GNUNET_TESTBED_RSH_CMD_SUFFIX")))
947  {
948  rshell_cmd = GNUNET_strdup (rshell_cmd);
949  rshell_cmd_cp = rshell_cmd;
950  for (; NULL != (arg = strtok (rshell_cmd, " ")); rshell_cmd = NULL)
951  GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (arg));
952  GNUNET_free (rshell_cmd_cp);
953  }
954  if (NULL != append_args)
955  {
956  for (append_cnt = 0; NULL != append_args[append_cnt]; append_cnt++)
957  GNUNET_array_append (rshell_args,
958  cnt,
959  GNUNET_strdup (append_args[append_cnt]));
960  }
961  GNUNET_array_append (rshell_args, cnt, NULL);
962  return rshell_args;
963 }
#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 979 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().

980 {
981  struct GNUNET_TESTBED_ControllerProc *cp = cls;
982  const struct GNUNET_TESTBED_HelperReply *msg;
983  const char *hostname;
984  char *config;
985  uLongf config_size;
986  uLongf xconfig_size;
987 
988  msg = (const struct GNUNET_TESTBED_HelperReply *) message;
989  GNUNET_assert (sizeof(struct GNUNET_TESTBED_HelperReply) <
990  ntohs (msg->header.size));
992  ntohs (msg->header.type));
993  config_size = (uLongf) ntohs (msg->config_size);
994  xconfig_size = (uLongf) (ntohs (msg->header.size)
995  - sizeof(struct GNUNET_TESTBED_HelperReply));
996  config = GNUNET_malloc (config_size);
997  GNUNET_assert (Z_OK == uncompress ((Bytef *) config,
998  &config_size,
999  (const Bytef *) &msg[1],
1000  xconfig_size));
1001  /* Replace the configuration template present in the host with the
1002  controller's running configuration */
1006  config,
1007  config_size,
1008  NULL));
1009  GNUNET_free (config);
1010  if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host)))
1011  hostname = "localhost";
1012  /* Change the hostname so that we can connect to it */
1014  "testbed",
1015  "hostname",
1016  hostname);
1017  cp->host->locked = GNUNET_NO;
1019  cp->cb (cp->cls, cp->host->cfg, GNUNET_OK);
1020  return GNUNET_OK;
1021 }
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:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:77
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 1033 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().

1034 {
1035  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1036 
1037  GNUNET_assert (NULL != cp->shandle);
1038  cp->shandle = NULL;
1039  GNUNET_free (cp->msg);
1040  cp->msg = NULL;
1041 }
#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 1051 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().

1052 {
1053  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1055  void *cb_cls;
1056 
1057  cb = cp->cb;
1058  cb_cls = cp->cls;
1059  cp->helper = NULL;
1061  if (NULL != cb)
1062  cb (cb_cls, NULL, GNUNET_SYSERR);
1063 }
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:76
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 1200 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().

1201 {
1202  if (NULL != cproc->shandle)
1204  if (NULL != cproc->helper)
1206 }
int GNUNET_HELPER_kill(struct GNUNET_HELPER_Handle *h, int soft_kill)
Sends termination signal to the helper process.
Definition: helper.c:177
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:695
#define GNUNET_YES
Definition: gnunet_common.h:77
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 1215 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().

1216 {
1217  if (NULL != cproc->helper)
1218  {
1220  GNUNET_HELPER_destroy (cproc->helper);
1221  }
1222  if (NULL != cproc->helper_argv)
1223  free_argv (cproc->helper_argv);
1224  cproc->host->controller_started = GNUNET_NO;
1225  cproc->host->locked = GNUNET_NO;
1226  GNUNET_free_non_null (cproc->msg);
1227  GNUNET_free (cproc);
1228 }
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:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#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:528
int GNUNET_HELPER_wait(struct GNUNET_HELPER_Handle *h)
Reap the helper process.
Definition: helper.c:225
#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 1296 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, GNUNET_TESTBED_HostHabitableCheckHandle::host, ret, type, and GNUNET_TESTBED_HostHabitableCheckHandle::wait_time.

Referenced by GNUNET_TESTBED_is_host_habitable().

1297 {
1299  void *cb_cls;
1301  const struct GNUNET_TESTBED_Host *host;
1302  unsigned long code;
1304  int ret;
1305 
1306  h->habitability_check_task = NULL;
1307  ret = GNUNET_OS_process_status (h->auxp, &type, &code);
1308  if (GNUNET_SYSERR == ret)
1309  {
1310  GNUNET_break (0);
1311  ret = GNUNET_NO;
1312  goto call_cb;
1313  }
1314  if (GNUNET_NO == ret)
1315  {
1319  return;
1320  }
1322  h->auxp = NULL;
1323  ret = (0 != code) ? GNUNET_NO : GNUNET_YES;
1324 
1325 call_cb:
1326  if (NULL != h->auxp)
1328  cb = h->cb;
1329  cb_cls = h->cb_cls;
1330  host = h->host;
1331  free_argv (h->helper_argv);
1332  GNUNET_free (h);
1333  if (NULL != cb)
1334  cb (cb_cls, host, ret);
1335 }
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:287
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:963
const struct GNUNET_TESTBED_Host * host
The host to check.
struct GNUNET_SCHEDULER_Task * habitability_check_task
Task id for the habitability check task.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_NO
Definition: gnunet_common.h:78
Opaque handle to a host running experiments managed by the testing framework.
#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:99
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:1253
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:76
#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:77
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 1542 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().

1544 {
1547  op);
1548 }
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 1557 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().

1558 {
1559  char *hostname;
1560 
1561  hostname = (char *) host->hostname;
1562  host->hostname = simple_resolve (hostname);
1563  if (NULL == host->hostname)
1564  {
1565  GNUNET_break (0);
1566  host->hostname = hostname;
1567  return;
1568  }
1569  GNUNET_free (hostname);
1570  host->hostname = GNUNET_strdup (host->hostname);
1571 }
#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 173 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 178 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_().