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