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
62 * controller has at least one master handle which is created when the
63 * controller is created; this master handle interacts with the
64 * controller process, destroying it destroys the controller (by
65 * closing stdin of the controller process). Additionally,
66 * controllers can interact with each other (in a P2P fashion); those
67 * links are established via TCP/IP on the controller's service port.
69 struct GNUNET_TESTBED_Controller;
72 * Handle to a large-scale testbed that is managed at a high level.
74 struct GNUNET_TESTBED_Testbed;
78 * Create a host to run peers and controllers on.
80 * @param hostname name of the host, use "NULL" for localhost
81 * @param username username to use for the login; may be NULL
82 * @param port port number to use for ssh; use 0 to let ssh decide
83 * @return handle to the host, NULL on error
85 struct GNUNET_TESTBED_Host *
86 GNUNET_TESTBED_host_create (const char *hostname,
92 * Load a set of hosts from a configuration file.
94 * @param filename file with the host specification
95 * @param hosts set to the hosts found in the file
96 * @return number of hosts returned in 'hosts', 0 on error
99 GNUNET_TESTBED_hosts_load_from_file (const char *filename,
100 struct GNUNET_TESTBED_Host **hosts);
104 * Destroy a host handle. Must only be called once everything
105 * running on that host has been stopped.
107 * @param host handle to destroy
110 GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host);
114 * Enumeration with (at most 64) possible event types that
115 * can be monitored using the testbed framework.
117 enum GNUNET_TESTBED_EventType
120 * A peer has been started.
122 GNUNET_TESTBED_ET_PEER_START = 0,
125 * A peer has been stopped.
127 GNUNET_TESTBED_ET_PEER_STOP = 1,
130 * A connection between two peers was established.
132 GNUNET_TESTBED_ET_CONNECT = 2,
135 * A connection between two peers was torn down.
137 GNUNET_TESTBED_ET_DISCONNECT = 3,
140 * A requested testbed operation has been completed.
142 GNUNET_TESTBED_ET_OPERATION_FINISHED = 4,
145 * The 'GNUNET_TESTBED_run' operation has been completed
147 GNUNET_TESTBED_ET_TESTBED_ONLINE = 5
153 * Types of information that can be requested about a peer.
155 enum GNUNET_TESTBED_PeerInformationType
159 * Special value (not valid for requesting information)
160 * that is used in the event struct if a 'generic' pointer
161 * is returned (for other operations not related to this
164 GNUNET_TESTBED_PIT_GENERIC = 0,
167 * What host is the peer running on? Returns a 'const struct
168 * GNUNET_TESTBED_Host *'. Valid until
169 * 'GNUNET_TESTBED_operation_done' is called.
171 GNUNET_TESTBED_PIT_HOST,
174 * What configuration is the peer using? Returns a 'const struct
175 * GNUNET_CONFIGURATION_Handle *'. Valid until
176 * 'GNUNET_TESTNIG_operation_done' is called. However, the
177 * values may be inaccurate if the peer is reconfigured in
180 GNUNET_TESTBED_PIT_CONFIGURATION,
183 * What is the identity of the peer? Returns a
184 * 'const struct GNUNET_PeerIdentity *'. Valid until
185 * 'GNUNET_TESTNIG_operation_done' is called.
187 GNUNET_TESTBED_PIT_IDENTITY
193 * Argument to GNUNET_TESTBED_ControllerCallback with details about
196 struct GNUNET_TESTBED_EventInformation
202 enum GNUNET_TESTBED_EventType type;
205 * Details about the event.
211 * Details about peer start event.
216 * Handle for the host where the peer
219 struct GNUNET_TESTBED_Host *host;
222 * Handle for the peer that was started.
224 struct GNUNET_TESTBED_Peer *peer;
229 * Details about peer stop event.
235 * Handle for the peer that was started.
237 struct GNUNET_TESTBED_Peer *peer;
242 * Details about connect event.
247 * Handle for one of the connected peers.
249 struct GNUNET_TESTBED_Peer *peer1;
252 * Handle for one of the connected peers.
254 struct GNUNET_TESTBED_Peer *peer2;
259 * Details about disconnect event.
264 * Handle for one of the disconnected peers.
266 struct GNUNET_TESTBED_Peer *peer1;
269 * Handle for one of the disconnected peers.
271 struct GNUNET_TESTBED_Peer *peer2;
276 * Details about an operation finished event.
282 * Handle for the operation that was finished.
284 struct GNUNET_TESTBED_Operation *operation;
287 * Closure that was passed in when the event was
293 * Error message for the operation, NULL on success.
298 * Peer information type; captures which of the types
299 * in the 'op_result' is actually in use.
301 enum GNUNET_TESTBED_PeerInformationType pit;
304 * Pointer to an operation-specific return value; NULL on error;
305 * can be NULL for certain operations. Valid until
306 * 'GNUNET_TESTBED_operation_done' is called.
311 * No result (NULL pointer) or generic result
312 * (whatever the GNUNET_TESTBED_ConnectAdapter returned).
317 * Identity of host running the peer.
319 struct GNUNET_TESTBED_Host *host;
322 * Identity of the peer.
324 const struct GNUNET_PeerIdentity *pid;
327 * Configuration of the peer.
329 const struct GNUNET_CONFIGURATION_Handle *cfg;
333 } operation_finished;
337 * Details about an testbed run completed event.
343 * Error message for the operation, NULL on success.
348 * Array of peers now running (valid until
349 * 'GNUNET_TESTBED_testbed_stop' is called). Note that it is
350 * not allowed to call 'GNUNET_TESTBED_peer_destroy' on peers
353 struct GNUNET_TESTBED_Peer **peers;
356 * Size of the 'peers' array.
358 unsigned int num_peers;
360 } testbed_run_finished;
368 * Signature of the event handler function called by the
369 * respective event controller.
372 * @param event information about the event
374 typedef void (*GNUNET_TESTBED_ControllerCallback)(void *cls,
375 const struct GNUNET_TESTBED_EventInformation *event);
379 * Start a controller process using the given configuration at the
382 * @param cfg configuration to use
383 * @param host host to run the controller on, NULL for 'localhost'
384 * @param event_mask bit mask with set of events to call 'cc' for;
385 * or-ed values of "1LL" shifted by the
386 * respective 'enum GNUNET_TESTBED_EventType'
387 * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
388 * @param cc controller callback to invoke on events
389 * @param cc_cls closure for cc
390 * @return handle to the controller
392 struct GNUNET_TESTBED_Controller *
393 GNUNET_TESTBED_controller_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
394 struct GNUNET_TESTBED_Host *host,
396 GNUNET_TESTBED_ControllerCallback cc,
401 * Configure shared services at a controller. Using this function,
402 * you can specify that certain services (such as "resolver")
403 * should not be run for each peer but instead be shared
404 * across N peers on the specified host. This function
405 * must be called before any peers are created at the host.
407 * @param controller controller to configure
408 * @param service_name name of the service to share
409 * @param num_peers number of peers that should share one instance
410 * of the specified service (1 for no sharing is the default),
411 * use 0 to disable the service
414 GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller *controller,
415 const char *service_name,
420 * Stop the given controller (also will terminate all peers and
421 * controllers dependent on this controller). This function
422 * blocks until the testbed has been fully terminated (!).
424 * @param controller handle to controller to stop
427 GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_Controller *controller);
431 * Create a link from a 'master' controller to a slave controller.
432 * Whenever the master controller is asked to start a peer at the
433 * given 'delegated_host', it will delegate the request to the
434 * specified slave controller. Note that the slave controller runs at
435 * the 'slave_host', which may or may not be the same host as the
436 * 'delegated_host' (for hierarchical delegations). The configuration
437 * of the slave controller is given and to be used to either create
438 * the slave controller or to connect to an existing slave controller
439 * process. 'is_subordinate' specifies if the given slave controller
440 * should be started and managed by the master controller, or if the
441 * slave already has a master and this is just a secondary master that
442 * is also allowed to use the existing slave.
444 * @param master handle to the master controller who creates the association
445 * @param delegated_host requests to which host should be delegated
446 * @param slave_host which host is used to run the slave controller
447 * @param slave_cfg configuration to use for the slave controller
448 * @param is_subordinate GNUNET_YES if the slave should be started (and stopped)
449 * by the master controller; GNUNET_NO if we are just
450 * allowed to use the slave via TCP/IP
453 GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
454 struct GNUNET_TESTBED_Host *delegated_host,
455 struct GNUNET_TESTBED_Host *slave_host,
456 const struct GNUNET_CONFIGURATION_Handle *slave_cfg,
461 * Create the given peer at the specified host using the given
462 * controller. If the given controller is not running on the target
463 * host, it should find or create a controller at the target host and
464 * delegate creating the peer. Explicit delegation paths can be setup
465 * using 'GNUNET_TESTBED_controller_link'. If no explicit delegation
466 * path exists, a direct link with a subordinate controller is setup
467 * for the first delegated peer to a particular host; the subordinate
468 * controller is then destroyed once the last peer that was delegated
469 * to the remote host is stopped.
471 * Creating the peer only creates the handle to manipulate and further
472 * configure the peer; use "GNUNET_TESTBED_peer_start" and
473 * "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's
476 * Note that the given configuration will be adjusted by the
477 * controller to avoid port/path conflicts with other peers.
478 * The "final" configuration can be obtained using
479 * 'GNUNET_TESTBED_peer_get_information'.
481 * @param controller controller process to use
482 * @param host host to run the peer on
483 * @param cfg configuration to use for the peer
484 * @return handle to the peer (actual startup will happen asynchronously)
486 struct GNUNET_TESTBED_Peer *
487 GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller,
488 struct GNUNET_TESTBED_Host *host,
489 const struct GNUNET_CONFIGURATION_Handle *cfg);
493 * Start the given peer.
495 * @param peer peer to start
496 * @return handle to the operation
498 struct GNUNET_TESTBED_Operation *
499 GNUNET_TESTBED_peer_start (struct GNUNET_TESTBED_Peer *peer);
503 * Stop the given peer. The handle remains valid (use
504 * "GNUNET_TESTBED_peer_destroy" to fully clean up the
505 * state of the peer).
507 * @param peer peer to stop
508 * @return handle to the operation
510 struct GNUNET_TESTBED_Operation *
511 GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer);
515 * Request information about a peer.
517 * @param peer peer to request information about
518 * @param pit desired information
519 * @return handle to the operation
521 struct GNUNET_TESTBED_Operation *
522 GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
523 enum GNUNET_TESTBED_PeerInformationType pit);
527 * Change peer configuration. Must only be called while the
528 * peer is stopped. Ports and paths cannot be changed this
531 * @param peer peer to change configuration for
532 * @param cfg new configuration (differences to existing
533 * configuration only)
534 * @return handle to the operation
536 struct GNUNET_TESTBED_Operation *
537 GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer,
538 const struct GNUNET_CONFIGURATION_Handle *cfg);
542 * Destroy the given peer; the peer should have been
543 * stopped first (if it was started).
545 * @param peer peer to stop
546 * @return handle to the operation
548 struct GNUNET_TESTBED_Operation *
549 GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer);
553 * Options for peer connections.
555 enum GNUNET_TESTBED_ConnectOption
558 * No option (not valid as an argument).
560 GNUNET_TESTBED_CO_NONE = 0,
563 * Allow or disallow a connection between the specified peers.
564 * Followed by GNUNET_NO (int) if a connection is disallowed
565 * or GNUNET_YES if a connection is allowed. Note that the
566 * default (all connections allowed or disallowed) is
567 * specified in the configuration of the controller.
569 GNUNET_TESTBED_CO_ALLOW = 1,
572 * FIXME: add (and implement) options to limit connection to
573 * particular transports, force simulation of particular latencies
574 * or message loss rates, or set bandwidth limitations.
581 * Manipulate the P2P underlay topology by configuring a link
584 * @param op_cls closure argument to give with the operation event
585 * @param p1 first peer
586 * @param p2 second peer
587 * @param co option to change
588 * @param ap option-specific values
589 * @return handle to the operation, NULL if configuring the link at this
590 * time is not allowed
592 struct GNUNET_TESTBED_Operation *
593 GNUNET_TESTBED_underlay_configure_link_va (void *op_cls,
594 struct GNUNET_TESTBED_Peer *p1,
595 struct GNUNET_TESTBED_Peer *p2,
596 enum GNUNET_TESTBED_ConnectOption co,
601 * Manipulate the P2P underlay topology by configuring a link
604 * @param op_cls closure argument to give with the operation event
605 * @param p1 first peer
606 * @param p2 second peer
607 * @param co option to change
608 * @param ... option-specific values
609 * @return handle to the operation, NULL if configuring the link at this
610 * time is not allowed
612 struct GNUNET_TESTBED_Operation *
613 GNUNET_TESTBED_underlay_configure_link (void *op_cls,
614 struct GNUNET_TESTBED_Peer *p1,
615 struct GNUNET_TESTBED_Peer *p2,
616 enum GNUNET_TESTBED_ConnectOption co, ...);
621 * Topologies supported for testbeds.
623 enum GNUNET_TESTBED_TopologyOption
626 * A clique (everyone connected to everyone else). No options.
628 GNUNET_TESTBED_TOPOLOGY_CLIQUE,
631 * Small-world network (2d torus plus random links). Followed
632 * by the number of random links to add (unsigned int).
634 GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD,
637 * Small-world network (ring plus random links). Followed
638 * by the number of random links to add (unsigned int).
640 GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING,
643 * Ring topology. No options.
645 GNUNET_TESTBED_TOPOLOGY_RING,
648 * 2-d torus. No options.
650 GNUNET_TESTBED_TOPOLOGY_2D_TORUS,
653 * Random graph. Followed by the link density, that is the
654 * percentage of links present in relation to a clique
657 GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
660 * Certain percentage of peers are unable to communicate directly
661 * replicating NAT conditions. Followed by the fraction of
662 * NAT'ed peers (float).
664 GNUNET_TESTBED_TOPOLOGY_INTERNAT,
667 * Scale free topology. FIXME: options?
669 GNUNET_TESTBED_TOPOLOGY_SCALE_FREE,
672 * Straight line topology. No options.
674 GNUNET_TESTBED_TOPOLOGY_LINE,
677 * All peers are disconnected. No options.
679 GNUNET_TESTBED_TOPOLOGY_NONE,
682 * Read a topology from a given file. Followed by the name of the file (const char *).
684 GNUNET_TESTBED_TOPOLOGY_FROM_FILE
689 * Configure overall network topology to have a particular shape.
691 * @param op_cls closure argument to give with the operation event
692 * @param num_peers number of peers in 'peers'
693 * @param peers array of 'num_peers' with the peers to configure
694 * @param topo desired underlay topology to use
695 * @param ap topology-specific options
696 * @return handle to the operation, NULL if configuring the topology
697 * is not allowed at this time
699 struct GNUNET_TESTBED_Operation *
700 GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls,
701 unsigned int num_peers,
702 struct GNUNET_TESTBED_Peer **peers,
703 enum GNUNET_TESTBED_TopologyOption topo,
708 * Configure overall network topology to have a particular shape.
710 * @param op_cls closure argument to give with the operation event
711 * @param num_peers number of peers in 'peers'
712 * @param peers array of 'num_peers' with the peers to configure
713 * @param topo desired underlay topology to use
714 * @param ... topology-specific options
715 * @return handle to the operation, NULL if configuring the topology
716 * is not allowed at this time
718 struct GNUNET_TESTBED_Operation *
719 GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
720 unsigned int num_peers,
721 struct GNUNET_TESTBED_Peer **peers,
722 enum GNUNET_TESTBED_TopologyOption topo,
727 * Both peers must have been started before calling this function.
728 * This function then obtains a HELLO from 'p1', gives it to 'p2'
729 * and asks 'p2' to connect to 'p1'.
731 * @param op_cls closure argument to give with the operation event
732 * @param p1 first peer
733 * @param p2 second peer
734 * @return handle to the operation, NULL if connecting these two
735 * peers is fundamentally not possible at this time (peers
736 * not running or underlay disallows)
738 struct GNUNET_TESTBED_Operation *
739 GNUNET_TESTBED_overlay_connect (void *op_cls,
740 struct GNUNET_TESTBED_Peer *p1,
741 struct GNUNET_TESTBED_Peer *p2);
745 * All peers must have been started before calling this function.
746 * This function then connects the given peers in the P2P overlay
747 * using the given topology.
749 * @param op_cls closure argument to give with the operation event
750 * @param num_peers number of peers in 'peers'
751 * @param peers array of 'num_peers' with the peers to configure
752 * @param topo desired underlay topology to use
753 * @param va topology-specific options
754 * @return handle to the operation, NULL if connecting these
755 * peers is fundamentally not possible at this time (peers
756 * not running or underlay disallows)
758 struct GNUNET_TESTBED_Operation *
759 GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
760 unsigned int num_peers,
761 struct GNUNET_TESTBED_Peer *peers,
762 enum GNUNET_TESTBED_TopologyOption topo,
767 * All peers must have been started before calling this function.
768 * This function then connects the given peers in the P2P overlay
769 * using the given topology.
771 * @param op_cls closure argument to give with the operation event
772 * @param num_peers number of peers in 'peers'
773 * @param peers array of 'num_peers' with the peers to configure
774 * @param topo desired underlay topology to use
775 * @param ... topology-specific options
776 * @return handle to the operation, NULL if connecting these
777 * peers is fundamentally not possible at this time (peers
778 * not running or underlay disallows)
780 struct GNUNET_TESTBED_Operation *
781 GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
782 unsigned int num_peers,
783 struct GNUNET_TESTBED_Peer *peers,
784 enum GNUNET_TESTBED_TopologyOption topo,
790 * Ask the testbed controller to write the current overlay topology to
791 * a file. Naturally, the file will only contain a snapshot as the
792 * topology may evolve all the time.
794 * @param controller overlay controller to inspect
795 * @param filename name of the file the topology should
799 GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller,
800 const char *filename);
804 * Adapter function called to establish a connection to
808 * @param cfg configuration of the peer to connect to
809 * @return service handle to return in 'op_result', NULL on error
811 typedef void * (*GNUNET_TESTBED_ConnectAdapter)(void *cls,
812 const struct GNUNET_CONFIGURATION_Handle *cfg);
816 * Adapter function called to destroy a connection to
820 * @param op_result service handle returned from the connect adapter
822 typedef void (*GNUNET_TESTBED_DisconnectAdapter)(void *cls,
827 * Connect to a service offered by the given peer. Will ensure that
828 * the request is queued to not overwhelm our ability to create and
829 * maintain connections with other systems. The actual service
830 * handle is then returned via the 'op_result' member in the event
831 * callback. The 'ca' callback is used to create the connection
832 * when the time is right; the 'da' callback will be used to
833 * destroy the connection (upon 'GNUNET_TESTBED_operation_done').
834 * 'GNUNET_TESTBED_operation_cancel' can be used to abort this
835 * operation until the event callback has been called.
837 * @param op_cls closure to pass in operation event
838 * @param peer peer that runs the service
839 * @param service_name name of the service to connect to
840 * @param ca helper function to establish the connection
841 * @param da helper function to close the connection
842 * @param cada_cls closure for ca and da
843 * @return handle for the operation
845 struct GNUNET_TESTBED_Operation *
846 GNUNET_TESTBED_service_connect (void *op_cls,
847 struct GNUNET_TESTBED_Peer *peer,
848 const char *service_name,
849 GNUNET_TESTBED_ConnectAdapter ca,
850 GNUNET_TESTBED_DisconnectAdapter da,
855 * Cancel a pending operation. Releases all resources
856 * of the operation and will ensure that no event
857 * is generated for the operation. Does NOT guarantee
858 * that the operation will be fully undone (or that
859 * nothing ever happened).
861 * @param operation operation to cancel
864 GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation);
868 * Signal that the information from an operation has been fully
869 * processed. This function MUST be called for each event
870 * of type 'operation_finished' to fully remove the operation
871 * from the operation queue. After calling this function, the
872 * 'op_result' becomes invalid (!).
874 * @param operation operation to signal completion for
877 GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation);
881 * Configure and run a testbed using the given
882 * master controller on 'num_hosts' starting
883 * 'num_peers' using the given peer configuration.
885 * @param controller master controller for the testbed
886 * (must not be destroyed until after the
887 * testbed is destroyed).
888 * @param num_hosts number of hosts in 'hosts', 0 to only
890 * @param hosts list of hosts to use for the testbed
891 * @param num_peers number of peers to start
892 * @param peer_cfg peer configuration template to use
893 * @param underlay_topology underlay topology to create
894 * @param va topology-specific options
895 * @return handle to the testbed
897 struct GNUNET_TESTBED_Testbed *
898 GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller,
899 unsigned int num_hosts,
900 struct GNUNET_TESTBED_Host **hosts,
901 unsigned int num_peers,
902 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
903 enum GNUNET_TESTBED_TopologyOption underlay_topology,
908 * Configure and run a testbed using the given
909 * master controller on 'num_hosts' starting
910 * 'num_peers' using the given peer configuration.
912 * @param controller master controller for the testbed
913 * (must not be destroyed until after the
914 * testbed is destroyed).
915 * @param num_hosts number of hosts in 'hosts', 0 to only
917 * @param hosts list of hosts to use for the testbed
918 * @param num_peers number of peers to start
919 * @param peer_cfg peer configuration template to use
920 * @param underlay_topology underlay topology to create
921 * @param ... topology-specific options
923 struct GNUNET_TESTBED_Testbed *
924 GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller,
925 unsigned int num_hosts,
926 struct GNUNET_TESTBED_Host **hosts,
927 unsigned int num_peers,
928 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
929 enum GNUNET_TESTBED_TopologyOption underlay_topology,
934 * Destroy a testbed. Stops all running peers and then
935 * destroys all peers. Does NOT destroy the master controller.
937 * @param testbed testbed to destroy
940 GNUNET_TESTBED_destroy (struct GNUNET_TESTBED_Testbed *testbed);
944 * Convenience method for running a testbed with
945 * a single call. Underlay and overlay topology
946 * are configured using the "UNDERLAY" and "OVERLAY"
947 * options in the "[testbed]" section of the configuration\
948 * (with possible options given in "UNDERLAY_XXX" and/or
951 * The testbed is to be terminated using a call to
952 * "GNUNET_SCHEDULER_shutdown".
954 * @param host_filename name of the file with the 'hosts', NULL
955 * to run everything on 'localhost'
956 * @param cfg configuration to use (for testbed, controller and peers)
957 * @param num_peers number of peers to start; FIXME: maybe put that ALSO into cfg?
958 * @param event_mask bit mask with set of events to call 'cc' for;
959 * or-ed values of "1LL" shifted by the
960 * respective 'enum GNUNET_TESTBED_EventType'
961 * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
962 * @param cc controller callback to invoke on events
963 * @param cc_cls closure for cc
964 * @param master task to run once the testbed is ready
965 * @param master_cls closure for 'task'.
968 GNUNET_TESTBED_run (const char *host_filename,
969 const struct GNUNET_CONFIGURATION_Handle *cfg,
970 unsigned int num_peers,
972 GNUNET_TESTBED_ControllerCallback cc,
974 GNUNET_SCHEDULER_Task master,
979 * Signature of a main function for a testcase.
982 * @param num_peers number of peers in 'peers'
983 * @param peers handle to peers run in the testbed
985 typedef void (*GNUNET_TESTBED_TestMaster)(void *cls,
986 unsigned int num_peers,
987 struct GNUNET_TESTBED_Peer **peers);
991 * Convenience method for running a "simple" test on the local system
992 * with a single call from 'main'. Underlay and overlay topology are
993 * configured using the "UNDERLAY" and "OVERLAY" options in the
994 * "[testbed]" section of the configuration (with possible options
995 * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").
997 * The test is to be terminated using a call to
998 * "GNUNET_SCHEDULER_shutdown". If starting the test fails,
999 * the program is stopped without 'master' ever being run.
1001 * NOTE: this function should be called from 'main', NOT from
1002 * within a GNUNET_SCHEDULER-loop. This function will initialze
1003 * the scheduler loop, the testbed and then pass control to
1006 * @param testname name of the testcase (to configure logging, etc.)
1007 * @param cfg_filename configuration filename to use
1008 * (for testbed, controller and peers)
1009 * @param num_peers number of peers to start
1010 * @param test_master task to run once the test is ready
1011 * @param test_master_cls closure for 'task'.
1014 GNUNET_TESTBED_test_run (const char *testname,
1015 const char *cfg_filename,
1016 unsigned int num_peers,
1017 GNUNET_TESTBED_TestMaster test_master,
1018 void *test_master_cls);
1021 #if 0 /* keep Emacsens' auto-indent happy */