GNUnet  0.10.x
Data Structures | Typedefs | Enumerations | Functions
Testbed service

Writing tests and creating large-scale emulation testbeds for GNUnet. More...

Data Structures

struct  GNUNET_TESTBED_EventInformation
 Argument to GNUNET_TESTBED_ControllerCallback with details about the event. More...
 
struct  GNUNET_TESTBED_PeerInformation
 Data returned from GNUNET_TESTBED_peer_get_information. More...
 

Typedefs

typedef 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 host is habitable or not. More...
 
typedef void(* GNUNET_TESTBED_ControllerCallback) (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
 Signature of the event handler function called by the respective event controller. More...
 
typedef void(* GNUNET_TESTBED_ControllerStatusCallback) (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status)
 Callback to signal successfull startup of the controller process. More...
 
typedef void(* GNUNET_TESTBED_HostRegistrationCompletion) (void *cls, const char *emsg)
 Callback which will be called to after a host registration succeeded or failed. More...
 
typedef void(* GNUNET_TESTBED_OperationCompletionCallback) (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
 Callback to be called when an operation is completed. More...
 
typedef void(* GNUNET_TESTBED_PeerCreateCallback) (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
 Functions of this signature are called when a peer has been successfully created. More...
 
typedef void(* GNUNET_TESTBED_PeerChurnCallback) (void *cls, const char *emsg)
 Functions of this signature are called when a peer has been successfully started or stopped. More...
 
typedef void(* GNUNET_TESTBED_PeerInfoCallback) (void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
 Callback to be called when the requested peer information is available The peer information in the callback is valid until the operation 'op' is canceled. More...
 
typedef void(* GNUNET_TESTBED_TopologyCompletionCallback) (void *cls, unsigned int nsuccess, unsigned int nfailures)
 Callbacks of this type are called when topology configuration is completed. More...
 
typedef void *(* GNUNET_TESTBED_ConnectAdapter) (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Adapter function called to establish a connection to a service. More...
 
typedef void(* GNUNET_TESTBED_DisconnectAdapter) (void *cls, void *op_result)
 Adapter function called to destroy a connection to a service. More...
 
typedef void(* GNUNET_TESTBED_ServiceConnectCompletionCallback) (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
 Callback to be called when a service connect operation is completed. More...
 
typedef int(* GNUNET_TESTBED_StatisticsIterator) (void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
 Callback function to process statistic values from all peers. More...
 
typedef void(* GNUNET_TESTBED_TestMaster) (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
 Signature of a main function for a testcase. More...
 
typedef void(* GNUNET_TESTBED_barrier_status_cb) (void *cls, const char *name, struct GNUNET_TESTBED_Barrier *barrier, enum GNUNET_TESTBED_BarrierStatus status, const char *emsg)
 Functions of this type are to be given as callback argument to GNUNET_TESTBED_barrier_init(). More...
 
typedef void(* GNUNET_TESTBED_barrier_wait_cb) (void *cls, const char *name, int status)
 Functions of this type are to be given as acallback argumetn to GNUNET_TESTBED_barrier_wait(). More...
 

Enumerations

enum  GNUNET_TESTBED_EventType {
  GNUNET_TESTBED_ET_PEER_START = 0, GNUNET_TESTBED_ET_PEER_STOP = 1, GNUNET_TESTBED_ET_CONNECT = 2, GNUNET_TESTBED_ET_DISCONNECT = 3,
  GNUNET_TESTBED_ET_OPERATION_FINISHED = 4
}
 Enumeration with (at most 64) possible event types that can be monitored using the testbed framework. More...
 
enum  GNUNET_TESTBED_PeerInformationType { GNUNET_TESTBED_PIT_GENERIC = 0, GNUNET_TESTBED_PIT_CONFIGURATION, GNUNET_TESTBED_PIT_IDENTITY }
 Types of information that can be requested about a peer. More...
 
enum  GNUNET_TESTBED_ConnectOption { GNUNET_TESTBED_CO_NONE = 0, GNUNET_TESTBED_CO_ALLOW = 1 }
 Options for peer connections. More...
 
enum  GNUNET_TESTBED_TopologyOption {
  GNUNET_TESTBED_TOPOLOGY_CLIQUE, GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD, GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING, GNUNET_TESTBED_TOPOLOGY_RING,
  GNUNET_TESTBED_TOPOLOGY_STAR, GNUNET_TESTBED_TOPOLOGY_2D_TORUS, GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, GNUNET_TESTBED_TOPOLOGY_INTERNAT,
  GNUNET_TESTBED_TOPOLOGY_SCALE_FREE, GNUNET_TESTBED_TOPOLOGY_LINE, GNUNET_TESTBED_TOPOLOGY_FROM_FILE, GNUNET_TESTBED_TOPOLOGY_NONE,
  GNUNET_TESTBED_TOPOLOGY_OPTION_END, GNUNET_TESTBED_TOPOLOGY_RETRY_CNT
}
 Topologies and topology options supported for testbeds. More...
 
enum  GNUNET_TESTBED_BarrierStatus { GNUNET_TESTBED_BARRIERSTATUS_INITIALISED = 1, GNUNET_TESTBED_BARRIERSTATUS_CROSSED, GNUNET_TESTBED_BARRIERSTATUS_ERROR }
 Status of a barrier. More...
 
enum  GNUNET_TESTBED_UnderlayLinkModelType { GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST, GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_WHITELIST }
 The type of GNUNET_TESTBED_UnderlayLinkModel. More...
 

Functions

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...
 
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...
 
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...
 
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...
 
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...
 
const char * GNUNET_TESTBED_host_get_hostname (const struct GNUNET_TESTBED_Host *host)
 Obtain the host's hostname. 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_stop (struct GNUNET_TESTBED_ControllerProc *cproc)
 Stop the controller process (also will terminate all peers and controllers dependent on this controller). More...
 
struct GNUNET_TESTBED_ControllerGNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls)
 Connect to a controller process. More...
 
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). 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...
 
struct GNUNET_TESTBED_OperationGNUNET_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. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_get_slave_config (void *op_cls, struct GNUNET_TESTBED_Controller *master, struct GNUNET_TESTBED_Host *slave_host)
 Function to acquire the configuration of a running slave controller. More...
 
struct GNUNET_TESTBED_OperationGNUNET_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. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_start (void *op_cls, struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
 Start the given peer. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_stop (void *op_cls, struct GNUNET_TESTBED_Peer *peer, GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls)
 Stop the given peer. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, enum GNUNET_TESTBED_PeerInformationType pit, GNUNET_TESTBED_PeerInfoCallback cb, void *cb_cls)
 Request information about a peer. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Change peer configuration. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer)
 Destroy the given peer; the peer should have been stopped first (if it was started). More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_peer_manage_service (void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, unsigned int start)
 Start or stop given service at a peer. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_shutdown_peers (struct GNUNET_TESTBED_Controller *c, void *op_cls, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls)
 Stops and destroys all peers. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_underlay_configure_link_va (void *op_cls, struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p2, enum GNUNET_TESTBED_ConnectOption co, va_list ap)
 Manipulate the P2P underlay topology by configuring a link between two peers. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_underlay_configure_link (void *op_cls, struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p2, enum GNUNET_TESTBED_ConnectOption co,...)
 Manipulate the P2P underlay topology by configuring a link between two peers. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_underlay_configure_topology_va (void *op_cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, enum GNUNET_TESTBED_TopologyOption topo, va_list ap)
 Configure overall network topology to have a particular shape. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_underlay_configure_topology (void *op_cls, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, enum GNUNET_TESTBED_TopologyOption topo,...)
 Configure overall network topology to have a particular shape. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_overlay_connect (void *op_cls, GNUNET_TESTBED_OperationCompletionCallback cb, void *cb_cls, struct GNUNET_TESTBED_Peer *p1, struct GNUNET_TESTBED_Peer *p2)
 Both peers must have been started before calling this function. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_overlay_configure_topology_va (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, va_list va)
 All peers must have been started before calling this function. More...
 
struct GNUNET_TESTBED_OperationGNUNET_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. More...
 
void GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller, const char *filename)
 Ask the testbed controller to write the current overlay topology to a file. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_service_connect (void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
 Connect to a service offered by the given peer. More...
 
void GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation)
 This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) from an operation has been fully processed i.e. More...
 
struct GNUNET_TESTBED_OperationGNUNET_TESTBED_get_statistics (unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, const char *subsystem, const char *name, GNUNET_TESTBED_StatisticsIterator proc, GNUNET_TESTBED_OperationCompletionCallback cont, void *cls)
 Convenience method that iterates over all (running) peers and retrieves all statistics from each peer. More...
 
uint32_t GNUNET_TESTBED_get_index (const struct GNUNET_TESTBED_Peer *peer)
 Return the index of the peer inside of the total peer array, aka. 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...
 
int GNUNET_TESTBED_test_run (const char *testname, const char *cfg_filename, 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 "simple" test on the local system with a single call from 'main'. 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...
 
struct GNUNET_TESTBED_BarrierGNUNET_TESTBED_barrier_init (struct GNUNET_TESTBED_Controller *controller, const char *name, unsigned int quorum, GNUNET_TESTBED_barrier_status_cb cb, void *cb_cls)
 Initialise a barrier and call the given callback when the required percentage of peers (quorum) reach the barrier. More...
 
void GNUNET_TESTBED_barrier_cancel (struct GNUNET_TESTBED_Barrier *barrier)
 Cancel a barrier. More...
 
struct GNUNET_TESTBED_BarrierWaitHandleGNUNET_TESTBED_barrier_wait (const char *name, GNUNET_TESTBED_barrier_wait_cb cb, void *cls)
 Wait for a barrier to be crossed. More...
 
void GNUNET_TESTBED_barrier_wait_cancel (struct GNUNET_TESTBED_BarrierWaitHandle *h)
 Cancel a barrier wait handle. More...
 
struct GNUNET_TESTBED_UnderlayLinkModelGNUNET_TESTBED_underlaylinkmodel_create (struct GNUNET_TESTBED_Peer *peer, enum GNUNET_TESTBED_UnderlayLinkModelType type)
 Create a GNUNET_TESTBED_UnderlayLinkModel for the given peer. More...
 
void GNUNET_TESTBED_underlaylinkmodel_add_peer (struct GNUNET_TESTBED_UnderlayLinkModel *model, struct GNUNET_TESTBED_Peer *peer)
 Add a peer to the given model. More...
 
void GNUNET_TESTBED_underlaylinkmodel_set_link (struct GNUNET_TESTBED_UnderlayLinkModel *model, struct GNUNET_TESTBED_Peer *peer, uint32_t latency, uint32_t loss, uint32_t bandwidth)
 Set the metrics for a link to the given peer in the underlay model. More...
 
void GNUNET_TESTBED_underlaylinkmodel_commit (struct GNUNET_TESTBED_UnderlayLinkModel *model)
 Commit the model. More...
 
void GNUNET_TESTBED_underlaylinkmodel_free (struct GNUNET_TESTBED_UnderlayLinkModel *model)
 Free the resources of the model. More...
 

Detailed Description

Writing tests and creating large-scale emulation testbeds for GNUnet.

See also
Documentation

Typedef Documentation

◆ GNUNET_TESTBED_HostHabitableCallback

typedef 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 host is habitable or not.

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

Parameters
clsthe closure given to GNUNET_TESTBED_is_host_habitable()
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 187 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_ControllerCallback

typedef void(* GNUNET_TESTBED_ControllerCallback) (void *cls, const struct GNUNET_TESTBED_EventInformation *event)

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

Parameters
clsclosure
eventinformation about the event

Definition at line 400 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_ControllerStatusCallback

typedef void(* GNUNET_TESTBED_ControllerStatusCallback) (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status)

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 420 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_HostRegistrationCompletion

typedef void(* GNUNET_TESTBED_HostRegistrationCompletion) (void *cls, const char *emsg)

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 514 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_OperationCompletionCallback

typedef void(* GNUNET_TESTBED_OperationCompletionCallback) (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)

Callback to be called when an operation is completed.

Parameters
clsthe callback closure from functions generating an operation
opthe operation that has been finished
emsgerror message in case the operation has failed; will be NULL if operation has executed successfully.

Definition at line 563 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_PeerCreateCallback

typedef void(* GNUNET_TESTBED_PeerCreateCallback) (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)

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 635 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_PeerChurnCallback

typedef void(* GNUNET_TESTBED_PeerChurnCallback) (void *cls, const char *emsg)

Functions of this signature are called when a peer has been successfully started or stopped.

Parameters
clsthe closure from GNUNET_TESTBED_peer_start/stop()
emsgNULL on success; otherwise an error description

Definition at line 685 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_PeerInfoCallback

typedef void(* GNUNET_TESTBED_PeerInfoCallback) (void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)

Callback to be called when the requested peer information is available The peer information in the callback is valid until the operation 'op' is canceled.

Parameters
cb_clsthe closure from GNUNET_TETSBED_peer_get_information()
opthe operation this callback corresponds to
pinfothe result; will be NULL if the operation has failed
emsgerror message if the operation has failed; will be NULL if the operation is successfull

Definition at line 763 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_TopologyCompletionCallback

typedef void(* GNUNET_TESTBED_TopologyCompletionCallback) (void *cls, unsigned int nsuccess, unsigned int nfailures)

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 1096 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_ConnectAdapter

typedef void*(* GNUNET_TESTBED_ConnectAdapter) (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)

Adapter function called to establish a connection to a service.

Parameters
clsclosure
cfgconfiguration of the peer to connect to; will be available until GNUNET_TESTBED_operation_done() is called on the operation returned from GNUNET_TESTBED_service_connect()
Returns
service handle to return in 'op_result', NULL on error

Definition at line 1191 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_DisconnectAdapter

typedef void(* GNUNET_TESTBED_DisconnectAdapter) (void *cls, void *op_result)

Adapter function called to destroy a connection to a service.

Parameters
clsclosure
op_resultservice handle returned from the connect adapter

Definition at line 1203 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_ServiceConnectCompletionCallback

typedef void(* GNUNET_TESTBED_ServiceConnectCompletionCallback) (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)

Callback to be called when a service connect operation is completed.

Parameters
clsthe callback closure from functions generating an operation
opthe operation that has been finished
ca_resultthe service handle returned from GNUNET_TESTBED_ConnectAdapter()
emsgerror message in case the operation has failed; will be NULL if operation has executed successfully.

Definition at line 1217 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_StatisticsIterator

typedef int(* GNUNET_TESTBED_StatisticsIterator) (void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)

Callback function to process statistic values from all peers.

Parameters
clsclosure
peerthe peer the statistic belong to
subsystemname of subsystem that created the statistic
namethe name of the datum
valuethe current value
is_persistentGNUNET_YES if the value is persistent, GNUNET_NO if not
Returns
GNUNET_OK to continue, GNUNET_SYSERR to abort iteration

Definition at line 1293 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_TestMaster

typedef void(* GNUNET_TESTBED_TestMaster) (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)

Signature of a main function for a testcase.

Parameters
clsclosure
hthe run handle
num_peersnumber of peers in 'peers'
peershandle to peers run in the testbed. NULL upon timeout (see GNUNET_TESTBED_test_run()).
links_succeededthe number of overlay link connection attempts that succeeded
links_failedthe number of overlay link connection attempts that failed
See also
GNUNET_TESTBED_test_run()

Definition at line 1358 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_barrier_status_cb

typedef void(* GNUNET_TESTBED_barrier_status_cb) (void *cls, const char *name, struct GNUNET_TESTBED_Barrier *barrier, enum GNUNET_TESTBED_BarrierStatus status, const char *emsg)

Functions of this type are to be given as callback argument to GNUNET_TESTBED_barrier_init().

The callback will be called when status information is available for the barrier.

Parameters
clsthe closure given to GNUNET_TESTBED_barrier_init()
namethe name of the barrier
barrierthe barrier handle
statusstatus of the barrier. The barrier is removed once it has been crossed or an error occurs while processing it. Therefore it is invalid to call GNUNET_TESTBED_barrier_cancel() on a crossed or errored barrier.
emsgif the status were to be GNUNET_SYSERR, this parameter has the error messsage

Definition at line 1513 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_barrier_wait_cb

typedef void(* GNUNET_TESTBED_barrier_wait_cb) (void *cls, const char *name, int status)

Functions of this type are to be given as acallback argumetn to GNUNET_TESTBED_barrier_wait().

The callback will be called when the barrier corresponding given in GNUNET_TESTBED_barrier_wait() is crossed or cancelled.

Parameters
clsclosure pointer given to GNUNET_TESTBED_barrier_wait()
namethe barrier name
statusGNUNET_SYSERR in case of error while waiting for the barrier; GNUNET_OK if the barrier is crossed

Definition at line 1568 of file gnunet_testbed_service.h.

Enumeration Type Documentation

◆ GNUNET_TESTBED_EventType

Enumeration with (at most 64) possible event types that can be monitored using the testbed framework.

Enumerator
GNUNET_TESTBED_ET_PEER_START 

A peer has been started.

GNUNET_TESTBED_ET_PEER_STOP 

A peer has been stopped.

GNUNET_TESTBED_ET_CONNECT 

A connection between two peers was established.

GNUNET_TESTBED_ET_DISCONNECT 

A connection between two peers was torn down.

GNUNET_TESTBED_ET_OPERATION_FINISHED 

A requested testbed operation has been completed.

Definition at line 235 of file gnunet_testbed_service.h.

235  {
240 
245 
250 
255 
260 };
A requested testbed operation has been completed.
A connection between two peers was torn down.
A connection between two peers was established.
A peer has been stopped.

◆ GNUNET_TESTBED_PeerInformationType

Types of information that can be requested about a peer.

Enumerator
GNUNET_TESTBED_PIT_GENERIC 

Special value (not valid for requesting information) that is used in the event struct if a 'generic' pointer is returned (for other operations not related to this enumeration).

GNUNET_TESTBED_PIT_CONFIGURATION 

What configuration is the peer using? Returns a 'const struct GNUNET_CONFIGURATION_Handle *'.

Valid until 'GNUNET_TESTNIG_operation_done' is called. However, the values may be inaccurate if the peer is reconfigured in the meantime.

GNUNET_TESTBED_PIT_IDENTITY 

What is the identity of the peer? Returns a 'const struct GNUNET_PeerIdentity *'.

Valid until 'GNUNET_TESTNIG_operation_done' is called.

Definition at line 266 of file gnunet_testbed_service.h.

266  {
274 
283 
290 };
Special value (not valid for requesting information) that is used in the event struct if a 'generic' ...
What configuration is the peer using? Returns a 'const struct GNUNET_CONFIGURATION_Handle *'...
What is the identity of the peer? Returns a 'const struct GNUNET_PeerIdentity *'. ...

◆ GNUNET_TESTBED_ConnectOption

Options for peer connections.

Enumerator
GNUNET_TESTBED_CO_NONE 

No option (not valid as an argument).

GNUNET_TESTBED_CO_ALLOW 

Allow or disallow a connection between the specified peers.

Followed by GNUNET_NO (int) if a connection is disallowed or GNUNET_YES if a connection is allowed. Note that the default (all connections allowed or disallowed) is specified in the configuration of the controller.

Definition at line 865 of file gnunet_testbed_service.h.

865  {
870 
879 
885 };
No option (not valid as an argument).
Allow or disallow a connection between the specified peers.

◆ GNUNET_TESTBED_TopologyOption

Topologies and topology options supported for testbeds.

Options should always end with GNUNET_TESTBED_TOPOLOGY_OPTION_END

Enumerator
GNUNET_TESTBED_TOPOLOGY_CLIQUE 

A clique (everyone connected to everyone else).

No options. If there are N peers this topology results in (N * (N -1)) connections.

GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD 

Small-world network (2d torus plus random links).

Followed by the number of random links to add (unsigned int).

GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING 

Small-world network (ring plus random links).

Followed by the number of random links to add (unsigned int).

GNUNET_TESTBED_TOPOLOGY_RING 

Ring topology.

No options.

GNUNET_TESTBED_TOPOLOGY_STAR 

Star topology.

No options.

GNUNET_TESTBED_TOPOLOGY_2D_TORUS 

2-d torus.

No options.

GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI 

Random graph.

Followed by the number of random links to be established (unsigned int)

GNUNET_TESTBED_TOPOLOGY_INTERNAT 

Certain percentage of peers are unable to communicate directly replicating NAT conditions.

Followed by the fraction of NAT'ed peers (float).

GNUNET_TESTBED_TOPOLOGY_SCALE_FREE 

Scale free topology.

It is generated according to the method described in "Emergence of Scaling in Random Networks." Science 286, 509-512, 1999.

This options takes two arguments in the following order: an uint16_t to determine the maximum number of edges a peer is permitted to have while generating scale free topology, a good value for this argument is 70; and an uint8_t to determine the number of edges to be established when adding a new node to the scale free network, a good value for this argument is 4.

GNUNET_TESTBED_TOPOLOGY_LINE 

Straight line topology.

No options.

GNUNET_TESTBED_TOPOLOGY_FROM_FILE 

Read a topology from a given file.

Followed by the name of the file (const char *).

GNUNET_TESTBED_TOPOLOGY_NONE 

All peers are disconnected.

No options.

GNUNET_TESTBED_TOPOLOGY_OPTION_END 

The options should always end with this.

GNUNET_TESTBED_TOPOLOGY_RETRY_CNT 

How many times should the failed overlay connect operations be retried before giving up.

The default if this option is not specified is to retry 3 times. This option takes and unsigned integer as a parameter. Use this option with parameter 0 to disable retrying of failed overlay connect operations.

Definition at line 932 of file gnunet_testbed_service.h.

932  {
938 
944 
950 
955 
960 
965 
971 
978 
990 
995 
1000 
1005 
1010 
1011  /* The following are not topologies but influence how the topology has to be
1012  setup. These options should follow the topology specific options (if
1013  required by the chosen topology). Note that these should be given before
1014  GNUNET_TESTBED_TOPOLOGY_OPTION_END */
1015 
1024 };
A clique (everyone connected to everyone else).
All peers are disconnected.
Read a topology from a given file.
Certain percentage of peers are unable to communicate directly replicating NAT conditions.
How many times should the failed overlay connect operations be retried before giving up...
The options should always end with this.
Small-world network (2d torus plus random links).
Small-world network (ring plus random links).

◆ GNUNET_TESTBED_BarrierStatus

Status of a barrier.

Enumerator
GNUNET_TESTBED_BARRIERSTATUS_INITIALISED 

Barrier initialised successfully.

GNUNET_TESTBED_BARRIERSTATUS_CROSSED 

Barrier is crossed.

GNUNET_TESTBED_BARRIERSTATUS_ERROR 

Error status.

Definition at line 1479 of file gnunet_testbed_service.h.

◆ GNUNET_TESTBED_UnderlayLinkModelType

The type of GNUNET_TESTBED_UnderlayLinkModel.

Enumerator
GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST 

The model is based on white listing of peers to which underlay connections are permitted.

Underlay connections to all other peers will not be permitted.

GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_WHITELIST 

The model is based on black listing of peers to which underlay connections are not permitted.

Underlay connections to all other peers will be permitted

Definition at line 1611 of file gnunet_testbed_service.h.

1611  {
1618 
1625 };
The model is based on black listing of peers to which underlay connections are not permitted...
The model is based on white listing of peers to which underlay connections are permitted.

Function Documentation

◆ GNUNET_TESTBED_host_create()

struct GNUNET_TESTBED_Host* GNUNET_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.

Parameters
hostnamename of the host, use "NULL" for localhost
usernameusername to use for the login; may be NULL
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
portport number to use for ssh; use 0 to let ssh decide
Returns
handle to the host, NULL on error

Definition at line 373 of file testbed_api_hosts.c.

References GNUNET_TESTBED_host_create_with_id().

Referenced by GNUNET_TESTBED_hosts_load_from_file(), and GNUNET_TESTBED_run().

377 {
378  static uint32_t uid_generator;
379 
380  if (NULL == hostname)
382  hostname,
383  username,
384  cfg,
385  port);
386  return GNUNET_TESTBED_host_create_with_id(++uid_generator,
387  hostname,
388  username,
389  cfg,
390  port);
391 }
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.
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_create_with_id()

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.

This function is used if a peer learns about a host via IPC between controllers (and thus some higher-level controller has already determined the unique IDs).

Parameters
idglobal host ID assigned to the host; 0 is reserved to always mean 'localhost'
hostnamename of the host, use "NULL" for localhost
usernameusername to use for the login; may be NULL
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
portport number to use for ssh; use 0 to let ssh decide
Returns
handle to the host, NULL on error
Parameters
idglobal host ID assigned to the host; 0 is reserved to always mean 'localhost'
hostnamename of the host, use "NULL" for localhost
usernameusername to use for the login; may be NULL
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
portport number to use for ssh; use 0 to let ssh decide
Returns
handle to the host, NULL on error

Definition at line 325 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::cfg, GNUNET_array_grow, GNUNET_assert, GNUNET_CONFIGURATION_dup(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_new, GNUNET_strdup, GNUNET_TESTBED_operation_queue_create_(), HOST_LIST_GROW_STEP, host_list_size, hostname, GNUNET_TESTBED_Host::hostname, GNUNET_TESTBED_Host::id, id, LOG, OPERATION_QUEUE_TYPE_ADAPTIVE, GNUNET_TESTBED_Host::opq_parallel_overlay_connect_operations, port, GNUNET_TESTBED_Host::port, and GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_host_create(), GNUNET_TESTBED_host_create_by_id_(), handle_add_host(), and handle_init().

331 {
332  struct GNUNET_TESTBED_Host *host;
333  unsigned int new_size;
334 
335  if ((id < host_list_size) && (NULL != host_list[id]))
336  {
337  LOG(GNUNET_ERROR_TYPE_WARNING, "Host with id: %u already created\n", id);
338  return NULL;
339  }
340  host = GNUNET_new(struct GNUNET_TESTBED_Host);
341  host->hostname = (NULL != hostname) ? GNUNET_strdup(hostname) : NULL;
342  host->username = (NULL != username) ? GNUNET_strdup(username) : NULL;
343  host->id = id;
344  host->port = (0 == port) ? 22 : port;
345  host->cfg = GNUNET_CONFIGURATION_dup(cfg);
348  UINT_MAX);
349  new_size = host_list_size;
350  while (id >= new_size)
351  new_size += HOST_LIST_GROW_STEP;
352  if (new_size != host_list_size)
355  LOG(GNUNET_ERROR_TYPE_DEBUG, "Adding host with id: %u\n", host->id);
356  host_list[id] = host;
357  return host;
358 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct OperationQueue * opq_parallel_overlay_connect_operations
Operation queue for simultaneous overlay connect operations target at this host.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define LOG(kind,...)
Generic logging shorthand.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Opaque handle to a host running experiments managed by the testing framework.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct OperationQueue * GNUNET_TESTBED_operation_queue_create_(enum OperationQueueType type, unsigned int max_active)
Create an operation queue.
struct GNUNET_CONFIGURATION_Handle * cfg
the configuration to use as a template while starting a controller on this host.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
uint32_t id
Global ID we use to refer to a host on the network.
uint16_t port
The port which is to be used for SSH.
const char * username
The username to be used for SSH login.
#define HOST_LIST_GROW_STEP
Number of extra elements we create space for when we grow host list.
const char * hostname
The hostname of the host; NULL for localhost.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
static char * hostname
Our hostname; we give this to all the peers we start.
static unsigned int host_list_size
The size of the available hosts list.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
Operation queue which adapts the number of operations to be active based on the operation completion ...
static struct GNUNET_TESTBED_Host ** host_list
Array of available hosts.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_hosts_load_from_file()

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.

The hostfile format is specified at https://gnunet.org/content/hosts-file-format

Parameters
filenamefile with the host specification
cfgthe configuration to use as a template while starting a controller on any of the loaded hosts. Operation queue sizes specific to a host are also read from this configuration handle
hostsset to the hosts found in the file; caller must free this if number of hosts returned is greater than 0
Returns
number of hosts returned in 'hosts', 0 on error
Parameters
filenamefile with the host specification
cfgthe configuration to use as a template while starting a controller on any of the loaded hosts. Operation queue sizes specific to a host are also read from this configuration handle
hostsset to the hosts found in the file; caller must free this if number of hosts returned is greater than 0
Returns
number of hosts returned in 'hosts', 0 on error

Definition at line 406 of file testbed_api_hosts.c.

References _, buf, data, fs, GNUNET_assert, GNUNET_DISK_file_size(), GNUNET_DISK_file_test(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_free_non_null, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_strlcpy(), GNUNET_TESTBED_host_create(), GNUNET_TESTBED_host_get_id_(), GNUNET_YES, hostname, LOG, port, size, and GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_hosts_load_from_loadleveler(), and GNUNET_TESTBED_run().

410 {
411  struct GNUNET_TESTBED_Host *starting_host;
412  char *data;
413  char *buf;
414  char *username;
415  char *hostname;
416  regex_t rex;
417  regmatch_t pmatch[6];
418  uint64_t fs;
419  short int port;
420  unsigned int offset;
421  unsigned int count;
422 
423 
424  GNUNET_assert(NULL != filename);
426  {
427  LOG(GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s not found\n"), filename);
428  return 0;
429  }
430  if (GNUNET_OK !=
432  fs = 0;
433  if (0 == fs)
434  {
436  _("Hosts file %s has no data\n"),
437  filename);
438  return 0;
439  }
440  data = GNUNET_malloc(fs);
441  if (fs != GNUNET_DISK_fn_read(filename, data, fs))
442  {
443  GNUNET_free(data);
445  _("Hosts file %s cannot be read\n"),
446  filename);
447  return 0;
448  }
449  buf = data;
450  offset = 0;
451  starting_host = NULL;
452  count = 0;
453  /* refer RFC 952 and RFC 1123 for valid hostnames */
454  GNUNET_assert(0 == regcomp(&rex,
455  "^(([[:alnum:]]+)@)?" /* username */
456  "([[:alnum:]]+[-[:alnum:]_\\.]+)" /* hostname */
457  "(:([[:digit:]]{1,5}))?", /* port */
458  REG_EXTENDED | REG_ICASE));
459  while (offset < (fs - 1))
460  {
461  offset++;
462  if (((data[offset] == '\n')) && (buf != &data[offset]))
463  {
464  unsigned int size;
465 
466  data[offset] = '\0';
467  username = NULL;
468  hostname = NULL;
469  port = 0;
470  if ((REG_NOMATCH == regexec(&rex, buf, 6, pmatch, 0)) ||
471  (-1 == pmatch[3].rm_so))
472  {
474  "Error reading line `%s' in hostfile\n",
475  buf);
476  buf = &data[offset + 1];
477  continue;
478  }
479  if (-1 != pmatch[2].rm_so)
480  {
481  size = pmatch[2].rm_eo - pmatch[2].rm_so;
482  username = GNUNET_malloc(size + 1);
484  0 != GNUNET_strlcpy(username, buf + pmatch[2].rm_so, size + 1));
485  }
486  if (-1 != pmatch[5].rm_so)
487  {
488  (void)sscanf(buf + pmatch[5].rm_so, "%5hd", &port);
489  }
490  size = pmatch[3].rm_eo - pmatch[3].rm_so;
491  hostname = GNUNET_malloc(size + 1);
493  0 != GNUNET_strlcpy(hostname, buf + pmatch[3].rm_so, size + 1));
495  "Successfully read host %s, port %d and user %s from file\n",
496  (NULL == hostname) ? "NULL" : hostname,
497  port,
498  (NULL == username) ? "NULL" : username);
499  /* We store hosts in a static list; hence we only require the starting
500  * host pointer in that list to access the newly created list of hosts */
501  if (NULL == starting_host)
502  starting_host =
503  GNUNET_TESTBED_host_create(hostname, username, cfg, port);
504  else
505  (void)GNUNET_TESTBED_host_create(hostname, username, cfg, port);
506  count++;
507  GNUNET_free_non_null(username);
508  GNUNET_free(hostname);
509  buf = &data[offset + 1];
510  }
511  else if ((data[offset] == '\n') || (data[offset] == '\0'))
512  buf = &data[offset + 1];
513  }
514  regfree(&rex);
515  GNUNET_free(data);
516  if (NULL == starting_host)
517  return 0;
518  *hosts = GNUNET_malloc(sizeof(struct GNUNET_TESTBED_Host *) * count);
519  GNUNET_memcpy(*hosts,
520  &host_list[GNUNET_TESTBED_host_get_id_(starting_host)],
521  sizeof(struct GNUNET_TESTBED_Host *) * count);
522  return count;
523 }
int GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:541
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define LOG(kind,...)
Generic logging shorthand.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Opaque handle to a host running experiments managed by the testing framework.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static char buf[2048]
static char * filename
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
struct GNUNET_TESTBED_Host * GNUNET_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.
const char * username
The username to be used for SSH login.
static unsigned int size
Size of the "table".
Definition: peer.c:66
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:36
int GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:254
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_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
uint32_t data
The data value.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
Definition: strings.c:219
#define GNUNET_malloc(size)
Wrapper around malloc.
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:791
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_TESTBED_Host ** host_list
Array of available hosts.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_hosts_load_from_loadleveler()

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.

This function is only available when compiled with support for LoadLeveler and is used for running on the SuperMUC

Parameters
cfgthe configuration to use as a template while starting a controller on any of the loaded hosts. Operation queue sizes specific to a host are also read from this configuration handle
hostsset to the hosts found in the file; caller must free this if number of hosts returned is greater than 0
Returns
number of hosts returned in 'hosts', 0 on error

Definition at line 581 of file testbed_api_hosts.c.

References _, __func__, getenv(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_TESTBED_hosts_load_from_file(), and LOG.

Referenced by GNUNET_TESTBED_run(), and run().

584 {
585 #if !ENABLE_SUPERMUC
587  _("The function %s is only available when compiled with (--with-ll)\n"),
588  __func__);
589  GNUNET_assert(0);
590 #else
591  const char *hostfile;
592 
593  if (NULL == (hostfile = getenv("MP_SAVEHOSTFILE")))
594  {
595  GNUNET_break(0);
596  return 0;
597  }
598  return GNUNET_TESTBED_hosts_load_from_file(hostfile, cfg, hosts);
599 #endif
600 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define LOG(kind,...)
Generic logging shorthand.
#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
#define __func__
char * getenv()
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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_host_destroy()

void GNUNET_TESTBED_host_destroy ( struct GNUNET_TESTBED_Host host)

Destroy a host handle.

Must only be called once everything running on that host has been stopped.

Parameters
hosthandle to destroy

Definition at line 610 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::cfg, GNUNET_assert, GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, GNUNET_realloc, GNUNET_TESTBED_operation_queue_destroy_(), HOST_LIST_GROW_STEP, host_list_size, GNUNET_TESTBED_Host::hostname, GNUNET_TESTBED_Host::id, id, GNUNET_TESTBED_Host::opq_parallel_overlay_connect_operations, GNUNET_TESTBED_Host::rc_head, GNUNET_TESTBED_Host::rc_tail, and GNUNET_TESTBED_Host::username.

Referenced by cleanup(), destroy_hosts(), GNUNET_TESTBED_run(), handle_add_host(), and shutdown_task().

611 {
612  struct RegisteredController *rc;
613  uint32_t id;
614 
616  GNUNET_assert(host_list[host->id] == host);
617  host_list[host->id] = NULL;
618  /* clear registered controllers list */
619  for (rc = host->rc_head; NULL != rc; rc = host->rc_head)
620  {
621  GNUNET_CONTAINER_DLL_remove(host->rc_head, host->rc_tail, rc);
622  GNUNET_free(rc);
623  }
624  GNUNET_free_non_null((char *)host->username);
625  GNUNET_free_non_null((char *)host->hostname);
629  GNUNET_free(host);
631  {
632  for (id = host_list_size - 1; id > host_list_size - HOST_LIST_GROW_STEP;
633  id--)
634  if (NULL != host_list[id])
635  break;
636  if (id != host_list_size - HOST_LIST_GROW_STEP)
637  break;
638  if (NULL != host_list[id])
639  break;
641  }
642  host_list =
644  sizeof(struct GNUNET_TESTBED_Host *) * host_list_size);
645 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct OperationQueue * opq_parallel_overlay_connect_operations
Operation queue for simultaneous overlay connect operations target at this host.
A list entry for registered controllers list.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Opaque handle to a host running experiments managed by the testing framework.
struct RegisteredController * rc_head
The head for the list of controllers where this host is registered.
struct GNUNET_CONFIGURATION_Handle * cfg
the configuration to use as a template while starting a controller on this host.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
struct RegisteredController * rc_tail
The tail for the list of controllers where this host is registered.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
uint32_t id
Global ID we use to refer to a host on the network.
void GNUNET_TESTBED_operation_queue_destroy_(struct OperationQueue *queue)
Destroys an operation queue.
const char * username
The username to be used for SSH login.
#define HOST_LIST_GROW_STEP
Number of extra elements we create space for when we grow host list.
const char * hostname
The hostname of the host; NULL for localhost.
static unsigned int host_list_size
The size of the available hosts list.
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_TESTBED_Host ** host_list
Array of available hosts.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_is_host_habitable()

struct GNUNET_TESTBED_HostHabitableCheckHandle* GNUNET_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.

Parameters
hostthe host to check
configthe configuration handle to lookup the path of the testbed helper
cbthe callback to call to inform about habitability of the given host
cb_clsthe closure for the callback
Returns
NULL upon any error or a handle which can be passed to GNUNET_TESTBED_is_host_habitable_cancel()

Definition at line 1346 of file testbed_api_hosts.c.

References GNUNET_TESTBED_HostHabitableCheckHandle::auxp, GNUNET_TESTBED_HostHabitableCheckHandle::cb, GNUNET_TESTBED_HostHabitableCheckHandle::cb_cls, free_argv(), gen_rsh_args(), gen_rsh_suffix_args(), GNUNET_asprintf(), GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_OS_get_libexec_binary_path(), GNUNET_OS_INHERIT_STD_ERR, GNUNET_OS_start_process_vap(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, h, habitability_check(), GNUNET_TESTBED_HostHabitableCheckHandle::habitability_check_task, GNUNET_TESTBED_HostHabitableCheckHandle::helper_argv, HELPER_TESTBED_BINARY, GNUNET_TESTBED_HostHabitableCheckHandle::host, hostname, GNUNET_TESTBED_Host::hostname, join_argv(), port, GNUNET_TESTBED_Host::port, GNUNET_TESTBED_Host::username, and GNUNET_TESTBED_HostHabitableCheckHandle::wait_time.

Referenced by GNUNET_TESTBED_run().

1351 {
1353  char **rsh_args;
1354  char **rsh_suffix_args;
1355  char *stat_args[3];
1356  const char *hostname;
1357  char *port;
1358 
1360  h->cb = cb;
1361  h->cb_cls = cb_cls;
1362  h->host = host;
1363  hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
1364  if (GNUNET_OK !=
1366  "testbed",
1367  "HELPER_BINARY_PATH",
1368  &stat_args[1]))
1370  GNUNET_asprintf(&port, "%u", host->port);
1371  rsh_args = gen_rsh_args(port, hostname, host->username);
1372  GNUNET_free(port);
1373  port = NULL;
1374  stat_args[0] = "stat";
1375  stat_args[2] = NULL;
1376  rsh_suffix_args = gen_rsh_suffix_args((const char **)stat_args);
1377  GNUNET_free(stat_args[1]);
1378  h->helper_argv =
1379  join_argv((const char **)rsh_args, (const char **)rsh_suffix_args);
1380  free_argv(rsh_suffix_args);
1381  free_argv(rsh_args);
1384  NULL,
1385  NULL,
1386  NULL,
1387  h->helper_argv[0],
1388  h->helper_argv);
1389  if (NULL == h->auxp)
1390  {
1391  GNUNET_break(0); /* Cannot exec SSH? */
1392  GNUNET_free(h);
1393  return NULL;
1394  }
1398  return h;
1399 }
struct GNUNET_OS_Process * auxp
The process handle for the SSH process.
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:90
const struct GNUNET_TESTBED_Host * host
The host to check.
#define HELPER_TESTBED_BINARY
Testbed Helper binary name.
Definition: testbed_api.h:38
struct GNUNET_SCHEDULER_Task * habitability_check_task
Task id for the habitability check task.
static char ** gen_rsh_args(const char *port, const char *hostname, const char *username)
Generates arguments for opening a remote shell.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#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...
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.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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.
The handle for whether a host is habitable or not.
struct GNUNET_OS_Process * GNUNET_OS_start_process_vap(int pipe_control, enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename, char *const argv[])
Start a process.
Definition: os_priority.c:607
struct GNUNET_TIME_Relative wait_time
How long we wait before checking the process status.
uint16_t port
The port which is to be used for SSH.
static char ** join_argv(const char *const *argv1, const char *const *argv2)
Function to join NULL terminated list of arguments.
const char * username
The username to be used for SSH login.
const char * hostname
The hostname of the host; NULL for localhost.
#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 char * hostname
Our hostname; we give this to all the peers we start.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
static void habitability_check(void *cls)
Task for checking whether a host is habitable or not.
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
char ** helper_argv
The arguments used to start the helper.
#define GNUNET_free(ptr)
Wrapper around free.
static char ** gen_rsh_suffix_args(const char *const *append_args)
Generates the arguments needed for executing the given binary in a remote shell.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_is_host_habitable_cancel()

void GNUNET_TESTBED_is_host_habitable_cancel ( struct GNUNET_TESTBED_HostHabitableCheckHandle handle)

Function to cancel a request started using GNUNET_TESTBED_is_host_habitable()

Parameters
handlethe habitability check handle

Definition at line 1408 of file testbed_api_hosts.c.

References GNUNET_TESTBED_HostHabitableCheckHandle::auxp, free_argv(), GNUNET_free, GNUNET_OS_process_destroy(), GNUNET_OS_process_kill(), GNUNET_OS_process_wait(), GNUNET_SCHEDULER_cancel(), GNUNET_TERM_SIG, GNUNET_TESTBED_HostHabitableCheckHandle::habitability_check_task, and GNUNET_TESTBED_HostHabitableCheckHandle::helper_argv.

Referenced by GNUNET_TESTBED_run(), and rc_cleanup_operations().

1410 {
1413  (void)GNUNET_OS_process_wait(handle->auxp);
1415  free_argv(handle->helper_argv);
1416  GNUNET_free(handle);
1417 }
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
struct GNUNET_SCHEDULER_Task * habitability_check_task
Task id for the habitability check task.
static void free_argv(char **argv)
Frees the given NULL terminated arguments.
int GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
Definition: os_priority.c:1000
char ** helper_argv
The arguments used to start the helper.
#define GNUNET_TERM_SIG
The termination signal.
Definition: platform.h:242
#define GNUNET_free(ptr)
Wrapper around free.
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:224
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:

◆ GNUNET_TESTBED_host_get_hostname()

const char* GNUNET_TESTBED_host_get_hostname ( const struct GNUNET_TESTBED_Host host)

Obtain the host's hostname.

Parameters
hosthandle to the host, NULL means 'localhost'
Returns
hostname of the host

Definition at line 237 of file testbed_api_hosts.c.

References GNUNET_TESTBED_Host::hostname.

Referenced by GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_register_host(), helper_mst(), host_habitable_cb(), and run().

238 {
239  return host->hostname;
240 }
const char * hostname
The hostname of the host; NULL for localhost.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_controller_start()

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.

The given host's configuration is used as a Template configuration to use for the remote controller; the remote controller will be started with a slightly modified configuration (port numbers, unix domain sockets and service home values are changed as per TESTING library on the remote host). The modified configuration replaces the host's existing configuration before signalling success through the GNUNET_TESTBED_ControllerStatusCallback()

Parameters
trusted_ipthe ip address of the controller which will be set as TRUSTED HOST(all connections form this ip are permitted by the testbed) when starting testbed controller at host. This can either be a single ip address or a network address in CIDR notation.
hostthe host where the controller has to be started. CANNOT be NULL.
cbfunction called when the controller is successfully started or dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be called if cb is called with GNUNET_SYSERR as status. Will never be called in the same task as 'GNUNET_TESTBED_controller_start' (synchronous errors will be signalled by returning NULL). This parameter cannot be NULL.
clsclosure for above callbacks
Returns
the controller process handle, NULL on errors

Definition at line 1087 of file testbed_api_hosts.c.

References API_VIOLATION, GNUNET_TESTBED_ControllerProc::cb, cfg, clear_msg(), GNUNET_TESTBED_ControllerProc::cls, GNUNET_TESTBED_Host::controller_started, free_argv(), gen_rsh_args(), gen_rsh_suffix_args(), GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_free, GNUNET_HELPER_send(), GNUNET_HELPER_start(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_OS_get_libexec_binary_path(), GNUNET_strdup, GNUNET_TESTBED_controller_stop(), GNUNET_TESTBED_create_helper_init_msg_(), GNUNET_TESTBED_host_get_cfg_(), GNUNET_TESTBED_host_get_id_(), GNUNET_YES, GNUNET_TESTBED_HelperInit::header, GNUNET_TESTBED_ControllerProc::helper, GNUNET_TESTBED_ControllerProc::helper_argv, helper_exp_cb(), helper_mst(), HELPER_TESTBED_BINARY, GNUNET_TESTBED_ControllerProc::host, hostname, GNUNET_TESTBED_Host::hostname, join_argv(), GNUNET_TESTBED_Host::locked, LOG_DEBUG, msg, GNUNET_TESTBED_ControllerProc::msg, port, GNUNET_TESTBED_Host::port, GNUNET_TESTBED_ControllerProc::shandle, and GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_run(), handle_link_controllers(), and host_habitable_cb().

1091 {
1092  struct GNUNET_TESTBED_ControllerProc *cp;
1094  const struct GNUNET_CONFIGURATION_Handle *cfg;
1095  const char *hostname;
1096  static char *const binary_argv[] = { HELPER_TESTBED_BINARY, NULL };
1097 
1098  GNUNET_assert(NULL != host);
1099  GNUNET_assert(NULL != (cfg = GNUNET_TESTBED_host_get_cfg_(host)));
1100  hostname = NULL;
1101  API_VIOLATION(
1102  GNUNET_NO == host->locked,
1103  "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
1104  host->locked = GNUNET_YES;
1105  API_VIOLATION(
1106  GNUNET_NO == host->controller_started,
1107  "Attempting to start a controller on a host which is already started a controller");
1109  if (0 == GNUNET_TESTBED_host_get_id_(host))
1110  {
1113  binary_argv,
1114  &helper_mst,
1115  &helper_exp_cb,
1116  cp);
1117  }
1118  else
1119  {
1120  char *helper_binary_path_args[2];
1121  char **rsh_args;
1122  char **rsh_suffix_args;
1123  const char *username;
1124  char *port;
1125  char *argstr;
1126  char *aux;
1127  unsigned int cnt;
1128 
1129  username = host->username;
1130  hostname = host->hostname;
1131  GNUNET_asprintf(&port, "%u", host->port);
1132  LOG_DEBUG("Starting remote connection to destination %s\n", hostname);
1133  if (GNUNET_OK !=
1135  "testbed",
1136  "HELPER_BINARY_PATH",
1137  &helper_binary_path_args[0]))
1138  helper_binary_path_args[0] =
1140  helper_binary_path_args[1] = NULL;
1141  rsh_args = gen_rsh_args(port, hostname, username);
1142  rsh_suffix_args =
1143  gen_rsh_suffix_args((const char **)helper_binary_path_args);
1144  cp->helper_argv =
1145  join_argv((const char **)rsh_args, (const char **)rsh_suffix_args);
1146  free_argv(rsh_args);
1147  free_argv(rsh_suffix_args);
1148  GNUNET_free(port);
1149  argstr = GNUNET_strdup("");
1150  for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++)
1151  {
1152  aux = argstr;
1153  GNUNET_assert(
1154  0 < GNUNET_asprintf(&argstr, "%s %s", aux, cp->helper_argv[cnt]));
1155  GNUNET_free(aux);
1156  }
1157  LOG_DEBUG("Helper cmd str: %s\n", argstr);
1158  GNUNET_free(argstr);
1160  cp->helper_argv[0],
1161  cp->helper_argv,
1162  &helper_mst,
1163  &helper_exp_cb,
1164  cp);
1165  GNUNET_free(helper_binary_path_args[0]);
1166  }
1167  if (NULL == cp->helper)
1168  {
1169  if (NULL != cp->helper_argv)
1170  free_argv(cp->helper_argv);
1171  GNUNET_free(cp);
1172  return NULL;
1173  }
1174  cp->host = host;
1175  cp->cb = cb;
1176  cp->cls = cls;
1177  msg = GNUNET_TESTBED_create_helper_init_msg_(trusted_ip, hostname, cfg);
1178  cp->msg = &msg->header;
1179  cp->shandle =
1180  GNUNET_HELPER_send(cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
1181  if (NULL == cp->shandle)
1182  {
1183  GNUNET_free(msg);
1185  return NULL;
1186  }
1187  return cp;
1188 }
struct GNUNET_TESTBED_HelperInit * GNUNET_TESTBED_create_helper_init_msg_(const char *trusted_ip, const char *hostname, const struct GNUNET_CONFIGURATION_Handle *cfg)
Creates a helper initialization message.
Definition: testbed_api.c:1973
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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 * GNUNET_HELPER_start(int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls)
Starts a helper and begins reading from it.
Definition: helper.c:487
#define HELPER_TESTBED_BINARY
Testbed Helper binary name.
Definition: testbed_api.h:38
struct GNUNET_HELPER_Handle * helper
The process handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
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...
static char ** gen_rsh_args(const char *port, const char *hostname, const char *username)
Generates arguments for opening a remote shell.
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_new(type)
Allocate a struct or union of the given type.
Initialization message for gnunet-helper-testbed to start testbed service.
Handle for controller process.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static void clear_msg(void *cls, int result)
Continuation function from GNUNET_HELPER_send()
static void free_argv(char **argv)
Frees the given NULL terminated arguments.
static void helper_exp_cb(void *cls)
Callback that will be called when the helper process dies.
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
const struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_host_get_cfg_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s configuration template.
uint16_t port
The port which is to be used for SSH.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define LOG_DEBUG(...)
Debug logging shorthand.
static char ** join_argv(const char *const *argv1, const char *const *argv2)
Function to join NULL terminated list of arguments.
const char * username
The username to be used for SSH login.
GNUNET_TESTBED_ControllerStatusCallback cb
The controller error callback.
#define API_VIOLATION(cond, errstr)
Prints API violation message.
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.
struct GNUNET_TESTBED_Host * host
The host where the helper is run.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
configuration data
Definition: configuration.c:83
void * cls
The closure for the above callback.
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, int can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
Definition: helper.c:653
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
#define GNUNET_YES
Definition: gnunet_common.h:77
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...
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MessageHeader * msg
The message corresponding to send handle.
static char ** gen_rsh_suffix_args(const char *const *append_args)
Generates the arguments needed for executing the given binary in a remote shell.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_controller_stop()

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

This function blocks until the testbed has been fully terminated (!). The controller status cb from GNUNET_TESTBED_controller_start() will not be called.

Parameters
cprocthe controller process handle

Definition at line 1237 of file testbed_api_hosts.c.

References GNUNET_TESTBED_controller_destroy_(), and GNUNET_TESTBED_controller_kill_().

Referenced by cleanup(), do_shutdown(), GNUNET_TESTBED_controller_start(), and helper_exp_cb().

1238 {
1241 }
void GNUNET_TESTBED_controller_kill_(struct GNUNET_TESTBED_ControllerProc *cproc)
Sends termination signal to the controller&#39;s helper process.
void GNUNET_TESTBED_controller_destroy_(struct GNUNET_TESTBED_ControllerProc *cproc)
Cleans-up the controller&#39;s helper process handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_controller_connect()

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.

The configuration to use for the connection is retrieved from the given host where a controller is started using GNUNET_TESTBED_controller_start().

Parameters
hosthost to run the controller on; This should be the same host if the controller was previously started with GNUNET_TESTBED_controller_start()
event_maskbit mask with set of events to call 'cc' for; or-ed values of "1LL" shifted by the respective 'enum GNUNET_TESTBED_EventType' (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
cccontroller callback to invoke on events
cc_clsclosure for cc
Returns
handle to the controller

Connect to a controller process.

Parameters
hosthost to run the controller on; This should be the same host if the controller was previously started with GNUNET_TESTBED_controller_start()
event_maskbit mask with set of events to call 'cc' for; or-ed values of "1LL" shifted by the respective 'enum GNUNET_TESTBED_EventType' (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
cccontroller callback to invoke on events
cc_clsclosure for cc
Returns
handle to the controller

Definition at line 1547 of file testbed_api.c.

References ForwardedOperationData::cc, GNUNET_TESTBED_Controller::cc, ForwardedOperationData::cc_cls, GNUNET_TESTBED_Controller::cc_cls, cfg, GNUNET_TESTBED_Controller::cfg, env, GNUNET_TESTBED_InitMessage::event_mask, event_mask, GNUNET_TESTBED_Controller::event_mask, GNUNET_assert, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_free, GNUNET_htonll(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS, GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS, GNUNET_MESSAGE_TYPE_TESTBED_INIT, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT, GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT, GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT, GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT, GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_TESTBED_controller_disconnect(), GNUNET_TESTBED_host_get_cfg_(), GNUNET_TESTBED_host_get_hostname(), GNUNET_TESTBED_host_get_id_(), GNUNET_TESTBED_mark_host_registered_at_(), GNUNET_TESTBED_operation_queue_create_(), GNUNET_TESTBED_Controller::host, GNUNET_TESTBED_InitMessage::host_id, GNUNET_TESTBED_Controller::mq, mq_error_handler(), msg, OPERATION_QUEUE_TYPE_FIXED, GNUNET_TESTBED_Controller::opq_parallel_operations, GNUNET_TESTBED_Controller::opq_parallel_service_connections, and GNUNET_TESTBED_Controller::opq_parallel_topology_config_operations.

Referenced by controller_status_cb(), opstart_neighbour_conn(), and slave_status_cb().

1551 {
1552  struct GNUNET_TESTBED_Controller *controller =
1555  { GNUNET_MQ_hd_var_size(add_host_confirm,
1558  controller),
1559  GNUNET_MQ_hd_fixed_size(peer_conevent,
1562  controller),
1563  GNUNET_MQ_hd_fixed_size(opsuccess,
1565  struct
1567  controller),
1568  GNUNET_MQ_hd_var_size(op_fail_event,
1571  controller),
1572  GNUNET_MQ_hd_fixed_size(peer_create_success,
1574  struct
1576  controller),
1577  GNUNET_MQ_hd_fixed_size(peer_event,
1580  controller),
1581  GNUNET_MQ_hd_var_size(peer_config,
1583  struct
1585  controller),
1586  GNUNET_MQ_hd_var_size(slave_config,
1589  controller),
1590  GNUNET_MQ_hd_var_size(link_controllers_result,
1593  controller),
1594  GNUNET_MQ_hd_var_size(barrier_status,
1597  controller),
1600  struct GNUNET_MQ_Envelope *env;
1601  const struct GNUNET_CONFIGURATION_Handle *cfg;
1602  const char *controller_hostname;
1603  unsigned long long max_parallel_operations;
1604  unsigned long long max_parallel_service_connections;
1605  unsigned long long max_parallel_topology_config_operations;
1606  size_t slen;
1607 
1608  GNUNET_assert(NULL != (cfg = GNUNET_TESTBED_host_get_cfg_(host)));
1609  if (GNUNET_OK !=
1611  "testbed",
1612  "MAX_PARALLEL_OPERATIONS",
1613  &max_parallel_operations))
1614  {
1615  GNUNET_break(0);
1616  GNUNET_free(controller);
1617  return NULL;
1618  }
1619  if (GNUNET_OK !=
1621  "testbed",
1622  "MAX_PARALLEL_SERVICE_CONNECTIONS",
1623  &max_parallel_service_connections))
1624  {
1625  GNUNET_break(0);
1626  GNUNET_free(controller);
1627  return NULL;
1628  }
1630  cfg,
1631  "testbed",
1632  "MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS",
1633  &max_parallel_topology_config_operations))
1634  {
1635  GNUNET_break(0);
1636  GNUNET_free(controller);
1637  return NULL;
1638  }
1639  controller->cc = cc;
1640  controller->cc_cls = cc_cls;
1641  controller->event_mask = event_mask;
1642  controller->cfg = GNUNET_CONFIGURATION_dup(cfg);
1643  controller->mq = GNUNET_CLIENT_connect(controller->cfg,
1644  "testbed",
1645  handlers,
1647  controller);
1648  if (NULL == controller->mq)
1649  {
1650  GNUNET_break(0);
1652  return NULL;
1653  }
1654  GNUNET_TESTBED_mark_host_registered_at_(host, controller);
1655  controller->host = host;
1656  controller->opq_parallel_operations =
1658  (unsigned int)
1659  max_parallel_operations);
1660  controller->opq_parallel_service_connections =
1662  (unsigned int)
1663  max_parallel_service_connections);
1667  (unsigned int)max_parallel_topology_config_operations);
1668  controller_hostname = GNUNET_TESTBED_host_get_hostname(host);
1669  if (NULL == controller_hostname)
1670  controller_hostname = "127.0.0.1";
1671  slen = strlen(controller_hostname) + 1;
1673  msg->host_id = htonl(GNUNET_TESTBED_host_get_id_(host));
1674  msg->event_mask = GNUNET_htonll(controller->event_mask);
1675  GNUNET_memcpy(&msg[1], controller_hostname, slen);
1676  GNUNET_MQ_send(controller->mq, env);
1677  return controller;
1678 }
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS
Message for signalling status of a barrier.
Event notification from a controller to a client.
Definition: testbed.h:517
#define GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION
Message which contains the configuration of slave controller.
Confirmation from the service that adding a host worked (or failed).
Definition: testbed.h:112
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
Message to signal successful peer creation.
Event notification from a controller to a client.
Definition: testbed.h:461
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
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT
Message for peer connect events.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:191
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.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:900
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration to use while connecting to controller.
Definition: testbed_api.h:210
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:584
Event notification from a controller to a client.
Definition: testbed.h:429
Operation queue which permits a fixed maximum number of operations to be active at any time...
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS
Message to signal that a add host succeeded.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Event notification from a controller to a client.
Definition: testbed.h:493
Initial message from a client to a testing control service.
Definition: testbed.h:36
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: testbed_api.c:1521
struct OperationQueue * GNUNET_TESTBED_operation_queue_create_(enum OperationQueueType type, unsigned int max_active)
Create an operation queue.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Response message for ControllerLinkRequest message.
Definition: testbed.h:165
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT
Message to signal the result of GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS request.
#define GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
Message for operation events.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:262
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
Message for peer events.
struct OperationQueue * opq_parallel_service_connections
Operation queue for simultaneous service connections.
Definition: testbed_api.h:246
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer&#39;s information.
const struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_host_get_cfg_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s configuration template.
Message handler for a specific message type.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
uint64_t event_mask
Global event mask for all testbed events.
struct OperationQueue * opq_parallel_topology_config_operations
Operation queue for simultaneous topology configuration operations.
Definition: testbed_api.h:251
Reply to GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION message.
Definition: testbed.h:638
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint32_t host_id
Host ID that the controller is either given (if this is the dominating client) or assumed to have (fo...
Definition: testbed.h:48
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
const char * GNUNET_TESTBED_host_get_hostname(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s hostname.
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
configuration data
Definition: configuration.c:83
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:215
#define GNUNET_MESSAGE_TYPE_TESTBED_INIT
Initial message from a client to a testing control service.
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:205
struct GNUNET_TESTBED_Host * host
The host where the controller is running.
Definition: testbed_api.h:195
uint64_t event_mask
Event mask that specifies which events this client is interested in.
Definition: testbed.h:54
Event notification from a controller to a client for a generic operational success where the operatio...
Definition: testbed.h:540
Message for signalling status changes of a barrier.
Definition: testbed.h:794
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:200
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_controller_disconnect()

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

This function blocks until the testbed has been fully terminated (!).

Parameters
chandle to controller to stop

Definition at line 1713 of file testbed_api.c.

References GNUNET_TESTBED_Controller::cfg, GNUNET_assert, GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_CONTAINER_multihashmap32_size(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_TESTBED_deregister_host_at_(), GNUNET_TESTBED_operation_queue_destroy_(), GNUNET_TESTBED_Controller::host, GNUNET_TESTBED_Controller::mq, opc_free_iterator(), GNUNET_TESTBED_Controller::opc_map, GNUNET_TESTBED_Controller::opq_parallel_operations, GNUNET_TESTBED_Controller::opq_parallel_service_connections, and GNUNET_TESTBED_Controller::opq_parallel_topology_config_operations.

Referenced by cleanup(), do_shutdown(), GNUNET_TESTBED_controller_connect(), kill_slave(), and oprelease_neighbour_conn().

1714 {
1715  if (NULL != c->mq)
1716  {
1717  GNUNET_MQ_destroy(c->mq);
1718  c->mq = NULL;
1719  }
1720  if (NULL != c->host)
1727  if (NULL != c->opc_map)
1728  {
1732  c->opc_map));
1735  }
1736  GNUNET_free(c);
1737 }
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration to use while connecting to controller.
Definition: testbed_api.h:210
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
static int opc_free_iterator(void *cls, uint32_t key, void *value)
Iterator to free opc map entries.
Definition: testbed_api.c:1691
struct OperationQueue * opq_parallel_service_connections
Operation queue for simultaneous service connections.
Definition: testbed_api.h:246
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.
struct GNUNET_CONTAINER_MultiHashMap32 * opc_map
The map of active operation contexts.
Definition: testbed_api.h:226
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
void GNUNET_TESTBED_operation_queue_destroy_(struct OperationQueue *queue)
Destroys an operation queue.
struct OperationQueue * opq_parallel_topology_config_operations
Operation queue for simultaneous topology configuration operations.
Definition: testbed_api.h:251
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:215
struct GNUNET_TESTBED_Host * host
The host where the controller is running.
Definition: testbed_api.h:195
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
#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_register_host()

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.

This makes the controller aware of the host. A host should be registered at the controller before starting a sub-controller on that host using GNUNET_TESTBED_controller_link().

Parameters
controllerthe controller handle
hostthe host to register
ccthe completion callback to call to inform the status of registration. After calling this callback the registration handle will be invalid. Cannot be NULL
cc_clsthe closure for the cc
Returns
handle to the host registration which can be used to cancel the registration; NULL if another registration handle is present and is not cancelled
Parameters
controllerthe controller handle
hostthe host to register
ccthe completion callback to call to inform the status of registration. After calling this callback the registration handle will be invalid. Cannot be NULL.
cc_clsthe closure for the cc
Returns
handle to the host registration which can be used to cancel the registration

Definition at line 1433 of file testbed_api_hosts.c.

References GNUNET_TESTBED_HostRegistrationHandle::c, GNUNET_TESTBED_HostRegistrationHandle::cc, GNUNET_TESTBED_HostRegistrationHandle::cc_cls, GNUNET_TESTBED_Host::cfg, config, GNUNET_TESTBED_AddHostMessage::config_size, RegisteredController::controller, GNUNET_assert, GNUNET_CONFIGURATION_serialize(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, GNUNET_new, GNUNET_TESTBED_compress_config_(), GNUNET_TESTBED_host_get_hostname(), GNUNET_TESTBED_host_get_id_(), GNUNET_TESTBED_host_get_ssh_port_(), GNUNET_TESTBED_host_get_username_(), GNUNET_TESTBED_is_host_registered_(), GNUNET_TESTBED_queue_message_(), GNUNET_YES, GNUNET_TESTBED_AddHostMessage::header, GNUNET_TESTBED_HostRegistrationHandle::host, GNUNET_TESTBED_AddHostMessage::host_id, hostname, GNUNET_TESTBED_AddHostMessage::hostname_length, LOG, msg, GNUNET_TESTBED_Controller::rh, GNUNET_MessageHeader::size, GNUNET_TESTBED_AddHostMessage::ssh_port, GNUNET_MessageHeader::type, and GNUNET_TESTBED_AddHostMessage::username_length.

Referenced by register_hosts(), and register_next_host().

1437 {
1440  const char *username;
1441  const char *hostname;
1442  char *config;
1443  char *cconfig;
1444  void *ptr;
1445  size_t cc_size;
1446  size_t config_size;
1447  uint16_t msg_size;
1448  uint16_t username_length;
1449  uint16_t hostname_length;
1450 
1451  if (NULL != controller->rh)
1452  return NULL;
1453  hostname = GNUNET_TESTBED_host_get_hostname(host);
1454  if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_(host, controller))
1455  {
1457  "Host hostname: %s already registered\n",
1458  (NULL == hostname) ? "localhost" : hostname);
1459  return NULL;
1460  }
1462  rh->host = host;
1463  rh->c = controller;
1464  GNUNET_assert(NULL != cc);
1465  rh->cc = cc;
1466  rh->cc_cls = cc_cls;
1467  controller->rh = rh;
1468  username = GNUNET_TESTBED_host_get_username_(host);
1469  username_length = 0;
1470  if (NULL != username)
1471  username_length = strlen(username);
1472  GNUNET_assert(NULL != hostname); /* Hostname must be present */
1473  hostname_length = strlen(hostname);
1474  GNUNET_assert(NULL != host->cfg);
1475  config = GNUNET_CONFIGURATION_serialize(host->cfg, &config_size);
1476  cc_size = GNUNET_TESTBED_compress_config_(config, config_size, &cconfig);
1477  GNUNET_free(config);
1478  msg_size = (sizeof(struct GNUNET_TESTBED_AddHostMessage));
1479  msg_size += username_length;
1480  msg_size += hostname_length;
1481  msg_size += cc_size;
1482  msg = GNUNET_malloc(msg_size);
1483  msg->header.size = htons(msg_size);
1485  msg->host_id = htonl(GNUNET_TESTBED_host_get_id_(host));
1486  msg->ssh_port = htons(GNUNET_TESTBED_host_get_ssh_port_(host));
1487  ptr = &msg[1];
1488  if (NULL != username)
1489  {
1490  msg->username_length = htons(username_length);
1491  GNUNET_memcpy(ptr, username, username_length);
1492  ptr += username_length;
1493  }
1494  msg->hostname_length = htons(hostname_length);
1495  GNUNET_memcpy(ptr, hostname, hostname_length);
1496  ptr += hostname_length;
1497  msg->config_size = htons(config_size);
1498  GNUNET_memcpy(ptr, cconfig, cc_size);
1499  ptr += cc_size;
1500  GNUNET_assert((ptr - (void *)msg) == msg_size);
1501  GNUNET_free(cconfig);
1502  GNUNET_TESTBED_queue_message_(controller,
1503  (struct GNUNET_MessageHeader *)msg);
1504  return rh;
1505 }
uint16_t username_length
Number of bytes in the user name that follows; 0 to use no user name; otherwise &#39;strlen (username)&#39;...
Definition: testbed.h:84
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Host * host
The host being registered.
struct GNUNET_TESTBED_HostRegistrationHandle * rh
The host registration handle; NULL if no current registration requests are present.
Definition: testbed_api.h:221
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Notify the service about a host that we intend to use.
Definition: testbed.h:63
uint16_t config_size
The length of the uncompressed configuration.
Definition: testbed.h:95
uint16_t hostname_length
Number of bytes in the host name (excluding 0-termination) that follows the user name; cannot be 0...
Definition: testbed.h:90
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define LOG(kind,...)
Generic logging shorthand.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void * cc_cls
The closure for above callback.
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.
const char * GNUNET_TESTBED_host_get_username_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s username.
static const struct GNUNET_CONFIGURATION_Handle * config
#define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST
Message to add host.
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
uint32_t host_id
Unique ID for the host (in NBO).
Definition: testbed.h:72
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.
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1328
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST.
Definition: testbed.h:67
struct GNUNET_TESTBED_Controller * c
The controller at which this host is being registered.
GNUNET_TESTBED_HostRegistrationCompletion cc
The Registartion completion callback.
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1750
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
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.
handle for host registration
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:77
uint16_t GNUNET_TESTBED_host_get_ssh_port_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s ssh port.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint16_t ssh_port
SSH port to use, 0 for default (in NBO).
Definition: testbed.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:

◆ GNUNET_TESTBED_cancel_registration()

void GNUNET_TESTBED_cancel_registration ( struct GNUNET_TESTBED_HostRegistrationHandle handle)

Cancel the pending registration.

Note that the registration message will already be queued to be sent to the service, cancellation has only the effect that the registration completion callback for the registration is never called and from our perspective the host is not registered until the completion callback is called.

Parameters
handlethe registration handle to cancel

Note that if the registration message is already sent to the service the cancellation has only the effect that the registration completion callback for the registration is never called.

Parameters
handlethe registration handle to cancel

Definition at line 1516 of file testbed_api_hosts.c.

References GNUNET_TESTBED_HostRegistrationHandle::c, GNUNET_break, GNUNET_free, and GNUNET_TESTBED_Controller::rh.

Referenced by do_shutdown(), kill_slave(), and rc_cleanup_operations().

1518 {
1519  if (handle != handle->c->rh)
1520  {
1521  GNUNET_break(0);
1522  return;
1523  }
1524  handle->c->rh = NULL;
1525  GNUNET_free(handle);
1526 }
struct GNUNET_TESTBED_HostRegistrationHandle * rh
The host registration handle; NULL if no current registration requests are present.
Definition: testbed_api.h:221
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_TESTBED_Controller * c
The controller at which this host is being registered.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_controller_link()

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.

Whenever the master controller is asked to start a peer at the delegated controller the request will be routed towards slave controller (if a route exists). The slave controller will then route it to the delegated controller. The configuration of the delegated controller is given and is used to either create the delegated controller or to connect to an existing controller. Note that while starting the delegated controller the configuration will be modified to accommodate available free ports. the 'is_subordinate' specifies if the given delegated controller should be started and managed by the slave controller, or if the delegated controller already has a master and the slave controller connects to it as a non master controller. The success or failure of this operation will be signalled through the GNUNET_TESTBED_ControllerCallback() with an event of type GNUNET_TESTBED_ET_OPERATION_FINISHED

Parameters
op_clsthe operation closure for the event which is generated to signal success or failure of this operation
masterhandle to the master controller who creates the association
delegated_hostrequests to which host should be delegated; cannot be NULL
slave_hostwhich host is used to run the slave controller; use NULL to make the master controller connect to the delegated host
is_subordinateGNUNET_YES if the controller at delegated_host should be started by the slave controller; GNUNET_NO if the slave controller has to connect to the already started delegated controller via TCP/IP
Returns
the operation handle

Whenever the master controller is asked to start a peer at the delegated controller the request will be routed towards slave controller (if a route exists). The slave controller will then route it to the delegated controller. The configuration of the delegated controller is given and is used to either create the delegated controller or to connect to an existing controller. Note that while starting the delegated controller the configuration will be modified to accommodate available free ports. the 'is_subordinate' specifies if the given delegated controller should be started and managed by the slave controller, or if the delegated controller already has a master and the slave controller connects to it as a non master controller. The success or failure of this operation will be signalled through the GNUNET_TESTBED_ControllerCallback() with an event of type GNUNET_TESTBED_ET_OPERATION_FINISHED

Parameters
op_clsthe operation closure for the event which is generated to signal success or failure of this operation
masterhandle to the master controller who creates the association
delegated_hostrequests to which host should be delegated; cannot be NULL
slave_hostwhich host is used to run the slave controller; use NULL to make the master controller connect to the delegated host
is_subordinateGNUNET_YES if the controller at delegated_host should be started by the slave controller; GNUNET_NO if the slave controller has to connect to the already started delegated controller via TCP/IP
Returns
the operation handle

Definition at line 1824 of file testbed_api.c.

References OperationContext::c, data, OperationContext::data, GNUNET_TESTBED_ControllerLinkRequest::delegated_host_id, GNUNET_assert, GNUNET_htonll(), GNUNET_malloc, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS, GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_host_get_id_(), GNUNET_TESTBED_is_host_registered_(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), GNUNET_YES, GNUNET_TESTBED_ControllerLinkRequest::header, GNUNET_TESTBED_Controller::host, ControllerLinkData::host_id, OperationContext::id, GNUNET_TESTBED_ControllerLinkRequest::is_subordinate, msg, ControllerLinkData::msg, OperationContext::op, OperationContext::op_cls, OP_LINK_CONTROLLERS, OPC_STATE_INIT, GNUNET_TESTBED_ControllerLinkRequest::operation_id, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_link_controllers(), opstart_link_controllers(), GNUNET_MessageHeader::size, GNUNET_TESTBED_ControllerLinkRequest::slave_host_id, OperationContext::state, OperationContext::type, and GNUNET_MessageHeader::type.

Referenced by lcf_proc_task(), and register_hosts().

1829 {
1830  struct OperationContext *opc;
1832  struct ControllerLinkData *data;
1833  uint32_t slave_host_id;
1834  uint32_t delegated_host_id;
1835  uint16_t msg_size;
1836 
1838  GNUNET_TESTBED_is_host_registered_(delegated_host, master));
1839  slave_host_id = GNUNET_TESTBED_host_get_id_(
1840  (NULL != slave_host) ? slave_host : master->host);
1841  delegated_host_id = GNUNET_TESTBED_host_get_id_(delegated_host);
1842  if ((NULL != slave_host) && (0 != slave_host_id))
1844  GNUNET_TESTBED_is_host_registered_(slave_host, master));
1845  msg_size = sizeof(struct GNUNET_TESTBED_ControllerLinkRequest);
1846  msg = GNUNET_malloc(msg_size);
1848  msg->header.size = htons(msg_size);
1849  msg->delegated_host_id = htonl(delegated_host_id);
1850  msg->slave_host_id = htonl(slave_host_id);
1851  msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
1852  data = GNUNET_new(struct ControllerLinkData);
1853  data->msg = msg;
1854  data->host_id = delegated_host_id;
1855  opc = GNUNET_new(struct OperationContext);
1856  opc->c = master;
1857  opc->data = data;
1858  opc->type = OP_LINK_CONTROLLERS;
1859  opc->id = GNUNET_TESTBED_get_next_op_id(opc->c);
1860  opc->state = OPC_STATE_INIT;
1861  opc->op_cls = op_cls;
1862  msg->operation_id = GNUNET_htonll(opc->id);
1867  opc->op);
1869  return opc->op;
1870 }
#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS
Message to link delegated controller to slave controller.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
void * op_cls
The operation closure.
Definition: testbed_api.h:149
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
static void oprelease_link_controllers(void *cls)
Callback which will be called when link-controllers type operation is released.
Definition: testbed_api.c:1436
uint32_t delegated_host_id
For which host should requests be delegated? NBO.
Definition: testbed.h:142
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint32_t host_id
The id of the host which is hosting the controller to be linked.
Definition: testbed_api.c:106
Link controllers operation.
Definition: testbed_api.h:88
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
static void opstart_link_controllers(void *cls)
Function to call to start a link-controllers type operation once all queues the operation is part of ...
Definition: testbed_api.c:1414
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:169
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
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.
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:116
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
uint32_t slave_host_id
Which host is responsible for managing the delegation? NBO.
Definition: testbed.h:152
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
uint8_t is_subordinate
Set to 1 if the receiving controller is the master controller for the slave host (and thus responsibl...
Definition: testbed.h:158
struct GNUNET_TESTBED_Host * host
The host where the controller is running.
Definition: testbed_api.h:195
Context data for controller link operations.
Definition: testbed_api.c:97
uint64_t operation_id
The id of the operation which created this message.
Definition: testbed.h:147
#define GNUNET_YES
Definition: gnunet_common.h:77
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS.
Definition: testbed.h:137
#define GNUNET_malloc(size)
Wrapper around malloc.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Client notifies controller that it should delegate requests for a particular client to a particular s...
Definition: testbed.h:133
struct GNUNET_TESTBED_ControllerLinkRequest * msg
The controller link message.
Definition: testbed_api.c:101
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_get_slave_config()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_get_slave_config ( void *  op_cls,
struct GNUNET_TESTBED_Controller master,
struct GNUNET_TESTBED_Host slave_host 
)

Function to acquire the configuration of a running slave controller.

The completion of the operation is signalled through the controller_cb from GNUNET_TESTBED_controller_connect(). If the operation is successful the handle to the configuration is available in the generic pointer of operation_finished field of struct GNUNET_TESTBED_EventInformation.

Parameters
op_clsthe closure for the operation
masterthe handle to master controller
slave_hostthe host where the slave controller is running; the handle to the slave_host should remain valid until this operation is cancelled or marked as finished
Returns
the operation handle; NULL if the slave_host is not registered at master

The completion of the operation is signalled through the controller_cb from GNUNET_TESTBED_controller_connect(). If the operation is successful the handle to the configuration is available in the generic pointer of operation_finished field of struct GNUNET_TESTBED_EventInformation.

Parameters
op_clsthe closure for the operation
masterthe handle to master controller
slave_hostthe host where the slave controller is running; the handle to the slave_host should remain valid until this operation is cancelled or marked as finished
Returns
the operation handle; NULL if the slave_host is not registered at master

Definition at line 1928 of file testbed_api.c.

References GNUNET_NO, GNUNET_TESTBED_get_slave_config_(), GNUNET_TESTBED_host_get_id_(), and GNUNET_TESTBED_is_host_registered_().

1931 {
1932  if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_(slave_host, master))
1933  return NULL;
1934  return GNUNET_TESTBED_get_slave_config_(op_cls,
1935  master,
1937  slave_host));
1938 }
#define GNUNET_NO
Definition: gnunet_common.h:78
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
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.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_get_slave_config_(void *op_cls, struct GNUNET_TESTBED_Controller *master, uint32_t slave_host_id)
Like GNUNET_TESTBED_get_slave_config(), however without the host registration check.
Definition: testbed_api.c:1886
Here is the call graph for this function:

◆ GNUNET_TESTBED_peer_create()

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.

If the given controller is not running on the target host, it should find or create a controller at the target host and delegate creating the peer. Explicit delegation paths can be setup using 'GNUNET_TESTBED_controller_link'. If no explicit delegation path exists, a direct link with a subordinate controller is setup for the first delegated peer to a particular host; the subordinate controller is then destroyed once the last peer that was delegated to the remote host is stopped.

Creating the peer only creates the handle to manipulate and further configure the peer; use GNUNET_TESTBED_peer_start and GNUNET_TESTBED_peer_stop to actually start/stop the peer's processes.

Note that the given configuration will be adjusted by the controller to avoid port/path conflicts with other peers. The "final" configuration can be obtained using GNUNET_TESTBED_peer_get_information.

Parameters
controllercontroller process to use
hosthost to run the peer on; cannot be NULL
cfgTemplate configuration to use for the peer. Should exist until operation is cancelled or GNUNET_TESTBED_operation_done() is called
cbthe callback to call when the peer has been created
clsthe closure to the above callback
Returns
the operation handle

If the given controller is not running on the target host, it should find or create a controller at the target host and delegate creating the peer. Explicit delegation paths can be setup using 'GNUNET_TESTBED_controller_link'. If no explicit delegation path exists, a direct link with a subordinate controller is setup for the first delegated peer to a particular host; the subordinate controller is then destroyed once the last peer that was delegated to the remote host is stopped.

Creating the peer only creates the handle to manipulate and further configure the peer; use "GNUNET_TESTBED_peer_start" and "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's processes.

Note that the given configuration will be adjusted by the controller to avoid port/path conflicts with other peers. The "final" configuration can be obtained using 'GNUNET_TESTBED_peer_get_information'.

Parameters
controllercontroller process to use
hosthost to run the peer on; cannot be NULL
cfgTemplate configuration to use for the peer. Should exist until operation is cancelled or GNUNET_TESTBED_operation_done() is called
cbthe callback to call when the peer has been created
clsthe closure to the above callback
Returns
the operation handle

Definition at line 591 of file testbed_api_peers.c.

References OperationContext::c, PeerCreateData::cb, cfg, PeerCreateData::cfg, PeerCreateData::cls, GNUNET_TESTBED_Peer::controller, data, OperationContext::data, GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), GNUNET_TESTBED_Peer::host, PeerCreateData::host, OperationContext::id, OperationContext::op, OP_PEER_CREATE, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_peer_create(), opstart_peer_create(), peer, PeerCreateData::peer, GNUNET_TESTBED_Peer::state, TESTBED_PS_INVALID, OperationContext::type, and GNUNET_TESTBED_Peer::unique_id.

Referenced by create_peers().

595 {
596  struct GNUNET_TESTBED_Peer *peer;
597  struct PeerCreateData *data;
598  struct OperationContext *opc;
599  static uint32_t id_gen;
600 
601  peer = GNUNET_new(struct GNUNET_TESTBED_Peer);
602  peer->controller = controller;
603  peer->host = host;
604  peer->unique_id = id_gen++;
605  peer->state = TESTBED_PS_INVALID;
606  data = GNUNET_new(struct PeerCreateData);
607  data->host = host;
608  data->cfg = cfg;
609  data->cb = cb;
610  data->cls = cls;
611  data->peer = peer;
612  opc = GNUNET_new(struct OperationContext);
613  opc->c = controller;
614  opc->data = data;
615  opc->id = GNUNET_TESTBED_get_next_op_id(controller);
616  opc->type = OP_PEER_CREATE;
617  opc->op =
621  opc->op);
623  return opc->op;
624 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
void * cls
The closure for the above callback.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
GNUNET_TESTBED_PeerCreateCallback cb
The call back to call when we receive peer create success message.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
const struct GNUNET_CONFIGURATION_Handle * cfg
The template configuration of the peer.
enum PeerState state
Peer&#39;s state.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
struct GNUNET_TESTBED_Host * host
Which host does this peer run on?
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
uint32_t unique_id
Globally unique ID of the peer.
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
Peer create operation.
Definition: testbed_api.h:48
struct GNUNET_TESTBED_Peer * peer
The peer structure to return when we get success message.
static void oprelease_peer_create(void *cls)
Callback which will be called when peer_create type operation is released.
State to signify that this peer is invalid.
static void opstart_peer_create(void *cls)
Function to call to start a peer_create type operation once all queues the operation is part of decla...
A peer controlled by the testing framework.
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Data for the OperationType OP_PEER_CREATE.
struct GNUNET_TESTBED_Host * host
The host where the peer has to be created.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_peer_start()

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.

Parameters
op_clsthe closure for this operation; will be set in the event information
peerpeer to start
pccfunction to call upon completion
pcc_clsclosure for 'pcc'
Returns
handle to the operation
Parameters
op_clsthe closure for this operation; will be set in event->details.operation_finished.op_cls when this operation fails.
peerpeer to start
pccfunction to call upon completion
pcc_clsclosure for 'pcc'
Returns
handle to the operation

Definition at line 638 of file testbed_api_peers.c.

References OperationContext::c, GNUNET_TESTBED_Peer::controller, data, OperationContext::data, GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), OperationContext::id, OperationContext::op, OperationContext::op_cls, OP_PEER_START, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_peer_start(), opstart_peer_start(), PeerEventData::pcc, PeerEventData::pcc_cls, peer, PeerEventData::peer, and OperationContext::type.

Referenced by start_peers_task().

640 {
641  struct OperationContext *opc;
642  struct PeerEventData *data;
643 
644  data = GNUNET_new(struct PeerEventData);
645  data->peer = peer;
646  data->pcc = pcc;
647  data->pcc_cls = pcc_cls;
648  opc = GNUNET_new(struct OperationContext);
649  opc->c = peer->controller;
650  opc->data = data;
651  opc->op_cls = op_cls;
652  opc->id = GNUNET_TESTBED_get_next_op_id(opc->c);
653  opc->type = OP_PEER_START;
654  opc->op =
658  opc->op);
660  return opc->op;
661 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
static void oprelease_peer_start(void *cls)
Callback which will be called when peer start type operation is released.
void * op_cls
The operation closure.
Definition: testbed_api.h:149
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
struct GNUNET_TESTBED_Peer * peer
The handle of the peer to start.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
Data for OperationType OP_PEER_START and OP_PEER_STOP.
GNUNET_TESTBED_PeerChurnCallback pcc
The Peer churn callback to call when this operation is completed.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
void * pcc_cls
Closure for the above callback.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
Peer start operation.
Definition: testbed_api.h:53
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
static void opstart_peer_start(void *cls)
Function called when a peer start operation is ready.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_peer_stop()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_peer_stop ( void *  op_cls,
struct GNUNET_TESTBED_Peer peer,
GNUNET_TESTBED_PeerChurnCallback  pcc,
void *  pcc_cls 
)

Stop the given peer.

The handle remains valid (use GNUNET_TESTBED_peer_destroy to fully clean up the state of the peer).

Parameters
op_clsthe closure for this operation; will be set in the event information
peerpeer to stop
pccfunction to call upon completion
pcc_clsclosure for 'pcc'
Returns
handle to the operation

The handle remains valid (use "GNUNET_TESTBED_peer_destroy" to fully clean up the state of the peer).

Parameters
op_clsthe closure for this operation; will be set in the event information
peerpeer to stop
pccfunction to call upon completion
pcc_clsclosure for 'pcc'
Returns
handle to the operation

Definition at line 677 of file testbed_api_peers.c.

References OperationContext::c, GNUNET_TESTBED_Peer::controller, data, OperationContext::data, GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), OperationContext::id, OperationContext::op, OperationContext::op_cls, OP_PEER_STOP, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_peer_stop(), opstart_peer_stop(), PeerEventData::pcc, PeerEventData::pcc_cls, peer, PeerEventData::peer, and OperationContext::type.

680 {
681  struct OperationContext *opc;
682  struct PeerEventData *data;
683 
684  data = GNUNET_new(struct PeerEventData);
685  data->peer = peer;
686  data->pcc = pcc;
687  data->pcc_cls = pcc_cls;
688  opc = GNUNET_new(struct OperationContext);
689  opc->c = peer->controller;
690  opc->data = data;
691  opc->op_cls = op_cls;
692  opc->id = GNUNET_TESTBED_get_next_op_id(opc->c);
693  opc->type = OP_PEER_STOP;
694  opc->op =
698  opc->op);
700  return opc->op;
701 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
static void oprelease_peer_stop(void *cls)
Callback which will be called when peer stop type operation is released.
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
void * op_cls
The operation closure.
Definition: testbed_api.h:149
static void opstart_peer_stop(void *cls)
Function called when a peer stop operation is ready.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
struct GNUNET_TESTBED_Peer * peer
The handle of the peer to start.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
Data for OperationType OP_PEER_START and OP_PEER_STOP.
GNUNET_TESTBED_PeerChurnCallback pcc
The Peer churn callback to call when this operation is completed.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
void * pcc_cls
Closure for the above callback.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Peer stop operation.
Definition: testbed_api.h:58
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Here is the call graph for this function:

◆ GNUNET_TESTBED_peer_get_information()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_peer_get_information ( struct GNUNET_TESTBED_Peer peer,
enum GNUNET_TESTBED_PeerInformationType  pit,
GNUNET_TESTBED_PeerInfoCallback  cb,
void *  cb_cls 
)

Request information about a peer.

The controller callback will not be called with event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this operation is available. Instead, the GNUNET_TESTBED_PeerInfoCallback() will be called. The peer information in the callback is valid until the operation is canceled.

Parameters
peerpeer to request information about
pitdesired information
cbthe convenience callback to be called when results for this operation are available
cb_clsthe closure for cb
Returns
handle to the operation

The controller callback will not be called with event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this operation is available. Instead, the GNUNET_TESTBED_PeerInfoCallback() will be called. The peer information in the callback is valid until the operation is canceled.

Parameters
peerpeer to request information about
pitdesired information
cbthe convenience callback to be called when results for this operation are available
cb_clsthe closure for the above callback
Returns
handle to the operation

Definition at line 719 of file testbed_api_peers.c.

References OperationContext::c, PeerInfoData::cb, PeerInfoData::cb_cls, GNUNET_TESTBED_Peer::controller, data, OperationContext::data, GNUNET_assert, GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), GNUNET_TESTBED_PIT_GENERIC, OperationContext::id, OperationContext::op, OP_PEER_INFO, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_peer_getinfo(), opstart_peer_getinfo(), peer, PeerInfoData::peer, PeerInfoData::pit, and OperationContext::type.

Referenced by main_run(), test_master(), test_run(), and tmain().

723 {
724  struct OperationContext *opc;
725  struct PeerInfoData *data;
726 
728  GNUNET_assert(NULL != cb);
729  data = GNUNET_new(struct PeerInfoData);
730  data->peer = peer;
731  data->pit = pit;
732  data->cb = cb;
733  data->cb_cls = cb_cls;
734  opc = GNUNET_new(struct OperationContext);
735  opc->c = peer->controller;
736  opc->data = data;
737  opc->type = OP_PEER_INFO;
738  opc->id = GNUNET_TESTBED_get_next_op_id(opc->c);
739  opc->op =
743  opc->op);
745  return opc->op;
746 }
Data for the OperationType OP_PEER_INFO.
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
void * cb_cls
The closure for peer info callback.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
GNUNET_TESTBED_PeerInfoCallback cb
The Peer info callback to call when this operation has completed.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
Special value (not valid for requesting information) that is used in the event struct if a &#39;generic&#39; ...
static void opstart_peer_getinfo(void *cls)
Function called when a peer get information operation is ready.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
static void oprelease_peer_getinfo(void *cls)
Callback which will be called when peer stop type operation is released.
enum GNUNET_TESTBED_PeerInformationType pit
The type of peer information requested.
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Get peer information operation.
Definition: testbed_api.h:68
struct GNUNET_TESTBED_Peer * peer
The peer whose information has been requested.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_peer_update_configuration()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_peer_update_configuration ( struct GNUNET_TESTBED_Peer peer,
const struct GNUNET_CONFIGURATION_Handle cfg 
)

Change peer configuration.

Ports and paths cannot be changed this way.

Parameters
peerpeer to change configuration for
cfgnew configuration
Returns
handle to the operation

Change peer configuration.

Must only be called while the peer is stopped. Ports and paths cannot be changed this way.

Parameters
peerpeer to change configuration for
cfgnew configuration (differences to existing configuration only)
Returns
handle to the operation

Definition at line 760 of file testbed_api_peers.c.

References OperationContext::c, PeerReconfigureData::cfg_size, PeerReconfigureData::config, GNUNET_TESTBED_Peer::controller, csize, data, OperationContext::data, GNUNET_break, GNUNET_CONFIGURATION_serialize(), GNUNET_free, GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), OperationContext::id, OperationContext::op, OP_PEER_RECONFIGURE, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_peer_reconfigure(), opstart_peer_reconfigure(), peer, PeerReconfigureData::peer, and OperationContext::type.

763 {
764  struct OperationContext *opc;
765  struct PeerReconfigureData *data;
766  size_t csize;
767 
768  data = GNUNET_new(struct PeerReconfigureData);
769  data->peer = peer;
770  data->config = GNUNET_CONFIGURATION_serialize(cfg, &csize);
771  if (NULL == data->config)
772  {
773  GNUNET_free(data);
774  return NULL;
775  }
776  if (csize > UINT16_MAX)
777  {
778  GNUNET_break(0);
779  GNUNET_free(data->config);
780  GNUNET_free(data);
781  return NULL;
782  }
783  data->cfg_size = (uint16_t)csize;
784  opc = GNUNET_new(struct OperationContext);
785  opc->c = peer->controller;
786  opc->data = data;
787  opc->type = OP_PEER_RECONFIGURE;
788  opc->id = GNUNET_TESTBED_get_next_op_id(opc->c);
789  opc->op =
793  opc->op);
795  return opc->op;
796 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
uint16_t cfg_size
the size of the serialized configuration
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
struct GNUNET_TESTBED_Peer * peer
The peer whose information has been requested.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void opstart_peer_reconfigure(void *cls)
Function called when a peer reconfigure operation is ready.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Reconfigure a peer.
Definition: testbed_api.h:73
static void oprelease_peer_reconfigure(void *cls)
Callback which will be called when a peer reconfigure operation is released.
static unsigned int csize
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Data for the operations of type OP_PEER_RECONFIGURE.
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
char * config
The serialized new configuration template.
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_TESTBED_peer_destroy()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_peer_destroy ( struct GNUNET_TESTBED_Peer peer)

Destroy the given peer; the peer should have been stopped first (if it was started).

Parameters
peerpeer to stop
Returns
handle to the operation

Definition at line 807 of file testbed_api_peers.c.

References OperationContext::c, GNUNET_TESTBED_Peer::controller, OperationContext::data, GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), OperationContext::id, OperationContext::op, OP_PEER_DESTROY, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_peer_destroy(), opstart_peer_destroy(), peer, and OperationContext::type.

808 {
809  struct OperationContext *opc;
810 
811  opc = GNUNET_new(struct OperationContext);
812  opc->data = peer;
813  opc->c = peer->controller;
815  opc->type = OP_PEER_DESTROY;
816  opc->op =
820  opc->op);
822  return opc->op;
823 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
Peer destroy operation.
Definition: testbed_api.h:63
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static void oprelease_peer_destroy(void *cls)
Callback which will be called when peer_create type operation is released.
static void opstart_peer_destroy(void *cls)
Function called when a peer destroy operation is ready.
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Here is the call graph for this function:

◆ GNUNET_TESTBED_peer_manage_service()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_peer_manage_service ( void *  op_cls,
struct GNUNET_TESTBED_Peer peer,
const char *  service_name,
GNUNET_TESTBED_OperationCompletionCallback  cb,
void *  cb_cls,
unsigned int  start 
)

Start or stop given service at a peer.

This should not be called to start/stop the peer's ARM service. Use GNUNET_TESTBED_peer_start(), GNUNET_TESTBED_peer_stop() for starting/stopping peer's ARM service. Success or failure of the generated operation is signalled through the controller event callback and/or operation completion callback.

Parameters
op_clsthe closure for the operation
peerthe peer whose service is to be started/stopped
service_namethe name of the service
cbthe operation completion callback
cb_clsthe closure for cb
start1 to start the service; 0 to stop the service
Returns
an operation handle; NULL upon error (peer not running)

This should not be called to start/stop the peer's ARM service. Use GNUNET_TESTBED_peer_start(), GNUNET_TESTBED_peer_stop() for starting/stopping peer's ARM service. Success or failure of the generated operation is signalled through the controller event callback and/or operation completion callback.

Parameters
op_clsthe closure for the operation
peerthe peer whose service is to be started/stopped
service_namethe name of the service
cbthe operation completion callback
cb_clsthe closure for the operation completion callback
start1 to start the service; 0 to stop the service
Returns
an operation handle; NULL upon error (peer not running)

Definition at line 975 of file testbed_api_peers.c.

References OperationContext::c, ManageServiceData::cb, ManageServiceData::cb_cls, GNUNET_TESTBED_Peer::controller, data, OperationContext::data, GNUNET_assert, GNUNET_MAX_MESSAGE_SIZE, GNUNET_new, GNUNET_strdup, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), OperationContext::id, ManageServiceData::msize, OperationContext::op, OperationContext::op_cls, OP_MANAGE_SERVICE, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_manage_service(), opstart_manage_service(), peer, ManageServiceData::peer, ManageServiceData::service_name, start, ManageServiceData::start, GNUNET_TESTBED_Peer::state, TESTBED_PS_STARTED, and OperationContext::type.

Referenced by adjust_running_peers(), announce_next_regex(), manage_service_wrapper(), and test_run().

981 {
982  struct ManageServiceData *data;
983  struct OperationContext *opc;
984  size_t msize;
985 
986  GNUNET_assert(TESTBED_PS_STARTED == peer->state); /* peer is not running? */
987  msize = strlen(service_name) + 1;
988  msize += sizeof(struct GNUNET_TESTBED_ManagePeerServiceMessage);
989  if (GNUNET_MAX_MESSAGE_SIZE < msize)
990  return NULL;
991  data = GNUNET_new(struct ManageServiceData);
992  data->cb = cb;
993  data->cb_cls = cb_cls;
994  data->peer = peer;
996  data->start = start;
997  data->msize = (uint16_t)msize;
998  opc = GNUNET_new(struct OperationContext);
999  opc->data = data;
1000  opc->c = peer->controller;
1001  opc->id = GNUNET_TESTBED_get_next_op_id(opc->c);
1002  opc->type = OP_MANAGE_SERVICE;
1003  opc->op_cls = op_cls;
1004  opc->op =
1008  opc->op);
1010  return opc->op;
1011 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
void * op_cls
The operation closure.
Definition: testbed_api.h:149
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
enum PeerState state
Peer&#39;s state.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
static void opstart_manage_service(void *cls)
Function called when a peer manage service operation is ready.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
GNUNET_TESTBED_OperationCompletionCallback cb
static void oprelease_manage_service(void *cls)
Callback which will be called when peer manage server operation is released.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
Start/stop service at a peer.
Definition: testbed_api.h:103
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
struct GNUNET_TESTBED_Peer * peer
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
Message to start/stop services of a peer.
Definition: testbed.h:682
The peer is running.
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_shutdown_peers()

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.

Is equivalent of calling GNUNET_TESTBED_peer_stop() and GNUNET_TESTBED_peer_destroy() on all peers, except that the peer stop event and operation finished event corresponding to the respective functions are not generated. This function should be called when there are no other pending operations. If there are pending operations, it will return NULL

Parameters
cthe controller to send this message to
op_clsclosure for the operation
cbthe callback to call when all peers are stopped and destroyed
cb_clsthe closure for the callback
Returns
operation handle on success; NULL if any pending operations are present

Definition at line 2275 of file testbed_api.c.

References OperationContext::c, ShutdownPeersData::cb, ShutdownPeersData::cb_cls, data, OperationContext::data, GNUNET_CONTAINER_multihashmap32_size(), GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), OperationContext::id, OperationContext::op, OperationContext::op_cls, OP_SHUTDOWN_PEERS, GNUNET_TESTBED_Controller::opc_map, OPC_STATE_INIT, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_shutdown_peers(), opstart_shutdown_peers(), OperationContext::state, and OperationContext::type.

Referenced by wait_op_completion().

2279 {
2280  struct OperationContext *opc;
2281  struct ShutdownPeersData *data;
2282 
2284  return NULL;
2285  data = GNUNET_new(struct ShutdownPeersData);
2286  data->cb = cb;
2287  data->cb_cls = cb_cls;
2288  opc = GNUNET_new(struct OperationContext);
2289  opc->c = c;
2290  opc->op_cls = op_cls;
2291  opc->data = data;
2293  opc->type = OP_SHUTDOWN_PEERS;
2294  opc->state = OPC_STATE_INIT;
2299  opc->op);
2301  return opc->op;
2302 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
void * op_cls
The operation closure.
Definition: testbed_api.h:149
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
Stop and destroy all peers.
Definition: testbed_api.h:98
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:169
static void opstart_shutdown_peers(void *cls)
Function called when a shutdown peers operation is ready.
Definition: testbed_api.c:2218
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
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
GNUNET_TESTBED_OperationCompletionCallback cb
The operation completion callback to call.
Definition: testbed_api.c:117
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:116
Date context for OP_SHUTDOWN_PEERS operations.
Definition: testbed_api.c:113
void * cb_cls
The closure for the above callback.
Definition: testbed_api.c:122
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:241
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
static void oprelease_shutdown_peers(void *cls)
Callback which will be called when shutdown peers operation is released.
Definition: testbed_api.c:2238
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_underlay_configure_link_va()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_underlay_configure_link_va ( void *  op_cls,
struct GNUNET_TESTBED_Peer p1,
struct GNUNET_TESTBED_Peer p2,
enum GNUNET_TESTBED_ConnectOption  co,
va_list  ap 
)

Manipulate the P2P underlay topology by configuring a link between two peers.

Parameters
op_clsclosure argument to give with the operation event
p1first peer
p2second peer
cooption to change
apoption-specific values
Returns
handle to the operation, NULL if configuring the link at this time is not allowed

◆ GNUNET_TESTBED_underlay_configure_link()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_underlay_configure_link ( void *  op_cls,
struct GNUNET_TESTBED_Peer p1,
struct GNUNET_TESTBED_Peer p2,
enum GNUNET_TESTBED_ConnectOption  co,
  ... 
)

Manipulate the P2P underlay topology by configuring a link between two peers.

Parameters
op_clsclosure argument to give with the operation event
p1first peer
p2second peer
cooption to change
...option-specific values
Returns
handle to the operation, NULL if configuring the link at this time is not allowed

Definition at line 839 of file testbed_api_peers.c.

References GNUNET_break.

844 {
845  GNUNET_break(0);
846  return NULL;
847 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...

◆ GNUNET_TESTBED_underlay_configure_topology_va()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_underlay_configure_topology_va ( void *  op_cls,
unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  peers,
enum GNUNET_TESTBED_TopologyOption  topo,
va_list  ap 
)

Configure overall network topology to have a particular shape.

Parameters
op_clsclosure argument to give with the operation event
num_peersnumber of peers in 'peers'
peersarray of 'num_peers' with the peers to configure
topodesired underlay topology to use
aptopology-specific options
Returns
handle to the operation, NULL if configuring the topology is not allowed at this time
Parameters
op_clsclosure argument to give with the operation event
num_peersnumber of peers in peers
peersarray of num_peers with the peers to configure
topodesired underlay topology to use
aptopology-specific options
Returns
handle to the operation, NULL if configuring the topology is not allowed at this time

Definition at line 1251 of file testbed_api_topology.c.

References GNUNET_break.

1258 {
1259  GNUNET_break(0);
1260  return NULL;
1261 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...

◆ GNUNET_TESTBED_underlay_configure_topology()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_underlay_configure_topology ( void *  op_cls,
unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  peers,
enum GNUNET_TESTBED_TopologyOption  topo,
  ... 
)

Configure overall network topology to have a particular shape.

Parameters
op_clsclosure argument to give with the operation event
num_peersnumber of peers in 'peers'
peersarray of 'num_peers' with the peers to configure
topodesired underlay topology to use
...topology-specific options
Returns
handle to the operation, NULL if configuring the topology is not allowed at this time
Parameters
op_clsclosure argument to give with the operation event
num_peersnumber of peers in peers
peersarray of num_peers with the peers to configure
topodesired underlay topology to use
...topology-specific options
Returns
handle to the operation, NULL if configuring the topology is not allowed at this time

Definition at line 1276 of file testbed_api_topology.c.

References GNUNET_break.

1281 {
1282  GNUNET_break(0);
1283  return NULL;
1284 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...

◆ GNUNET_TESTBED_overlay_connect()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_overlay_connect ( void *  op_cls,
GNUNET_TESTBED_OperationCompletionCallback  cb,
void *  cb_cls,
struct GNUNET_TESTBED_Peer p1,
struct GNUNET_TESTBED_Peer p2 
)

Both peers must have been started before calling this function.

This function then obtains a HELLO from p1, gives it to p2 and asks p2 to connect to p1.

Parameters
op_clsclosure argument to give with the operation event
cbthe callback to call when this operation has finished
cb_clsthe closure for cb
p1first peer
p2second peer
Returns
handle to the operation, NULL if connecting these two peers is fundamentally not possible at this time (peers not running or underlay disallows)

This function then obtains a HELLO from 'p1', gives it to 'p2' and asks 'p2' to connect to 'p1'.

Parameters
op_clsclosure argument to give with the operation event
cbthe callback to call when this operation has finished
cb_clsthe closure for the above callback
p1first peer
p2second peer
Returns
handle to the operation, NULL if connecting these two peers is fundamentally not possible at this time (peers not running or underlay disallows)

Definition at line 865 of file testbed_api_peers.c.

References OperationContext::c, OverlayConnectData::cb, OverlayConnectData::cb_cls, GNUNET_TESTBED_Peer::controller, data, OperationContext::data, GNUNET_assert, GNUNET_new, GNUNET_TESTBED_get_next_op_id(), GNUNET_TESTBED_host_queue_oc_(), GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_Peer::host, OperationContext::id, OperationContext::op, OperationContext::op_cls, OP_OVERLAY_CONNECT, oprelease_overlay_connect(), opstart_overlay_connect(), OverlayConnectData::p1, OverlayConnectData::p2, GNUNET_TESTBED_Peer::state, TESTBED_PS_STARTED, and OperationContext::type.

Referenced by do_connect_peers(), opstart_overlay_configure_topology(), and overlay_link_completed().

869 {
870  struct OperationContext *opc;
871  struct OverlayConnectData *data;
872 
874  data = GNUNET_new(struct OverlayConnectData);
875  data->p1 = p1;
876  data->p2 = p2;
877  data->cb = cb;
878  data->cb_cls = cb_cls;
879  opc = GNUNET_new(struct OperationContext);
880  opc->data = data;
881  opc->c = p1->controller;
882  opc->id = GNUNET_TESTBED_get_next_op_id(opc->c);
883  opc->type = OP_OVERLAY_CONNECT;
884  opc->op_cls = op_cls;
885  opc->op =
890  return opc->op;
891 }
void * cb_cls
The closure for the above callback.
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:139
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:144
void * op_cls
The operation closure.
Definition: testbed_api.h:149
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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...
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
static void oprelease_overlay_connect(void *cls)
Callback which will be called when overlay connect operation is released.
uint64_t GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
Function to return the operation id for a controller.
Definition: testbed_api.c:2201
#define GNUNET_new(type)
Allocate a struct or union of the given type.
enum PeerState state
Peer&#39;s state.
uint64_t id
The id of the opearation.
Definition: testbed_api.h:159
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
enum OperationType type
The type of operation.
Definition: testbed_api.h:164
struct GNUNET_TESTBED_Host * host
Which host does this peer run on?
GNUNET_TESTBED_OperationCompletionCallback cb
The operation completion callback to call once this operation is done.
Data structure for OperationType OP_OVERLAY_CONNECT.
struct GNUNET_TESTBED_Peer * p1
Peer A to connect to peer B.
static void opstart_overlay_connect(void *cls)
Function called when a overlay connect operation is ready.
Overlay connection operation.
Definition: testbed_api.h:78
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
struct GNUNET_TESTBED_Peer * p2
Peer B.
The peer is running.
void * data
Data relevant to the operation.
Definition: testbed_api.h:154
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_overlay_configure_topology_va()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_overlay_configure_topology_va ( 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,
va_list  va 
)

All peers must have been started before calling this function.

This function then connects the given peers in the P2P overlay using the given topology.

Parameters
op_clsclosure argument to give with the peer connect operation events generated through this function
num_peersnumber of peers in 'peers'
peersarray of 'num_peers' with the peers to configure
max_connectionsthe maximums number of overlay connections that will be made to achieve the given topology
comp_cbthe completion callback to call when the topology generation is completed
comp_cb_clsclosure for the comp_cb
topodesired underlay topology to use
vatopology-specific options
Returns
handle to the operation, NULL if connecting these peers is fundamentally not possible at this time (peers not running or underlay disallows) or if num_peers is less than 2

This function then connects the given peers in the P2P overlay using the given topology.

Parameters
op_clsclosure argument to give with the peer connect operation events generated through this function
num_peersnumber of peers in peers
peersarray of num_peers with the peers to configure
max_connectionsthe maximums number of overlay connections that will be made to achieve the given topology
comp_cbthe completion callback to call when the topology generation is completed
comp_cb_clsclosure for the above completion callback
topodesired underlay topology to use
vatopology-specific options
Returns
handle to the operation, NULL if connecting these peers is fundamentally not possible at this time (peers not running or underlay disallows) or if num_peers is less than 2

Definition at line 1308 of file testbed_api_topology.c.

References TopologyContextOverlay::comp_cb, TopologyContextOverlay::comp_cb_cls, GNUNET_TESTBED_Peer::controller, DEFAULT_RETRY_CNT, filename, gen_topo_2dtorus(), gen_topo_clique(), gen_topo_from_file(), gen_topo_line(), gen_topo_random(), gen_topo_ring(), gen_topo_scale_free(), gen_topo_star(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_new, GNUNET_NO, GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), GNUNET_TESTBED_TOPOLOGY_2D_TORUS, GNUNET_TESTBED_TOPOLOGY_CLIQUE, GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, GNUNET_TESTBED_TOPOLOGY_FROM_FILE, GNUNET_TESTBED_TOPOLOGY_LINE, GNUNET_TESTBED_TOPOLOGY_OPTION_END, GNUNET_TESTBED_TOPOLOGY_RETRY_CNT, GNUNET_TESTBED_TOPOLOGY_RING, GNUNET_TESTBED_TOPOLOGY_SCALE_FREE, GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD, GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING, GNUNET_TESTBED_TOPOLOGY_STAR, GNUNET_VA_ARG_ENUM, GNUNET_YES, TopologyContextOverlay::link_array, TopologyContext::link_array_size, LOG, m, num_peers, TopologyContext::num_peers, OverlayLink::op, TopologyContextOverlay::op_cls, GNUNET_TESTBED_Controller::opq_parallel_topology_config_operations, oprelease_overlay_configure_topology(), opstart_overlay_configure_topology(), TopologyContext::overlay, TopologyContextOverlay::peers, peers, TopologyContextOverlay::retry_cnt, OverlayLink::tc, TopologyContext::type, and TopologyContext::u.

Referenced by GNUNET_TESTBED_overlay_configure_topology().

1317 {
1318  struct TopologyContext *tc;
1319  struct TopologyContextOverlay *overlay;
1320  struct GNUNET_TESTBED_Operation *op;
1321  struct GNUNET_TESTBED_Controller *c;
1322  enum GNUNET_TESTBED_TopologyOption secondary_option;
1323 
1324  if (num_peers < 2)
1325  return NULL;
1326  c = peers[0]->controller;
1327  tc = GNUNET_new(struct TopologyContext);
1328  tc->type = TOPOLOGYCONTEXT_TYPE_OVERLAY;
1329  overlay = &tc->u.overlay;
1330  overlay->peers = peers;
1331  tc->num_peers = num_peers;
1332  overlay->op_cls = op_cls;
1333  overlay->retry_cnt = DEFAULT_RETRY_CNT;
1334  overlay->comp_cb = comp_cb;
1335  overlay->comp_cb_cls = comp_cb_cls;
1336  switch (topo)
1337  {
1339  gen_topo_line(tc);
1340  break;
1341 
1343  gen_topo_star(tc);
1344  break;
1345 
1347  gen_topo_ring(tc);
1348  break;
1349 
1351  gen_topo_random(tc, va_arg(va, unsigned int), GNUNET_NO);
1352  break;
1353 
1355  gen_topo_ring(tc);
1356  gen_topo_random(tc, va_arg(va, unsigned int), GNUNET_YES);
1357  break;
1358 
1360  gen_topo_clique(tc);
1361  break;
1362 
1364  gen_topo_2dtorus(tc);
1365  break;
1366 
1368  gen_topo_2dtorus(tc);
1369  gen_topo_random(tc, va_arg(va, unsigned int), GNUNET_YES);
1370 
1371  break;
1372 
1374  {
1375  uint16_t cap;
1376  uint8_t m;
1377 
1378  cap = (uint16_t)va_arg(va, unsigned int);
1379  m = (uint8_t)va_arg(va, unsigned int);
1380  gen_topo_scale_free(tc, cap, m);
1381  }
1382  break;
1383 
1385  {
1386  const char *filename;
1387 
1388  filename = va_arg(va, const char *);
1389 
1390  GNUNET_assert(NULL != filename);
1391  gen_topo_from_file(tc, filename);
1392  }
1393  break;
1394 
1395  default:
1396  GNUNET_break(0);
1397  GNUNET_free(tc);
1398  return NULL;
1399  }
1400  do
1401  {
1402  secondary_option = GNUNET_VA_ARG_ENUM(va, GNUNET_TESTBED_TopologyOption);
1403 
1404  switch (secondary_option)
1405  {
1407  overlay->retry_cnt = va_arg(va, unsigned int);
1408  break;
1409 
1411  break;
1412 
1413  default:
1414  GNUNET_break(0); /* Should not use any other option apart from
1415  * the ones handled here */
1416  GNUNET_free_non_null(overlay->link_array);
1417  GNUNET_free(tc);
1418  return NULL;
1419  }
1420  }
1421  while (GNUNET_TESTBED_TOPOLOGY_OPTION_END != secondary_option);
1429  "Generated %u connections\n",
1430  tc->link_array_size);
1431  if (NULL != max_connections)
1433  return op;
1434 }
A clique (everyone connected to everyone else).
static void gen_topo_scale_free(struct TopologyContext *tc, uint16_t cap, uint8_t m)
Generates scale free network.
GNUNET_TESTBED_TopologyOption
Topologies and topology options supported for testbeds.
static void gen_topo_star(struct TopologyContext *tc)
Generates star topology.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:191
struct TopologyContextOverlay overlay
Topology context information for overlay topology.
#define LOG(kind,...)
Generic loggins shorthand.
unsigned int num_peers
The number of peers.
static unsigned long long max_connections
If there are at least this many connections, old ones will be removed.
static void gen_topo_clique(struct TopologyContext *tc)
Generates clique topology.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:410
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
enum TopologyContext::@73 type
The type of this context.
#define GNUNET_NO
Definition: gnunet_common.h:78
unsigned int link_array_size
The size of the link array.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void gen_topo_ring(struct TopologyContext *tc)
Generates ring topology.
static void gen_topo_line(struct TopologyContext *tc)
Generates line topology.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Opaque handle to an abstract operation to be executed by the testing framework.
void * op_cls
The operation closure.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
Read a topology from a given file.
struct GNUNET_TESTBED_Peer ** peers
The array of peers.
GNUNET_TESTBED_TopologyCompletionCallback comp_cb
topology generation completion callback
How many times should the failed overlay connect operations be retried before giving up...
static char * filename
unsigned int retry_cnt
How many retries to do before we give up.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
static void gen_topo_random(struct TopologyContext *tc, unsigned int links, int append)
Generates ring topology.
The options should always end with this.
static void gen_topo_from_file(struct TopologyContext *tc, const char *filename)
Generates topology from the given file.
struct OperationQueue * opq_parallel_topology_config_operations
Operation queue for simultaneous topology configuration operations.
Definition: testbed_api.h:251
Small-world network (2d torus plus random links).
static unsigned int num_peers
void * comp_cb_cls
The closure for the above callback.
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
static void gen_topo_2dtorus(struct TopologyContext *tc)
Generates ring topology.
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
static struct CadetPeer * peers
Operation to get peer ids.
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
struct OverlayLink * link_array
An array of links; this array is of size link_array_size.
union TopologyContext::@74 u
static void opstart_overlay_configure_topology(void *cls)
Function called when a overlay connect operation is ready.
Context information for overlay topologies.
Context information for topology operations.
static void oprelease_overlay_configure_topology(void *cls)
Callback which will be called when overlay connect operation is released.
#define DEFAULT_RETRY_CNT
Default number of retires.
#define GNUNET_free(ptr)
Wrapper around free.
Small-world network (ring plus random links).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_overlay_configure_topology()

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.

This function then connects the given peers in the P2P overlay using the given topology.

Parameters
op_clsclosure argument to give with the peer connect operation events generated through this function
num_peersnumber of peers in 'peers'
peersarray of 'num_peers' with the peers to configure
max_connectionsthe maximums number of overlay connections that will be made to achieve the given topology
comp_cbthe completion callback to call when the topology generation is completed
comp_cb_clsclosure for the above completion callback
topodesired underlay topology to use
...topology-specific options
Returns
handle to the operation, NULL if connecting these peers is fundamentally not possible at this time (peers not running or underlay disallows) or if num_peers is less than 2

Definition at line 1458 of file testbed_api_topology.c.

References GNUNET_assert, GNUNET_TESTBED_overlay_configure_topology_va(), GNUNET_TESTBED_TOPOLOGY_OPTION_END, and OverlayLink::op.

Referenced by event_cb().

1467 {
1468  struct GNUNET_TESTBED_Operation *op;
1469  va_list vargs;
1470 
1472  va_start(vargs, topo);
1475  comp_cb, comp_cb_cls,
1476  topo,
1477  vargs);
1478  va_end(vargs);
1479  return op;
1480 }
static unsigned long long max_connections
If there are at least this many connections, old ones will be removed.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Opaque handle to an abstract operation to be executed by the testing framework.
The options should always end with this.
static unsigned int num_peers
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_overlay_configure_topology_va(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, va_list va)
All peers must have been started before calling this function.
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:

◆ GNUNET_TESTBED_overlay_write_topology_to_file()

void GNUNET_TESTBED_overlay_write_topology_to_file ( struct GNUNET_TESTBED_Controller controller,
const char *  filename 
)

Ask the testbed controller to write the current overlay topology to a file.

Naturally, the file will only contain a snapshot as the topology may evolve all the time. FIXME: needs continuation!?

Parameters
controlleroverlay controller to inspect
filenamename of the file the topology should be written to.

Naturally, the file will only contain a snapshot as the topology may evolve all the time.

Parameters
controlleroverlay controller to inspect
filenamename of the file the topology should be written to.

Definition at line 1951 of file testbed_api.c.

References GNUNET_break.

1954 {
1955  GNUNET_break(0);
1956 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...

◆ GNUNET_TESTBED_service_connect()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_service_connect ( void *  op_cls,
struct GNUNET_TESTBED_Peer peer,
const char *  service_name,
GNUNET_TESTBED_ServiceConnectCompletionCallback  cb,
void *  cb_cls,
GNUNET_TESTBED_ConnectAdapter  ca,
GNUNET_TESTBED_DisconnectAdapter  da,
void *  cada_cls 
)

Connect to a service offered by the given peer.

Will ensure that the request is queued to not overwhelm our ability to create and maintain connections with other systems. The actual service handle is then returned via the 'op_result' member in the event callback. The ca callback is used to create the connection when the time is right; the da callback will be used to destroy the connection (upon GNUNET_TESTBED_operation_done). GNUNET_TESTBED_operation_done can be used to abort this operation until the event callback has been called.

Parameters
op_clsclosure to pass in operation event // FIXME: didn't we say we'd no longer use the global callback for these? -CG
peerpeer that runs the service
service_namename of the service to connect to
cbthe callback to call when this operation is ready (that is, right after the connect adapter returns)
cb_clsclosure for cb
cahelper function to establish the connection
dahelper function to close the connection
cada_clsclosure for ca and da
Returns
handle for the operation

Will ensure that the request is queued to not overwhelm our ability to create and maintain connections with other systems. The actual service handle is then returned via the 'op_result' member in the event callback. The 'ca' callback is used to create the connection when the time is right; the 'da' callback will be used to destroy the connection (upon 'GNUNET_TESTBED_operation_done'). 'GNUNET_TESTBED_operation_done' can be used to abort this operation until the event callback has been called.

Parameters
op_clsclosure to pass in operation event
peerpeer that runs the service
service_namename of the service to connect to
cbthe callback to call when this operation finishes
cb_clsclosure for the above callback
cahelper function to establish the connection
dahelper function to close the connection
cada_clsclosure for ca and da
Returns
handle for the operation

Definition at line 255 of file testbed_api_services.c.

References ServiceConnectData::ca, ServiceConnectData::cada_cls, ServiceConnectData::cb, ServiceConnectData::cb_cls, ServiceConnectData::da, data, GNUNET_new, GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_insert_(), INIT, ServiceConnectData::op_cls, ServiceConnectData::operation, oprelease_service_connect(), opstart_service_connect(), ServiceConnectData::peer, and ServiceConnectData::state.

Referenced by cadet_test_run(), connect_nse_service(), dht_test_run(), do_collect_stats(), do_comm_connect(), do_connect_ats(), find_string(), GNUNET_FS_TEST_download(), GNUNET_FS_TEST_publish(), opstart_get_stats(), peer_info_cb(), session_disconnect_adapter(), start_profiling(), stats_cb(), test_master(), and test_run().

262 {
263  struct ServiceConnectData *data;
264 
265  data = GNUNET_new(struct ServiceConnectData);
266  data->ca = ca;
267  data->da = da;
268  data->cada_cls = cada_cls;
269  data->op_cls = op_cls;
270  data->peer = peer;
271  data->state = INIT;
272  data->cb = cb;
273  data->cb_cls = cb_cls;
274  data->operation =
278  controller->opq_parallel_service_connections,
279  data->operation);
281  controller->opq_parallel_operations,
282  data->operation);
284  return data->operation;
285 }
struct GNUNET_TESTBED_Operation * operation
The operation which created this structure.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_TESTBED_ConnectAdapter ca
helper function callback to establish the connection
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
void * op_cls
Closure for operation event.
void * cb_cls
The closure for operation completion callback.
enum State state
State information.
GNUNET_TESTBED_DisconnectAdapter da
helper function callback to close the connection
static void oprelease_service_connect(void *cls)
Callback which will be called when service connect type operation is released.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_TESTBED_Peer * peer
The peer handle.
GNUNET_TESTBED_ServiceConnectCompletionCallback cb
The operation completion callback.
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
static void opstart_service_connect(void *cls)
Function called when a service connect operation is ready.
void * cada_cls
Closure to the above callbacks.
Data accessed during service connections.
Initial state.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_operation_done()

void GNUNET_TESTBED_operation_done ( struct GNUNET_TESTBED_Operation operation)

This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) from an operation has been fully processed i.e.

if the event callback is ever called for this operation. If the event callback for this operation has not yet been called, calling this function cancels the operation, frees its resources and ensures the no event is generated with respect to this operation. Note that however cancelling an operation does NOT guarantee that the operation will be fully undone (or that nothing ever happened).

This function MUST be called for every operation to fully remove the operation from the operation queue. After calling this function, if operation is completed and its event information is of type GNUNET_TESTBED_ET_OPERATION_FINISHED, the 'op_result' becomes invalid (!).

If the operation is generated from GNUNET_TESTBED_service_connect() then calling this function on such as operation calls the disconnect adapter if the connect adapter was ever called.

Parameters
operationoperation to signal completion or cancellation

Definition at line 2037 of file testbed_api.c.

References exop_check(), and GNUNET_TESTBED_operation_release_().

Referenced by cancel_get(), churn_cb(), clean_peer(), close_monitor_connections(), connect_completion_callback(), daemon_started(), decrypt_cb(), delayed_put(), destroy(), destroy_pooled_connection(), dht_connected(), disconnect_cadet_peers(), do_shutdown(), download_timeout(), event_cb(), get_iter(), GNUNET_CADET_TEST_cleanup(), GNUNET_DHT_TEST_cleanup(), GST_free_lcf(), GST_link_notify_disconnect(), handle_shutdown(), info_cb(), lcf_proc_task(), manage_service_cb(), op_done_task(), oprelease_get_stats(), oprelease_overlay_configure_topology(), overlay_link_completed(), peer_create_cb(), peer_id_cb(), peer_info_cb(), peerinformation_cb(), post_test_op(), post_test_shutdown_ready_cb(), publish_fs_connect_complete_cb(), publish_timeout(), rc_cleanup_operations(), rcop_cleanup_iterator(), regex_found_handler(), report_success(), report_uri(), search_timed_out(), secret_ready_cb(), service_started(), shutdown_op(), shutdown_task(), slave_event_cb(), statistics_done_cb(), stats_cb(), stats_cont(), and topology_completion_callback().

