GNUnet  0.10.x
Data Structures | Macros | Enumerations | Functions
testbed_api_testbed.c File Reference

high-level testbed management More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "testbed_api.h"
#include "testbed_api_peers.h"
#include "testbed_api_hosts.h"
#include "testbed_api_topology.h"
Include dependency graph for testbed_api_testbed.c:

Go to the source code of this file.

Data Structures

struct  RunContextOperation
 Context information for the operation we start. More...
 
struct  CompatibilityCheckContext
 Context for host compability checks. More...
 
struct  GNUNET_TESTBED_RunHandle
 Testbed Run Handle. More...
 
struct  SearchContext
 Context information to be used while searching for operation contexts. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from(kind, "testbed-api-testbed", __VA_ARGS__)
 Generic loggins shorthand. More...
 
#define DEBUG(...)   LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 Debug logging shortcut. More...
 
#define DEFAULT_SETUP_TIMEOUT   300
 The default setup timeout in seconds. More...
 
#define TESTBED_CONFIG_SECTION   "testbed"
 Configuration section for testbed. More...
 
#define SCALE_FREE_CAP   "SCALE_FREE_TOPOLOGY_CAP"
 Option string for the maximum number of edges a peer is permitted to have while generating scale free topology. More...
 
#define SCALE_FREE_M   "SCALE_FREE_TOPOLOGY_M"
 Option string for the number of edges to be established when adding a new node to the scale free network. More...
 

Enumerations

enum  State {
  STATE_INIT = 0, STATE_SLAVES_STARTING, STATE_PEERS_CREATING, STATE_PEERS_STARTING,
  STATE_PEERS_LINKING, STATE_SEARCH_REGEX, STATE_PEERS_DESTROYING, INIT,
  CFG_REQUEST_QUEUED, SERVICE_CONNECTED, RC_INIT = 0, RC_LINKED,
  RC_PEERS_CREATED, RC_READY, RC_PEERS_SHUTDOWN
}
 States of RunContext. More...
 

Functions

static uint32_t rcop_key (void *rcop)
 Return a 32-bit key from a pointer. More...
 
static int search_iterator (void *cls, uint32_t key, void *value)
 Iterator for searching over the elements matching a given query. More...
 
static struct RunContextOperationsearch_rcop (struct GNUNET_TESTBED_RunHandle *rc, struct GNUNET_TESTBED_Operation *op)
 Initiate a search for the given operation in the rcop_map. More...
 
static void insert_rcop (struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
 Insert an RunContextOperation into the rcop_map of the given RunContext. More...
 
static void remove_rcop (struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
 Remove a RunContextOperation from the rcop_map of the given RunContext. More...
 
static void cleanup (struct GNUNET_TESTBED_RunHandle *rc)
 Assuming all peers have been destroyed cleanup run handle. More...
 
static int rcop_cleanup_iterator (void *cls, uint32_t key, void *value)
 Iterator for cleaning up elements from rcop_map. More...
 
static void rc_cleanup_operations (struct GNUNET_TESTBED_RunHandle *rc)
 Cancels operations and tasks which are assigned to the given run context. More...
 
static void cancel_interrupt_task (struct GNUNET_TESTBED_RunHandle *rc)
 Cancels the scheduled interrupt task. More...
 
static void wait_op_completion (void *cls)
 This callback will be called when all the operations are completed (done/cancelled) More...
 
static void interrupt (void *cls)
 Task run upon interrupts (SIGINT, SIGTERM) and upon scheduler shutdown. More...
 
static const char * prof_time (struct GNUNET_TESTBED_RunHandle *rc)
 Function to return the string representation of the duration between current time and `pstart_time' in `RunContext'. More...
 
static void start_peers_task (void *cls)
 Task for starting peers. More...
 
static void peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
 Functions of this signature are called when a peer has been successfully created. More...
 
static void call_master (struct GNUNET_TESTBED_RunHandle *rc)
 call test master callback More...
 
static void topology_completion_callback (void *cls, unsigned int nsuccess, unsigned int nfailures)
 Callbacks of this type are called when topology configuration is completed. More...
 
static void create_peers (struct GNUNET_TESTBED_RunHandle *rc)
 Function to create peers. More...
 
static void event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
 Signature of the event handler function called by the respective event controller. More...
 
static void register_hosts (void *cls)
 Task to register all hosts available in the global host list. More...
 
static void host_registration_completion (void *cls, const char *emsg)
 Callback which will be called to after a host registration succeeded or failed. More...
 
static void controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status)
 Callback to signal successfull startup of the controller process. More...
 
static int netint_proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr, const struct sockaddr *broadcast_addr, const struct sockaddr *netmask, socklen_t addrlen)
 Callback function invoked for each interface found. More...
 
