GNUnet  0.11.x
Data Structures | Macros | Typedefs | Functions
transport-testing-cmds.h File Reference
#include "gnunet_testing_lib.h"
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  StartPeerState
 

Macros

#define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT(name, type)
 Create headers for a trait with name name for statically allocated data of type type. More...
 
#define GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT(name, type)
 Create C implementation for a trait with name name for statically allocated data of type type. More...
 
#define GNUNET_TRANSPORT_SIMPLE_TRAITS(op)
 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, 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)
 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_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...
 
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_peer_id (const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_PeerIdentity **ret)
 
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_peer_id (const struct GNUNET_PeerIdentity *value)
 
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_CONTAINER_MultiShortmap **ret)
 
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_connected_peers_map (const struct GNUNET_CONTAINER_MultiShortmap *value)
 
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_hello_size (const struct GNUNET_TESTING_Command *cmd, const size_t **ret)
 
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_hello_size (const size_t *value)
 
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_hello (const struct GNUNET_TESTING_Command *cmd, const char **ret)
 
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_hello (const char *value)
 
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_application_handle (const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TRANSPORT_ApplicationHandle **ret)
 
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_application_handle (const struct GNUNET_TRANSPORT_ApplicationHandle *value)
 
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_connect_peer_state (const struct GNUNET_TESTING_Command *cmd, const struct ConnectPeersState **ret)
 
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_connect_peer_state (const struct ConnectPeersState *value)
 
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_state (const struct GNUNET_TESTING_Command *cmd, const struct StartPeerState **ret)
 
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_state (const struct StartPeerState *value)
 

Macro Definition Documentation

◆ GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT

#define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT (   name,
  type 
)
Value:
enum GNUNET_GenericReturnValue \
GNUNET_TRANSPORT_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
type **ret); \
struct GNUNET_TESTING_Trait \
GNUNET_TRANSPORT_make_trait_ ## name ( \
type * value);
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char * value
Value of the record to add/remove.
const char * name
A command to be run by the interpreter.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

Create headers for a trait with name name for statically allocated data of type type.

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

◆ GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT

#define GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT (   name,
  type 
)
Value:
enum GNUNET_GenericReturnValue \
GNUNET_TRANSPORT_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
type **ret) \
{ \
if (NULL == cmd->traits) return GNUNET_SYSERR; \
return cmd->traits (cmd->cls, \
(const void **) ret, \
0); \
} \
GNUNET_TRANSPORT_make_trait_ ## name ( \
type * value) \
{ \
struct GNUNET_TESTING_Trait ret = { \
.trait_name = GNUNET_S (name), \
.ptr = (const void *) value \
}; \
return ret; \
}
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_S(a)
API for writing an interpreter to test GNUnet components.

Create C implementation for a trait with name name for statically allocated data of type type.

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

◆ GNUNET_TRANSPORT_SIMPLE_TRAITS

#define GNUNET_TRANSPORT_SIMPLE_TRAITS (   op)
Value:
op (peer_id, const struct GNUNET_PeerIdentity) \
op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
op (hello_size, const size_t) \
op (hello, const char) \
op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
op (connect_peer_state, const struct ConnectPeersState) \
op (state, const struct StartPeerState)
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
enum State state
current state of profiling
Struct to store information needed in callbacks.
Internal representation of the hash map.
The identity of the host (wraps the signing key of the peer).
Handle to the TRANSPORT subsystem for application management.

Call op on all simple traits.

Definition at line 333 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 32 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,
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.
mThe number of the local node of the actual network namespace.
nThe number of the actual namespace.
local_mNumber of local nodes in each namespace.
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 398 of file transport_api_cmd_start_peer.c.

455 {
456  struct StartPeerState *sps;
457  struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
459  unsigned int i;
460 
461  sps = GNUNET_new (struct StartPeerState);
462  sps->no = no;
463  sps->system_label = system_label;
464  sps->connected_peers_map = connected_peers_map;
465  sps->cfgname = cfgname;
466  sps->node_ip = node_ip;
468  sps->broadcast = broadcast;
469 
470  if (NULL != handlers)
471  {
472  for (i = 0; NULL != handlers[i].cb; i++)
473  ;
474  sps->handlers = GNUNET_new_array (i + 1,
475  struct GNUNET_MQ_MessageHandler);
476  GNUNET_memcpy (sps->handlers,
477  handlers,
478  i * sizeof(struct GNUNET_MQ_MessageHandler));
479  }
480 
481  struct GNUNET_TESTING_Command cmd = {
482  .cls = sps,
483  .label = label,
484  .run = &start_peer_run,
485  .ac = &sps->ac,
486  .cleanup = &start_peer_cleanup,
487  .traits = &start_peer_traits
488  };
489 
490  return cmd;
491 }
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_NO
Definition: gnunet_common.h:94
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_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.
Message handler for a specific message type.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
unsigned int no
An unique number to identify the peer.
char * node_ip
The ip of a node.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
struct GNUNET_CONTAINER_MultiShortmap * connected_peers_map
GNUNET_TRANSPORT_notify_connect_cb notify_connect
unsigned int broadcast
Flag indicating, if udp broadcast should be switched on.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
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.

◆ 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 122 of file transport_api_cmd_stop_peer.c.

141 {
142  struct StopPeerState *sps;
143 
144  sps = GNUNET_new (struct StopPeerState);
145  sps->start_label = start_label;
146  {
147  struct GNUNET_TESTING_Command cmd = {
148  .cls = sps,
149  .label = label,
150  .run = &stop_peer_run,
151  .cleanup = &stop_peer_cleanup,
152  .traits = &stop_peer_traits
153  };
154  return cmd;
155  }
156 }
Struct to hold information for callbacks.
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...

