GNUnet 0.21.1
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
32
33
38{
42 unsigned int tcp_port;
43
47 unsigned int udp_port;
48};
49
50
55{
60
65};
66
71{
76
81
86};
87
88
93
98{
103
108
113 unsigned int namespace_n;
114
118 unsigned int node_n;
119
124
129
134
139};
140
145{
150
155
159 char *plugin;
160
164 unsigned int is_global;
165
169 unsigned int namespace_n;
170
174 unsigned int node_n;
175
179 unsigned int node_number;
180
185
189 unsigned int expected_reaches;
190};
191
192
197{
201 unsigned int namespace_n;
202
207
212};
213
218{
219
223 char *plugin;
224
228 unsigned int namespaces_n;
229
233 unsigned int nodes_m;
234
238 unsigned int nodes_x;
239
244
249
254};
255
264
265
275
276
283unsigned int
286 topology);
287
296GNUNET_TESTING_get_node (unsigned int num,
297 struct GNUNET_TESTING_NetjailTopology *topology);
298
299
308GNUNET_TESTING_get_connections (unsigned int num,
309 const struct GNUNET_TESTING_NetjailTopology *topology);
310
311
319char *
321 const char *prefix);
322
323
329void
331
332
340unsigned int
342 GNUNET_TESTING_NodeConnection *node_connection,
343 struct GNUNET_TESTING_NetjailTopology *topology);
344
345
351{
356
360 const char *label;
361
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,
452 struct GNUNET_TESTING_NetjailTopology *topology,
453 unsigned int *read_file,
454 char *topology_data,
456
457
468 const char *label,
469 const char *helper_start_label,
470 struct GNUNET_TESTING_NetjailTopology *topology);
471
472
482 const char *label);
483
495
496
508
509
523 const char *system_label,
524 uint32_t no,
525 const char *node_ip,
526 const char *cfgname,
527 unsigned int broadcast);
528
529
530/* ***** Netjail trait support ***** */
531
532
536#define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op, prefix) \
537 op (prefix, test_system, const struct GNUNET_TESTING_System) \
538 op (prefix, async_context, struct GNUNET_TESTING_AsyncContext) \
539 op (prefix, helper_handles, const struct GNUNET_HELPER_Handle *) \
540 op (prefix, local_prepared_state, const struct GNUNET_TESTING_LocalPreparedState) \
541 op (prefix, block_state, struct GNUNET_TESTING_BlockState)
542
544
545
546#endif
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:119
static int prefix
If printing the value of PREFIX has been requested.
Definition: gnunet-config.c:59
static char * data
The data to insert into the dht.
static char * filename
static int write_message(uint16_t message_type, const char *data, size_t data_length)
Write message to the master process.
#define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(prefix, name, type)
Create headers for a trait with name name for statically allocated data of type type.
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.
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:2447
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_file(const char *filename)
Getting the topology from file.
Definition: testing.c:2786
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_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:2251
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_start_peer(const char *label, const char *system_label, uint32_t no, const char *node_ip, const char *cfgname, unsigned int broadcast)
Create command.
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:2229
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.
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:2361
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:2347
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string(const char *data)
FIXME: this could use a "to_string".
Definition: testing.c:2515
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:2387
#define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op, prefix)
Call op on all simple traits.
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.
struct GNUNET_TESTING_CommandLabel label
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.
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?
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.