GNUnet  0.10.x
Data Structures | Macros | Typedefs | Functions | Variables
transport-testing.h File Reference

testing lib for transport service More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_hello_service.h"
#include "gnunet_transport_manipulation_service.h"
#include "gnunet_testing_lib.h"
Include dependency graph for transport-testing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_TRANSPORT_TESTING_PeerContext
 Context for a single peer. More...
 
struct  GNUNET_TRANSPORT_TESTING_ConnectRequest
 Handle for a request to connect two peers. More...
 
struct  GNUNET_TRANSPORT_TESTING_Handle
 Handle for a test run. More...
 
struct  GNUNET_TRANSPORT_TESTING_TestMessage
 
struct  GNUNET_TRANSPORT_TESTING_ConnectCheckContext
 Closure that must be passed to GNUNET_TRANSPORT_TESTING_connect_check. More...
 
struct  GNUNET_TRANSPORT_TESTING_SendClosure
 Type of the closure argument to pass to GNUNET_TRANSPORT_TESTING_simple_send() and GNUNET_TRANSPORT_TESTING_large_send(). More...
 

Macros

#define GNUNET_TRANSPORT_TESTING_main(num_peers, check, check_cls)
 Setup testcase. More...
 
#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE   12345
 Message type used by GNUNET_TRANSPORT_TESTING_simple_send(). More...
 
#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2   12346
 Alternative message type for tests. More...
 
#define GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE   2600
 Size of a message sent with GNUNET_TRANSPORT_TESTING_large_send(). More...
 

Typedefs

typedef void(* GNUNET_TRANSPORT_TESTING_ConnectContextCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
 Function called on matching connect requests. More...
 
typedef void(* GNUNET_TRANSPORT_TESTING_ConnectContinuation) (void *cls, unsigned int num_peers, struct GNUNET_TRANSPORT_TESTING_PeerContext *p[])
 Function called once the peers have been launched and connected by GNUNET_TRANSPORT_TESTING_connect_check(). More...
 
typedef void(* GNUNET_TRANSPORT_TESTING_NotifyConnect) (void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)
 Function called to notify transport users that another peer connected to us. More...
 
typedef void(* GNUNET_TRANSPORT_TESTING_NotifyDisconnect) (void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)
 Function called to notify transport users that another peer disconnected from us. More...
 
typedef int(* GNUNET_TRANSPORT_TESTING_CheckCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_Handle *tth_, const char *test_plugin_, const char *test_name_, unsigned int num_peers, char *cfg_files[])
 Main function of a testcase. More...
 

Functions

struct GNUNET_TRANSPORT_TESTING_HandleGNUNET_TRANSPORT_TESTING_init (void)
 Initialize the transport testing. More...
 
void GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth)
 Clean up the transport testing. More...
 
struct GNUNET_TRANSPORT_TESTING_PeerContextGNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth, const char *cfgname, int peer_id, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd, void *cb_cls, GNUNET_SCHEDULER_TaskCallback start_cb, void *start_cb_cls)
 Start a peer with the given configuration. More...
 
void GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *pc)
 Shutdown the given peer. More...
 
int GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, GNUNET_SCHEDULER_TaskCallback restart_cb, void *restart_cb_cls)
 Stops and restarts the given peer, sleeping (!) for 5s in between. More...
 
struct GNUNET_TRANSPORT_TESTING_ConnectRequestGNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1, struct GNUNET_TRANSPORT_TESTING_PeerContext *p2, GNUNET_SCHEDULER_TaskCallback cb, void *cls)
 Connect the given peers and call the callback when both peers report the inbound connection. More...
 
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
 Cancel the request to connect two peers. More...
 
void GNUNET_TRANSPORT_TESTING_find_connecting_context (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1, struct GNUNET_TRANSPORT_TESTING_PeerContext *p2, GNUNET_TRANSPORT_TESTING_ConnectContextCallback cb, void *cb_cls)
 Find any connecting context matching the given pair of peers. More...
 
struct GNUNET_TRANSPORT_TESTING_PeerContextGNUNET_TRANSPORT_TESTING_find_peer (struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc, const struct GNUNET_PeerIdentity *peer)
 Find peer by peer ID. More...
 
int GNUNET_TRANSPORT_TESTING_connect_check (void *cls, struct GNUNET_TRANSPORT_TESTING_Handle *tth_, const char *test_plugin_, const char *test_name_, unsigned int num_peers, char *cfg_files[])
 Common implementation of the GNUNET_TRANSPORT_TESTING_CheckCallback. More...
 
int GNUNET_TRANSPORT_TESTING_main_ (const char *argv0, const char *filename, unsigned int num_peers, GNUNET_TRANSPORT_TESTING_CheckCallback check, void *check_cls)
 Setup testcase. More...
 
int GNUNET_TRANSPORT_TESTING_send (struct GNUNET_TRANSPORT_TESTING_PeerContext *sender, struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, uint16_t mtype, uint16_t msize, uint32_t num, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
 Send a test message of type mtype and size msize from peer sender to peer receiver. More...
 
void GNUNET_TRANSPORT_TESTING_simple_send (void *cls)
 Task that sends a minimalistic test message from the first peer to the second peer. More...
 
void GNUNET_TRANSPORT_TESTING_large_send (void *cls)
 Task that sends a large test message from the first peer to the second peer. More...
 
void GNUNET_TRANSPORT_TESTING_log_connect (void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)
 Log a connect event. More...
 
void GNUNET_TRANSPORT_TESTING_log_disconnect (void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)
 Log a disconnect event. More...
 
char * GNUNET_TRANSPORT_TESTING_get_test_name (const char *file)
 Extracts the test filename from an absolute file name and removes the extension. More...
 
char * GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, int count)
 This function takes the filename (e.g. More...
 
char * GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable, const char *testname)
 Extracts the plugin anme from an absolute file name and the test name. More...
 
char * GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file)
 Extracts the filename from an absolute file name and removes the extenstion. More...
 

Variables

GNUNET_NETWORK_STRUCT_END typedef void(* GNUNET_TRANSPORT_TESTING_ReceiveCallback )(void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
 Function called by the transport for each received message. More...
 

Detailed Description

testing lib for transport service

Author
Matthias Wachs
Christian Grothoff

Definition in file transport-testing.h.

Macro Definition Documentation

◆ GNUNET_TRANSPORT_TESTING_main

#define GNUNET_TRANSPORT_TESTING_main (   num_peers,
  check,
  check_cls 
)
Value:
__FILE__, \
check, \
check_cls)
static unsigned int num_peers
int GNUNET_TRANSPORT_TESTING_main_(const char *argv0, const char *filename, unsigned int num_peers, GNUNET_TRANSPORT_TESTING_CheckCallback check, void *check_cls)
Setup testcase.

Setup testcase.

Calls check with the data the test needs.

Parameters
num_peersnumber of peers to start
checkmain function to run
check_clsclosure for check
Returns
GNUNET_OK on success

Definition at line 721 of file transport-testing.h.

◆ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE

#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE   12345

Message type used by GNUNET_TRANSPORT_TESTING_simple_send().

Definition at line 761 of file transport-testing.h.

Referenced by connect_check_run(), and do_send().

◆ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2

#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2   12346

Alternative message type for tests.

Definition at line 766 of file transport-testing.h.

Referenced by connect_check_run().

◆ GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE

#define GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE   2600

Size of a message sent with GNUNET_TRANSPORT_TESTING_large_send().

Big enough to usually force defragmentation.

Definition at line 822 of file transport-testing.h.

Typedef Documentation

◆ GNUNET_TRANSPORT_TESTING_ConnectContextCallback

typedef void(* GNUNET_TRANSPORT_TESTING_ConnectContextCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)

Function called on matching connect requests.

Parameters
clsclosure
ccrequest matching the query

Definition at line 366 of file transport-testing.h.

◆ GNUNET_TRANSPORT_TESTING_ConnectContinuation

typedef void(* GNUNET_TRANSPORT_TESTING_ConnectContinuation) (void *cls, unsigned int num_peers, struct GNUNET_TRANSPORT_TESTING_PeerContext *p[])

Function called once the peers have been launched and connected by GNUNET_TRANSPORT_TESTING_connect_check().

Parameters
clsclosure
num_peerssize of the p array
pthe peers that were launched

Definition at line 398 of file transport-testing.h.

◆ GNUNET_TRANSPORT_TESTING_NotifyConnect

typedef void(* GNUNET_TRANSPORT_TESTING_NotifyConnect) (void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)

Function called to notify transport users that another peer connected to us.

Parameters
clsclosure
mepeer experiencing the event
otherpeer that connected to me

Definition at line 454 of file transport-testing.h.

◆ GNUNET_TRANSPORT_TESTING_NotifyDisconnect

typedef void(* GNUNET_TRANSPORT_TESTING_NotifyDisconnect) (void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *me, const struct GNUNET_PeerIdentity *other)

Function called to notify transport users that another peer disconnected from us.

Parameters
clsclosure
mepeer experiencing the event
otherpeer that disconnected from me

Definition at line 468 of file transport-testing.h.

◆ GNUNET_TRANSPORT_TESTING_CheckCallback

typedef int(* GNUNET_TRANSPORT_TESTING_CheckCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_Handle *tth_, const char *test_plugin_, const char *test_name_, unsigned int num_peers, char *cfg_files[])

Main function of a testcase.

Called with the initial setup data for the test as derived from the source name and the binary name.

Parameters
clsclosure
tth_initialized testing handle
test_plugin_name of the plugin
test_name_name of the test
num_peersnumber of entries in the cfg_file array
cfg_filesarray of names of configuration files for the peers
Returns
GNUNET_SYSERR on error

Definition at line 686 of file transport-testing.h.

Function Documentation

◆ GNUNET_TRANSPORT_TESTING_init()

struct GNUNET_TRANSPORT_TESTING_Handle* GNUNET_TRANSPORT_TESTING_init ( void  )

Initialize the transport testing.

Returns
transport testing handle

Definition at line 893 of file transport-testing.c.

References GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_TESTING_system_create(), and GNUNET_TRANSPORT_TESTING_Handle::tl_system.

Referenced by GNUNET_TRANSPORT_TESTING_main_().

894 {
896 
898  tth->tl_system = GNUNET_TESTING_system_create ("transport-testing",
899  NULL,
900  NULL,
901  NULL);
902  if (NULL == tth->tl_system)
903  {
905  "Failed to initialize testing library!\n");
906  GNUNET_free (tth);
907  return NULL;
908  }
909  return tth;
910 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TESTING_System * tl_system
Testing library system handle.
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services)
Create a system handle.
Definition: testing.c:449
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_done()

void GNUNET_TRANSPORT_TESTING_done ( struct GNUNET_TRANSPORT_TESTING_Handle tth)

Clean up the transport testing.

Parameters
tthtransport testing handle

Definition at line 853 of file transport-testing.c.

References GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_TESTING_system_destroy(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), GNUNET_TRANSPORT_TESTING_stop_peer(), GNUNET_YES, LOG, GNUNET_TRANSPORT_TESTING_PeerContext::next, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, p, GNUNET_TRANSPORT_TESTING_Handle::p_head, t, and GNUNET_TRANSPORT_TESTING_Handle::tl_system.

Referenced by GNUNET_TRANSPORT_TESTING_main_().

854 {
859 
860  if (NULL == tth)
861  return;
862  cc = tth->cc_head;
863  while (NULL != cc)
864  {
865  ct = cc->next;
867  "Developer forgot to cancel connect request!\n");
869  cc = ct;
870  }
871  p = tth->p_head;
872  while (NULL != p)
873  {
874  t = p->next;
876  "Developer forgot to stop peer!\n");
878  p = t;
879  }
881  GNUNET_YES);
882 
883  GNUNET_free (tth);
884 }
Handle for a request to connect two peers.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
Context for a single peer.
static struct GNUNET_SCHEDULER_Task * t
Main task.
#define LOG(kind,...)
struct GNUNET_TRANSPORT_TESTING_PeerContext * next
Next element in the DLL.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
struct GNUNET_TESTING_System * tl_system
Testing library system handle.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
Definition: testing.c:527
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers Tou MUST cancel the request if you stop the peers before the ...
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_TRANSPORT_TESTING_stop_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
Shutdown the given peer.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_start_peer()

struct GNUNET_TRANSPORT_TESTING_PeerContext* GNUNET_TRANSPORT_TESTING_start_peer ( struct GNUNET_TRANSPORT_TESTING_Handle tth,
const char *  cfgname,
int  peer_id,
const struct GNUNET_MQ_MessageHandler handlers,
GNUNET_TRANSPORT_NotifyConnect  nc,
GNUNET_TRANSPORT_NotifyDisconnect  nd,
void *  cb_cls,
GNUNET_SCHEDULER_TaskCallback  start_cb,
void *  start_cb_cls 
)

Start a peer with the given configuration.

Parameters
tththe testing handle
cfgnameconfiguration file
peer_idthe peer_id
handlersfunctions for receiving messages
ncconnect callback
nddisconnect callback
cb_clsclosure for nc and nd callback
start_cbstart callback
start_cb_clsclosure for start_cb
Returns
the peer context
Parameters
tththe testing handle
cfgnameconfiguration file
peer_ida unique number to identify the peer
handlersfunctions for receiving messages
ncconnect callback
nddisconnect callback
cb_clsclosure for callback
start_cbstart callback
start_cb_clsclosure for callback
Returns
the peer context

Definition at line 375 of file transport-testing.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_MQ_MessageHandler::cb, GNUNET_TRANSPORT_TESTING_PeerContext::cb_cls, GNUNET_TRANSPORT_TESTING_PeerContext::cfg, get_hello(), GNUNET_TRANSPORT_TESTING_PeerContext::ghh, GNUNET_assert, GNUNET_ATS_connectivity_init(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_load(), GNUNET_CONTAINER_DLL_insert, GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_free_non_null, GNUNET_i2s_full(), GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_configuration_create(), GNUNET_TESTING_peer_configure(), GNUNET_TESTING_peer_get_identity(), GNUNET_TESTING_peer_start(), GNUNET_TRANSPORT_AC_ANY, GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_hello_get(), GNUNET_TRANSPORT_manipulation_connect(), GNUNET_TRANSPORT_TESTING_stop_peer(), GNUNET_TRANSPORT_TESTING_PeerContext::handlers, GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, nc, GNUNET_TRANSPORT_TESTING_PeerContext::nc, GNUNET_TRANSPORT_TESTING_PeerContext::nd, GNUNET_TRANSPORT_TESTING_PeerContext::no, notify_connect(), notify_disconnect(), p, GNUNET_TRANSPORT_TESTING_Handle::p_head, GNUNET_TRANSPORT_TESTING_Handle::p_tail, GNUNET_TRANSPORT_TESTING_PeerContext::peer, peer_id, GNUNET_TRANSPORT_TESTING_PeerContext::start_cb, start_cb(), GNUNET_TRANSPORT_TESTING_PeerContext::start_cb_cls, GNUNET_TRANSPORT_TESTING_PeerContext::th, GNUNET_TRANSPORT_TESTING_Handle::tl_system, GNUNET_TRANSPORT_TESTING_PeerContext::tmh, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by connect_check_run().

384 {
385  char *emsg = NULL;
387  struct GNUNET_PeerIdentity dummy;
388  unsigned int i;
389 
390  if (GNUNET_NO == GNUNET_DISK_file_test (cfgname))
391  {
393  "File not found: `%s'\n",
394  cfgname);
395  return NULL;
396  }
397 
399  p->tth = tth;
400  p->nc = nc;
401  p->nd = nd;
402  if (NULL != handlers)
403  {
404  for (i=0;NULL != handlers[i].cb;i++) ;
405  p->handlers = GNUNET_new_array (i + 1,
406  struct GNUNET_MQ_MessageHandler);
408  handlers,
409  i * sizeof (struct GNUNET_MQ_MessageHandler));
410  }
411  if (NULL != cb_cls)
412  p->cb_cls = cb_cls;
413  else
414  p->cb_cls = p;
415  p->start_cb = start_cb;
416  if (NULL != start_cb_cls)
417  p->start_cb_cls = start_cb_cls;
418  else
419  p->start_cb_cls = p;
421  tth->p_tail,
422  p);
423 
424  /* Create configuration and call testing lib to modify it */
427  GNUNET_CONFIGURATION_load (p->cfg, cfgname));
428  if (GNUNET_SYSERR ==
430  p->cfg))
431  {
433  "Testing library failed to create unique configuration based on `%s'\n",
434  cfgname);
436  GNUNET_free (p);
437  return NULL;
438  }
439 
440  p->no = peer_id;
441  /* Configure peer with configuration */
443  p->cfg,
444  p->no,
445  NULL,
446  &emsg);
447  if (NULL == p->peer)
448  {
450  "Testing library failed to create unique configuration based on `%s': `%s'\n",
451  cfgname,
452  emsg);
454  GNUNET_free_non_null (emsg);
455  return NULL;
456  }
457  GNUNET_free_non_null (emsg);
459  {
461  "Testing library failed to create unique configuration based on `%s'\n",
462  cfgname);
464  return NULL;
465  }
466 
467  memset (&dummy,
468  '\0',
469  sizeof (dummy));
471  &p->id);
472  if (0 == memcmp (&dummy,
473  &p->id,
474  sizeof (struct GNUNET_PeerIdentity)))
475  {
477  "Testing library failed to obtain peer identity for peer %u\n",
478  p->no);
480  return NULL;
481  }
483  "Peer %u configured with identity `%s'\n",
484  p->no,
485  GNUNET_i2s_full (&p->id));
488  NULL,
489  handlers,
490  p,
493  NULL);
494  if ( (NULL == p->th) ||
495  (NULL == p->tmh) )
496  {
498  "Failed to connect to transport service for peer `%s': `%s'\n",
499  cfgname,
500  emsg);
502  return NULL;
503  }
505  if (NULL == p->ats)
506  {
508  "Failed to connect to ATS service for peer `%s': `%s'\n",
509  cfgname,
510  emsg);
512  return NULL;
513  }
516  &get_hello,
517  p);
518  GNUNET_assert (NULL != p->ghh);
519  return p;
520 }
int GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:669
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
static void get_hello(void *cb_cls, const struct GNUNET_MessageHeader *message)
static struct in_addr dummy
Target "dummy" address.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1315
struct GNUNET_PeerIdentity id
Peer identity.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context for a single peer.
GNUNET_TRANSPORT_NotifyDisconnect nd
Notify disconnect callback.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
#define LOG(kind,...)
unsigned int no
An unique number to identify the peer.
struct GNUNET_TESTING_System * tl_system
Testing library system handle.
int GNUNET_TESTING_configuration_create(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new configuration using the given configuration as a template; ports and paths will be modif...
Definition: testing.c:1113
GNUNET_SCHEDULER_TaskCallback start_cb
Startup completed callback.
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
struct GNUNET_TESTING_Peer * GNUNET_TESTING_peer_configure(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t key_number, struct GNUNET_PeerIdentity *id, char **emsg)
Configure a GNUnet peer.
Definition: testing.c:1134
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
#define GNUNET_memcpy(dst, src, n)
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
struct GNUNET_TRANSPORT_ManipulationHandle * tmh
Peer's transport service manipulation handle.
GNUNET_MQ_MessageCallback cb
Callback, called every time a new message of the specified type has been receied. ...
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
Message handler for a specific message type.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
struct GNUNET_TESTING_Peer * peer
Peer's testing handle.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
GNUNET_TRANSPORT_NotifyConnect nc
Notify connect callback.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_TRANSPORT_ManipulationHandle * GNUNET_TRANSPORT_manipulation_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the transport service.
struct GNUNET_TRANSPORT_HelloGetHandle * GNUNET_TRANSPORT_hello_get(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_TRANSPORT_AddressClass ac, GNUNET_TRANSPORT_HelloUpdateCallback rec, void *rec_cls)
Obtain updates on changes to the HELLO message for this peer.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1292
static void start_cb(void *cls)
Function called once we have successfully launched a peer.
void * cb_cls
Closure for the nc and nd callbacks.
void GNUNET_TRANSPORT_TESTING_stop_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
Shutdown the given peer.
struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Peer's transport get hello handle to retrieve peer's HELLO message.
void * start_cb_cls
Closure for start_cb.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_tail
tail DLL of peers
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_stop_peer()

void GNUNET_TRANSPORT_TESTING_stop_peer ( struct GNUNET_TRANSPORT_TESTING_PeerContext p)

Shutdown the given peer.

Parameters
pthe peer

Definition at line 625 of file transport-testing.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_PeerContext::cfg, GNUNET_TRANSPORT_TESTING_PeerContext::ghh, GNUNET_ATS_connectivity_done(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_OK, GNUNET_TESTING_peer_destroy(), GNUNET_TESTING_peer_stop(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_TRANSPORT_hello_get_cancel(), GNUNET_TRANSPORT_manipulation_disconnect(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), GNUNET_TRANSPORT_TESTING_PeerContext::handlers, GNUNET_TRANSPORT_TESTING_PeerContext::hello, GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, GNUNET_TRANSPORT_TESTING_PeerContext::no, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, GNUNET_TRANSPORT_TESTING_Handle::p_head, GNUNET_TRANSPORT_TESTING_Handle::p_tail, GNUNET_TRANSPORT_TESTING_PeerContext::peer, GNUNET_TRANSPORT_TESTING_PeerContext::th, GNUNET_TRANSPORT_TESTING_PeerContext::tmh, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by do_shutdown(), GNUNET_TRANSPORT_TESTING_done(), and GNUNET_TRANSPORT_TESTING_start_peer().

626 {
627  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
630 
631  for (cc = tth->cc_head; NULL != cc; cc = ccn)
632  {
633  ccn = cc->next;
634  if ( (cc->p1 == p) ||
635  (cc->p2 == p) )
637  }
638  if (NULL != p->ghh)
639  {
641  p->ghh = NULL;
642  }
643  if (NULL != p->tmh)
644  {
646  p->tmh = NULL;
647  }
648  if (NULL != p->th)
649  {
651  p->th = NULL;
652  }
653  if (NULL != p->peer)
654  {
655  if (GNUNET_OK !=
657  {
659  "Testing lib failed to stop peer %u (`%s')\n",
660  p->no,
661  GNUNET_i2s (&p->id));
662  }
664  p->peer = NULL;
665  }
666  if (NULL != p->ats)
667  {
669  p->ats = NULL;
670  }
671  if (NULL != p->hello)
672  {
673  GNUNET_free (p->hello);
674  p->hello = NULL;
675  }
676  if (NULL != p->cfg)
677  {
679  p->cfg = NULL;
680  }
681  if (NULL != p->handlers)
682  {
683  GNUNET_free (p->handlers);
684  p->handlers = NULL;
685  }
687  tth->p_tail,
688  p);
690  "Peer %u (`%s') stopped\n",
691  p->no,
692  GNUNET_i2s (&p->id));
693  GNUNET_free (p);
694 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle for a request to connect two peers.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
struct GNUNET_PeerIdentity id
Peer identity.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
#define LOG(kind,...)
unsigned int no
An unique number to identify the peer.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1418
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_TRANSPORT_ManipulationHandle * tmh
Peer's transport service manipulation handle.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_head
head DLL of peers
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
struct GNUNET_TESTING_Peer * peer
Peer's testing handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers Tou MUST cancel the request if you stop the peers before the ...
struct GNUNET_HELLO_Message * hello
Peers HELLO Message.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
void GNUNET_TRANSPORT_manipulation_disconnect(struct GNUNET_TRANSPORT_ManipulationHandle *handle)
Disconnect from the transport service.
struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Peer's transport get hello handle to retrieve peer's HELLO message.
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1511
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p_tail
tail DLL of peers
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_restart_peer()

int GNUNET_TRANSPORT_TESTING_restart_peer ( struct GNUNET_TRANSPORT_TESTING_PeerContext p,
GNUNET_SCHEDULER_TaskCallback  restart_cb,
void *  restart_cb_cls 
)

Stops and restarts the given peer, sleeping (!) for 5s in between.

Parameters
pthe peer
restart_cbrestart callback
restart_cb_clscallback closure
Returns
GNUNET_OK in success otherwise GNUNET_SYSERR
Parameters
pthe peer
restart_cbcallback to call when restarted
restart_cb_clscallback closure
Returns
GNUNET_OK in success otherwise GNUNET_SYSERR

Definition at line 532 of file transport-testing.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_PeerContext::cfg, get_hello(), GNUNET_TRANSPORT_TESTING_PeerContext::ghh, GNUNET_assert, GNUNET_ATS_connectivity_done(), GNUNET_ATS_connectivity_init(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_i2s(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_peer_start(), GNUNET_TESTING_peer_stop(), GNUNET_TRANSPORT_AC_ANY, GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_TRANSPORT_hello_get(), GNUNET_TRANSPORT_hello_get_cancel(), GNUNET_TRANSPORT_manipulation_disconnect(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), GNUNET_TRANSPORT_TESTING_PeerContext::handlers, GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, GNUNET_TRANSPORT_TESTING_PeerContext::no, notify_connect(), notify_disconnect(), GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, GNUNET_TRANSPORT_TESTING_PeerContext::peer, GNUNET_TRANSPORT_TESTING_PeerContext::start_cb, GNUNET_TRANSPORT_TESTING_PeerContext::start_cb_cls, GNUNET_TRANSPORT_TESTING_PeerContext::th, GNUNET_TRANSPORT_TESTING_PeerContext::tmh, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

535 {
538 
539  /* shutdown */
541  "Stopping peer %u (`%s')\n",
542  p->no,
543  GNUNET_i2s (&p->id));
544  if (NULL != p->ghh)
545  {
547  p->ghh = NULL;
548  }
549  if (NULL != p->th)
550  {
552  p->th = NULL;
553  }
554  if (NULL != p->tmh)
555  {
557  p->tmh = NULL;
558  }
559  for (cc = p->tth->cc_head; NULL != cc; cc = ccn)
560  {
561  ccn = cc->next;
562  if ( (cc->p1 == p) ||
563  (cc->p2 == p) )
565  }
566  if (NULL != p->ats)
567  {
569  p->ats = NULL;
570  }
571  if (GNUNET_SYSERR ==
573  {
575  "Failed to stop peer %u (`%s')\n",
576  p->no,
577  GNUNET_i2s (&p->id));
578  return GNUNET_SYSERR;
579  }
580 
581  sleep (5); // YUCK!
582 
584  "Restarting peer %u (`%s')\n",
585  p->no,
586  GNUNET_i2s (&p->id));
587  /* restart */
589  {
591  "Failed to restart peer %u (`%s')\n",
592  p->no,
593  GNUNET_i2s (&p->id));
594  return GNUNET_SYSERR;
595  }
596 
597  GNUNET_assert (NULL == p->start_cb);
598  p->start_cb = restart_cb;
599  p->start_cb_cls = restart_cb_cls;
600 
602  NULL,
603  p->handlers,
604  p,
607  NULL);
608  GNUNET_assert (NULL != p->th);
612  &get_hello,
613  p);
614  GNUNET_assert (NULL != p->ghh);
615  return GNUNET_OK;
616 }
Handle for a request to connect two peers.
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
static void get_hello(void *cb_cls, const struct GNUNET_MessageHeader *message)
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1315
struct GNUNET_PeerIdentity id
Peer identity.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
#define LOG(kind,...)
unsigned int no
An unique number to identify the peer.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1418
GNUNET_SCHEDULER_TaskCallback start_cb
Startup completed callback.
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
struct GNUNET_TRANSPORT_ManipulationHandle * tmh
Peer's transport service manipulation handle.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
struct GNUNET_TESTING_Peer * peer
Peer's testing handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers Tou MUST cancel the request if you stop the peers before the ...
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
struct GNUNET_TRANSPORT_HelloGetHandle * GNUNET_TRANSPORT_hello_get(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_TRANSPORT_AddressClass ac, GNUNET_TRANSPORT_HelloUpdateCallback rec, void *rec_cls)
Obtain updates on changes to the HELLO message for this peer.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
void GNUNET_TRANSPORT_manipulation_disconnect(struct GNUNET_TRANSPORT_ManipulationHandle *handle)
Disconnect from the transport service.
struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Peer's transport get hello handle to retrieve peer's HELLO message.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void * start_cb_cls
Closure for start_cb.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.
Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_connect_peers()

struct GNUNET_TRANSPORT_TESTING_ConnectRequest* GNUNET_TRANSPORT_TESTING_connect_peers ( struct GNUNET_TRANSPORT_TESTING_PeerContext p1,
struct GNUNET_TRANSPORT_TESTING_PeerContext p2,
GNUNET_SCHEDULER_TaskCallback  cb,
void *  cls 
)

Connect the given peers and call the callback when both peers report the inbound connection.

Remarks: start_peer's notify_connect callback can be called before.

Parameters
p1peer 1
p2peer 2
cbthe callback to call when both peers notified that they are connected
clscallback cls
Returns
a connect request handle

Connect the given peers and call the callback when both peers report the inbound connection.

Remarks: start_peer's notify_connect callback can be called before.

Parameters
tthtransport testing handle
p1peer 1
p2peer 2
cbthe callback to call when both peers notified that they are connected
clscallback cls
Returns
a connect request handle

Definition at line 762 of file transport-testing.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::ats, GNUNET_TRANSPORT_TESTING_ConnectRequest::ats_sh, GNUNET_TRANSPORT_TESTING_ConnectRequest::cb, GNUNET_TRANSPORT_TESTING_ConnectRequest::cb_cls, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_Handle::cc_tail, GNUNET_TRANSPORT_TESTING_ConnectRequest::connected, GNUNET_ATS_connectivity_suggest(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_TRANSPORT_TESTING_PeerContext::id, LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, offer_hello(), GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1_c, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2_c, GNUNET_TRANSPORT_TESTING_ConnectRequest::tct, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by do_connect().

766 {
767  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
770 
771  ccn = NULL;
772  for (cc = tth->cc_head; NULL != cc; cc = cc->next)
773  {
774  if ( (cc->p1 == p1) &&
775  (cc->p2 == p2) )
776  {
777  ccn = cc;
778  break;
779  }
780  }
781 
783  cc->p1 = p1;
784  cc->p2 = p2;
785  cc->cb = cb;
786  if (NULL != cls)
787  cc->cb_cls = cls;
788  else
789  cc->cb_cls = cc;
790  if (NULL != ccn)
791  {
792  cc->p1_c = ccn->p1_c;
793  cc->p2_c = ccn->p2_c;
794  cc->connected = ccn->connected;
795  }
797  tth->cc_tail,
798  cc);
800  cc);
802  &p2->id,
803  1);
805  "New connect request %p\n",
806  cc);
807  return cc;
808 }
Handle for a request to connect two peers.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
struct GNUNET_PeerIdentity id
Peer identity.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Handle by which we ask ATS to faciliate the connection.
#define LOG(kind,...)
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest(struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
We would like to receive address suggestions for a peer.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
int p1_c
Set if peer1 says the connection is up to peer2.
struct GNUNET_ATS_ConnectivityHandle * ats
Peer's ATS handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
int connected
GNUNET_YES if both p1_c and p2_c are GNUNET_YES.
GNUNET_SCHEDULER_TaskCallback cb
Function to call upon completion.
static void offer_hello(void *cls)
Offer the current HELLO of P2 to P1.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
int p2_c
Set if peer2 says the connection is up to peer1.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_tail
head DLL of connect contexts
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_connect_peers_cancel()

void GNUNET_TRANSPORT_TESTING_connect_peers_cancel ( struct GNUNET_TRANSPORT_TESTING_ConnectRequest cc)

Cancel the request to connect two peers.

You MUST cancel the request if you stop the peers before the peers connected succesfully.

Parameters
cca connect request handle

Cancel the request to connect two peers.

Parameters
tthtransport testing handle
cca connect request handle

Definition at line 819 of file transport-testing.c.

References GNUNET_TRANSPORT_TESTING_ConnectRequest::ats_sh, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_Handle::cc_tail, GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_offer_hello_cancel(), LOG, GNUNET_TRANSPORT_TESTING_ConnectRequest::oh, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::tct, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by do_shutdown(), GNUNET_TRANSPORT_TESTING_done(), GNUNET_TRANSPORT_TESTING_restart_peer(), and GNUNET_TRANSPORT_TESTING_stop_peer().

820 {
821  struct GNUNET_TRANSPORT_TESTING_Handle *tth = cc->p1->tth;
822 
824  "Canceling connect request!\n");
825  if (NULL != cc->tct)
826  {
828  cc->tct = NULL;
829  }
830  if (NULL != cc->oh)
831  {
833  cc->oh = NULL;
834  }
835  if (NULL != cc->ats_sh)
836  {
838  cc->ats_sh = NULL;
839  }
841  tth->cc_tail,
842  cc);
843  GNUNET_free (cc);
844 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Handle by which we inform the peer about the HELLO of the other peer.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Handle by which we ask ATS to faciliate the connection.
#define LOG(kind,...)
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
void GNUNET_TRANSPORT_offer_hello_cancel(struct GNUNET_TRANSPORT_OfferHelloHandle *ohh)
Cancel the request to transport to offer the HELLO message.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
struct GNUNET_SCHEDULER_Task * tct
Task by which we accomplish the connection.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_tail
head DLL of connect contexts
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_find_connecting_context()

void GNUNET_TRANSPORT_TESTING_find_connecting_context ( struct GNUNET_TRANSPORT_TESTING_PeerContext p1,
struct GNUNET_TRANSPORT_TESTING_PeerContext p2,
GNUNET_TRANSPORT_TESTING_ConnectContextCallback  cb,
void *  cb_cls 
)

Find any connecting context matching the given pair of peers.

Parameters
p1first peer
p2second peer
cbfunction to call
cb_clsclosure for cb

Definition at line 56 of file transport-testing.c.

References GNUNET_TRANSPORT_TESTING_ConnectRequest::cb, GNUNET_TRANSPORT_TESTING_Handle::cc_head, GNUNET_TRANSPORT_TESTING_ConnectRequest::next, GNUNET_TRANSPORT_TESTING_ConnectRequest::p1, GNUNET_TRANSPORT_TESTING_ConnectRequest::p2, and GNUNET_TRANSPORT_TESTING_PeerContext::tth.

Referenced by GNUNET_TRANSPORT_TESTING_send(), notify_connect(), and notify_disconnect().

60 {
61  struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
64 
65  for (cc = tth->cc_head; NULL != cc; cc = ccn)
66  {
67  ccn = cc->next;
68  if ( (cc->p1 == p1) &&
69  (cc->p2 == p2) )
70  cb (cb_cls,
71  cc);
72  }
73 }
Handle for a request to connect two peers.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * next
Kept in a DLL.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Transport testing handle this peer belongs to.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc_head
head DLL of connect contexts
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer we want to connect.
GNUNET_SCHEDULER_TaskCallback cb
Function to call upon completion.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer we want to connect.
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_find_peer()

struct GNUNET_TRANSPORT_TESTING_PeerContext* GNUNET_TRANSPORT_TESTING_find_peer ( struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext ccc,
const struct GNUNET_PeerIdentity peer 
)

Find peer by peer ID.

Parameters
ccccontext to search
peerpeer to look for
Returns
NULL if peer was not found

Definition at line 209 of file transport-testing-main.c.

References GNUNET_TRANSPORT_TESTING_PeerContext::id, GNUNET_TRANSPORT_TESTING_ConnectCheckContext::num_peers, and GNUNET_TRANSPORT_TESTING_ConnectCheckContext::p.

211 {
212  for (unsigned int i=0;i<ccc->num_peers;i++)
213  if ( (NULL != ccc->p[i]) &&
214  (0 == memcmp (peer,
215  &ccc->p[i]->id,
216  sizeof (*peer))) )
217  return ccc->p[i];
218  return NULL;
219 }
struct GNUNET_TRANSPORT_TESTING_PeerContext ** p
Array with num_peers entries.
struct GNUNET_PeerIdentity id
Peer identity.
unsigned int num_peers
Number of peers involved in the test.

◆ GNUNET_TRANSPORT_TESTING_connect_check()

int GNUNET_TRANSPORT_TESTING_connect_check ( void *  cls,
struct GNUNET_TRANSPORT_TESTING_Handle tth_,
const char *  test_plugin_,
const char *  test_name_,
unsigned int  num_peers,
char *  cfg_files[] 
)

Common implementation of the GNUNET_TRANSPORT_TESTING_CheckCallback.

Starts and connects the two peers, then invokes the connect_continuation from cls. Sets up a timeout to abort the test, and a shutdown handler to clean up properly on exit.

Parameters
clsclosure of type struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext
tth_initialized testing handle
test_plugin_name of the plugin
test_name_name of the test
num_peersnumber of entries in the cfg_file array
cfg_filesarray of names of configuration files for the peers
Returns
GNUNET_SYSERR on error

Definition at line 505 of file transport-testing-main.c.

References GNUNET_TRANSPORT_TESTING_ConnectRequestList::ccc, GNUNET_TRANSPORT_TESTING_InternalPeerContext::ccc, GNUNET_TRANSPORT_TESTING_ConnectCheckContext::cfg_files, GNUNET_TRANSPORT_TESTING_ConnectCheckContext::cls, GNUNET_TRANSPORT_TESTING_ConnectCheckContext::config_file, connect_check_run(), GNUNET_TRANSPORT_TESTING_ConnectCheckContext::global_ret, GNUNET_GETOPT_OPTION_END, GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_SYSERR, GNUNET_TRANSPORT_TESTING_ConnectCheckContext::ip, num_peers, GNUNET_TRANSPORT_TESTING_ConnectCheckContext::num_peers, GNUNET_TRANSPORT_TESTING_InternalPeerContext::off, p, GNUNET_TRANSPORT_TESTING_ConnectCheckContext::p, GNUNET_TRANSPORT_TESTING_ConnectCheckContext::test_name, GNUNET_TRANSPORT_TESTING_ConnectCheckContext::test_plugin, and GNUNET_TRANSPORT_TESTING_ConnectCheckContext::tth.

511 {
512  static struct GNUNET_GETOPT_CommandLineOption options[] = {
514  };
518  char * argv[] = {
519  (char *) test_name_,
520  "-c",
521  (char *) ccc->config_file,
522  NULL
523  };
524 
525  ccc->num_peers = num_peers;
526  ccc->cfg_files = cfg_files;
527  ccc->test_plugin = test_plugin_;
528  ccc->test_name = test_name_;
529  ccc->tth = tth_;
530  ccc->global_ret = GNUNET_OK;
531  ccc->p = p;
532  ccc->ip = ip;
533  for (unsigned int i=0;i<num_peers;i++)
534  {
535  ip[i].off = i;
536  ip[i].ccc = ccc;
537  }
538  if (GNUNET_OK !=
539  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
540  argv,
541  test_name_,
542  "nohelp",
543  options,
545  ccc))
546  return GNUNET_SYSERR;
547  return ccc->global_ret;
548 }
int global_ret
Result from the main function, set to GNUNET_OK on success.
struct GNUNET_TRANSPORT_TESTING_PeerContext ** p
Array with num_peers entries.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
const char * test_name
Name of the testcase.
Closure that must be passed to GNUNET_TRANSPORT_TESTING_connect_check.
unsigned int num_peers
Number of peers involved in the test.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Main testing handle.
Context for a single peer.
char ** cfg_files
Configuration files we have, array with num_peers entries.
unsigned int off
Offset of the peer this is about.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Definition of a command line option.
struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext * ccc
Overall context of the callback.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void * cls
Closure for rec, nc and nd.
const char * config_file
Which configuration file should we pass to the GNUNET_PROGRAM_run() of the testcase?
const char * test_plugin
Name of the plugin.
struct GNUNET_TRANSPORT_TESTING_InternalPeerContext * ip
Array with num_peers entries.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int num_peers
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:361
static void connect_check_run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Function run from GNUNET_TRANSPORT_TESTING_connect_check once the scheduler is up.
Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_main_()

int GNUNET_TRANSPORT_TESTING_main_ ( const char *  argv0,
const char *  filename,
unsigned int  num_peers,
GNUNET_TRANSPORT_TESTING_CheckCallback  check,
void *  check_cls 
)

Setup testcase.

Calls check with the data the test needs.

Parameters
argv0binary name (argv[0])
filenamesource file name (FILE)
num_peersnumber of peers to start
checkmain function to run
check_clsclosure for check
Returns
GNUNET_OK on success

Definition at line 562 of file transport-testing-main.c.

References GNUNET_free, GNUNET_free_non_null, GNUNET_log_setup(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TRANSPORT_TESTING_done(), GNUNET_TRANSPORT_TESTING_get_config_name(), GNUNET_TRANSPORT_TESTING_get_test_name(), GNUNET_TRANSPORT_TESTING_get_test_plugin_name(), GNUNET_TRANSPORT_TESTING_get_test_source_name(), GNUNET_TRANSPORT_TESTING_init(), num_peers, and ret.

567 {
569  char *test_name;
570  char *test_source;
571  char *test_plugin;
572  char *cfg_names[num_peers];
573  int ret;
574 
575  ret = GNUNET_OK;
576  test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv0);
577  GNUNET_log_setup (test_name,
578  "WARNING",
579  NULL);
582  test_source);
583  for (unsigned int i=0;i<num_peers;i++)
584  cfg_names[i] = GNUNET_TRANSPORT_TESTING_get_config_name (argv0,
585  i+1);
587  if (NULL == tth)
588  {
589  ret = GNUNET_SYSERR;
590  }
591  else
592  {
593  ret = check (check_cls,
594  tth,
595  test_plugin,
596  test_name,
597  num_peers,
598  cfg_names);
600  }
601  for (unsigned int i=0;i<num_peers;i++)
602  GNUNET_free (cfg_names[i]);
603  GNUNET_free (test_source);
604  GNUNET_free_non_null (test_plugin);
605  GNUNET_free (test_name);
606  return ret;
607 }
struct GNUNET_TRANSPORT_TESTING_Handle * GNUNET_TRANSPORT_TESTING_init()
Initialize the transport testing.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
char * GNUNET_TRANSPORT_TESTING_get_test_name(const char *file)
Extracts the test filename from an absolute file name and removes the extension.
static int ret
Final status code.
Definition: gnunet-arm.c:89
void GNUNET_TRANSPORT_TESTING_done(struct GNUNET_TRANSPORT_TESTING_Handle *tth)
Clean up the transport testing.
static char * filename
char * GNUNET_TRANSPORT_TESTING_get_test_plugin_name(const char *file, const char *test)
Extracts the plugin name from an absolute file name and the test name.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int num_peers
char * GNUNET_TRANSPORT_TESTING_get_test_source_name(const char *file)
Extracts the filename from an absolute file name and removes the extension.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_TRANSPORT_TESTING_get_config_name(const char *file, int count)
This function takes the filename (e.g.
Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_send()

int GNUNET_TRANSPORT_TESTING_send ( struct GNUNET_TRANSPORT_TESTING_PeerContext sender,
struct GNUNET_TRANSPORT_TESTING_PeerContext receiver,
uint16_t  mtype,
uint16_t  msize,
uint32_t  num,
GNUNET_SCHEDULER_TaskCallback  cont,
void *  cont_cls 
)

Send a test message of type mtype and size msize from peer sender to peer receiver.

The peers should be connected when this function is called.

Parameters
senderthe sending peer
receiverthe receiving peer
mtypemessage type to use
msizesize of the message, at least sizeof (struct GNUNET_TRANSPORT_TESTING_TestMessage)
numunique message number
contcontinuation to call after transmission
cont_clsclosure for cont
Returns
GNUNET_OK if message was queued, GNUNET_NO if peers are not connected GNUNET_SYSERR if msize is illegal

Definition at line 65 of file transport-testing-send.c.

References env, find_cr(), GNUNET_break, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, GNUNET_TRANSPORT_TESTING_find_connecting_context(), GNUNET_TRANSPORT_TESTING_PeerContext::id, GNUNET_TRANSPORT_TESTING_ConnectRequest::mq, GNUNET_TRANSPORT_TESTING_PeerContext::no, and GNUNET_TRANSPORT_TESTING_TestMessage::num.

Referenced by do_send().

72 {
74  struct GNUNET_MQ_Envelope *env;
76 
77  if (msize < sizeof (struct GNUNET_TRANSPORT_TESTING_TestMessage))
78  {
79  GNUNET_break (0);
80  return GNUNET_SYSERR;
81  }
82  cr = NULL;
84  receiver,
85  &find_cr,
86  &cr);
87  if (NULL == cr)
89  sender,
90  &find_cr,
91  &cr);
92  if (NULL == cr)
93  {
94  GNUNET_break (0);
95  return GNUNET_NO;
96  }
97  if (NULL == cr->mq)
98  {
99  GNUNET_break (0);
100  return GNUNET_NO;
101  }
102  {
103  char *receiver_s = GNUNET_strdup (GNUNET_i2s (&receiver->id));
104 
106  "Sending message from peer %u (`%s') -> peer %u (`%s') !\n",
107  sender->no,
108  GNUNET_i2s (&sender->id),
109  receiver->no,
110  receiver_s);
111  GNUNET_free (receiver_s);
112  }
113  env = GNUNET_MQ_msg_extra (test,
114  msize - sizeof (*test),
115  mtype);
116  test->num = htonl (num);
117  memset (&test[1],
118  num,
119  msize - sizeof (*test));
121  cont,
122  cont_cls);
123  GNUNET_MQ_send (cr->mq,
124  env);
125  return GNUNET_OK;
126 }
Handle for a request to connect two peers.
struct GNUNET_PeerIdentity id
Peer identity.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
unsigned int no
An unique number to identify the peer.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MQ_Handle * mq
Message queue for sending from p1 to p2.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
void GNUNET_TRANSPORT_TESTING_find_connecting_context(struct GNUNET_TRANSPORT_TESTING_PeerContext *p1, struct GNUNET_TRANSPORT_TESTING_PeerContext *p2, GNUNET_TRANSPORT_TESTING_ConnectContextCallback cb, void *cb_cls)
Find any connecting context matching the given pair of peers.
uint32_t num
Monotonically increasing counter throughout the test.
static void find_cr(void *cls, struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
Return cx in cls.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
Definition: mq.c:774
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_log(kind,...)
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_simple_send()

void GNUNET_TRANSPORT_TESTING_simple_send ( void *  cls)

Task that sends a minimalistic test message from the first peer to the second peer.

Parameters
clsthe struct GNUNET_TRANSPORT_TESTING_SendClosure which should contain at least two peers, the first two of which should be currently connected
clsthe struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext which should contain at least two peers, the first two of which should be currently connected

Definition at line 174 of file transport-testing-send.c.

References GNUNET_TRANSPORT_TESTING_SendClosure::ccc, GNUNET_TRANSPORT_TESTING_SendClosure::cont, GNUNET_TRANSPORT_TESTING_SendClosure::cont_cls, do_send(), done(), GNUNET_TRANSPORT_TESTING_SendClosure::get_size_cb, GNUNET_TRANSPORT_TESTING_simple_send(), GNUNET_TRANSPORT_TESTING_SendClosure::num_messages, and sc.

Referenced by GNUNET_TRANSPORT_TESTING_simple_send().

175 {
177  int done;
178  size_t msize;
179 
180  if (0 < sc->num_messages)
181  {
182  sc->num_messages--;
183  done = (0 == sc->num_messages);
184  }
185  else
186  {
187  done = 0; /* infinite loop */
188  }
189  msize = sizeof (struct GNUNET_TRANSPORT_TESTING_TestMessage);
190  if (NULL != sc->get_size_cb)
191  msize = sc->get_size_cb (sc->num_messages);
192  /* if this was the last message, call the continuation,
193  otherwise call this function again */
194  do_send (sc->ccc,
195  msize,
197  done ? sc->cont_cls : sc);
198 }
static void done()
unsigned int num_messages
Number of messages to be transmitted in a loop.
size_t(* get_size_cb)(unsigned int n)
Function that returns the desired message size.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
GNUNET_SCHEDULER_TaskCallback cont
Function to call after all transmissions, can be NULL.
static void do_send(struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc, uint16_t size, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Task that sends a test message from the first peer to the second peer.
struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext * ccc
Context for the transmission.
Type of the closure argument to pass to GNUNET_TRANSPORT_TESTING_simple_send() and GNUNET_TRANSPORT_T...
void GNUNET_TRANSPORT_TESTING_simple_send(void *cls)
Task that sends a minimalistic test message from the first peer to the second peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_large_send()

void GNUNET_TRANSPORT_TESTING_large_send ( void *  cls)

Task that sends a large test message from the first peer to the second peer.

Parameters
clsthe struct GNUNET_TRANSPORT_TESTING_SendClosure which should contain at least two peers, the first two of which should be currently connected
clsthe struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext which should contain at least two peers, the first two of which should be currently connected

Definition at line 210 of file transport-testing-send.c.

References GNUNET_TRANSPORT_TESTING_SendClosure::ccc, GNUNET_TRANSPORT_TESTING_SendClosure::cont, GNUNET_TRANSPORT_TESTING_SendClosure::cont_cls, do_send(), done(), GNUNET_TRANSPORT_TESTING_SendClosure::get_size_cb, GNUNET_TRANSPORT_TESTING_large_send(), GNUNET_TRANSPORT_TESTING_SendClosure::num_messages, and sc.

Referenced by GNUNET_TRANSPORT_TESTING_large_send().

211 {
213  int done;
214  size_t msize;
215 
216  if (0 < sc->num_messages)
217  {
218  sc->num_messages--;
219  done = (0 == sc->num_messages);
220  }
221  else
222  {
223  done = 0; /* infinite loop */
224  }
225  msize = 2600;
226  if (NULL != sc->get_size_cb)
227  msize = sc->get_size_cb (sc->num_messages);
228  /* if this was the last message, call the continuation,
229  otherwise call this function again */
230  do_send (sc->ccc,
231  msize,
233  done ? sc->cont_cls : sc);
234 }
static void done()
unsigned int num_messages
Number of messages to be transmitted in a loop.
size_t(* get_size_cb)(unsigned int n)
Function that returns the desired message size.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
GNUNET_SCHEDULER_TaskCallback cont
Function to call after all transmissions, can be NULL.
static void do_send(struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc, uint16_t size, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Task that sends a test message from the first peer to the second peer.
struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext * ccc
Context for the transmission.
Type of the closure argument to pass to GNUNET_TRANSPORT_TESTING_simple_send() and GNUNET_TRANSPORT_T...
void GNUNET_TRANSPORT_TESTING_large_send(void *cls)
Task that sends a large test message from the first peer to the second peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_log_connect()

void GNUNET_TRANSPORT_TESTING_log_connect ( void *  cls,
struct GNUNET_TRANSPORT_TESTING_PeerContext me,
const struct GNUNET_PeerIdentity other 
)

Log a connect event.

Parameters
clsNULL
mepeer that had the event
otherpeer that connected.

Definition at line 37 of file transport-testing-loggers.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_strdup, GNUNET_TRANSPORT_TESTING_PeerContext::id, and GNUNET_TRANSPORT_TESTING_PeerContext::no.

40 {
41  char *ps;
42 
43  ps = GNUNET_strdup (GNUNET_i2s (&me->id));
45  "Peer %s connected to %u (%s)!\n",
46  GNUNET_i2s (other),
47  me->no,
48  ps);
49  GNUNET_free (ps);
50 }
struct GNUNET_PeerIdentity id
Peer identity.
unsigned int no
An unique number to identify the peer.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_log_disconnect()

void GNUNET_TRANSPORT_TESTING_log_disconnect ( void *  cls,
struct GNUNET_TRANSPORT_TESTING_PeerContext me,
const struct GNUNET_PeerIdentity other 
)

Log a disconnect event.

Parameters
clsNULL
mepeer that had the event
otherpeer that disconnected.

Definition at line 62 of file transport-testing-loggers.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_strdup, GNUNET_TRANSPORT_TESTING_PeerContext::id, and GNUNET_TRANSPORT_TESTING_PeerContext::no.

65 {
66  char *ps;
67 
68  ps = GNUNET_strdup (GNUNET_i2s (&me->id));
70  "Peer `%s' disconnected from %u (%s)!\n",
71  GNUNET_i2s (other),
72  me->no,
73  ps);
74  GNUNET_free (ps);
75 }
struct GNUNET_PeerIdentity id
Peer identity.
unsigned int no
An unique number to identify the peer.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_TRANSPORT_TESTING_get_test_name()

char* GNUNET_TRANSPORT_TESTING_get_test_name ( const char *  file)

Extracts the test filename from an absolute file name and removes the extension.

Parameters
fileabsolute file name
Returns
resulting test name
Parameters
fileabsolute file name
Returns
the result

Definition at line 91 of file transport-testing-filenames.c.

References extract_filename(), filename, GNUNET_free, GNUNET_strdup, and ret.

Referenced by GNUNET_TRANSPORT_TESTING_main_().

92 {
93  char *backup = extract_filename (file);
94  char *filename = backup;
95  char *dotexe;
96  char *ret;
97 
98  if (NULL == filename)
99  return NULL;
100 
101  /* remove "lt-" */
102  filename = strstr (filename, "test");
103  if (NULL == filename)
104  {
105  GNUNET_free (backup);
106  return NULL;
107  }
108 
109  /* remove ".exe" */
110  if (NULL != (dotexe = strstr (filename, ".exe")))
111  dotexe[0] = '\0';
112  ret = GNUNET_strdup (filename);
113  GNUNET_free (backup);
114  return ret;
115 }
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * filename
static char * extract_filename(const char *file)
Removes all directory separators from absolute filename.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_get_config_name()

char* GNUNET_TRANSPORT_TESTING_get_config_name ( const char *  file,
int  count 
)

This function takes the filename (e.g.

argv[0), removes a "lt-"-prefix and if existing ".exe"-prefix and adds the peer-number

Parameters
filefilename of the test, e.g. argv[0]
countpeer number
Returns
configuration name to use

argv[0), removes a "lt-"-prefix and if existing ".exe"-prefix and adds the peer-number

Parameters
filefilename of the test, e.g. argv[0]
countpeer number
Returns
the result

Definition at line 192 of file transport-testing-filenames.c.

References extract_filename(), filename, GNUNET_asprintf(), GNUNET_free, and ret.

Referenced by GNUNET_TRANSPORT_TESTING_main_().

194 {
195  char *filename = extract_filename (file);
196  char *backup = filename;
197  char *dotexe;
198  char *ret;
199 
200  if (NULL == filename)
201  return NULL;
202  /* remove "lt-" */
203  filename = strstr (filename, "test");
204  if (NULL == filename)
205  goto fail;
206  /* remove ".exe" */
207  if (NULL != (dotexe = strstr (filename, ".exe")))
208  dotexe[0] = '\0';
209  GNUNET_asprintf (&ret,
210  "%s_peer%u.conf",
211  filename,
212  count);
213  GNUNET_free (backup);
214  return ret;
215 fail:
216  GNUNET_free (backup);
217  return NULL;
218 }
static int ret
Final status code.
Definition: gnunet-arm.c:89
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static char * filename
static char * extract_filename(const char *file)
Removes all directory separators from absolute filename.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_get_test_plugin_name()

char* GNUNET_TRANSPORT_TESTING_get_test_plugin_name ( const char *  file,
const char *  test 
)

Extracts the plugin anme from an absolute file name and the test name.

Parameters
fileabsolute file name
testtest name
Returns
the plugin name

Extracts the plugin anme from an absolute file name and the test name.

Parameters
fileabsolute file name
testtest name
Returns
the result

Definition at line 145 of file transport-testing-filenames.c.

References e, extract_filename(), filename, GNUNET_free, GNUNET_strdup, ret, and t.

Referenced by GNUNET_TRANSPORT_TESTING_main_().

147 {
148  char *filename;
149  char *dotexe;
150  char *e = extract_filename (file);
151  char *t = extract_filename (test);
152  char *ret;
153 
154  if (NULL == e)
155  goto fail;
156  /* remove "lt-" */
157  filename = strstr (e, "tes");
158  if (NULL == filename)
159  goto fail;
160  /* remove ".exe" */
161  if (NULL != (dotexe = strstr (filename, ".exe")))
162  dotexe[0] = '\0';
163 
164  /* find last _ */
165  filename = strstr (filename, t);
166  if (NULL == filename)
167  goto fail;
168  /* copy plugin */
169  filename += strlen (t);
170  if ('\0' != *filename)
171  filename++;
172  ret = GNUNET_strdup (filename);
173  goto suc;
174 fail:
175  ret = NULL;
176 suc:
177  GNUNET_free (t);
178  GNUNET_free (e);
179  return ret;
180 }
static struct Experiment * e
static struct GNUNET_SCHEDULER_Task * t
Main task.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * filename
static char * extract_filename(const char *file)
Removes all directory separators from absolute filename.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_TESTING_get_test_source_name()

char* GNUNET_TRANSPORT_TESTING_get_test_source_name ( const char *  file)

Extracts the filename from an absolute file name and removes the extenstion.

Parameters
fileabsolute file name
Returns
the source name

Extracts the filename from an absolute file name and removes the extenstion.

Parameters
fileabsolute file name
Returns
the result

Definition at line 125 of file transport-testing-filenames.c.

References extract_filename().

Referenced by GNUNET_TRANSPORT_TESTING_main_().

126 {
127  char *src = extract_filename (file);
128  char *split;
129 
130  split = strstr (src, ".");
131  if (NULL != split)
132  split[0] = '\0';
133  return src;
134 }
static char * extract_filename(const char *file)
Removes all directory separators from absolute filename.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ GNUNET_TRANSPORT_TESTING_ReceiveCallback

GNUNET_NETWORK_STRUCT_END typedef void(* GNUNET_TRANSPORT_TESTING_ReceiveCallback) (void *cls, struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)

Function called by the transport for each received message.

Parameters
clsclosure
receiverreceiver of the message
sendersender of the message
messagethe message

Definition at line 439 of file transport-testing.h.