2 This file is part of GNUnet
3 (C) 2008, 2009, 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_testbed_service.h
23 * @brief API for writing tests and creating large-scale
24 * emulation testbeds for GNUnet.
25 * @author Christian Grothoff
28 #ifndef GNUNET_TESTBED_SERVICE_H
29 #define GNUNET_TESTBED_SERVICE_H
31 #include "gnunet_util_lib.h"
36 #if 0 /* keep Emacsens' auto-indent happy */
43 * Opaque handle to a host running experiments managed by the testbed framework.
44 * The master process must be able to SSH to this host without password (via
47 struct GNUNET_TESTBED_Host;
50 * Opaque handle to a peer controlled by the testbed framework. A peer runs
51 * at a particular host.
53 struct GNUNET_TESTBED_Peer;
56 * Opaque handle to an abstract operation to be executed by the testbed framework.
58 struct GNUNET_TESTBED_Operation;
61 * Handle to interact with a GNUnet testbed controller. Each controller has at
62 * least one master handle which is created when the controller is created; this
63 * master handle interacts with the controller via stdin/stdout of the controller
64 * process. Additionally, controllers can interact with each other (in a P2P
65 * fashion); those links are established via TCP/IP on the controller's service
68 struct GNUNET_TESTBED_Controller;
71 * Handle to a large-scale testbed that is managed at a high level.
73 struct GNUNET_TESTBED_Testbed;
77 * Create a host to run peers and controllers on.
79 * @param hostname name of the host, use "NULL" for localhost
80 * @param username username to use for the login; may be NULL
81 * @param port port number to use for ssh; use 0 to let ssh decide
82 * @return handle to the host, NULL on error
84 struct GNUNET_TESTBED_Host *
85 GNUNET_TESTBED_host_create (const char *hostname,
91 * Load a set of hosts from a configuration file.
93 * @param filename file with the host specification
94 * @param hosts set to the hosts found in the file
95 * @return number of hosts returned in 'hosts', 0 on error
98 GNUNET_TESTBED_hosts_load_from_file (const char *filename,
99 struct GNUNET_TESTBED_Host **hosts);
103 * Destroy a host handle. Must only be called once everything
104 * running on that host has been stopped.
106 * @param host handle to destroy
109 GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host);
113 * Enumeration with (at most 64) possible event types that
114 * can be monitored using the testbed framework.
116 enum GNUNET_TESTBED_EventType
119 * A peer has been started.
121 GNUNET_TESTBED_ET_PEER_START = 0,
124 * A peer has been stopped.
126 GNUNET_TESTBED_ET_PEER_STOP = 1,
129 * A connection between two peers was established.
131 GNUNET_TESTBED_ET_CONNECT = 2,
134 * A connection between two peers was torn down.
136 GNUNET_TESTBED_ET_DISCONNECT = 3,
139 * A requested testbed operation has been completed.
141 GNUNET_TESTBED_ET_OPERATION_FINISHED = 4,
144 * The 'GNUNET_TESTBED_run' operation has been completed
146 GNUNET_TESTBED_ET_TESTBED_ONLINE = 5
152 * Types of information that can be requested about a peer.
154 enum GNUNET_TESTBED_PeerInformationType
158 * Special value (not valid for requesting information)
159 * that is used in the event struct if a 'generic' pointer
160 * is returned (for other operations not related to this
163 GNUNET_TESTBED_PIT_GENERIC = 0,
166 * What host is the peer running on? Returns a 'const struct
167 * GNUNET_TESTBED_Host *'. Valid until
168 * 'GNUNET_TESTBED_operation_done' is called.
170 GNUNET_TESTBED_PIT_HOST,
173 * What configuration is the peer using? Returns a 'const struct
174 * GNUNET_CONFIGURATION_Handle *'. Valid until
175 * 'GNUNET_TESTNIG_operation_done' is called. However, the
176 * values may be inaccurate if the peer is reconfigured in
179 GNUNET_TESTBED_PIT_CONFIGURATION,
182 * What is the identity of the peer? Returns a
183 * 'const struct GNUNET_PeerIdentity *'. Valid until
184 * 'GNUNET_TESTNIG_operation_done' is called.
186 GNUNET_TESTBED_PIT_IDENTITY
192 * Argument to GNUNET_TESTBED_ControllerCallback with details about
195 struct GNUNET_TESTBED_EventInformation
201 enum GNUNET_TESTBED_EventType type;
204 * Details about the event.
210 * Details about peer start event.
215 * Handle for the host where the peer
218 struct GNUNET_TESTBED_Host *host;
221 * Handle for the peer that was started.
223 struct GNUNET_TESTBED_Peer *peer;
228 * Details about peer stop event.
234 * Handle for the peer that was started.
236 struct GNUNET_TESTBED_Peer *peer;
241 * Details about connect event.
246 * Handle for one of the connected peers.
248 struct GNUNET_TESTBED_Peer *peer1;
251 * Handle for one of the connected peers.
253 struct GNUNET_TESTBED_Peer *peer2;
258 * Details about disconnect event.
263 * Handle for one of the disconnected peers.
265 struct GNUNET_TESTBED_Peer *peer1;
268 * Handle for one of the disconnected peers.
270 struct GNUNET_TESTBED_Peer *peer2;
275 * Details about an operation finished event.
281 * Handle for the operation that was finished.
283 struct GNUNET_TESTBED_Operation *operation;
286 * Closure that was passed in when the event was
292 * Error message for the operation, NULL on success.
297 * Peer information type; captures which of the types
298 * in the 'op_result' is actually in use.
300 enum GNUNET_TESTBED_PeerInformationType pit;
303 * Pointer to an operation-specific return value; NULL on error;
304 * can be NULL for certain operations. Valid until
305 * 'GNUNET_TESTBED_operation_done' is called.
310 * No result (NULL pointer) or generic result
311 * (whatever the GNUNET_TESTBED_ConnectAdapter returned).
316 * Identity of host running the peer.
318 struct GNUNET_TESTBED_Host *host;
321 * Identity of the peer.
323 const struct GNUNET_PeerIdentity *pid;
326 * Configuration of the peer.
328 const struct GNUNET_CONFIGURATION_Handle *cfg;
332 } operation_finished;
336 * Details about an testbed run completed event.
342 * Error message for the operation, NULL on success.
347 * Array of peers now running (valid until
348 * 'GNUNET_TESTBED_testbed_stop' is called). Note that it is
349 * not allowed to call 'GNUNET_TESTBED_peer_destroy' on peers
352 struct GNUNET_TESTBED_Peer **peers;
355 * Size of the 'peers' array.
357 unsigned int num_peers;
359 } testbed_run_finished;
367 * Signature of the event handler function called by the
368 * respective event controller.
371 * @param event information about the event
373 typedef void (*GNUNET_TESTBED_ControllerCallback)(void *cls,
374 const struct GNUNET_TESTBED_EventInformation *event);
378 * Start a controller process using the given configuration at the
381 * @param cfg configuration to use
382 * @param host host to run the controller on, NULL for 'localhost'
383 * @param event_mask bit mask with set of events to call 'cc' for;
384 * or-ed values of "1LL" shifted by the
385 * respective 'enum GNUNET_TESTBED_EventType'
386 * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
387 * @param cc controller callback to invoke on events
388 * @param cc_cls closure for cc
389 * @return handle to the controller
391 struct GNUNET_TESTBED_Controller *
392 GNUNET_TESTBED_controller_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
393 struct GNUNET_TESTBED_Host *host,
395 GNUNET_TESTBED_ControllerCallback cc,
400 * Configure shared services at a controller. Using this function,
401 * you can specify that certain services (such as "resolver")
402 * should not be run for each peer but instead be shared
403 * across N peers on the specified host. This function
404 * must be called before any peers are created at the host.
406 * @param controller controller to configure
407 * @param service_name name of the service to share
408 * @param num_peers number of peers that should share one instance
409 * of the specified service (1 for no sharing is the default),
410 * use 0 to disable the service
413 GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller *controller,
414 const char *service_name,
419 * Stop the given controller (also will terminate all peers and
420 * controllers dependent on this controller). This function
421 * blocks until the testbed has been fully terminated (!).
423 * @param controller handle to controller to stop
426 GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_Controller *controller);
430 * Create a link from a 'master' controller to a slave controller.
431 * Whenever the master controller is asked to start a peer at the
432 * given 'delegated_host', it will delegate the request to the
433 * specified slave controller. Note that the slave controller runs at
434 * the 'slave_host', which may or may not be the same host as the
435 * 'delegated_host' (for hierarchical delegations). The configuration
436 * of the slave controller is given and to be used to either create
437 * the slave controller or to connect to an existing slave controller
438 * process. 'is_subordinate' specifies if the given slave controller
439 * should be started and managed by the master controller, or if the
440 * slave already has a master and this is just a secondary master that
441 * is also allowed to use the existing slave.
443 * @param master handle to the master controller who creates the association
444 * @param delegated_host requests to which host should be delegated
445 * @param slave_host which host is used to run the slave controller
446 * @param slave_cfg configuration to use for the slave controller
447 * @param is_subordinate GNUNET_YES if the slave should be started (and stopped)
448 * by the master controller; GNUNET_NO if we are just
449 * allowed to use the slave via TCP/IP
452 GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
453 struct GNUNET_TESTBED_Host *delegated_host,
454 struct GNUNET_TESTBED_Host *slave_host,
455 const struct GNUNET_CONFIGURATION_Handle *slave_cfg,
460 * Create the given peer at the specified host using the given
461 * controller. If the given controller is not running on the target
462 * host, it should find or create a controller at the target host and
463 * delegate creating the peer. Explicit delegation paths can be setup
464 * using 'GNUNET_TESTBED_controller_link'. If no explicit delegation
465 * path exists, a direct link with a subordinate controller is setup
466 * for the first delegated peer to a particular host; the subordinate
467 * controller is then destroyed once the last peer that was delegated
468 * to the remote host is stopped.
470 * Creating the peer only creates the handle to manipulate and further
471 * configure the peer; use "GNUNET_TESTBED_peer_start" and
472 * "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's
475 * Note that the given configuration will be adjusted by the
476 * controller to avoid port/path conflicts with other peers.
477 * The "final" configuration can be obtained using
478 * 'GNUNET_TESTBED_peer_get_information'.
480 * @param controller controller process to use
481 * @param host host to run the peer on
482 * @param cfg configuration to use for the peer
483 * @return handle to the peer (actual startup will happen asynchronously)
485 struct GNUNET_TESTBED_Peer *
486 GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller,
487 struct GNUNET_TESTBED_Host *host,
488 const struct GNUNET_CONFIGURATION_Handle *cfg);
492 * Start the given peer.
494 * @param peer peer to start
495 * @return handle to the operation
497 struct GNUNET_TESTBED_Operation *
498 GNUNET_TESTBED_peer_start (struct GNUNET_TESTBED_Peer *peer);
502 * Stop the given peer. The handle remains valid (use
503 * "GNUNET_TESTBED_peer_destroy" to fully clean up the
504 * state of the peer).
506 * @param peer peer to stop
507 * @return handle to the operation
509 struct GNUNET_TESTBED_Operation *
510 GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer);
514 * Request information about a peer.
516 * @param peer peer to request information about
517 * @param pit desired information
518 * @return handle to the operation
520 struct GNUNET_TESTBED_Operation *
521 GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
522 enum GNUNET_TESTBED_PeerInformationType pit);
526 * Change peer configuration. Must only be called while the
527 * peer is stopped. Ports and paths cannot be changed this
530 * @param peer peer to change configuration for
531 * @param cfg new configuration (differences to existing
532 * configuration only)
533 * @return handle to the operation
535 struct GNUNET_TESTBED_Operation *
536 GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer,
537 const struct GNUNET_CONFIGURATION_Handle *cfg);
541 * Destroy the given peer; the peer should have been
542 * stopped first (if it was started).
544 * @param peer peer to stop
545 * @return handle to the operation
547 struct GNUNET_TESTBED_Operation *
548 GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer);
552 * Options for peer connections.
554 enum GNUNET_TESTBED_ConnectOption
557 * No option (not valid as an argument).
559 GNUNET_TESTBED_CO_NONE = 0,
562 * Allow or disallow a connection between the specified peers.
563 * Followed by GNUNET_NO (int) if a connection is disallowed
564 * or GNUNET_YES if a connection is allowed. Note that the
565 * default (all connections allowed or disallowed) is
566 * specified in the configuration of the controller.
568 GNUNET_TESTBED_CO_ALLOW = 1,
571 * FIXME: add (and implement) options to limit connection to
572 * particular transports, force simulation of particular latencies
573 * or message loss rates, or set bandwidth limitations.
580 * Manipulate the P2P underlay topology by configuring a link
583 * @param op_cls closure argument to give with the operation event
584 * @param p1 first peer
585 * @param p2 second peer
586 * @param co option to change
587 * @param ap option-specific values
588 * @return handle to the operation, NULL if configuring the link at this
589 * time is not allowed
591 struct GNUNET_TESTBED_Operation *
592 GNUNET_TESTBED_underlay_configure_link_va (void *op_cls,
593 struct GNUNET_TESTBED_Peer *p1,
594 struct GNUNET_TESTBED_Peer *p2,
595 enum GNUNET_TESTBED_ConnectOption co,
600 * Manipulate the P2P underlay topology by configuring a link
603 * @param op_cls closure argument to give with the operation event
604 * @param p1 first peer
605 * @param p2 second peer
606 * @param co option to change
607 * @param ... option-specific values
608 * @return handle to the operation, NULL if configuring the link at this
609 * time is not allowed
611 struct GNUNET_TESTBED_Operation *
612 GNUNET_TESTBED_underlay_configure_link (void *op_cls,
613 struct GNUNET_TESTBED_Peer *p1,
614 struct GNUNET_TESTBED_Peer *p2,
615 enum GNUNET_TESTBED_ConnectOption co, ...);
620 * Topologies supported for testbeds.
622 enum GNUNET_TESTBED_TopologyOption
625 * A clique (everyone connected to everyone else). No options.
627 GNUNET_TESTBED_TOPOLOGY_CLIQUE,
630 * Small-world network (2d torus plus random links). Followed
631 * by the number of random links to add (unsigned int).
633 GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD,
636 * Small-world network (ring plus random links). Followed
637 * by the number of random links to add (unsigned int).
639 GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING,
642 * Ring topology. No options.
644 GNUNET_TESTBED_TOPOLOGY_RING,
647 * 2-d torus. No options.
649 GNUNET_TESTBED_TOPOLOGY_2D_TORUS,
652 * Random graph. Followed by the link density, that is the
653 * percentage of links present in relation to a clique
656 GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
659 * Certain percentage of peers are unable to communicate directly
660 * replicating NAT conditions. Followed by the fraction of
661 * NAT'ed peers (float).
663 GNUNET_TESTBED_TOPOLOGY_INTERNAT,
666 * Scale free topology. FIXME: options?
668 GNUNET_TESTBED_TOPOLOGY_SCALE_FREE,
671 * Straight line topology. No options.
673 GNUNET_TESTBED_TOPOLOGY_LINE,
676 * All peers are disconnected. No options.
678 GNUNET_TESTBED_TOPOLOGY_NONE,
681 * Read a topology from a given file. Followed by the name of the file (const char *).
683 GNUNET_TESTBED_TOPOLOGY_FROM_FILE
688 * Configure overall network topology to have a particular shape.
690 * @param op_cls closure argument to give with the operation event
691 * @param num_peers number of peers in 'peers'
692 * @param peers array of 'num_peers' with the peers to configure
693 * @param topo desired underlay topology to use
694 * @param ap topology-specific options
695 * @return handle to the operation, NULL if configuring the topology
696 * is not allowed at this time
698 struct GNUNET_TESTBED_Operation *
699 GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls,
700 unsigned int num_peers,
701 struct GNUNET_TESTBED_Peer **peers,
702 enum GNUNET_TESTBED_TopologyOption topo,
707 * Configure overall network topology to have a particular shape.
709 * @param op_cls closure argument to give with the operation event
710 * @param num_peers number of peers in 'peers'
711 * @param peers array of 'num_peers' with the peers to configure
712 * @param topo desired underlay topology to use
713 * @param ... topology-specific options
714 * @return handle to the operation, NULL if configuring the topology
715 * is not allowed at this time
717 struct GNUNET_TESTBED_Operation *
718 GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
719 unsigned int num_peers,
720 struct GNUNET_TESTBED_Peer **peers,
721 enum GNUNET_TESTBED_TopologyOption topo,
726 * Both peers must have been started before calling this function.
727 * This function then obtains a HELLO from 'p1', gives it to 'p2'
728 * and asks 'p2' to connect to 'p1'.
730 * @param op_cls closure argument to give with the operation event
731 * @param p1 first peer
732 * @param p2 second peer
733 * @return handle to the operation, NULL if connecting these two
734 * peers is fundamentally not possible at this time (peers
735 * not running or underlay disallows)
737 struct GNUNET_TESTBED_Operation *
738 GNUNET_TESTBED_overlay_connect (void *op_cls,
739 struct GNUNET_TESTBED_Peer *p1,
740 struct GNUNET_TESTBED_Peer *p2);
744 * All peers must have been started before calling this function.
745 * This function then connects the given peers in the P2P overlay
746 * using the given topology.
748 * @param op_cls closure argument to give with the operation event
749 * @param num_peers number of peers in 'peers'
750 * @param peers array of 'num_peers' with the peers to configure
751 * @param topo desired underlay topology to use
752 * @param va topology-specific options
753 * @return handle to the operation, NULL if connecting these
754 * peers is fundamentally not possible at this time (peers
755 * not running or underlay disallows)
757 struct GNUNET_TESTBED_Operation *
758 GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
759 unsigned int num_peers,
760 struct GNUNET_TESTBED_Peer *peers,
761 enum GNUNET_TESTBED_TopologyOption topo,
766 * All peers must have been started before calling this function.
767 * This function then connects the given peers in the P2P overlay
768 * using the given topology.
770 * @param op_cls closure argument to give with the operation event
771 * @param num_peers number of peers in 'peers'
772 * @param peers array of 'num_peers' with the peers to configure
773 * @param topo desired underlay topology to use
774 * @param ... topology-specific options
775 * @return handle to the operation, NULL if connecting these
776 * peers is fundamentally not possible at this time (peers
777 * not running or underlay disallows)
779 struct GNUNET_TESTBED_Operation *
780 GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
781 unsigned int num_peers,
782 struct GNUNET_TESTBED_Peer *peers,
783 enum GNUNET_TESTBED_TopologyOption topo,
789 * Ask the testbed controller to write the current overlay topology to
790 * a file. Naturally, the file will only contain a snapshot as the
791 * topology may evolve all the time.
793 * @param controller overlay controller to inspect
794 * @param filename name of the file the topology should
798 GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller,
799 const char *filename);
803 * Adapter function called to establish a connection to
807 * @param cfg configuration of the peer to connect to
808 * @return service handle to return in 'op_result', NULL on error
810 typedef void * (*GNUNET_TESTBED_ConnectAdapter)(void *cls,
811 const struct GNUNET_CONFIGURATION_Handle *cfg);
815 * Adapter function called to destroy a connection to
819 * @param op_result service handle returned from the connect adapter
821 typedef void (*GNUNET_TESTBED_DisconnectAdapter)(void *cls,
826 * Connect to a service offered by the given peer. Will ensure that
827 * the request is queued to not overwhelm our ability to create and
828 * maintain connections with other systems. The actual service
829 * handle is then returned via the 'op_result' member in the event
830 * callback. The 'ca' callback is used to create the connection
831 * when the time is right; the 'da' callback will be used to
832 * destroy the connection (upon 'GNUNET_TESTBED_operation_done').
833 * 'GNUNET_TESTBED_operation_cancel' can be used to abort this
834 * operation until the event callback has been called.
836 * @param op_cls closure to pass in operation event
837 * @param peer peer that runs the service
838 * @param service_name name of the service to connect to
839 * @param ca helper function to establish the connection
840 * @param da helper function to close the connection
841 * @param cada_cls closure for ca and da
842 * @return handle for the operation
844 struct GNUNET_TESTBED_Operation *
845 GNUNET_TESTBED_service_connect (void *op_cls,
846 struct GNUNET_TESTBED_Peer *peer,
847 const char *service_name,
848 GNUNET_TESTBED_ConnectAdapter ca,
849 GNUNET_TESTBED_DisconnectAdapter da,
854 * Cancel a pending operation. Releases all resources
855 * of the operation and will ensure that no event
856 * is generated for the operation. Does NOT guarantee
857 * that the operation will be fully undone (or that
858 * nothing ever happened).
860 * @param operation operation to cancel
863 GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation);
867 * Signal that the information from an operation has been fully
868 * processed. This function MUST be called for each event
869 * of type 'operation_finished' to fully remove the operation
870 * from the operation queue. After calling this function, the
871 * 'op_result' becomes invalid (!).
873 * @param operation operation to signal completion for
876 GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation);
880 * Configure and run a testbed using the given
881 * master controller on 'num_hosts' starting
882 * 'num_peers' using the given peer configuration.
884 * @param controller master controller for the testbed
885 * (must not be destroyed until after the
886 * testbed is destroyed).
887 * @param num_hosts number of hosts in 'hosts', 0 to only
889 * @param hosts list of hosts to use for the testbed
890 * @param num_peers number of peers to start
891 * @param peer_cfg peer configuration template to use
892 * @param underlay_topology underlay topology to create
893 * @param va topology-specific options
894 * @return handle to the testbed
896 struct GNUNET_TESTBED_Testbed *
897 GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller,
898 unsigned int num_hosts,
899 struct GNUNET_TESTBED_Host **hosts,
900 unsigned int num_peers,
901 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
902 enum GNUNET_TESTBED_TopologyOption underlay_topology,
907 * Configure and run a testbed using the given
908 * master controller on 'num_hosts' starting
909 * 'num_peers' using the given peer configuration.
911 * @param controller master controller for the testbed
912 * (must not be destroyed until after the
913 * testbed is destroyed).
914 * @param num_hosts number of hosts in 'hosts', 0 to only
916 * @param hosts list of hosts to use for the testbed
917 * @param num_peers number of peers to start
918 * @param peer_cfg peer configuration template to use
919 * @param underlay_topology underlay topology to create
920 * @param ... topology-specific options
922 struct GNUNET_TESTBED_Testbed *
923 GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller,
924 unsigned int num_hosts,
925 struct GNUNET_TESTBED_Host **hosts,
926 unsigned int num_peers,
927 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
928 enum GNUNET_TESTBED_TopologyOption underlay_topology,
933 * Destroy a testbed. Stops all running peers and then
934 * destroys all peers. Does NOT destroy the master controller.
936 * @param testbed testbed to destroy
939 GNUNET_TESTBED_destroy (struct GNUNET_TESTBED_Testbed *testbed);
943 * Convenience method for running a testbed with
944 * a single call. Underlay and overlay topology
945 * are configured using the "UNDERLAY" and "OVERLAY"
946 * options in the "[testbed]" section of the configuration\
947 * (with possible options given in "UNDERLAY_XXX" and/or
950 * The testbed is to be terminated using a call to
951 * "GNUNET_SCHEDULER_shutdown".
953 * @param host_filename name of the file with the 'hosts', NULL
954 * to run everything on 'localhost'
955 * @param cfg configuration to use (for testbed, controller and peers)
956 * @param num_peers number of peers to start; FIXME: maybe put that ALSO into cfg?
957 * @param event_mask bit mask with set of events to call 'cc' for;
958 * or-ed values of "1LL" shifted by the
959 * respective 'enum GNUNET_TESTBED_EventType'
960 * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
961 * @param cc controller callback to invoke on events
962 * @param cc_cls closure for cc
963 * @param master task to run once the testbed is ready
964 * @param master_cls closure for 'task'.
967 GNUNET_TESTBED_run (const char *host_filename,
968 const struct GNUNET_CONFIGURATION_Handle *cfg,
969 unsigned int num_peers,
971 GNUNET_TESTBED_ControllerCallback cc,
973 GNUNET_SCHEDULER_Task master,
978 * Signature of a main function for a testcase.
981 * @param num_peers number of peers in 'peers'
982 * @param peers handle to peers run in the testbed
984 typedef void (*GNUNET_TESTBED_TestMaster)(void *cls,
985 unsigned int num_peers,
986 struct GNUNET_TESTBED_Peer **peers);
990 * Convenience method for running a "simple" test on the local system
991 * with a single call from 'main'. Underlay and overlay topology are
992 * configured using the "UNDERLAY" and "OVERLAY" options in the
993 * "[testbed]" section of the configuration (with possible options
994 * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").
996 * The test is to be terminated using a call to
997 * "GNUNET_SCHEDULER_shutdown". If starting the test fails,
998 * the program is stopped without 'master' ever being run.
1000 * NOTE: this function should be called from 'main', NOT from
1001 * within a GNUNET_SCHEDULER-loop. This function will initialze
1002 * the scheduler loop, the testbed and then pass control to
1005 * @param testname name of the testcase (to configure logging, etc.)
1006 * @param cfg_filename configuration filename to use
1007 * (for testbed, controller and peers)
1008 * @param num_peers number of peers to start
1009 * @param test_master task to run once the test is ready
1010 * @param test_master_cls closure for 'task'.
1013 GNUNET_TESTBED_test_run (const char *testname,
1014 const char *cfg_filename,
1015 unsigned int num_peers,
1016 GNUNET_TESTBED_TestMaster test_master,
1017 void *test_master_cls);
1020 #if 0 /* keep Emacsens' auto-indent happy */