GNUnet  0.19.4
gnunet_testing_netjail_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2021 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
27 #ifndef GNUNET_TESTING_NETJAIL_LIB_H
28 #define GNUNET_TESTING_NETJAIL_LIB_H
29 
30 #include "gnunet_testing_ng_lib.h"
31 #include "gnunet_testing_plugin.h"
32 
34 
39 {
43  unsigned int tcp_port;
44 
48  unsigned int udp_port;
49 };
50 
51 
56 {
61 
66 };
67 
72 {
77 
82 
87 };
88 
89 
94 
99 {
104 
109 
114  unsigned int namespace_n;
115 
119  unsigned int node_n;
120 
125 
130 
135 
140 };
141 
146 {
151 
156 
160  char *plugin;
161 
165  unsigned int is_global;
166 
170  unsigned int namespace_n;
171 
175  unsigned int node_n;
176 
180  unsigned int node_number;
181 
185  unsigned int additional_connects;
186 
190  unsigned int expected_reaches;
191 };
192 
193 
198 {
202  unsigned int namespace_n;
203 
208 
213 };
214 
219 {
220 
224  char *plugin;
225 
229  unsigned int namespaces_n;
230 
234  unsigned int nodes_m;
235 
239  unsigned int nodes_x;
240 
245 
250 
254  unsigned int additional_connects;
255 };
256 
265 
266 
276 
277 
284 unsigned int
287  topology);
288 
297 GNUNET_TESTING_get_node (unsigned int num,
299 
300 
309 GNUNET_TESTING_get_connections (unsigned int num,
311 
312 
320 char *
322  const char *prefix);
323 
324 
330 void
332 
333 
341 unsigned int
343  GNUNET_TESTING_NodeConnection *node_connection,
345 
351 {
356 
360  const char *label;
361 
365  unsigned int asynchronous_finish;
366 };
367 
373 {
378 
384 };
385 
396  const char *create_label);
397 
407  const char *testdir);
408 
409 
420  char *topology_config,
421  unsigned int *read_file);
422 
423 
434  char *topology_config,
435  unsigned int *read_file);
436 
437 
451  const char *label,
453  unsigned int *read_file,
454  char *topology_data,
456 
457 
468  const char *label,
469  const char *helper_start_label,
471 
472 
482  const char *label);
483 
495 
496 
507  write_message);
508 
509 
510 /* ***** Netjail trait support ***** */
511 
512 
516 #define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op) \
517  op (test_system, const struct GNUNET_TESTING_System) \
518  op (async_context, const struct GNUNET_TESTING_AsyncContext) \
519  op (helper_handles, const struct GNUNET_HELPER_Handle *) \
520  op (local_prepared_state, const struct GNUNET_TESTING_LocalPreparedState) \
521  op (block_state, const struct GNUNET_TESTING_BlockState)
522 
524 
525 #endif
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
static int prefix
If printing the value of PREFIX has been requested.
Definition: gnunet-config.c:59
static char * filename
static int write_message(uint16_t message_type, const char *data, size_t data_length)
Write message to the master process.
uint32_t data
The data value.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start(const char *label, char *topology_config, unsigned int *read_file)
This command executes a shell script to setup the netjail environment.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_local_test_prepared(const char *label, GNUNET_TESTING_cmd_helper_write_cb write_message)
This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_cmds_helper(const char *label, const char *helper_start_label, struct GNUNET_TESTING_NetjailTopology *topology)
Create command.
GNUNET_TESTING_NodeType
Enum for the different types of nodes.
@ GNUNET_TESTING_SUBNET_NODE
Node in a subnet.
@ GNUNET_TESTING_GLOBAL_NODE
Global known node.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_destroy(const char *label, const char *create_label)
This command destroys the ressources allocated for the test system setup.
#define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op)
Call op on all simple traits.
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.
Definition: testing.c:2480
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_block_until_external_trigger(const char *label)
This command is used to block the loop, until the command is finished by other commands,...
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_send_peer_ready(const char *label, GNUNET_TESTING_cmd_helper_write_cb write_message)
DEPRECATED This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED message to the master lo...
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string(const char *data)
FIXME: this could use a "to_string".
Definition: testing.c:2548
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.
Definition: testing.c:2284
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_stop(const char *label, char *topology_config, unsigned int *read_file)
This command executes a shell script to remove the netjail environment.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_cmds_helper(const char *label, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int *read_file, char *topology_data, struct GNUNET_TIME_Relative timeout)
This command executes a shell script which starts a helper process.
struct GNUNET_TESTING_NetjailNode * GNUNET_TESTING_get_node(unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology)
Get a node from the topology.
Definition: testing.c:2262
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.
Definition: testing.c:2394
char * GNUNET_TESTING_get_address(struct GNUNET_TESTING_NodeConnection *connection, const char *prefix)
Get the address for a specific communicator from a connection.
Definition: testing.c:2420
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_file(const char *filename)
Getting the topology from file.
Definition: testing.c:2819
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_create(const char *label, const char *testdir)
This command is setting up a test environment for a peer to start.
void GNUNET_TESTING_free_topology(struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
Definition: testing.c:2380
#define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(name, type)
Create headers for a trait with name name for statically allocated data of type type.
void(* GNUNET_TESTING_cmd_helper_write_cb)(struct GNUNET_MessageHeader *message, size_t msg_length)
Callback function to write messages from the helper process running on a netjail node to the master p...
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
Definition: pabc_helper.c:71
Internal representation of the hash map.
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.
struct GNUNET_TESTING_AddressPrefix * prev
Pointer to the previous prefix in the DLL.
State each asynchronous command must have in its closure.
Struct with information for callbacks.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
unsigned int asynchronous_finish
If this command will block.
const char * label
The label of this command.
A command to be run by the interpreter.
char label[127+1]
Label for the command.
Struct to hold information for callbacks.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
GNUNET_TESTING_cmd_helper_write_cb write_message
Callback to write messages to the master loop.
unsigned int namespace_n
The number of the subnet.
struct GNUNET_CONTAINER_MultiShortmap * nodes
Hash map containing the nodes in this subnet.
struct GNUNET_TESTING_NetjailRouter * router
Router of the subnet.
Node in the netjail topology.
unsigned int namespace_n
The number of the subnet this node is running in.
unsigned int node_number
The overall number of the node in the whole test system.
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 expected_reaches
The number of cmds waiting for a specific barrier.
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.
unsigned int tcp_port
Will tcp be forwarded?
unsigned int udp_port
Will udp be forwarded?
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.
struct GNUNET_TESTING_NodeConnection * prev
Pointer to the previous connection in the DLL.
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.
Time for relative time used by GNUnet, in microseconds.