GNUnet  0.19.3
testbed_api_hosts.h File Reference

internal API to access the 'hosts' subsystem More...

#include "testbed.h"
Include dependency graph for testbed_api_hosts.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_TESTBED_HostRegistrationHandle
 handle for host registration 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 a host's unique global ID. 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...
 
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...
 
void GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, const struct GNUNET_TESTBED_Controller *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 *controller)
 Checks whether a host has been registered with the given controller. 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_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_host_resolve_ (struct GNUNET_TESTBED_Host *host)
 Resolves the hostname of the host to an ip address. More...
 
void GNUNET_TESTBED_extract_cfg (struct GNUNET_TESTBED_Host *host, const struct GNUNET_MessageHeader *message)
 

Detailed Description

internal API to access the 'hosts' subsystem

Author
Christian Grothoff

Definition in file testbed_api_hosts.h.

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 on error
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.

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.

References host_list, host_list_size, and id.

Referenced by handle_link_controllers_result().

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.

213 {
214  return GNUNET_TESTBED_host_create_with_id (id, NULL, NULL, cfg, 0);
215 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
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.

References cfg, and GNUNET_TESTBED_host_create_with_id().

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 a host's unique global ID.

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

Definition at line 219 of file testbed_api_hosts.c.

220 {
221  return host->id;
222 }
uint32_t id
Global ID we use to refer to a host on the network.

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(), host_list_add(), hr_completion(), opstart_overlay_connect(), opstart_peer_create(), and register_next_host().

Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_get_username_()

const char* GNUNET_TESTBED_host_get_username_ ( const struct GNUNET_TESTBED_Host host)

Obtain the host's username.

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

Definition at line 245 of file testbed_api_hosts.c.

246 {
247  return host->username;
248 }
const char * username
The username to be used for SSH login.

References GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_register_host().

Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_get_ssh_port_()

uint16_t GNUNET_TESTBED_host_get_ssh_port_ ( const struct GNUNET_TESTBED_Host host)

Obtain the host's ssh port.

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

Definition at line 258 of file testbed_api_hosts.c.

259 {
260  return host->port;
261 }
uint16_t port
The port which is to be used for SSH.

References GNUNET_TESTBED_Host::port.

Referenced by GNUNET_TESTBED_register_host().

Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_get_cfg_()

const struct GNUNET_CONFIGURATION_Handle* GNUNET_TESTBED_host_get_cfg_ ( const struct GNUNET_TESTBED_Host host)

Obtain the host's configuration template.

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

Definition at line 284 of file testbed_api_hosts.c.

285 {
286  return host->cfg;
287 }
struct GNUNET_CONFIGURATION_Handle * cfg
the configuration to use as a template while starting a controller on this host.

References GNUNET_TESTBED_Host::cfg.

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

Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_replace_cfg_()

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

Function to replace host's configuration.

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

Definition at line 297 of file testbed_api_hosts.c.

300 {
302  host->cfg = GNUNET_CONFIGURATION_dup (new_cfg);
303 }
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.

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

Referenced by handle_link_controllers_result().

Here is the call graph for this function:
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 605 of file testbed_api_hosts.c.

608 {
609  struct RegisteredController *rc;
610 
611  for (rc = host->rc_head; NULL != rc; rc = rc->next)
612  {
613  if (controller == rc->controller) /* already registered at controller */
614  {
615  GNUNET_break (0);
616  return;
617  }
618  }
619  rc = GNUNET_new (struct RegisteredController);
620  rc->controller = controller;
622 }
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct RegisteredController * rc_head
The head for the list of controllers where this host is registered.
struct RegisteredController * rc_tail
The tail for the list of controllers where this host is registered.
A list entry for registered controllers list.
const struct GNUNET_TESTBED_Controller * controller
The controller at which this host is registered.
struct RegisteredController * next
The next ptr for DLL.

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().

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

635 {
636  struct RegisteredController *rc;
637 
638  for (rc = host->rc_head; NULL != rc; rc = rc->next)
639  if (controller == rc->controller)
640  break;
641  if (NULL == rc)
642  {
643  GNUNET_break (0);
644  return;
645  }
646  GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
647  GNUNET_free (rc);
648 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.

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().

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 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

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

662 {
663  struct RegisteredController *rc;
664 
665  for (rc = host->rc_head; NULL != rc; rc = rc->next)
666  {
667  if (controller == rc->controller) /* already registered at controller */
668  {
669  return GNUNET_YES;
670  }
671  }
672  return GNUNET_NO;
673 }
@ GNUNET_YES
@ GNUNET_NO

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().

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

1491 {
1493  h->opq_parallel_overlay_connect_operations,
1494  op);
1495 }
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.

References GNUNET_TESTBED_operation_queue_insert_(), h, and op.

Referenced by GNUNET_TESTBED_overlay_connect().

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

1148 {
1149  if (NULL != cproc->shandle)
1151  if (NULL != cproc->helper)
1153 }
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
Definition: helper.c:654
int GNUNET_HELPER_kill(struct GNUNET_HELPER_Handle *h, int soft_kill)
Sends termination signal to the helper process.
Definition: helper.c:167
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
struct GNUNET_HELPER_Handle * helper
The process handle.

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().

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

1163 {
1164  if (NULL != cproc->helper)
1165  {
1167  GNUNET_HELPER_destroy (cproc->helper);
1168  }
1169  if (NULL != cproc->helper_argv)
1170  free_argv (cproc->helper_argv);
1171  cproc->host->controller_started = GNUNET_NO;
1172  cproc->host->locked = GNUNET_NO;
1173  GNUNET_free (cproc->msg);
1174  GNUNET_free (cproc);
1175 }
int GNUNET_HELPER_wait(struct GNUNET_HELPER_Handle *h)
Reap the helper process.
Definition: helper.c:207
void GNUNET_HELPER_destroy(struct GNUNET_HELPER_Handle *h)
Free's the resources occupied by the helper handle.
Definition: helper.c:500
@ GNUNET_OK
char ** helper_argv
The arguments used to start the helper.
struct GNUNET_MessageHeader * msg
The message corresponding to send handle.
struct GNUNET_TESTBED_Host * host
The host where the helper is run.
int locked
Is this host locked by GNUNET_TESTBED_controller_start()?
int controller_started
Is a controller started on this host? FIXME: Is this needed?
static void free_argv(char **argv)
Frees the given NULL terminated arguments.

References GNUNET_TESTBED_Host::controller_started, free_argv(), GNUNET_break, GNUNET_free, 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().

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

1505 {
1506  char *hostname;
1507 
1508  hostname = (char *) host->hostname;
1509  host->hostname = simple_resolve (hostname);
1510  if (NULL == host->hostname)
1511  {
1512  GNUNET_break (0);
1513  host->hostname = hostname;
1514  return;
1515  }
1517  host->hostname = GNUNET_strdup (host->hostname);
1518 }
static char * hostname
Our hostname; we give this to all the peers we start.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
const char * hostname
The hostname of the host; NULL for localhost.
const char * simple_resolve(const char *host)
Resolves a hostname using getaddrinfo.

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

Referenced by host_habitable_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_extract_cfg()

void GNUNET_TESTBED_extract_cfg ( struct GNUNET_TESTBED_Host host,
const struct GNUNET_MessageHeader message 
)