static void host_habitable_cb (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 host is habitable or not. More...
 
static void timeout_task (void *cls)
 Task run upon timeout while setting up the testbed. More...
 
void GNUNET_TESTBED_run (const char *host_filename, const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int num_peers, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, GNUNET_TESTBED_TestMaster test_master, void *test_master_cls)
 Convenience method for running a testbed with a single call. More...
 
struct GNUNET_TESTBED_ControllerGNUNET_TESTBED_run_get_controller_handle (struct GNUNET_TESTBED_RunHandle *h)
 Obtain handle to the master controller from a testbed run. More...
 

Detailed Description

high-level testbed management

Author
Christian Grothoff
Sree Harsha Totakura

Definition in file testbed_api_testbed.c.

Macro Definition Documentation

◆ LOG

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

◆ DEBUG

#define DEBUG (   ...)    LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)

◆ DEFAULT_SETUP_TIMEOUT

#define DEFAULT_SETUP_TIMEOUT   300

The default setup timeout in seconds.

Definition at line 51 of file testbed_api_testbed.c.

Referenced by GNUNET_TESTBED_run().

◆ TESTBED_CONFIG_SECTION

#define TESTBED_CONFIG_SECTION   "testbed"

Configuration section for testbed.

Definition at line 57 of file testbed_api_testbed.c.

Referenced by event_cb(), and GNUNET_TESTBED_run().

◆ SCALE_FREE_CAP

#define SCALE_FREE_CAP   "SCALE_FREE_TOPOLOGY_CAP"

Option string for the maximum number of edges a peer is permitted to have while generating scale free topology.

Definition at line 63 of file testbed_api_testbed.c.

Referenced by event_cb(), and GNUNET_TESTBED_run().

◆ SCALE_FREE_M

#define SCALE_FREE_M   "SCALE_FREE_TOPOLOGY_M"

Option string for the number of edges to be established when adding a new node to the scale free network.

Definition at line 69 of file testbed_api_testbed.c.

Referenced by event_cb(), and GNUNET_TESTBED_run().

Enumeration Type Documentation

◆ State

enum State

States of RunContext.

Enumerator
STATE_INIT 

Initial state.

STATE_SLAVES_STARTING 

Starting slaves.

STATE_PEERS_CREATING 

Creating peers.

STATE_PEERS_STARTING 

Starting peers.

STATE_PEERS_LINKING 

Linking peers.

STATE_SEARCH_REGEX 

Matching strings against announced regexes.

STATE_PEERS_DESTROYING 

Destroying peers; we can do this as the controller takes care of stopping a peer if it is running.

INIT 

Initial state.

CFG_REQUEST_QUEUED 

The configuration request has been sent.

SERVICE_CONNECTED 

connected to service

RC_INIT 

Initial state.

RC_LINKED 

Controllers on given hosts started and linked.

RC_PEERS_CREATED 

Peers are created.

RC_READY 

The testbed run is ready and the master callback can be called now.

At this time the peers are all started and if a topology is provided in the configuration the topology would have been attempted

RC_PEERS_SHUTDOWN 

All peers shutdown (stopped and destroyed)

Definition at line 95 of file testbed_api_testbed.c.

95  {
99  RC_INIT = 0,
100 
104  RC_LINKED,
105 
110 
116  RC_READY,
117 
118  /* /\** */
119  /* * Peers are stopped */
120  /* *\/ */
121  /* RC_PEERS_STOPPED, */
122 
123  /* /\** */
124  /* * Peers are destroyed */
125  /* *\/ */
126  /* RC_PEERS_DESTROYED */
127 
132 };
The testbed run is ready and the master callback can be called now.
Controllers on given hosts started and linked.
Peers are created.
Initial state.
All peers shutdown (stopped and destroyed)

Function Documentation

◆ rcop_key()

static uint32_t rcop_key ( void *  rcop)
static

Return a 32-bit key from a pointer.

Parameters
rcopthe pointer
Returns
32-bit key

Definition at line 334 of file testbed_api_testbed.c.

Referenced by insert_rcop(), remove_rcop(), and search_rcop().

335 {
336  return *((uint32_t *)&rcop);
337 }
Here is the caller graph for this function:

◆ search_iterator()

static int search_iterator ( void *  cls,
uint32_t  key,
void *  value 
)
static

Iterator for searching over the elements matching a given query.

Parameters
clsthe SearchContext
keythe 32-bit key
valuethe RunContextOperation element
Returns
GNUNET_YES to continue iteration; GNUNET_NO to cancel it

Definition at line 365 of file testbed_api_testbed.c.

References RunContextOperation::cls, GNUNET_assert, GNUNET_NO, GNUNET_YES, RunContextOperation::op, SearchContext::query, SearchContext::result, sc, and value.

Referenced by search_rcop().

366 {
367  struct RunContextOperation *rcop = value;
368  struct SearchContext *sc = cls;
369 
370  GNUNET_assert(NULL != rcop);
371  if (sc->query == rcop->op)
372  {
373  GNUNET_assert(NULL == sc->result);
374  sc->result = rcop;
375  return GNUNET_NO;
376  }
377  return GNUNET_YES;
378 }
Context information for the operation we start.
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
static char * value
Value of the record to add/remove.
struct RunContextOperation * result
The Run context operation which has the operation being queried.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
struct GNUNET_TESTBED_Operation * query
The operation pointer to look for.
Context information to be used while searching for operation contexts.
Definition: testbed_api.c:220
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ search_rcop()

static struct RunContextOperation* search_rcop ( struct GNUNET_TESTBED_RunHandle rc,
struct GNUNET_TESTBED_Operation op 
)
static

Initiate a search for the given operation in the rcop_map.

Parameters
rcthe RunContext whose rcop_map will be searched for the given operation
opthe given operation to search for
Returns
the matching RunContextOperation if found; NULL if not

Definition at line 390 of file testbed_api_testbed.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_get_multiple(), GNUNET_SYSERR, RunContextOperation::op, SearchContext::query, rcop_key(), GNUNET_TESTBED_RunHandle::rcop_map, SearchContext::result, and search_iterator().

Referenced by event_cb().

391 {
392  struct SearchContext sc;
393 
394  sc.query = op;
395  sc.result = NULL;
396  if (GNUNET_SYSERR ==
398  rcop_key(op),
400  &sc))
401  {
402  GNUNET_assert(NULL != sc.result);
403  return sc.result;
404  }
405  return NULL;
406 }
struct GNUNET_CONTAINER_MultiHashMap32 * rcop_map
A hashmap for operations started by us.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_CONTAINER_multihashmap32_get_multiple(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
static uint32_t rcop_key(void *rcop)
Return a 32-bit key from a pointer.
static int search_iterator(void *cls, uint32_t key, void *value)
Iterator for searching over the elements matching a given query.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
Context information to be used while searching for operation contexts.
Definition: testbed_api.c:220
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert_rcop()

static void insert_rcop ( struct GNUNET_TESTBED_RunHandle rc,
struct RunContextOperation rcop 
)
static

Insert an RunContextOperation into the rcop_map of the given RunContext.

Parameters
rcthe RunContext into whose map is to be used for insertion
rcopthe RunContextOperation to insert

Definition at line 416 of file testbed_api_testbed.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_OK, RunContextOperation::op, rcop_key(), and GNUNET_TESTBED_RunHandle::rcop_map.

Referenced by create_peers(), register_hosts(), start_peers_task(), and wait_op_completion().

417 {
420  rcop_key(rcop->op), rcop,
422 }
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
struct GNUNET_CONTAINER_MultiHashMap32 * rcop_map
A hashmap for operations started by us.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
static uint32_t rcop_key(void *rcop)
Return a 32-bit key from a pointer.
Allow multiple values with the same key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_rcop()

static void remove_rcop ( struct GNUNET_TESTBED_RunHandle rc,
struct RunContextOperation rcop 
)
static

Remove a RunContextOperation from the rcop_map of the given RunContext.

Parameters
rcthe RunContext from whose map the given RunContextOperaton has to be removed
rcopthe RunContextOperation

Definition at line 433 of file testbed_api_testbed.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_YES, RunContextOperation::op, rcop_key(), and GNUNET_TESTBED_RunHandle::rcop_map.

Referenced by event_cb(), peer_create_cb(), and rcop_cleanup_iterator().

434 {
437  rcop_key(rcop->op),
438  rcop));
439 }
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
struct GNUNET_CONTAINER_MultiHashMap32 * rcop_map
A hashmap for operations started by us.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static uint32_t rcop_key(void *rcop)
Return a 32-bit key from a pointer.
int GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

static void cleanup ( struct GNUNET_TESTBED_RunHandle rc)
static

Assuming all peers have been destroyed cleanup run handle.

Parameters
rcthe run context

Definition at line 447 of file testbed_api_testbed.c.

References GNUNET_TESTBED_RunHandle::c, GNUNET_TESTBED_RunHandle::cfg, GNUNET_TESTBED_RunHandle::cproc, GNUNET_assert, GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_size(), GNUNET_free, GNUNET_free_non_null, GNUNET_TESTBED_controller_disconnect(), GNUNET_TESTBED_controller_stop(), GNUNET_TESTBED_host_destroy(), GNUNET_TESTBED_RunHandle::h, GNUNET_TESTBED_RunHandle::hclist, GNUNET_TESTBED_RunHandle::hosts, GNUNET_TESTBED_RunHandle::num_hosts, GNUNET_TESTBED_RunHandle::peers, RC_PEERS_SHUTDOWN, GNUNET_TESTBED_RunHandle::rcop_map, GNUNET_TESTBED_RunHandle::reg_handle, GNUNET_TESTBED_RunHandle::register_hosts_task, GNUNET_TESTBED_RunHandle::state, GNUNET_TESTBED_RunHandle::topo_file, and GNUNET_TESTBED_RunHandle::trusted_ip.

Referenced by wait_op_completion().

448 {
449  unsigned int hid;
450 
451  GNUNET_assert(NULL == rc->register_hosts_task);
452  GNUNET_assert(NULL == rc->reg_handle);
453  GNUNET_assert(NULL == rc->peers);
454  GNUNET_assert(NULL == rc->hclist);
458  if (NULL != rc->c)
460  if (NULL != rc->cproc)
462  if (NULL != rc->h)
464  for (hid = 0; hid < rc->num_hosts; hid++)
467  if (NULL != rc->cfg)
471  GNUNET_free(rc);
472 }
void GNUNET_TESTBED_controller_disconnect(struct GNUNET_TESTBED_Controller *c)
Stop the given controller (also will terminate all peers and controllers dependent on this controller...
Definition: testbed_api.c:1713
enum State state
State of this context.
struct GNUNET_CONTAINER_MultiHashMap32 * rcop_map
A hashmap for operations started by us.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_HostRegistrationHandle * reg_handle
Host registration 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...
struct GNUNET_TESTBED_ControllerProc * cproc
The handle to the controller process.
char * trusted_ip
The trusted IP string.
struct GNUNET_TESTBED_Controller * c
The controller handle.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_TESTBED_Host * h
Handle to the host on which the controller runs.
char * topo_file
The file containing topology data.
struct CompatibilityCheckContext * hclist
Array of compatibility check contexts.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
void GNUNET_TESTBED_host_destroy(struct GNUNET_TESTBED_Host *host)
Destroy a host handle.
unsigned int num_hosts
Number of hosts in the given host file.
struct GNUNET_TESTBED_Peer ** peers
Array of peers which we create.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the controller.
struct GNUNET_TESTBED_Host ** hosts
An array of hosts loaded from the hostkeys file.
struct GNUNET_SCHEDULER_Task * register_hosts_task
Host registration task.
#define GNUNET_free(ptr)
Wrapper around free.
All peers shutdown (stopped and destroyed)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcop_cleanup_iterator()

static int rcop_cleanup_iterator ( void *  cls,
uint32_t  key,
void *  value 
)
static

Iterator for cleaning up elements from rcop_map.

Parameters
clsthe RunContext
keythe 32-bit key
valuethe RunContextOperation element
Returns
always GNUNET_YES

Definition at line 484 of file testbed_api_testbed.c.

References RunContextOperation::cls, GNUNET_assert, GNUNET_free, GNUNET_TESTBED_operation_done(), GNUNET_YES, RunContextOperation::op, RunContextOperation::rc, remove_rcop(), and value.

Referenced by rc_cleanup_operations().

485 {
486  struct GNUNET_TESTBED_RunHandle *rc = cls;
487  struct RunContextOperation *rcop = value;
488 
489  GNUNET_assert(rc == rcop->rc);
490  remove_rcop(rc, rcop);
492  GNUNET_free(rcop);
493  return GNUNET_YES;
494 }
Context information for the operation we start.
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_RunHandle * rc
Context information for GNUNET_TESTBED_run()
static char * value
Value of the record to add/remove.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2037
static void remove_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
Remove a RunContextOperation from the rcop_map of the given RunContext.
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rc_cleanup_operations()

static void rc_cleanup_operations ( struct GNUNET_TESTBED_RunHandle rc)
static

Cancels operations and tasks which are assigned to the given run context.

Parameters
rcthe RunContext

Definition at line 503 of file testbed_api_testbed.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TESTBED_cancel_registration(), GNUNET_TESTBED_is_host_habitable_cancel(), GNUNET_TESTBED_operation_done(), CompatibilityCheckContext::h, GNUNET_TESTBED_RunHandle::hclist, GNUNET_TESTBED_RunHandle::num_hosts, rcop_cleanup_iterator(), GNUNET_TESTBED_RunHandle::rcop_map, GNUNET_TESTBED_RunHandle::reg_handle, GNUNET_TESTBED_RunHandle::register_hosts_task, GNUNET_TESTBED_RunHandle::timeout_task, and GNUNET_TESTBED_RunHandle::topology_operation.

Referenced by interrupt().

504 {
505  struct CompatibilityCheckContext *hc;
506  unsigned int nhost;
507 
508  if (NULL != rc->hclist)
509  {
510  for (nhost = 0; nhost < rc->num_hosts; nhost++)
511  {
512  hc = &rc->hclist[nhost];
513  if (NULL != hc->h)
515  }
516  GNUNET_free(rc->hclist);
517  rc->hclist = NULL;
518  }
519  /* Stop register hosts task if it is running */
520  if (NULL != rc->register_hosts_task)
521  {
523  rc->register_hosts_task = NULL;
524  }
525  if (NULL != rc->timeout_task)
526  {
528  rc->timeout_task = NULL;
529  }
530  if (NULL != rc->reg_handle)
531  {
533  rc->reg_handle = NULL;
534  }
535  if (NULL != rc->topology_operation)
536  {
538  rc->topology_operation = NULL;
539  }
540  /* cancel any exiting operations */
544  rc));
545 }
void GNUNET_TESTBED_cancel_registration(struct GNUNET_TESTBED_HostRegistrationHandle *handle)
Cancel the pending registration.
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run of a timeout.
void GNUNET_TESTBED_is_host_habitable_cancel(struct GNUNET_TESTBED_HostHabitableCheckHandle *handle)
Function to cancel a request started using GNUNET_TESTBED_is_host_habitable()
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMap32 * rcop_map
A hashmap for operations started by us.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_HostRegistrationHandle * reg_handle
Host registration handle.
Context for host compability checks.
struct GNUNET_TESTBED_HostHabitableCheckHandle * h
Handle for the compability check.
struct CompatibilityCheckContext * hclist
Array of compatibility check contexts.
struct GNUNET_TESTBED_Operation * topology_operation
The topology generation operation.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2037
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
unsigned int num_hosts
Number of hosts in the given host file.
struct GNUNET_SCHEDULER_Task * register_hosts_task
Host registration task.
static int rcop_cleanup_iterator(void *cls, uint32_t key, void *value)
Iterator for cleaning up elements from rcop_map.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cancel_interrupt_task()

static void cancel_interrupt_task ( struct GNUNET_TESTBED_RunHandle rc)
static

Cancels the scheduled interrupt task.

Parameters
rcthe run context

Definition at line 554 of file testbed_api_testbed.c.

References GNUNET_SCHEDULER_cancel(), and GNUNET_TESTBED_RunHandle::interrupt_task.

Referenced by wait_op_completion().

555 {
557  rc->interrupt_task = NULL;
558 }
struct GNUNET_SCHEDULER_Task * interrupt_task
Task run upon shutdown interrupts.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait_op_completion()

static void wait_op_completion ( void *  cls)
static

This callback will be called when all the operations are completed (done/cancelled)

Parameters
clsrun context

Definition at line 568 of file testbed_api_testbed.c.

References GNUNET_TESTBED_RunHandle::c, cancel_interrupt_task(), cleanup(), RunContextOperation::cls, GNUNET_TESTBED_RunHandle::cproc, DEBUG, GNUNET_assert, GNUNET_free, GNUNET_new, GNUNET_TESTBED_shutdown_peers(), GNUNET_TIME_absolute_get(), GNUNET_YES, insert_rcop(), RunContextOperation::op, GNUNET_TESTBED_RunHandle::peers, GNUNET_TESTBED_RunHandle::pstart_time, RunContextOperation::rc, RC_PEERS_SHUTDOWN, GNUNET_TESTBED_RunHandle::shutdown, and GNUNET_TESTBED_RunHandle::state.

Referenced by interrupt().

569 {
570  struct GNUNET_TESTBED_RunHandle *rc = cls;
571  struct RunContextOperation *rcop;
572 
573  if ((NULL == rc->cproc)
574  || (NULL == rc->c)
575  || (GNUNET_YES == rc->shutdown))
576  {
577  if (NULL != rc->peers)
578  {
579  GNUNET_free(rc->peers);
580  rc->peers = NULL;
581  }
582  goto cleanup_;
583  }
584  if (NULL == rc->peers)
585  goto cleanup_;
586  rc->shutdown = GNUNET_YES;
587  rcop = GNUNET_new(struct RunContextOperation);
588  rcop->rc = rc;
589  rcop->op = GNUNET_TESTBED_shutdown_peers(rc->c, rcop, NULL, NULL);
590  GNUNET_assert(NULL != rcop->op);
591  DEBUG("Shutting down peers\n");
593  insert_rcop(rc, rcop);
594  return;
595 
596 cleanup_:
597  rc->state = RC_PEERS_SHUTDOWN;
599  cleanup(rc);
600 }
Context information for the operation we start.
enum State state
State of this context.
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_RunHandle * rc
Context information for GNUNET_TESTBED_run()
static void insert_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
Insert an RunContextOperation into the rcop_map of the given RunContext.
struct GNUNET_TESTBED_ControllerProc * cproc
The handle to the controller process.
struct GNUNET_TESTBED_Controller * c
The controller handle.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute pstart_time
Profiling start time.
#define DEBUG(...)
Debug logging shortcut.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static void cancel_interrupt_task(struct GNUNET_TESTBED_RunHandle *rc)
Cancels the scheduled interrupt task.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_shutdown_peers(struct GNUNET_TESTBED_Controller *c, void *op_cls, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls)
Stops and destroys all peers.
Definition: testbed_api.c:2275
static void cleanup(struct GNUNET_TESTBED_RunHandle *rc)
Assuming all peers have been destroyed cleanup run handle.
int shutdown
Have we already shutdown.
struct GNUNET_TESTBED_Peer ** peers
Array of peers which we create.
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
All peers shutdown (stopped and destroyed)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interrupt()

static void interrupt ( void *  cls)
static

Task run upon interrupts (SIGINT, SIGTERM) and upon scheduler shutdown.

Parameters
clsthe RunContext which has to be acted upon

Definition at line 609 of file testbed_api_testbed.c.

References GNUNET_TESTBED_RunHandle::c, RunContextOperation::cls, GNUNET_CONTAINER_multihashmap32_size(), GNUNET_ERROR_TYPE_WARNING, GNUNET_NO, GNUNET_SCHEDULER_add_shutdown(), GNUNET_TESTBED_RunHandle::interrupt_task, LOG, GNUNET_TESTBED_Controller::opc_map, GNUNET_TESTBED_Controller::opcq_empty_cb, GNUNET_TESTBED_Controller::opcq_empty_cls, RunContextOperation::rc, rc_cleanup_operations(), GNUNET_TESTBED_RunHandle::shutdown, size, and wait_op_completion().

Referenced by GNUNET_TESTBED_run().

610 {
611  struct GNUNET_TESTBED_RunHandle *rc = cls;
612  struct GNUNET_TESTBED_Controller *c = rc->c;
613  unsigned int size;
614 
615  /* reschedule */
618  if ((GNUNET_NO == rc->shutdown) &&
619  (NULL != c) &&
620  (NULL != c->opc_map) &&
621  (0 != (size = GNUNET_CONTAINER_multihashmap32_size(c->opc_map))))
622  {
624  "Shutdown postponed as there are %u operations currently active\n",
625  size);
627  c->opcq_empty_cls = rc;
628  return;
629  }
630  wait_op_completion(rc);
631 }
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:191
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
TESTBED_opcq_empty_cb opcq_empty_cb
If this callback is not NULL, schedule it as a task when opc_map gets empty.
Definition: testbed_api.h:231
static void wait_op_completion(void *cls)
This callback will be called when all the operations are completed (done/cancelled) ...
struct GNUNET_TESTBED_Controller * c
The controller handle.
#define GNUNET_NO
Definition: gnunet_common.h:78
static void interrupt(void *cls)
Task run upon interrupts (SIGINT, SIGTERM) and upon scheduler shutdown.
struct GNUNET_SCHEDULER_Task * interrupt_task
Task run upon shutdown interrupts.
#define LOG(kind,...)
Generic loggins shorthand.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_MultiHashMap32 * opc_map
The map of active operation contexts.
Definition: testbed_api.h:226
static unsigned int size
Size of the "table".
Definition: peer.c:66
void * opcq_empty_cls
Closure for the above task.
Definition: testbed_api.h:236
static void rc_cleanup_operations(struct GNUNET_TESTBED_RunHandle *rc)
Cancels operations and tasks which are assigned to the given run context.
int shutdown
Have we already shutdown.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prof_time()

static const char* prof_time ( struct GNUNET_TESTBED_RunHandle rc)
static

Function to return the string representation of the duration between current time and `pstart_time' in `RunContext'.

Parameters
rcthe RunContext
Returns
the representation string; this is NOT reentrant

Definition at line 642 of file testbed_api_testbed.c.

References GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, and GNUNET_TESTBED_RunHandle::pstart_time.

Referenced by event_cb(), peer_create_cb(), and topology_completion_callback().

643 {
644  struct GNUNET_TIME_Relative ptime;
645 
648 }
struct GNUNET_TIME_Absolute pstart_time
Profiling start time.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:686
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
#define GNUNET_YES
Definition: gnunet_common.h:77
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_peers_task()

static void start_peers_task ( void *  cls)
static

Task for starting peers.

Parameters
clsthe RunHandle

Definition at line 657 of file testbed_api_testbed.c.

References RunContextOperation::cls, DEBUG, GNUNET_assert, GNUNET_new, GNUNET_TESTBED_peer_start(), GNUNET_TIME_absolute_get(), insert_rcop(), GNUNET_TESTBED_RunHandle::num_peers, RunContextOperation::op, peer, GNUNET_TESTBED_RunHandle::peer_count, GNUNET_TESTBED_RunHandle::peers, GNUNET_TESTBED_RunHandle::pstart_time, and RunContextOperation::rc.

Referenced by peer_create_cb().

658 {
659  struct GNUNET_TESTBED_RunHandle *rc = cls;
660  struct RunContextOperation *rcop;
661  unsigned int peer;
662 
663  DEBUG("Starting Peers\n");
665  for (peer = 0; peer < rc->num_peers; peer++)
666  {
667  rcop = GNUNET_new(struct RunContextOperation);
668  rcop->rc = rc;
669  rcop->op = GNUNET_TESTBED_peer_start(NULL, rc->peers[peer], NULL, NULL);
670  GNUNET_assert(NULL != rcop->op);
671  rcop->cls = rc->peers[peer];
672  insert_rcop(rc, rcop);
673  }
674  rc->peer_count = 0;
675 }
Context information for the operation we start.
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_RunHandle * rc
Context information for GNUNET_TESTBED_run()
static void insert_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
Insert an RunContextOperation into the rcop_map of the given RunContext.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_start(void *op_cls, struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
Start the given peer.
unsigned int num_peers
number of peers to start
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute pstart_time
Profiling start time.
#define DEBUG(...)
Debug logging shortcut.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
unsigned int peer_count
Current peer count for an operation; Set this to 0 and increment for each successful operation on a p...
struct GNUNET_TESTBED_Peer ** peers
Array of peers which we create.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_create_cb()

static void peer_create_cb ( void *  cls,
struct GNUNET_TESTBED_Peer peer,
const char *  emsg 
)
static

Functions of this signature are called when a peer has been successfully created.

Parameters
clsthe closure from GNUNET_TESTBED_peer_create()
peerthe handle for the created peer; NULL on any error during creation
emsgNULL if peer is not NULL; else MAY contain the error description

Definition at line 688 of file testbed_api_testbed.c.

References RunContextOperation::cls, DEBUG, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_operation_done(), LOG, GNUNET_TESTBED_RunHandle::num_peers, RunContextOperation::op, peer, GNUNET_TESTBED_RunHandle::peer_count, GNUNET_TESTBED_RunHandle::peers, prof_time(), RunContextOperation::rc, RC_PEERS_CREATED, remove_rcop(), start_peers_task(), and GNUNET_TESTBED_RunHandle::state.

Referenced by create_peers().

689 {
690  struct RunContextOperation *rcop = cls;
691  struct GNUNET_TESTBED_RunHandle *rc;
692 
693  GNUNET_assert(NULL != rcop);
694  GNUNET_assert(NULL != (rc = rcop->rc));
695  remove_rcop(rc, rcop);
697  GNUNET_free(rcop);
698  if (NULL == peer)
699  {
700  if (NULL != emsg)
701  LOG(GNUNET_ERROR_TYPE_ERROR, "Error while creating a peer: %s\n",
702  emsg);
704  return;
705  }
706  rc->peers[rc->peer_count] = peer;
707  rc->peer_count++;
708  if (rc->peer_count < rc->num_peers)
709  return;
710  DEBUG("%u peers created in %s\n", rc->num_peers, prof_time(rc));
711  rc->state = RC_PEERS_CREATED;
713 }
static void start_peers_task(void *cls)
Task for starting peers.
Context information for the operation we start.
enum State state
State of this context.
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_RunHandle * rc
Context information for GNUNET_TESTBED_run()
unsigned int num_peers
number of peers to start
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
#define LOG(kind,...)
Generic loggins shorthand.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2037
#define DEBUG(...)
Debug logging shortcut.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Peers are created.
unsigned int peer_count
Current peer count for an operation; Set this to 0 and increment for each successful operation on a p...
static void remove_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
Remove a RunContextOperation from the rcop_map of the given RunContext.
struct GNUNET_TESTBED_Peer ** peers
Array of peers which we create.
static const char * prof_time(struct GNUNET_TESTBED_RunHandle *rc)
Function to return the string representation of the duration between current time and `pstart_time&#39; i...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ call_master()

static void call_master ( struct GNUNET_TESTBED_RunHandle rc)
static

call test master callback

Parameters
rcthe RunContext

Definition at line 722 of file testbed_api_testbed.c.

References GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_RunHandle::links_failed, GNUNET_TESTBED_RunHandle::links_succeeded, GNUNET_TESTBED_RunHandle::num_peers, GNUNET_TESTBED_RunHandle::peers, GNUNET_TESTBED_RunHandle::test_master, GNUNET_TESTBED_RunHandle::test_master_cls, and GNUNET_TESTBED_RunHandle::timeout_task.

Referenced by event_cb(), and topology_completion_callback().

723 {
725  rc->timeout_task = NULL;
726  if (NULL != rc->test_master)
727  rc->test_master(rc->test_master_cls, rc, rc->num_peers, rc->peers,
728  rc->links_succeeded, rc->links_failed);
729 }
unsigned int links_succeeded
the number of overlay link connection attempts that succeeded
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run of a timeout.
unsigned int links_failed
the number of overlay link connection attempts that failed
unsigned int num_peers
number of peers to start
void * test_master_cls
The closure for the TestMaster callback.
struct GNUNET_TESTBED_Peer ** peers
Array of peers which we create.
GNUNET_TESTBED_TestMaster test_master
TestMaster callback to call when testbed initialization is done.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ topology_completion_callback()

static void topology_completion_callback ( void *  cls,
unsigned int  nsuccess,
unsigned int  nfailures 
)
static

Callbacks of this type are called when topology configuration is completed.

Parameters
clsthe operation closure given to GNUNET_TESTBED_overlay_configure_topology_va() and GNUNET_TESTBED_overlay_configure() calls
nsuccessthe number of successful overlay connects
nfailuresthe number of overlay connects which failed

Definition at line 742 of file testbed_api_testbed.c.

References call_master(), RunContextOperation::cls, DEBUG, GNUNET_TESTBED_operation_done(), GNUNET_TESTBED_RunHandle::links_failed, GNUNET_TESTBED_RunHandle::links_succeeded, prof_time(), RunContextOperation::rc, RC_READY, GNUNET_TESTBED_RunHandle::state, and GNUNET_TESTBED_RunHandle::topology_operation.

Referenced by event_cb().

744 {
745  struct GNUNET_TESTBED_RunHandle *rc = cls;
746 
747  DEBUG("Overlay topology generated in %s\n", prof_time(rc));
749  rc->topology_operation = NULL;
750  rc->links_succeeded = nsuccess;
751  rc->links_failed = nfailures;
752  rc->state = RC_READY;
753  call_master(rc);
754 }
enum State state
State of this context.
unsigned int links_succeeded
the number of overlay link connection attempts that succeeded
unsigned int links_failed
the number of overlay link connection attempts that failed
The testbed run is ready and the master callback can be called now.
struct GNUNET_TESTBED_Operation * topology_operation
The topology generation operation.
static void call_master(struct GNUNET_TESTBED_RunHandle *rc)
call test master callback
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2037
#define DEBUG(...)
Debug logging shortcut.
static const char * prof_time(struct GNUNET_TESTBED_RunHandle *rc)
Function to return the string representation of the duration between current time and `pstart_time&#39; i...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_peers()

static void create_peers ( struct GNUNET_TESTBED_RunHandle rc)
static

Function to create peers.

Parameters
rcthe RunContext

Definition at line 763 of file testbed_api_testbed.c.

References GNUNET_TESTBED_RunHandle::c, GNUNET_TESTBED_RunHandle::cfg, DEBUG, GNUNET_assert, GNUNET_malloc, GNUNET_new, GNUNET_TESTBED_peer_create(), GNUNET_TIME_absolute_get(), GNUNET_TESTBED_RunHandle::h, GNUNET_TESTBED_RunHandle::hosts, insert_rcop(), GNUNET_TESTBED_RunHandle::num_hosts, GNUNET_TESTBED_RunHandle::num_peers, RunContextOperation::op, peer, GNUNET_TESTBED_RunHandle::peer_count, peer_create_cb(), GNUNET_TESTBED_RunHandle::peers, GNUNET_TESTBED_RunHandle::pstart_time, and RunContextOperation::rc.

Referenced by controller_status_cb(), and event_cb().

764 {
765  struct RunContextOperation *rcop;
766  unsigned int peer;
767 
768  DEBUG("Creating peers\n");
770  rc->peers =
771  GNUNET_malloc(sizeof(struct GNUNET_TESTBED_Peer *) * rc->num_peers);
772  GNUNET_assert(NULL != rc->c);
773  rc->peer_count = 0;
774  for (peer = 0; peer < rc->num_peers; peer++)
775  {
776  rcop = GNUNET_new(struct RunContextOperation);
777  rcop->rc = rc;
778  rcop->op =
780  (0 ==
781  rc->num_hosts) ? rc->h : rc->hosts[peer %
782  rc->num_hosts],
783  rc->cfg, &peer_create_cb, rcop);
784  GNUNET_assert(NULL != rcop->op);
785  insert_rcop(rc, rcop);
786  }
787 }
Context information for the operation we start.
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_RunHandle * rc
Context information for GNUNET_TESTBED_run()
static void insert_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
Insert an RunContextOperation into the rcop_map of the given RunContext.
struct GNUNET_TESTBED_Controller * c
The controller handle.
unsigned int num_peers
number of peers to start
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TIME_Absolute pstart_time
Profiling start time.
struct GNUNET_TESTBED_Host * h
Handle to the host on which the controller runs.
#define DEBUG(...)
Debug logging shortcut.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static void peer_create_cb(void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
Functions of this signature are called when a peer has been successfully created. ...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
unsigned int peer_count
Current peer count for an operation; Set this to 0 and increment for each successful operation on a p...
unsigned int num_hosts
Number of hosts in the given host file.
struct GNUNET_TESTBED_Peer ** peers
Array of peers which we create.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the controller.
struct GNUNET_TESTBED_Host ** hosts
An array of hosts loaded from the hostkeys file.
A peer controlled by the testing framework.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_create(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_TESTBED_Host *host, const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TESTBED_PeerCreateCallback cb, void *cls)
Create the given peer at the specified host using the given controller.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ event_cb()

static void event_cb ( void *  cls,
const struct GNUNET_TESTBED_EventInformation event 
)
static

Signature of the event handler function called by the respective event controller.

Parameters
clsclosure
eventinformation about the event

Definition at line 798 of file testbed_api_testbed.c.

References _, call_master(), GNUNET_TESTBED_RunHandle::cc, GNUNET_TESTBED_RunHandle::cc_cls, GNUNET_TESTBED_RunHandle::cfg, RunContextOperation::cls, create_peers(), DEBUG, GNUNET_TESTBED_EventInformation::details, GNUNET_TESTBED_RunHandle::event_mask, GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_free_non_null, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_ET_OPERATION_FINISHED, GNUNET_TESTBED_ET_PEER_START, GNUNET_TESTBED_operation_done(), GNUNET_TESTBED_overlay_configure_topology(), GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, GNUNET_TESTBED_TOPOLOGY_FROM_FILE, GNUNET_TESTBED_TOPOLOGY_NONE, GNUNET_TESTBED_TOPOLOGY_OPTION_END, GNUNET_TESTBED_TOPOLOGY_SCALE_FREE, GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD, GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING, GNUNET_TIME_absolute_get(), GNUNET_YES, LOG, GNUNET_TESTBED_RunHandle::num_hosts, GNUNET_TESTBED_RunHandle::num_oc, GNUNET_TESTBED_RunHandle::num_peers, number, RunContextOperation::op, GNUNET_TESTBED_EventInformation::op, GNUNET_TESTBED_EventInformation::operation_finished, GNUNET_TESTBED_RunHandle::peer_count, GNUNET_TESTBED_RunHandle::peers, prof_time(), GNUNET_TESTBED_RunHandle::pstart_time, GNUNET_TESTBED_RunHandle::random_links, RunContextOperation::rc, RC_INIT, RC_LINKED, RC_PEERS_CREATED, RC_PEERS_SHUTDOWN, RC_READY, GNUNET_TESTBED_RunHandle::reg_hosts, register_hosts(), remove_rcop(), SCALE_FREE_CAP, SCALE_FREE_M, search_rcop(), GNUNET_TESTBED_RunHandle::shutdown, GNUNET_TESTBED_RunHandle::state, TESTBED_CONFIG_SECTION, GNUNET_TESTBED_RunHandle::topo_file, GNUNET_TESTBED_RunHandle::topology, topology_completion_callback(), GNUNET_TESTBED_RunHandle::topology_operation, and GNUNET_TESTBED_EventInformation::type.

Referenced by controller_status_cb().

799 {
800  struct GNUNET_TESTBED_RunHandle *rc = cls;
801  struct RunContextOperation *rcop;
802 
803  if (RC_INIT == rc->state)
804  {
805  switch (event->type)
806  {
808  rcop = event->op_cls;
809  if (NULL != event->details.operation_finished.emsg)
810  {
811  LOG(GNUNET_ERROR_TYPE_ERROR, _("Linking controllers failed. Exiting"));
813  }
814  else
815  rc->reg_hosts++;
816  GNUNET_assert(event->op == rcop->op);
817  remove_rcop(rc, rcop);
819  GNUNET_free(rcop);
820  if (rc->reg_hosts == rc->num_hosts)
821  {
822  rc->state = RC_LINKED;
823  create_peers(rc);
824  }
825  return;
826 
827  default:
828  GNUNET_break(0);
830  return;
831  }
832  }
834  goto call_cc;
835  if (NULL == (rcop = search_rcop(rc, event->op)))
836  goto call_cc;
837  remove_rcop(rc, rcop);
839  GNUNET_free(rcop);
840  if ((GNUNET_NO == rc->shutdown)
841  && (NULL != event->details.operation_finished.emsg))
842  {
843  LOG(GNUNET_ERROR_TYPE_ERROR, "A operation has failed with error: %s\n",
844  event->details.operation_finished.emsg);
846  return;
847  }
849  switch (rc->state)
850  {
851  case RC_LINKED:
852  case RC_PEERS_CREATED:
853  case RC_READY:
854  rc->state = RC_PEERS_SHUTDOWN;
856  rc->peers = NULL;
857  DEBUG("Peers shut down in %s\n", prof_time(rc));
859  break;
860 
861  default:
862  GNUNET_assert(0);
863  }
864  return;
865 
866 call_cc:
867  if ((0 != (rc->event_mask & (1LL << event->type))) && (NULL != rc->cc))
868  rc->cc(rc->cc_cls, event);
869  if (GNUNET_TESTBED_ET_PEER_START != event->type)
870  return;
871  if (NULL == (rcop = search_rcop(rc, event->op))) /* Not our operation */
872  return;
873  remove_rcop(rc, rcop);
875  GNUNET_free(rcop);
876  rc->peer_count++;
877  if (rc->peer_count < rc->num_peers)
878  return;
879  DEBUG("%u peers started in %s\n", rc->num_peers, prof_time(rc));
881  {
882  switch (rc->topology)
883  {
885  GNUNET_assert(0);
886 
890  rc->topology_operation =
892  rc->peers, &rc->num_oc,
894  rc,
895  rc->topology,
896  rc->random_links,
898  break;
899 
901  GNUNET_assert(NULL != rc->topo_file);
902  rc->topology_operation =
904  rc->peers, &rc->num_oc,
906  rc,
907  rc->topology,
908  rc->topo_file,
910  break;
911 
913  {
914  unsigned long long number;
915  unsigned int cap;
919  &number));
920  cap = (unsigned int)number;
923  SCALE_FREE_M,
924  &number));
925  rc->topology_operation =
927  rc->peers, &rc->num_oc,
929  rc,
930  rc->topology,
931  cap, /* uint16_t */
932  (unsigned int)number, /* uint8_t */
934  }
935  break;
936 
937  default:
938  rc->topology_operation =
940  rc->peers, &rc->num_oc,
942  rc,
943  rc->topology,
945  }
946  if (NULL == rc->topology_operation)
948  "Not generating a topology. Check number of peers\n");
949  else
950  {
951  DEBUG("Creating overlay topology\n");
953  return;
954  }
955  }
956  rc->state = RC_READY;
957  call_master(rc);
958 }
Context information for the operation we start.
enum State state
State of this context.
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
void * cc_cls
The pointer to the controller callback.
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
All peers are disconnected.
unsigned int num_oc
Expected overlay connects.
static struct RunContextOperation * search_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct GNUNET_TESTBED_Operation *op)
Initiate a search for the given operation in the rcop_map.
#define TESTBED_CONFIG_SECTION
Configuration section for testbed.
unsigned int num_peers
number of peers to start
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
enum GNUNET_TESTBED_EventType type
Type of the event.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
The testbed run is ready and the master callback can be called now.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
struct GNUNET_TIME_Absolute pstart_time
Profiling start time.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Read a topology from a given file.
#define SCALE_FREE_M
Option string for the number of edges to be established when adding a new node to the scale free netw...
#define LOG(kind,...)
Generic loggins shorthand.
char * topo_file
The file containing topology data.
struct GNUNET_TESTBED_Operation * topology_operation
The topology generation operation.
static void create_peers(struct GNUNET_TESTBED_RunHandle *rc)
Function to create peers.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_overlay_configure_topology(void *op_cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int *max_connections, GNUNET_TESTBED_TopologyCompletionCallback comp_cb, void *comp_cb_cls, enum GNUNET_TESTBED_TopologyOption topo,...)
All peers must have been started before calling this function.
A requested testbed operation has been completed.
unsigned int reg_hosts
Number of registered hosts.
static void call_master(struct GNUNET_TESTBED_RunHandle *rc)
call test master callback
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2037
#define DEBUG(...)
Debug logging shortcut.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_TESTBED_EventInformation::@58::@63 operation_finished
Details about an operation finished event.
The options should always end with this.
Controllers on given hosts started and linked.
static void topology_completion_callback(void *cls, unsigned int nsuccess, unsigned int nfailures)
Callbacks of this type are called when topology configuration is completed.
union GNUNET_TESTBED_EventInformation::@58 details
Details about the event.
Small-world network (2d torus plus random links).
Peers are created.
Initial state.
unsigned int peer_count
Current peer count for an operation; Set this to 0 and increment for each successful operation on a p...
GNUNET_TESTBED_ControllerCallback cc
The callback to use as controller callback.
unsigned int random_links
Number of random links to established.
enum GNUNET_TESTBED_TopologyOption topology
The topology which has to be achieved with the peers started in this context.
static void remove_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
Remove a RunContextOperation from the rcop_map of the given RunContext.
unsigned int num_hosts
Number of hosts in the given host file.
int shutdown
Have we already shutdown.
struct GNUNET_TESTBED_Peer ** peers
Array of peers which we create.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the controller.
#define GNUNET_YES
Definition: gnunet_common.h:77
static const char * prof_time(struct GNUNET_TESTBED_RunHandle *rc)
Function to return the string representation of the duration between current time and `pstart_time&#39; i...
#define GNUNET_free(ptr)
Wrapper around free.
uint64_t event_mask
The event mask for the controller.
All peers shutdown (stopped and destroyed)
struct GNUNET_TESTBED_Operation * op
Handle for the corresponding operation that generated this event.
Small-world network (ring plus random links).
#define SCALE_FREE_CAP
Option string for the maximum number of edges a peer is permitted to have while generating scale free...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_hosts()

static void register_hosts ( void *  cls)
static

Task to register all hosts available in the global host list.

Parameters
clsthe RunContext
clsRunContext

Definition at line 1000 of file testbed_api_testbed.c.

References GNUNET_TESTBED_RunHandle::c, RunContextOperation::cls, DEBUG, GNUNET_assert, GNUNET_new, GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_register_host(), GNUNET_YES, GNUNET_TESTBED_RunHandle::h, host_registration_completion(), GNUNET_TESTBED_RunHandle::hosts, insert_rcop(), GNUNET_TESTBED_RunHandle::num_hosts, RunContextOperation::op, RunContextOperation::rc, GNUNET_TESTBED_RunHandle::reg_handle, GNUNET_TESTBED_RunHandle::reg_hosts, and GNUNET_TESTBED_RunHandle::register_hosts_task.

Referenced by controller_status_cb(), event_cb(), and host_registration_completion().

1001 {
1002  struct GNUNET_TESTBED_RunHandle *rc = cls;
1003  struct RunContextOperation *rcop;
1004  unsigned int slave;
1005 
1006  rc->register_hosts_task = NULL;
1007  if (rc->reg_hosts == rc->num_hosts)
1008  {
1009  DEBUG("All hosts successfully registered\n");
1010  /* Start slaves */
1011  for (slave = 0; slave < rc->num_hosts; slave++)
1012  {
1013  rcop = GNUNET_new(struct RunContextOperation);
1014  rcop->rc = rc;
1015  rcop->op =
1016  GNUNET_TESTBED_controller_link(rcop, rc->c, rc->hosts[slave],
1017  rc->h, GNUNET_YES);
1018  GNUNET_assert(NULL != rcop->op);
1019  insert_rcop(rc, rcop);
1020  }
1021  rc->reg_hosts = 0;
1022  return;
1023  }
1024  rc->reg_handle =
1027  rc->reg_hosts++;
1028 }
Context information for the operation we start.
struct GNUNET_TESTBED_Operation * op
The testbed operation handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_HostRegistrationHandle * reg_handle
Host registration handle.
struct GNUNET_TESTBED_RunHandle * rc
Context information for GNUNET_TESTBED_run()
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_controller_link(void *op_cls, struct GNUNET_TESTBED_Controller *master, struct GNUNET_TESTBED_Host *delegated_host, struct GNUNET_TESTBED_Host *slave_host, int is_subordinate)
Create a link from slave controller to delegated controller.
Definition: testbed_api.c:1824
static void insert_rcop(struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
Insert an RunContextOperation into the rcop_map of the given RunContext.
struct GNUNET_TESTBED_Controller * c
The controller handle.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TESTBED_Host * h
Handle to the host on which the controller runs.
unsigned int reg_hosts
Number of registered hosts.
#define DEBUG(...)
Debug logging shortcut.
static void host_registration_completion(void *cls, const char *emsg)
Callback which will be called to after a host registration succeeded or failed.
unsigned int num_hosts
Number of hosts in the given host file.
struct GNUNET_TESTBED_Host ** hosts
An array of hosts loaded from the hostkeys file.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_SCHEDULER_Task * register_hosts_task
Host registration task.
struct GNUNET_TESTBED_HostRegistrationHandle * GNUNET_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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ host_registration_completion()

static void host_registration_completion ( void *  cls,
const char *  emsg 
)
static

Callback which will be called to after a host registration succeeded or failed.

Parameters
clsthe closure
emsgthe error message; NULL if host registration is successful

Definition at line 977 of file testbed_api_testbed.c.

References _, RunContextOperation::cls, GNUNET_ERROR_TYPE_WARNING, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), LOG, RunContextOperation::rc, GNUNET_TESTBED_RunHandle::reg_handle, register_hosts(), and GNUNET_TESTBED_RunHandle::register_hosts_task.

Referenced by register_hosts().

978 {
979  struct GNUNET_TESTBED_RunHandle *rc = cls;
980 
981  rc->reg_handle = NULL;
982  if (NULL != emsg)
983  {
985  _("Host registration failed for a host. Error: %s\n"), emsg);
987  return;
988  }
990  rc);
991 }
struct GNUNET_TESTBED_HostRegistrationHandle * reg_handle
Host registration handle.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define LOG(kind,...)
Generic loggins shorthand.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
struct GNUNET_SCHEDULER_Task * register_hosts_task
Host registration task.
static void register_hosts(void *cls)
Task to register all hosts available in the global host list.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ controller_status_cb()

static void controller_status_cb ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
int  status 
)
static

Callback to signal successfull startup of the controller process.

Parameters
clsthe closure from GNUNET_TESTBED_controller_start()
cfgthe configuration with which the controller has been started; NULL if status is not GNUNET_OK
statusGNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, GNUNET_TESTBED_controller_stop() shouldn't be called in this case

Definition at line 1041 of file testbed_api_testbed.c.

References _, GNUNET_TESTBED_RunHandle::c, GNUNET_TESTBED_RunHandle::cfg, RunContextOperation::cls, GNUNET_TESTBED_RunHandle::cproc, create_peers(), event_cb(), event_mask, GNUNET_TESTBED_RunHandle::event_mask, GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_dup(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_ET_CONNECT, GNUNET_TESTBED_ET_OPERATION_FINISHED, GNUNET_TESTBED_ET_PEER_START, GNUNET_TESTBED_TOPOLOGY_NONE, GNUNET_TESTBED_RunHandle::h, GNUNET_TESTBED_RunHandle::num_hosts, RunContextOperation::rc, RC_LINKED, GNUNET_TESTBED_RunHandle::reg_hosts, register_hosts(), GNUNET_TESTBED_RunHandle::register_hosts_task, GNUNET_TESTBED_RunHandle::state, and GNUNET_TESTBED_RunHandle::topology.

Referenced by GNUNET_TESTBED_run(), and host_habitable_cb().

1043 {
1044  struct GNUNET_TESTBED_RunHandle *rc = cls;
1045  uint64_t event_mask;
1046 
1047  if (status != GNUNET_OK)
1048  {
1049  rc->cproc = NULL;
1051  _("Controller crash detected. Shutting down.\n"));
1053  return;
1054  }
1056  rc->cfg = GNUNET_CONFIGURATION_dup(cfg);
1057  event_mask = rc->event_mask;
1058  event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
1059  event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
1061  event_mask |= GNUNET_TESTBED_ET_CONNECT;
1062  rc->c =
1063  GNUNET_TESTBED_controller_connect(rc->h, event_mask, &event_cb, rc);
1064  if (0 < rc->num_hosts)
1065  {
1066  rc->reg_hosts = 0;
1068  return;
1069  }
1070  rc->state = RC_LINKED;
1071  create_peers(rc);
1072 }
enum State state
State of this context.
static void event_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Signature of the event handler function called by the respective event controller.
All peers are disconnected.
struct GNUNET_TESTBED_ControllerProc * cproc
The handle to the controller process.
struct GNUNET_TESTBED_Controller * c
The controller handle.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_TESTBED_Host * h
Handle to the host on which the controller runs.
static void create_peers(struct GNUNET_TESTBED_RunHandle *rc)
Function to create peers.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
A requested testbed operation has been completed.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
uint16_t status
See PRISM_STATUS_*-constants.
unsigned int reg_hosts
Number of registered hosts.
uint64_t event_mask
Global event mask for all testbed events.
Controllers on given hosts started and linked.
struct GNUNET_TESTBED_Controller * GNUNET_TESTBED_controller_connect(struct GNUNET_TESTBED_Host *host, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls)
Connect to a controller process.
Definition: testbed_api.c:1547
A connection between two peers was established.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
enum GNUNET_TESTBED_TopologyOption topology
The topology which has to be achieved with the peers started in this context.
#define GNUNET_log(kind,...)
unsigned int num_hosts
Number of hosts in the given host file.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the controller.
struct GNUNET_SCHEDULER_Task * register_hosts_task
Host registration task.
static void register_hosts(void *cls)
Task to register all hosts available in the global host list.
uint64_t event_mask
The event mask for the controller.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netint_proc()

static int netint_proc ( void *  cls,
const char *  name,
int  isDefault,
const struct sockaddr *  addr,
const struct sockaddr *  broadcast_addr,
const struct sockaddr *  netmask,
socklen_t  addrlen 
)
static

Callback function invoked for each interface found.

Parameters
clsclosure
namename of the interface (can be NULL for unknown)
isDefaultis this presumably the default interface
addraddress of this interface (can be NULL for unknown or unassigned)
broadcast_addrthe broadcast address (can be NULL for unknown or unassigned)
netmaskthe network mask (can be NULL for unknown or unassigned))
addrlenlength of the address
Returns
GNUNET_OK to continue iteration, GNUNET_SYSERR to abort

Definition at line 1088 of file testbed_api_testbed.c.

References buf, RunContextOperation::cls, GNUNET_asprintf(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror, GNUNET_OK, GNUNET_strdup, GNUNET_YES, RunContextOperation::rc, and GNUNET_TESTBED_RunHandle::trusted_ip.

Referenced by host_habitable_cb().

1091 {
1092  struct GNUNET_TESTBED_RunHandle *rc = cls;
1093  char hostip[NI_MAXHOST];
1094  char *buf;
1095 
1096  if (sizeof(struct sockaddr_in) != addrlen)
1097  return GNUNET_OK; /* Only consider IPv4 for now */
1098  if (0 !=
1099  getnameinfo(addr, addrlen, hostip, NI_MAXHOST, NULL, 0, NI_NUMERICHOST))
1101  if (NULL == rc->trusted_ip)
1102  {
1103  rc->trusted_ip = GNUNET_strdup(hostip);
1104  return GNUNET_YES;
1105  }
1106  (void)GNUNET_asprintf(&buf, "%s; %s", rc->trusted_ip, hostip);
1107  GNUNET_free(rc->trusted_ip);
1108  rc->trusted_ip = buf;
1109  return GNUNET_YES;
1110 }
char * trusted_ip
The trusted IP string.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static char buf[2048]
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ host_habitable_cb()

static void host_habitable_cb ( void *  cls,
const struct GNUNET_TESTBED_Host host,
int  status 
)
static

Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to inform whether the given host is habitable or not.

The Handle returned by GNUNET_TESTBED_is_host_habitable() is invalid after this callback is called

Parameters
clsNULL
hostthe host whose status is being reported; will be NULL if the host given to GNUNET_TESTBED_is_host_habitable() is NULL
statusGNUNET_YES if it is habitable; GNUNET_NO if not

Definition at line 1124 of file testbed_api_testbed.c.

References _, RunContextOperation::cls, controller_status_cb(), GNUNET_TESTBED_RunHandle::cproc, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_OS_network_interfaces_list(), GNUNET_SCHEDULER_shutdown(), GNUNET_strdup, GNUNET_TESTBED_controller_start(), GNUNET_TESTBED_host_get_hostname(), GNUNET_TESTBED_host_resolve_(), CompatibilityCheckContext::h, GNUNET_TESTBED_RunHandle::h, GNUNET_TESTBED_RunHandle::hclist, GNUNET_TESTBED_RunHandle::hosts, CompatibilityCheckContext::index, LOG, netint_proc(), GNUNET_TESTBED_RunHandle::num_hosts, RunContextOperation::rc, CompatibilityCheckContext::rc, GNUNET_TESTBED_RunHandle::reg_hosts, and GNUNET_TESTBED_RunHandle::trusted_ip.

Referenced by GNUNET_TESTBED_run().

1126 {
1127  struct CompatibilityCheckContext *hc = cls;
1128  struct GNUNET_TESTBED_RunHandle *rc;
1129  struct GNUNET_TESTBED_Host **old_hosts;
1130  unsigned int nhost;
1131 
1132  GNUNET_assert(NULL != (rc = hc->rc));
1133  nhost = hc->index;
1134  GNUNET_assert(nhost <= rc->num_hosts);
1135  GNUNET_assert(host == rc->hosts[nhost]);
1136  hc->h = NULL;
1137  if (GNUNET_NO == status)
1138  {
1139  if ((NULL != host) && (NULL != GNUNET_TESTBED_host_get_hostname(host)))
1140  LOG(GNUNET_ERROR_TYPE_ERROR, _("Host %s cannot start testbed\n"),
1142  else
1144  _("Testbed cannot be started on localhost\n"));
1146  return;
1147  }
1148  rc->reg_hosts++;
1149  if (rc->reg_hosts < rc->num_hosts)
1150  return;
1151  GNUNET_free(rc->hclist);
1152  rc->hclist = NULL;
1153  rc->h = rc->hosts[0];
1154  rc->num_hosts--;
1155  if (0 < rc->num_hosts)
1156  {
1157  old_hosts = rc->hosts;
1158  rc->hosts =
1159  GNUNET_malloc(sizeof(struct GNUNET_TESTBED_Host *) * rc->num_hosts);
1160  GNUNET_memcpy(rc->hosts, &old_hosts[1],
1161  (sizeof(struct GNUNET_TESTBED_Host *) * rc->num_hosts));
1162  GNUNET_free(old_hosts);
1163  }
1164  else
1165  {
1166  GNUNET_free(rc->hosts);
1167  rc->hosts = NULL;
1168  }
1170  for (nhost = 0; nhost < rc->num_hosts; nhost++)
1171  GNUNET_TESTBED_host_resolve_(rc->hosts[nhost]);
1173  if (NULL == rc->trusted_ip)
1174  rc->trusted_ip = GNUNET_strdup("127.0.0.1");
1175  rc->cproc =
1177  &controller_status_cb, rc);
1178  GNUNET_free(rc->trusted_ip);
1179  rc->trusted_ip = NULL;
1180  if (NULL == rc->cproc)
1181  {
1182  LOG(GNUNET_ERROR_TYPE_ERROR, _("Cannot start the master controller"));
1184  }
1185 }
unsigned int index
Index of the host in the run context&#39;s hosts array.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_ControllerProc * cproc
The handle to the controller process.
char * trusted_ip
The trusted IP string.
Context for host compability checks.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_OS_network_interfaces_list(GNUNET_OS_NetworkInterfaceProcessor proc, void *proc_cls)
Enumerate all network interfaces.
Definition: os_network.c:388
Opaque handle to a host running experiments managed by the testing framework.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_TESTBED_Host * h
Handle to the host on which the controller runs.
struct GNUNET_TESTBED_HostHabitableCheckHandle * h
Handle for the compability check.
#define LOG(kind,...)
Generic loggins shorthand.
struct CompatibilityCheckContext * hclist
Array of compatibility check contexts.
void GNUNET_TESTBED_host_resolve_(struct GNUNET_TESTBED_Host *host)
Resolves the hostname of the host to an ip address.
uint16_t status
See PRISM_STATUS_*-constants.
struct GNUNET_TESTBED_RunHandle * rc
The run context.
unsigned int reg_hosts
Number of registered hosts.
static int netint_proc(void *cls, const char *name, int isDefault, const struct sockaddr *addr, const struct sockaddr *broadcast_addr, const struct sockaddr *netmask, socklen_t addrlen)
Callback function invoked for each interface found.
const char * GNUNET_TESTBED_host_get_hostname(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s hostname.
unsigned int num_hosts
Number of hosts in the given host file.
struct GNUNET_TESTBED_Host ** hosts
An array of hosts loaded from the hostkeys file.
static void controller_status_cb(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status)
Callback to signal successfull startup of the controller process.
struct GNUNET_TESTBED_ControllerProc * GNUNET_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.
#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:

◆ timeout_task()

static void timeout_task ( void *  cls)
static

Task run upon timeout while setting up the testbed.

Parameters
clsthe RunContext

Definition at line 1194 of file testbed_api_testbed.c.

References _, RunContextOperation::cls, GNUNET_ERROR_TYPE_ERROR, GNUNET_SCHEDULER_shutdown(), LOG, RunContextOperation::rc, GNUNET_TESTBED_RunHandle::test_master, GNUNET_TESTBED_RunHandle::test_master_cls, and GNUNET_TESTBED_RunHandle::timeout_task.

Referenced by GNUNET_TESTBED_run().

1195 {
1196  struct GNUNET_TESTBED_RunHandle *rc = cls;
1197 
1198  rc->timeout_task = NULL;
1200  _("Shutting down testbed due to timeout while setup.\n"));
1202  if (NULL != rc->test_master)
1203  rc->test_master(rc->test_master_cls, rc, 0, NULL, 0, 0);
1204  rc->test_master = NULL;
1205 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run of a timeout.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define LOG(kind,...)
Generic loggins shorthand.
void * test_master_cls
The closure for the TestMaster callback.
GNUNET_TESTBED_TestMaster test_master
TestMaster callback to call when testbed initialization is done.
Here is the call graph for this function:
Here is the caller graph for this function: