GNUnet  0.11.x
Macros | Functions
transport_api_cmd_start_peer.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_netjail_lib.h"
#include "gnunet_peerstore_service.h"
#include "gnunet_transport_core_service.h"
#include "gnunet_transport_application_service.h"
#include "transport-testing-cmds.h"
Include dependency graph for transport_api_cmd_start_peer.c:

Go to the source code of this file.


#define LOG(kind, ...)   GNUNET_log (kind, __VA_ARGS__)
 Generic logging shortcut. More...


static void retrieve_hello (void *cls)
 Function to start the retrieval task to retrieve the hello of this peer from the peerstore. More...
static void hello_iter_cb (void *cb_cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
 Callback delivering the hello of this peer from peerstore. More...
static void notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
 Disconnect callback for the connection to the core service. More...
static void * notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
 Connect callback for the connection to the core service. More...
static void start_peer_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 The run method of this cmd will start all services of a peer to test the transport service. More...
static void start_peer_cleanup (void *cls)
 The cleanup function of this cmd frees resources the cmd allocated. More...
static int start_peer_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 This function prepares an array with traits. More...
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_start_peer (const char *label, const char *system_label, uint32_t no, char *node_ip, struct GNUNET_MQ_MessageHandler *handlers, const char *cfgname, GNUNET_TRANSPORT_notify_connect_cb notify_connect, unsigned int broadcast)
 Create command. More...

Macro Definition Documentation


#define LOG (   kind,
)    GNUNET_log (kind, __VA_ARGS__)

Generic logging shortcut.

Definition at line 38 of file transport_api_cmd_start_peer.c.

Function Documentation

◆ retrieve_hello()

static void retrieve_hello ( void *  cls)

Function to start the retrieval task to retrieve the hello of this peer from the peerstore.

Definition at line 79 of file transport_api_cmd_start_peer.c.

80 {
81  struct StartPeerState *sps = cls;
82  sps->rh_task = NULL;
83  sps->pic = GNUNET_PEERSTORE_iterate (sps->ph,
84  "transport",
85  &sps->id,
88  sps);
90 }
Key used for storing HELLOs in the peerstore.
struct GNUNET_PEERSTORE_IterateContext * GNUNET_PEERSTORE_iterate(struct GNUNET_PEERSTORE_Handle *h, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Iterate over records matching supplied key information.
struct GNUNET_PeerIdentity id
Peer identity.
struct GNUNET_PEERSTORE_Handle * ph
Peer's PEERSTORE Handle.
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer's transport get hello handle to retrieve peer's HELLO message.
static void hello_iter_cb(void *cb_cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
Callback delivering the hello of this peer from peerstore.

References GNUNET_PEERSTORE_iterate(), GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, hello_iter_cb(), StartPeerState::id, StartPeerState::ph, StartPeerState::pic, and StartPeerState::rh_task.

Referenced by hello_iter_cb(), and start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hello_iter_cb()

static void hello_iter_cb ( void *  cb_cls,
const struct GNUNET_PEERSTORE_Record record,
const char *  emsg 

Callback delivering the hello of this peer from peerstore.

Definition at line 50 of file transport_api_cmd_start_peer.c.

53 {
54  struct StartPeerState *sps = cb_cls;
55  if (NULL == record)
56  {
57  sps->pic = NULL;
59  return;
60  }
61  // Check record type et al?
62  sps->hello_size = record->value_size;
63  sps->hello = GNUNET_malloc (sps->hello_size);
64  memcpy (sps->hello, record->value, sps->hello_size);
65  sps->hello[sps->hello_size - 1] = '\0';
68  sps->pic = NULL;
70 }
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
#define GNUNET_malloc(size)
Wrapper around malloc.
void GNUNET_PEERSTORE_iterate_cancel(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iterate request Please do not call after the iterate request is done.
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:1296
size_t hello_size
Hello size.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
static void retrieve_hello(void *cls)
Function to start the retrieval task to retrieve the hello of this peer from the peerstore.

References StartPeerState::ac, GNUNET_malloc, GNUNET_PEERSTORE_iterate_cancel(), GNUNET_SCHEDULER_add_now(), GNUNET_TESTING_async_finish(), StartPeerState::hello, StartPeerState::hello_size, StartPeerState::pic, record(), retrieve_hello(), and StartPeerState::rh_task.

Referenced by retrieve_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_disconnect()

static void notify_disconnect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  handler_cls 

Disconnect callback for the connection to the core service.

Definition at line 98 of file transport_api_cmd_start_peer.c.

101 {
102  struct StartPeerState *sps = cls;
105  "Peer %s disconnected from peer %u (`%s')\n",
106  GNUNET_i2s (peer),
107  sps->no,
108  GNUNET_i2s (&sps->id));
110 }
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
unsigned int no
An unique number to identify the peer.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define LOG(kind,...)
Generic logging shortcut.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), StartPeerState::id, LOG, StartPeerState::no, and peer.

Referenced by start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_connect()

static void* notify_connect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle mq 

Connect callback for the connection to the core service.

Definition at line 118 of file transport_api_cmd_start_peer.c.

121 {
122  struct StartPeerState *sps = cls;
124  struct GNUNET_HashCode hc;
125  struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key;
127  void *ret = NULL;
130  "This Peer %s \n",
131  GNUNET_i2s (&sps->id));
133  "Peer %s connected to peer number %u\n",
134  GNUNET_i2s (peer),
135  sps->no);
137  GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
140  memcpy (key,
141  &hc,
142  sizeof (*key));
144  key,
145  mq,
148  GNUNET_free (key);
150  sps->notify_connect (sps->,
151  peer);
153  // TODO what does the handler function need?
154  return ret;
155 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_HashCode key
The key used in the DHT.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
int GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Allow multiple values with the same key.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
A 512-bit hashcode.
A 256-bit hashcode.
struct GNUNET_TESTING_Interpreter * is
Interpreter we are part of.
struct GNUNET_CONTAINER_MultiShortmap * connected_peers_map
GNUNET_TRANSPORT_notify_connect_cb notify_connect

References StartPeerState::ac, StartPeerState::connected_peers_map, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_new, StartPeerState::id, GNUNET_TESTING_AsyncContext::is, key, LOG, mq, StartPeerState::no, StartPeerState::notify_connect, peer, and ret.

Referenced by start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_peer_run()

static void start_peer_run ( void *  cls,
struct GNUNET_TESTING_Interpreter is 

The run method of this cmd will start all services of a peer to test the transport service.

Definition at line 163 of file transport_api_cmd_start_peer.c.

165 {
166  struct StartPeerState *sps = cls;
167  char *emsg = NULL;
168  struct GNUNET_PeerIdentity dummy;
169  const struct GNUNET_TESTING_Command *system_cmd;
170  const struct GNUNET_TESTING_System *tl_system;
171  char *home;
172  char *transport_unix_path;
173  char *tcp_communicator_unix_path;
174  char *udp_communicator_unix_path;
175  char *bindto;
176  char *bindto_udp;
179  {
181  "File not found: `%s'\n",
182  sps->cfgname);
184  return;
185  }
190  GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname));
192  GNUNET_asprintf (&home,
193  "$GNUNET_TMP/test-transport/api-tcp-p%u",
194  sps->no);
196  GNUNET_asprintf (&transport_unix_path,
197  "$GNUNET_RUNTIME_DIR/tng-p%u.sock",
198  sps->no);
200  GNUNET_asprintf (&tcp_communicator_unix_path,
201  "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
202  sps->no);
204  GNUNET_asprintf (&udp_communicator_unix_path,
205  "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
206  sps->no);
208  GNUNET_asprintf (&bindto,
209  "%s:60002",
210  sps->node_ip);
212  GNUNET_asprintf (&bindto_udp,
213  "2086");
216  "node_ip %s\n",
217  bindto);
220  "bind_udp %s\n",
221  GNUNET_YES == sps->broadcast ?
222  bindto_udp : bindto);
224  GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME",
225  home);
226  GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH",
227  transport_unix_path);
228  GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
229  "BINDTO",
230  bindto);
231  GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
232  "BINDTO",
233  GNUNET_YES == sps->broadcast ?
234  bindto_udp : bindto);
235  GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
236  "UNIXPATH",
237  tcp_communicator_unix_path);
238  GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
239  "UNIXPATH",
240  udp_communicator_unix_path);
243  sps->system_label);
245  &tl_system);
247  sps->tl_system = tl_system;
250  "Creating testing library with key number %u\n",
251  sps->no);
253  if (GNUNET_SYSERR ==
255  GNUNET_TESTING_System *) tl_system,
256  sps->cfg))
257  {
259  "Testing library failed to create unique configuration based on `%s'\n",
260  sps->cfgname);
263  return;
264  }
266  sps->peer = GNUNET_TESTING_peer_configure ((struct
267  GNUNET_TESTING_System *) sps->
268  tl_system,
269  sps->cfg,
270  sps->no,
271  NULL,
272  &emsg);
273  if (NULL == sps->peer)
274  {
276  "Testing library failed to create unique configuration based on `%s': `%s' with key number %u\n",
277  sps->cfgname,
278  emsg,
279  sps->no);
280  GNUNET_free (emsg);
282  return;
283  }
286  {
288  "Testing library failed to create unique configuration based on `%s'\n",
289  sps->cfgname);
290  GNUNET_free (emsg);
292  return;
293  }
295  memset (&dummy,
296  '\0',
297  sizeof(dummy));
300  &sps->id);
302  if (0 == memcmp (&dummy,
303  &sps->id,
304  sizeof(struct GNUNET_PeerIdentity)))
305  {
307  "Testing library failed to obtain peer identity for peer %u\n",
308  sps->no);
309  GNUNET_free (emsg);
311  return;
312  }
314  "Peer %u configured with identity `%s'\n",
315  sps->no,
316  GNUNET_i2s_full (&sps->id));
318  sps->th = GNUNET_TRANSPORT_core_connect (sps->cfg,
319  NULL,
320  sps->handlers,
321  sps,
324  if (NULL == sps->th)
325  {
327  "Failed to connect to transport service for peer `%s': `%s'\n",
328  sps->cfgname,
329  emsg);
330  GNUNET_free (emsg);
332  return;
333  }
335  sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
336  if (NULL == sps->th)
337  {
339  "Failed to connect to peerstore service for peer `%s': `%s'\n",
340  sps->cfgname,
341  emsg);
342  GNUNET_free (emsg);
344  return;
345  }
348  if (NULL == sps->ah)
349  {
351  "Failed to initialize the TRANSPORT application suggestion client handle for peer `%s': `%s'\n",
352  sps->cfgname,
353  emsg);
354  GNUNET_free (emsg);
356  return;
357  }
359  GNUNET_free (home);
360  GNUNET_free (transport_unix_path);
361  GNUNET_free (tcp_communicator_unix_path);
362  GNUNET_free (udp_communicator_unix_path);
363  GNUNET_free (bindto);
364  GNUNET_free (bindto_udp);
365 }
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
Definition: gnunet_common.h:95
Definition: gnunet_common.h:97
Definition: gnunet_common.h:94
Definition: gnunet_common.h:93
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_test_system(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_System **ret)
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.
struct GNUNET_TRANSPORT_ApplicationHandle * GNUNET_TRANSPORT_application_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the TRANSPORT application client handle.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
Create a new configuration object.
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
enum GNUNET_GenericReturnValue 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:482
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
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:1170
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1363
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:1149
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:1341
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.
The identity of the host (wraps the signing key of the peer).
A command to be run by the interpreter.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:103
char * node_ip
The ip of a node.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
struct GNUNET_TESTING_Peer * peer
unsigned int broadcast
Flag indicating, if udp broadcast should be switched on.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
const struct GNUNET_TESTING_System * tl_system
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Connect callback for the connection to the core service.
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
Disconnect callback for the connection to the core service.

References StartPeerState::ah, StartPeerState::broadcast, StartPeerState::cfg, StartPeerState::cfgname, dummy, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_load(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_i2s_full(), GNUNET_NO, GNUNET_OK, GNUNET_PEERSTORE_connect(), GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, GNUNET_TESTING_configuration_create(), GNUNET_TESTING_get_trait_test_system(), GNUNET_TESTING_interpreter_fail(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TESTING_peer_configure(), GNUNET_TESTING_peer_get_identity(), GNUNET_TESTING_peer_start(), GNUNET_TRANSPORT_application_init(), GNUNET_TRANSPORT_core_connect(), GNUNET_YES, StartPeerState::handlers, StartPeerState::id, is, LOG, StartPeerState::no, StartPeerState::node_ip, notify_connect(), notify_disconnect(), StartPeerState::peer, StartPeerState::ph, retrieve_hello(), StartPeerState::rh_task, StartPeerState::system_label, StartPeerState::th, and StartPeerState::tl_system.

Here is the call graph for this function:

◆ start_peer_cleanup()

static void start_peer_cleanup ( void *  cls)

The cleanup function of this cmd frees resources the cmd allocated.

Definition at line 373 of file transport_api_cmd_start_peer.c.

374 {
375  struct StartPeerState *sps = cls;
377  if (NULL != sps->handlers)
378  {
379  GNUNET_free (sps->handlers);
380  sps->handlers = NULL;
381  }
382  if (NULL != sps->cfg)
383  {
385  sps->cfg = NULL;
386  }
387  GNUNET_free (sps->hello);
389  GNUNET_free (sps);
390 }

References StartPeerState::cfg, StartPeerState::connected_peers_map, GNUNET_CONFIGURATION_destroy(), GNUNET_free, StartPeerState::handlers, and StartPeerState::hello.

Here is the call graph for this function:

◆ start_peer_traits()

static int start_peer_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 

This function prepares an array with traits.

Definition at line 398 of file transport_api_cmd_start_peer.c.

402 {
403  struct StartPeerState *sps = cls;
405  struct GNUNET_PeerIdentity *id = &sps->id;
406  struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
407  sps->connected_peers_map;
408  char *hello = sps->hello;
409  size_t hello_size = sps->hello_size;
412  struct GNUNET_TESTING_Trait traits[] = {
414  GNUNET_TRANSPORT_make_trait_peer_id ((const void *) id),
416  void *)
417  connected_peers_map),
418  GNUNET_TRANSPORT_make_trait_hello ((const void *) hello),
419  GNUNET_TRANSPORT_make_trait_hello_size ((const void *) hello_size),
420  GNUNET_TRANSPORT_make_trait_state ((const void *) sps),
422  };
424  return GNUNET_TESTING_get_trait (traits,
425  ret,
426  trait,
427  index);
428 }
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" trait.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Extract a trait.
Internal representation of the hash map.
unsigned int index
Index number associated with the trait.
Handle to the TRANSPORT subsystem for application management.
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_application_handle(const struct GNUNET_TRANSPORT_ApplicationHandle *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_hello(const char *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_peer_id(const struct GNUNET_PeerIdentity *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_hello_size(const size_t *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_state(const struct StartPeerState *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_make_trait_connected_peers_map(const struct GNUNET_CONTAINER_MultiShortmap *value)

References ah, StartPeerState::ah, StartPeerState::connected_peers_map, GNUNET_TESTING_get_trait(), GNUNET_TESTING_trait_end(), GNUNET_TRANSPORT_make_trait_application_handle(), GNUNET_TRANSPORT_make_trait_connected_peers_map(), GNUNET_TRANSPORT_make_trait_hello(), GNUNET_TRANSPORT_make_trait_hello_size(), GNUNET_TRANSPORT_make_trait_peer_id(), GNUNET_TRANSPORT_make_trait_state(), StartPeerState::hello, StartPeerState::hello_size, StartPeerState::id, GNUNET_TESTING_Trait::index, and ret.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_cmd_start_peer()

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

Create command.

labelname for command.
system_labelLabel of the cmd to setup a test environment.
mThe number of the local node of the actual network namespace.
nThe number of the actual namespace.
local_mNumber of local nodes in each namespace.
handlersHandler for messages received by this peer.
cfgnameConfiguration file name for this peer.
notify_connectMethod which will be called, when a peer connects.
broadcastFlag indicating, if broadcast should be switched on.

Definition at line 398 of file transport_api_cmd_start_peer.c.

455 {
456  struct StartPeerState *sps;
457  struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
459  unsigned int i;
461  sps = GNUNET_new (struct StartPeerState);
462  sps->no = no;
463  sps->system_label = system_label;
464  sps->connected_peers_map = connected_peers_map;
465  sps->cfgname = cfgname;
466  sps->node_ip = node_ip;
468  sps->broadcast = broadcast;
470  if (NULL != handlers)
471  {
472  for (i = 0; NULL != handlers[i].cb; i++)
473  ;
474  sps->handlers = GNUNET_new_array (i + 1,
475  struct GNUNET_MQ_MessageHandler);
476  GNUNET_memcpy (sps->handlers,
477  handlers,
478  i * sizeof(struct GNUNET_MQ_MessageHandler));
479  }
481  struct GNUNET_TESTING_Command cmd = {
482  .cls = sps,
483  .label = label,
484  .run = &start_peer_run,
485  .ac = &sps->ac,
486  .cleanup = &start_peer_cleanup,
487  .traits = &start_peer_traits
488  };
490  return cmd;
491 }
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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_array(n, type)
Allocate a size n array with structs or unions of the given type.
Message handler for a specific message type.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
static void start_peer_cleanup(void *cls)
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, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will start all services of a peer to test the transport service.