diff options
Diffstat (limited to 'src/transport/transport_api_cmd_start_peer.c')
-rw-r--r-- | src/transport/transport_api_cmd_start_peer.c | 604 |
1 files changed, 0 insertions, 604 deletions
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c deleted file mode 100644 index dc19f10eb..000000000 --- a/src/transport/transport_api_cmd_start_peer.c +++ /dev/null | |||
@@ -1,604 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_start_peer.c | ||
23 | * @brief cmd to start a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "gnunet_peerstore_service.h" | ||
30 | #include "gnunet_transport_core_service.h" | ||
31 | #include "gnunet_transport_application_service.h" | ||
32 | #include "transport-testing-cmds.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | |||
40 | static void | ||
41 | retrieve_hello (void *cls); | ||
42 | |||
43 | |||
44 | /** | ||
45 | * Callback delivering the hello of this peer from peerstore. | ||
46 | * | ||
47 | */ | ||
48 | static void | ||
49 | hello_iter_cb (void *cb_cls, | ||
50 | const struct GNUNET_PEERSTORE_Record *record, | ||
51 | const char *emsg) | ||
52 | { | ||
53 | struct StartPeerState *sps = cb_cls; | ||
54 | if (NULL == record) | ||
55 | { | ||
56 | sps->pic = NULL; | ||
57 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); | ||
58 | return; | ||
59 | } | ||
60 | // Check record type et al? | ||
61 | sps->hello_size = record->value_size; | ||
62 | sps->hello = GNUNET_malloc (sps->hello_size); | ||
63 | memcpy (sps->hello, record->value, sps->hello_size); | ||
64 | sps->hello[sps->hello_size - 1] = '\0'; | ||
65 | |||
66 | GNUNET_PEERSTORE_iterate_cancel (sps->pic); | ||
67 | sps->pic = NULL; | ||
68 | GNUNET_TESTING_async_finish (&sps->ac); | ||
69 | } | ||
70 | |||
71 | |||
72 | /** | ||
73 | * Function to start the retrieval task to retrieve the hello of this peer | ||
74 | * from the peerstore. | ||
75 | * | ||
76 | */ | ||
77 | static void | ||
78 | retrieve_hello (void *cls) | ||
79 | { | ||
80 | struct StartPeerState *sps = cls; | ||
81 | sps->rh_task = NULL; | ||
82 | sps->pic = GNUNET_PEERSTORE_iterate (sps->ph, | ||
83 | "transport", | ||
84 | &sps->id, | ||
85 | GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY, | ||
86 | hello_iter_cb, | ||
87 | sps); | ||
88 | |||
89 | } | ||
90 | |||
91 | |||
92 | /** | ||
93 | * Disconnect callback for the connection to the core service. | ||
94 | * | ||
95 | */ | ||
96 | static void | ||
97 | notify_disconnect (void *cls, | ||
98 | const struct GNUNET_PeerIdentity *peer, | ||
99 | void *handler_cls) | ||
100 | { | ||
101 | struct StartPeerState *sps = cls; | ||
102 | |||
103 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
104 | "Peer %s disconnected from peer %u (`%s')\n", | ||
105 | GNUNET_i2s (peer), | ||
106 | sps->no, | ||
107 | GNUNET_i2s (&sps->id)); | ||
108 | |||
109 | } | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Connect callback for the connection to the core service. | ||
114 | * | ||
115 | */ | ||
116 | static void * | ||
117 | notify_connect (void *cls, | ||
118 | const struct GNUNET_PeerIdentity *peer, | ||
119 | struct GNUNET_MQ_Handle *mq) | ||
120 | { | ||
121 | struct StartPeerState *sps = cls; | ||
122 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | ||
123 | struct GNUNET_HashCode hc; | ||
124 | struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key; | ||
125 | |||
126 | void *ret = NULL; | ||
127 | |||
128 | |||
129 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
130 | "Peer %s connected to peer %u (`%s')\n", | ||
131 | GNUNET_i2s (peer), | ||
132 | sps->no, | ||
133 | GNUNET_i2s (&sps->id)); | ||
134 | |||
135 | GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc); | ||
136 | |||
137 | |||
138 | memcpy (key, | ||
139 | &hc, | ||
140 | sizeof (*key)); | ||
141 | GNUNET_CONTAINER_multishortmap_put (sps->connected_peers_map, | ||
142 | key, | ||
143 | mq, | ||
144 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
145 | |||
146 | GNUNET_free (key); | ||
147 | |||
148 | sps->notify_connect (cls, | ||
149 | peer, | ||
150 | mq); | ||
151 | |||
152 | // TODO what does the handler function need? | ||
153 | return ret; | ||
154 | } | ||
155 | |||
156 | |||
157 | /** | ||
158 | * The run method of this cmd will start all services of a peer to test the transport service. | ||
159 | * | ||
160 | */ | ||
161 | static void | ||
162 | start_peer_run (void *cls, | ||
163 | struct GNUNET_TESTING_Interpreter *is) | ||
164 | { | ||
165 | struct StartPeerState *sps = cls; | ||
166 | char *emsg = NULL; | ||
167 | struct GNUNET_PeerIdentity dummy; | ||
168 | const struct GNUNET_TESTING_Command *system_cmd; | ||
169 | struct GNUNET_TESTING_System *tl_system; | ||
170 | char *home; | ||
171 | char *transport_unix_path; | ||
172 | char *tcp_communicator_unix_path; | ||
173 | char *udp_communicator_unix_path; | ||
174 | char *bindto; | ||
175 | |||
176 | if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname)) | ||
177 | { | ||
178 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
179 | "File not found: `%s'\n", | ||
180 | sps->cfgname); | ||
181 | GNUNET_TESTING_interpreter_fail (is); | ||
182 | return; | ||
183 | } | ||
184 | |||
185 | |||
186 | sps->cfg = GNUNET_CONFIGURATION_create (); | ||
187 | GNUNET_assert (GNUNET_OK == | ||
188 | GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname)); | ||
189 | |||
190 | GNUNET_asprintf (&home, | ||
191 | "$GNUNET_TMP/test-transport/api-tcp-p%u", | ||
192 | sps->no); | ||
193 | |||
194 | GNUNET_asprintf (&transport_unix_path, | ||
195 | "$GNUNET_RUNTIME_DIR/tng-p%u.sock", | ||
196 | sps->no); | ||
197 | |||
198 | GNUNET_asprintf (&tcp_communicator_unix_path, | ||
199 | "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock", | ||
200 | sps->no); | ||
201 | |||
202 | GNUNET_asprintf (&udp_communicator_unix_path, | ||
203 | "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock", | ||
204 | sps->no); | ||
205 | |||
206 | GNUNET_asprintf (&bindto, | ||
207 | "%s:60002", | ||
208 | sps->node_ip); | ||
209 | |||
210 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
211 | "node_ip %s\n", | ||
212 | bindto); | ||
213 | |||
214 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME", | ||
215 | home); | ||
216 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH", | ||
217 | transport_unix_path); | ||
218 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", | ||
219 | "BINDTO", | ||
220 | bindto); | ||
221 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp", | ||
222 | "BINDTO", | ||
223 | bindto); | ||
224 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", | ||
225 | "UNIXPATH", | ||
226 | tcp_communicator_unix_path); | ||
227 | GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp", | ||
228 | "UNIXPATH", | ||
229 | udp_communicator_unix_path); | ||
230 | |||
231 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (is, | ||
232 | sps->system_label); | ||
233 | GNUNET_TESTING_get_trait_test_system (system_cmd, | ||
234 | &tl_system); | ||
235 | |||
236 | sps->tl_system = tl_system; | ||
237 | |||
238 | if (GNUNET_SYSERR == | ||
239 | GNUNET_TESTING_configuration_create (tl_system, | ||
240 | sps->cfg)) | ||
241 | { | ||
242 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
243 | "Testing library failed to create unique configuration based on `%s'\n", | ||
244 | sps->cfgname); | ||
245 | GNUNET_CONFIGURATION_destroy (sps->cfg); | ||
246 | GNUNET_TESTING_interpreter_fail (is); | ||
247 | return; | ||
248 | } | ||
249 | |||
250 | sps->peer = GNUNET_TESTING_peer_configure (sps->tl_system, | ||
251 | sps->cfg, | ||
252 | sps->no, | ||
253 | NULL, | ||
254 | &emsg); | ||
255 | if (NULL == sps->peer) | ||
256 | { | ||
257 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
258 | "Testing library failed to create unique configuration based on `%s': `%s'\n", | ||
259 | sps->cfgname, | ||
260 | emsg); | ||
261 | GNUNET_free (emsg); | ||
262 | GNUNET_TESTING_interpreter_fail (is); | ||
263 | return; | ||
264 | } | ||
265 | |||
266 | if (GNUNET_OK != GNUNET_TESTING_peer_start (sps->peer)) | ||
267 | { | ||
268 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
269 | "Testing library failed to create unique configuration based on `%s'\n", | ||
270 | sps->cfgname); | ||
271 | GNUNET_free (emsg); | ||
272 | GNUNET_TESTING_interpreter_fail (is); | ||
273 | return; | ||
274 | } | ||
275 | |||
276 | memset (&dummy, | ||
277 | '\0', | ||
278 | sizeof(dummy)); | ||
279 | |||
280 | GNUNET_TESTING_peer_get_identity (sps->peer, | ||
281 | &sps->id); | ||
282 | |||
283 | if (0 == memcmp (&dummy, | ||
284 | &sps->id, | ||
285 | sizeof(struct GNUNET_PeerIdentity))) | ||
286 | { | ||
287 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
288 | "Testing library failed to obtain peer identity for peer %u\n", | ||
289 | sps->no); | ||
290 | GNUNET_free (emsg); | ||
291 | GNUNET_TESTING_interpreter_fail (is); | ||
292 | return; | ||
293 | } | ||
294 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
295 | "Peer %u configured with identity `%s'\n", | ||
296 | sps->no, | ||
297 | GNUNET_i2s_full (&sps->id)); | ||
298 | |||
299 | sps->th = GNUNET_TRANSPORT_core_connect (sps->cfg, | ||
300 | NULL, | ||
301 | sps->handlers, | ||
302 | sps, | ||
303 | ¬ify_connect, | ||
304 | ¬ify_disconnect); | ||
305 | if (NULL == sps->th) | ||
306 | { | ||
307 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
308 | "Failed to connect to transport service for peer `%s': `%s'\n", | ||
309 | sps->cfgname, | ||
310 | emsg); | ||
311 | GNUNET_free (emsg); | ||
312 | GNUNET_TESTING_interpreter_fail (is); | ||
313 | return; | ||
314 | } | ||
315 | |||
316 | sps->ph = GNUNET_PEERSTORE_connect (sps->cfg); | ||
317 | if (NULL == sps->th) | ||
318 | { | ||
319 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
320 | "Failed to connect to peerstore service for peer `%s': `%s'\n", | ||
321 | sps->cfgname, | ||
322 | emsg); | ||
323 | GNUNET_free (emsg); | ||
324 | GNUNET_TESTING_interpreter_fail (is); | ||
325 | return; | ||
326 | } | ||
327 | |||
328 | sps->ah = GNUNET_TRANSPORT_application_init (sps->cfg); | ||
329 | if (NULL == sps->ah) | ||
330 | { | ||
331 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
332 | "Failed to initialize the TRANSPORT application suggestion client handle for peer `%s': `%s'\n", | ||
333 | sps->cfgname, | ||
334 | emsg); | ||
335 | GNUNET_free (emsg); | ||
336 | GNUNET_TESTING_interpreter_fail (is); | ||
337 | return; | ||
338 | } | ||
339 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); | ||
340 | } | ||
341 | |||
342 | |||
343 | /** | ||
344 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
345 | * | ||
346 | */ | ||
347 | static void | ||
348 | start_peer_cleanup (void *cls) | ||
349 | { | ||
350 | struct StartPeerState *sps = cls; | ||
351 | |||
352 | if (NULL != sps->handlers) | ||
353 | { | ||
354 | GNUNET_free (sps->handlers); | ||
355 | sps->handlers = NULL; | ||
356 | } | ||
357 | if (NULL != sps->cfg) | ||
358 | { | ||
359 | GNUNET_CONFIGURATION_destroy (sps->cfg); | ||
360 | sps->cfg = NULL; | ||
361 | } | ||
362 | GNUNET_free (sps->hello); | ||
363 | GNUNET_free (sps->connected_peers_map); | ||
364 | GNUNET_free (sps); | ||
365 | } | ||
366 | |||
367 | |||
368 | /** | ||
369 | * This function prepares an array with traits. | ||
370 | * | ||
371 | */ | ||
372 | static int | ||
373 | start_peer_traits (void *cls, | ||
374 | const void **ret, | ||
375 | const char *trait, | ||
376 | unsigned int index) | ||
377 | { | ||
378 | struct StartPeerState *sps = cls; | ||
379 | struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah; | ||
380 | struct GNUNET_PeerIdentity *id = &sps->id; | ||
381 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = | ||
382 | sps->connected_peers_map; | ||
383 | char *hello = sps->hello; | ||
384 | size_t hello_size = sps->hello_size; | ||
385 | |||
386 | |||
387 | struct GNUNET_TESTING_Trait traits[] = { | ||
388 | { | ||
389 | .index = 0, | ||
390 | .trait_name = "application_handle", | ||
391 | .ptr = (const void *) ah, | ||
392 | }, | ||
393 | { | ||
394 | .index = 1, | ||
395 | .trait_name = "peer_id", | ||
396 | .ptr = (const void *) id, | ||
397 | }, | ||
398 | { | ||
399 | .index = 2, | ||
400 | .trait_name = "connected_peers_map", | ||
401 | .ptr = (const void *) connected_peers_map, | ||
402 | }, | ||
403 | { | ||
404 | .index = 3, | ||
405 | .trait_name = "hello", | ||
406 | .ptr = (const void *) hello, | ||
407 | }, | ||
408 | { | ||
409 | .index = 4, | ||
410 | .trait_name = "hello_size", | ||
411 | .ptr = (const void *) hello_size, | ||
412 | }, | ||
413 | { | ||
414 | .index = 5, | ||
415 | .trait_name = "state", | ||
416 | .ptr = (const void *) sps, | ||
417 | }, | ||
418 | GNUNET_TESTING_trait_end () | ||
419 | }; | ||
420 | |||
421 | return GNUNET_TESTING_get_trait (traits, | ||
422 | ret, | ||
423 | trait, | ||
424 | index); | ||
425 | } | ||
426 | |||
427 | |||
428 | /** | ||
429 | * Function to get the trait with the struct StartPeerState. | ||
430 | * | ||
431 | * @param[out] sps struct StartPeerState. | ||
432 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
433 | * | ||
434 | */ | ||
435 | int | ||
436 | GNUNET_TRANSPORT_get_trait_state ( | ||
437 | const struct GNUNET_TESTING_Command *cmd, | ||
438 | struct StartPeerState **sps) | ||
439 | { | ||
440 | return cmd->traits (cmd->cls, | ||
441 | (const void **) sps, | ||
442 | "state", | ||
443 | (unsigned int) 5); | ||
444 | } | ||
445 | |||
446 | |||
447 | /** | ||
448 | * Function to get the trait with the size of the hello. | ||
449 | * | ||
450 | * @param[out] hello_size size of hello. | ||
451 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
452 | * | ||
453 | */ | ||
454 | int | ||
455 | GNUNET_TRANSPORT_get_trait_hello_size (const struct | ||
456 | GNUNET_TESTING_Command | ||
457 | *cmd, | ||
458 | size_t **hello_size) | ||
459 | { | ||
460 | return cmd->traits (cmd->cls, | ||
461 | (const void **) hello_size, | ||
462 | "hello_size", | ||
463 | (unsigned int) 4); | ||
464 | } | ||
465 | |||
466 | |||
467 | /** | ||
468 | * Function to get the trait with the hello. | ||
469 | * | ||
470 | * @param[out] hello The hello for the peer. | ||
471 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
472 | * | ||
473 | */ | ||
474 | int | ||
475 | GNUNET_TRANSPORT_get_trait_hello (const struct | ||
476 | GNUNET_TESTING_Command | ||
477 | *cmd, | ||
478 | char **hello) | ||
479 | { | ||
480 | return cmd->traits (cmd->cls, | ||
481 | (const void **) hello, | ||
482 | "hello", | ||
483 | (unsigned int) 3); | ||
484 | } | ||
485 | |||
486 | |||
487 | /** | ||
488 | * Function to get the trait with the map of connected peers. | ||
489 | * | ||
490 | * @param[out] connected_peers_map The map with connected peers. | ||
491 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
492 | * | ||
493 | */ | ||
494 | int | ||
495 | GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct | ||
496 | GNUNET_TESTING_Command | ||
497 | *cmd, | ||
498 | struct | ||
499 | GNUNET_CONTAINER_MultiShortmap | ||
500 | * | ||
501 | * | ||
502 | connected_peers_map) | ||
503 | { | ||
504 | return cmd->traits (cmd->cls, | ||
505 | (const void **) connected_peers_map, | ||
506 | "connected_peers_map", | ||
507 | (unsigned int) 2); | ||
508 | } | ||
509 | |||
510 | |||
511 | /** | ||
512 | * Function to get the trait with the transport application handle. | ||
513 | * | ||
514 | * @param[out] ah The application handle. | ||
515 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
516 | */ | ||
517 | int | ||
518 | GNUNET_TRANSPORT_get_trait_application_handle (const struct | ||
519 | GNUNET_TESTING_Command *cmd, | ||
520 | struct | ||
521 | GNUNET_TRANSPORT_ApplicationHandle | ||
522 | **ah) | ||
523 | { | ||
524 | return cmd->traits (cmd->cls, | ||
525 | (const void **) ah, | ||
526 | "application_handle", | ||
527 | (unsigned int) 0); | ||
528 | } | ||
529 | |||
530 | |||
531 | /** | ||
532 | * Function to get the trait with the peer id. | ||
533 | * | ||
534 | * @param[out] id The peer id. | ||
535 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
536 | */ | ||
537 | int | ||
538 | GNUNET_TRANSPORT_get_trait_peer_id (const struct | ||
539 | GNUNET_TESTING_Command *cmd, | ||
540 | struct GNUNET_PeerIdentity **id) | ||
541 | { | ||
542 | return cmd->traits (cmd->cls, | ||
543 | (const void **) id, | ||
544 | "peer_id", | ||
545 | (unsigned int) 1); | ||
546 | } | ||
547 | |||
548 | |||
549 | /** | ||
550 | * Create command. | ||
551 | * | ||
552 | * @param label name for command. | ||
553 | * @param system_label Label of the cmd to setup a test environment. | ||
554 | * @param m The number of the local node of the actual network namespace. | ||
555 | * @param n The number of the actual namespace. | ||
556 | * @param local_m Number of local nodes in each namespace. | ||
557 | * @param handlers Handler for messages received by this peer. | ||
558 | * @param cfgname Configuration file name for this peer. | ||
559 | * @return command. | ||
560 | */ | ||
561 | struct GNUNET_TESTING_Command | ||
562 | GNUNET_TRANSPORT_cmd_start_peer (const char *label, | ||
563 | const char *system_label, | ||
564 | uint32_t no, | ||
565 | char *node_ip, | ||
566 | struct GNUNET_MQ_MessageHandler *handlers, | ||
567 | const char *cfgname, | ||
568 | GNUNET_TRANSPORT_NotifyConnect notify_connect) | ||
569 | { | ||
570 | struct StartPeerState *sps; | ||
571 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = | ||
572 | GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); | ||
573 | unsigned int i; | ||
574 | |||
575 | sps = GNUNET_new (struct StartPeerState); | ||
576 | sps->no = no; | ||
577 | sps->system_label = system_label; | ||
578 | sps->connected_peers_map = connected_peers_map; | ||
579 | sps->cfgname = cfgname; | ||
580 | sps->node_ip = node_ip; | ||
581 | sps->notify_connect = notify_connect; | ||
582 | |||
583 | if (NULL != handlers) | ||
584 | { | ||
585 | for (i = 0; NULL != handlers[i].cb; i++) | ||
586 | ; | ||
587 | sps->handlers = GNUNET_new_array (i + 1, | ||
588 | struct GNUNET_MQ_MessageHandler); | ||
589 | GNUNET_memcpy (sps->handlers, | ||
590 | handlers, | ||
591 | i * sizeof(struct GNUNET_MQ_MessageHandler)); | ||
592 | } | ||
593 | |||
594 | struct GNUNET_TESTING_Command cmd = { | ||
595 | .cls = sps, | ||
596 | .label = label, | ||
597 | .run = &start_peer_run, | ||
598 | .ac = &sps->ac, | ||
599 | .cleanup = &start_peer_cleanup, | ||
600 | .traits = &start_peer_traits | ||
601 | }; | ||
602 | |||
603 | return cmd; | ||
604 | } | ||