2038 {
2039  (void)exop_check(operation);
2041 }
static int exop_check(const struct GNUNET_TESTBED_Operation *const op)
Checks if an operation is present in the list of operations marked for expiry.
Definition: testbed_api.c:186
void GNUNET_TESTBED_operation_release_(struct GNUNET_TESTBED_Operation *op)
An operation is &#39;done&#39; (was cancelled or finished); remove it from the queues and release associated ...
Here is the call graph for this function:

◆ GNUNET_TESTBED_get_statistics()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_get_statistics ( unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  peers,
const char *  subsystem,
const char *  name,
GNUNET_TESTBED_StatisticsIterator  proc,
GNUNET_TESTBED_OperationCompletionCallback  cont,
void *  cls 
)

Convenience method that iterates over all (running) peers and retrieves all statistics from each peer.

Parameters
num_peersnumber of peers to iterate over
peersarray of peers to iterate over
subsystemlimit to the specified subsystem, NULL for all subsystems
namename of the statistic value, NULL for all values
procprocessing function for each statistic retrieved
contcontinuation to call once call is completed. The completion of this operation is ONLY signalled through this callback – no GNUNET_TESTBED_ET_OPERATION_FINISHED is generated
clsclosure to pass to proc and cont
Returns
operation handle to cancel the operation
Parameters
num_peersnumber of peers to iterate over
peersarray of peers to iterate over
subsystemlimit to the specified subsystem, NULL for all subsystems
namename of the statistic value, NULL for all values
procprocessing function for each statistic retrieved
contcontinuation to call once call is completed(?)
clsclosure to pass to proc and cont
Returns
operation handle to cancel the operation

Definition at line 402 of file testbed_api_statistics.c.

References GetStatsContext::cb_cls, GetStatsContext::cont, GNUNET_assert, GNUNET_new, GNUNET_strdup, GNUNET_TESTBED_operation_begin_wait_(), GNUNET_TESTBED_operation_create_(), GNUNET_TESTBED_operation_queue_create_(), GNUNET_TESTBED_operation_queue_insert_(), GetStatsContext::main_op, GetStatsContext::name, GetStatsContext::num_peers, OPERATION_QUEUE_TYPE_FIXED, oprelease_get_stats(), opstart_get_stats(), GetStatsContext::peers, GetStatsContext::proc, sc, and GetStatsContext::subsystem.

Referenced by collect_stats(), destroy(), summarize(), and terminate_task().

408 {
409  struct GetStatsContext *sc;
410 
411  GNUNET_assert(NULL != proc);
412  GNUNET_assert(NULL != cont);
413  if (NULL == no_wait_queue)
415  (OPERATION_QUEUE_TYPE_FIXED, UINT_MAX);
416  sc = GNUNET_new(struct GetStatsContext);
417  sc->peers = peers;
418  sc->subsystem = (NULL == subsystem) ? NULL : GNUNET_strdup(subsystem);
419  sc->name = (NULL == name) ? NULL : GNUNET_strdup(name);
420  sc->proc = proc;
421  sc->cont = cont;
422  sc->cb_cls = cls;
423  sc->num_peers = num_peers;
424  sc->main_op =
429  return sc->main_op;
430 }
static char * subsystem
Set to subsystem that we&#39;re going to get stats for (or NULL for all).
GNUNET_TESTBED_StatisticsIterator proc
The iterator to call with statistics information.
static struct OperationQueue * no_wait_queue
A no-wait operation queue.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an &#39;operation&#39; to be performed.
Operation queue which permits a fixed maximum number of operations to be active at any time...
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
char * subsystem
The subsystem of peers for which statistics are requested.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct OperationQueue * GNUNET_TESTBED_operation_queue_create_(enum OperationQueueType type, unsigned int max_active)
Create an operation queue.
GNUNET_TESTBED_OperationCompletionCallback cont
The callback to call when we are done iterating through all peers&#39; statistics services.
struct GNUNET_TESTBED_Peer ** peers
The array of peers whose statistics services are to be accessed.
static void opstart_get_stats(void *cls)
Function called when get_statistics operation is ready.
static void oprelease_get_stats(void *cls)
Function called when get_statistics operation is cancelled or marked as done.
const char * name
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
Context information for use in GNUNET_TESTBED_get_statistics()
static unsigned int num_peers
unsigned int num_peers
The number of peers present in the peers array.
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
char * name
The particular statistics value of interest.
static struct CadetPeer * peers
Operation to get peer ids.
void * cb_cls
The closure for the above callbacks.
struct GNUNET_TESTBED_Operation * main_op
The main operation we generate while creating this context.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_get_index()

uint32_t GNUNET_TESTBED_get_index ( const struct GNUNET_TESTBED_Peer peer)

Return the index of the peer inside of the total peer array, aka.

the peer's "unique ID".

Parameters
peerPeer handle.
Returns
The peer's unique ID.

Definition at line 2314 of file testbed_api.c.

References GNUNET_TESTBED_Peer::unique_id.

Referenced by statistics_cb(), and stats_iterator().

2315 {
2316  return peer->unique_id;
2317 }
uint32_t unique_id
Globally unique ID of the peer.
Here is the caller graph for this function:

◆ GNUNET_TESTBED_run()

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.

Underlay and overlay topology are configured using the "UNDERLAY" and "OVERLAY" options in the "[testbed]" section of the configuration\ (with possible options given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").

The test_master callback will be called once the testbed setup is finished or upon a timeout. This timeout is given through the configuration file by setting the option "SETUP_TIMEOUT" in "[TESTBED]" section.

The testbed is to be terminated using a call to "GNUNET_SCHEDULER_shutdown".

Parameters
host_filenamename of the file with the 'hosts', NULL to run everything on 'localhost'
cfgconfiguration to use (for testbed, controller and peers)
num_peersnumber of peers to start; FIXME: maybe put that ALSO into cfg?; should be greater than 0
event_maskbit mask with set of events to call 'cc' for; or-ed values of "1LL" shifted by the respective 'enum GNUNET_TESTBED_EventType' (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
cccontroller callback to invoke on events; This callback is called for all peer start events even if GNUNET_TESTBED_ET_PEER_START isn't set in the event_mask as this is the only way get access to the handle of each peer
cc_clsclosure for cc
test_masterthis callback will be called once the test is ready or upon timeout
test_master_clsclosure for 'test_master'.

Underlay and overlay topology are configured using the "UNDERLAY" and "OVERLAY" options in the "[testbed]" section of the configuration\ (with possible options given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").

The testbed is to be terminated using a call to "GNUNET_SCHEDULER_shutdown".

Parameters
host_filenamename of the file with the 'hosts', NULL to run everything on 'localhost'
cfgconfiguration to use (for testbed, controller and peers)
num_peersnumber of peers to start; FIXME: maybe put that ALSO into cfg?
event_maskbit mask with set of events to call 'cc' for; or-ed values of "1LL" shifted by the respective 'enum GNUNET_TESTBED_EventType' (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
cccontroller callback to invoke on events; This callback is called for all peer start events even if GNUNET_TESTBED_ET_PEER_START isn't set in the event_mask as this is the only way get access to the handle of each peer
cc_clsclosure for cc
test_masterthis callback will be called once the test is ready
test_master_clsclosure for 'test_master'.

Definition at line 1236 of file testbed_api_testbed.c.

References _, GNUNET_TESTBED_RunHandle::cc, GNUNET_TESTBED_RunHandle::cc_cls, GNUNET_TESTBED_RunHandle::cfg, controller_status_cb(), GNUNET_TESTBED_RunHandle::cproc, DEFAULT_SETUP_TIMEOUT, event_mask, GNUNET_TESTBED_RunHandle::event_mask, GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_have_value(), GNUNET_CONTAINER_multihashmap32_create(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_config_invalid(), GNUNET_log_config_missing(), GNUNET_malloc, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_TESTBED_controller_start(), GNUNET_TESTBED_host_create(), GNUNET_TESTBED_host_destroy(), GNUNET_TESTBED_hosts_load_from_file(), GNUNET_TESTBED_hosts_load_from_loadleveler(), GNUNET_TESTBED_is_host_habitable(), GNUNET_TESTBED_is_host_habitable_cancel(), GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, GNUNET_TESTBED_TOPOLOGY_FROM_FILE, GNUNET_TESTBED_topology_get_(), 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_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, CompatibilityCheckContext::h, GNUNET_TESTBED_RunHandle::h, GNUNET_TESTBED_RunHandle::hclist, host_habitable_cb(), GNUNET_TESTBED_RunHandle::hosts, CompatibilityCheckContext::index, interrupt(), GNUNET_TESTBED_RunHandle::interrupt_task, LOG, GNUNET_TESTBED_RunHandle::num_hosts, num_peers, GNUNET_TESTBED_RunHandle::num_peers, number, GNUNET_TESTBED_RunHandle::random_links, RunContextOperation::rc, CompatibilityCheckContext::rc, RC_INIT, GNUNET_TESTBED_RunHandle::rcop_map, SCALE_FREE_CAP, SCALE_FREE_M, GNUNET_TESTBED_RunHandle::state, GNUNET_TESTBED_RunHandle::test_master, test_master(), GNUNET_TESTBED_RunHandle::test_master_cls, TESTBED_CONFIG_SECTION, GNUNET_TESTBED_RunHandle::timeout_task, timeout_task(), GNUNET_TESTBED_RunHandle::topo_file, topology, and GNUNET_TESTBED_RunHandle::topology.

Referenced by run().

1242 {
1243  struct GNUNET_TESTBED_RunHandle *rc;
1244  char *topology;
1245  struct CompatibilityCheckContext *hc;
1247  unsigned long long number;
1248  unsigned int hid;
1249  unsigned int nhost;
1250 
1251  GNUNET_assert(num_peers > 0);
1252  rc = GNUNET_new(struct GNUNET_TESTBED_RunHandle);
1253  rc->cfg = GNUNET_CONFIGURATION_dup(cfg);
1254 #if ENABLE_SUPERMUC
1256  &rc->hosts);
1257  if (0 == rc->num_hosts)
1258  {
1260  _("No hosts loaded from LoadLeveler. Need at least one host\n"));
1261  goto error_cleanup;
1262  }
1263 #else
1264  if (NULL != host_filename)
1265  {
1266  rc->num_hosts =
1268  &rc->hosts);
1269  if (0 == rc->num_hosts)
1270  {
1272  _("No hosts loaded. Need at least one host\n"));
1273  goto error_cleanup;
1274  }
1275  }
1276  else
1277  rc->h = GNUNET_TESTBED_host_create(NULL, NULL, rc->cfg, 0);
1278 #endif
1279  rc->num_peers = num_peers;
1280  rc->event_mask = event_mask;
1281  rc->cc = cc;
1282  rc->cc_cls = cc_cls;
1283  rc->test_master = test_master;
1284  rc->test_master_cls = test_master_cls;
1285  rc->state = RC_INIT;
1287  if (GNUNET_OK ==
1289  "OVERLAY_TOPOLOGY", &topology))
1290  {
1291  if (GNUNET_NO == GNUNET_TESTBED_topology_get_(&rc->topology, topology))
1292  {
1294  "OVERLAY_TOPLOGY",
1295  _
1296  ("Specified topology must be supported by testbed"));
1297  }
1298  GNUNET_free(topology);
1299  }
1300  switch (rc->topology)
1301  {
1305  if (GNUNET_OK !=
1307  "OVERLAY_RANDOM_LINKS",
1308  &number))
1309  {
1310  /* OVERLAY option RANDOM & SMALL_WORLD_RING requires OVERLAY_RANDOM_LINKS
1311  * option to be set to the number of random links to be established */
1313  "OVERLAY_RANDOM_LINKS");
1314  goto error_cleanup;
1315  }
1316  if (number > UINT32_MAX)
1317  {
1318  GNUNET_break(0); /* Too big number */
1319  goto error_cleanup;
1320  }
1321  rc->random_links = (unsigned int)number;
1322  break;
1323 
1325  if (GNUNET_OK !=
1327  "OVERLAY_TOPOLOGY_FILE",
1328  &rc->topo_file))
1329  {
1331  "OVERLAY_TOPOLOGY_FILE");
1332  goto error_cleanup;
1333  }
1334  goto warn_ignore;
1335 
1337  if (GNUNET_OK !=
1339  SCALE_FREE_CAP, &number))
1340  {
1342  SCALE_FREE_CAP);
1343  goto error_cleanup;
1344  }
1345  if (UINT16_MAX < number)
1346  {
1348  _("Maximum number of edges a peer can have in a scale free topology"
1349  " cannot be more than %u. Given `%s = %llu'"), UINT16_MAX,
1350  SCALE_FREE_CAP, number);
1351  goto error_cleanup;
1352  }
1353  if (GNUNET_OK !=
1355  SCALE_FREE_M, &number))
1356  {
1358  SCALE_FREE_M);
1359  goto error_cleanup;
1360  }
1361  if (UINT8_MAX < number)
1362  {
1364  _("The number of edges that can established when adding a new node"
1365  " to scale free topology cannot be more than %u. Given `%s = %llu'"),
1366  UINT8_MAX, SCALE_FREE_M, number);
1367  goto error_cleanup;
1368  }
1369  goto warn_ignore;
1370 
1372  /* not allowed! */
1373  GNUNET_assert(0);
1374 
1375  default:
1376 warn_ignore:
1377  /* Warn if OVERLAY_RANDOM_LINKS is present that it will be ignored */
1378  if (GNUNET_YES ==
1380  "OVERLAY_RANDOM_LINKS"))
1382  "Ignoring value of `OVERLAY_RANDOM_LINKS' in given configuration\n");
1383  break;
1384  }
1385  if (0 != rc->num_hosts)
1386  {
1387  rc->hclist = GNUNET_malloc(sizeof(struct CompatibilityCheckContext)
1388  * rc->num_hosts);
1389  for (nhost = 0; nhost < rc->num_hosts; nhost++)
1390  {
1391  hc = &rc->hclist[nhost];
1392  hc->index = nhost;
1393  hc->rc = rc;
1394  hc->h = GNUNET_TESTBED_is_host_habitable(rc->hosts[nhost], rc->cfg,
1395  &host_habitable_cb, hc);
1396  if (NULL == hc->h)
1397  {
1398  GNUNET_break(0);
1399  for (nhost = 0; nhost < rc->num_hosts; nhost++)
1400  {
1401  hc = &rc->hclist[nhost];
1402  if (NULL != hc->h)
1404  }
1405  GNUNET_free(rc->hclist);
1406  rc->hclist = NULL;
1407  goto error_cleanup;
1408  }
1409  }
1410  }
1411  else
1412  rc->cproc =
1413  GNUNET_TESTBED_controller_start("127.0.0.1", rc->h,
1414  &controller_status_cb, rc);
1416  "SETUP_TIMEOUT",
1417  &timeout))
1418  {
1421  }
1423  rc->timeout_task =
1425  GNUNET_assert(NULL == rc->interrupt_task);
1426  rc->interrupt_task =
1428  rc);
1429  return;
1430 
1431 error_cleanup:
1432  if (NULL != rc->h)
1434  if (NULL != rc->hosts)
1435  {
1436  for (hid = 0; hid < rc->num_hosts; hid++)
1437  if (NULL != rc->hosts[hid])
1439  GNUNET_free(rc->hosts);
1440  }
1441  if (NULL != rc->cfg)
1443  GNUNET_free(rc);
1444 }
unsigned int index
Index of the host in the run context&#39;s hosts array.
enum State state
State of this context.
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
struct GNUNET_TESTBED_HostHabitableCheckHandle * GNUNET_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.
static void timeout_task(void *cls)
Task run upon timeout while setting up the testbed.
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.
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run of a timeout.
void * cc_cls
The pointer to the controller callback.
void GNUNET_TESTBED_is_host_habitable_cancel(struct GNUNET_TESTBED_HostHabitableCheckHandle *handle)
Function to cancel a request started using GNUNET_TESTBED_is_host_habitable()
static void test_master(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **started_peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
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
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_TIME_UNIT_SECONDS
One second.
All peers are disconnected.
struct GNUNET_TESTBED_ControllerProc * cproc
The handle to the controller process.
Context for host compability checks.
#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 DEFAULT_SETUP_TIMEOUT
The default setup timeout in seconds.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
static void interrupt(void *cls)
Task run upon interrupts (SIGINT, SIGTERM) and upon scheduler shutdown.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
struct GNUNET_SCHEDULER_Task * interrupt_task
Task run upon shutdown interrupts.
#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
struct GNUNET_TESTBED_Host * h
Handle to the host on which the controller runs.
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...
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 struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:114
struct GNUNET_TESTBED_HostHabitableCheckHandle * h
Handle for the compability check.
#define LOG(kind,...)
Generic loggins shorthand.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
char * topo_file
The file containing topology data.
struct CompatibilityCheckContext * hclist
Array of compatibility check contexts.
int GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:440
struct GNUNET_TESTBED_RunHandle * rc
The run context.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
The options should always end with this.
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
uint64_t event_mask
Global event mask for all testbed events.
struct GNUNET_TESTBED_Host * GNUNET_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.
void GNUNET_TESTBED_host_destroy(struct GNUNET_TESTBED_Host *host)
Destroy a host handle.
Small-world network (2d torus plus random links).
static unsigned int num_peers
Initial state.
static char * host_filename
Data file with the hosts for the testbed.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
void * test_master_cls
The closure for the TestMaster callback.
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.
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.
Definition: