Interface for functions internally exported from testbed_api.c. More...
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "testbed.h"
#include "testbed_helper.h"
Go to the source code of this file.
Data Structures | |
struct | OperationContext |
Context information for GNUNET_TESTBED_Operation. More... | |
struct | GNUNET_TESTBED_Controller |
Handle to interact with a GNUnet testbed controller. More... | |
struct | GNUNET_TESTBED_Barrier |
Handle for barrier. More... | |
Macros | |
#define | HELPER_TESTBED_BINARY "gnunet-helper-testbed" |
Testbed Helper binary name. More... | |
Typedefs | |
typedef void(* | TESTBED_opcq_empty_cb) (void *cls) |
Operation empty callback. More... | |
Enumerations | |
enum | OperationType { SOLVER_OP_ADD_ADDRESS , SOLVER_OP_DEL_ADDRESS , SOLVER_OP_START_SET_PROPERTY , SOLVER_OP_STOP_SET_PROPERTY , SOLVER_OP_START_SET_PREFERENCE , SOLVER_OP_STOP_SET_PREFERENCE , SOLVER_OP_START_REQUEST , SOLVER_OP_STOP_REQUEST , OP_PEER_CREATE , OP_PEER_START , OP_PEER_STOP , OP_PEER_DESTROY , OP_PEER_INFO , OP_PEER_RECONFIGURE , OP_OVERLAY_CONNECT , OP_FORWARDED , OP_LINK_CONTROLLERS , OP_GET_SLAVE_CONFIG , OP_SHUTDOWN_PEERS , OP_MANAGE_SERVICE } |
Enumeration of operations. More... | |
enum | OperationContextState { OPC_STATE_INIT = 0 , OPC_STATE_STARTED , OPC_STATE_FINISHED } |
Enumeration of states of OperationContext. More... | |
Functions | |
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. More... | |
void | GNUNET_TESTBED_insert_opc_ (struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc) |
Inserts the given operation context into the operation context map of the given controller. More... | |
void | GNUNET_TESTBED_remove_opc_ (const struct GNUNET_TESTBED_Controller *c, struct OperationContext *opc) |
Removes the given operation context from the operation context map of the given controller. More... | |
size_t | GNUNET_TESTBED_compress_config_ (const char *config, size_t size, char **xconfig) |
Compresses given configuration using zlib compress. More... | |
char * | GNUNET_TESTBED_compress_cfg_ (const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size, size_t *xsize) |
Function to serialize and compress using zlib a configuration through a configuration handle. More... | |
struct GNUNET_TESTBED_HelperInit * | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, const char *hostname, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Creates a helper initialization message. More... | |
struct OperationContext * | GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller *controller, uint64_t operation_id, const struct GNUNET_MessageHeader *msg, GNUNET_MQ_MessageCallback cc, void *cc_cls) |
Sends the given message as an operation. More... | |
void | GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc) |
Function to cancel an operation created by simply forwarding an operation message. More... | |
struct GNUNET_CONFIGURATION_Handle * | GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg) |
Generates configuration by uncompressing configuration in given message. More... | |
const char * | GNUNET_TESTBED_parse_error_string_ (const struct GNUNET_TESTBED_OperationFailureEventMessage *msg) |
Checks the integrity of the OpeationFailureEventMessage and if good returns the error message it contains. More... | |
uint64_t | GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller) |
Function to return the operation id for a controller. More... | |
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. More... | |
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 the barrier OR upon error. More... | |
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. More... | |
Interface for functions internally exported from testbed_api.c.
Definition in file testbed_api.h.
#define HELPER_TESTBED_BINARY "gnunet-helper-testbed" |
Testbed Helper binary name.
Definition at line 38 of file testbed_api.h.
typedef void(* TESTBED_opcq_empty_cb) (void *cls) |
enum OperationType |
Enumeration of operations.
Enumerator | |
---|---|
SOLVER_OP_ADD_ADDRESS | |
SOLVER_OP_DEL_ADDRESS | |
SOLVER_OP_START_SET_PROPERTY | |
SOLVER_OP_STOP_SET_PROPERTY | |
SOLVER_OP_START_SET_PREFERENCE | |
SOLVER_OP_STOP_SET_PREFERENCE | |
SOLVER_OP_START_REQUEST | |
SOLVER_OP_STOP_REQUEST | |
OP_PEER_CREATE | Peer create operation. |
OP_PEER_START | Peer start operation. |
OP_PEER_STOP | Peer stop operation. |
OP_PEER_DESTROY | Peer destroy operation. |
OP_PEER_INFO | Get peer information operation. |
OP_PEER_RECONFIGURE | Reconfigure a peer. |
OP_OVERLAY_CONNECT | Overlay connection operation. |
OP_FORWARDED | Forwarded operation. |
OP_LINK_CONTROLLERS | Link controllers operation. |
OP_GET_SLAVE_CONFIG | Get slave config operation. |
OP_SHUTDOWN_PEERS | Stop and destroy all peers. |
OP_MANAGE_SERVICE | Start/stop service at a peer. |
Definition at line 44 of file testbed_api.h.
Enumeration of states of OperationContext.
Definition at line 111 of file testbed_api.h.
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.
controller | the handle to the controller |
msg | the message to queue |
controller | the handle to the controller |
msg | the message to queue |
Definition at line 1336 of file testbed_api.c.
References env, GNUNET_assert, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_INIT, GNUNET_MESSAGE_TYPE_TESTBED_MAX, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TESTBED_Controller::mq, msg, GNUNET_MessageHeader::size, size, GNUNET_MessageHeader::type, and type.
Referenced by GNUNET_TESTBED_register_host(), handle_barrier_status(), handle_remote_overlay_connect(), opstart_get_slave_config(), opstart_link_controllers(), opstart_peer_getinfo(), and send_hello_thru_rocc().
void GNUNET_TESTBED_insert_opc_ | ( | struct GNUNET_TESTBED_Controller * | c, |
struct OperationContext * | opc | ||
) |
Inserts the given operation context into the operation context map of the given controller.
Creates the operation context map if one does not exist for the controller
c | the controller |
opc | the operation context to be inserted |
Definition at line 298 of file testbed_api.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_create(), GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_OK, OperationContext::id, SearchContext::opc, and GNUNET_TESTBED_Controller::opc_map.
Referenced by GNUNET_TESTBED_forward_operation_msg_(), opstart_get_slave_config(), opstart_link_controllers(), opstart_manage_service(), opstart_overlay_connect(), opstart_peer_create(), opstart_peer_destroy(), opstart_peer_getinfo(), opstart_peer_reconfigure(), opstart_peer_start(), opstart_peer_stop(), and opstart_shutdown_peers().
void GNUNET_TESTBED_remove_opc_ | ( | const struct GNUNET_TESTBED_Controller * | c, |
struct OperationContext * | opc | ||
) |
Removes the given operation context from the operation context map of the given controller.
c | the controller |
opc | the operation context to remove |
Definition at line 319 of file testbed_api.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_CONTAINER_multihashmap32_size(), GNUNET_YES, OperationContext::id, SearchContext::opc, GNUNET_TESTBED_Controller::opc_map, GNUNET_TESTBED_Controller::opcq_empty_cb, and GNUNET_TESTBED_Controller::opcq_empty_cls.
Referenced by GNUNET_TESTBED_forward_operation_msg_cancel_(), handle_forwarded_operation_msg(), handle_link_controllers_result(), handle_op_fail_event(), handle_opsuccess(), handle_peer_conevent(), handle_peer_config(), handle_peer_create_success(), handle_peer_event(), handle_slave_config(), oprelease_get_slave_config(), oprelease_link_controllers(), oprelease_manage_service(), oprelease_overlay_connect(), oprelease_peer_create(), oprelease_peer_destroy(), oprelease_peer_getinfo(), oprelease_peer_reconfigure(), oprelease_peer_start(), oprelease_peer_stop(), and oprelease_shutdown_peers().
size_t GNUNET_TESTBED_compress_config_ | ( | const char * | config, |
size_t | size, | ||
char ** | xconfig | ||
) |
Compresses given configuration using zlib compress.
config | the serialized configuration |
size | the size of config |
xconfig | will be set to the compressed configuration (memory is fresly allocated) |
Definition at line 1758 of file testbed_api.c.
References config, GNUNET_assert, GNUNET_malloc, and size.
Referenced by GNUNET_TESTBED_compress_cfg_(), GNUNET_TESTBED_create_helper_init_msg_(), GNUNET_TESTBED_register_host(), handle_peer_get_config(), handle_slave_get_config(), opstart_peer_create(), opstart_peer_reconfigure(), and tokenizer_cb().
char* GNUNET_TESTBED_compress_cfg_ | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
size_t * | size, | ||
size_t * | xsize | ||
) |
Function to serialize and compress using zlib a configuration through a configuration handle.
cfg | the configuration |
size | the size of configuration when serialize. Will be set on success. |
xsize | the sizeo of the compressed configuration. Will be set on success. |
Definition at line 1785 of file testbed_api.c.
References cfg, config, GNUNET_CONFIGURATION_serialize(), GNUNET_free, GNUNET_TESTBED_compress_config_(), and size.
Referenced by send_controller_link_response().
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.
This function is here because we want to use this in testing
trusted_ip | the 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. |
hostname | the hostname of the destination this message is intended for |
cfg | the configuration that has to used to start the testbed service thru helper |
This function is here because we want to use this in testing
trusted_ip | the ip address of the controller which will be set as TRUSTED HOST(all connections from 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. |
hostname | the hostname of the destination this message is intended for |
cfg | the configuration that has to used to start the testbed service thru helper |
Definition at line 1957 of file testbed_api.c.
References cfg, config, GNUNET_TESTBED_HelperInit::config_size, GNUNET_assert, GNUNET_CONFIGURATION_serialize(), GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT, GNUNET_realloc, GNUNET_TESTBED_compress_config_(), hostname, msg, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by GNUNET_TESTBED_controller_start().
struct OperationContext* GNUNET_TESTBED_forward_operation_msg_ | ( | struct GNUNET_TESTBED_Controller * | controller, |
uint64_t | operation_id, | ||
const struct GNUNET_MessageHeader * | msg, | ||
GNUNET_MQ_MessageCallback | cc, | ||
void * | cc_cls | ||
) |
Sends the given message as an operation.
The given callback is called when a reply for the operation is available. Call GNUNET_TESTBED_forward_operation_msg_cancel_() to cleanup the returned operation context if the cc hasn't been called
controller | the controller to which the message has to be sent |
operation_id | the operation id of the message |
msg | the message to send |
cc | the callback to call when reply is available |
cc_cls | the closure for the above callback |
Definition at line 1370 of file testbed_api.c.
References OperationContext::c, OperationContext::data, data, env, GNUNET_memcpy, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_TESTBED_insert_opc_(), OperationContext::id, GNUNET_TESTBED_Controller::mq, msg, OP_FORWARDED, GNUNET_MessageHeader::size, size, GNUNET_MessageHeader::type, OperationContext::type, and type.
Referenced by forward_overlay_connect(), GST_process_next_focc(), handle_manage_peer_service(), handle_peer_create(), handle_peer_destroy(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), handle_shutdown_peers(), opstart_service_connect(), and p2_controller_connect_cb().
void GNUNET_TESTBED_forward_operation_msg_cancel_ | ( | struct OperationContext * | opc | ) |
Function to cancel an operation created by simply forwarding an operation message.
opc | the operation context from GNUNET_TESTBED_forward_operation_msg_() |
Definition at line 1407 of file testbed_api.c.
References OperationContext::c, OperationContext::data, GNUNET_free, and GNUNET_TESTBED_remove_opc_().
Referenced by cleanup_occ_rp2c(), GST_clear_fopcq(), GST_forwarded_operation_timeout(), and oprelease_service_connect().
struct GNUNET_CONFIGURATION_Handle* GNUNET_TESTBED_extract_config_ | ( | const struct GNUNET_MessageHeader * | msg | ) |
Generates configuration by uncompressing configuration in given message.
The given message should be of the following types: #GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG, #GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG
msg | the message containing compressed configuration |
The given message should be of the following types: GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT,
FIXME: This API is incredibly ugly.
msg | the message containing compressed configuration |
Definition at line 2043 of file testbed_api.c.
References cfg, GNUNET_TESTBED_AddHostMessage::config_size, GNUNET_TESTBED_ControllerLinkResponse::config_size, GNUNET_TESTBED_PeerCreateMessage::config_size, GNUNET_TESTBED_PeerReconfigureMessage::config_size, GNUNET_TESTBED_PeerConfigurationInformationMessage::config_size, GNUNET_TESTBED_SlaveConfiguration::config_size, data, GNUNET_assert, GNUNET_break_op, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_deserialize(), GNUNET_free, GNUNET_malloc, GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER, GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT, GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER, GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, GNUNET_OK, GNUNET_TESTBED_AddHostMessage::header, GNUNET_TESTBED_ControllerLinkResponse::header, GNUNET_TESTBED_PeerCreateMessage::header, GNUNET_TESTBED_PeerReconfigureMessage::header, GNUNET_TESTBED_PeerConfigurationInformationMessage::header, GNUNET_TESTBED_SlaveConfiguration::header, GNUNET_TESTBED_AddHostMessage::hostname_length, msg, ret, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and GNUNET_TESTBED_AddHostMessage::username_length.
Referenced by configuration_receiver(), handle_add_host(), handle_link_controllers_result(), handle_peer_config(), handle_peer_create(), handle_peer_reconfigure(), and handle_slave_config().
const char* GNUNET_TESTBED_parse_error_string_ | ( | const struct GNUNET_TESTBED_OperationFailureEventMessage * | msg | ) |
Checks the integrity of the OpeationFailureEventMessage and if good returns the error message it contains.
msg | the OperationFailureEventMessage |
Definition at line 2150 of file testbed_api.c.
References GNUNET_break, msg, and GNUNET_MessageHeader::size.
Referenced by configuration_receiver(), and handle_op_fail_event().
uint64_t GNUNET_TESTBED_get_next_op_id | ( | struct GNUNET_TESTBED_Controller * | controller | ) |
Function to return the operation id for a controller.
The operation id is created from the controllers host id and its internal operation counter.
controller | the handle to the controller whose operation id has to be incremented |
Definition at line 2178 of file testbed_api.c.
References GNUNET_TESTBED_host_get_id_(), GNUNET_TESTBED_Controller::host, and GNUNET_TESTBED_Controller::operation_counter.
Referenced by GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_get_slave_config_(), GNUNET_TESTBED_overlay_connect(), GNUNET_TESTBED_peer_create(), GNUNET_TESTBED_peer_destroy(), GNUNET_TESTBED_peer_get_information(), GNUNET_TESTBED_peer_manage_service(), GNUNET_TESTBED_peer_start(), GNUNET_TESTBED_peer_stop(), GNUNET_TESTBED_peer_update_configuration(), GNUNET_TESTBED_shutdown_peers(), and opstart_service_connect().
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.
Another difference is that this function takes the id of the slave host.
op_cls | the closure for the operation |
master | the handle to master controller |
slave_host_id | id of the host where the slave controller is running to the slave_host should remain valid until this operation is cancelled or marked as finished |
Definition at line 1894 of file testbed_api.c.
References OperationContext::c, 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_GET_SLAVE_CONFIG, OPC_STATE_INIT, GNUNET_TESTBED_Controller::opq_parallel_operations, oprelease_get_slave_config(), opstart_get_slave_config(), OperationContext::state, and OperationContext::type.
Referenced by GNUNET_TESTBED_get_slave_config().
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 the barrier OR upon error.
controller | the handle to the controller |
name | identification name of the barrier |
quorum | the percentage of peers that is required to reach the barrier. Peers signal reaching a barrier by calling GNUNET_TESTBED_barrier_reached(). |
cb | the callback to call when the barrier is reached or upon error. Cannot be NULL. |
cls | closure for the above callback |
echo | GNUNET_YES to echo the barrier crossed status message back to the controller |
Definition at line 2324 of file testbed_api.c.
References GNUNET_TESTBED_Controller::barrier_map, GNUNET_TESTBED_Barrier::c, GNUNET_TESTBED_Barrier::cb, GNUNET_TESTBED_Barrier::cls, echo, GNUNET_TESTBED_Barrier::echo, env, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_YES, key, GNUNET_TESTBED_Barrier::key, LOG_DEBUG, GNUNET_TESTBED_Controller::mq, msg, name, and GNUNET_TESTBED_Barrier::name.
Referenced by GNUNET_TESTBED_barrier_init(), and handle_barrier_init().
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.
barrier | the barrier to remove |
Definition at line 2304 of file testbed_api.c.
References GNUNET_TESTBED_Controller::barrier_map, GNUNET_TESTBED_Barrier::c, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_free, GNUNET_OK, GNUNET_TESTBED_Barrier::key, and GNUNET_TESTBED_Barrier::name.
Referenced by GNUNET_TESTBED_barrier_cancel(), and handle_barrier_status().