GNUnet 0.22.2
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.

Macros

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

Functions

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, const char *node_ip, struct GNUNET_MQ_MessageHandler *handlers, const char *cfgname, GNUNET_TRANSPORT_notify_connect_cb notify_connect, unsigned int broadcast)
 Create command. More...
 

Macro Definition Documentation

◆ LOG

#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)
static

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

Definition at line 82 of file transport_api_cmd_start_peer.c.

83{
84 struct GNUNET_TESTING_StartPeerState *sps = cls;
85 sps->rh_task = NULL;
87 "transport",
88 &sps->id,
91 sps);
92
93}
struct GNUNET_PEERSTORE_IterateContext * GNUNET_PEERSTORE_iteration_start(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 peerstore entries.
#define GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY
Key used for storing HELLOs in the peerstore.
Handle for a peer controlled via ARM.
struct GNUNET_PeerIdentity id
Peer identity.
struct GNUNET_PEERSTORE_IterateContext * pic
Peer's transport get hello handle to retrieve peer's HELLO message.
struct GNUNET_PEERSTORE_Handle * ph
Peer's PEERSTORE Handle.
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
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_iteration_start(), GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, hello_iter_cb(), GNUNET_TESTING_StartPeerState::id, GNUNET_TESTING_StartPeerState::ph, GNUNET_TESTING_StartPeerState::pic, and GNUNET_TESTING_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 
)
static

Callback delivering the hello of this peer from peerstore.

Definition at line 50 of file transport_api_cmd_start_peer.c.

53{
54 struct GNUNET_TESTING_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';
66
68 "Our hello %s\n",
69 sps->hello);
71 sps->pic = NULL;
73}
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.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_malloc(size)
Wrapper around malloc.
void GNUNET_PEERSTORE_iteration_stop(struct GNUNET_PEERSTORE_IterateContext *ic)
Cancel an iteration.
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:1304
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.
#define LOG(kind,...)
Generic logging shortcut.

References GNUNET_TESTING_StartPeerState::ac, GNUNET_ERROR_TYPE_DEBUG, GNUNET_malloc, GNUNET_PEERSTORE_iteration_stop(), GNUNET_SCHEDULER_add_now(), GNUNET_TESTING_async_finish(), GNUNET_TESTING_StartPeerState::hello, GNUNET_TESTING_StartPeerState::hello_size, LOG, GNUNET_TESTING_StartPeerState::pic, record(), retrieve_hello(), and GNUNET_TESTING_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 
)
static

Disconnect callback for the connection to the core service.

Definition at line 101 of file transport_api_cmd_start_peer.c.

104{
105 struct GNUNET_TESTING_StartPeerState *sps = cls;
106
108 "Peer %s disconnected from peer %u (`%s')\n",
110 sps->no,
111 GNUNET_i2s (&sps->id));
112
113}
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_TESTING_Peer * peer
struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_TESTING_StartPeerState::id, LOG, GNUNET_TESTING_StartPeerState::no, and GNUNET_TESTING_StartPeerState::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 
)
static

Connect callback for the connection to the core service.

Definition at line 121 of file transport_api_cmd_start_peer.c.

124{
125 struct GNUNET_TESTING_StartPeerState *sps = cls;
127 struct GNUNET_HashCode hc;
128 struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key;
129
130 void *ret = (struct GNUNET_PeerIdentity *) peer;
131
133 "This Peer %s \n",
134 GNUNET_i2s (&sps->id));
135
136
138
140 "Peer %s connected to peer number %u with mq %p\n",
141 GNUNET_i2s (peer),
142 sps->no,
143 mq);
144
145
146 memcpy (key,
147 &hc,
148 sizeof (*key));
150 key,
151 mq,
153
155
156 sps->notify_connect (sps->ac.is,
157 peer);
158
159 return ret;
160}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static int ret
Final status code.
Definition: gnunet-arm.c:93
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
enum GNUNET_GenericReturnValue 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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
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.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
A 256-bit hashcode.
struct GNUNET_TESTING_Interpreter * is
Interpreter we are part of.
struct GNUNET_CONTAINER_MultiShortmap * connected_peers_map
A map with struct GNUNET_MQ_Handle values for each peer this peer is connected to.
GNUNET_TESTING_notify_connect_cb notify_connect
Callback which is called on neighbour connect events.

References GNUNET_TESTING_StartPeerState::ac, GNUNET_TESTING_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, GNUNET_TESTING_StartPeerState::id, GNUNET_TESTING_AsyncContext::is, key, LOG, mq, GNUNET_TESTING_StartPeerState::no, GNUNET_TESTING_StartPeerState::notify_connect, GNUNET_PeerIdentity::public_key, and ret.

Referenced by GNUNET_TRANSPORT_cmd_start_peer(), and 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 
)
static

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

Definition at line 168 of file transport_api_cmd_start_peer.c.

170{
171 struct GNUNET_TESTING_StartPeerState *sps = cls;
172 char *emsg = NULL;
174 const struct GNUNET_TESTING_Command *system_cmd;
175 const struct GNUNET_TESTBED_System *tl_system;
176 char *home;
177 char *transport_unix_path;
178 char *tcp_communicator_unix_path;
179 char *udp_communicator_unix_path;
180 char *bindto;
181 char *bindto_udp;
182
184 {
186 "File not found: `%s'\n",
187 sps->cfgname);
189 return;
190 }
191
192
196
197 GNUNET_asprintf (&home,
198 "$GNUNET_TMP/test-transport/api-tcp-p%u",
199 sps->no);
200
201 GNUNET_asprintf (&transport_unix_path,
202 "$GNUNET_RUNTIME_DIR/tng-p%u.sock",
203 sps->no);
204
205 GNUNET_asprintf (&tcp_communicator_unix_path,
206 "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
207 sps->no);
208
209 GNUNET_asprintf (&udp_communicator_unix_path,
210 "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
211 sps->no);
212
213 GNUNET_asprintf (&bindto,
214 "%s:60002",
215 sps->node_ip);
216
217 GNUNET_asprintf (&bindto_udp,
218 "2086");
219
221 "node_ip %s\n",
222 bindto);
223
225 "bind_udp %s\n",
226 GNUNET_YES == sps->broadcast ?
227 bindto_udp : bindto);
228
229 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME",
230 home);
231 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH",
232 transport_unix_path);
233 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
234 "BINDTO",
235 bindto);
236 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
237 "BINDTO",
238 GNUNET_YES == sps->broadcast ?
239 bindto_udp : bindto);
240 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
241 "UNIXPATH",
242 tcp_communicator_unix_path);
243 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
244 "UNIXPATH",
245 udp_communicator_unix_path);
246
247
249 sps->system_label);
250 GNUNET_TESTING_get_trait_test_system (system_cmd,
251 &tl_system);
252
253 sps->tl_system = tl_system;
254
256 "Creating testing library with key number %u\n",
257 sps->no);
258
259 if (GNUNET_SYSERR ==
260 GNUNET_TESTING_configuration_create ((struct
261 GNUNET_TESTBED_System *) tl_system,
262 sps->cfg))
263 {
265 "Testing library failed to create unique configuration based on `%s'\n",
266 sps->cfgname);
269 return;
270 }
271
272 sps->peer = GNUNET_TESTING_peer_configure ((struct
273 GNUNET_TESTBED_System *) sps->
274 tl_system,
275 sps->cfg,
276 sps->no,
277 NULL,
278 &emsg);
279 if (NULL == sps->peer)
280 {
282 "Testing library failed to create unique configuration based on `%s': `%s' with key number %u\n",
283 sps->cfgname,
284 emsg,
285 sps->no);
286 GNUNET_free (emsg);
288 return;
289 }
290
291 if (GNUNET_OK != GNUNET_TESTING_peer_start (sps->peer))
292 {
294 "Testing library failed to create unique configuration based on `%s'\n",
295 sps->cfgname);
296 GNUNET_free (emsg);
298 return;
299 }
300
301 memset (&dummy,
302 '\0',
303 sizeof(dummy));
304
305 GNUNET_TESTING_peer_get_identity (sps->peer,
306 &sps->id);
307
308 if (0 == memcmp (&dummy,
309 &sps->id,
310 sizeof(struct GNUNET_PeerIdentity)))
311 {
313 "Testing library failed to obtain peer identity for peer %u\n",
314 sps->no);
315 GNUNET_free (emsg);
317 return;
318 }
320 "Peer %u configured with identity `%s'\n",
321 sps->no,
322 GNUNET_i2s_full (&sps->id));
323
325 NULL,
326 sps->handlers,
327 sps,
330 if (NULL == sps->th)
331 {
333 "Failed to connect to transport service for peer `%s': `%s'\n",
334 sps->cfgname,
335 emsg);
336 GNUNET_free (emsg);
338 return;
339 }
340
341 sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
342 if (NULL == sps->ph)
343 {
345 "Failed to connect to peerstore service for peer `%s': `%s'\n",
346 sps->cfgname,
347 emsg);
348 GNUNET_free (emsg);
350 return;
351 }
352
354 if (NULL == sps->ah)
355 {
357 "Failed to initialize the TRANSPORT application suggestion client handle for peer `%s': `%s'\n",
358 sps->cfgname,
359 emsg);
360 GNUNET_free (emsg);
362 return;
363 }
365 GNUNET_free (home);
366 GNUNET_free (transport_unix_path);
367 GNUNET_free (tcp_communicator_unix_path);
368 GNUNET_free (udp_communicator_unix_path);
369 GNUNET_free (bindto);
370 GNUNET_free (bindto_udp);
371}
static struct GNUNET_TESTING_Interpreter * is
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
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_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_TRANSPORT_ApplicationHandle * GNUNET_TRANSPORT_application_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the TRANSPORT application client handle.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
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.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
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:520
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#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).
@ GNUNET_ERROR_TYPE_ERROR
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.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testbed.c:54
A command to be run by the interpreter.
const struct GNUNET_TESTING_System * tl_system
Test setup for this peer.
struct GNUNET_TRANSPORT_ApplicationHandle * ah
Application handle.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
char * system_label
The label of the command which was started by calling GNUNET_TESTING_cmd_system_create.
enum GNUNET_GenericReturnValue broadcast
Flag indicating, if udp broadcast should be switched on.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.
struct GNUNET_CONFIGURATION_Handle * cfg
Peer's configuration.
char * cfgname
GNUnet configuration file used to start a peer.
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 GNUNET_TESTING_StartPeerState::ah, GNUNET_TESTING_StartPeerState::broadcast, GNUNET_TESTING_StartPeerState::cfg, GNUNET_TESTING_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_interpreter_fail(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TRANSPORT_application_init(), GNUNET_TRANSPORT_core_connect(), GNUNET_YES, GNUNET_TESTING_StartPeerState::handlers, GNUNET_TESTING_StartPeerState::id, is, LOG, GNUNET_TESTING_StartPeerState::no, GNUNET_TESTING_StartPeerState::node_ip, notify_connect(), notify_disconnect(), GNUNET_TESTING_StartPeerState::peer, GNUNET_TESTING_StartPeerState::ph, retrieve_hello(), GNUNET_TESTING_StartPeerState::rh_task, GNUNET_TESTING_StartPeerState::system_label, GNUNET_TESTING_StartPeerState::th, and GNUNET_TESTING_StartPeerState::tl_system.

Referenced by GNUNET_TRANSPORT_cmd_start_peer().

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

◆ start_peer_cleanup()

static void start_peer_cleanup ( void *  cls)
static

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

Definition at line 379 of file transport_api_cmd_start_peer.c.

380{
381 struct GNUNET_TESTING_StartPeerState *sps = cls;
382
383 if (NULL != sps->handlers)
384 {
385 GNUNET_free (sps->handlers);
386 sps->handlers = NULL;
387 }
388 // TODO Investigate why this caused problems during shutdown.
389 /*if (NULL != sps->cfg)
390 {
391 GNUNET_CONFIGURATION_destroy (sps->cfg);
392 sps->cfg = NULL;
393 }*/
394 GNUNET_free (sps->cfgname);
395 GNUNET_free (sps->node_ip);
397 GNUNET_free (sps->hello);
399 GNUNET_free (sps);
400}

References GNUNET_TESTING_StartPeerState::cfgname, GNUNET_TESTING_StartPeerState::connected_peers_map, GNUNET_free, GNUNET_TESTING_StartPeerState::handlers, GNUNET_TESTING_StartPeerState::hello, GNUNET_TESTING_StartPeerState::node_ip, and GNUNET_TESTING_StartPeerState::system_label.

Referenced by GNUNET_TRANSPORT_cmd_start_peer().

Here is the caller graph for this function:

◆ start_peer_traits()

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

This function prepares an array with traits.

Definition at line 408 of file transport_api_cmd_start_peer.c.

412{
413 struct GNUNET_TESTING_StartPeerState *sps = cls;
415 struct GNUNET_PeerIdentity *id = &sps->id;
416 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
418 char *hello = sps->hello;
419 size_t hello_size = sps->hello_size;
420
421
422 struct GNUNET_TESTING_Trait traits[] = {
426 void *)
427 connected_peers_map),
428 GNUNET_TRANSPORT_TESTING_make_trait_hello ((const void *) hello),
429 GNUNET_TRANSPORT_TESTING_make_trait_hello_size ((const void *) hello_size),
432 void *) &sps->broadcast),
434 };
435
437 ret,
438 trait,
439 index);
440}
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" of traits array.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Obtain value of a trait from a command.
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_TESTING_make_trait_broadcast(const enum GNUNET_GenericReturnValue *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_TESTING_make_trait_state(const struct GNUNET_TESTING_StartPeerState *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_TESTING_make_trait_hello(const char *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_TESTING_make_trait_application_handle(const struct GNUNET_TRANSPORT_ApplicationHandle *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_TESTING_make_trait_connected_peers_map(const struct GNUNET_CONTAINER_MultiShortmap *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_TESTING_make_trait_peer_id(const struct GNUNET_PeerIdentity *value)
struct GNUNET_TESTING_Trait GNUNET_TRANSPORT_TESTING_make_trait_hello_size(const size_t *value)
Internal representation of the hash map.
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
unsigned int index
Index number associated with the trait.
Handle to the TRANSPORT subsystem for application management.
static enum GNUNET_GenericReturnValue traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.

References ah, GNUNET_TESTING_StartPeerState::ah, GNUNET_TESTING_StartPeerState::connected_peers_map, GNUNET_TESTING_get_trait(), GNUNET_TESTING_trait_end(), GNUNET_TRANSPORT_TESTING_make_trait_application_handle(), GNUNET_TRANSPORT_TESTING_make_trait_broadcast(), GNUNET_TRANSPORT_TESTING_make_trait_connected_peers_map(), GNUNET_TRANSPORT_TESTING_make_trait_hello(), GNUNET_TRANSPORT_TESTING_make_trait_hello_size(), GNUNET_TRANSPORT_TESTING_make_trait_peer_id(), GNUNET_TRANSPORT_TESTING_make_trait_state(), GNUNET_TESTING_StartPeerState::hello, GNUNET_TESTING_StartPeerState::hello_size, GNUNET_TESTING_StartPeerState::id, GNUNET_TESTING_Trait::index, ret, and traits().

Referenced by GNUNET_TRANSPORT_cmd_start_peer().

Here is the call graph for this function:
Here is the caller 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,
const char *  node_ip,
struct GNUNET_MQ_MessageHandler handlers,
const char *  cfgname,
GNUNET_TRANSPORT_notify_connect_cb  notify_connect,
unsigned int  broadcast 
)

Create command.

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

Definition at line 444 of file transport_api_cmd_start_peer.c.

453{
455 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
457 unsigned int i;
458
460 sps->no = no;
461 sps->system_label = GNUNET_strdup (system_label);
462 sps->connected_peers_map = connected_peers_map;
463 sps->cfgname = GNUNET_strdup (cfgname);
464 sps->node_ip = GNUNET_strdup (node_ip);
466 sps->broadcast = broadcast;
467
468 if (NULL != handlers)
469 {
470 for (i = 0; NULL != handlers[i].cb; i++)
471 ;
472 sps->handlers = GNUNET_new_array (i + 1,
475 handlers,
476 i * sizeof(struct GNUNET_MQ_MessageHandler));
477 }
479 label,
483 &sps->ac);
484}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new_ac(void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
Create a new command that may be asynchronous.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#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.
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.

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

Here is the call graph for this function: