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