Go to the source code of this file.
Data Structures | |
struct | GNUNET_TESTBED_System |
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths and ports. More... | |
struct | UpdateContext |
Closure for iterator for updating. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__) |
#define | LOW_PORT 12000 |
Lowest port used for GNUnet testing. More... | |
#define | HIGH_PORT 56000 |
Highest port used for GNUnet testing. More... | |
Functions | |
struct GNUNET_TESTBED_System * | GNUNET_TESTBED_system_create_with_portrange (const char *testdir, const char *trusted_ip, const char *hostname, uint16_t lowport, uint16_t highport) |
Create a system handle. More... | |
struct GNUNET_TESTBED_System * | GNUNET_TESTBED_system_create (const char *testdir, const char *trusted_ip, const char *hostname) |
Create a system handle. More... | |
void | GNUNET_TESTBED_system_destroy (struct GNUNET_TESTBED_System *system, bool remove_paths) |
Free system resources. More... | |
uint16_t | GNUNET_TESTBED_reserve_port (struct GNUNET_TESTBED_System *system) |
Reserve a TCP or UDP port for a peer. More... | |
void | GNUNET_TESTBED_release_port (struct GNUNET_TESTBED_System *system, uint16_t port) |
Release reservation of a TCP or UDP port for a peer (used during #GNUNET_TESTBED_peer_destroy()). More... | |
static void | update_config (void *cls, const char *section, const char *option, const char *value) |
Function to iterate over options. More... | |
static void | update_config_sections (void *cls, const char *section) |
Section iterator to set ACCEPT_FROM/ACCEPT_FROM6 to include the address of 'trusted_hosts' in all sections. More... | |
enum GNUNET_GenericReturnValue | GNUNET_TESTBED_configuration_create (struct GNUNET_TESTBED_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t **ports, unsigned int *nports) |
Create a new configuration using the given configuration as a template; ports and paths will be modified to select available ports on the local system. More... | |
Definition in file testbed.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "testing-api", __VA_ARGS__) |
#define LOW_PORT 12000 |
#define HIGH_PORT 56000 |
struct GNUNET_TESTBED_System * GNUNET_TESTBED_system_create_with_portrange | ( | const char * | testdir, |
const char * | trusted_ip, | ||
const char * | hostname, | ||
uint16_t | lowport, | ||
uint16_t | highport | ||
) |
Create a system handle.
There must only be one system handle per operating system.
testdir | only the directory name without any path. This is used for all service homes; the directory will be created in a temporary location depending on the underlying OS. This variable will be overridden with the value of the environmental variable GNUNET_TESTBED_PREFIX, if it exists. |
trusted_ip | the ip address which will be set as TRUSTED HOST in all service configurations generated to allow control connections from this ip. This can either be a single ip address or a network address in CIDR notation. |
hostname | the hostname of the system we are using for testing; NULL for localhost |
lowport | lowest port number this system is allowed to allocate (inclusive) |
highport | highest port number this system is allowed to allocate (exclusive) |
Definition at line 105 of file testbed.c.
References getenv(), GNUNET_assert, GNUNET_DISK_mkdtemp(), GNUNET_free, GNUNET_new, GNUNET_strdup, GNUNET_TESTBED_PREFIX, GNUNET_TESTBED_System::highport, GNUNET_TESTBED_System::hostname, GNUNET_TESTBED_System::lowport, GNUNET_TESTBED_System::tmppath, and GNUNET_TESTBED_System::trusted_ip.
Referenced by GNUNET_TESTBED_system_create().
struct GNUNET_TESTBED_System * GNUNET_TESTBED_system_create | ( | const char * | testdir, |
const char * | trusted_ip, | ||
const char * | hostname | ||
) |
Create a system handle.
There must only be one system handle per operating system. Uses a default range for allowed ports. Ports are still tested for availability.
testdir | only the directory name without any path. This is used for all service homes; the directory will be created in a temporary location depending on the underlying OS. This variable will be overridden with the value of the environmental variable GNUNET_TESTBED_PREFIX, if it exists. |
trusted_ip | the ip address which will be set as TRUSTED HOST in all service configurations generated to allow control connections from this ip. This can either be a single ip address or a network address in CIDR notation. |
hostname | the hostname of the system we are using for testing; NULL for localhost |
shared_services | NULL terminated array describing services that are to be shared among peers |
Definition at line 136 of file testbed.c.
References GNUNET_TESTBED_system_create_with_portrange(), HIGH_PORT, GNUNET_TESTBED_System::hostname, LOW_PORT, and GNUNET_TESTBED_System::trusted_ip.
Referenced by create_unique_cfgs(), and system_create_run().
void GNUNET_TESTBED_system_destroy | ( | struct GNUNET_TESTBED_System * | system, |
bool | remove_paths | ||
) |
Free system resources.
system | system to be freed |
remove_paths | should the 'testdir' and all subdirectories be removed (clean up on shutdown)? |
Definition at line 150 of file testbed.c.
References GNUNET_DISK_directory_remove(), GNUNET_free, GNUNET_TESTBED_System::hostname, GNUNET_TESTBED_System::tmppath, and GNUNET_TESTBED_System::trusted_ip.
Referenced by create_unique_cfgs(), and system_create_cleanup().
uint16_t GNUNET_TESTBED_reserve_port | ( | struct GNUNET_TESTBED_System * | system | ) |
Reserve a TCP or UDP port for a peer.
system | system to use for reservation tracking |
Definition at line 163 of file testbed.c.
References ai, AI_NUMERICSERV, GNUNET_asprintf(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_NO, GNUNET_OK, GNUNET_TESTBED_System::highport, LOG, GNUNET_TESTBED_System::lowport, GNUNET_TESTBED_System::reserved_ports, and ret.
Referenced by update_config().
void GNUNET_TESTBED_release_port | ( | struct GNUNET_TESTBED_System * | system, |
uint16_t | port | ||
) |
Release reservation of a TCP or UDP port for a peer (used during #GNUNET_TESTBED_peer_destroy()).
system | system to use for reservation tracking |
port | reserved port to release |
Definition at line 252 of file testbed.c.
References GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, LOG, port, and GNUNET_TESTBED_System::reserved_ports.
|
static |
Function to iterate over options.
Copies the options to the target configuration, updating PORT values as needed.
cls | the UpdateContext |
section | name of the section |
option | name of the option |
value | value of the option |
Definition at line 323 of file testbed.c.
References GNUNET_array_append, GNUNET_asprintf(), GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, GNUNET_snprintf(), GNUNET_SYSERR, GNUNET_TESTBED_reserve_port(), GNUNET_YES, PATH_MAX, uc, and value.
Referenced by GNUNET_TESTBED_configuration_create().
|
static |
Section iterator to set ACCEPT_FROM/ACCEPT_FROM6 to include the address of 'trusted_hosts' in all sections.
cls | the UpdateContext |
section | name of the section |
Definition at line 420 of file testbed.c.
References GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_have_value(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_strdup, GNUNET_YES, key, and uc.
Referenced by GNUNET_TESTBED_configuration_create().
enum GNUNET_GenericReturnValue GNUNET_TESTBED_configuration_create | ( | struct GNUNET_TESTBED_System * | system, |
struct GNUNET_CONFIGURATION_Handle * | cfg, | ||
uint16_t ** | ports, | ||
unsigned int * | nports | ||
) |
Create a new configuration using the given configuration as a template; ports and paths will be modified to select available ports on the local system.
The default configuration will be available in PATHS section under the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS section to the temporary directory specific to this configuration. If we run out of "*port" numbers, return GNUNET_SYSERR.
This is primarily a helper function used internally by 'GNUNET_TESTBED_peer_configure'.
system | system to use to coordinate resource usage |
cfg | template configuration to update |
ports | array with port numbers used in the created configuration. Will be updated upon successful return. Can be NULL |
nports | the size of the ‘ports’ array. Will be updated. |
Definition at line 532 of file testbed.c.
References cfg, GNUNET_asprintf(), GNUNET_CONFIGURATION_iterate(), GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, UpdateContext::nports, GNUNET_TESTBED_System::path_counter, UpdateContext::ports, UpdateContext::system, GNUNET_TESTBED_System::tmppath, uc, update_config(), and update_config_sections().
Referenced by create_unique_cfgs(), and start_peer_run().