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 422 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 442 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 536 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 585 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 657 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 707 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 787 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 1123 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 1218 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 1230 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 1244 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 1320 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 1385 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 1542 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 1597 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.

236 {
241 
246 
251 
256 
261 
262 };
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 268 of file gnunet_testbed_service.h.

269 {
270 
278 
287 
294 
295 };
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 889 of file gnunet_testbed_service.h.

890 {
895 
904 
911 };
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 958 of file gnunet_testbed_service.h.

959 {
965 
971 
977 
982 
987 
992 
998 
1005 
1017 
1022 
1027 
1032 
1037 
1038  /* The following are not topologies but influence how the topology has to be
1039  setup. These options should follow the topology specific options (if
1040  required by the chosen topology). Note that these should be given before
1041  GNUNET_TESTBED_TOPOLOGY_OPTION_END */
1042 
1051 };
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 1506 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 1640 of file gnunet_testbed_service.h.

1641 {
1648 
1655 };
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 366 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().

369 {
370  static uint32_t uid_generator;
371 
372  if (NULL == hostname)
373  return GNUNET_TESTBED_host_create_with_id (0, hostname, username,
374  cfg, port);
375  return GNUNET_TESTBED_host_create_with_id (++uid_generator, hostname,
376  username, cfg, port);
377 }
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:79
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 319 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, 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().

324 {
325  struct GNUNET_TESTBED_Host *host;
326  unsigned int new_size;
327 
328  if ((id < host_list_size) && (NULL != host_list[id]))
329  {
330  LOG (GNUNET_ERROR_TYPE_WARNING, "Host with id: %u already created\n", id);
331  return NULL;
332  }
333  host = GNUNET_new (struct GNUNET_TESTBED_Host);
334  host->hostname = (NULL != hostname) ? GNUNET_strdup (hostname) : NULL;
335  host->username = (NULL != username) ? GNUNET_strdup (username) : NULL;
336  host->id = id;
337  host->port = (0 == port) ? 22 : port;
338  host->cfg = GNUNET_CONFIGURATION_dup (cfg);
341  UINT_MAX);
342  new_size = host_list_size;
343  while (id >= new_size)
344  new_size += HOST_LIST_GROW_STEP;
345  if (new_size != host_list_size)
348  LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding host with id: %u\n", host->id);
349  host_list[id] = host;
350  return host;
351 }
#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.
GUID host
#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:79
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 392 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, SSCANF, and GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_hosts_load_from_loadleveler(), and GNUNET_TESTBED_run().

396 {
397  struct GNUNET_TESTBED_Host *starting_host;
398  char *data;
399  char *buf;
400  char *username;
401  char *hostname;
402  regex_t rex;
403  regmatch_t pmatch[6];
404  uint64_t fs;
405  short int port;
406  unsigned int offset;
407  unsigned int count;
408 
409 
410  GNUNET_assert (NULL != filename);
412  {
413  LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s not found\n"), filename);
414  return 0;
415  }
416  if (GNUNET_OK !=
418  fs = 0;
419  if (0 == fs)
420  {
421  LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s has no data\n"), filename);
422  return 0;
423  }
424  data = GNUNET_malloc (fs);
425  if (fs != GNUNET_DISK_fn_read (filename, data, fs))
426  {
427  GNUNET_free (data);
428  LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s cannot be read\n"),
429  filename);
430  return 0;
431  }
432  buf = data;
433  offset = 0;
434  starting_host = NULL;
435  count = 0;
436  /* refer RFC 952 and RFC 1123 for valid hostnames */
437  GNUNET_assert (0 == regcomp (&rex,
438  "^(([[:alnum:]]+)@)?" /* username */
439  "([[:alnum:]]+[-[:alnum:]_\\.]+)" /* hostname */
440  "(:([[:digit:]]{1,5}))?", /* port */
441  REG_EXTENDED | REG_ICASE));
442  while (offset < (fs - 1))
443  {
444  offset++;
445  if (((data[offset] == '\n')) && (buf != &data[offset]))
446  {
447  unsigned int size;
448 
449  data[offset] = '\0';
450  username = NULL;
451  hostname = NULL;
452  port = 0;
453  if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0))
454  || (-1 == pmatch[3].rm_so))
455  {
457  "Error reading line `%s' in hostfile\n", buf);
458  buf = &data[offset + 1];
459  continue;
460  }
461  if (-1 != pmatch[2].rm_so)
462  {
463  size = pmatch[2].rm_eo - pmatch[2].rm_so;
464  username = GNUNET_malloc (size + 1);
465  GNUNET_assert(0 != GNUNET_strlcpy (username,
466  buf + pmatch[2].rm_so,
467  size + 1));
468  }
469  if (-1 != pmatch[5].rm_so)
470  {
471  (void) SSCANF (buf + pmatch[5].rm_so, "%5hd", &port);
472  }
473  size = pmatch[3].rm_eo - pmatch[3].rm_so;
474  hostname = GNUNET_malloc (size + 1);
475  GNUNET_assert(0 != GNUNET_strlcpy (hostname,
476  buf + pmatch[3].rm_so,
477  size + 1));
479  "Successfully read host %s, port %d and user %s from file\n",
480  (NULL == hostname) ? "NULL" : hostname,
481  port,
482  (NULL == username) ? "NULL" : username);
483  /* We store hosts in a static list; hence we only require the starting
484  * host pointer in that list to access the newly created list of hosts */
485  if (NULL == starting_host)
486  starting_host = GNUNET_TESTBED_host_create (hostname, username, cfg,
487  port);
488  else
489  (void) GNUNET_TESTBED_host_create (hostname, username, cfg, port);
490  count++;
491  GNUNET_free_non_null (username);
492  GNUNET_free (hostname);
493  buf = &data[offset + 1];
494  }
495  else if ((data[offset] == '\n') || (data[offset] == '\0'))
496  buf = &data[offset + 1];
497  }
498  regfree (&rex);
499  GNUNET_free (data);
500  if (NULL == starting_host)
501  return 0;
502  *hosts = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * count);
503  GNUNET_memcpy (*hosts,
504  &host_list[GNUNET_TESTBED_host_get_id_ (starting_host)],
505  sizeof (struct GNUNET_TESTBED_Host *) * count);
506  return count;
507 }
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:669
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#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:208
#define GNUNET_memcpy(dst, src, n)
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:67
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:289
static char * hostname
Our hostname; we give this to all the peers we start.
#define SSCANF
Definition: plibc.h:691
static uint16_t port
Port number.
Definition: gnunet-bcd.c:79
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
uint32_t data
The data value.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
#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:1019
#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 565 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().