◆ 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 
)

Create command.

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

Definition at line 163 of file transport_api_cmd_connecting_peers.c.

212 {
213  struct ConnectPeersState *cps;
214 
215  cps = GNUNET_new (struct ConnectPeersState);
217  cps->num = num;
218  cps->create_label = create_label;
219  cps->topology = topology;
222 
223  {
224  struct GNUNET_TESTING_Command cmd = {
225  .cls = cps,
226  .label = label,
227  .run = &connect_peers_run,
228  .ac = &cps->ac,
229  .cleanup = &connect_peers_cleanup,
230  .traits = &connect_peers_traits
231  };
232 
233  return cmd;
234  }
235 }
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
uint32_t num
Number globally identifying the node.
struct GNUNET_TESTING_NetjailTopology * topology
The topology of the test setup.
GNUNET_TRANSPORT_notify_connect_cb notify_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.
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.
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.

◆ 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_peer_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
Thetopology for the test setup.
Returns
command.
Parameters
labelname for command.
start_peer_labelLabel of the cmd to start a peer.
start_peer_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
Thetopology for the test setup.
Returns
command.

Definition at line 113 of file transport_api_cmd_send_simple.c.

195 {
196  struct SendSimpleState *sss;
197 
198  sss = GNUNET_new (struct SendSimpleState);
199  sss->num = num;
201  sss->create_label = create_label;
202  sss->topology = topology;
203 
204  struct GNUNET_TESTING_Command cmd = {
205  .cls = sss,
206  .label = label,
207  .run = &send_simple_run,
208  .cleanup = &send_simple_cleanup
209  };
210 
211  return cmd;
212 }
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.

◆ 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.
Thetopology for the test setup.
Returns
command.

Definition at line 552 of file transport_api_cmd_backchannel_check.c.

581 {
582  struct CheckState *cs;
583 
584  cs = GNUNET_new (struct CheckState);
586  cs->num = num;
588  cs->topology = topology;
589  cs->node_n = node_n;
590  cs->namespace_n = namespace_n;
591 
592  struct GNUNET_TESTING_Command cmd = {
593  .cls = cs,
594  .label = label,
595  .run = &backchannel_check_run,
596  .ac = &cs->ac,
597  .cleanup = &backchannel_check_cleanup,
598  .traits = &backchannel_check_traits
599  };
600 
601  return cmd;
602 }
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.

◆ GNUNET_TRANSPORT_get_trait_peer_id()

enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_peer_id ( const struct GNUNET_TESTING_Command cmd,
const struct GNUNET_PeerIdentity **  ret 
)

Definition at line 1 of file transport_api_traits.c.

◆ GNUNET_TRANSPORT_make_trait_peer_id()

struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_peer_id ( const struct GNUNET_PeerIdentity value)

Definition at line 1 of file transport_api_traits.c.

Referenced by start_peer_traits().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_connected_peers_map()

enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_connected_peers_map ( const struct GNUNET_TESTING_Command cmd,
const struct GNUNET_CONTAINER_MultiShortmap **  ret 
)

Definition at line 1 of file transport_api_traits.c.

Referenced by send_simple_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_make_trait_connected_peers_map()

struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_connected_peers_map ( const struct GNUNET_CONTAINER_MultiShortmap value)

Definition at line 1 of file transport_api_traits.c.

Referenced by start_peer_traits().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_hello_size()

enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_hello_size ( const struct GNUNET_TESTING_Command cmd,
const size_t **  ret 
)

Definition at line 1 of file transport_api_traits.c.

◆ GNUNET_TRANSPORT_make_trait_hello_size()

struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_hello_size ( const size_t *  value)

Definition at line 1 of file transport_api_traits.c.

Referenced by start_peer_traits().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_hello()

enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_hello ( const struct GNUNET_TESTING_Command cmd,
const char **  ret 
)

Definition at line 1 of file transport_api_traits.c.

◆ GNUNET_TRANSPORT_make_trait_hello()

struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_hello ( const char *  value)

Definition at line 1 of file transport_api_traits.c.

Referenced by start_peer_traits().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_application_handle()

enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_application_handle ( const struct GNUNET_TESTING_Command cmd,
const struct GNUNET_TRANSPORT_ApplicationHandle **  ret 
)

Definition at line 1 of file transport_api_traits.c.

Referenced by backchannel_check_run(), and connect_peers_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_make_trait_application_handle()

struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_application_handle ( const struct GNUNET_TRANSPORT_ApplicationHandle value)

Definition at line 1 of file transport_api_traits.c.

Referenced by start_peer_traits().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_connect_peer_state()

enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_connect_peer_state ( const struct GNUNET_TESTING_Command cmd,
const struct ConnectPeersState **  ret 
)

Definition at line 1 of file transport_api_traits.c.

◆ GNUNET_TRANSPORT_make_trait_connect_peer_state()

struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_connect_peer_state ( const struct ConnectPeersState value)

Definition at line 1 of file transport_api_traits.c.

◆ GNUNET_TRANSPORT_get_trait_state()

enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_get_trait_state ( const struct GNUNET_TESTING_Command cmd,
const struct StartPeerState **  ret 
)

Definition at line 1 of file transport_api_traits.c.

Referenced by stop_peer_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_make_trait_state()

struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_state ( const struct StartPeerState value)

Definition at line 1 of file transport_api_traits.c.

Referenced by start_peer_traits().

Here is the caller graph for this function: