GNUnet  0.11.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 successful 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 argument 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...
 
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 167 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 389 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 successful 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 successful; GNUNET_SYSERR if not, GNUNET_TESTBED_controller_stop() shouldn't be called in this case

Definition at line 410 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 505 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 554 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 627 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 677 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 successful

Definition at line 757 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 1099 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 1199 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 1211 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 1225 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 1303 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 1368 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 message

Definition at line 1524 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 argument 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 1579 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 216 of file gnunet_testbed_service.h.

217 {
222 
227 
232 
237 
242 };
@ GNUNET_TESTBED_ET_CONNECT
A connection between two peers was established.
@ GNUNET_TESTBED_ET_OPERATION_FINISHED
A requested testbed operation has been completed.
@ GNUNET_TESTBED_ET_PEER_START
A peer has been started.
@ GNUNET_TESTBED_ET_DISCONNECT
A connection between two peers was torn down.
@ GNUNET_TESTBED_ET_PEER_STOP
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 248 of file gnunet_testbed_service.h.

249 {
257 
266 
273 };
@ GNUNET_TESTBED_PIT_CONFIGURATION
What configuration is the peer using? Returns a 'const struct GNUNET_CONFIGURATION_Handle *'.
@ GNUNET_TESTBED_PIT_IDENTITY
What is the identity of the peer? Returns a 'const struct GNUNET_PeerIdentity *'.
@ GNUNET_TESTBED_PIT_GENERIC
Special value (not valid for requesting information) that is used in the event struct if a 'generic' ...

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

863 {
868 
877 
883 };
@ GNUNET_TESTBED_CO_NONE
No option (not valid as an argument).
@ GNUNET_TESTBED_CO_ALLOW
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 930 of file gnunet_testbed_service.h.

931 {
937 
943 
949 
954 
959 
964 
970 
977 
989 
994 
999 
1004 
1009 
1010  /* The following are not topologies but influence how the topology has to be
1011  setup. These options should follow the topology specific options (if
1012  required by the chosen topology). Note that these should be given before
1013  GNUNET_TESTBED_TOPOLOGY_OPTION_END */
1014 
1023 };
@ GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD
Small-world network (2d torus plus random links).
@ GNUNET_TESTBED_TOPOLOGY_FROM_FILE
Read a topology from a given file.
@ GNUNET_TESTBED_TOPOLOGY_NONE
All peers are disconnected.
@ GNUNET_TESTBED_TOPOLOGY_RING
Ring topology.
@ GNUNET_TESTBED_TOPOLOGY_CLIQUE
A clique (everyone connected to everyone else).
@ GNUNET_TESTBED_TOPOLOGY_SCALE_FREE
Scale free topology.
@ GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI
Random graph.
@ GNUNET_TESTBED_TOPOLOGY_INTERNAT
Certain percentage of peers are unable to communicate directly replicating NAT conditions.
@ GNUNET_TESTBED_TOPOLOGY_STAR
Star topology.
@ GNUNET_TESTBED_TOPOLOGY_RETRY_CNT
How many times should the failed overlay connect operations be retried before giving up.
@ GNUNET_TESTBED_TOPOLOGY_2D_TORUS
2-d torus.
@ GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING
Small-world network (ring plus random links).
@ GNUNET_TESTBED_TOPOLOGY_LINE
Straight line topology.
@ GNUNET_TESTBED_TOPOLOGY_OPTION_END
The options should always end with this.

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

1491 {
1496 
1501 
1506 };
@ GNUNET_TESTBED_BARRIERSTATUS_CROSSED
Barrier is crossed.
@ GNUNET_TESTBED_BARRIERSTATUS_ERROR
Error status.
@ GNUNET_TESTBED_BARRIERSTATUS_INITIALISED
Barrier initialised successfully.

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

1624 {
1631 
1638 };
@ GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_WHITELIST
The model is based on black listing of peers to which underlay connections are not permitted.
@ GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST
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 375 of file testbed_api_hosts.c.

379 {
380  static uint32_t uid_generator;
381 
382  if (NULL == hostname)
384  hostname,
385  username,
386  cfg,
387  port);
388  return GNUNET_TESTBED_host_create_with_id (++uid_generator,
389  hostname,
390  username,
391  cfg,
392  port);
393 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static uint16_t port
Port number.
Definition: gnunet-bcd.c:83
static char * hostname
Our hostname; we give this to all the peers we start.
struct GNUNET_TESTBED_Host * GNUNET_TESTBED_host_create_with_id(uint32_t id, const char *hostname, const char *username, const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t port)
Create a host to run peers and controllers on.

References cfg, GNUNET_TESTBED_host_create_with_id(), hostname, port, and GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_hosts_load_from_file(), and GNUNET_TESTBED_run().

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

333 {
334  struct GNUNET_TESTBED_Host *host;
335  unsigned int new_size;
336 
337  if ((id < host_list_size) && (NULL != host_list[id]))
338  {
339  LOG (GNUNET_ERROR_TYPE_WARNING, "Host with id: %u already created\n", id);
340  return NULL;
341  }
342  host = GNUNET_new (struct GNUNET_TESTBED_Host);
343  host->hostname = (NULL != hostname) ? GNUNET_strdup (hostname) : NULL;
344  host->username = (NULL != username) ? GNUNET_strdup (username) : NULL;
345  host->id = id;
346  host->port = (0 == port) ? 22 : port;
347  host->cfg = GNUNET_CONFIGURATION_dup (cfg);
350  UINT_MAX);
351  new_size = host_list_size;
352  while (id >= new_size)
353  new_size += HOST_LIST_GROW_STEP;
354  if (new_size != host_list_size)
357  LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding host with id: %u\n", host->id);
358  host_list[id] = host;
359  return host;
360 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#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.
struct GNUNET_CONFIGURATION_Handle * cfg
the configuration to use as a template while starting a controller on this host.
const char * hostname
The hostname of the host; NULL for localhost.
uint32_t id
Global ID we use to refer to a host on the network.
struct OperationQueue * opq_parallel_overlay_connect_operations
Operation queue for simultaneous overlay connect operations target at this host.
uint16_t port
The port which is to be used for SSH.
const char * username
The username to be used for SSH login.
static unsigned int host_list_size
The size of the available hosts list.
static struct GNUNET_TESTBED_Host ** host_list
Array of available hosts.
#define LOG(kind,...)
Generic logging shorthand.
#define HOST_LIST_GROW_STEP
Number of extra elements we create space for when we grow host list.
struct OperationQueue * GNUNET_TESTBED_operation_queue_create_(enum OperationQueueType type, unsigned int max_active)
Create an operation queue.
@ OPERATION_QUEUE_TYPE_ADAPTIVE
Operation queue which adapts the number of operations to be active based on the operation completion ...

References cfg, GNUNET_TESTBED_Host::cfg, GNUNET_array_grow, GNUNET_assert, GNUNET_CONFIGURATION_dup(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_new, GNUNET_strdup, GNUNET_TESTBED_operation_queue_create_(), host_list, HOST_LIST_GROW_STEP, host_list_size, hostname, GNUNET_TESTBED_Host::hostname, id, GNUNET_TESTBED_Host::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().

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

412 {
413  struct GNUNET_TESTBED_Host *starting_host;
414  char *data;
415  char *buf;
416  char *username;
417  char *hostname;
418  regex_t rex;
419  regmatch_t pmatch[6];
420  uint64_t fs;
421  short int port;
422  unsigned int offset;
423  unsigned int count;
424 
425 
426  GNUNET_assert (NULL != filename);
428  {
429  LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Hosts file %s not found\n"), filename);
430  return 0;
431  }
432  if (GNUNET_OK !=
434  fs = 0;
435  if (0 == fs)
436  {
438  _ ("Hosts file %s has no data\n"),
439  filename);
440  return 0;
441  }
442  data = GNUNET_malloc (fs);
444  {
445  GNUNET_free (data);
447  _ ("Hosts file %s cannot be read\n"),
448  filename);
449  return 0;
450  }
451  buf = data;
452  offset = 0;
453  starting_host = NULL;
454  count = 0;
455  /* refer RFC 952 and RFC 1123 for valid hostnames */
456  GNUNET_assert (0 == regcomp (&rex,
457  "^(([[:alnum:]]+)@)?" /* username */
458  "([[:alnum:]]+[-[:alnum:]_\\.]+)" /* hostname */
459  "(:([[:digit:]]{1,5}))?", /* port */
460  REG_EXTENDED | REG_ICASE));
461  while (offset < (fs - 1))
462  {
463  offset++;
464  if (((data[offset] == '\n')) && (buf != &data[offset]))
465  {
466  unsigned int size;
467 
468  data[offset] = '\0';
469  username = NULL;
470  hostname = NULL;
471  port = 0;
472  if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0)) ||
473  (-1 == pmatch[3].rm_so))
474  {
476  "Error reading line `%s' in hostfile\n",
477  buf);
478  buf = &data[offset + 1];
479  continue;
480  }
481  if (-1 != pmatch[2].rm_so)
482  {
483  size = pmatch[2].rm_eo - pmatch[2].rm_so;
484  username = GNUNET_malloc (size + 1);
485  GNUNET_assert (
486  0 != GNUNET_strlcpy (username, buf + pmatch[2].rm_so, size + 1));
487  }
488  if (-1 != pmatch[5].rm_so)
489  {
490  (void) sscanf (buf + pmatch[5].rm_so, "%5hd", &port);
491  }
492  size = pmatch[3].rm_eo - pmatch[3].rm_so;
493  hostname = GNUNET_malloc (size + 1);
494  GNUNET_assert (
495  0 != GNUNET_strlcpy (hostname, buf + pmatch[3].rm_so, size + 1));
497  "Successfully read host %s, port %d and user %s from file\n",
498  (NULL == hostname) ? "NULL" : hostname,
499  port,
500  (NULL == username) ? "NULL" : username);
501  /* We store hosts in a static list; hence we only require the starting
502  * host pointer in that list to access the newly created list of hosts */
503  if (NULL == starting_host)
504  starting_host =
506  else
508  count++;
511  buf = &data[offset + 1];
512  }
513  else if ((data[offset] == '\n') || (data[offset] == '\0'))
514  buf = &data[offset + 1];
515  }
516  regfree (&rex);
517  GNUNET_free (data);
518  if (NULL == starting_host)
519  return 0;
520  *hosts = GNUNET_malloc (sizeof(struct GNUNET_TESTBED_Host *) * count);
521  GNUNET_memcpy (*hosts,
522  &host_list[GNUNET_TESTBED_host_get_id_ (starting_host)],
523  sizeof(struct GNUNET_TESTBED_Host *) * count);
524  return count;
525 }
static char * filename
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:36
uint32_t data
The data value.
static char buf[2048]
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
enum GNUNET_GenericReturnValue 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:482
enum GNUNET_GenericReturnValue 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:222
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:664
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
Definition: strings.c:162
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.
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host's unique global ID.

References _, buf, cfg, data, filename, 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_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_strlcpy(), GNUNET_TESTBED_host_create(), GNUNET_TESTBED_host_get_id_(), GNUNET_YES, host_list, hostname, LOG, port, size, and GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_run().

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

578 {
579  GNUNET_assert (host->id < host_list_size);
580  GNUNET_assert (host_list[host->id] == host);
581  host_list[host->id] = NULL;
582  /* clear registered controllers list */
583  for (struct RegisteredController *rc = host->rc_head;
584  NULL != rc;
585  rc = host->rc_head)
586  {
587  GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
588  GNUNET_free (rc);
589  }
590  GNUNET_free_nz ((char *) host->username);
591  GNUNET_free_nz ((char *) host->hostname);
595  GNUNET_free (host);
597  {
598  uint32_t id;
599 
600  for (id = host_list_size - 1; id > host_list_size - HOST_LIST_GROW_STEP;
601  id--)
602  if (NULL != host_list[id])
603  break;
605  break;
606  if (NULL != host_list[id])
607  break;
609  }
610  host_list =
612  sizeof(struct GNUNET_TESTBED_Host *) * host_list_size);
613 }
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
#define GNUNET_free_nz(ptr)
Wrapper around free.
struct RegisteredController * rc_head
The head for the list of controllers where this host is registered.
struct RegisteredController * rc_tail
The tail for the list of controllers where this host is registered.
A list entry for registered controllers list.
void GNUNET_TESTBED_operation_queue_destroy_(struct OperationQueue *queue)
Destroys an operation queue.

References GNUNET_TESTBED_Host::cfg, GNUNET_assert, GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_nz, GNUNET_realloc, GNUNET_TESTBED_operation_queue_destroy_(), host_list, HOST_LIST_GROW_STEP, host_list_size, GNUNET_TESTBED_Host::hostname, id, GNUNET_TESTBED_Host::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(), GNUNET_TESTBED_run(), handle_add_host(), and shutdown_task().

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

1321 {
1323  char **rsh_args;
1324  char **rsh_suffix_args;
1325  char *stat_args[3];
1326  const char *hostname;
1327  char *port;
1328 
1330  h->cb = cb;
1331  h->cb_cls = cb_cls;
1332  h->host = host;
1333  hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
1334  if (GNUNET_OK !=
1336  "testbed",
1337  "HELPER_BINARY_PATH",
1338  &stat_args[1]))
1340  GNUNET_asprintf (&port, "%u", host->port);
1341  rsh_args = gen_rsh_args (port, hostname, host->username);
1342  GNUNET_free (port);
1343  port = NULL;
1344  stat_args[0] = "stat";
1345  stat_args[2] = NULL;
1346  rsh_suffix_args = gen_rsh_suffix_args ((const char **) stat_args);
1347  GNUNET_free (stat_args[1]);
1348  h->helper_argv =
1349  join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
1350  free_argv (rsh_suffix_args);
1351  free_argv (rsh_args);
1353  NULL,
1354  NULL,
1355  NULL,
1356  h->helper_argv[0],
1357  h->helper_argv);
1358  if (NULL == h->auxp)
1359  {
1360  GNUNET_break (0); /* Cannot exec SSH? */
1361  GNUNET_free (h);
1362  return NULL;
1363  }
1364  h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time);
1365  h->habitability_check_task =
1367  return h;
1368 }
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static const struct GNUNET_CONFIGURATION_Handle * config
enum GNUNET_GenericReturnValue 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.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
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 ...
struct GNUNET_OS_Process * GNUNET_OS_start_process_vap(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:604
@ GNUNET_OS_INHERIT_STD_ERR
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:91
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:1269
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
The handle for whether a host is habitable or not.
const struct GNUNET_TESTBED_Host * host
The host to check.
GNUNET_TESTBED_HostHabitableCallback cb
The callback to call once we have the status.
#define HELPER_TESTBED_BINARY
Testbed Helper binary name.
Definition: testbed_api.h:38
static char ** gen_rsh_args(const char *port, const char *hostname, const char *username)
Generates arguments for opening a remote shell.
static char ** gen_rsh_suffix_args(const char *const *append_args)
Generates the arguments needed for executing the given binary in a remote shell.
static void habitability_check(void *cls)
Task for checking whether a host is habitable or not.
static void free_argv(char **argv)
Frees the given NULL terminated arguments.
static char ** join_argv(const char *const *argv1, const char *const *argv2)
Function to join NULL terminated list of arguments.

References GNUNET_TESTBED_HostHabitableCheckHandle::cb, GNUNET_TESTBED_HostHabitableCheckHandle::cb_cls, config, free_argv(), gen_rsh_args(), gen_rsh_suffix_args(), GNUNET_asprintf(), GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_free, GNUNET_new, 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(), HELPER_TESTBED_BINARY, GNUNET_TESTBED_HostHabitableCheckHandle::host, hostname, GNUNET_TESTBED_Host::hostname, join_argv(), port, GNUNET_TESTBED_Host::port, and GNUNET_TESTBED_Host::username.

Referenced by GNUNET_TESTBED_run().

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

1379 {
1380  GNUNET_SCHEDULER_cancel (handle->habitability_check_task);
1382  (void) GNUNET_OS_process_wait (handle->auxp);
1384  free_argv (handle->helper_argv);
1385  GNUNET_free (handle);
1386 }
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
int GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
Definition: os_priority.c:983
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
Definition: os_priority.c:286
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:224
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
#define GNUNET_TERM_SIG
The termination signal.
Definition: platform.h:233

References free_argv(), GNUNET_free, GNUNET_OS_process_destroy(), GNUNET_OS_process_kill(), GNUNET_OS_process_wait(), GNUNET_SCHEDULER_cancel(), GNUNET_TERM_SIG, and handle.

Referenced by GNUNET_TESTBED_run(), and rc_cleanup_operations().

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

240 {
241  return host->hostname;
242 }

References GNUNET_TESTBED_Host::hostname.

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

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

1060 {
1061  struct GNUNET_TESTBED_ControllerProc *cp;
1063  const struct GNUNET_CONFIGURATION_Handle *cfg;
1064  const char *hostname;
1065  static char *const binary_argv[] = { HELPER_TESTBED_BINARY, NULL };
1066 
1067  GNUNET_assert (NULL != host);
1068  GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
1069  hostname = NULL;
1070  API_VIOLATION (
1071  GNUNET_NO == host->locked,
1072  "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
1073  host->locked = GNUNET_YES;
1074  API_VIOLATION (
1075  GNUNET_NO == host->controller_started,
1076  "Attempting to start a controller on a host which is already started a controller");
1078  if (0 == GNUNET_TESTBED_host_get_id_ (host))
1079  {
1082  binary_argv,
1083  &helper_mst,
1084  &helper_exp_cb,
1085  cp);
1086  }
1087  else
1088  {
1089  char *helper_binary_path_args[2];
1090  char **rsh_args;
1091  char **rsh_suffix_args;
1092  const char *username;
1093  char *port;
1094  char *argstr;
1095  char *aux;
1096  unsigned int cnt;
1097 
1098  username = host->username;
1099  hostname = host->hostname;
1100  GNUNET_asprintf (&port, "%u", host->port);
1101  LOG_DEBUG ("Starting remote connection to destination %s\n", hostname);
1102  if (GNUNET_OK !=
1104  "testbed",
1105  "HELPER_BINARY_PATH",
1106  &helper_binary_path_args[0]))
1107  helper_binary_path_args[0] =
1109  helper_binary_path_args[1] = NULL;
1110  rsh_args = gen_rsh_args (port, hostname, username);
1111  rsh_suffix_args =
1112  gen_rsh_suffix_args ((const char **) helper_binary_path_args);
1113  cp->helper_argv =
1114  join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
1115  free_argv (rsh_args);
1116  free_argv (rsh_suffix_args);
1117  GNUNET_free (port);
1118  argstr = GNUNET_strdup ("");
1119  for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++)
1120  {
1121  aux = argstr;
1122  GNUNET_assert (
1123  0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt]));
1124  GNUNET_free (aux);
1125  }
1126  LOG_DEBUG ("Helper cmd str: %s\n", argstr);
1127  GNUNET_free (argstr);
1129  cp->helper_argv[0],
1130  cp->helper_argv,
1131  &helper_mst,
1132  &helper_exp_cb,
1133  cp);
1134  GNUNET_free (helper_binary_path_args[0]);
1135  }
1136  if (NULL == cp->helper)
1137  {
1138  if (NULL != cp->helper_argv)
1139  free_argv (cp->helper_argv);
1140  GNUNET_free (cp);
1141  return NULL;
1142  }
1143  cp->host = host;
1144  cp->cb = cb;
1145  cp->cls = cls;
1147  cp->msg = &msg->header;
1148  cp->shandle =
1149  GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
1150  if (NULL == cp->shandle)
1151  {
1152  GNUNET_free (msg);
1154  return NULL;
1155  }
1156  return cp;
1157 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
@ GNUNET_NO
Definition: gnunet_common.h:94
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:657
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
void GNUNET_TESTBED_controller_stop(struct GNUNET_TESTBED_ControllerProc *cproc)
Stop the controller process (also will terminate all peers and controllers dependent on this controll...
Handle for controller process.
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
char ** helper_argv
The arguments used to start the helper.
GNUNET_TESTBED_ControllerStatusCallback cb
The controller error callback.
struct GNUNET_HELPER_Handle * helper
The process handle.
struct GNUNET_MessageHeader * msg
The message corresponding to send handle.
struct GNUNET_TESTBED_Host * host
The host where the helper is run.
void * cls
The closure for the above callback.
Initialization message for gnunet-helper-testbed to start testbed service.
int locked
Is this host locked by GNUNET_TESTBED_controller_start()?
int controller_started
Is a controller started on this host? FIXME: Is this needed?
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:1981
static void clear_msg(void *cls, int result)
Continuation function from GNUNET_HELPER_send()
#define API_VIOLATION(cond, errstr)
Prints API violation message.
static void helper_exp_cb(void *cls)
Callback that will be called when the helper process dies.
#define LOG_DEBUG(...)
Debug logging shorthand.
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.
const struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_host_get_cfg_(const struct GNUNET_TESTBED_Host *host)
Obtain the host's configuration template.

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_ControllerProc::helper, GNUNET_TESTBED_ControllerProc::helper_argv, helper_exp_cb(), helper_mst(), HELPER_TESTBED_BINARY, GNUNET_TESTBED_ControllerProc::host, hostname, GNUNET_TESTBED_Host::hostname, join_argv(), GNUNET_TESTBED_Host::locked, LOG_DEBUG, msg, GNUNET_TESTBED_ControllerProc::msg, port, GNUNET_TESTBED_Host::port, GNUNET_TESTBED_ControllerProc::shandle, and GNUNET_TESTBED_Host::username.

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

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

1207 {
1210 }
void GNUNET_TESTBED_controller_kill_(struct GNUNET_TESTBED_ControllerProc *cproc)
Sends termination signal to the controller's helper process.
void GNUNET_TESTBED_controller_destroy_(struct GNUNET_TESTBED_ControllerProc *cproc)
Cleans-up the controller's helper process handle.

References GNUNET_TESTBED_controller_destroy_(), and GNUNET_TESTBED_controller_kill_().

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

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' (e.g. "(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' (e.g. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
cccontroller callback to invoke on events
cc_clsclosure for cc
Returns
handle to the controller

Definition at line 1555 of file testbed_api.c.

1559 {
1560  struct GNUNET_TESTBED_Controller *controller =
1563  { GNUNET_MQ_hd_var_size (add_host_confirm,
1566  controller),
1567  GNUNET_MQ_hd_fixed_size (peer_conevent,
1570  controller),
1571  GNUNET_MQ_hd_fixed_size (opsuccess,
1573  struct
1575  controller),
1576  GNUNET_MQ_hd_var_size (op_fail_event,
1579  controller),
1580  GNUNET_MQ_hd_fixed_size (peer_create_success,
1582  struct
1584  controller),
1585  GNUNET_MQ_hd_fixed_size (peer_event,
1588  controller),
1589  GNUNET_MQ_hd_var_size (peer_config,
1591  struct
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),
1606  GNUNET_MQ_handler_end () };
1608  struct GNUNET_MQ_Envelope *env;
1609  const struct GNUNET_CONFIGURATION_Handle *cfg;
1610  const char *controller_hostname;
1611  unsigned long long max_parallel_operations;
1612  unsigned long long max_parallel_service_connections;
1613  unsigned long long max_parallel_topology_config_operations;
1614  size_t slen;
1615 
1616  GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
1617  if (GNUNET_OK !=
1619  "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 !=
1629  "testbed",
1630  "MAX_PARALLEL_SERVICE_CONNECTIONS",
1631  &max_parallel_service_connections))
1632  {
1633  GNUNET_break (0);
1634  GNUNET_free (controller);
1635  return NULL;
1636  }
1638  cfg,
1639  "testbed",
1640  "MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS",
1641  &max_parallel_topology_config_operations))
1642  {
1643  GNUNET_break (0);
1644  GNUNET_free (controller);
1645  return NULL;
1646  }
1647  controller->cc = cc;
1648  controller->cc_cls = cc_cls;
1649  controller->event_mask = event_mask;
1650  controller->cfg = GNUNET_CONFIGURATION_dup (cfg);
1651  controller->mq = GNUNET_CLIENT_connect (controller->cfg,
1652  "testbed",
1653  handlers,
1655  controller);
1656  if (NULL == controller->mq)
1657  {
1658  GNUNET_break (0);
1660  return NULL;
1661  }
1662  GNUNET_TESTBED_mark_host_registered_at_ (host, controller);
1663  controller->host = host;
1664  controller->opq_parallel_operations =
1666  (unsigned int)
1667  max_parallel_operations);
1668  controller->opq_parallel_service_connections =
1670  (unsigned int)
1671  max_parallel_service_connections);
1675  (unsigned int) max_parallel_topology_config_operations);
1676  controller_hostname = GNUNET_TESTBED_host_get_hostname (host);
1677  if (NULL == controller_hostname)
1678  controller_hostname = "127.0.0.1";
1679  slen = strlen (controller_hostname) + 1;
1681  msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1682  msg->event_mask = GNUNET_htonll (controller->event_mask);
1683  GNUNET_memcpy (&msg[1], controller_hostname, slen);
1684  GNUNET_MQ_send (controller->mq, env);
1685  return controller;
1686 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
uint64_t event_mask
Global event mask for all testbed events.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:36
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:1064
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#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
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TESTBED_INIT
Initial message from a client to a testing control service.
#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_PEER_EVENT
Message for peer events.
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
Message to signal successful peer creation.
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS
Message for signalling status of a barrier.
#define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS
Message to signal that a add host succeeded.
#define GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION
Message which contains the configuration of slave controller.
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
#define GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
Message for operation events.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer's information.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT
Message for peer connect events.
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:1721
const char * GNUNET_TESTBED_host_get_hostname(const struct GNUNET_TESTBED_Host *host)
Obtain the host's hostname.
Message handler for a specific message type.
Message for signalling status changes of a barrier.
Definition: testbed.h:822
Event notification from a controller to a client.
Definition: testbed.h:476
Response message for ControllerLinkRequest message.
Definition: testbed.h:170
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
uint64_t event_mask
The controller event mask.
Definition: testbed_api.h:265
void * cc_cls
The closure for controller callback.
Definition: testbed_api.h:208
struct OperationQueue * opq_parallel_topology_config_operations
Operation queue for simultaneous topology configuration operations.
Definition: testbed_api.h:254
struct OperationQueue * opq_parallel_service_connections
Operation queue for simultaneous service connections.
Definition: testbed_api.h:249
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
struct GNUNET_TESTBED_Host * host
The host where the controller is running.
Definition: testbed_api.h:198
GNUNET_TESTBED_ControllerCallback cc
The controller callback.
Definition: testbed_api.h:203
struct OperationQueue * opq_parallel_operations
Operation queue for simultaneous operations.
Definition: testbed_api.h:244
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration to use while connecting to controller.
Definition: testbed_api.h:213
Event notification from a controller to a client for a generic operational success where the operatio...
Definition: testbed.h:558
Confirmation from the service that adding a host worked (or failed).
Definition: testbed.h:115
Initial message from a client to a testing control service.
Definition: testbed.h:37
Event notification from a controller to a client.
Definition: testbed.h:509
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:604
Event notification from a controller to a client.
Definition: testbed.h:534
Event notification from a controller to a client.
Definition: testbed.h:443
Reply to GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION message.
Definition: testbed.h:660
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
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.
@ OPERATION_QUEUE_TYPE_FIXED
Operation queue which permits a fixed maximum number of operations to be active at any time.

References GNUNET_TESTBED_Controller::cc, GNUNET_TESTBED_Controller::cc_cls, cfg, GNUNET_TESTBED_Controller::cfg, env, 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_(), handlers, GNUNET_TESTBED_Controller::host, 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().

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 1721 of file testbed_api.c.

1722 {
1723  if (NULL != c->mq)
1724  {
1725  GNUNET_MQ_destroy (c->mq);
1726  c->mq = NULL;
1727  }
1728  if (NULL != c->host)
1735  if (NULL != c->opc_map)
1736  {
1740  c->opc_map));
1743  }
1744  GNUNET_free (c);
1745 }
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
struct GNUNET_CONTAINER_MultiHashMap32 * opc_map
The map of active operation contexts.
Definition: testbed_api.h:229
static int opc_free_iterator(void *cls, uint32_t key, void *value)
Iterator to free opc map entries.
Definition: testbed_api.c:1699
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.

References OperationContext::c, 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().

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

1406 {
1409  const char *username;
1410  const char *hostname;
1411  char *config;
1412  char *cconfig;
1413  void *ptr;
1414  size_t cc_size;
1415  size_t config_size;
1416  uint16_t msg_size;
1417  uint16_t username_length;
1418  uint16_t hostname_length;
1419 
1420  if (NULL != controller->rh)
1421  return NULL;
1423  if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller))
1424  {
1426  "Host hostname: %s already registered\n",
1427  (NULL == hostname) ? "localhost" : hostname);
1428  return NULL;
1429  }
1431  rh->host = host;
1432  rh->c = controller;
1433  GNUNET_assert (NULL != cc);
1434  rh->cc = cc;
1435  rh->cc_cls = cc_cls;
1436  controller->rh = rh;
1437  username = GNUNET_TESTBED_host_get_username_ (host);
1438  username_length = 0;
1439  if (NULL != username)
1440  username_length = strlen (username);
1441  GNUNET_assert (NULL != hostname); /* Hostname must be present */
1442  hostname_length = strlen (hostname);
1443  GNUNET_assert (NULL != host->cfg);
1445  cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig);
1446  GNUNET_free (config);
1447  msg_size = (sizeof(struct GNUNET_TESTBED_AddHostMessage));
1448  msg_size += username_length;
1449  msg_size += hostname_length;
1450  msg_size += cc_size;
1451  msg = GNUNET_malloc (msg_size);
1452  msg->header.size = htons (msg_size);
1453  msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST);
1454  msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1455  msg->ssh_port = htons (GNUNET_TESTBED_host_get_ssh_port_ (host));
1456  ptr = &msg[1];
1457  if (NULL != username)
1458  {
1459  msg->username_length = htons (username_length);
1460  GNUNET_memcpy (ptr, username, username_length);
1461  ptr += username_length;
1462  }
1463  msg->hostname_length = htons (hostname_length);
1465  ptr += hostname_length;
1466  msg->config_size = htons (config_size);
1467  GNUNET_memcpy (ptr, cconfig, cc_size);
1468  ptr += cc_size;
1469  GNUNET_assert ((ptr - (void *) msg) == msg_size);
1470  GNUNET_free (cconfig);
1471  GNUNET_TESTBED_queue_message_ (controller,
1472  (struct GNUNET_MessageHeader *) msg);
1473  return rh;
1474 }
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
#define GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST
Message to add host.
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Notify the service about a host that we intend to use.
Definition: testbed.h:65
uint16_t username_length
Number of bytes in the user name that follows; 0 to use no user name; otherwise 'strlen (username)',...
Definition: testbed.h:86
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:92
uint16_t config_size
The length of the uncompressed configuration.
Definition: testbed.h:97
struct GNUNET_TESTBED_HostRegistrationHandle * rh
The host registration handle; NULL if no current registration requests are present.
Definition: testbed_api.h:224
handle for host registration
struct GNUNET_TESTBED_Host * host
The host being registered.
struct GNUNET_TESTBED_Controller * c
The controller at which this host is being registered.
GNUNET_TESTBED_HostRegistrationCompletion cc
The Registration completion callback.
void * cc_cls
The closure for above callback.
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:1336
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1758
const char * GNUNET_TESTBED_host_get_username_(const struct GNUNET_TESTBED_Host *host)
Obtain the host's username.
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.
uint16_t GNUNET_TESTBED_host_get_ssh_port_(const struct GNUNET_TESTBED_Host *host)
Obtain the host's ssh port.

References GNUNET_TESTBED_HostRegistrationHandle::c, GNUNET_TESTBED_HostRegistrationHandle::cc, GNUNET_TESTBED_HostRegistrationHandle::cc_cls, GNUNET_TESTBED_Host::cfg, config, GNUNET_TESTBED_AddHostMessage::config_size, 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_HostRegistrationHandle::host, hostname, GNUNET_TESTBED_AddHostMessage::hostname_length, LOG, msg, GNUNET_TESTBED_Controller::rh, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and GNUNET_TESTBED_AddHostMessage::username_length.

Referenced by register_hosts(), and register_next_host().

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

1487 {
1488  if (handle != handle->c->rh)
1489  {
1490  GNUNET_break (0);
1491  return;
1492  }
1493  handle->c->rh = NULL;
1494  GNUNET_free (handle);
1495 }
GNUNET_DNS_RequestHandler rh
Function to call to get replies.
Definition: dns_api.c:71

References GNUNET_break, GNUNET_free, handle, and GNUNET_DNS_Handle::rh.

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

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 1832 of file testbed_api.c.

1837 {
1838  struct OperationContext *opc;
1840  struct ControllerLinkData *data;
1841  uint32_t slave_host_id;
1842  uint32_t delegated_host_id;
1843  uint16_t msg_size;
1844 
1846  GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
1847  slave_host_id = GNUNET_TESTBED_host_get_id_ (
1848  (NULL != slave_host) ? slave_host : master->host);
1849  delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host);
1850  if ((NULL != slave_host) && (0 != slave_host_id))
1852  GNUNET_TESTBED_is_host_registered_ (slave_host, master));
1853  msg_size = sizeof(struct GNUNET_TESTBED_ControllerLinkRequest);
1854  msg = GNUNET_malloc (msg_size);
1856  msg->header.size = htons (msg_size);
1857  msg->delegated_host_id = htonl (delegated_host_id);
1858  msg->slave_host_id = htonl (slave_host_id);
1859  msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
1860  data = GNUNET_new (struct ControllerLinkData);
1861  data->msg = msg;
1862  data->host_id = delegated_host_id;
1863  opc = GNUNET_new (struct OperationContext);
1864  opc->c = master;
1865  opc->data = data;
1866  opc->type = OP_LINK_CONTROLLERS;
1867  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
1868  opc->state = OPC_STATE_INIT;
1869  opc->op_cls = op_cls;
1870  msg->operation_id = GNUNET_htonll (opc->id);
1875  opc->op);
1877  return opc->op;
1878 }
#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS
Message to link delegated controller to slave controller.
Context data for controller link operations.
Definition: testbed_api.c:100
Client notifies controller that it should delegate requests for a particular client to a particular s...
Definition: testbed.h:137
uint32_t slave_host_id
Which host is responsible for managing the delegation? NBO.
Definition: testbed.h:156
uint32_t delegated_host_id
For which host should requests be delegated? NBO.
Definition: testbed.h:146
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:162
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
void * op_cls
The operation closure.
Definition: testbed_api.h:151
enum OperationContextState state
The state of the operation.
Definition: testbed_api.h:171
enum OperationType type
The type of operation.
Definition: testbed_api.h:166
uint64_t id
The id of the operation.
Definition: testbed_api.h:161
struct GNUNET_TESTBED_Operation * op
The operation.
Definition: testbed_api.h:146
struct GNUNET_TESTBED_Controller * c
The controller to which this operation context belongs to.
Definition: testbed_api.h:141
void * data
Data relevant to the operation.
Definition: testbed_api.h:156
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:2209
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:1422
static void oprelease_link_controllers(void *cls)
Callback which will be called when link-controllers type operation is released.
Definition: testbed_api.c:1444
@ OP_LINK_CONTROLLERS
Link controllers operation.
Definition: testbed_api.h:89
@ OPC_STATE_INIT
The initial state where the associated operation has just been created and is waiting in the operatio...
Definition: testbed_api.h:117
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an 'operation' to be performed.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.

References OperationContext::c, OperationContext::data, 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_Controller::host, OperationContext::id, GNUNET_TESTBED_ControllerLinkRequest::is_subordinate, msg, OperationContext::op, OperationContext::op_cls, OP_LINK_CONTROLLERS, OPC_STATE_INIT, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_link_controllers(), opstart_link_controllers(), GNUNET_MessageHeader::size, GNUNET_TESTBED_ControllerLinkRequest::slave_host_id, OperationContext::state, GNUNET_MessageHeader::type, and OperationContext::type.

Referenced by lcf_proc_task(), and register_hosts().

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 1936 of file testbed_api.c.

1939 {
1940  if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_ (slave_host, master))
1941  return NULL;
1942  return GNUNET_TESTBED_get_slave_config_ (op_cls,
1943  master,
1945  slave_host));
1946 }
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:1894

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

Here is the call graph for this function:

◆ GNUNET_TESTBED_peer_create()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_peer_create ( struct GNUNET_TESTBED_Controller controller,
struct GNUNET_TESTBED_Host host,
const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_TESTBED_PeerCreateCallback  cb,
void *  cls 
)

Create the given peer at the specified host using the given controller.

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

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

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

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

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

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

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

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

Definition at line 591 of file testbed_api_peers.c.

595 {
596  struct GNUNET_TESTBED_Peer *peer;
597  struct PeerCreateData *data;
598  struct OperationContext *opc;
599  static uint32_t id_gen;
600 
602  peer->controller = controller;
603  peer->host = host;
604  peer->unique_id = id_gen++;
606  data = GNUNET_new (struct PeerCreateData);
607  data->host = host;
608  data->cfg = cfg;
609  data->cb = cb;
610  data->cls = cls;
611  data->peer = peer;
612  opc = GNUNET_new (struct OperationContext);
613  opc->c = controller;
614  opc->data = data;
615  opc->id = GNUNET_TESTBED_get_next_op_id (controller);
616  opc->type = OP_PEER_CREATE;
617  opc->op =
621  opc->op);
623  return opc->op;
624 }
A peer controlled by the testing framework.
enum PeerState state
Peer's state.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
uint32_t unique_id
Globally unique ID of the peer.
struct GNUNET_TESTBED_Host * host
Which host does this peer run on?
Data for the OperationType OP_PEER_CREATE.
@ OP_PEER_CREATE
Peer create operation.
Definition: testbed_api.h:49
static void oprelease_peer_create(void *cls)
Callback which will be called when peer_create type operation is released.
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...
@ TESTBED_PS_INVALID
State to signify that this peer is invalid.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

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

Referenced by create_peers().

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

◆ GNUNET_TESTBED_peer_start()

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

Start the given peer.

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

Definition at line 638 of file testbed_api_peers.c.

640 {
641  struct OperationContext *opc;
642  struct PeerEventData *data;
643 
644  data = GNUNET_new (struct PeerEventData);
645  data->peer = peer;
646  data->pcc = pcc;
647  data->pcc_cls = pcc_cls;
648  opc = GNUNET_new (struct OperationContext);
649  opc->c = peer->controller;
650  opc->data = data;
651  opc->op_cls = op_cls;
652  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
653  opc->type = OP_PEER_START;
654  opc->op =
658  opc->op);
660  return opc->op;
661 }
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.
void * pcc_cls
Closure for the above callback.
@ OP_PEER_START
Peer start operation.
Definition: testbed_api.h:54
static void oprelease_peer_start(void *cls)
Callback which will be called when peer start type operation is released.
static void opstart_peer_start(void *cls)
Function called when a peer start operation is ready.

References OperationContext::c, GNUNET_TESTBED_Peer::controller, OperationContext::data, 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, and OperationContext::type.

Referenced by start_peers_task().

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

◆ GNUNET_TESTBED_peer_stop()

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

Stop the given peer.

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

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

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

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

Definition at line 677 of file testbed_api_peers.c.

680 {
681  struct OperationContext *opc;
682  struct PeerEventData *data;
683 
684  data = GNUNET_new (struct PeerEventData);
685  data->peer = peer;
686  data->pcc = pcc;
687  data->pcc_cls = pcc_cls;
688  opc = GNUNET_new (struct OperationContext);
689  opc->c = peer->controller;
690  opc->data = data;
691  opc->op_cls = op_cls;
692  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
693  opc->type = OP_PEER_STOP;
694  opc->op =
698  opc->op);
700  return opc->op;
701 }
@ OP_PEER_STOP
Peer stop operation.
Definition: testbed_api.h:59
static void opstart_peer_stop(void *cls)
Function called when a peer stop operation is ready.
static void oprelease_peer_stop(void *cls)
Callback which will be called when peer stop type operation is released.

References OperationContext::c, GNUNET_TESTBED_Peer::controller, OperationContext::data, 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, and OperationContext::type.

Here is the call graph for this function:

◆ GNUNET_TESTBED_peer_get_information()

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

Request information about a peer.

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

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

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

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

Definition at line 719 of file testbed_api_peers.c.

723 {
724  struct OperationContext *opc;
725  struct PeerInfoData *data;
726 
728  GNUNET_assert (NULL != cb);
729  data = GNUNET_new (struct PeerInfoData);
730  data->peer = peer;
731  data->pit = pit;
732  data->cb = cb;
733  data->cb_cls = cb_cls;
734  opc = GNUNET_new (struct OperationContext);
735  opc->c = peer->controller;
736  opc->data = data;
737  opc->type = OP_PEER_INFO;
738  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
739  opc->op =
743  opc->op);
745  return opc->op;
746 }
Data for the OperationType OP_PEER_INFO.
GNUNET_TESTBED_PeerInfoCallback cb
The Peer info callback to call when this operation has completed.
void * cb_cls
The closure for peer info callback.
enum GNUNET_TESTBED_PeerInformationType pit
The type of peer information requested.
@ OP_PEER_INFO
Get peer information operation.
Definition: testbed_api.h:69
static void oprelease_peer_getinfo(void *cls)
Callback which will be called when peer stop type operation is released.
static void opstart_peer_getinfo(void *cls)
Function called when a peer get information operation is ready.

References OperationContext::c, PeerInfoData::cb, PeerInfoData::cb_cls, GNUNET_TESTBED_Peer::controller, OperationContext::data, 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::pit, and OperationContext::type.

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

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

◆ GNUNET_TESTBED_peer_update_configuration()

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

Change peer configuration.

Ports and paths cannot be changed this way.

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

Change peer configuration.

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

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

Definition at line 760 of file testbed_api_peers.c.

763 {
764  struct OperationContext *opc;
765  struct PeerReconfigureData *data;
766  size_t csize;
767 
769  data->peer = peer;
771  if (NULL == data->config)
772  {
773  GNUNET_free (data);
774  return NULL;
775  }
776  if (csize > UINT16_MAX)
777  {
778  GNUNET_break (0);
779  GNUNET_free (data->config);
780  GNUNET_free (data);
781  return NULL;
782  }
783  data->cfg_size = (uint16_t) csize;
784  opc = GNUNET_new (struct OperationContext);
785  opc->c = peer->controller;
786  opc->data = data;
787  opc->type = OP_PEER_RECONFIGURE;
788  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
789  opc->op =
793  opc->op);
795  return opc->op;
796 }
static unsigned int csize
Data for the operations of type OP_PEER_RECONFIGURE.
@ OP_PEER_RECONFIGURE
Reconfigure a peer.
Definition: testbed_api.h:74
static void opstart_peer_reconfigure(void *cls)
Function called when a peer reconfigure operation is ready.
static void oprelease_peer_reconfigure(void *cls)
Callback which will be called when a peer reconfigure operation is released.

References OperationContext::c, cfg, GNUNET_TESTBED_Peer::controller, csize, OperationContext::data, 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, and OperationContext::type.

Here is the call graph for this function:

◆ GNUNET_TESTBED_peer_destroy()

struct GNUNET_TESTBED_Operation* GNUNET_TESTBED_peer_destroy ( struct GNUNET_TESTBED_Peer peer)

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

Parameters
peerpeer to stop
Returns
handle to the operation

Definition at line 807 of file testbed_api_peers.c.

808 {
809  struct OperationContext *opc;
810 
811  opc = GNUNET_new (struct OperationContext);
812  opc->data = peer;
813  opc->c = peer->controller;
815  opc->type = OP_PEER_DESTROY;
816  opc->op =
820  opc->op);
822  return opc->op;
823 }
@ OP_PEER_DESTROY
Peer destroy operation.
Definition: testbed_api.h:64
static void opstart_peer_destroy(void *cls)
Function called when a peer destroy operation is ready.
static void oprelease_peer_destroy(void *cls)
Callback which will be called when peer_create type operation is released.

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.

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 976 of file testbed_api_peers.c.

983 {
984  struct ManageServiceData *data;
985  struct OperationContext *opc;
986  size_t msize;
987 
988  GNUNET_assert (TESTBED_PS_STARTED == peer->state); /* peer is not running? */
989  msize = strlen (service_name) + 1;
990  msize += sizeof(struct GNUNET_TESTBED_ManagePeerServiceMessage);
991  if (GNUNET_MAX_MESSAGE_SIZE < msize)
992  return NULL;
993  data = GNUNET_new (struct ManageServiceData);
994  data->cb = cb;
995  data->cb_cls = cb_cls;
996  data->peer = peer;
997  data->service_name = GNUNET_strdup (service_name);
998  data->start = start;
999  data->msize = (uint16_t) msize;
1000  opc = GNUNET_new (struct OperationContext);
1001  opc->data = data;
1002  opc->c = peer->controller;
1003  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
1004  opc->type = OP_MANAGE_SERVICE;
1005  opc->op_cls = op_cls;
1006  opc->op =
1010  opc->op);
1012  return opc->op;
1013 }
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
Message to start/stop services of a peer.
Definition: testbed.h:706
@ OP_MANAGE_SERVICE
Start/stop service at a peer.
Definition: testbed_api.h:104
static void oprelease_manage_service(void *cls)
Callback which will be called when peer manage server operation is released.
static void opstart_manage_service(void *cls)
Function called when a peer manage service operation is ready.
@ TESTBED_PS_STARTED
The peer is running.

References OperationContext::c, GNUNET_TESTBED_Peer::controller, OperationContext::data, 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, OperationContext::op, OperationContext::op_cls, OP_MANAGE_SERVICE, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_manage_service(), opstart_manage_service(), peer, service_name, 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().

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 2283 of file testbed_api.c.

2287 {
2288  struct OperationContext *opc;
2289  struct ShutdownPeersData *data;
2290 
2292  return NULL;
2293  data = GNUNET_new (struct ShutdownPeersData);
2294  data->cb = cb;
2295  data->cb_cls = cb_cls;
2296  opc = GNUNET_new (struct OperationContext);
2297  opc->c = c;
2298  opc->op_cls = op_cls;
2299  opc->data = data;
2300  opc->id = GNUNET_TESTBED_get_next_op_id (c);
2301  opc->type = OP_SHUTDOWN_PEERS;
2302  opc->state = OPC_STATE_INIT;
2307  opc->op);
2309  return opc->op;
2310 }
Date context for OP_SHUTDOWN_PEERS operations.
Definition: testbed_api.c:117
void * cb_cls
The closure for the above callback.
Definition: testbed_api.c:126
GNUNET_TESTBED_OperationCompletionCallback cb
The operation completion callback to call.
Definition: testbed_api.c:121
static void opstart_shutdown_peers(void *cls)
Function called when a shutdown peers operation is ready.
Definition: testbed_api.c:2226
static void oprelease_shutdown_peers(void *cls)
Callback which will be called when shutdown peers operation is released.
Definition: testbed_api.c:2246
@ OP_SHUTDOWN_PEERS
Stop and destroy all peers.
Definition: testbed_api.h:99

References OperationContext::c, ShutdownPeersData::cb, ShutdownPeersData::cb_cls, OperationContext::data, 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().

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

◆ GNUNET_TESTBED_underlay_configure_link_va()

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

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

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

◆ GNUNET_TESTBED_underlay_configure_link()

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

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

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

Definition at line 839 of file testbed_api_peers.c.

844 {
845  GNUNET_break (0);
846  return NULL;
847 }

References GNUNET_break.

◆ 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 1265 of file testbed_api_topology.c.

1272 {
1273  GNUNET_break (0);
1274  return NULL;
1275 }

References GNUNET_break.

◆ 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 1290 of file testbed_api_topology.c.

1295 {
1296  GNUNET_break (0);
1297  return NULL;
1298 }

References GNUNET_break.

◆ GNUNET_TESTBED_overlay_connect()

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

Both peers must have been started before calling this function.

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

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

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

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

Definition at line 865 of file testbed_api_peers.c.

869 {
870  struct OperationContext *opc;
871  struct OverlayConnectData *data;
872 
874  p2->state));
876  data->p1 = p1;
877  data->p2 = p2;
878  data->cb = cb;
879  data->cb_cls = cb_cls;
880  opc = GNUNET_new (struct OperationContext);
881  opc->data = data;
882  opc->c = p1->controller;
883  opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
884  opc->type = OP_OVERLAY_CONNECT;
885  opc->op_cls = op_cls;
886  opc->op =
891  return opc->op;
892 }
Data structure for OperationType OP_OVERLAY_CONNECT.
void * cb_cls
The closure for the above callback.
struct GNUNET_TESTBED_Peer * p2
Peer B.
GNUNET_TESTBED_OperationCompletionCallback cb
The operation completion callback to call once this operation is done.
struct GNUNET_TESTBED_Peer * p1
Peer A to connect to peer B.
@ OP_OVERLAY_CONNECT
Overlay connection operation.
Definition: testbed_api.h:79
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.
static void opstart_overlay_connect(void *cls)
Function called when a overlay connect operation is ready.
static void oprelease_overlay_connect(void *cls)
Callback which will be called when overlay connect operation is released.

References OperationContext::c, OverlayConnectData::cb, OverlayConnectData::cb_cls, GNUNET_TESTBED_Peer::controller, OperationContext::data, 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 opstart_overlay_configure_topology(), and overlay_link_completed().

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 1322 of file testbed_api_topology.c.

1332 {
1333  struct TopologyContext *tc;
1334  struct TopologyContextOverlay *overlay;
1335  struct GNUNET_TESTBED_Operation *op;
1336  struct GNUNET_TESTBED_Controller *c;
1337  enum GNUNET_TESTBED_TopologyOption secondary_option;
1338 
1339  if (num_peers < 2)
1340  return NULL;
1341  c = peers[0]->controller;
1342  tc = GNUNET_new (struct TopologyContext);
1343  tc->type = TOPOLOGYCONTEXT_TYPE_OVERLAY;
1344  overlay = &tc->u.overlay;
1345  overlay->peers = peers;
1346  tc->num_peers = num_peers;
1347  overlay->op_cls = op_cls;
1348  overlay->retry_cnt = DEFAULT_RETRY_CNT;
1349  overlay->comp_cb = comp_cb;
1350  overlay->comp_cb_cls = comp_cb_cls;
1351  switch (topo)
1352  {
1354  gen_topo_line (tc);
1355  break;
1356 
1358  gen_topo_star (tc);
1359  break;
1360 
1362  gen_topo_ring (tc);
1363  break;
1364 
1366  gen_topo_random (tc, va_arg (va, unsigned int), GNUNET_NO);
1367  break;
1368 
1370  gen_topo_ring (tc);
1371  gen_topo_random (tc, va_arg (va, unsigned int), GNUNET_YES);
1372  break;
1373 
1375  gen_topo_clique (tc);
1376  break;
1377 
1379  gen_topo_2dtorus (tc);
1380  break;
1381 
1383  gen_topo_2dtorus (tc);
1384  gen_topo_random (tc, va_arg (va, unsigned int), GNUNET_YES);
1385 
1386  break;
1387 
1389  {
1390  uint16_t cap;
1391  uint8_t m;
1392 
1393  cap = (uint16_t) va_arg (va, unsigned int);
1394  m = (uint8_t) va_arg (va, unsigned int);
1395  gen_topo_scale_free (tc, cap, m);
1396  }
1397  break;
1398 
1400  {
1401  const char *filename;
1402 
1403  filename = va_arg (va, const char *);
1404 
1405  GNUNET_assert (NULL != filename);
1407  }
1408  break;
1409 
1410  default:
1411  GNUNET_break (0);
1412  GNUNET_free (tc);
1413  return NULL;
1414  }
1415  do
1416  {
1417  secondary_option = GNUNET_VA_ARG_ENUM (va, GNUNET_TESTBED_TopologyOption);
1418 
1419  switch (secondary_option)
1420  {
1422  overlay->retry_cnt = va_arg (va, unsigned int);
1423  break;
1424 
1426  break;
1427 
1428  default:
1429  GNUNET_break (0); /* Should not use any other option apart from
1430  * the ones handled here */
1431  GNUNET_free (overlay->link_array);
1432  GNUNET_free (tc);
1433  return NULL;
1434  }
1435  }
1436  while (GNUNET_TESTBED_TOPOLOGY_OPTION_END != secondary_option);
1444  "Generated %u connections\n",
1445  tc->link_array_size);
1446  if (NULL != max_connections)
1447  *max_connections = tc->link_array_size;
1448  return op;
1449 }
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct CadetPeer * peers
Operation to get peer ids.
static unsigned int num_peers
static unsigned long long max_connections
If there are at least this many connections, old ones will be removed.
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
GNUNET_TESTBED_TopologyOption
Topologies and topology options supported for testbeds.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:423
Opaque handle to an abstract operation to be executed by the testing framework.
Context information for overlay topologies.
struct GNUNET_TESTBED_Peer ** peers
The array of peers.
unsigned int retry_cnt
How many retries to do before we give up.
void * comp_cb_cls
The closure for the above callback.
struct OverlayLink * link_array
An array of links; this array is of size link_array_size.
void * op_cls
The operation closure.
GNUNET_TESTBED_TopologyCompletionCallback comp_cb
topology generation completion callback
Context information for topology operations.
#define DEFAULT_RETRY_CNT
Default number of retires.
static void gen_topo_scale_free(struct TopologyContext *tc, uint16_t cap, uint8_t m)
Generates scale free network.
static void gen_topo_line(struct TopologyContext *tc)
Generates line topology.
static void gen_topo_star(struct TopologyContext *tc)
Generates star topology.
static void gen_topo_from_file(struct TopologyContext *tc, const char *filename)
Generates topology from the given file.
static void opstart_overlay_configure_topology(void *cls)
Function called when a overlay connect operation is ready.
static void gen_topo_clique(struct TopologyContext *tc)
Generates clique topology.
static void gen_topo_random(struct TopologyContext *tc, unsigned int links, int append)
Generates ring topology.
static void oprelease_overlay_configure_topology(void *cls)
Callback which will be called when overlay connect operation is released.
#define LOG(kind,...)
Generic loggins shorthand.
static void gen_topo_2dtorus(struct TopologyContext *tc)
Generates ring topology.
static void gen_topo_ring(struct TopologyContext *tc)
Generates ring topology.