568 {
569 #if !ENABLE_SUPERMUC
571  _("The function %s is only available when compiled with (--with-ll)\n"),
572  __func__);
573  GNUNET_assert (0);
574 #else
575  const char *hostfile;
576 
577  if (NULL == (hostfile = getenv ("MP_SAVEHOSTFILE")))
578  {
579  GNUNET_break (0);
580  return 0;
581  }
582  return GNUNET_TESTBED_hosts_load_from_file (hostfile, cfg, hosts);
583 #endif
584 }
#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:208
#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 594 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().

595 {
596  struct RegisteredController *rc;
597  uint32_t id;
598 
599  GNUNET_assert (host->id < host_list_size);
600  GNUNET_assert (host_list[host->id] == host);
601  host_list[host->id] = NULL;
602  /* clear registered controllers list */
603  for (rc = host->rc_head; NULL != rc; rc = host->rc_head)
604  {
605  GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
606  GNUNET_free (rc);
607  }
608  GNUNET_free_non_null ((char *) host->username);
609  GNUNET_free_non_null ((char *) host->hostname);
613  GNUNET_free (host);
615  {
616  for (id = host_list_size - 1; id > host_list_size - HOST_LIST_GROW_STEP;
617  id--)
618  if (NULL != host_list[id])
619  break;
620  if (id != host_list_size - HOST_LIST_GROW_STEP)
621  break;
622  if (NULL != host_list[id])
623  break;
625  }
626  host_list =
628  sizeof (struct GNUNET_TESTBED_Host *) * host_list_size);
629 }
#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 1323 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, host, 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().

1328 {
1330  char **rsh_args;
1331  char **rsh_suffix_args;
1332  char *stat_args[3];
1333  const char *hostname;
1334  char *port;
1335 
1337  h->cb = cb;
1338  h->cb_cls = cb_cls;
1339  h->host = host;
1340  hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
1341  if (GNUNET_OK !=
1342  GNUNET_CONFIGURATION_get_value_filename (config, "testbed",
1343  "HELPER_BINARY_PATH",
1344  &stat_args[1]))
1345  stat_args[1] =
1347  GNUNET_asprintf (&port, "%u", host->port);
1348  rsh_args = gen_rsh_args (port, hostname, host->username);
1349  GNUNET_free (port);
1350  port = NULL;
1351  stat_args[0] = "stat";
1352  stat_args[2] = NULL;
1353  rsh_suffix_args = gen_rsh_suffix_args ((const char **) stat_args);
1354  GNUNET_free (stat_args[1]);
1355  h->helper_argv = join_argv ((const char **) rsh_args,
1356  (const char **) rsh_suffix_args);
1357  free_argv (rsh_suffix_args);
1358  free_argv (rsh_args);
1359  h->auxp =
1361  NULL, NULL, h->helper_argv[0], h->helper_argv);
1362  if (NULL == h->auxp)
1363  {
1364  GNUNET_break (0); /* Cannot exec SSH? */
1365  GNUNET_free (h);
1366  return NULL;
1367  }
1371  return h;
1372 }
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:92
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:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#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:1246
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:1321
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.
GUID host
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:79
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 1381 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().

1384 {
1386  (void) GNUNET_OS_process_kill (handle->auxp, GNUNET_TERM_SIG);
1387  (void) GNUNET_OS_process_wait (handle->auxp);
1388  GNUNET_OS_process_destroy (handle->auxp);
1389  free_argv (handle->helper_argv);
1390  GNUNET_free (handle);
1391 }
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:364
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:1762
char ** helper_argv
The arguments used to start the helper.
#define GNUNET_TERM_SIG
The termination signal.
Definition: platform.h:282
#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:251
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
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 232 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().

233 {
234  return host->hostname;
235 }
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 1071 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, host, 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().

1075 {
1076  struct GNUNET_TESTBED_ControllerProc *cp;
1078  const struct GNUNET_CONFIGURATION_Handle *cfg;
1079  const char *hostname;
1080  static char *const binary_argv[] = {
1081  HELPER_TESTBED_BINARY, NULL
1082  };
1083 
1084  GNUNET_assert (NULL != host);
1085  GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
1086  hostname = NULL;
1087  API_VIOLATION (GNUNET_NO == host->locked,
1088  "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
1089  host->locked = GNUNET_YES;
1091  "Attempting to start a controller on a host which is already started a controller");
1093  if (0 == GNUNET_TESTBED_host_get_id_ (host))
1094  {
1095  cp->helper =
1097  &helper_mst, &helper_exp_cb, cp);
1098  }
1099  else
1100  {
1101  char *helper_binary_path_args[2];
1102  char **rsh_args;
1103  char **rsh_suffix_args;
1104  const char *username;
1105  char *port;
1106  char *argstr;
1107  char *aux;
1108  unsigned int cnt;
1109 
1110  username = host->username;
1111  hostname = host->hostname;
1112  GNUNET_asprintf (&port, "%u", host->port);
1113  LOG_DEBUG ("Starting remote connection to destination %s\n", hostname);
1114  if (GNUNET_OK !=
1116  "HELPER_BINARY_PATH",
1117  &helper_binary_path_args[0]))
1118  helper_binary_path_args[0] =
1120  helper_binary_path_args[1] = NULL;
1121  rsh_args = gen_rsh_args (port, hostname, username);
1122  rsh_suffix_args = gen_rsh_suffix_args ((const char **) helper_binary_path_args);
1123  cp->helper_argv =
1124  join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
1125  free_argv (rsh_args);
1126  free_argv (rsh_suffix_args);
1127  GNUNET_free (port);
1128  argstr = GNUNET_strdup ("");
1129  for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++)
1130  {
1131  aux = argstr;
1132  GNUNET_assert (0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt]));
1133  GNUNET_free (aux);
1134  }
1135  LOG_DEBUG ("Helper cmd str: %s\n", argstr);
1136  GNUNET_free (argstr);
1137  cp->helper =
1139  &helper_exp_cb, cp);
1140  GNUNET_free (helper_binary_path_args[0]);
1141  }
1142  if (NULL == cp->helper)
1143  {
1144  if (NULL != cp->helper_argv)
1145  free_argv (cp->helper_argv);
1146  GNUNET_free (cp);
1147  return NULL;
1148  }
1149  cp->host = host;
1150  cp->cb = cb;
1151  cp->cls = cls;
1152  msg = GNUNET_TESTBED_create_helper_init_msg_ (trusted_ip, hostname, cfg);
1153  cp->msg = &msg->header;
1154  cp->shandle =
1155  GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
1156  if (NULL == cp->shandle)
1157  {
1158  GNUNET_free (msg);
1160  return NULL;
1161  }
1162  return cp;
1163 }
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:1982
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:491
#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:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#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.
GUID host
#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:79
configuration data
Definition: configuration.c:85
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:660
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:80
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 1212 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().

1213 {
1216 }
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 1558 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_(), host, 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().

1562 {
1563  struct GNUNET_TESTBED_Controller *controller
1565  struct GNUNET_MQ_MessageHandler handlers[] = {
1566  GNUNET_MQ_hd_var_size (add_host_confirm,
1569  controller),
1570  GNUNET_MQ_hd_fixed_size (peer_conevent,
1573  controller),
1574  GNUNET_MQ_hd_fixed_size (opsuccess,
1577  controller),
1578  GNUNET_MQ_hd_var_size (op_fail_event,
1581  controller),
1582  GNUNET_MQ_hd_fixed_size (peer_create_success,
1585  controller),
1586  GNUNET_MQ_hd_fixed_size (peer_event,
1589  controller),
1590  GNUNET_MQ_hd_var_size (peer_config,
1593  controller),
1594  GNUNET_MQ_hd_var_size (slave_config,
1597  controller),
1598  GNUNET_MQ_hd_var_size (link_controllers_result,
1601  controller),
1602  GNUNET_MQ_hd_var_size (barrier_status,
1605  controller),
1607  };
1609  struct GNUNET_MQ_Envelope *env;
1610  const struct GNUNET_CONFIGURATION_Handle *cfg;
1611  const char *controller_hostname;
1612  unsigned long long max_parallel_operations;
1613  unsigned long long max_parallel_service_connections;
1614  unsigned long long max_parallel_topology_config_operations;
1615  size_t slen;
1616 
1617  GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
1618  if (GNUNET_OK !=
1619  GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
1620  "MAX_PARALLEL_OPERATIONS",
1621  &max_parallel_operations))
1622  {
1623  GNUNET_break (0);
1624  GNUNET_free (controller);
1625  return NULL;
1626  }
1627  if (GNUNET_OK !=
1628  GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
1629  "MAX_PARALLEL_SERVICE_CONNECTIONS",
1630  &max_parallel_service_connections))
1631  {
1632  GNUNET_break (0);
1633  GNUNET_free (controller);
1634  return NULL;
1635  }
1636  if (GNUNET_OK !=
1637  GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
1638  "MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS",
1639  &max_parallel_topology_config_operations))
1640  {
1641  GNUNET_break (0);
1642  GNUNET_free (controller);
1643  return NULL;
1644  }
1645  controller->cc = cc;
1646  controller->cc_cls = cc_cls;
1647  controller->event_mask = event_mask;
1648  controller->cfg = GNUNET_CONFIGURATION_dup (cfg);
1649  controller->mq = GNUNET_CLIENT_connect (controller->cfg,
1650  "testbed",
1651  handlers,
1653  controller);
1654  if (NULL == controller->mq)
1655  {
1656  GNUNET_break (0);
1658  return NULL;
1659  }
1660  GNUNET_TESTBED_mark_host_registered_at_ (host, controller);
1661  controller->host = host;
1662  controller->opq_parallel_operations =
1664  (unsigned int) max_parallel_operations);
1665  controller->opq_parallel_service_connections =
1667  (unsigned int)
1668  max_parallel_service_connections);
1671  (unsigned int)
1672  max_parallel_topology_config_operations);
1673  controller_hostname = GNUNET_TESTBED_host_get_hostname (host);
1674  if (NULL == controller_hostname)
1675  controller_hostname = "127.0.0.1";
1676  slen = strlen (controller_hostname) + 1;
1677  env = GNUNET_MQ_msg_extra (msg,
1678  slen,
1680  msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1681  msg->event_mask = GNUNET_htonll (controller->event_mask);
1682  GNUNET_memcpy (&msg[1],
1683  controller_hostname,
1684  slen);
1685  GNUNET_MQ_send (controller->mq,
1686  env);
1687  return controller;
1688 }
#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:563
#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:117
#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:501
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:1723
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:194
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:901
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration to use while connecting to controller.
Definition: testbed_api.h:214
#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:639
Event notification from a controller to a client.
Definition: testbed.h:466
Operation queue which permits a fixed maximum number of operations to be active at any time...
#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:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Event notification from a controller to a client.
Definition: testbed.h:536
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:1529
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:176
#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:266
#define GNUNET_memcpy(dst, src, n)
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:250
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:255
GUID host
Reply to GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION message.
Definition: testbed.h:698
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:50
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:245
configuration data
Definition: configuration.c:85
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:219
#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:209
struct GNUNET_TESTBED_Host * host
The host where the controller is running.
Definition: testbed_api.h:199
uint64_t event_mask
Event mask that specifies which events this client is interested in.
Definition: testbed.h:56
Event notification from a controller to a client for a generic operational success where the operatio...
Definition: testbed.h:589
Message for signalling status changes of a barrier.
Definition: testbed.h:862
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:353
#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:204
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 1723 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().

1724 {
1725  if (NULL != c->mq)
1726  {
1727  GNUNET_MQ_destroy (c->mq);
1728  c->mq = NULL;
1729  }
1730  if (NULL != c->host)
1738  if (NULL != c->opc_map)
1739  {
1743  c->opc_map));
1746  }
1747  GNUNET_free (c);
1748 }
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration to use while connecting to controller.
Definition: testbed_api.h:214
#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:1701
struct OperationQueue * opq_parallel_service_connections
Operation queue for simultaneous service connections.
Definition: testbed_api.h:250
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:230
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:255
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_HashMapIterator32 it, void *it_cls)
Iterate over all entries in the map.
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:245
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:219
struct GNUNET_TESTBED_Host * host
The host where the controller is running.
Definition: testbed_api.h:199
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#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 1407 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, host, 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().

1411 {
1414  const char *username;
1415  const char *hostname;
1416  char *config;
1417  char *cconfig;
1418  void *ptr;
1419  size_t cc_size;
1420  size_t config_size;
1421  uint16_t msg_size;
1422  uint16_t username_length;
1423  uint16_t hostname_length;
1424 
1425  if (NULL != controller->rh)
1426  return NULL;
1427  hostname = GNUNET_TESTBED_host_get_hostname (host);
1428  if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller))
1429  {
1430  LOG (GNUNET_ERROR_TYPE_WARNING, "Host hostname: %s already registered\n",
1431  (NULL == hostname) ? "localhost" : hostname);
1432  return NULL;
1433  }
1435  rh->host = host;
1436  rh->c = controller;
1437  GNUNET_assert (NULL != cc);
1438  rh->cc = cc;
1439  rh->cc_cls = cc_cls;
1440  controller->rh = rh;
1441  username = GNUNET_TESTBED_host_get_username_ (host);
1442  username_length = 0;
1443  if (NULL != username)
1444  username_length = strlen (username);
1445  GNUNET_assert (NULL != hostname); /* Hostname must be present */
1446  hostname_length = strlen (hostname);
1447  GNUNET_assert (NULL != host->cfg);
1448  config = GNUNET_CONFIGURATION_serialize (host->cfg, &config_size);
1449  cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig);
1450  GNUNET_free (config);
1451  msg_size = (sizeof (struct GNUNET_TESTBED_AddHostMessage));
1452  msg_size += username_length;
1453  msg_size += hostname_length;
1454  msg_size += cc_size;
1455  msg = GNUNET_malloc (msg_size);
1456  msg->header.size = htons (msg_size);
1458  msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1459  msg->ssh_port = htons (GNUNET_TESTBED_host_get_ssh_port_ (host));
1460  ptr = &msg[1];
1461  if (NULL != username)
1462  {
1463  msg->username_length = htons (username_length);
1464  GNUNET_memcpy (ptr, username, username_length);
1465  ptr += username_length;
1466  }
1467  msg->hostname_length = htons (hostname_length);
1468  GNUNET_memcpy (ptr, hostname, hostname_length);
1469  ptr += hostname_length;
1470  msg->config_size = htons (config_size);
1471  GNUNET_memcpy (ptr, cconfig, cc_size);
1472  ptr += cc_size;
1473  GNUNET_assert ((ptr - (void *) msg) == msg_size);
1474  GNUNET_free (cconfig);
1475  GNUNET_TESTBED_queue_message_ (controller,
1476  (struct GNUNET_MessageHeader *) msg);
1477  return rh;
1478 }
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:88
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:225
#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:65
uint16_t config_size
The length of the uncompressed configuration.
Definition: testbed.h:99
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:94
#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.
#define GNUNET_memcpy(dst, src, n)
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:76
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.
GUID host
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:1331
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST.
Definition: testbed.h:71
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:1761
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:80
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:81
#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 1489 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().

1491 {
1492  if (handle != handle->c->rh)
1493  {
1494  GNUNET_break (0);
1495  return;
1496  }
1497  handle->c->rh = NULL;
1498  GNUNET_free (handle);
1499 }
struct GNUNET_TESTBED_HostRegistrationHandle * rh
The host registration handle; NULL if no current registration requests are present.
Definition: testbed_api.h:225
#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 1833 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().

1838 {
1839  struct OperationContext *opc;
1841  struct ControllerLinkData *data;
1842  uint32_t slave_host_id;
1843  uint32_t delegated_host_id;
1844  uint16_t msg_size;
1845 
1847  GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
1848  slave_host_id =
1849  GNUNET_TESTBED_host_get_id_ ((NULL !=
1850  slave_host) ? slave_host : master->host);
1851  delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host);
1852  if ((NULL != slave_host) && (0 != slave_host_id))
1854  GNUNET_TESTBED_is_host_registered_ (slave_host, master));
1855  msg_size = sizeof (struct GNUNET_TESTBED_ControllerLinkRequest);
1856  msg = GNUNET_malloc (msg_size);
1858  msg->header.size = htons (msg_size);
1859  msg->delegated_host_id = htonl (delegated_host_id);
1860  msg->slave_host_id = htonl (slave_host_id);
1861  msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
1862  data = GNUNET_new (struct ControllerLinkData);
1863  data->msg = msg;
1864  data->host_id = delegated_host_id;
1865  opc = GNUNET_new (struct OperationContext);
1866  opc->c = master;
1867  opc->data = data;
1868  opc->type = OP_LINK_CONTROLLERS;
1869  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
1870  opc->state = OPC_STATE_INIT;
1871  opc->op_cls = op_cls;
1872  msg->operation_id = GNUNET_htonll (opc->id);
1873  opc->op =
1877  opc->op);
1879  return opc->op;
1880 }
#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:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
#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:2213
#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:1448
uint32_t delegated_host_id
For which host should requests be delegated? NBO.
Definition: testbed.h:152
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:114
Link controllers operation.
Definition: testbed_api.h:89
uint64_t id
The id of the opearation.
Definition: testbed_api.h:162
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:1426
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
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:167
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:118
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:245
uint32_t slave_host_id
Which host is responsible for managing the delegation? NBO.
Definition: testbed.h:162
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:168
struct GNUNET_TESTBED_Host * host
The host where the controller is running.
Definition: testbed_api.h:199
Context data for controller link operations.
Definition: testbed_api.c:104
uint64_t operation_id
The id of the operation which created this message.
Definition: testbed.h:157
#define GNUNET_YES
Definition: gnunet_common.h:80
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS.
Definition: testbed.h:147
#define GNUNET_malloc(size)
Wrapper around malloc.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
Client notifies controller that it should delegate requests for a particular client to a particular s...
Definition: testbed.h:141
struct GNUNET_TESTBED_ControllerLinkRequest * msg
The controller link message.
Definition: testbed_api.c:109
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 1938 of file testbed_api.c.

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

1941 {
1942  if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_ (slave_host, master))
1943  return NULL;
1944  return GNUNET_TESTBED_get_slave_config_ (op_cls, master,
1946  (slave_host));
1947 }
#define GNUNET_NO
Definition: gnunet_common.h:81
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:1896
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 575 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_(), host, 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().

579 {
580 
581  struct GNUNET_TESTBED_Peer *peer;
582  struct PeerCreateData *data;
583  struct OperationContext *opc;
584  static uint32_t id_gen;
585 
586  peer = GNUNET_new (struct GNUNET_TESTBED_Peer);
587  peer->controller = controller;
588  peer->host = host;
589  peer->unique_id = id_gen++;
590  peer->state = TESTBED_PS_INVALID;
591  data = GNUNET_new (struct PeerCreateData);
592  data->host = host;
593  data->cfg = cfg;
594  data->cb = cb;
595  data->cls = cls;
596  data->peer = peer;
597  opc = GNUNET_new (struct OperationContext);
598  opc->c = controller;
599  opc->data = data;
600  opc->id = GNUNET_TESTBED_get_next_op_id (controller);
601  opc->type = OP_PEER_CREATE;
602  opc->op =
606  opc->op);
608  return opc->op;
609 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
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:2213
#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:162
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:167
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.
GUID host
uint32_t unique_id
Globally unique ID of the peer.
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:245
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:49
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:157
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:137
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 623 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().

625 {
626  struct OperationContext *opc;
627  struct PeerEventData *data;
628 
629  data = GNUNET_new (struct PeerEventData);
630  data->peer = peer;
631  data->pcc = pcc;
632  data->pcc_cls = pcc_cls;
633  opc = GNUNET_new (struct OperationContext);
634  opc->c = peer->controller;
635  opc->data = data;
636  opc->op_cls = op_cls;
637  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
638  opc->type = OP_PEER_START;
639  opc->op =
643  opc->op);
645  return opc->op;
646 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
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:152
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:2213
#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:162
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:54
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
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:245
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:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
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 662 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.

665 {
666  struct OperationContext *opc;
667  struct PeerEventData *data;
668 
669  data = GNUNET_new (struct PeerEventData);
670  data->peer = peer;
671  data->pcc = pcc;
672  data->pcc_cls = pcc_cls;
673  opc = GNUNET_new (struct OperationContext);
674  opc->c = peer->controller;
675  opc->data = data;
676  opc->op_cls = op_cls;
677  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
678  opc->type = OP_PEER_STOP;
679  opc->op =
683  opc->op);
685  return opc->op;
686 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
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:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
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:2213
#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:162
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:167
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Peer stop operation.
Definition: testbed_api.h:59
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:245
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:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
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 704 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().

708 {
709  struct OperationContext *opc;
710  struct PeerInfoData *data;
711 
713  GNUNET_assert (NULL != cb);
714  data = GNUNET_new (struct PeerInfoData);
715  data->peer = peer;
716  data->pit = pit;
717  data->cb = cb;
718  data->cb_cls = cb_cls;
719  opc = GNUNET_new (struct OperationContext);
720  opc->c = peer->controller;
721  opc->data = data;
722  opc->type = OP_PEER_INFO;
723  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
724  opc->op =
728  opc->op);
730  return opc->op;
731 }
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:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
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:2213
#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:162
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:167
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:245
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:157
uint32_t data
The data value.
Get peer information operation.
Definition: testbed_api.h:69
struct GNUNET_TESTBED_Peer * peer
The peer whose information has been requested.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
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 745 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.

748 {
749  struct OperationContext *opc;
750  struct PeerReconfigureData *data;
751  size_t csize;
752 
753  data = GNUNET_new (struct PeerReconfigureData);
754  data->peer = peer;
755  data->config = GNUNET_CONFIGURATION_serialize (cfg, &csize);
756  if (NULL == data->config)
757  {
758  GNUNET_free (data);
759  return NULL;
760  }
761  if (csize > UINT16_MAX)
762  {
763  GNUNET_break (0);
764  GNUNET_free (data->config);
765  GNUNET_free (data);
766  return NULL;
767  }
768  data->cfg_size = (uint16_t) csize;
769  opc = GNUNET_new (struct OperationContext);
770  opc->c = peer->controller;
771  opc->data = data;
772  opc->type = OP_PEER_RECONFIGURE;
773  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
774  opc->op =
778  opc->op);
780  return opc->op;
781 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
uint16_t cfg_size
the size of the serialized configuration
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
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:2213
#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:74
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:162
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:167
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:245
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:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#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 792 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.

793 {
794  struct OperationContext *opc;
795 
796  opc = GNUNET_new (struct OperationContext);
797  opc->data = peer;
798  opc->c = peer->controller;
800  opc->type = OP_PEER_DESTROY;
801  opc->op =
805  opc->op);
807  return opc->op;
808 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
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:2213
#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:162
Peer destroy operation.
Definition: testbed_api.h:64
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:167
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:245
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:157
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
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 958 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().

964 {
965  struct ManageServiceData *data;
966  struct OperationContext *opc;
967  size_t msize;
968 
969  GNUNET_assert (TESTBED_PS_STARTED == peer->state); /* peer is not running? */
970  msize = strlen (service_name) + 1;
971  msize += sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage);
972  if (GNUNET_MAX_MESSAGE_SIZE < msize)
973  return NULL;
974  data = GNUNET_new (struct ManageServiceData);
975  data->cb = cb;
976  data->cb_cls = cb_cls;
977  data->peer = peer;
979  data->start = start;
980  data->msize = (uint16_t) msize;
981  opc = GNUNET_new (struct OperationContext);
982  opc->data = data;
983  opc->c = peer->controller;
984  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
985  opc->type = OP_MANAGE_SERVICE;
986  opc->op_cls = op_cls;
987  opc->op =
991  opc->op);
993  return opc->op;
994 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
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:2213
#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:162
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:167
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:104
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:245
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:745
The peer is running.
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
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 2288 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().

2292 {
2293  struct OperationContext *opc;
2294  struct ShutdownPeersData *data;
2295 
2297  return NULL;
2298  data = GNUNET_new (struct ShutdownPeersData);
2299  data->cb = cb;
2300  data->cb_cls = cb_cls;
2301  opc = GNUNET_new (struct OperationContext);
2302  opc->c = c;
2303  opc->op_cls = op_cls;
2304  opc->data = data;
2305  opc->id = GNUNET_TESTBED_get_next_op_id (c);
2306  opc->type = OP_SHUTDOWN_PEERS;
2307  opc->state = OPC_STATE_INIT;
2311  opc->op);
2313  return opc->op;
2314 }
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
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:99
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:2213
#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:162
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:172
static void opstart_shutdown_peers(void *cls)
Function called when a shutdown peers operation is ready.
Definition: testbed_api.c:2230
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:230
enum OperationType type
The type of operation.
Definition: testbed_api.h:167
GNUNET_TESTBED_OperationCompletionCallback cb
The operation completion callback to call.
Definition: testbed_api.c:127
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:118
Date context for OP_SHUTDOWN_PEERS operations.
Definition: testbed_api.c:122
void * cb_cls
The closure for the above callback.
Definition: testbed_api.c:132
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:245
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:2253
void * data
Data relevant to the operation.
Definition: testbed_api.h:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
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 824 of file testbed_api_peers.c.

References GNUNET_break.

829 {
830  GNUNET_break (0);
831  return NULL;
832 }
#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 1255 of file testbed_api_topology.c.

References GNUNET_break.

1262 {
1263  GNUNET_break (0);
1264  return NULL;
1265 }
#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 1280 of file testbed_api_topology.c.

References GNUNET_break.

1285 {
1286  GNUNET_break (0);
1287  return NULL;
1288 }
#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 850 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().

854 {
855  struct OperationContext *opc;
856  struct OverlayConnectData *data;
857 
859  data = GNUNET_new (struct OverlayConnectData);
860  data->p1 = p1;
861  data->p2 = p2;
862  data->cb = cb;
863  data->cb_cls = cb_cls;
864  opc = GNUNET_new (struct OperationContext);
865  opc->data = data;
866  opc->c = p1->controller;
867  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
868  opc->type = OP_OVERLAY_CONNECT;
869  opc->op_cls = op_cls;
870  opc->op =
875  return opc->op;
876 }
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:142
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:147
void * op_cls
The operation closure.
Definition: testbed_api.h:152
#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:2213
#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:162
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:167
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:79
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:157
uint32_t data
The data value.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
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 1312 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().

1321 {
1322  struct TopologyContext *tc;
1323  struct TopologyContextOverlay *overlay;
1324  struct GNUNET_TESTBED_Operation *op;
1325  struct GNUNET_TESTBED_Controller *c;
1326  enum GNUNET_TESTBED_TopologyOption secondary_option;
1327 
1328  if (num_peers < 2)
1329  return NULL;
1330  c = peers[0]->controller;
1331  tc = GNUNET_new (struct TopologyContext);
1332  tc->type = TOPOLOGYCONTEXT_TYPE_OVERLAY;
1333  overlay = &tc->u.overlay;
1334  overlay->peers = peers;
1335  tc->num_peers = num_peers;
1336  overlay->op_cls = op_cls;
1337  overlay->retry_cnt = DEFAULT_RETRY_CNT;
1338  overlay->comp_cb = comp_cb;
1339  overlay->comp_cb_cls = comp_cb_cls;
1340  switch (topo)
1341  {
1343  gen_topo_line (tc);
1344  break;
1346  gen_topo_star (tc);
1347  break;
1349  gen_topo_ring (tc);
1350  break;
1352  gen_topo_random (tc, va_arg (va, unsigned int), GNUNET_NO);
1353  break;
1355  gen_topo_ring (tc);
1356  gen_topo_random (tc, va_arg (va, unsigned int), GNUNET_YES);
1357  break;
1359  gen_topo_clique (tc);
1360  break;
1362  gen_topo_2dtorus (tc);
1363  break;
1365  gen_topo_2dtorus (tc);
1366  gen_topo_random (tc, va_arg (va, unsigned int), GNUNET_YES);
1367 
1368  break;
1370  {
1371  uint16_t cap;
1372  uint8_t m;
1373 
1374  cap = (uint16_t) va_arg (va, unsigned int);
1375  m = (uint8_t) va_arg (va, unsigned int);
1376  gen_topo_scale_free (tc, cap, m);
1377  }
1378  break;
1380  {
1381  const char *filename;
1382 
1383  filename = va_arg (va, const char *);
1384 
1385  GNUNET_assert (NULL != filename);
1386  gen_topo_from_file (tc, filename);
1387  }
1388  break;
1389  default:
1390  GNUNET_break (0);
1391  GNUNET_free (tc);
1392  return NULL;
1393  }
1394  do
1395  {
1396  secondary_option = GNUNET_VA_ARG_ENUM (va, GNUNET_TESTBED_TopologyOption);
1397 
1398  switch (secondary_option)
1399  {
1401  overlay->retry_cnt = va_arg (va, unsigned int);
1402  break;
1404  break;
1405  default:
1406  GNUNET_break (0); /* Should not use any other option apart from
1407  * the ones handled here */
1408  GNUNET_free_non_null (overlay->link_array);
1409  GNUNET_free (tc);
1410  return NULL;
1411  }
1412  }
1413  while (GNUNET_TESTBED_TOPOLOGY_OPTION_END != secondary_option);
1421  "Generated %u connections\n",
1422  tc->link_array_size);
1423  if (NULL != max_connections)
1425  return op;
1426 }
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:194
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:417
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:81
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:255
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:80
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 1450 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().

1459 {
1460  struct GNUNET_TESTBED_Operation *op;
1461  va_list vargs;
1462 
1464  va_start (vargs, topo);
1467  comp_cb, comp_cb_cls,
1468  topo,
1469  vargs);
1470  va_end (vargs);
1471  return op;
1472 }
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 1960 of file testbed_api.c.

References GNUNET_break.

1963 {
1964  GNUNET_break (0);
1965 }
#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 256 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().

263 {
264  struct ServiceConnectData *data;
265 
266  data = GNUNET_new (struct ServiceConnectData);
267  data->ca = ca;
268  data->da = da;
269  data->cada_cls = cada_cls;
270  data->op_cls = op_cls;
271  data->peer = peer;
272  data->state = INIT;
273  data->cb = cb;
274  data->cb_cls = cb_cls;
275  data->operation =
279  controller->opq_parallel_service_connections,
280  data->operation);
282  controller->opq_parallel_operations,
283  data->operation);
285  return data->operation;
286 }
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 2046 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().

2047 {
2048  (void) exop_check (operation);
2050 }
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:197
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 405 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().

411 {
412  struct GetStatsContext *sc;
413 
414  GNUNET_assert (NULL != proc);
415  GNUNET_assert (NULL != cont);
416  if (NULL == no_wait_queue)
418  (OPERATION_QUEUE_TYPE_FIXED, UINT_MAX);
419  sc = GNUNET_new (struct GetStatsContext);
420  sc->peers = peers;
421  sc->subsystem = (NULL == subsystem) ? NULL : GNUNET_strdup (subsystem);
422  sc->name = (NULL == name) ? NULL : GNUNET_strdup (name);
423  sc->proc = proc;
424  sc->cont = cont;
425  sc->cb_cls = cls;
426  sc->num_peers = num_peers;
427  sc->main_op =
432  return sc->main_op;
433 }
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 2326 of file testbed_api.c.

References GNUNET_TESTBED_Peer::unique_id.

Referenced by statistics_cb(), and stats_iterator().

2327 {
2328  return peer->unique_id;
2329 }
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 1237 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().

1243 {
1244  struct GNUNET_TESTBED_RunHandle *rc;
1245  char *topology;
1246  struct CompatibilityCheckContext *hc;
1248  unsigned long long number;
1249  unsigned int hid;
1250  unsigned int nhost;
1251 
1252  GNUNET_assert (num_peers > 0);
1253  rc = GNUNET_new (struct GNUNET_TESTBED_RunHandle);
1254  rc->cfg = GNUNET_CONFIGURATION_dup (cfg);
1255 #if ENABLE_SUPERMUC
1257  &rc->hosts);
1258  if (0 == rc->num_hosts)
1259  {
1261  _("No hosts loaded from LoadLeveler. Need at least one host\n"));
1262  goto error_cleanup;
1263  }
1264 #else
1265  if (NULL != host_filename)
1266  {
1267  rc->num_hosts =
1269  &rc->hosts);
1270  if (0 == rc->num_hosts)
1271  {
1273  _("No hosts loaded. Need at least one host\n"));
1274  goto error_cleanup;
1275  }
1276  }
1277  else
1278  rc->h = GNUNET_TESTBED_host_create (NULL, NULL, rc->cfg, 0);
1279 #endif
1280  rc->num_peers = num_peers;
1281  rc->event_mask = event_mask;
1282  rc->cc = cc;
1283  rc->cc_cls = cc_cls;
1284  rc->test_master = test_master;
1285  rc->test_master_cls = test_master_cls;
1286  rc->state = RC_INIT;
1288  if (GNUNET_OK ==
1290  "OVERLAY_TOPOLOGY", &topology))
1291  {
1292  if (GNUNET_NO == GNUNET_TESTBED_topology_get_ (&rc->topology, topology))
1293  {
1295  "OVERLAY_TOPLOGY",
1296  _
1297  ("Specified topology must be supported by testbed"));
1298  }
1299  GNUNET_free (topology);
1300  }
1301  switch (rc->topology)
1302  {
1306  if (GNUNET_OK !=
1308  "OVERLAY_RANDOM_LINKS",
1309  &number))
1310  {
1311  /* OVERLAY option RANDOM & SMALL_WORLD_RING requires OVERLAY_RANDOM_LINKS
1312  * option to be set to the number of random links to be established */
1314  "OVERLAY_RANDOM_LINKS");
1315  goto error_cleanup;
1316  }
1317  if (number > UINT32_MAX)
1318  {
1319  GNUNET_break (0); /* Too big number */
1320  goto error_cleanup;
1321  }
1322  rc->random_links = (unsigned int) number;
1323  break;
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;
1336  if (GNUNET_OK !=
1338  SCALE_FREE_CAP, &number))
1339  {
1341  SCALE_FREE_CAP);
1342  goto error_cleanup;
1343  }
1344  if (UINT16_MAX < number)
1345  {
1347  _("Maximum number of edges a peer can have in a scale free topology"
1348  " cannot be more than %u. Given `%s = %llu'"), UINT16_MAX,
1349  SCALE_FREE_CAP, number);
1350  goto error_cleanup;
1351  }
1352  if (GNUNET_OK !=
1354  SCALE_FREE_M, &number))
1355  {
1357  SCALE_FREE_M);
1358  goto error_cleanup;
1359  }
1360  if (UINT8_MAX < number)
1361  {
1363  _("The number of edges that can established when adding a new node"
1364  " to scale free topology cannot be more than %u. Given `%s = %llu'"),
1365  UINT8_MAX, SCALE_FREE_M, number);
1366  goto error_cleanup;
1367  }
1368  goto warn_ignore;
1370  /* not allowed! */
1371  GNUNET_assert (0);
1372  default:
1373  warn_ignore:
1374  /* Warn if OVERLAY_RANDOM_LINKS is present that it will be ignored */
1375  if (GNUNET_YES ==
1377  "OVERLAY_RANDOM_LINKS"))
1379  "Ignoring value of `OVERLAY_RANDOM_LINKS' in given configuration\n");
1380  break;
1381  }
1382  if (0 != rc->num_hosts)
1383  {
1384  rc->hclist = GNUNET_malloc (sizeof (struct CompatibilityCheckContext)
1385  * rc->num_hosts);
1386  for (nhost = 0; nhost < rc->num_hosts; nhost++)
1387  {
1388  hc = &rc->hclist[nhost];
1389  hc->index = nhost;
1390  hc->rc = rc;
1391  hc->h = GNUNET_TESTBED_is_host_habitable (rc->hosts[nhost], rc->cfg,
1392  &host_habitable_cb, hc);
1393  if (NULL == hc->h)
1394  {
1395  GNUNET_break (0);
1396  for (nhost = 0; nhost < rc->num_hosts; nhost++)
1397  {
1398  hc = &rc->hclist[nhost];
1399  if (NULL != hc->h)
1401  }
1402  GNUNET_free (rc->hclist);
1403  rc->hclist = NULL;
1404  goto error_cleanup;
1405  }
1406  }
1407  }
1408  else
1409  rc->cproc =
1410  GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h,
1411  &controller_status_cb, rc);
1413  "SETUP_TIMEOUT",
1414  &timeout))
1415  {
1418  }
1420  rc->timeout_task =
1422  GNUNET_assert (NULL == rc->interrupt_task);
1423  rc->interrupt_task =
1425  rc);
1426  return;
1427 
1428 error_cleanup:
1429  if (NULL != rc->h)
1431  if (NULL != rc->hosts)
1432  {
1433  for (hid = 0; hid < rc->num_hosts; hid++)
1434  if (NULL != rc->hosts[hid])
1436  GNUNET_free (rc->hosts);
1437  }
1438  if (NULL != rc->cfg)
1440  GNUNET_free (rc);
1441 }
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:1293
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:81
#define DEFAULT_SETUP_TIMEOUT
The default setup timeout in seconds.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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:208
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:1246
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:439
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_f