aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport-testing2.h')
-rw-r--r--src/transport/transport-testing2.h947
1 files changed, 0 insertions, 947 deletions
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
deleted file mode 100644
index b9e492219..000000000
--- a/src/transport/transport-testing2.h
+++ /dev/null
@@ -1,947 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009, 2015, 2016 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 transport-testing.h
23 * @brief testing lib for transport service
24 * @author Matthias Wachs
25 * @author Christian Grothoff
26 */
27#ifndef TRANSPORT_TESTING_H
28#define TRANSPORT_TESTING_H
29#include "platform.h"
30#include "gnunet_util_lib.h"
31#include "gnunet_hello_lib.h"
32#include "gnunet_peerstore_service.h"
33#include "gnunet_transport_core_service.h"
34#include "gnunet_transport_application_service.h"
35#include "gnunet_transport_manipulation_service.h"
36#include "gnunet_testing_lib.h"
37
38
39/* ************* Basic functions for starting/stopping/connecting *********** */
40
41/**
42 * Context for a single peer
43 */
44struct GNUNET_TRANSPORT_TESTING_PeerContext;
45
46/**
47 * Definition for a transport testing handle
48 */
49struct GNUNET_TRANSPORT_TESTING_Handle;
50
51
52/**
53 * Context for a single peer
54 */
55struct GNUNET_TRANSPORT_TESTING_PeerContext
56{
57 /**
58 * Next element in the DLL
59 */
60 struct GNUNET_TRANSPORT_TESTING_PeerContext *next;
61
62 /**
63 * Previous element in the DLL
64 */
65 struct GNUNET_TRANSPORT_TESTING_PeerContext *prev;
66
67 /**
68 * Transport testing handle this peer belongs to
69 */
70 struct GNUNET_TRANSPORT_TESTING_Handle *tth;
71
72 /**
73 * Application handle
74 */
75 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
76
77 /**
78 * Peer's configuration
79 */
80 struct GNUNET_CONFIGURATION_Handle *cfg;
81
82 /**
83 * Peer's transport service handle
84 */
85 struct GNUNET_TRANSPORT_CoreHandle *th;
86
87 /**
88 * Peer's ATS handle.
89 */
90 struct GNUNET_ATS_ConnectivityHandle *ats;
91
92 /**
93 * Peer's PEERSTORE Handle
94 */
95 struct GNUNET_PEERSTORE_Handle *ph;
96
97 /**
98 * Peer's transport get hello handle to retrieve peer's HELLO message
99 */
100 struct GNUNET_PEERSTORE_IterateContext *pic;
101
102 /**
103 * Hello
104 */
105 char *hello;
106
107 /**
108 * Hello size
109 */
110 size_t hello_size;
111
112 /**
113 * Peer's testing handle
114 */
115 struct GNUNET_TESTING_Peer *peer;
116
117 /**
118 * Peer identity
119 */
120 struct GNUNET_PeerIdentity id;
121
122 /**
123 * Handle for the peer's ARM process
124 */
125 struct GNUNET_OS_Process *arm_proc;
126
127 /**
128 * Receive callback
129 */
130 struct GNUNET_MQ_MessageHandler *handlers;
131
132 /**
133 * Notify connect callback
134 */
135 GNUNET_TRANSPORT_NotifyConnect nc;
136
137 /**
138 * Notify disconnect callback
139 */
140 GNUNET_TRANSPORT_NotifyDisconnect nd;
141
142 /**
143 * Startup completed callback
144 */
145 GNUNET_SCHEDULER_TaskCallback start_cb;
146
147 /**
148 * Hello get task
149 */
150 struct GNUNET_SCHEDULER_Task *rh_task;
151
152 /**
153 * Closure for the @a nc and @a nd callbacks
154 */
155 void *cb_cls;
156
157 /**
158 * Closure for @e start_cb.
159 */
160 void *start_cb_cls;
161
162 /**
163 * An unique number to identify the peer
164 */
165 unsigned int no;
166};
167
168
169/**
170 * Handle for a request to connect two peers.
171 */
172struct GNUNET_TRANSPORT_TESTING_ConnectRequest
173{
174 /**
175 * Kept in a DLL.
176 */
177 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *next;
178
179 /**
180 * Kept in a DLL.
181 */
182 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *prev;
183
184 /**
185 * Peer we want to connect.
186 */
187 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
188
189 /**
190 * Peer we want to connect.
191 */
192 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
193
194 /**
195 * Task by which we accomplish the connection.
196 */
197 struct GNUNET_SCHEDULER_Task *tct;
198
199 /**
200 * Handle by which we ask ATS to facilitate the connection.
201 */
202 struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
203
204 /**
205 * Function to call upon completion.
206 */
207 GNUNET_SCHEDULER_TaskCallback cb;
208
209 /**
210 * Closure for @e cb.
211 */
212 void *cb_cls;
213
214 /**
215 * Message queue for sending from @a p1 to @a p2.
216 */
217 struct GNUNET_MQ_Handle *mq;
218
219 /**
220 * Set if peer1 says the connection is up to peer2.
221 */
222 int p1_c;
223
224 /**
225 * Set if peer2 says the connection is up to peer1.
226 */
227 int p2_c;
228
229 /**
230 * #GNUNET_YES if both @e p1_c and @e p2_c are #GNUNET_YES.
231 */
232 int connected;
233};
234
235
236/**
237 * Handle for a test run.
238 */
239struct GNUNET_TRANSPORT_TESTING_Handle
240{
241 /**
242 * Testing library system handle
243 */
244 struct GNUNET_TESTING_System *tl_system;
245
246 /**
247 * head DLL of connect contexts
248 */
249 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_head;
250
251 /**
252 * head DLL of connect contexts
253 */
254 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc_tail;
255
256 /**
257 * head DLL of peers
258 */
259 struct GNUNET_TRANSPORT_TESTING_PeerContext *p_head;
260
261 /**
262 * tail DLL of peers
263 */
264 struct GNUNET_TRANSPORT_TESTING_PeerContext *p_tail;
265};
266
267
268/**
269 * Initialize the transport testing
270 *
271 * @return transport testing handle
272 */
273struct GNUNET_TRANSPORT_TESTING_Handle *
274GNUNET_TRANSPORT_TESTING_init (void);
275
276
277/**
278 * Clean up the transport testing
279 *
280 * @param tth transport testing handle
281 */
282void
283GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth);
284
285
286/**
287 * Start a peer with the given configuration
288 *
289 * @param tth the testing handle
290 * @param cfgname configuration file
291 * @param peer_id an identification number for the peer
292 * @param handlers functions for receiving messages
293 * @param nc connect callback
294 * @param nd disconnect callback
295 * @param cb_cls closure for @a nc and @a nd callback
296 * @param start_cb start callback
297 * @param start_cb_cls closure for @a start_cb
298 * @return the peer context
299 */
300struct GNUNET_TRANSPORT_TESTING_PeerContext *
301GNUNET_TRANSPORT_TESTING_start_peer (
302 struct GNUNET_TRANSPORT_TESTING_Handle *tth,
303 const char *cfgname,
304 int peer_id,
305 const struct GNUNET_MQ_MessageHandler *handlers,
306 GNUNET_TRANSPORT_NotifyConnect nc,
307 GNUNET_TRANSPORT_NotifyDisconnect nd,
308 void *cb_cls,
309 GNUNET_SCHEDULER_TaskCallback start_cb,
310 void *start_cb_cls);
311
312
313/**
314 * Shutdown the given peer
315 *
316 * @param p the peer
317 */
318void
319GNUNET_TRANSPORT_TESTING_stop_peer (
320 struct GNUNET_TRANSPORT_TESTING_PeerContext *pc);
321
322
323/**
324 * Stops and restarts the given peer, sleeping (!) for 5s in between.
325 *
326 * @param p the peer
327 * @param restart_cb restart callback
328 * @param restart_cb_cls callback closure
329 * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR
330 */
331int
332GNUNET_TRANSPORT_TESTING_restart_peer (
333 struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
334 GNUNET_SCHEDULER_TaskCallback restart_cb,
335 void *restart_cb_cls);
336
337
338/**
339 * Connect the given peers and call the callback when both peers
340 * report the inbound connection. Remarks: start_peer's notify_connect
341 * callback can be called before.
342 *
343 * @param p1 peer 1
344 * @param p2 peer 2
345 * @param cb the callback to call when both peers notified that they are
346 * connected
347 * @param cls callback cls
348 * @return a connect request handle
349 */
350struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
351GNUNET_TRANSPORT_TESTING_connect_peers (
352 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
353 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
354 GNUNET_SCHEDULER_TaskCallback cb,
355 void *cls);
356
357
358/**
359 * Cancel the request to connect two peers. You MUST cancel the
360 * request if you stop the peers before the peers connected
361 * successfully.
362 *
363 * @param cc a connect request handle
364 */
365void
366GNUNET_TRANSPORT_TESTING_connect_peers_cancel (
367 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
368
369
370/**
371 * Function called on matching connect requests.
372 *
373 * @param cls closure
374 * @param cc request matching the query
375 */
376typedef void (*GNUNET_TRANSPORT_TESTING_ConnectContextCallback) (
377 void *cls,
378 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
379
380
381/**
382 * Find any connecting context matching the given pair of peers.
383 *
384 * @param p1 first peer
385 * @param p2 second peer
386 * @param cb function to call
387 * @param cb_cls closure for @a cb
388 */
389void
390GNUNET_TRANSPORT_TESTING_find_connecting_context (
391 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
392 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
393 GNUNET_TRANSPORT_TESTING_ConnectContextCallback cb,
394 void *cb_cls);
395
396
397/* ********************** high-level process functions *************** */
398
399
400/**
401 * Function called once the peers have been launched and
402 * connected by #GNUNET_TRANSPORT_TESTING_connect_check().
403 *
404 * @param cls closure
405 * @param num_peers size of the @a p array
406 * @param p the peers that were launched
407 */
408typedef void (*GNUNET_TRANSPORT_TESTING_ConnectContinuation) (
409 void *cls,
410 unsigned int num_peers,
411 struct GNUNET_TRANSPORT_TESTING_PeerContext *p[]);
412
413
414/**
415 * Internal data structure.
416 */
417struct GNUNET_TRANSPORT_TESTING_ConnectRequestList;
418
419/**
420 * Internal data structure.
421 */
422struct GNUNET_TRANSPORT_TESTING_InternalPeerContext;
423
424
425GNUNET_NETWORK_STRUCT_BEGIN
426struct GNUNET_TRANSPORT_TESTING_TestMessage
427{
428 /**
429 * Type is (usually) #GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE.
430 */
431 struct GNUNET_MessageHeader header;
432
433 /**
434 * Monotonically increasing counter throughout the test.
435 */
436 uint32_t num GNUNET_PACKED;
437};
438
439struct GNUNET_TRANSPORT_TESTING_PerformanceTestMessage
440{
441 /**
442 * Type is (usually) #GNUNET_TRANSPORT_TESTING_SIMPLE_PERFORMANCE_MTYPE.
443 */
444 struct GNUNET_MessageHeader header;
445
446 /**
447 * Time this message was send via transport api.
448 */
449 struct GNUNET_TIME_AbsoluteNBO time_send;
450
451 /**
452 * Monotonically increasing counter throughout the test.
453 */
454 uint32_t num GNUNET_PACKED;
455};
456
457GNUNET_NETWORK_STRUCT_END
458
459
460/**
461 * Function called by the transport for each received message.
462 *
463 * @param cls closure
464 * @param receiver receiver of the message
465 * @param sender sender of the message
466 * @param message the message
467 */
468typedef void (*GNUNET_TRANSPORT_TESTING_ReceiveCallback) (
469 void *cls,
470 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
471 const struct GNUNET_PeerIdentity *sender,
472 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message);
473
474
475/**
476 * Function called to notify transport users that another
477 * peer connected to us.
478 *
479 * @param cls closure
480 * @param me peer experiencing the event
481 * @param other peer that connected to @a me
482 */
483typedef void (*GNUNET_TRANSPORT_TESTING_NotifyConnect) (
484 void *cls,
485 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
486 const struct GNUNET_PeerIdentity *other);
487
488
489/**
490 * Function called to notify transport users that another
491 * peer disconnected from us.
492 *
493 * @param cls closure
494 * @param me peer experiencing the event
495 * @param other peer that disconnected from @a me
496 */
497typedef void (*GNUNET_TRANSPORT_TESTING_NotifyDisconnect) (
498 void *cls,
499 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
500 const struct GNUNET_PeerIdentity *other);
501
502
503/**
504 * Closure that must be passed to
505 * #GNUNET_TRANSPORT_TESTING_connect_check.
506 */
507struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext
508{
509 /**
510 * How should we continue after the connect?
511 */
512 GNUNET_SCHEDULER_TaskCallback connect_continuation;
513
514 /**
515 * Closure for @e connect_continuation.
516 */
517 void *connect_continuation_cls;
518
519 /**
520 * Which configuration file should we pass to the
521 * #GNUNET_PROGRAM_run() of the testcase?
522 */
523 const char *config_file;
524
525 /**
526 * Receiver argument to give for peers we start.
527 */
528 GNUNET_TRANSPORT_TESTING_ReceiveCallback rec;
529
530 /**
531 * Notify connect argument to give for peers we start.
532 */
533 GNUNET_TRANSPORT_TESTING_NotifyConnect nc;
534
535 /**
536 * Notify disconnect argument to give for peers we start.
537 */
538 GNUNET_TRANSPORT_TESTING_NotifyDisconnect nd;
539
540 /**
541 * Closure for @e rec, @e nc and @e nd.
542 */
543 void *cls;
544
545 /**
546 * Custom task to run on shutdown.
547 */
548 GNUNET_SCHEDULER_TaskCallback shutdown_task;
549
550 /**
551 * Closure for @e shutdown_task.
552 */
553 void *shutdown_task_cls;
554
555 /**
556 * Custom task to run after peers were started but before we try to
557 * connect them. If this function is set, we wait ONE second after
558 * running this function until we continue with connecting the
559 * peers.
560 */
561 GNUNET_SCHEDULER_TaskCallback pre_connect_task;
562
563 /**
564 * Closure for @e shutdown_task.
565 */
566 void *pre_connect_task_cls;
567
568 /**
569 * When should the testcase time out?
570 */
571 struct GNUNET_TIME_Relative timeout;
572
573 /**
574 * Should we try to create connections in both directions?
575 */
576 int bi_directional;
577
578 /* ******* fields set by #GNUNET_TRANSPORT_TESTING_connect_check **** */
579
580 /**
581 * Number of peers involved in the test.
582 */
583 unsigned int num_peers;
584
585 /**
586 * Configuration files we have, array with @e num_peers entries.
587 */
588 char **cfg_files;
589
590 /**
591 * Array with @e num_peers entries.
592 */
593 struct GNUNET_TRANSPORT_TESTING_PeerContext **p;
594
595 /**
596 * Name of the plugin.
597 */
598 const char *test_plugin;
599
600 /**
601 * Name of the testcase.
602 */
603 const char *test_name;
604
605 /**
606 * Configuration object for the testcase.
607 */
608 const struct GNUNET_CONFIGURATION_Handle *cfg;
609
610 /**
611 * Main testing handle.
612 */
613 struct GNUNET_TRANSPORT_TESTING_Handle *tth;
614
615 /**
616 * Result from the main function, set to #GNUNET_OK on success.
617 * Clients should set to #GNUNET_SYSERR to indicate test failure.
618 */
619 int global_ret;
620
621 /**
622 * Generator for the `num` field in test messages. Incremented each
623 * time #GNUNET_TRANSPORT_TESTING_simple_send or
624 * #GNUNET_TRANSPORT_TESTING_large_send are used to transmit a
625 * message.
626 */
627 uint32_t send_num_gen;
628
629 /* ******* internal state, clients should not mess with this **** */
630
631 /**
632 * Task run on timeout.
633 */
634 struct GNUNET_SCHEDULER_Task *timeout_task;
635
636 /**
637 * Task run to connect peers.
638 */
639 struct GNUNET_SCHEDULER_Task *connect_task;
640
641 /**
642 * Number of peers that have been started.
643 */
644 unsigned int started;
645
646 /**
647 * DLL of active connect requests.
648 */
649 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *crl_head;
650
651 /**
652 * DLL of active connect requests.
653 */
654 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *crl_tail;
655
656 /**
657 * Array with @e num_peers entries.
658 */
659 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ip;
660};
661
662
663/**
664 * Find peer by peer ID.
665 *
666 * @param ccc context to search
667 * @param peer peer to look for
668 * @return NULL if @a peer was not found
669 */
670struct GNUNET_TRANSPORT_TESTING_PeerContext *
671GNUNET_TRANSPORT_TESTING_find_peer (
672 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc,
673 const struct GNUNET_PeerIdentity *peer);
674
675
676/**
677 * Common implementation of the #GNUNET_TRANSPORT_TESTING_CheckCallback.
678 * Starts and connects the two peers, then invokes the
679 * `connect_continuation` from @a cls. Sets up a timeout to
680 * abort the test, and a shutdown handler to clean up properly
681 * on exit.
682 *
683 * @param cls closure of type `struct
684 * GNUNET_TRANSPORT_TESTING_ConnectCheckContext`
685 * @param tth_ initialized testing handle
686 * @param test_plugin_ name of the plugin
687 * @param test_name_ name of the test
688 * @param num_peers number of entries in the @a cfg_file array
689 * @param cfg_files array of names of configuration files for the peers
690 * @return #GNUNET_SYSERR on error
691 */
692int
693GNUNET_TRANSPORT_TESTING_connect_check (
694 void *cls,
695 struct GNUNET_TRANSPORT_TESTING_Handle *tth_,
696 const char *test_plugin_,
697 const char *test_name_,
698 unsigned int num_peers,
699 char *cfg_files[]);
700
701
702/**
703 * Main function of a testcase. Called with the initial setup data
704 * for the test as derived from the source name and the binary name.
705 *
706 * @param cls closure
707 * @param tth_ initialized testing handle
708 * @param test_plugin_ name of the plugin
709 * @param test_name_ name of the test
710 * @param num_peers number of entries in the @a cfg_file array
711 * @param cfg_files array of names of configuration files for the peers
712 * @return #GNUNET_SYSERR on error
713 */
714typedef int (*GNUNET_TRANSPORT_TESTING_CheckCallback) (
715 void *cls,
716 struct GNUNET_TRANSPORT_TESTING_Handle *tth_,
717 const char *test_plugin_,
718 const char *test_name_,
719 unsigned int num_peers,
720 char *cfg_files[]);
721
722
723/**
724 * Setup testcase. Calls @a check with the data the test needs.
725 *
726 * @param argv0 binary name (argv[0])
727 * @param filename source file name (__FILE__)
728 * @param num_peers number of peers to start
729 * @param check main function to run
730 * @param check_cls closure for @a check
731 * @return #GNUNET_OK on success
732 */
733int
734GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
735 const char *filename,
736 unsigned int num_peers,
737 GNUNET_TRANSPORT_TESTING_CheckCallback check,
738 void *check_cls);
739
740
741/**
742 * Setup testcase. Calls @a check with the data the test needs.
743 *
744 * @param num_peers number of peers to start
745 * @param check main function to run
746 * @param check_cls closure for @a check
747 * @return #GNUNET_OK on success
748 */
749#define GNUNET_TRANSPORT_TESTING_main(num_peers, check, check_cls) \
750 GNUNET_TRANSPORT_TESTING_main_ (argv[0], \
751 __FILE__, \
752 num_peers, \
753 check, \
754 check_cls)
755
756/* ***************** Convenience functions for sending ********* */
757
758/**
759 * Send a test message of type @a mtype and size @a msize from
760 * peer @a sender to peer @a receiver. The peers should be
761 * connected when this function is called.
762 *
763 * @param sender the sending peer
764 * @param receiver the receiving peer
765 * @param mtype message type to use
766 * @param msize size of the message, at least `sizeof (struct
767 * GNUNET_TRANSPORT_TESTING_TestMessage)`
768 * @param num unique message number
769 * @param cont continuation to call after transmission
770 * @param cont_cls closure for @a cont
771 * @return #GNUNET_OK if message was queued,
772 * #GNUNET_NO if peers are not connected
773 * #GNUNET_SYSERR if @a msize is illegal
774 */
775int
776GNUNET_TRANSPORT_TESTING_send (
777 struct GNUNET_TRANSPORT_TESTING_PeerContext *sender,
778 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
779 uint16_t mtype,
780 uint16_t msize,
781 uint32_t num,
782 GNUNET_SCHEDULER_TaskCallback cont,
783 void *cont_cls);
784
785
786/**
787 * Message type used by #GNUNET_TRANSPORT_TESTING_simple_send().
788 */
789#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE 12345
790
791/**
792 * Alternative message type for tests.
793 */
794#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2 12346
795
796/**
797 * Message type used by #().
798 */
799#define GNUNET_TRANSPORT_TESTING_SIMPLE_PERFORMANCE_MTYPE 12347
800
801/**
802 * Type of the closure argument to pass to
803 * #GNUNET_TRANSPORT_TESTING_simple_send() and
804 * #GNUNET_TRANSPORT_TESTING_large_send().
805 */
806struct GNUNET_TRANSPORT_TESTING_SendClosure
807{
808 /**
809 * Context for the transmission.
810 */
811 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
812
813 /**
814 * Function that returns the desired message size. Overrides
815 * the message size, can be NULL in which case the message
816 * size is the default.
817 */
818 size_t (*get_size_cb) (unsigned int n);
819
820 /**
821 * Number of messages to be transmitted in a loop.
822 * Use zero for "forever" (until external shutdown).
823 */
824 unsigned int num_messages;
825
826 /**
827 * Function to call after all transmissions, can be NULL.
828 */
829 GNUNET_SCHEDULER_TaskCallback cont;
830
831 /**
832 * Closure for @e cont.
833 */
834 void *cont_cls;
835};
836
837
838/**
839 * Task that sends a minimalistic test message from the
840 * first peer to the second peer.
841 *
842 * @param cls the `struct GNUNET_TRANSPORT_TESTING_SendClosure`
843 * which should contain at least two peers, the first two
844 * of which should be currently connected
845 */
846void
847GNUNET_TRANSPORT_TESTING_simple_send (void *cls);
848
849/**
850 * Size of a message sent with
851 * #GNUNET_TRANSPORT_TESTING_large_send(). Big enough
852 * to usually force defragmentation.
853 */
854#define GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE 2600
855
856/**
857 * Task that sends a large test message from the
858 * first peer to the second peer.
859 *
860 * @param cls the `struct GNUNET_TRANSPORT_TESTING_SendClosure`
861 * which should contain at least two peers, the first two
862 * of which should be currently connected
863 */
864void
865GNUNET_TRANSPORT_TESTING_large_send (void *cls);
866
867
868/* ********************** log-only convenience functions ************* */
869
870
871/**
872 * Log a connect event.
873 *
874 * @param cls NULL
875 * @param me peer that had the event
876 * @param other peer that connected.
877 */
878void
879GNUNET_TRANSPORT_TESTING_log_connect (
880 void *cls,
881 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
882 const struct GNUNET_PeerIdentity *other);
883
884
885/**
886 * Log a disconnect event.
887 *
888 * @param cls NULL
889 * @param me peer that had the event
890 * @param other peer that disconnected.
891 */
892void
893GNUNET_TRANSPORT_TESTING_log_disconnect (
894 void *cls,
895 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
896 const struct GNUNET_PeerIdentity *other);
897
898
899/* ********************** low-level filename functions *************** */
900
901
902/**
903 * Extracts the test filename from an absolute file name and removes
904 * the extension.
905 *
906 * @param file absolute file name
907 * @return resulting test name
908 */
909char *
910GNUNET_TRANSPORT_TESTING_get_test_name (const char *file);
911
912
913/**
914 * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
915 * if existing ".exe"-prefix and adds the peer-number
916 *
917 * @param file filename of the test, e.g. argv[0]
918 * @param count peer number
919 * @return configuration name to use
920 */
921char *
922GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, int count);
923
924
925/**
926 * Extracts the plugin anme from an absolute file name and the test name
927 * @param file absolute file name
928 * @param test test name
929 * @return the plugin name
930 */
931char *
932GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable,
933 const char *testname);
934
935
936/**
937 * Extracts the filename from an absolute file name and removes the
938 * extension
939 *
940 * @param file absolute file name
941 * @return the source name
942 */
943char *
944GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file);
945
946#endif
947/* end of transport_testing.h */