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)
 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 187 of file testbed_api_hosts.c.

References host_list_size, and id.

Referenced by handle_link_controllers_result().

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

References GNUNET_TESTBED_host_create_with_id().

211 {
212  return GNUNET_TESTBED_host_create_with_id(id, NULL, NULL, cfg, 0);
213 }
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 224 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().

225 {
226  return host->id;
227 }
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 250 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_register_host().

251 {
252  return host->username;
253 }
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 263 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::port.

Referenced by GNUNET_TESTBED_register_host().

264 {
265  return host->port;
266 }
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 276 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::controller_started.

277 {
278  return host->controller_started;
279 }
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 289 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().

290 {
291  return host->cfg;
292 }
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 302 of file testbed_api_hosts.c.

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

Referenced by handle_link_controllers_result().

305 {
307  host->cfg = GNUNET_CONFIGURATION_dup(new_cfg);
308 }
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 533 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_().

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

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

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

712 {
713  struct RegisteredController *rc;
714 
715  for (rc = host->rc_head; NULL != rc; rc = rc->next)
716  {
717  if (controller == rc->controller) /* already registered at controller */
718  {
719  return GNUNET_YES;
720  }
721  }
722  return GNUNET_NO;
723 }
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 774 of file testbed_api_hosts.c.

References GNUNET_assert, GNUNET_malloc, and GNUNET_strdup.

Referenced by gen_rsh_args().

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

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

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

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

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

977 {
978  struct GNUNET_TESTBED_ControllerProc *cp = cls;
979  const struct GNUNET_TESTBED_HelperReply *msg;
980  const char *hostname;
981  char *config;
982  uLongf config_size;
983  uLongf xconfig_size;
984 
985  msg = (const struct GNUNET_TESTBED_HelperReply *)message;
987  ntohs(msg->header.size));
989  ntohs(msg->header.type));
990  config_size = (uLongf)ntohs(msg->config_size);
991  xconfig_size = (uLongf)(ntohs(msg->header.size) -
992  sizeof(struct GNUNET_TESTBED_HelperReply));
993  config = GNUNET_malloc(config_size);
994  GNUNET_assert(Z_OK == uncompress((Bytef *)config,
995  &config_size,
996  (const Bytef *)&msg[1],
997  xconfig_size));
998  /* Replace the configuration template present in the host with the
999  controller's running configuration */
1003  config,
1004  config_size,
1005  NULL));
1006  GNUNET_free(config);
1007  if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname(cp->host)))
1008  hostname = "localhost";
1009  /* Change the hostname so that we can connect to it */
1011  "testbed",
1012  "hostname",
1013  hostname);
1014  cp->host->locked = GNUNET_NO;
1016  cp->cb(cp->cls, cp->host->cfg, GNUNET_OK);
1017  return GNUNET_OK;
1018 }
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 1030 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().

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

1049 {
1050  struct GNUNET_TESTBED_ControllerProc *cp = cls;
1052  void *cb_cls;
1053 
1054  cb = cp->cb;
1055  cb_cls = cp->cls;
1056  cp->helper = NULL;
1058  if (NULL != cb)
1059  cb(cb_cls, NULL, GNUNET_SYSERR);
1060 }
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 1197 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().

1198 {
1199  if (NULL != cproc->shandle)
1201  if (NULL != cproc->helper)
1203 }
int GNUNET_HELPER_kill(struct GNUNET_HELPER_Handle *h, int soft_kill)
Sends termination signal to the helper process.
Definition: helper.c:175
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:692
#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 1212 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().

1213 {
1214  if (NULL != cproc->helper)
1215  {
1217  GNUNET_HELPER_destroy(cproc->helper);
1218  }
1219  if (NULL != cproc->helper_argv)
1220  free_argv(cproc->helper_argv);
1221  cproc->host->controller_started = GNUNET_NO;
1222  cproc->host->locked = GNUNET_NO;
1223  GNUNET_free_non_null(cproc->msg);
1224  GNUNET_free(cproc);
1225 }
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:526
int GNUNET_HELPER_wait(struct GNUNET_HELPER_Handle *h)
Reap the helper process.
Definition: helper.c:223
#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 1292 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().

1293 {
1295  void *cb_cls;
1297  const struct GNUNET_TESTBED_Host *host;
1298  unsigned long code;
1300  int ret;
1301 
1302  h->habitability_check_task = NULL;
1303  ret = GNUNET_OS_process_status(h->auxp, &type, &code);
1304  if (GNUNET_SYSERR == ret)
1305  {
1306  GNUNET_break(0);
1307  ret = GNUNET_NO;
1308  goto call_cb;
1309  }
1310  if (GNUNET_NO == ret)
1311  {
1315  return;
1316  }
1318  h->auxp = NULL;
1319  ret = (0 != code) ? GNUNET_NO : GNUNET_YES;
1320 
1321 call_cb:
1322  if (NULL != h->auxp)
1324  cb = h->cb;
1325  cb_cls = h->cb_cls;
1326  host = h->host;
1327  free_argv(h->helper_argv);
1328  GNUNET_free(h);
1329  if (NULL != cb)
1330  cb(cb_cls, host, ret);
1331 }
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:286
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.
#define GNUNET_NO
Definition: gnunet_common.h:78
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:1237
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 1538 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().

1540 {
1542  op);
1543 }
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 1552 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().

1553 {
1554  char *hostname;
1555 
1556  hostname = (char *)host->hostname;
1557  host->hostname = simple_resolve(hostname);
1558  if (NULL == host->hostname)
1559  {
1560  GNUNET_break(0);
1561  host->hostname = hostname;
1562  return;
1563  }
1564  GNUNET_free(hostname);
1565  host->hostname = GNUNET_strdup(host->hostname);
1566 }
#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 171 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 176 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_().