References TopologyContextOverlay::comp_cb, TopologyContextOverlay::comp_cb_cls, 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_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, LOG, m, max_connections, num_peers, op, TopologyContextOverlay::op_cls, GNUNET_TESTBED_Controller::opq_parallel_topology_config_operations, oprelease_overlay_configure_topology(), opstart_overlay_configure_topology(), peers, TopologyContextOverlay::peers, TopologyContextOverlay::retry_cnt, and tc.

Referenced by GNUNET_TESTBED_overlay_configure_topology().

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 1473 of file testbed_api_topology.c.

1483 {
1484  struct GNUNET_TESTBED_Operation *op;
1485  va_list vargs;
1486 
1488  va_start (vargs, topo);
1491  comp_cb, comp_cb_cls,
1492  topo,
1493  vargs);
1494  va_end (vargs);
1495  return op;
1496 }
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.

References GNUNET_assert, GNUNET_TESTBED_overlay_configure_topology_va(), GNUNET_TESTBED_TOPOLOGY_OPTION_END, max_connections, num_peers, op, and peers.

Referenced by event_cb().

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 1959 of file testbed_api.c.

1962 {
1963  GNUNET_break (0);
1964 }

References GNUNET_break.

◆ 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 257 of file testbed_api_services.c.

264 {
265  struct ServiceConnectData *data;
266 
268  data->ca = ca;
269  data->da = da;
270  data->cada_cls = cada_cls;
271  data->op_cls = op_cls;
272  data->peer = peer;
273  data->state = INIT;
274  data->cb = cb;
275  data->cb_cls = cb_cls;
276  data->operation =
280  controller->
281  opq_parallel_service_connections,
282  data->operation);
284  controller->opq_parallel_operations,
285  data->operation);
287  return data->operation;
288 }
Data accessed during service connections.
GNUNET_TESTBED_ConnectAdapter ca
helper function callback to establish the connection
GNUNET_TESTBED_ServiceConnectCompletionCallback cb
The operation completion callback.
GNUNET_TESTBED_DisconnectAdapter da
helper function callback to close the connection
void * op_cls
Closure for operation event.
void * cb_cls
The closure for operation completion callback.
void * cada_cls
Closure to the above callbacks.
@ INIT
Initial state.
static void opstart_service_connect(void *cls)
Function called when a service connect operation is ready.
static void oprelease_service_connect(void *cls)
Callback which will be called when service connect type operation is released.

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, oprelease_service_connect(), opstart_service_connect(), and peer.

Referenced by cadet_test_run(), connect_nse_service(), dht_test_run(), do_collect_stats(), 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().

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 2045 of file testbed_api.c.

2046 {
2047  (void) exop_check (operation);
2049 }
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:191
void GNUNET_TESTBED_operation_release_(struct GNUNET_TESTBED_Operation *op)
An operation is 'done' (was cancelled or finished); remove it from the queues and release associated ...

References exop_check(), and GNUNET_TESTBED_operation_release_().

Referenced by cancel_get(), churn_cb(), clean_peer(), close_monitor_connections(), 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(), 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_cb(), shutdown_op(), shutdown_task(), slave_event_cb(), statistics_done_cb(), stats_cb(), stats_cont(), and topology_completion_callback().

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 404 of file testbed_api_statistics.c.

410 {
411  struct GetStatsContext *sc;
412 
413  GNUNET_assert (NULL != proc);
414  GNUNET_assert (NULL != cont);
415  if (NULL == no_wait_queue)
417  (OPERATION_QUEUE_TYPE_FIXED, UINT_MAX);
418  sc = GNUNET_new (struct GetStatsContext);
419  sc->peers = peers;
420  sc->subsystem = (NULL == subsystem) ? NULL : GNUNET_strdup (subsystem);
421  sc->name = (NULL == name) ? NULL : GNUNET_strdup (name);
422  sc->proc = proc;
423  sc->cont = cont;
424  sc->cb_cls = cls;
425  sc->num_peers = num_peers;
426  sc->main_op =
431  return sc->main_op;
432 }
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
const char * name
Context information for use in GNUNET_TESTBED_get_statistics()
GNUNET_TESTBED_OperationCompletionCallback cont
The callback to call when we are done iterating through all peers' statistics services.
GNUNET_TESTBED_StatisticsIterator proc
The iterator to call with statistics information.
static void oprelease_get_stats(void *cls)
Function called when get_statistics operation is cancelled or marked as done.
static struct OperationQueue * no_wait_queue
A no-wait operation queue.
static void opstart_get_stats(void *cls)
Function called when get_statistics operation is ready.

References 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_(), name, no_wait_queue, num_peers, OPERATION_QUEUE_TYPE_FIXED, oprelease_get_stats(), opstart_get_stats(), peers, GetStatsContext::proc, sc, and subsystem.

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

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 2322 of file testbed_api.c.

2323 {
2324  return peer->unique_id;
2325 }

References peer, and GNUNET_TESTBED_Peer::unique_id.

Referenced by statistics_cb(), and stats_iterator().

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' (e.g. "(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' (e.g. "(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 1250 of file testbed_api_testbed.c.

1256 {
1257  struct GNUNET_TESTBED_RunHandle *rc;
1258  char *topology;
1259  struct CompatibilityCheckContext *hc;
1261  unsigned long long number;
1262  unsigned int hid;
1263  unsigned int nhost;
1264 
1265  GNUNET_assert (num_peers > 0);
1266  rc = GNUNET_new (struct GNUNET_TESTBED_RunHandle);
1268  if (NULL != host_filename)
1269  {
1270  rc->num_hosts =
1272  &rc->hosts);
1273  if (0 == rc->num_hosts)
1274  {
1276  _ ("No hosts loaded. Need at least one host\n"));
1277  goto error_cleanup;
1278  }
1279  }
1280  else
1281  rc->h = GNUNET_TESTBED_host_create (NULL, NULL, rc->cfg, 0);
1282  rc->num_peers = num_peers;
1283  rc->event_mask = event_mask;
1284  rc->cc = cc;
1285  rc->cc_cls = cc_cls;
1286  rc->test_master = test_master;
1287  rc->test_master_cls = test_master_cls;
1288  rc->state = RC_INIT;
1290  if (GNUNET_OK ==
1292  "OVERLAY_TOPOLOGY", &topology))
1293  {
1295  {
1298  "OVERLAY_TOPLOGY",
1299  _
1300  (
1301  "Specified topology must be supported by testbed"));
1302  }
1304  }
1305  switch (rc->topology)
1306  {
1310  if (GNUNET_OK !=
1312  "OVERLAY_RANDOM_LINKS",
1313  &number))
1314  {
1315  /* OVERLAY option RANDOM & SMALL_WORLD_RING requires OVERLAY_RANDOM_LINKS
1316  * option to be set to the number of random links to be established */
1319  "OVERLAY_RANDOM_LINKS");
1320  goto error_cleanup;
1321  }
1322  if (number > UINT32_MAX)
1323  {
1324  GNUNET_break (0); /* Too big number */
1325  goto error_cleanup;
1326  }
1327  rc->random_links = (unsigned int) number;
1328  break;
1329 
1331  if (GNUNET_OK !=
1334  "OVERLAY_TOPOLOGY_FILE",
1335  &rc->topo_file))
1336  {
1339  "OVERLAY_TOPOLOGY_FILE");
1340  goto error_cleanup;
1341  }
1342  goto warn_ignore;
1343 
1345  if (GNUNET_OK !=
1348  {
1351  SCALE_FREE_CAP);
1352  goto error_cleanup;
1353  }
1354  if (UINT16_MAX < number)
1355  {
1357  _ ("Maximum number of edges a peer can have in a scale free topology"
1358  " cannot be more than %u. Given `%s = %llu'"), UINT16_MAX,
1360  goto error_cleanup;
1361  }
1362  if (GNUNET_OK !=
1364  SCALE_FREE_M, &number))
1365  {
1368  SCALE_FREE_M);
1369  goto error_cleanup;
1370  }
1371  if (UINT8_MAX < number)
1372  {
1374  _ ("The number of edges that can established when adding a new node"
1375  " to scale free topology cannot be more than %u. Given `%s = %llu'"),
1376  UINT8_MAX, SCALE_FREE_M, number);
1377  goto error_cleanup;
1378  }
1379  goto warn_ignore;
1380 
1382  /* not allowed! */
1383  GNUNET_assert (0);
1384 
1385  default:
1386 warn_ignore:
1387  /* Warn if OVERLAY_RANDOM_LINKS is present that it will be ignored */
1388  if (GNUNET_YES ==
1390  "OVERLAY_RANDOM_LINKS"))
1392  "Ignoring value of `OVERLAY_RANDOM_LINKS' in given configuration\n");
1393  break;
1394  }
1395  if (0 != rc->num_hosts)
1396  {
1397  rc->hclist = GNUNET_malloc (sizeof(struct CompatibilityCheckContext)
1398  * rc->num_hosts);
1399  for (nhost = 0; nhost < rc->num_hosts; nhost++)
1400  {
1401  hc = &rc->hclist[nhost];
1402  hc->index = nhost;
1403  hc->rc = rc;
1404  hc->h = GNUNET_TESTBED_is_host_habitable (rc->hosts[nhost], rc->cfg,
1405  &host_habitable_cb, hc);
1406  if (NULL == hc->h)
1407  {
1408  GNUNET_break (0);
1409  for (nhost = 0; nhost < rc->num_hosts; nhost++)
1410  {
1411  hc = &rc->hclist[nhost];
1412  if (NULL != hc->h)
1414  }
1415  GNUNET_free (rc->hclist);
1416  rc->hclist = NULL;
1417  goto error_cleanup;
1418  }
1419  }
1420  }
1421  else
1422  rc->cproc =
1423  GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h,
1424  &controller_status_cb, rc);
1427  "SETUP_TIMEOUT",
1428  &timeout))
1429  {
1432  }
1434  rc->timeout_task =
1436  GNUNET_assert (NULL == rc->interrupt_task);
1437  rc->interrupt_task =
1439  rc);
1440  return;
1441 
1442 error_cleanup:
1443  if (NULL != rc->h)
1445  if (NULL != rc->hosts)
1446  {
1447  for (hid = 0; hid < rc->num_hosts; hid++)
1448  if (NULL != rc->hosts[hid])
1450  GNUNET_free (rc->hosts);
1451  }
1452  if (NULL != rc->cfg)
1454  GNUNET_free (rc);
1455 }
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
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.
static char * host_filename
Data file with the hosts for the testbed.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
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.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_ERROR
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,...
Definition: scheduler.c:1331
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.
void GNUNET_TESTBED_is_host_habitable_cancel(struct GNUNET_TESTBED_HostHabitableCheckHandle *handle)
Function to cancel a request started using GNUNET_TESTBED_is_host_habitable()
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.
void GNUNET_TESTBED_host_destroy(struct GNUNET_TESTBED_Host *host)
Destroy a host handle.
struct GNUNET_TESTBED_ControllerProc * GNUNET_TESTBED_controller_start(const char *trusted_ip, struct GNUNET_TESTBED_Host *host, GNUNET_TESTBED_ControllerStatusCallback cb, void *cls)
Starts a controller process at the given host.
#define GNUNET_TIME_UNIT_SECONDS
One second.
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:311
uint32_t number
Context for host compatibility checks.
struct GNUNET_TESTBED_HostHabitableCheckHandle * h
Handle for the compatibility check.
struct GNUNET_TESTBED_RunHandle * rc
The run context.
unsigned int index
Index of the host in the run context's hosts array.
GNUNET_TESTBED_ControllerCallback cc
The callback to use as controller callback.
void * test_master_cls
The closure for the TestMaster callback.
unsigned int num_hosts
Number of hosts in the given host file.
struct GNUNET_SCHEDULER_Task * interrupt_task
Task run upon shutdown interrupts.
GNUNET_TESTBED_TestMaster test_master
TestMaster callback to call when testbed initialization is done.
struct GNUNET_TESTBED_ControllerProc * cproc
The handle to the controller process.
struct CompatibilityCheckContext * hclist
Array of compatibility check contexts.
struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run of a timeout.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the controller.
void * cc_cls
The pointer to the controller callback.
unsigned int random_links
Number of random links to established.
struct GNUNET_TESTBED_Host ** hosts
An array of hosts loaded from the hostkeys file.
enum GNUNET_TESTBED_TopologyOption topology
The topology which has to be achieved with the peers started in this context.
uint64_t event_mask
The event mask for the controller.
struct GNUNET_CONTAINER_MultiHashMap32 * rcop_map
A hashmap for operations started by us.
unsigned int num_peers
number of peers to start
enum State state
State of this context.
struct GNUNET_TESTBED_Host * h
Handle to the host on which the controller runs.
char * topo_file
The file containing topology data.
Time for relative time used by GNUnet, in microseconds.
#define DEFAULT_SETUP_TIMEOUT
The default setup timeout in seconds.
static void controller_status_cb(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status)
Callback to signal successful startup of the controller process.
static void timeout_task(void *cls)
Task run upon timeout while setting up the testbed.
@ RC_INIT
Initial state.
#define TESTBED_CONFIG_SECTION
Configuration section for testbed.
#define SCALE_FREE_CAP
Option string for the maximum number of edges a peer is permitted to have while generating scale free...
#define LOG(kind,...)
Generic loggins shorthand.
static void interrupt(void *cls)
Task run upon interrupts (SIGINT, SIGTERM) and upon scheduler shutdown.
#define SCALE_FREE_M
Option string for the number of edges to be established when adding a new node to the scale free netw...
static void host_habitable_cb(void *cls, const struct GNUNET_TESTBED_Host *host, int status)
Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to inform whether the given hos...
int GNUNET_TESTBED_topology_get_(enum GNUNET_TESTBED_TopologyOption *topology, const char *topology_string)
Get a topology from a string input.

