GNUnet  0.17.6
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_util_lib.h"
31 #include "gnunet_testing_plugin.h"
32 #include "gnunet_testing_ng_lib.h"
33 
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 {
150  char *plugin;
151 
155  unsigned int is_global;
156 
160  unsigned int namespace_n;
161 
165  unsigned int node_n;
166 
170  unsigned int additional_connects;
171 
176 
181 };
182 
183 
188 {
192  unsigned int namespace_n;
193 
198 
203 };
204 
209 {
210 
214  char *plugin;
215 
219  unsigned int namespaces_n;
220 
224  unsigned int nodes_m;
225 
229  unsigned int nodes_x;
230 
235 
240 
244  unsigned int additional_connects;
245 };
246 
255 
256 
265 
266 
273 unsigned int
276  topology);
277 
278 
287 GNUNET_TESTING_get_connections (unsigned int num, struct
289 
290 
298 char *
300  char *prefix);
301 
302 
308 void
310 
311 
319 unsigned int
321  GNUNET_TESTING_NodeConnection *node_connection,
323 
324 
330 {
335 
339  const char *label;
340 
344  unsigned int asynchronous_finish;
345 };
346 
352 {
357 
363 };
364 
365 
368  const char *create_label);
369 
370 
373  const char *testdir);
374 
375 
386  char *topology_config,
387  unsigned int *read_file);
388 
389 
400  char *topology_config,
401  unsigned int *read_file);
402 
403 
416  const char *label,
418  unsigned int *read_file,
419  char *topology_data,
421 
422 
433  const char *label,
434  const char *helper_start_label,
436 
437 
444 struct GNUNET_MessageHeader *
446 
447 
450  const char *label);
451 
452 
455  const char *label);
456 
457 
458 // Wait for barrier to be reached by all;
459 // async version implies reached but does not
460 // wait on other peers to reach it.
463  const char *label,
464  const char *barrier_label);
465 
466 
469  const char *label,
470  unsigned int *all_peers_started);
471 
472 
483  const char *label);
484 
485 
489 
490 
500  const char *label,
502 
514  write_message);
515 
516 
517 /* ***** Netjail trait support ***** */
518 
519 
523 #define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op) \
524  op (test_system, const struct GNUNET_TESTING_System) \
525  op (async_context, const struct GNUNET_TESTING_AsyncContext) \
526  op (helper_handles, const struct GNUNET_HELPER_Handle *) \
527  op (local_prepared_state, const struct LocalPreparedState) \
528  op (block_state, const struct BlockState)
529 
531 
532 #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:58
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)
Create command.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_create(const char *label)
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_local_test_finished(const char *label, TESTING_CMD_HELPER_write_cb write_message)
Create command.
struct GNUNET_MessageHeader * GNUNET_TESTING_send_local_test_finished_msg(enum GNUNET_GenericReturnValue rv)
Create a GNUNET_CMDS_LOCAL_FINISHED message.
Definition: testing.c:2416
char * GNUNET_TESTING_get_address(struct GNUNET_TESTING_NodeConnection *connection, char *prefix)
Get the address for a specific communicator from a connection.
Definition: testing.c:2324
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_testing_system(const char *label, const char *helper_start_label, struct GNUNET_TESTING_NetjailTopology *topology)
Create command.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_destroy(const char *label, const char *create_label)
Create command.
#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:2387
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string(char *data)
Parse the topology data.
Definition: testing.c:2441
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_block_until_external_trigger(const char *label)
Create command.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_testing_system(const char *label, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int *read_file, char *topology_data, struct GNUNET_TIME_Relative timeout)
Create command.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_stop(const char *label, char *topology_config, unsigned int *read_file)
Create command.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_send_peer_ready(const char *label, TESTING_CMD_HELPER_write_cb write_message)
Create command.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_setup_finished(const char *label)
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_block_until_all_peers_started(const char *label, unsigned int *all_peers_started)
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.
Definition: testing.c:2192
GNUNET_TESTING_NODE_TYPE
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_local_test_prepared(const char *label, TESTING_CMD_HELPER_write_cb write_message)
Create command.
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:2298
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_file(const char *filename)
Getting the topology from file.
Definition: testing.c:2716
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_create(const char *label, const char *testdir)
Create command.
void GNUNET_TESTING_free_topology(struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
Definition: testing.c:2284
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_reached(const char *label, const char *barrier_label)
#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(* TESTING_CMD_HELPER_write_cb)(struct GNUNET_MessageHeader *message, size_t msg_length)
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
Definition: pabc_helper.c:70
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.
Internal representation of the hash map.
Header for all communications.
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.
A command to be run by the interpreter.
const char * label
Label for the command.
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.
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.
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.
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.
Time for relative time used by GNUnet, in microseconds.
Struct to hold information for callbacks.
TESTING_CMD_HELPER_write_cb write_message
Callback to write messages to the master loop.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.