GNUnet  0.11.x
Data Structures | 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  StartPeerState_v2
 
struct  StartPeerState
 

Functions

int GNUNET_TRANSPORT_get_trait_state (const struct GNUNET_TESTING_Command *cmd, struct StartPeerState **sps)
 Function to get the trait with the struct StartPeerState. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_start_peer_v2 (const char *label, const char *system_label, uint32_t no, char *node_ip, struct GNUNET_MQ_MessageHandler *handlers, const char *cfgname)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_start_peer (const char *label, const char *system_label, char *m, char *n, char *local_m, char *node_ip, struct GNUNET_MQ_MessageHandler *handlers, const char *cfgname)
 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)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_connect_peers_v2 (const char *label, const char *start_peer_label, const char *create_label, uint32_t num)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple (const char *label, char *m, char *n, uint32_t num, const char *start_peer_label)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple_v2 (const char *label, const char *start_peer_label, uint32_t num)
 Create command. More...
 
int GNUNET_TRANSPORT_get_trait_peer_id (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_PeerIdentity **id)
 Function to get the trait with the peer id. More...
 
int GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_CONTAINER_MultiShortmap **connected_peers_map)
 Function to get the trait with the map of connected peers. More...
 
int GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_CONTAINER_MultiShortmap **connected_peers_map)
 Function to get the trait with the map of connected peers. More...
 
int GNUNET_TRANSPORT_get_trait_hello_size (const struct GNUNET_TESTING_Command *cmd, size_t **hello_size)
 Function to get the trait with the size of the hello. More...
 
int GNUNET_TRANSPORT_get_trait_hello (const struct GNUNET_TESTING_Command *cmd, char **hello)
 Function to get the trait with the hello. More...
 
int GNUNET_TRANSPORT_get_trait_application_handle (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TRANSPORT_ApplicationHandle **ah)
 Function to get the trait with the transport application handle. More...
 
int GNUNET_TRANSPORT_get_trait_application_handle_v2 (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TRANSPORT_ApplicationHandle **ah)
 Function to get the trait with the transport application handle. More...
 

Function Documentation

◆ GNUNET_TRANSPORT_get_trait_state()

int GNUNET_TRANSPORT_get_trait_state ( const struct GNUNET_TESTING_Command cmd,
struct StartPeerState **  sps 
)

Function to get the trait with the struct StartPeerState.

Parameters
[out]spsstruct StartPeerState.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 440 of file transport_api_cmd_start_peer.c.

444 {
445  return cmd->traits (cmd->cls,
446  (const void **) sps,
447  "state",
448  (unsigned int) 5);
449 }
int(* traits)(void *cls, const void **ret, const char *trait, unsigned int index)
Extract information from a command that is useful for other commands.
void * cls
Closure for all commands with command-specific context information.

References GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

Referenced by stop_peer_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_cmd_start_peer_v2()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_start_peer_v2 ( const char *  label,
const char *  system_label,
uint32_t  no,
char *  node_ip,
struct GNUNET_MQ_MessageHandler handlers,
const char *  cfgname 
)

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.
Returns
command.

Definition at line 543 of file transport_api_cmd_start_peer_v2.c.

