GNUnet 0.22.2
transport-testing-cmds.h File Reference
Include dependency graph for transport-testing-cmds.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ConnectPeersState
 Struct to store information needed in callbacks. More...
 
struct  TestState
 

Macros

#define GNUNET_TRANSPORT_SIMPLE_TRAITS(op, prefix)    op (prefix, connect_peer_state, const struct ConnectPeersState)
 Call op on all simple traits. More...
 

Typedefs

typedef void *(* GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_PeerIdentity *peer)
 

Functions

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_start_peer (const char *label, const char *system_label, uint32_t no, const char *node_ip, struct GNUNET_MQ_MessageHandler *handlers, const char *cfgname, GNUNET_TRANSPORT_notify_connect_cb notify_connect, unsigned int broadcast)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_stop_peer (const char *label, const char *start_label)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_connect_peers (const char *label, const char *start_peer_label, const char *create_label, uint32_t num, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int additional_connects, unsigned int wait_for_connect)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple (const char *label, const char *start_peer_label, const char *create_label, uint32_t num, struct GNUNET_TESTING_NetjailTopology *topology)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple_performance (const char *label, const char *start_peer_label, const char *create_label, uint32_t num, int size, int max_send, struct GNUNET_TESTING_NetjailTopology *topology)
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_backchannel_check (const char *label, const char *start_peer_label, const char *create_label, uint32_t num, unsigned int node_n, unsigned int namespace_n, struct GNUNET_TESTING_NetjailTopology *topology)
 Create command. More...
 

Macro Definition Documentation

◆ GNUNET_TRANSPORT_SIMPLE_TRAITS

#define GNUNET_TRANSPORT_SIMPLE_TRAITS (   op,
  prefix 
)     op (prefix, connect_peer_state, const struct ConnectPeersState)

Call op on all simple traits.

Definition at line 253 of file transport-testing-cmds.h.

Typedef Documentation

◆ GNUNET_TRANSPORT_notify_connect_cb

typedef void *(* GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_PeerIdentity *peer)

Definition at line 107 of file transport-testing-cmds.h.

Function Documentation

◆ GNUNET_TRANSPORT_cmd_start_peer()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_start_peer ( const char *  label,
const char *  system_label,
uint32_t  no,
const char *  node_ip,
struct GNUNET_MQ_MessageHandler handlers,
const char *  cfgname,
GNUNET_TRANSPORT_notify_connect_cb  notify_connect,
unsigned int  broadcast 
)

Create command.

Parameters
labelname for command.
system_labelLabel of the cmd to setup a test environment.
noDecimal number representing the last byte of the IP address of this peer.
node_ipThe IP address of this node.
handlersHandler for messages received by this peer.
cfgnameConfiguration file name for this peer.
notify_connectMethod which will be called, when a peer connects.
broadcastFlag indicating, if broadcast should be switched on.
Returns
command.

Definition at line 444 of file transport_api_cmd_start_peer.c.

453{
455 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
457 unsigned int i;
458
460 sps->no = no;
461 sps->system_label = GNUNET_strdup (system_label);
462 sps->connected_peers_map = connected_peers_map;
463 sps->cfgname = GNUNET_strdup (cfgname);
464 sps->node_ip = GNUNET_strdup (node_ip);
466 sps->broadcast = broadcast;
467
468 if (NULL != handlers)
469 {
470 for (i = 0; NULL != handlers[i].cb; i++)
471 ;
472 sps->handlers = GNUNET_new_array (i + 1,
475 handlers,
476 i * sizeof(struct GNUNET_MQ_MessageHandler));
477 }
479 label,
483 &sps->ac);
484}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new_ac(void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
Create a new command that may be asynchronous.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_NO
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
Internal representation of the hash map.
Message handler for a specific message type.
Handle for a peer controlled via ARM.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
char * system_label
The label of the command which was started by calling GNUNET_TESTING_cmd_system_create.
unsigned int no
An unique number to identify the peer.
struct GNUNET_CONTAINER_MultiShortmap * connected_peers_map
A map with struct GNUNET_MQ_Handle values for each peer this peer is connected to.
GNUNET_TESTING_notify_connect_cb notify_connect
Callback which is called on neighbour connect events.
enum GNUNET_GenericReturnValue broadcast
Flag indicating, if udp broadcast should be switched on.
char * cfgname
GNUnet configuration file used to start a peer.
static void start_peer_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Connect callback for the connection to the core service.
static int start_peer_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
static void start_peer_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will start all services of a peer to test the transport service.

References GNUNET_TESTING_StartPeerState::ac, GNUNET_TESTING_StartPeerState::broadcast, GNUNET_TESTING_StartPeerState::cfgname, GNUNET_TESTING_StartPeerState::connected_peers_map, GNUNET_CONTAINER_multishortmap_create(), GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_NO, GNUNET_strdup, GNUNET_TESTING_command_new_ac(), handlers, GNUNET_TESTING_StartPeerState::handlers, GNUNET_TESTING_StartPeerState::no, GNUNET_TESTING_StartPeerState::node_ip, GNUNET_TESTING_StartPeerState::notify_connect, notify_connect(), start_peer_cleanup(), start_peer_run(), start_peer_traits(), and GNUNET_TESTING_StartPeerState::system_label.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_cmd_stop_peer()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_stop_peer ( const char *  label,
const char *  start_label 
)

Create command.

Parameters
labelname for command.
start_labelLabel of the cmd to start the peer.
Returns
command.

Definition at line 141 of file transport_api_cmd_stop_peer.c.

143{
144 struct StopPeerState *sps;
145
146 sps = GNUNET_new (struct StopPeerState);
148 return GNUNET_TESTING_command_new (sps,
149 label,
153}
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.
Struct to hold information for callbacks.
const char * start_label
Label of the cmd to start the peer.
const char * label
Label of the cmd.
static int stop_peer_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.
static void stop_peer_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static void stop_peer_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will stop all services of a peer which were used to test the transport ser...

References GNUNET_new, GNUNET_TESTING_command_new, StopPeerState::label, StopPeerState::start_label, stop_peer_cleanup(), stop_peer_run(), and stop_peer_traits().

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_cmd_connect_peers()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_connect_peers ( const char *  label,
const char *  start_peer_label,
const char *  create_label,
uint32_t  num,
struct GNUNET_TESTING_NetjailTopology topology,
unsigned int  additional_connects,
unsigned int  wait_for_connect 
)

Create command.

Parameters
labelname for command
start_peer_labelLabel of the cmd to start a peer.
create_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
topologyThe topology for the test setup.
additional_connectsNumber of additional connects this cmd will wait for not triggered by this cmd.
Returns
command.

Definition at line 264 of file transport_api_cmd_connecting_peers.c.

272{
273 struct ConnectPeersState *cps;
274 unsigned int node_additional_connects;
275
276 node_additional_connects = GNUNET_TESTING_get_additional_connects (num,
277 topology);
278
280 "global: %u and local: %u additional_connects\n",
282 node_additional_connects);
283
284 if (0 != node_additional_connects)
285 additional_connects = node_additional_connects;
286
287 cps = GNUNET_new (struct ConnectPeersState);
289 cps->num = num;
291 cps->topology = topology;
295
296 // FIXME: wrap with cmd_make_unblocking!
299 label,
303 &cps->ac);
304 else
305 return GNUNET_TESTING_command_new (cps,
306 label,
310}
@ GNUNET_YES
@ GNUNET_ERROR_TYPE_DEBUG
Struct to store information needed in callbacks.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
uint32_t num
Number globally identifying the node.
GNUNET_TESTING_notify_connect_cb notify_connect
struct GNUNET_TESTING_NetjailTopology * topology
The topology of the test setup.
unsigned int wait_for_connect
Flag indicating, whether the command is waiting for peers to connect that are configured to connect.
const char * start_peer_label
Label of the cmd to start a peer.
unsigned int additional_connects
Number of additional connects this cmd will wait for not triggered by this cmd.
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.
static void connect_peers_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will connect to peers.
static void * notify_connect(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_PeerIdentity *peer)
Callback from start peer cmd for signaling a peer got connected.
#define LOG(kind,...)
Generic logging shortcut.
static void connect_peers_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
enum GNUNET_GenericReturnValue connect_peers_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.

References ConnectPeersState::ac, ConnectPeersState::additional_connects, connect_peers_cleanup(), connect_peers_run(), connect_peers_traits(), ConnectPeersState::create_label, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_TESTING_command_new, GNUNET_TESTING_command_new_ac(), GNUNET_TESTING_get_additional_connects(), GNUNET_YES, LOG, ConnectPeersState::notify_connect, notify_connect(), ConnectPeersState::num, ConnectPeersState::start_peer_label, ConnectPeersState::topology, and ConnectPeersState::wait_for_connect.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_cmd_send_simple()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple ( const char *  label,
const char *  start_peer_label,
const char *  create_label,
uint32_t  num,
struct GNUNET_TESTING_NetjailTopology topology 
)

Create command.

Parameters
labelname for command.
start_peer_labelLabel of the cmd to start a peer.
create_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
topologyThe topology for the test setup.
Returns
command.

Definition at line 141 of file transport_api_cmd_send_simple.c.

147{
148 struct SendSimpleState *sss;
149
150 sss = GNUNET_new (struct SendSimpleState);
151 sss->num = num;
154 sss->topology = topology;
155
156 return GNUNET_TESTING_command_new (sss,
157 label,
160 NULL);
161}
Struct to hold information for callbacks.
const char * create_label
Label of the cmd which started the test system.
uint32_t num
Number globally identifying the node.
struct GNUNET_TESTING_NetjailTopology * topology
The topology we get the connected nodes from.
const char * start_peer_label
Label of the cmd to start a peer.
static void send_simple_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will send a simple message to the connected peers.
static void send_simple_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.

References SendSimpleState::create_label, GNUNET_new, GNUNET_TESTING_command_new, SendSimpleState::num, send_simple_cleanup(), send_simple_run(), SendSimpleState::start_peer_label, and SendSimpleState::topology.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_cmd_send_simple_performance()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple_performance ( const char *  label,
const char *  start_peer_label,
const char *  create_label,
uint32_t  num,
int  size,
int  max_send,
struct GNUNET_TESTING_NetjailTopology topology 
)
Parameters
labelname for command.
start_peer_labelLabel of the cmd to start a peer.
create_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
sizeThe size of the test message to send.
max_sendThe number of messages to send.
topologyThe topology for the test setup.
Returns
command.

Definition at line 192 of file transport_api_cmd_send_simple_performance.c.

201{
202 struct SendSimplePerfState *sss;
203 struct GNUNET_TESTING_Command cmd;
204
205 sss = GNUNET_new (struct SendSimplePerfState);
206 sss->start_peer_label = start_peer_label;
207 sss->create_label = create_label;
208 sss->topology = topology;
209 sss->size = size;
210 sss->max_send = max_send;
212 label,
215 NULL,
216 &sss->ac);
217 cmd.asynchronous_finish = GNUNET_YES;
218 return cmd;
219}
static unsigned int size
Size of the "table".
Definition: peer.c:68
A command to be run by the interpreter.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
Struct to hold information for callbacks.
unsigned int size
Size of the message in bytes.
unsigned int max_send
Maximum number of messages per peer.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
const char * create_label
Label of the cmd which started the test system.
struct GNUNET_TESTING_NetjailTopology * topology
The topology we get the connected nodes from.
const char * start_peer_label
Label of the cmd to start a peer.
static void send_simple_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will send a simple message to the connected peers.
static void send_simple_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.

References SendSimplePerfState::ac, GNUNET_TESTING_Command::asynchronous_finish, SendSimplePerfState::create_label, GNUNET_new, GNUNET_TESTING_command_new_ac(), GNUNET_YES, GNUNET_TESTING_Command::label, SendSimplePerfState::max_send, send_simple_cleanup(), send_simple_run(), size, SendSimplePerfState::size, SendSimplePerfState::start_peer_label, and SendSimplePerfState::topology.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_cmd_backchannel_check()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_backchannel_check ( const char *  label,
const char *  start_peer_label,
const char *  create_label,
uint32_t  num,
unsigned int  node_n,
unsigned int  namespace_n,
struct GNUNET_TESTING_NetjailTopology topology 
)

Create command.

Parameters
labelname for command.
start_peer_labelLabel of the cmd to start a peer.
create_labelLabel of the cmd to create the testing system.
numNumber globally identifying the node.
node_nThe number of the node in a network namespace.
namespace_nThe number of the network namespace.
topologyThe topology for the test setup.
Returns
command.

Definition at line 529 of file transport_api_cmd_backchannel_check.c.

537{
538 struct CheckState *cs;
539
540 cs = GNUNET_new (struct CheckState);
542 cs->num = num;
544 cs->topology = topology;
545 cs->node_n = node_n;
547
549 label,
553 &cs->ac);
554}
Struct to store information needed in callbacks.
const char * start_peer_label
Label of the cmd to start a peer.
uint32_t num
Number globally identifying the node.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
unsigned int node_n
The number of the node in a network namespace.
unsigned int namespace_n
The number of the network namespace.
struct GNUNET_TESTING_NetjailTopology * topology
The topology of the test setup.
static void backchannel_check_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static void backchannel_check_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will connect to peers.
static int backchannel_check_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.

References CheckState::ac, backchannel_check_cleanup(), backchannel_check_run(), backchannel_check_traits(), CheckState::create_label, GNUNET_new, GNUNET_TESTING_command_new_ac(), CheckState::namespace_n, CheckState::node_n, CheckState::num, CheckState::start_peer_label, and CheckState::topology.

Here is the call graph for this function: