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.h924
1 files changed, 0 insertions, 924 deletions
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
deleted file mode 100644
index e2167ca7e..000000000
--- a/src/transport/transport-testing2.h
+++ /dev/null
@@ -1,924 +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 the peer_id
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};
438GNUNET_NETWORK_STRUCT_END
439
440
441/**
442 * Function called by the transport for each received message.
443 *
444 * @param cls closure
445 * @param receiver receiver of the message
446 * @param sender sender of the message
447 * @param message the message
448 */
449typedef void (*GNUNET_TRANSPORT_TESTING_ReceiveCallback) (
450 void *cls,
451 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
452 const struct GNUNET_PeerIdentity *sender,
453 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message);
454
455
456/**
457 * Function called to notify transport users that another
458 * peer connected to us.
459 *
460 * @param cls closure
461 * @param me peer experiencing the event
462 * @param other peer that connected to @a me
463 */
464typedef void (*GNUNET_TRANSPORT_TESTING_NotifyConnect) (
465 void *cls,
466 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
467 const struct GNUNET_PeerIdentity *other);
468
469
470/**
471 * Function called to notify transport users that another
472 * peer disconnected from us.
473 *
474 * @param cls closure
475 * @param me peer experiencing the event
476 * @param other peer that disconnected from @a me
477 */
478typedef void (*GNUNET_TRANSPORT_TESTING_NotifyDisconnect) (
479 void *cls,
480 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
481 const struct GNUNET_PeerIdentity *other);
482
483
484/**
485 * Closure that must be passed to
486 * #GNUNET_TRANSPORT_TESTING_connect_check.
487 */
488struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext
489{
490 /**
491 * How should we continue after the connect?
492 */
493 GNUNET_SCHEDULER_TaskCallback connect_continuation;
494
495 /**
496 * Closure for @e connect_continuation.
497 */
498 void *connect_continuation_cls;
499
500 /**
501 * Which configuration file should we pass to the
502 * #GNUNET_PROGRAM_run() of the testcase?
503 */
504 const char *config_file;
505
506 /**
507 * Receiver argument to give for peers we start.
508 */
509 GNUNET_TRANSPORT_TESTING_ReceiveCallback rec;
510
511 /**
512 * Notify connect argument to give for peers we start.
513 */
514 GNUNET_TRANSPORT_TESTING_NotifyConnect nc;
515
516 /**
517 * Notify disconnect argument to give for peers we start.
518 */
519 GNUNET_TRANSPORT_TESTING_NotifyDisconnect nd;
520
521 /**
522 * Closure for @e rec, @e nc and @e nd.
523 */
524 void *cls;
525
526 /**
527 * Custom task to run on shutdown.
528 */
529 GNUNET_SCHEDULER_TaskCallback shutdown_task;
530
531 /**
532 * Closure for @e shutdown_task.
533 */
534 void *shutdown_task_cls;
535
536 /**
537 * Custom task to run after peers were started but before we try to
538 * connect them. If this function is set, we wait ONE second after
539 * running this function until we continue with connecting the
540 * peers.
541 */
542 GNUNET_SCHEDULER_TaskCallback pre_connect_task;
543
544 /**
545 * Closure for @e shutdown_task.
546 */
547 void *pre_connect_task_cls;
548
549 /**
550 * When should the testcase time out?
551 */
552 struct GNUNET_TIME_Relative timeout;
553
554 /**
555 * Should we try to create connections in both directions?
556 */
557 int bi_directional;
558
559 /* ******* fields set by #GNUNET_TRANSPORT_TESTING_connect_check **** */
560
561 /**
562 * Number of peers involved in the test.
563 */
564 unsigned int num_peers;
565
566 /**
567 * Configuration files we have, array with @e num_peers entries.
568 */
569 char **cfg_files;
570
571 /**
572 * Array with @e num_peers entries.
573 */
574 struct GNUNET_TRANSPORT_TESTING_PeerContext **p;
575
576 /**
577 * Name of the plugin.
578 */
579 const char *test_plugin;
580
581 /**
582 * Name of the testcase.
583 */
584 const char *test_name;
585
586 /**
587 * Configuration object for the testcase.
588 */
589 const struct GNUNET_CONFIGURATION_Handle *cfg;
590
591 /**
592 * Main testing handle.
593 */
594 struct GNUNET_TRANSPORT_TESTING_Handle *tth;
595
596 /**
597 * Result from the main function, set to #GNUNET_OK on success.
598 * Clients should set to #GNUNET_SYSERR to indicate test failure.
599 */
600 int global_ret;
601
602 /**
603 * Generator for the `num` field in test messages. Incremented each
604 * time #GNUNET_TRANSPORT_TESTING_simple_send or
605 * #GNUNET_TRANSPORT_TESTING_large_send are used to transmit a
606 * message.
607 */
608 uint32_t send_num_gen;
609
610 /* ******* internal state, clients should not mess with this **** */
611
612 /**
613 * Task run on timeout.
614 */
615 struct GNUNET_SCHEDULER_Task *timeout_task;
616
617 /**
618 * Task run to connect peers.
619 */
620 struct GNUNET_SCHEDULER_Task *connect_task;
621
622 /**
623 * Number of peers that have been started.
624 */
625 unsigned int started;
626
627 /**
628 * DLL of active connect requests.
629 */
630 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *crl_head;
631
632 /**
633 * DLL of active connect requests.
634 */
635 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *crl_tail;
636
637 /**
638 * Array with @e num_peers entries.
639 */
640 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ip;
641};
642
643
644/**
645 * Find peer by peer ID.
646 *
647 * @param ccc context to search
648 * @param peer peer to look for
649 * @return NULL if @a peer was not found
650 */
651struct GNUNET_TRANSPORT_TESTING_PeerContext *
652GNUNET_TRANSPORT_TESTING_find_peer (
653 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc,
654 const struct GNUNET_PeerIdentity *peer);
655
656
657/**
658 * Common implementation of the #GNUNET_TRANSPORT_TESTING_CheckCallback.
659 * Starts and connects the two peers, then invokes the
660 * `connect_continuation` from @a cls. Sets up a timeout to
661 * abort the test, and a shutdown handler to clean up properly
662 * on exit.
663 *
664 * @param cls closure of type `struct
665 * GNUNET_TRANSPORT_TESTING_ConnectCheckContext`
666 * @param tth_ initialized testing handle
667 * @param test_plugin_ name of the plugin
668 * @param test_name_ name of the test
669 * @param num_peers number of entries in the @a cfg_file array
670 * @param cfg_files array of names of configuration files for the peers
671 * @return #GNUNET_SYSERR on error
672 */
673int
674GNUNET_TRANSPORT_TESTING_connect_check (
675 void *cls,
676 struct GNUNET_TRANSPORT_TESTING_Handle *tth_,
677 const char *test_plugin_,
678 const char *test_name_,
679 unsigned int num_peers,
680 char *cfg_files[]);
681
682
683/**
684 * Main function of a testcase. Called with the initial setup data
685 * for the test as derived from the source name and the binary name.
686 *
687 * @param cls closure
688 * @param tth_ initialized testing handle
689 * @param test_plugin_ name of the plugin
690 * @param test_name_ name of the test
691 * @param num_peers number of entries in the @a cfg_file array
692 * @param cfg_files array of names of configuration files for the peers
693 * @return #GNUNET_SYSERR on error
694 */
695typedef int (*GNUNET_TRANSPORT_TESTING_CheckCallback) (
696 void *cls,
697 struct GNUNET_TRANSPORT_TESTING_Handle *tth_,
698 const char *test_plugin_,
699 const char *test_name_,
700 unsigned int num_peers,
701 char *cfg_files[]);
702
703
704/**
705 * Setup testcase. Calls @a check with the data the test needs.
706 *
707 * @param argv0 binary name (argv[0])
708 * @param filename source file name (__FILE__)
709 * @param num_peers number of peers to start
710 * @param check main function to run
711 * @param check_cls closure for @a check
712 * @return #GNUNET_OK on success
713 */
714int
715GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
716 const char *filename,
717 unsigned int num_peers,
718 GNUNET_TRANSPORT_TESTING_CheckCallback check,
719 void *check_cls);
720
721
722/**
723 * Setup testcase. Calls @a check with the data the test needs.
724 *
725 * @param num_peers number of peers to start
726 * @param check main function to run
727 * @param check_cls closure for @a check
728 * @return #GNUNET_OK on success
729 */
730#define GNUNET_TRANSPORT_TESTING_main(num_peers, check, check_cls) \
731 GNUNET_TRANSPORT_TESTING_main_ (argv[0], \
732 __FILE__, \
733 num_peers, \
734 check, \
735 check_cls)
736
737/* ***************** Convenience functions for sending ********* */
738
739/**
740 * Send a test message of type @a mtype and size @a msize from
741 * peer @a sender to peer @a receiver. The peers should be
742 * connected when this function is called.
743 *
744 * @param sender the sending peer
745 * @param receiver the receiving peer
746 * @param mtype message type to use
747 * @param msize size of the message, at least `sizeof (struct
748 * GNUNET_TRANSPORT_TESTING_TestMessage)`
749 * @param num unique message number
750 * @param cont continuation to call after transmission
751 * @param cont_cls closure for @a cont
752 * @return #GNUNET_OK if message was queued,
753 * #GNUNET_NO if peers are not connected
754 * #GNUNET_SYSERR if @a msize is illegal
755 */
756int
757GNUNET_TRANSPORT_TESTING_send (
758 struct GNUNET_TRANSPORT_TESTING_PeerContext *sender,
759 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
760 uint16_t mtype,
761 uint16_t msize,
762 uint32_t num,
763 GNUNET_SCHEDULER_TaskCallback cont,
764 void *cont_cls);
765
766
767/**
768 * Message type used by #GNUNET_TRANSPORT_TESTING_simple_send().
769 */
770#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE 12345
771
772/**
773 * Alternative message type for tests.
774 */
775#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2 12346
776
777
778/**
779 * Type of the closure argument to pass to
780 * #GNUNET_TRANSPORT_TESTING_simple_send() and
781 * #GNUNET_TRANSPORT_TESTING_large_send().
782 */
783struct GNUNET_TRANSPORT_TESTING_SendClosure
784{
785 /**
786 * Context for the transmission.
787 */
788 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
789
790 /**
791 * Function that returns the desired message size. Overrides
792 * the message size, can be NULL in which case the message
793 * size is the default.
794 */
795 size_t (*get_size_cb) (unsigned int n);
796
797 /**
798 * Number of messages to be transmitted in a loop.
799 * Use zero for "forever" (until external shutdown).
800 */
801 unsigned int num_messages;
802
803 /**
804 * Function to call after all transmissions, can be NULL.
805 */
806 GNUNET_SCHEDULER_TaskCallback cont;
807
808 /**
809 * Closure for @e cont.
810 */
811 void *cont_cls;
812};
813
814
815/**
816 * Task that sends a minimalistic test message from the
817 * first peer to the second peer.
818 *
819 * @param cls the `struct GNUNET_TRANSPORT_TESTING_SendClosure`
820 * which should contain at least two peers, the first two
821 * of which should be currently connected
822 */
823void
824GNUNET_TRANSPORT_TESTING_simple_send (void *cls);
825
826/**
827 * Size of a message sent with
828 * #GNUNET_TRANSPORT_TESTING_large_send(). Big enough
829 * to usually force defragmentation.
830 */
831#define GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE 2600
832
833/**
834 * Task that sends a large test message from the
835 * first peer to the second peer.
836 *
837 * @param cls the `struct GNUNET_TRANSPORT_TESTING_SendClosure`
838 * which should contain at least two peers, the first two
839 * of which should be currently connected
840 */
841void
842GNUNET_TRANSPORT_TESTING_large_send (void *cls);
843
844
845/* ********************** log-only convenience functions ************* */
846
847
848/**
849 * Log a connect event.
850 *
851 * @param cls NULL
852 * @param me peer that had the event
853 * @param other peer that connected.
854 */
855void
856GNUNET_TRANSPORT_TESTING_log_connect (
857 void *cls,
858 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
859 const struct GNUNET_PeerIdentity *other);
860
861
862/**
863 * Log a disconnect event.
864 *
865 * @param cls NULL
866 * @param me peer that had the event
867 * @param other peer that disconnected.
868 */
869void
870GNUNET_TRANSPORT_TESTING_log_disconnect (
871 void *cls,
872 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
873 const struct GNUNET_PeerIdentity *other);
874
875
876/* ********************** low-level filename functions *************** */
877
878
879/**
880 * Extracts the test filename from an absolute file name and removes
881 * the extension.
882 *
883 * @param file absolute file name
884 * @return resulting test name
885 */
886char *
887GNUNET_TRANSPORT_TESTING_get_test_name (const char *file);
888
889
890/**
891 * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
892 * if existing ".exe"-prefix and adds the peer-number
893 *
894 * @param file filename of the test, e.g. argv[0]
895 * @param count peer number
896 * @return configuration name to use
897 */
898char *
899GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, int count);
900
901
902/**
903 * Extracts the plugin anme from an absolute file name and the test name
904 * @param file absolute file name
905 * @param test test name
906 * @return the plugin name
907 */
908char *
909GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable,
910 const char *testname);
911
912
913/**
914 * Extracts the filename from an absolute file name and removes the
915 * extension
916 *
917 * @param file absolute file name
918 * @return the source name
919 */
920char *
921GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file);
922
923#endif
924/* end of transport_testing.h */