References _, GNUNET_TESTBED_RunHandle::cc, GNUNET_TESTBED_RunHandle::cc_cls, cfg, 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_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_filename, host_habitable_cb(), GNUNET_TESTBED_RunHandle::hosts, CompatibilityCheckContext::index, consensus-simulation::int, 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, CompatibilityCheckContext::rc, RC_INIT, GNUNET_TESTBED_RunHandle::rcop_map, SCALE_FREE_CAP, SCALE_FREE_M, GNUNET_TESTBED_RunHandle::state, test_master(), GNUNET_TESTBED_RunHandle::test_master, GNUNET_TESTBED_RunHandle::test_master_cls, TESTBED_CONFIG_SECTION, timeout, GNUNET_TESTBED_RunHandle::timeout_task, timeout_task(), GNUNET_TESTBED_RunHandle::topo_file, topology, and GNUNET_TESTBED_RunHandle::topology.

Referenced by run().

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

◆ GNUNET_TESTBED_test_run()

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

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 test is to be terminated using a call to "GNUNET_SCHEDULER_shutdown". If starting the test fails, the program is stopped without 'master' ever being run.

NOTE: this function should be called from 'main', NOT from within a GNUNET_SCHEDULER-loop. This function will initialize the scheduler loop, the testbed and then pass control to 'master'.

Parameters
testnamename of the testcase (to configure logging, etc.)
cfg_filenameconfiguration filename to use (for testbed, controller and peers)
num_peersnumber of peers to start; should be greter 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' (e.g. "(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.
Returns
GNUNET_SYSERR on error, GNUNET_OK on success

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 is to be terminated using a call to "GNUNET_SCHEDULER_shutdown". If starting the test fails, the program is stopped without 'master' ever being run.

NOTE: this function should be called from 'main', NOT from within a GNUNET_SCHEDULER-loop. This function will initialize the scheduler loop, the testbed and then pass control to 'master'.

Parameters
testnamename of the testcase (to configure logging, etc.)
cfg_filenameconfiguration filename to use (for testbed, controller and peers)
num_peersnumber of peers to 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' (e.g. "(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_mastertask to run once the test is ready
test_master_clsclosure for test_master
Returns
GNUNET_SYSERR on error, GNUNET_OK on success

Definition at line 123 of file testbed_api_test.c.

131 {
132  char *argv2[] = {
133  NULL,
134  "-c",
135  NULL,
136  NULL
137  };
140  };
141  struct TestRunContext *rc;
142  int ret;
143 
144  argv2[0] = GNUNET_strdup (testname);
145  argv2[2] = GNUNET_strdup (cfg_filename);
146  GNUNET_assert (NULL != test_master);
147  GNUNET_assert (num_peers > 0);
148 
149  char* envcfg = getenv(ENV_TESTBED_CONFIG);
150  setenv(ENV_TESTBED_CONFIG, cfg_filename, 1);
151 
152  rc = GNUNET_malloc (sizeof(struct TestRunContext)
153  + (num_peers * sizeof(struct GNUNET_TESTBED_Peer *)));
154  rc->test_master = test_master;
156  rc->num_peers = num_peers;
157  rc->event_mask = event_mask;
158  rc->cc = cc;
159  rc->cc_cls = cc_cls;
160  ret = GNUNET_PROGRAM_run ((sizeof(argv2) / sizeof(char *)) - 1, argv2,
161  testname, "nohelp", options, &run, rc);
162 
163  if (envcfg)
164  setenv(ENV_TESTBED_CONFIG, envcfg, 1);
165  else
166  unsetenv(ENV_TESTBED_CONFIG);
167 
168  GNUNET_free (rc);
169  GNUNET_free (argv2[0]);
170  GNUNET_free (argv2[2]);
171  return ret;
172 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
char * getenv()
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char * cfg_filename
Name of the configuration file.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:364
Definition of a command line option.
Context information for test run.
GNUNET_TESTBED_ControllerCallback cc
The controller event callback.
unsigned int num_peers
Number of peers to start.
void * test_master_cls
Closure for test master.
void * cc_cls
Closure for the above callback.
uint64_t event_mask
event mask for the controller callback
GNUNET_TESTBED_TestMaster test_master
Test master callback.
#define ENV_TESTBED_CONFIG
The environmental variable which when available refers to the configuration file the local testbed co...
Definition: testbed.h:776
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
Main run function.

References TestRunContext::cc, TestRunContext::cc_cls, cfg_filename, ENV_TESTBED_CONFIG, event_mask, TestRunContext::event_mask, getenv(), GNUNET_assert, GNUNET_free, GNUNET_GETOPT_OPTION_END, GNUNET_malloc, GNUNET_PROGRAM_run(), GNUNET_strdup, num_peers, TestRunContext::num_peers, options, ret, run(), test_master(), TestRunContext::test_master, and TestRunContext::test_master_cls.

Referenced by GNUNET_CADET_TEST_ruN(), GNUNET_DHT_TEST_run(), GNUNET_run_messenger_setup(), main(), and run().

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

◆ GNUNET_TESTBED_run_get_controller_handle()

struct GNUNET_TESTBED_Controller* GNUNET_TESTBED_run_get_controller_handle ( struct GNUNET_TESTBED_RunHandle h)

Obtain handle to the master controller from a testbed run.

The handle returned should not be disconnected.

Parameters
hthe testbed run handle
Returns
handle to the master controller

Definition at line 1466 of file testbed_api_testbed.c.

1467 {
1468  return h->c;
1469 }

References h.

◆ GNUNET_TESTBED_barrier_init()

struct GNUNET_TESTBED_Barrier* GNUNET_TESTBED_barrier_init ( struct GNUNET_TESTBED_Controller controller,
const char *  name,
unsigned int  quorum,
GNUNET_TESTBED_barrier_status_cb  cb,
void *  cls 
)

Initialise a barrier and call the given callback when the required percentage of peers (quorum) reach the barrier.

Parameters
controllerthe handle to the controller
nameidentification name of the barrier
quorumthe percentage of peers that is required to reach the barrier. Peers signal reaching a barrier by calling GNUNET_TESTBED_barrier_reached().
cbthe callback to call when the barrier is reached or upon error. Cannot be NULL.
cb_clsclosure for cb
Returns
barrier handle

Initialise a barrier and call the given callback when the required percentage of peers (quorum) reach the barrier.

Parameters
controllerthe handle to the controller
nameidentification name of the barrier
quorumthe percentage of peers that is required to reach the barrier. Peers signal reaching a barrier by calling GNUNET_TESTBED_barrier_reached().
cbthe callback to call when the barrier is reached or upon error. Cannot be NULL.
clsclosure for the above callback
Returns
barrier handle; NULL upon error

Definition at line 2438 of file testbed_api.c.

2443 {
2444  return GNUNET_TESTBED_barrier_init_ (controller,
2445  name,
2446  quorum,
2447  cb,
2448  cls,
2449  GNUNET_YES);
2450 }
struct GNUNET_TESTBED_Barrier * GNUNET_TESTBED_barrier_init_(struct GNUNET_TESTBED_Controller *controller, const char *name, unsigned int quorum, GNUNET_TESTBED_barrier_status_cb cb, void *cls, int echo)
Initialise a barrier and call the given callback when the required percentage of peers (quorum) reach...
Definition: testbed_api.c:2371

References GNUNET_TESTBED_Barrier::cb, GNUNET_TESTBED_Barrier::cls, GNUNET_TESTBED_barrier_init_(), GNUNET_YES, and name.

Here is the call graph for this function:

◆ GNUNET_TESTBED_barrier_cancel()

void GNUNET_TESTBED_barrier_cancel ( struct GNUNET_TESTBED_Barrier barrier)

Cancel a barrier.

Parameters
barrierthe barrier handle

Definition at line 2459 of file testbed_api.c.

2460 {
2461  struct GNUNET_MQ_Envelope *env;
2463  size_t slen;
2464 
2465  slen = strlen (barrier->name);
2466  env =
2468  GNUNET_memcpy (msg->name, barrier->name, slen);
2469  GNUNET_MQ_send (barrier->c->mq, env);
2471 }
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL
Message to cancel a barrier.
Message to cancel a barrier.
Definition: testbed.h:805
struct GNUNET_TESTBED_Controller * c
The controller handle given while initialising this barrier.
Definition: testbed_api.h:287
char * name
The name of the barrier.
Definition: testbed_api.h:292
void GNUNET_TESTBED_barrier_remove_(struct GNUNET_TESTBED_Barrier *barrier)
Remove a barrier and it was the last one in the barrier hash map, destroy the hash map.
Definition: testbed_api.c:2335

References GNUNET_TESTBED_Barrier::c, env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TESTBED_barrier_remove_(), GNUNET_TESTBED_Controller::mq, msg, and GNUNET_TESTBED_Barrier::name.

Referenced by cancel_wrappers().

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

◆ GNUNET_TESTBED_barrier_wait()

struct GNUNET_TESTBED_BarrierWaitHandle* GNUNET_TESTBED_barrier_wait ( const char *  name,
GNUNET_TESTBED_barrier_wait_cb  cb,
void *  cb_cls 
)

Wait for a barrier to be crossed.

This function should be called by the peers which have been started by the testbed. If the peer is not started by testbed this function may return error

Parameters
namethe name of the barrier
cbthe barrier wait callback
clsthe closure for the above callback
Returns
barrier wait handle which can be used to cancel the waiting at anytime before the callback is called. NULL upon error.

This function should be called by the peers which have been started by the testbed. If the peer is not started by testbed this function may return error

Parameters
namethe name of the barrier
cbthe barrier wait callback
cb_clsthe closure for cb
Returns
barrier wait handle which can be used to cancel the waiting at anytime before the callback is called. NULL upon error.

Definition at line 175 of file testbed_api_barriers.c.

178 {
185  h),
187  };
188  struct GNUNET_MQ_Envelope *env;
190  const char *cfg_filename;
191  size_t name_len;
192 
193  GNUNET_assert (NULL != cb);
195  if (NULL == cfg_filename)
196  {
198  "Are you running under testbed?\n");
199  GNUNET_free (h);
200  return NULL;
201  }
203  if (GNUNET_OK !=
205  cfg_filename))
206  {
208  "Unable to load configuration from file `%s'\n",
209  cfg_filename);
211  GNUNET_free (h);
212  return NULL;
213  }
215  "Waiting on barrier `%s'\n",
216  name);
217  h->name = GNUNET_strdup (name);
218  h->cb = cb;
219  h->cb_cls = cb_cls;
221  "testbed-barrier",
222  handlers,
224  h);
225  if (NULL == h->mq)
226  {
228  "Unable to connect to local testbed-barrier service\n");
230  return NULL;
231  }
232  name_len = strlen (name); /* NOTE: unusual to not have 0-termination, change? */
234  name_len,
236  GNUNET_memcpy (msg->name,
237  name,
238  name_len);
239  GNUNET_MQ_send (h->mq,
240  env);
241  return h;
242 }
uint16_t status
See PRISM_STATUS_*-constants.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT
Message sent by a peer when it has reached a barrier and is waiting for it to be crossed.
void GNUNET_TESTBED_barrier_wait_cancel(struct GNUNET_TESTBED_BarrierWaitHandle *h)
Cancel a barrier wait handle.
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Message sent from peers to the testbed-barrier service to indicate that they have reached a barrier a...
Definition: testbed.h:851
#define LOG(type,...)
Logging shorthand.
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...

References GNUNET_ARM_Handle::cfg, cfg_filename, env, ENV_TESTBED_CONFIG, getenv(), GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_load(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_TESTBED_barrier_wait_cancel(), h, handlers, LOG, GNUNET_ARM_Handle::mq, mq_error_handler(), msg, name, and status.

Referenced by do_wait().

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

◆ GNUNET_TESTBED_barrier_wait_cancel()

void GNUNET_TESTBED_barrier_wait_cancel ( struct GNUNET_TESTBED_BarrierWaitHandle h)

Cancel a barrier wait handle.

Should not be called in or after the callback given to GNUNET_TESTBED_barrier_wait() has been called.

Parameters
hthe barrier wait handle
hthe barrier wait handle

Definition at line 251 of file testbed_api_barriers.c.

252 {
253  if (NULL != h->mq)
254  {
256  h->mq = NULL;
257  }
258  GNUNET_free (h->name);
260  GNUNET_free (h);
261 }

References GNUNET_ARM_Handle::cfg, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_MQ_destroy(), h, and GNUNET_ARM_Handle::mq.

Referenced by do_shutdown(), GNUNET_TESTBED_barrier_wait(), handle_status(), and mq_error_handler().

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

◆ GNUNET_TESTBED_underlaylinkmodel_create()

struct GNUNET_TESTBED_UnderlayLinkModel* GNUNET_TESTBED_underlaylinkmodel_create ( struct GNUNET_TESTBED_Peer peer,
enum GNUNET_TESTBED_UnderlayLinkModelType  type 
)

Create a GNUNET_TESTBED_UnderlayLinkModel for the given peer.

A peer can have ONLY ONE model and it can be either a blacklist or whitelist based one.

Parameters
peerthe peer for which the model has to be created
typethe type of the model
Returns
the model

Definition at line 153 of file testbed_api_underlay.c.

157 {
159 
163  m->type = type;
164  return m;
165 }
uint8_t underlay_model_exists
Has an underlay model already set for this peer?
Model for configuring underlay links of a peer.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

References GNUNET_assert, GNUNET_new, m, peer, type, and GNUNET_TESTBED_Peer::underlay_model_exists.

◆ GNUNET_TESTBED_underlaylinkmodel_add_peer()

void GNUNET_TESTBED_underlaylinkmodel_add_peer ( struct GNUNET_TESTBED_UnderlayLinkModel model,
struct GNUNET_TESTBED_Peer peer 
)

Add a peer to the given model.

Underlay connections to the given peer will be permitted if the model is whitelist based; otherwise they will not be permitted.

Parameters
modelthe model
peerthe peer to add

Definition at line 178 of file testbed_api_underlay.c.

182 {
183  struct ListEntry *entry;
184 
185  entry = GNUNET_new (struct ListEntry);
186  entry->peer = peer;
187  entry->next = model->entries;
188  model->entries = entry;
189 }
struct ListEntry * entries
List of peers in the list.
Container for holding a peer in whitelist/blacklist.
struct GNUNET_TESTBED_Peer * peer
the peer
struct ListEntry * next
the next pointer

References GNUNET_TESTBED_UnderlayLinkModel::entries, GNUNET_new, ListEntry::next, ListEntry::peer, and peer.

◆ GNUNET_TESTBED_underlaylinkmodel_set_link()

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.

The link SHOULD be permittable according to the given model.

Parameters
modelthe model
peerthe other end peer of the link
latencylatency of the link in microseconds
lossdata loss of the link expressed as a percentage
bandwidthbandwidth of the link in kilobytes per second [kB/s]

Definition at line 204 of file testbed_api_underlay.c.

211 {
212  struct LinkProperty *prop;
213 
214  prop = GNUNET_new (struct LinkProperty);
215  prop->peer = peer;
216  prop->latency = latency;
217  prop->loss = loss;
218  prop->bandwidth = bandwidth;
219  prop->next = model->props;
220  model->props = prop;
221 }
struct LinkProperty * props
list of link properties
An underlay link.
uint32_t bandwidth
bandwidth of the link in kilobytes per second
struct LinkProperty * next
next pointer for list
uint32_t latency
latency of the link in microseconds
uint32_t loss
data loss on the link expressed as percentage
struct GNUNET_TESTBED_Peer * peer
the peer whose link is defined by these properties

References LinkProperty::bandwidth, GNUNET_new, LinkProperty::latency, LinkProperty::loss, LinkProperty::next, LinkProperty::peer, peer, and GNUNET_TESTBED_UnderlayLinkModel::props.

◆ GNUNET_TESTBED_underlaylinkmodel_commit()

void GNUNET_TESTBED_underlaylinkmodel_commit ( struct GNUNET_TESTBED_UnderlayLinkModel model)

Commit the model.

The model is freed in this function(!).

Parameters
modelthe model to commit

Definition at line 250 of file testbed_api_underlay.c.

252 {
253  /* FIXME: Marshal the model into a message */
254  GNUNET_break (0);
255  /* do not reset the value of model->peer->underlay_model_exists */
256  free_entries (model);
257  free_link_properties (model);
258  GNUNET_free (model);
259 }
struct GNUNET_TESTBED_UnderlayLinkModel free_entries(struct GNUNET_TESTBED_UnderlayLinkModel *model)
Function to free resources of list entries.
static void free_link_properties(struct GNUNET_TESTBED_UnderlayLinkModel *model)
Function to free resources of link properties added to the given model.

References free_entries(), free_link_properties(), GNUNET_break, and GNUNET_free.

Here is the call graph for this function:

◆ GNUNET_TESTBED_underlaylinkmodel_free()

void GNUNET_TESTBED_underlaylinkmodel_free ( struct GNUNET_TESTBED_UnderlayLinkModel model)

Free the resources of the model.

Use this function only if the model has not be committed and has to be unallocated. The peer can then have another model created.

Parameters
modelthe model to unallocate

Definition at line 233 of file testbed_api_underlay.c.

235 {
236  model->peer->underlay_model_exists = 0;
237  free_entries (model);
238  free_link_properties (model);
239  gnunet_free (model);
240 }
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References free_entries(), free_link_properties(), GNUNET_TESTBED_UnderlayLinkModel::peer, and GNUNET_TESTBED_Peer::underlay_model_exists.

Here is the call graph for this function: