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