GNUnet  0.11.x
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 
171 
176 };
177 
178 
183 {
187  unsigned int namespace_n;
188 
193 
198 };
199 
204 {
205 
209  char *plugin;
210 
214  unsigned int namespaces_n;
215 
219  unsigned int nodes_m;
220 
224  unsigned int nodes_x;
225 
230 
235 };
236 
245 
246 
255 
256 
265 GNUNET_TESTING_get_connections (unsigned int num, struct
267 
268 
276 char *
278  char *prefix);
279 
280 
286 void
288 
289 
297 unsigned int
299  GNUNET_TESTING_NodeConnection *node_connection,
301 
302 
308 {
313 
317  const char *label;
318 
322  unsigned int asynchronous_finish;
323 };
324 
330 {
335 
341 };
342 
343 
346  const char *create_label);
347 
348 
351  const char *testdir);
352 
353 
364  char *topology_config,
365  unsigned int *read_file);
366 
367 
378  char *topology_config,
379  unsigned int *read_file);
380 
381 
394  const char *label,
396  unsigned int *read_file,
397  char *topology_data,
399 
400 
411  const char *label,
412  const char *helper_start_label,
414 
415 
422 struct GNUNET_MessageHeader *
424 
425 
428  const char *label);
429 
430 
433  const char *label);
434 
435 
436 // Wait for barrier to be reached by all;
437 // async version implies reached but does not
438 // wait on other peers to reach it.
441  const char *label,
442  const char *barrier_label);
443 
444 
447  const char *label,
448  unsigned int *all_peers_started);
449 
450 
461  const char *label);
462 
463 
467 
468 
478  const char *label,
480 
492  write_message);
493 
494 
495 /* ***** Netjail trait support ***** */
496 
497 
501 #define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op) \
502  op (test_system, const struct GNUNET_TESTING_System) \
503  op (async_context, const struct GNUNET_TESTING_AsyncContext) \
504  op (helper_handles, const struct GNUNET_HELPER_Handle *) \
505  op (local_prepared_state, const struct LocalPreparedState) \
506  op (block_state, const struct BlockState)
507 
509 
510 #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:53
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.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
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:2355
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:2295
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.
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string(char *data)
Parse the topology data.
Definition: testing.c:2380
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:2097
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 connction.
Definition: testing.c:2269
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_file(const char *filename)
Getting the topology from file.
Definition: testing.c:2634
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:2249
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)
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 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.
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.