39 #define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__)
41 #define CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u"
43 #define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u"
45 #define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u"
47 #define PREFIX_TCP "tcp"
49 #define PREFIX_UDP "udp"
57 #define LOW_PORT 12000
64 #define HIGH_PORT 56000
272 _ (
"Hostkeys file not found: %s\n"),
289 _ (
"Incorrect hostkey file format: %s\n"),
399 if (NULL != trusted_ip)
408 if (NULL == shared_services)
410 for (cnt = 0; NULL != shared_services[cnt].
service; cnt++)
412 tss = shared_services[cnt];
478 (void) unlink (i->
cfg_fn);
493 char *libexec_binary;
522 "Killing shared service instance (%s) failed\n",
583 struct addrinfo hint;
584 struct addrinfo *
ret;
586 uint32_t *port_buckets;
602 hint.ai_family = AF_UNSPEC;
603 hint.ai_socktype = 0;
604 hint.ai_protocol = 0;
607 hint.ai_canonname = NULL;
611 for (index = (system->
lowport / 32) + 1; index < (system->
highport / 32);
614 xor_image = (UINT32_MAX ^ port_buckets[index]);
620 if (0 == ((xor_image >> pos) & 1U))
625 open_port = (index * 32) + pos;
652 port_buckets[index] |= (1U << pos);
657 "Found a free port %u\n",
658 (
unsigned int) open_port);
679 uint32_t *port_buckets;
687 if (0 == (port_buckets[bucket] & (1U << pos)))
692 port_buckets[bucket] &= ~(1U << pos);
725 _ (
"Key number %u does not exist\n"),
799 char *single_variable;
800 char *per_host_variable;
801 unsigned long long num_per_host;
806 if (! ((0 == strcmp (option,
"PORT")) || (0 == strcmp (option,
"UNIXPATH")) ||
807 (0 == strcmp (option,
"HOSTNAME"))))
811 if ((0 == strcmp (option,
"PORT")) && (1 == sscanf (
value,
"%u", &ival)))
830 else if ((ival != 0) &&
846 if (0 == strcmp (option,
"UNIXPATH"))
869 if (0 == strcmp (option,
"HOSTNAME"))
871 value = (NULL ==
uc->system->hostname) ?
"localhost" :
uc->system->hostname;
893 char *orig_allowed_hosts;
895 char *ACCEPT_FROM_key;
909 "TESTING_IGNORE_KEYS",
912 for (ikeys_cnt = 0; NULL != (ptr = strstr (ptr,
";")); ikeys_cnt++)
923 ptr = strstr (ptr,
";");
934 if (NULL != strstr (ikeys[
key],
"ADVERTISED_PORT"))
937 if ((
key == ikeys_cnt) &&
955 if (NULL != strstr (ikeys[
key],
"ACCEPT_FROM"))
965 ACCEPT_FROM_key =
"ACCEPT_FROM";
966 if ((NULL !=
uc->system->trusted_ip) &&
967 (NULL != strstr (
uc->system->trusted_ip,
":")))
968 ACCEPT_FROM_key =
"ACCEPT_FROM6";
972 &orig_allowed_hosts))
976 if (NULL ==
uc->system->trusted_ip)
982 uc->system->trusted_ip);
1004 ((0 != ss->
share) &&
1089 unsigned int *nports)
1092 char *default_config;
1178 char *hostkey_filename;
1179 char *config_filename;
1180 char *libexec_binary;
1187 unsigned int nports;
1191 ss_instances = NULL;
1199 "You attempted to create a testbed with more than %u hosts. Please precompute more hostkeys first.\n"),
1208 _ (
"Failed to initialize hostkey for peer %u\n"),
1209 (
unsigned int) key_number);
1218 _ (
"PRIVATE_KEY option in PEER section missing in configuration\n"));
1231 _ (
"Failed to create configuration for peer "
1232 "(not enough free ports?)\n"));
1239 &hostkey_filename));
1247 _ (
"Cannot open hostkey file `%s': %s\n"),
1261 _ (
"Failed to write hostkey file for peer %u: %s\n"),
1262 (
unsigned int) key_number,
1274 if (NULL == ss_instances[cnt])
1289 "Failed to write configuration file `%s' for peer %u: %s\n"),
1291 (
unsigned int) key_number,
1297 peer->ss_instances = ss_instances;
1298 peer->cfgfile = config_filename;
1305 &
peer->main_binary))
1315 peer->system = system;
1316 peer->key_number = key_number;
1318 peer->ports = ports;
1319 peer->nports = nports;
1344 if (NULL !=
peer->id)
1368 if (NULL !=
peer->main_process)
1374 for (cnt = 0; cnt <
peer->system->n_shared_services; cnt++)
1376 i =
peer->ss_instances[cnt];
1384 peer->main_process =
1392 if (NULL ==
peer->main_process)
1395 _ (
"Failed to start `%s': %s\n"),
1417 if (NULL ==
peer->main_process)
1424 for (cnt = 0; cnt <
peer->system->n_shared_services; cnt++)
1426 i =
peer->ss_instances[cnt];
1448 if (NULL ==
peer->main_process)
1455 peer->main_process = NULL;
1522 if (NULL ==
peer->main_process)
1525 if (NULL ==
peer->ah)
1563 if (NULL !=
peer->main_process)
1565 if (NULL !=
peer->ah)
1568 if (NULL !=
peer->cfg)
1574 if (NULL !=
peer->ports)
1576 for (cnt = 0; cnt <
peer->nports; cnt++)
1602 const char *cfgfilename,
1647 sc->tm (
sc->tm_cls,
sc->cfg,
sc->peer);
1675 const char *cfgfilename,
1684 char *libexec_binary;
1694 _ (
"Failed to load configuration from %s\n"),
1716 &
peer->main_binary))
1739 if ((NULL !=
peer->main_process) &&
1770 size_t slen = strlen (argv0) + 1;
1776 ret = strrchr (sbuf,
'_');
1780 dot = strchr (
ret,
'.');
1796 slen = strlen (
line) + 1;
1797 copy = malloc (slen);
1798 memcpy (copy,
line, slen);
1799 token = strtok_r (copy,
":", &rest);
1800 token = strtok_r (NULL,
":", &rest);
1816 slen = strlen (
line) + 1;
1817 copy = malloc (slen);
1818 memcpy (copy,
line, slen);
1819 token = strtok_r (copy,
":", &rest);
1821 memcpy (
ret, token, 2);
1831 size_t slen, slen_token;
1836 slen = strlen (
line) + 1;
1837 copy = malloc (slen);
1838 memcpy (copy,
line, slen);
1839 token = strtok_r (copy,
":", &rest);
1840 token = strtok_r (NULL,
":", &rest);
1844 slen_token = strlen (token);
1845 ret = malloc (slen_token + 1);
1846 memcpy (
ret, token, slen_token + 1);
1861 slen = strlen (
line) + 1;
1862 copy = malloc (slen);
1863 memcpy (copy,
line, slen);
1864 token = strtok_r (copy,
":", &rest);
1865 token = strtok_r (NULL,
":", &rest);
1866 token = strtok_r (NULL,
":", &rest);
1877 size_t slen, slen_token;
1884 slen = strlen (
line) + 1;
1885 copy = malloc (slen);
1886 memcpy (copy,
line, slen);
1887 temp = strstr (copy,
key);
1890 token = strtok_r (temp,
":", &rest);
1891 token = strtok_r (NULL,
":", &rest);
1892 token2 = strtok_r (token,
"}", &rest);
1893 slen_token = strlen (token2);
1894 ret = malloc (slen_token + 1);
1895 memcpy (
ret, token2, slen_token + 1);
1916 node_connection->
node = node;
1918 slen = strlen (
line) + 1;
1919 copy = malloc (slen);
1920 memcpy (copy,
line, slen);
1921 token = strtok_r (copy,
":", &rest);
1922 if (0 == strcmp (
"{K", token))
1925 token = strtok_r (NULL,
":", &rest);
1930 node_connection->
node_n = node_n;
1933 else if (0 == strcmp (
"{P", token))
1936 token = strtok_r (NULL,
":", &rest);
1937 sscanf (token,
"%u", &namespace_n);
1939 token = strtok_r (NULL,
":", &rest);
1940 sscanf (token,
"%u", &node_n);
1941 node_connection->
node_n = node_n;
1943 "node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n",
1949 while (NULL != (token = strtok_r (NULL,
":", &rest)))
1952 token2 = strtok_r (token,
"}", &rest2);
1955 slen = strlen (token2) + 1;
1956 prefix->address_prefix = malloc (slen);
1957 memcpy (
prefix->address_prefix, token2, slen);
1961 slen = strlen (token) + 1;
1962 prefix->address_prefix = malloc (slen);
1963 memcpy (
prefix->address_prefix, token, slen);
1967 "address_prefix %s\n",
1974 "address_prefix %s\n",
1979 return node_connection;
1986 char *
value, *value2;
1995 temp = strstr (
line,
"connect");
1998 slen = strlen (temp) + 1;
2000 memcpy (copy, temp, slen);
2001 strtok_r (copy,
":", &rest);
2002 value = strtok_r (rest,
"|", &rest2);
2004 while (NULL !=
value)
2007 "node_connections value %s\n",
2013 value2 = strstr (
value,
"}}");
2016 value = strtok_r (NULL,
"|", &rest2);
2032 "plugin: %s space: %u node: %u global: %u\n",
2039 pos_connection = pos_connection->
next)
2043 "namespace_n: %u node_n: %u node_type: %u\n",
2075 "plugin: %s spaces: %u nodes: %u known: %u\n",
2133 "ceil num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n",
2145 if (NULL ==
namespace)
2187 peer->public_key = *pub_key;
2208 while (NULL != pos_connection->
next)
2211 while (NULL != pos_prefix->
next)
2213 tmp_prefix = pos_prefix->
next;
2215 pos_prefix = tmp_prefix;
2217 tmp_connection = pos_connection->
next;
2219 pos_connection = tmp_connection;
2273 unsigned int n,
m, num;
2307 node = connection->
node;
2318 else if (1 == connection->
node_n)
2365 "Local test exits with status %d\n",
2370 reply->
header.
size = htons ((uint16_t) msg_length);
2371 reply->
result = htons (rv);
2400 token = strtok_r (
data,
"\n", &rest);
2407 while (NULL != token)
2413 "In the loop with token: %s beginning with %s\n",
2416 if (0 == strcmp (
key,
"M"))
2419 "Get first Value for M.\n");
2426 else if (0 == strcmp (
key,
"N"))
2429 "Get first Value for N.\n");
2436 else if (0 == strcmp (
key,
"X"))
2439 "Get first Value for X.\n");
2446 else if (0 == strcmp (
key,
"AC"))
2449 "Get first Value for AC.\n");
2456 else if (0 == strcmp (
key,
"T"))
2459 "Get first string value for T.\n");
2466 else if (0 == strcmp (
key,
"K"))
2472 "Get first Value for K.\n");
2494 "Get value for key value on K.\n");
2502 else if (0 == strcmp (
key,
"R"))
2509 "Get first Value for R.\n");
2520 "Get value for key tcp_port on R.\n");
2530 "Get value for key udp_port on R.\n");
2548 namespace->namespace_n = out;
2555 namespace->router = router;
2558 else if (0 == strcmp (
key,
"P"))
2564 "Get first Value for P.\n");
2585 namespace->namespace_n = out;
2592 "Get second Value for P.\n");
2615 "Get value for key plugin on P.\n");
2626 token = strtok_r (NULL,
"\n", &rest);
2657 _ (
"Topology file %s not found\n"),
2665 _ (
"Topology file %s has no data\n"),
2673 _ (
"Topology file %s cannot be read\n"),
2680 "file lenght %lu\n",
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int ret
Return value of the commandline.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static uint16_t port
Port number.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
static int prefix
If printing the value of PREFIX has been requested.
static char * line
Desired phone line (string to be converted to a hash).
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * fs
Handle to FS service.
uint32_t data
The data value.
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static char * value
Value of the record to add/remove.
static struct GNUNET_FS_SearchContext * sc
static char * hostname
Our hostname; we give this to all the peers we start.
static struct GNUNET_FS_UnindexContext * uc
static char * service_name
Option -s: service name (hash to get service descriptor)
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_TESTING_SUBNET_NODE
Node in a subnet.
@ GNUNET_TESTING_GLOBAL_NODE
Global known node.
struct GNUNET_ARM_Handle * GNUNET_ARM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ConnectionStatusCallback conn_status, void *conn_status_cls)
Set up a context for communicating with ARM, then start connecting to the ARM service using that cont...
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service (if connected) and destroy the context.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Section_Iterator iter, void *iter_cls)
Iterate over all sections in the configuration.
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.
void GNUNET_CONFIGURATION_remove_section(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Remove the given section and all options in it.
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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
void GNUNET_CONFIGURATION_iterate(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over all options in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
char * GNUNET_CONFIGURATION_expand_dollar(const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig)
Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or...
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_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
void GNUNET_CONFIGURATION_iterate_section_values(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over values of a section in the configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
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).
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
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).
void * GNUNET_DISK_file_map(const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, enum GNUNET_DISK_MapType access, size_t len)
Map a file into memory.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
char * GNUNET_DISK_mkdtemp(const char *t)
Create an (empty) temporary directory on disk.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_unmap(struct GNUNET_DISK_MapHandle *h)
Unmap a file.
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_NONE
Nobody is allowed to do anything to the file.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_MAP_TYPE_READ
Read-only memory map.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
int GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multishortmap_contains(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create(int domain, int type, int protocol)
Create a new socket.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_bind(struct GNUNET_NETWORK_Handle *desc, const struct sockaddr *address, socklen_t address_len)
Bind a socket to a particular address.
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(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,...)
Start a process.
struct GNUNET_OS_Process * GNUNET_OS_start_process_s(enum GNUNET_OS_InheritStdioFlags std_inheritance, const int *lsocks, const char *filename,...)
Start a process.
int GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
char * GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
@ GNUNET_OS_INHERIT_STD_OUT_AND_ERR
When these flags are set, the child process will inherit stdout and stderr of the parent.
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services)
Create a system handle.
#define GNUNET_TESTING_PREFIX
The environmental variable, if set, that dictates where testing should place generated peer configura...
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create_with_portrange(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services, uint16_t lowport, uint16_t highport)
Create a system handle.
struct GNUNET_TESTING_Peer * GNUNET_TESTING_peer_configure(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t key_number, struct GNUNET_PeerIdentity *id, char **emsg)
Configure a GNUnet peer.
void(* GNUNET_TESTING_PeerStopCallback)(void *cls, struct GNUNET_TESTING_Peer *peer, int success)
Callback to inform whether the peer is running or stopped.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_TESTING_hostkey_get(const struct GNUNET_TESTING_System *system, uint32_t key_number, struct GNUNET_PeerIdentity *id)
Testing includes a number of pre-created hostkeys for faster peer startup.
int GNUNET_TESTING_peer_run(const char *testdir, const char *cfgfilename, GNUNET_TESTING_TestMain tm, void *tm_cls)
Start a single peer and run a test using the testing library.
void(* GNUNET_TESTING_TestMain)(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
Signature of the 'main' function for a (single-peer) testcase that is run using GNUNET_TESTING_peer_r...
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
int GNUNET_TESTING_service_run(const char *testdir, const char *service_name, const char *cfgfilename, GNUNET_TESTING_TestMain tm, void *tm_cls)
Start a single service (no ARM, except of course if the given service name is 'arm') and run a test u...
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
uint16_t GNUNET_TESTING_reserve_port(struct GNUNET_TESTING_System *system)
Reserve a TCP or UDP port for a peer.
void GNUNET_TESTING_release_port(struct GNUNET_TESTING_System *system, uint16_t port)
Release reservation of a TCP or UDP port for a peer (used during GNUNET_TESTING_peer_destroy()).
void GNUNET_TESTING_peer_stop_async_cancel(struct GNUNET_TESTING_Peer *peer)
Cancel a previous asynchronous peer stop request.
int GNUNET_TESTING_peer_stop_async(struct GNUNET_TESTING_Peer *peer, GNUNET_TESTING_PeerStopCallback cb, void *cb_cls)
Stop a peer asynchronously using ARM API.
int GNUNET_TESTING_configuration_create(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new configuration using the given configuration as a template; ports and paths will be modif...
char * GNUNET_TESTING_get_testname_from_underscore(const char *argv0)
Sometimes we use the binary name to determine which specific test to run.
int GNUNET_TESTING_peer_kill(struct GNUNET_TESTING_Peer *peer)
Sends SIGTERM to the peer's main process.
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
int GNUNET_TESTING_peer_wait(struct GNUNET_TESTING_Peer *peer)
Waits for a peer to terminate.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
#define GNUNET_TESTING_HOSTKEYFILESIZE
Size of each hostkey in the hostkey file (in BYTES).
Handle for interacting with ARM.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED.
enum GNUNET_GenericReturnValue result
Private ECC key encoded for transmission.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
Handle used to access files (and pipes).
int fd
File handle on Unix-like systems.
Handle for a memory-mapping operation.
The identity of the host (wraps the signing key of the peer).
Protocol address prefix für a connection between nodes.
struct GNUNET_TESTING_AddressPrefix * next
Pointer to the next prefix in the DLL.
char * address_prefix
The address prefix.
unsigned int namespace_n
The number of the subnet.
Node in the netjail topology.
unsigned int namespace_n
The number of the subnet this node is running in.
struct GNUNET_TESTING_NodeConnection * node_connections_head
Head of the DLL with the connections which shall be established to other nodes.
unsigned int is_global
Flag indicating if this node is a global known node.
char * plugin
Plugin for the test case to be run on this node.
unsigned int node_n
The number of this node in the subnet.
struct GNUNET_TESTING_NodeConnection * node_connections_tail
Tail of the DLL with the connections which shall be established to other nodes.
API for writing an interpreter to test GNUnet components.
unsigned int tcp_port
Will tcp be forwarded?
unsigned int udp_port
Will udp be forwarded?
Toplogy of our netjail setup.
struct GNUNET_CONTAINER_MultiShortmap * map_globals
Hash map containing the global known nodes which are not natted.
char * plugin
Default plugin for the test case to be run on nodes.
unsigned int nodes_m
Number of nodes per subnet.
unsigned int nodes_x
Number of global known nodes.
unsigned int namespaces_n
Number of subnets.
struct GNUNET_CONTAINER_MultiShortmap * map_namespaces
Hash map containing the subnets (for natted nodes) of the topology.
unsigned int additional_connects
Additional connects we do expect, beside the connects which are configured in the topology.
Connection to another node.
struct GNUNET_TESTING_AddressPrefix * address_prefixes_tail
Tail of the DLL with the address prefixes for the protocolls this node is reachable.
enum GNUNET_TESTING_NODE_TYPE node_type
The type of the node this connection points to.
struct GNUNET_TESTING_NodeConnection * next
Pointer to the next connection in the DLL.
unsigned int node_n
The number of the node this connection points to.
struct GNUNET_TESTING_NetjailNode * node
The node which establish the connection.
unsigned int namespace_n
The number of the subnet of the node this connection points to.
struct GNUNET_TESTING_AddressPrefix * address_prefixes_head
Head of the DLL with the address prefixes for the protocolls this node is reachable.
Handle for a GNUnet peer controlled by testing.
struct GNUNET_TESTING_System * system
The TESTING system associated with this peer.
struct GNUNET_OS_Process * main_process
Handle to the running binary of the service, NULL if the peer/service is currently not running.
unsigned int nports
The number of ports in the above array.
char * main_binary
Binary to be executed during 'GNUNET_TESTING_peer_start'.
struct GNUNET_CONFIGURATION_Handle * cfg
The config of the peer.
uint16_t * ports
Array of ports currently allocated to this peer.
struct SharedServiceInstance ** ss_instances
struct GNUNET_PeerIdentity * id
The cached identity of this peer.
struct GNUNET_ARM_Handle * ah
The handle to the peer's ARM service.
uint32_t key_number
The keynumber of this peer's hostkey.
void * cb_cls
The closure for the above callback.
char * cfgfile
Path to the configuration file for this peer.
GNUNET_TESTING_PeerStopCallback cb
The callback to call asynchronously when a peer is stopped.
Specification of a service that is to be shared among peers.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration template for the service.
unsigned int share
The number of peers which share an instance of the service.
const char * service
The name of the service.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
uint16_t highport
Highest port we are allowed to use.
char * trusted_ip
The trusted ip.
char * tmppath
Prefix (e.g.
uint32_t total_hostkeys
The number of hostkeys.
unsigned int n_shared_services
char * hostname
our hostname
uint32_t reserved_ports[65536/32]
Bitmap where each port that has already been reserved for some GNUnet peer is recorded.
char * hostkeys_data
Hostkeys data, contains "GNUNET_TESTING_HOSTKEYFILESIZE * total_hostkeys" bytes.
uint32_t path_counter
Counter we use to make service home paths unique on this system; the full path consists of the tmppat...
struct SharedService ** shared_services
struct GNUNET_DISK_MapHandle * map
memory map for hostkeys_data.
uint16_t lowport
Lowest port we are allowed to use.
Structure for holding service data.
struct GNUNET_TESTING_Peer * peer
The peer in which the service is run.
void * tm_cls
Closure for the above callback.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration of the peer in which the service is run.
GNUNET_TESTING_TestMain tm
Callback to signal service startup.
struct SharedService * ss
struct GNUNET_OS_Process * proc
The structure for identifying a shared service.
struct GNUNET_CONFIGURATION_Handle * cfg
struct SharedServiceInstance ** instances
Closure for update_rel_sum() and update_abs_sum().
uint16_t * ports
Array of ports currently allocated to this peer.
struct GNUNET_TESTING_System * system
The system for which we are building configurations.
char * gnunet_home
The customized service home path for this peer.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration we are building.
unsigned int nports
The number of ports in the above array.
int status
build status - to signal error while building a configuration
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
int free_nodes_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static char * get_value(char *key, char *line)
static void disconn_status(void *cls, int connected)
Function called whenever we connect to or disconnect from ARM.
struct GNUNET_MessageHeader * GNUNET_TESTING_send_local_test_finished_msg(enum GNUNET_GenericReturnValue rv)
Create a GNUNET_CMDS_LOCAL_FINISHED message.
static int start_shared_service_instance(struct SharedServiceInstance *i)
static void service_run_main(void *cls)
Callback to be called when SCHEDULER has been started.
char * GNUNET_TESTING_get_address(struct GNUNET_TESTING_NodeConnection *connection, char *prefix)
Get the address for a specific communicator from a connection.
#define HIGH_PORT
Highest port used for GNUnet testing.
static void node_connections(char *line, struct GNUNET_TESTING_NetjailNode *node)
static void hostkeys_unload(struct GNUNET_TESTING_System *system)
Function to remove the loaded hostkeys.
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string(char *data)
Parse the topology data.
struct GNUNET_PeerIdentity * GNUNET_TESTING_get_pub_key(unsigned int num, const struct GNUNET_TESTING_System *tl_system)
Retrieve the public key from the test system with the unique node id.
static unsigned int get_second_value(char *line)
int free_namespaces_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static void cleanup_shared_service_instance(struct SharedServiceInstance *i)
static unsigned int get_first_value(char *line)
static void update_config(void *cls, const char *section, const char *option, const char *value)
Function to iterate over options.
static struct SharedServiceInstance * associate_shared_service(struct GNUNET_TESTING_System *system, struct SharedService *ss, struct GNUNET_CONFIGURATION_Handle *cfg)
struct GNUNET_TESTING_NodeConnection * GNUNET_TESTING_get_connections(unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology)
Get the connections to other nodes for a specific node.
static char * get_key(char *line)
static void stop_shared_service_instance(struct SharedServiceInstance *i)
static int log_topo(struct GNUNET_TESTING_NetjailTopology *topology)
static char * get_first_string_value(char *line)
static struct GNUNET_TESTING_NodeConnection * get_connect_value(char *line, struct GNUNET_TESTING_NetjailNode *node)
unsigned int GNUNET_TESTING_calculate_num(struct GNUNET_TESTING_NodeConnection *node_connection, struct GNUNET_TESTING_NetjailTopology *topology)
Calculate the unique id identifying a node from a given connction.
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 sec...
static int GNUNET_TESTING_configuration_create_(struct GNUNET_TESTING_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 modif...
#define CONNECT_ADDRESS_TEMPLATE
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_file(const char *filename)
Getting the topology from file.
#define LOW_PORT
Lowest port used for GNUnet testing.
static void cfg_copy_iterator(void *cls, const char *section, const char *option, const char *value)
Function to iterate over options.
static int log_nodes(void *cls, const struct GNUNET_ShortHashCode *id, void *value)
#define KNOWN_CONNECT_ADDRESS_TEMPLATE
void GNUNET_TESTING_free_topology(struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
#define ROUTER_CONNECT_ADDRESS_TEMPLATE
static int log_namespaces(void *cls, const struct GNUNET_ShortHashCode *id, void *value)
static int hostkeys_load(struct GNUNET_TESTING_System *system)
Testing includes a number of pre-created hostkeys for faster peer startup.
Message formats for communication between testing cmds helper and testcase plugins.