573 {
574  struct StartPeerState_v2 *sps;
575  struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
577  unsigned int i;
578 
579  sps = GNUNET_new (struct StartPeerState_v2);
580  sps->no = no;
581  sps->system_label = system_label;
582  sps->connected_peers_map = connected_peers_map;
583  sps->cfgname = cfgname;
584  sps->node_ip = node_ip;
585 
586  if (NULL != handlers)
587  {
588  for (i = 0; NULL != handlers[i].cb; i++)
589  ;
590  sps->handlers = GNUNET_new_array (i + 1,
591  struct GNUNET_MQ_MessageHandler);
592  GNUNET_memcpy (sps->handlers,
593  handlers,
594  i * sizeof(struct GNUNET_MQ_MessageHandler));
595  }
596 
597  struct GNUNET_TESTING_Command cmd = {
598  .cls = sps,
599  .label = label,
600  .run = &start_peer_run,
601  .finish = &start_peer_finish,
602  .cleanup = &start_peer_cleanup,
603  .traits = &start_peer_traits
604  };
605 
606  return cmd;
607 }
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.
Internal representation of the hash map.
Message handler for a specific message type.
A command to be run by the interpreter.
const char * label
Label for the command.
unsigned int no
An unique number to identify the peer.
struct GNUNET_CONTAINER_MultiShortmap * connected_peers_map
char * node_ip
The ip of a node.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
static int start_peer_finish(void *cls, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
This function checks StartPeerState_v2::finished, which is set when the hello was retrieved.
static void start_peer_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
The cleanup function of this cmd frees resources the cmd allocated.
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, const struct GNUNET_TESTING_Command *cmd, 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_Command::cls, and GNUNET_TESTING_Command::traits.

◆ GNUNET_TRANSPORT_cmd_start_peer()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_start_peer ( const char *  label,
const char *  system_label,
char *  m,
char *  n,
char *  local_m,
char *  node_ip,
struct GNUNET_MQ_MessageHandler handlers,
const char *  cfgname 
)

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.
Returns
command.

Definition at line 542 of file transport_api_cmd_start_peer.c.

574 {
575  struct StartPeerState *sps;
576  struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
578  unsigned int i;
579 
580  sps = GNUNET_new (struct StartPeerState);
581  sps->m = m;
582  sps->n = n;
583  sps->local_m = local_m;
584  sps->no = (atoi (n) - 1) * atoi (sps->local_m) + atoi (m);
585  sps->system_label = system_label;
586  sps->connected_peers_map = connected_peers_map;
587  sps->cfgname = cfgname;
588  sps->node_ip = node_ip;
589 
590  if (NULL != handlers)
591  {
592  for (i = 0; NULL != handlers[i].cb; i++)
593  ;
594  sps->handlers = GNUNET_new_array (i + 1,
595  struct GNUNET_MQ_MessageHandler);
596  GNUNET_memcpy (sps->handlers,
597  handlers,
598  i * sizeof(struct GNUNET_MQ_MessageHandler));
599  }
600 
601  struct GNUNET_TESTING_Command cmd = {
602  .cls = sps,
603  .label = label,
604  .run = &start_peer_run,
605  .finish = &start_peer_finish,
606  .cleanup = &start_peer_cleanup,
607  .traits = &start_peer_traits
608  };
609 
610  return cmd;
611 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
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
static int start_peer_finish(void *cls, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
This function checks StartPeerState::finished, which is set when the hello was retrieved.
static void start_peer_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
The cleanup function of this cmd frees resources the cmd allocated.
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, const struct GNUNET_TESTING_Command *cmd, 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_Command::cls, and GNUNET_TESTING_Command::traits.

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

148 {
149  struct StopPeerState *sps;
150 
151  sps = GNUNET_new (struct StopPeerState);
152  sps->start_label = start_label;
153 
154  struct GNUNET_TESTING_Command cmd = {
155  .cls = sps,
156  .label = label,
157  .run = &stop_peer_run,
158  .cleanup = &stop_peer_cleanup,
159  .traits = &stop_peer_traits
160  };
161 
162  return cmd;
163 }
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, const struct GNUNET_TESTING_Command *cmd)
The cleanup function of this cmd frees resources the cmd allocated.
static void stop_peer_run(void *cls, const struct GNUNET_TESTING_Command *cmd, 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 
)

Create command.

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

Definition at line 240 of file transport_api_cmd_connecting_peers.c.

262 {
263  struct ConnectPeersState *cps;
264 
265  cps = GNUNET_new (struct ConnectPeersState);
267  cps->num = num;
268  cps->create_label = create_label;
269 
270 
271  struct GNUNET_TESTING_Command cmd = {
272  .cls = cps,
273  .label = label,
274  .run = &connect_peers_run,
275  .finish = &connect_peers_finish,
276  .cleanup = &connect_peers_cleanup,
277  .traits = &connect_peers_traits
278  };
279 
280  return cmd;
281 }
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.
static void connect_peers_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
The cleanup function of this cmd frees resources the cmd allocated.
static int connect_peers_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.
static int connect_peers_finish(void *cls, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
The finish function of this cmd will check if the peer we are trying to connect to is in the connecte...
static void connect_peers_run(void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will connect to peers.

◆ GNUNET_TRANSPORT_cmd_connect_peers_v2()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_connect_peers_v2 ( const char *  label,
const char *  start_peer_label,
const char *  create_label,
uint32_t  num 
)

Create command.

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

Definition at line 201 of file transport_api_cmd_connecting_peers_v2.c.

223 {
224  struct ConnectPeersState *cps;
225 
226  cps = GNUNET_new (struct ConnectPeersState);
228  cps->num = num;
229  cps->create_label = create_label;
230 
231 
232  struct GNUNET_TESTING_Command cmd = {
233  .cls = cps,
234  .label = label,
235  .run = &connect_peers_run,
236  .finish = &connect_peers_finish,
237  .cleanup = &connect_peers_cleanup,
238  .traits = &connect_peers_traits
239  };
240 
241  return cmd;
242 }
static void connect_peers_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
The cleanup function of this cmd frees resources the cmd allocated.
static int connect_peers_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.
static int connect_peers_finish(void *cls, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
The finish function of this cmd will check if the peer we are trying to connect to is in the connecte...
static void connect_peers_run(void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will connect to peers.

◆ GNUNET_TRANSPORT_cmd_send_simple()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple ( const char *  label,
char *  m,
char *  n,
uint32_t  num,
const char *  start_peer_label 
)

Create command.

Parameters
labelname for command.
mThe number of the local node of the actual network namespace.
nThe number of the actual namespace.
numNumber globally identifying the node.
start_peer_labelLabel of the cmd to start a peer.
Returns
command.

Definition at line 97 of file transport_api_cmd_send_simple.c.

154 {
155  struct SendSimpleState *sss;
156 
157  sss = GNUNET_new (struct SendSimpleState);
158  sss->m = m;
159  sss->n = n;
160  sss->num = num;
162 
163  struct GNUNET_TESTING_Command cmd = {
164  .cls = sss,
165  .label = label,
166  .run = &send_simple_run,
167  .cleanup = &send_simple_cleanup,
168  .traits = &send_simple_traits
169  };
170 
171  return cmd;
172 }
Struct to hold information for callbacks.
const char * start_peer_label
Label of the cmd to start a peer.
uint32_t num
Number globally identifying the node.
char * n
The number of the actual namespace.
char * m
The number of the local node of the actual network namespace.
static void send_simple_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
The cleanup function of this cmd frees resources the cmd allocated.
static void send_simple_run(void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will send a simple message to the connected peer.
static int send_simple_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.

◆ GNUNET_TRANSPORT_cmd_send_simple_v2()

struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_send_simple_v2 ( const char *  label,
const char *  start_peer_label,
uint32_t  num 
)

Create command.

Parameters
labelname for command.
mThe number of the local node of the actual network namespace.
nThe number of the actual namespace.
numNumber globally identifying the node.
start_peer_labelLabel of the cmd to start a peer.
Returns
command.

Definition at line 85 of file transport_api_cmd_send_simple_v2.c.

140 {
141  struct SendSimpleState *sss;
142 
143  sss = GNUNET_new (struct SendSimpleState);
144  sss->num = num;
146 
147  struct GNUNET_TESTING_Command cmd = {
148  .cls = sss,
149  .label = label,
150  .run = &send_simple_run,
151  .cleanup = &send_simple_cleanup,
152  .traits = &send_simple_traits
153  };
154 
155  return cmd;
156 }
static void send_simple_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
The cleanup function of this cmd frees resources the cmd allocated.
static void send_simple_run(void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will send a simple message to the connected peer.
static int send_simple_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()

int GNUNET_TRANSPORT_get_trait_peer_id ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_PeerIdentity **  id 
)

Function to get the trait with the peer id.

Parameters
[out]idThe peer id.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 542 of file transport_api_cmd_start_peer.c.

545 {
546  return cmd->traits (cmd->cls,
547  (const void **) id,
548  "peer_id",
549  (unsigned int) 1);
550 }

Referenced by connect_peers_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_connected_peers_map()

int GNUNET_TRANSPORT_get_trait_connected_peers_map ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_CONTAINER_MultiShortmap **  connected_peers_map 
)

Function to get the trait with the map of connected peers.

Parameters
[out]connected_peers_mapThe map with connected peers.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 500 of file transport_api_cmd_start_peer.c.

507 {
508  return cmd->traits (cmd->cls,
509  (const void **) connected_peers_map,
510  "connected_peers_map",
511  (unsigned int) 2);
512 }

References GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

Referenced by connect_peers_finish(), and send_simple_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_connected_peers_map_v2()

int GNUNET_TRANSPORT_get_trait_connected_peers_map_v2 ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_CONTAINER_MultiShortmap **  connected_peers_map 
)

Function to get the trait with the map of connected peers.

Parameters
[out]connected_peers_mapThe map with connected peers.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 500 of file transport_api_cmd_start_peer_v2.c.

508 {
509  return cmd->traits (cmd->cls,
510  (const void **) connected_peers_map,
511  "connected_peers_map",
512  (unsigned int) 2);
513 }

References GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

Referenced by connect_peers_finish().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_hello_size()

int GNUNET_TRANSPORT_get_trait_hello_size ( const struct GNUNET_TESTING_Command cmd,
size_t **  hello_size 
)

Function to get the trait with the size of the hello.

Parameters
[out]hello_sizesize of hello.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 460 of file transport_api_cmd_start_peer.c.

464 {
465  return cmd->traits (cmd->cls,
466  (const void **) hello_size,
467  "hello_size",
468  (unsigned int) 4);
469 }

References GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

◆ GNUNET_TRANSPORT_get_trait_hello()

int GNUNET_TRANSPORT_get_trait_hello ( const struct GNUNET_TESTING_Command cmd,
char **  hello 
)

Function to get the trait with the hello.

Parameters
[out]helloThe hello for the peer.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 480 of file transport_api_cmd_start_peer.c.

484 {
485  return cmd->traits (cmd->cls,
486  (const void **) hello,
487  "hello",
488  (unsigned int) 3);
489 }

References GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

Referenced by connect_peers_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_application_handle()

int GNUNET_TRANSPORT_get_trait_application_handle ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TRANSPORT_ApplicationHandle **  ah 
)

Function to get the trait with the transport application handle.

Parameters
[out]ahThe application handle.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 522 of file transport_api_cmd_start_peer.c.

527 {
528  return cmd->traits (cmd->cls,
529  (const void **) ah,
530  "application_handle",
531  (unsigned int) 0);
532 }
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.

References ah, GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

Referenced by connect_peers_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_get_trait_application_handle_v2()

int GNUNET_TRANSPORT_get_trait_application_handle_v2 ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TRANSPORT_ApplicationHandle **  ah 
)

Function to get the trait with the transport application handle.

Parameters
[out]ahThe application handle.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 523 of file transport_api_cmd_start_peer_v2.c.

528 {
529  return cmd->traits (cmd->cls,
530  (const void **) ah,
531  "application_handle",
532  (unsigned int) 0);
533 }

References ah, GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

Referenced by connect_peers_run().

Here is the caller graph for this function: