42 #define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__)
44 #define CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u"
46 #define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u"
48 #define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u"
62 #define PREFIX_TCP "tcp"
64 #define PREFIX_UDP "udp"
66 #define PREFIX_TCP_NATTED "tcp_natted"
68 #define PREFIX_UDP_NATTED "udp_natted"
76 #define LOW_PORT 12000
83 #define HIGH_PORT 56000
291 _ (
"Hostkeys file not found: %s\n"),
308 _ (
"Incorrect hostkey file format: %s\n"),
418 if (NULL != trusted_ip)
427 if (NULL == shared_services)
429 for (cnt = 0; NULL != shared_services[cnt].
service; cnt++)
431 tss = shared_services[cnt];
432 memset (&ss, 0,
sizeof (ss));
497 (void) unlink (i->
cfg_fn);
512 char *libexec_binary;
541 "Killing shared service instance (%s) failed\n",
601 struct addrinfo hint;
602 struct addrinfo *
ret;
604 uint32_t *port_buckets;
620 hint.ai_family = AF_UNSPEC;
621 hint.ai_socktype = 0;
622 hint.ai_protocol = 0;
625 hint.ai_canonname = NULL;
629 for (index = (system->
lowport / 32) + 1; index < (system->
highport / 32);
632 xor_image = (UINT32_MAX ^ port_buckets[index]);
638 if (0 == ((xor_image >> pos) & 1U))
643 open_port = (index * 32) + pos;
670 port_buckets[index] |= (1U << pos);
675 "Found a free port %u\n",
676 (
unsigned int) open_port);
697 uint32_t *port_buckets;
705 if (0 == (port_buckets[bucket] & (1U << pos)))
710 port_buckets[bucket] &= ~(1U << pos);
743 _ (
"Key number %u does not exist\n"),
817 char *single_variable;
818 char *per_host_variable;
819 unsigned long long num_per_host;
824 if (! ((0 == strcmp (option,
"PORT")) || (0 == strcmp (option,
"UNIXPATH")) ||
825 (0 == strcmp (option,
"HOSTNAME"))))
829 if ((0 == strcmp (option,
"PORT")) && (1 == sscanf (
value,
"%u", &ival)))
848 else if ((ival != 0) &&
864 if (0 == strcmp (option,
"UNIXPATH"))
887 if (0 == strcmp (option,
"HOSTNAME"))
889 value = (NULL ==
uc->system->hostname) ?
"localhost" :
uc->system->hostname;
911 char *orig_allowed_hosts;
913 char *ACCEPT_FROM_key;
927 "TESTING_IGNORE_KEYS",
930 for (ikeys_cnt = 0; NULL != (ptr = strstr (ptr,
";")); ikeys_cnt++)
941 ptr = strstr (ptr,
";");
952 if (NULL != strstr (ikeys[
key],
"ADVERTISED_PORT"))
955 if ((
key == ikeys_cnt) &&
973 if (NULL != strstr (ikeys[
key],
"ACCEPT_FROM"))
983 ACCEPT_FROM_key =
"ACCEPT_FROM";
984 if ((NULL !=
uc->system->trusted_ip) &&
985 (NULL != strstr (
uc->system->trusted_ip,
":")))
986 ACCEPT_FROM_key =
"ACCEPT_FROM6";
990 &orig_allowed_hosts))
994 if (NULL ==
uc->system->trusted_ip)
1000 uc->system->trusted_ip);
1022 ((0 != ss->
share) &&
1107 unsigned int *nports)
1110 char *default_config;
1196 char *hostkey_filename;
1197 char *config_filename;
1198 char *libexec_binary;
1205 unsigned int nports;
1209 ss_instances = NULL;
1217 "You attempted to create a testbed with more than %u hosts. Please precompute more hostkeys first.\n"),
1226 _ (
"Failed to initialize hostkey for peer %u\n"),
1227 (
unsigned int) key_number);
1236 _ (
"PRIVATE_KEY option in PEER section missing in configuration\n"));
1249 _ (
"Failed to create configuration for peer "
1250 "(not enough free ports?)\n"));
1257 &hostkey_filename));
1265 _ (
"Cannot open hostkey file `%s': %s\n"),
1279 _ (
"Failed to write hostkey file for peer %u: %s\n"),
1280 (
unsigned int) key_number,
1292 if (NULL == ss_instances[cnt])
1307 "Failed to write configuration file `%s' for peer %u: %s\n"),
1309 (
unsigned int) key_number,
1315 peer->ss_instances = ss_instances;
1316 peer->cfgfile = config_filename;
1323 &
peer->main_binary))
1333 peer->system = system;
1334 peer->key_number = key_number;
1336 peer->ports = ports;
1337 peer->nports = nports;
1362 if (NULL !=
peer->id)
1386 if (NULL !=
peer->main_process)
1392 for (cnt = 0; cnt <
peer->system->n_shared_services; cnt++)
1394 i =
peer->ss_instances[cnt];
1402 peer->main_process =
1410 if (NULL ==
peer->main_process)
1413 _ (
"Failed to start `%s': %s\n"),
1435 if (NULL ==
peer->main_process)
1442 for (cnt = 0; cnt <
peer->system->n_shared_services; cnt++)
1444 i =
peer->ss_instances[cnt];
1466 if (NULL ==
peer->main_process)
1473 peer->main_process = NULL;
1529 if (NULL ==
peer->main_process)
1532 if (NULL ==
peer->ah)
1570 if (NULL !=
peer->main_process)
1572 if (NULL !=
peer->ah)
1575 if (NULL !=
peer->cfg)
1581 if (NULL !=
peer->ports)
1583 for (cnt = 0; cnt <
peer->nports; cnt++)
1593 const char *cfgfilename,
1638 sc->tm (
sc->tm_cls,
sc->cfg,
sc->peer);
1645 const char *cfgfilename,
1654 char *libexec_binary;
1664 _ (
"Failed to load configuration from %s\n"),
1686 &
peer->main_binary))
1709 if ((NULL !=
peer->main_process) &&
1742 slen = strlen (
line) + 1;
1744 memcpy (copy,
line, slen);
1745 token = strtok_r (copy,
":", &rest);
1746 token = strtok_r (NULL,
":", &rest);
1770 slen = strlen (
line) + 1;
1772 memcpy (copy,
line, slen);
1773 token = strtok_r (copy,
":", &rest);
1774 tlen = strlen (token) + 1;
1776 memcpy (
ret, token, tlen);
1795 size_t slen, slen_token;
1800 slen = strlen (
line) + 1;
1802 memcpy (copy,
line, slen);
1803 token = strtok_r (copy,
":", &rest);
1804 token = strtok_r (NULL,
":", &rest);
1808 slen_token = strlen (token);
1810 memcpy (
ret, token, slen_token + 1);
1834 token = strtok_r (copy,
":", &rest);
1835 token = strtok_r (NULL,
":", &rest);
1836 token = strtok_r (NULL,
":", &rest);
1838 "Format error in configuration line: %s\n",
1859 char copy[strlen (
line) + 1];
1866 slen = strlen (
line) + 1;
1867 memcpy (copy,
line, slen);
1868 temp = strstr (copy,
key);
1871 token = strtok_r (temp,
":", &rest);
1874 token = strtok_r (NULL,
":", &rest);
1877 token2 = strtok_r (token,
"}", &rest);
1909 unsigned int sscanf_ret;
1912 node_connection->
node = node;
1915 token = strtok_r (copy,
":", &rest);
1916 if (0 == strcmp (
"{K", token))
1919 token = strtok_r (NULL,
":", &rest);
1924 node_connection->
node_n = node_n;
1927 else if (0 == strcmp (
"{P", token))
1930 token = strtok_r (NULL,
":", &rest);
1932 sscanf_ret = sscanf (token,
"%u", &namespace_n);
1939 token = strtok_r (NULL,
":", &rest);
1941 sscanf_ret = sscanf (token,
"%u", &node_n);
1947 node_connection->
node_n = node_n;
1949 "node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n",
1963 while (NULL != (token = strtok_r (NULL,
":", &rest)))
1966 token2 = strtok_r (token,
"}", &rest2);
1973 "address_prefix %s\n",
1980 "address_prefix %s\n",
1985 return node_connection;
2008 char *
value, *value2;
2016 temp = strstr (
line,
"connect");
2020 strtok_r (copy,
":", &rest);
2021 value = strtok_r (rest,
"|", &rest2);
2023 while (NULL !=
value)
2026 "node_connections value %s\n",
2029 if (NULL == node_connection)
2032 "connect key was not expected in this configuration line: %s\n",
2039 value2 = strstr (
value,
"}}");
2042 value = strtok_r (NULL,
"|", &rest2);
2066 "plugin: %s space: %u node: %u global: %u\n",
2073 pos_connection = pos_connection->
next)
2077 "namespace_n: %u node_n: %u node_type: %u\n",
2122 "plugin: %s spaces: %u nodes: %u known: %u\n",
2155 unsigned int namespace_n;
2156 unsigned int node_m;
2185 "ceil num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n",
2196 if (NULL !=
namespace)
2208 "node additional_connects: %u %p\n",
2214 *namespace_ex =
namespace;
2260 "get_connections\n");
2365 unsigned int n,
m, num;
2396 "get address prefix: %s node_n: %u\n",
2400 node = connection->
node;
2411 else if (1 == connection->
node_n)
2456 "get_additional_connects\n");
2463 "No info found for node %d\n", num);
2467 "node additional_connects for node %p\n",
2470 "node additional_connects: %u\n",
2484 if (NULL != ac_value)
2531 token = strtok_r (
data,
"\n", &rest);
2538 while (NULL != token)
2544 "In the loop with token: %s beginning with %s\n",
2547 if (0 == strcmp (
key,
"M"))
2550 "Get first Value for M.\n");
2557 else if (0 == strcmp (
key,
"N"))
2560 "Get first Value for N.\n");
2567 else if (0 == strcmp (
key,
"X"))
2570 "Get first Value for X.\n");
2577 else if (0 == strcmp (
key,
"AC"))
2580 "Get first Value for AC.\n");
2587 else if (0 == strcmp (
key,
"T"))
2590 "Get first string value for T.\n");
2597 else if (0 == strcmp (
key,
"K"))
2604 "Get first Value for K.\n");
2626 "Get value for key value on K.\n");
2636 else if (0 == strcmp (
key,
"R"))
2642 "Get first Value for R.\n");
2652 "Get value for key tcp_port on R.\n");
2662 "Get value for key udp_port on R.\n");
2681 namespace->namespace_n = out;
2688 namespace->router = router;
2691 else if (0 == strcmp (
key,
"P"))
2698 "Get first Value for P.\n");
2719 namespace->namespace_n = out;
2726 "Get second Value for P.\n");
2749 "Get value for key plugin on P.\n");
2762 "Get AC Value for P.\n");
2766 token = strtok_r (NULL,
"\n", &rest);
2795 _ (
"Topology file %s not found\n"),
2803 _ (
"Topology file %s has no data\n"),
2811 _ (
"Topology file %s cannot be read\n"),
2818 "file length %" PRIu64
"\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)
Convenience API for writing testcases for GNUnet.
@ 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.
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_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_SectionIterator iter, void *iter_cls)
Iterate over all sections in the configuration.
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_remove(head, tail, element)
Remove an element from a DLL.
#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.
enum GNUNET_GenericReturnValue 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.
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).
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.
#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.
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(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
#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_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#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.
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.
enum GNUNET_GenericReturnValue GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
@ 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/)
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...
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.
Private ECC key encoded for transmission.
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.
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 additional_connects
The number of unintentional additional connections this node waits for.
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.
Router of a netjail subnet.
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.
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.
enum GNUNET_TESTING_NodeType node_type
The type of the node this connection points to.
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.
struct SharedService * shared_services
uint32_t path_counter
Counter we use to make service home paths unique on this system; the full path consists of the tmppat...
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 enum GNUNET_GenericReturnValue start_shared_service_instance(struct SharedServiceInstance *i)
static unsigned int get_first_value(const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
struct GNUNET_PeerIdentity * GNUNET_TESTING_get_peer(unsigned int num, const struct GNUNET_TESTING_System *tl_system)
Retrieve the peer identity from the test system with the unique node id.
static void disconn_status(void *cls, int connected)
Function called whenever we connect to or disconnect from ARM.
#define PREFIX_UDP_NATTED
static void service_run_main(void *cls)
Callback to be called when SCHEDULER has been started.
static void node_connections(const char *line, struct GNUNET_TESTING_NetjailNode *node)
Every line in the topology configuration starts with a string indicating which kind of information wi...
#define HIGH_PORT
Highest port used for GNUnet testing.
static void hostkeys_unload(struct GNUNET_TESTING_System *system)
Function to remove the loaded hostkeys.
unsigned int GNUNET_TESTING_get_additional_connects(unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology)
Get the number of unintentional additional connections the node waits for.
static struct GNUNET_TESTING_NodeConnection * get_connect_value(const char *line, struct GNUNET_TESTING_NetjailNode *node)
Every line in the topology configuration starts with a string indicating which kind of information wi...
static char * get_value(const char *key, const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
static char * get_first_string_value(const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
struct GNUNET_TESTING_NodeConnection * GNUNET_TESTING_get_connections(unsigned int num, const struct GNUNET_TESTING_NetjailTopology *topology)
Get the connections to other nodes for a specific node.
static enum GNUNET_GenericReturnValue hostkeys_load(struct GNUNET_TESTING_System *system)
Testing includes a number of pre-created hostkeys for faster peer startup.
int free_namespaces_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
#define PREFIX_TCP_NATTED
static unsigned int get_second_value(const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
static void cleanup_shared_service_instance(struct SharedServiceInstance *i)
static void get_node_info(unsigned int num, const struct GNUNET_TESTING_NetjailTopology *topology, struct GNUNET_TESTING_NetjailNode **node_ex, struct GNUNET_TESTING_NetjailNamespace **namespace_ex, struct GNUNET_TESTING_NodeConnection **node_connections_ex)
This function extracts information about a specific node from the topology.
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_NetjailTopology * GNUNET_TESTING_get_topo_from_string(const char *input)
Parse the topology data.
static void stop_shared_service_instance(struct SharedServiceInstance *i)
static char * get_key(const char *line)
Every line in the topology configuration starts with a string indicating which kind of information wi...
struct GNUNET_TESTING_NetjailNode * GNUNET_TESTING_get_node(unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology)
Get a node from the topology.
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 connection.
char * GNUNET_TESTING_get_address(struct GNUNET_TESTING_NodeConnection *connection, const char *prefix)
Get the address for a specific communicator from a connection.
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
static int log_topo(const struct GNUNET_TESTING_NetjailTopology *topology)
Helper function to log the configuration in case of a problem with configuration.
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)
A helper function to log information about individual nodes.
#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)
Helper function to log information about namespaces.
static void parse_ac(struct GNUNET_TESTING_NetjailNode *p_node, const char *token)
Message formats for communication between testing cmds helper and testcase plugins.