#include "gnunet_common.h"
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
#include "testing_api_topology.h"
#include "testing_cmds.h"
Go to the source code of this file.
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__) |
#define | CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u" |
#define | ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u" |
#define | KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u" |
#define | PREFIX_TCP "tcp" |
#define | PREFIX_UDP "udp" |
#define | PREFIX_TCP_NATTED "tcp_natted" |
#define | PREFIX_UDP_NATTED "udp_natted" |
Functions | |
static int | log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
A helper function to log information about individual nodes. More... | |
static int | log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
Helper function to log information about namespaces. More... | |
static int | log_topo (const struct GNUNET_TESTING_NetjailTopology *topology) |
Helper function to log the configuration in case of a problem with configuration. More... | |
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. More... | |
struct GNUNET_TESTING_NetjailNode * | GNUNET_TESTING_get_node (unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology) |
Get a node from the topology. More... | |
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. More... | |
static int | free_value_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value) |
static int | free_subnets_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value) |
static int | free_carriers_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value) |
void | GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology) |
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology. More... | |
unsigned int | GNUNET_TESTING_calculate_num (struct GNUNET_TESTING_NodeConnection *node_connection, struct GNUNET_TESTING_NetjailTopology *topology) |
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology. More... | |
char * | GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, const char *prefix) |
Get the address for a specific communicator from a connection. More... | |
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. More... | |
char * | GNUNET_TESTING_get_plugin_from_topo (struct GNUNET_TESTING_NetjailTopology *njt, const char *my_node_id) |
Get the global plugin name form the topology file. More... | |
static void | create_subnet_peers (struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_NetjailTopology *topology, struct GNUNET_TESTING_NetjailSubnet *subnet) |
static void | create_subnets (struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_NetjailTopology *topology, struct GNUNET_TESTING_NetjailCarrier *carrier) |
static void | create_peers (struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_NetjailTopology *topology, struct GNUNET_TESTING_NetjailCarrier *carrier) |
struct GNUNET_TESTING_NetjailTopology * | GNUNET_TESTING_get_topo_from_string_ (const char *input) |
Parse the topology data. More... | |
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "testing-api", __VA_ARGS__) |
Definition at line 39 of file testing_api_topology.c.
#define CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u" |
Definition at line 41 of file testing_api_topology.c.
#define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u" |
Definition at line 43 of file testing_api_topology.c.
#define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u" |
Definition at line 45 of file testing_api_topology.c.
#define PREFIX_TCP "tcp" |
Definition at line 47 of file testing_api_topology.c.
#define PREFIX_UDP "udp" |
Definition at line 49 of file testing_api_topology.c.
#define PREFIX_TCP_NATTED "tcp_natted" |
Definition at line 51 of file testing_api_topology.c.
#define PREFIX_UDP_NATTED "udp_natted" |
Definition at line 53 of file testing_api_topology.c.
|
static |
A helper function to log information about individual nodes.
cls | This is not used actually. |
id | The key of this value in the map. |
value | A struct GNUNET_TESTING_NetjailNode which holds information about a node. return GNUNET_YES to continue with iterating, GNUNET_NO otherwise. |
Definition at line 65 of file testing_api_topology.c.
References GNUNET_TESTING_AddressPrefix::address_prefix, GNUNET_TESTING_NodeConnection::address_prefixes_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, GNUNET_TESTING_NetjailNode::is_global, LOG, GNUNET_TESTING_NodeConnection::namespace_n, GNUNET_TESTING_NetjailNode::namespace_n, GNUNET_TESTING_AddressPrefix::next, GNUNET_TESTING_NodeConnection::next, GNUNET_TESTING_NetjailNode::node_connections_head, GNUNET_TESTING_NodeConnection::node_n, GNUNET_TESTING_NetjailNode::node_n, GNUNET_TESTING_NodeConnection::node_type, GNUNET_TESTING_NetjailNode::plugin, and value.
Referenced by log_namespaces(), and log_topo().
|
static |
Helper function to log information about namespaces.
cls | This is not used actually. |
id | The key of this value in the map. |
value | A struct GNUNET_TESTING_NetjailNamespace which holds information about a subnet. return GNUNET_YES to continue with iterating, GNUNET_NO otherwise. |
Definition at line 112 of file testing_api_topology.c.
References GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_YES, log_nodes(), and value.
Referenced by log_topo().
|
static |
Helper function to log the configuration in case of a problem with configuration.
topology | The struct GNUNET_TESTING_NetjailTopology holding the configuration information. |
Definition at line 131 of file testing_api_topology.c.
References GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, LOG, log_namespaces(), log_nodes(), GNUNET_TESTING_NetjailTopology::map_globals, GNUNET_TESTING_NetjailTopology::map_namespaces, GNUNET_TESTING_NetjailTopology::namespaces_n, GNUNET_TESTING_NetjailTopology::nodes_m, GNUNET_TESTING_NetjailTopology::nodes_x, and GNUNET_TESTING_NetjailTopology::plugin.
Referenced by get_node_info().
|
static |
This function extracts information about a specific node from the topology.
num | The global index number of the node. | |
[out] | node_ex | A struct GNUNET_TESTING_NetjailNode with information about the node. |
[out] | namespace_ex | A struct GNUNET_TESTING_NetjailNamespace with information about the namespace the node is in or NULL, if the node is a global node. |
[out] | node_connections_ex | A struct GNUNET_TESTING_NodeConnection with information about the connection of this node to other nodes. |
Definition at line 159 of file testing_api_topology.c.
References GNUNET_TESTING_NetjailNode::additional_connects, GNUNET_CONTAINER_multishortmap_get(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, consensus-simulation::int, LOG, log_topo(), GNUNET_TESTING_NetjailTopology::map_globals, GNUNET_TESTING_NodeConnection::namespace_n, GNUNET_TESTING_NodeConnection::node, GNUNET_TESTING_NetjailNode::node_connections_head, GNUNET_TESTING_NetjailTopology::nodes_m, and GNUNET_TESTING_NetjailTopology::nodes_x.
Referenced by GNUNET_TESTING_get_additional_connects(), GNUNET_TESTING_get_connections(), and GNUNET_TESTING_get_node().
struct GNUNET_TESTING_NetjailNode * GNUNET_TESTING_get_node | ( | unsigned int | num, |
struct GNUNET_TESTING_NetjailTopology * | topology | ||
) |
Get a node from the topology.
num | The specific node we want the connections for. |
topology | The topology we get the connections from. |
Definition at line 241 of file testing_api_topology.c.
References get_node_info(), and GNUNET_TESTING_NodeConnection::node.
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.
num | The specific node we want the connections for. |
topology | The topology we get the connections from. |
Definition at line 263 of file testing_api_topology.c.
References get_node_info(), GNUNET_ERROR_TYPE_DEBUG, LOG, and GNUNET_TESTING_NodeConnection::node.
Referenced by backchannel_check_run(), and connect_peers_run().
|
static |
Definition at line 281 of file testing_api_topology.c.
References GNUNET_free, GNUNET_OK, and value.
Referenced by free_carriers_cb(), free_subnets_cb(), and GNUNET_TESTING_free_topology().
|
static |
Definition at line 294 of file testing_api_topology.c.
References free_value_cb(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, GNUNET_OK, GNUNET_TESTING_NetjailSubnet::peers, and value.
Referenced by free_carriers_cb().
|
static |
Definition at line 312 of file testing_api_topology.c.
References free_subnets_cb(), free_value_cb(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, GNUNET_OK, GNUNET_TESTING_NetjailCarrier::peers, GNUNET_TESTING_NetjailCarrier::subnets, and value.
Referenced by GNUNET_TESTING_free_topology().
void GNUNET_TESTING_free_topology | ( | struct GNUNET_TESTING_NetjailTopology * | topology | ) |
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
topology | The GNUNET_TESTING_NetjailTopology to be deallocated. |
Definition at line 338 of file testing_api_topology.c.
References GNUNET_TESTING_NetjailTopology::backbone_peers, GNUNET_TESTING_NetjailTopology::carriers, free_carriers_cb(), free_value_cb(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, and GNUNET_TESTING_NetjailTopology::plugin.
Referenced by cleanup(), do_shutdown_later(), and netjail_exec_run().
unsigned int GNUNET_TESTING_calculate_num | ( | struct GNUNET_TESTING_NodeConnection * | node_connection, |
struct GNUNET_TESTING_NetjailTopology * | topology | ||
) |
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
Calculate the unique id identifying a node from a given connection.
topology | The GNUNET_TESTING_NetjailTopology to be deallocated. |
void GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology) { GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces, &free_namespaces_cb, NULL); GNUNET_CONTAINER_multishortmap_destroy (topology->map_namespaces); GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, &free_nodes_cb, NULL); GNUNET_CONTAINER_multishortmap_destroy (topology->map_globals); GNUNET_free (topology->plugin); GNUNET_free (topology); }
Definition at line 373 of file testing_api_topology.c.
References m, GNUNET_TESTING_NodeConnection::namespace_n, GNUNET_TESTING_NodeConnection::node_n, GNUNET_TESTING_NetjailTopology::nodes_m, and GNUNET_TESTING_NetjailTopology::nodes_x.
Referenced by connect_peers_run(), and notify_connect().
char * GNUNET_TESTING_get_address | ( | struct GNUNET_TESTING_NodeConnection * | connection, |
const char * | prefix | ||
) |
Get the address for a specific communicator from a connection.
connection | The connection we like to have the address from. |
prefix | The communicator protocol prefix. |
Definition at line 399 of file testing_api_topology.c.
References CONNECT_ADDRESS_TEMPLATE, GNUNET_asprintf(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, KNOWN_CONNECT_ADDRESS_TEMPLATE, LOG, GNUNET_TESTING_NodeConnection::namespace_n, GNUNET_TESTING_NetjailNode::namespace_n, GNUNET_TESTING_NodeConnection::node, GNUNET_TESTING_NodeConnection::node_n, GNUNET_TESTING_NetjailNode::node_n, prefix, PREFIX_TCP, PREFIX_TCP_NATTED, PREFIX_UDP, PREFIX_UDP_NATTED, and ROUTER_CONNECT_ADDRESS_TEMPLATE.
Referenced by connect_peers_run().
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.
num | The specific node we want the additional connects for. |
Definition at line 459 of file testing_api_topology.c.
References GNUNET_TESTING_NetjailNode::additional_connects, get_node_info(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, and LOG.
Referenced by GNUNET_CORE_cmd_connect_peers(), and GNUNET_TRANSPORT_cmd_connect_peers().
char * GNUNET_TESTING_get_plugin_from_topo | ( | struct GNUNET_TESTING_NetjailTopology * | njt, |
const char * | my_node_id | ||
) |
Get the global plugin name form the topology file.
Definition at line 490 of file testing_api_topology.c.
References njt, and GNUNET_TESTING_NetjailTopology::plugin.
Referenced by handle_helper_init().
|
static |
Definition at line 499 of file testing_api_topology.c.
References GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, LOG, GNUNET_TESTING_NetjailSubnet::number_peers, GNUNET_TESTING_NetjailSubnet::peers, and GNUNET_TESTING_NetjailTopology::total.
Referenced by create_subnets().
|
static |
Definition at line 529 of file testing_api_topology.c.
References cfg, create_subnet_peers(), GNUNET_TESTING_NetjailTopology::default_subnet_peers, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_TESTING_NetjailCarrier::index, GNUNET_TESTING_NetjailSubnet::index, LOG, GNUNET_TESTING_NetjailSubnet::number, GNUNET_TESTING_NetjailSubnet::number_peers, GNUNET_TESTING_NetjailCarrier::number_subnets, GNUNET_TESTING_NetjailCarrier::subnets, and GNUNET_TESTING_NetjailTopology::total.
Referenced by GNUNET_TESTING_get_topo_from_string_().
|
static |
Definition at line 576 of file testing_api_topology.c.
References GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, LOG, GNUNET_TESTING_NetjailCarrierPeer::number, GNUNET_TESTING_NetjailCarrier::number_peers, GNUNET_TESTING_NetjailCarrier::peers, and GNUNET_TESTING_NetjailTopology::total.
Referenced by GNUNET_TESTING_get_topo_from_string_().
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string_ | ( | const char * | data | ) |
Parse the topology data.
data | The topology data. |
Definition at line 608 of file testing_api_topology.c.
References _, GNUNET_TESTING_NetjailTopology::backbone_peers, GNUNET_TESTING_NetjailTopology::carriers, cfg, create_peers(), create_subnets(), GNUNET_TESTING_NetjailTopology::default_carrier_peers, GNUNET_TESTING_NetjailTopology::default_subnets, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_deserialize(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, LOG, GNUNET_TESTING_NetjailTopology::num_backbone_peers, GNUNET_TESTING_NetjailTopology::num_carriers, GNUNET_TESTING_NetjailBackbonePeer::number, GNUNET_TESTING_NetjailCarrier::number, GNUNET_TESTING_NetjailCarrier::number_peers, GNUNET_TESTING_NetjailCarrier::number_subnets, GNUNET_TESTING_NetjailTopology::plugin, and GNUNET_TESTING_NetjailTopology::total.
Referenced by handle_helper_init(), netjail_exec_run(), and run().