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,
93 * Create a host to run peers and controllers on. This function is used
94 * if a peer learns about a host via IPC between controllers (and thus
95 * some higher-level controller has already determined the unique IDs).
97 * @param id global host ID assigned to the host; 0 is
98 * reserved to always mean 'localhost'
99 * @param hostname name of the host, use "NULL" for localhost
100 * @param username username to use for the login; may be NULL
101 * @param port port number to use for ssh; use 0 to let ssh decide
102 * @return handle to the host, NULL on error
104 struct GNUNET_TESTBED_Host *
105 GNUNET_TESTBED_host_create_with_id (uint32_t id,
106 const char *hostname,
107 const char *username,
112 * Load a set of hosts from a configuration file.
114 * @param filename file with the host specification
115 * @param hosts set to the hosts found in the file
116 * @return number of hosts returned in 'hosts', 0 on error
119 GNUNET_TESTBED_hosts_load_from_file (const char *filename,
120 struct GNUNET_TESTBED_Host **hosts);
124 * Destroy a host handle. Must only be called once everything
125 * running on that host has been stopped.
127 * @param host handle to destroy
130 GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host);
134 * Enumeration with (at most 64) possible event types that
135 * can be monitored using the testbed framework.
137 enum GNUNET_TESTBED_EventType
140 * A peer has been started.
142 GNUNET_TESTBED_ET_PEER_START = 0,
145 * A peer has been stopped.
147 GNUNET_TESTBED_ET_PEER_STOP = 1,
150 * A connection between two peers was established.
152 GNUNET_TESTBED_ET_CONNECT = 2,
155 * A connection between two peers was torn down.
157 GNUNET_TESTBED_ET_DISCONNECT = 3,
160 * A requested testbed operation has been completed.
162 GNUNET_TESTBED_ET_OPERATION_FINISHED = 4,
165 * The 'GNUNET_TESTBED_run' operation has been completed
167 GNUNET_TESTBED_ET_TESTBED_ONLINE = 5
173 * Types of information that can be requested about a peer.
175 enum GNUNET_TESTBED_PeerInformationType
179 * Special value (not valid for requesting information)
180 * that is used in the event struct if a 'generic' pointer
181 * is returned (for other operations not related to this
184 GNUNET_TESTBED_PIT_GENERIC = 0,
187 * What host is the peer running on? Returns a 'const struct
188 * GNUNET_TESTBED_Host *'. Valid until
189 * 'GNUNET_TESTBED_operation_done' is called.
191 GNUNET_TESTBED_PIT_HOST,
194 * What configuration is the peer using? Returns a 'const struct
195 * GNUNET_CONFIGURATION_Handle *'. Valid until
196 * 'GNUNET_TESTNIG_operation_done' is called. However, the
197 * values may be inaccurate if the peer is reconfigured in
200 GNUNET_TESTBED_PIT_CONFIGURATION,
203 * What is the identity of the peer? Returns a
204 * 'const struct GNUNET_PeerIdentity *'. Valid until
205 * 'GNUNET_TESTNIG_operation_done' is called.
207 GNUNET_TESTBED_PIT_IDENTITY
213 * Argument to GNUNET_TESTBED_ControllerCallback with details about
216 struct GNUNET_TESTBED_EventInformation
222 enum GNUNET_TESTBED_EventType type;
225 * Details about the event.
231 * Details about peer start event.
236 * Handle for the host where the peer
239 struct GNUNET_TESTBED_Host *host;
242 * Handle for the peer that was started.
244 struct GNUNET_TESTBED_Peer *peer;
249 * Details about peer stop event.
255 * Handle for the peer that was started.
257 struct GNUNET_TESTBED_Peer *peer;
262 * Details about connect event.
267 * Handle for one of the connected peers.
269 struct GNUNET_TESTBED_Peer *peer1;
272 * Handle for one of the connected peers.
274 struct GNUNET_TESTBED_Peer *peer2;
279 * Details about disconnect event.
284 * Handle for one of the disconnected peers.
286 struct GNUNET_TESTBED_Peer *peer1;
289 * Handle for one of the disconnected peers.
291 struct GNUNET_TESTBED_Peer *peer2;
296 * Details about an operation finished event.
302 * Handle for the operation that was finished.
304 struct GNUNET_TESTBED_Operation *operation;
307 * Closure that was passed in when the event was
313 * Error message for the operation, NULL on success.
318 * Peer information type; captures which of the types
319 * in the 'op_result' is actually in use.
321 enum GNUNET_TESTBED_PeerInformationType pit;
324 * Pointer to an operation-specific return value; NULL on error;
325 * can be NULL for certain operations. Valid until
326 * 'GNUNET_TESTBED_operation_done' is called.
331 * No result (NULL pointer) or generic result
332 * (whatever the GNUNET_TESTBED_ConnectAdapter returned).
337 * Identity of host running the peer.
339 struct GNUNET_TESTBED_Host *host;
342 * Identity of the peer.
344 const struct GNUNET_PeerIdentity *pid;
347 * Configuration of the peer.
349 const struct GNUNET_CONFIGURATION_Handle *cfg;
353 } operation_finished;
357 * Details about an testbed run completed event.
363 * Error message for the operation, NULL on success.
368 * Array of peers now running (valid until
369 * 'GNUNET_TESTBED_testbed_stop' is called). Note that it is
370 * not allowed to call 'GNUNET_TESTBED_peer_destroy' on peers
373 struct GNUNET_TESTBED_Peer **peers;
376 * Size of the 'peers' array.
378 unsigned int num_peers;
380 } testbed_run_finished;
388 * Signature of the event handler function called by the
389 * respective event controller.
392 * @param event information about the event
394 typedef void (*GNUNET_TESTBED_ControllerCallback)(void *cls,
395 const struct GNUNET_TESTBED_EventInformation *event);
399 * Start a controller process using the given configuration at the
402 * @param cfg configuration to use
403 * @param host host to run the controller on, NULL for 'localhost'
404 * @param event_mask bit mask with set of events to call 'cc' for;
405 * or-ed values of "1LL" shifted by the
406 * respective 'enum GNUNET_TESTBED_EventType'
407 * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
408 * @param cc controller callback to invoke on events
409 * @param cc_cls closure for cc
410 * @return handle to the controller
412 struct GNUNET_TESTBED_Controller *
413 GNUNET_TESTBED_controller_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
414 struct GNUNET_TESTBED_Host *host,
416 GNUNET_TESTBED_ControllerCallback cc,
421 * Configure shared services at a controller. Using this function,
422 * you can specify that certain services (such as "resolver")
423 * should not be run for each peer but instead be shared
424 * across N peers on the specified host. This function
425 * must be called before any peers are created at the host.
427 * @param controller controller to configure
428 * @param service_name name of the service to share
429 * @param num_peers number of peers that should share one instance
430 * of the specified service (1 for no sharing is the default),
431 * use 0 to disable the service
434 GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller *controller,
435 const char *service_name,
440 * Stop the given controller (also will terminate all peers and
441 * controllers dependent on this controller). This function
442 * blocks until the testbed has been fully terminated (!).
444 * @param controller handle to controller to stop
447 GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_Controller *controller);
451 * Opaque handle for host registration
453 struct GNUNET_TESTBED_HostRegistrationHandle;
457 * Callback which will be called to after a host registration succeeded or failed
459 * @param cls the closure
460 * @param emsg the error message; NULL if host registration is successful
462 typedef void (* GNUNET_TESTBED_HostRegistrationCompletion) (void *cls,
467 * Register a host with the controller
469 * @param controller the controller handle
470 * @param host the host to register
471 * @param cc the completion callback to call to inform the status of
472 * registration. After calling this callback the registration handle
473 * will be invalid. Cannot be NULL
474 * @param cc_cls the closure for the cc
475 * @return handle to the host registration which can be used to cancel the
476 * registration; NULL if another registration handle is present and
479 struct GNUNET_TESTBED_HostRegistrationHandle *
480 GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
481 struct GNUNET_TESTBED_Host *host,
482 GNUNET_TESTBED_HostRegistrationCompletion cc,
487 * Cancel the pending registration. Note that the registration message will
488 * already be queued to be sent to the service, cancellation has only the
489 * effect that the registration completion callback for the registration is
490 * never called and from our perspective the host is not registered until the
491 * completion callback is called.
493 * @param handle the registration handle to cancel
496 GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle
501 * Create a link from a 'master' controller to a slave controller.
502 * Whenever the master controller is asked to start a peer at the
503 * given 'delegated_host', it will delegate the request to the
504 * specified slave controller. Note that the slave controller runs at
505 * the 'slave_host', which may or may not be the same host as the
506 * 'delegated_host' (for hierarchical delegations). The configuration
507 * of the slave controller is given and to be used to either create
508 * the slave controller or to connect to an existing slave controller
509 * process. 'is_subordinate' specifies if the given slave controller
510 * should be started and managed by the master controller, or if the
511 * slave already has a master and this is just a secondary master that
512 * is also allowed to use the existing slave.
514 * @param master handle to the master controller who creates the association
515 * @param delegated_host requests to which host should be delegated
516 * @param slave_host which host is used to run the slave controller
517 * @param slave_cfg configuration to use for the slave controller
518 * @param is_subordinate GNUNET_YES if the slave should be started (and stopped)
519 * by the master controller; GNUNET_NO if we are just
520 * allowed to use the slave via TCP/IP
523 GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
524 struct GNUNET_TESTBED_Host *delegated_host,
525 struct GNUNET_TESTBED_Host *slave_host,
526 const struct GNUNET_CONFIGURATION_Handle *slave_cfg,
531 * Create the given peer at the specified host using the given
532 * controller. If the given controller is not running on the target
533 * host, it should find or create a controller at the target host and
534 * delegate creating the peer. Explicit delegation paths can be setup
535 * using 'GNUNET_TESTBED_controller_link'. If no explicit delegation
536 * path exists, a direct link with a subordinate controller is setup
537 * for the first delegated peer to a particular host; the subordinate
538 * controller is then destroyed once the last peer that was delegated
539 * to the remote host is stopped.
541 * Creating the peer only creates the handle to manipulate and further
542 * configure the peer; use "GNUNET_TESTBED_peer_start" and
543 * "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's
546 * Note that the given configuration will be adjusted by the
547 * controller to avoid port/path conflicts with other peers.
548 * The "final" configuration can be obtained using
549 * 'GNUNET_TESTBED_peer_get_information'.
551 * @param controller controller process to use
552 * @param host host to run the peer on
553 * @param cfg configuration to use for the peer
554 * @return handle to the peer (actual startup will happen asynchronously)
556 struct GNUNET_TESTBED_Peer *
557 GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller,
558 struct GNUNET_TESTBED_Host *host,
559 const struct GNUNET_CONFIGURATION_Handle *cfg);
563 * Start the given peer.
565 * @param peer peer to start
566 * @return handle to the operation
568 struct GNUNET_TESTBED_Operation *
569 GNUNET_TESTBED_peer_start (struct GNUNET_TESTBED_Peer *peer);
573 * Stop the given peer. The handle remains valid (use
574 * "GNUNET_TESTBED_peer_destroy" to fully clean up the
575 * state of the peer).
577 * @param peer peer to stop
578 * @return handle to the operation
580 struct GNUNET_TESTBED_Operation *
581 GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer);
585 * Request information about a peer.
587 * @param peer peer to request information about
588 * @param pit desired information
589 * @return handle to the operation
591 struct GNUNET_TESTBED_Operation *
592 GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
593 enum GNUNET_TESTBED_PeerInformationType pit);
597 * Change peer configuration. Must only be called while the
598 * peer is stopped. Ports and paths cannot be changed this
601 * @param peer peer to change configuration for
602 * @param cfg new configuration (differences to existing
603 * configuration only)
604 * @return handle to the operation
606 struct GNUNET_TESTBED_Operation *
607 GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer,
608 const struct GNUNET_CONFIGURATION_Handle *cfg);
612 * Destroy the given peer; the peer should have been
613 * stopped first (if it was started).
615 * @param peer peer to stop
616 * @return handle to the operation
618 struct GNUNET_TESTBED_Operation *
619 GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer);
623 * Options for peer connections.
625 enum GNUNET_TESTBED_ConnectOption
628 * No option (not valid as an argument).
630 GNUNET_TESTBED_CO_NONE = 0,
633 * Allow or disallow a connection between the specified peers.
634 * Followed by GNUNET_NO (int) if a connection is disallowed
635 * or GNUNET_YES if a connection is allowed. Note that the
636 * default (all connections allowed or disallowed) is
637 * specified in the configuration of the controller.
639 GNUNET_TESTBED_CO_ALLOW = 1,
642 * FIXME: add (and implement) options to limit connection to
643 * particular transports, force simulation of particular latencies
644 * or message loss rates, or set bandwidth limitations.
651 * Manipulate the P2P underlay topology by configuring a link
654 * @param op_cls closure argument to give with the operation event
655 * @param p1 first peer
656 * @param p2 second peer
657 * @param co option to change
658 * @param ap option-specific values
659 * @return handle to the operation, NULL if configuring the link at this
660 * time is not allowed
662 struct GNUNET_TESTBED_Operation *
663 GNUNET_TESTBED_underlay_configure_link_va (void *op_cls,
664 struct GNUNET_TESTBED_Peer *p1,
665 struct GNUNET_TESTBED_Peer *p2,
666 enum GNUNET_TESTBED_ConnectOption co,
671 * Manipulate the P2P underlay topology by configuring a link
674 * @param op_cls closure argument to give with the operation event
675 * @param p1 first peer
676 * @param p2 second peer
677 * @param co option to change
678 * @param ... option-specific values
679 * @return handle to the operation, NULL if configuring the link at this
680 * time is not allowed
682 struct GNUNET_TESTBED_Operation *
683 GNUNET_TESTBED_underlay_configure_link (void *op_cls,
684 struct GNUNET_TESTBED_Peer *p1,
685 struct GNUNET_TESTBED_Peer *p2,
686 enum GNUNET_TESTBED_ConnectOption co, ...);
691 * Topologies supported for testbeds.
693 enum GNUNET_TESTBED_TopologyOption
696 * A clique (everyone connected to everyone else). No options.
698 GNUNET_TESTBED_TOPOLOGY_CLIQUE,
701 * Small-world network (2d torus plus random links). Followed
702 * by the number of random links to add (unsigned int).
704 GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD,
707 * Small-world network (ring plus random links). Followed
708 * by the number of random links to add (unsigned int).
710 GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING,
713 * Ring topology. No options.
715 GNUNET_TESTBED_TOPOLOGY_RING,
718 * 2-d torus. No options.
720 GNUNET_TESTBED_TOPOLOGY_2D_TORUS,
723 * Random graph. Followed by the link density, that is the
724 * percentage of links present in relation to a clique
727 GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
730 * Certain percentage of peers are unable to communicate directly
731 * replicating NAT conditions. Followed by the fraction of
732 * NAT'ed peers (float).
734 GNUNET_TESTBED_TOPOLOGY_INTERNAT,
737 * Scale free topology. FIXME: options?
739 GNUNET_TESTBED_TOPOLOGY_SCALE_FREE,
742 * Straight line topology. No options.
744 GNUNET_TESTBED_TOPOLOGY_LINE,
747 * All peers are disconnected. No options.
749 GNUNET_TESTBED_TOPOLOGY_NONE,
752 * Read a topology from a given file. Followed by the name of the file (const char *).
754 GNUNET_TESTBED_TOPOLOGY_FROM_FILE
759 * Configure overall network topology to have a particular shape.
761 * @param op_cls closure argument to give with the operation event
762 * @param num_peers number of peers in 'peers'
763 * @param peers array of 'num_peers' with the peers to configure
764 * @param topo desired underlay topology to use
765 * @param ap topology-specific options
766 * @return handle to the operation, NULL if configuring the topology
767 * is not allowed at this time
769 struct GNUNET_TESTBED_Operation *
770 GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls,
771 unsigned int num_peers,
772 struct GNUNET_TESTBED_Peer **peers,
773 enum GNUNET_TESTBED_TopologyOption topo,
778 * Configure overall network topology to have a particular shape.
780 * @param op_cls closure argument to give with the operation event
781 * @param num_peers number of peers in 'peers'
782 * @param peers array of 'num_peers' with the peers to configure
783 * @param topo desired underlay topology to use
784 * @param ... topology-specific options
785 * @return handle to the operation, NULL if configuring the topology
786 * is not allowed at this time
788 struct GNUNET_TESTBED_Operation *
789 GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
790 unsigned int num_peers,
791 struct GNUNET_TESTBED_Peer **peers,
792 enum GNUNET_TESTBED_TopologyOption topo,
797 * Both peers must have been started before calling this function.
798 * This function then obtains a HELLO from 'p1', gives it to 'p2'
799 * and asks 'p2' to connect to 'p1'.
801 * @param op_cls closure argument to give with the operation event
802 * @param p1 first peer
803 * @param p2 second peer
804 * @return handle to the operation, NULL if connecting these two
805 * peers is fundamentally not possible at this time (peers
806 * not running or underlay disallows)
808 struct GNUNET_TESTBED_Operation *
809 GNUNET_TESTBED_overlay_connect (void *op_cls,
810 struct GNUNET_TESTBED_Peer *p1,
811 struct GNUNET_TESTBED_Peer *p2);
815 * All peers must have been started before calling this function.
816 * This function then connects the given peers in the P2P overlay
817 * using the given topology.
819 * @param op_cls closure argument to give with the operation event
820 * @param num_peers number of peers in 'peers'
821 * @param peers array of 'num_peers' with the peers to configure
822 * @param topo desired underlay topology to use
823 * @param va topology-specific options
824 * @return handle to the operation, NULL if connecting these
825 * peers is fundamentally not possible at this time (peers
826 * not running or underlay disallows)
828 struct GNUNET_TESTBED_Operation *
829 GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
830 unsigned int num_peers,
831 struct GNUNET_TESTBED_Peer *peers,
832 enum GNUNET_TESTBED_TopologyOption topo,
837 * All peers must have been started before calling this function.
838 * This function then connects the given peers in the P2P overlay
839 * using the given topology.
841 * @param op_cls closure argument to give with the operation event
842 * @param num_peers number of peers in 'peers'
843 * @param peers array of 'num_peers' with the peers to configure
844 * @param topo desired underlay topology to use
845 * @param ... topology-specific options
846 * @return handle to the operation, NULL if connecting these
847 * peers is fundamentally not possible at this time (peers
848 * not running or underlay disallows)
850 struct GNUNET_TESTBED_Operation *
851 GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
852 unsigned int num_peers,
853 struct GNUNET_TESTBED_Peer *peers,
854 enum GNUNET_TESTBED_TopologyOption topo,
859 * Ask the testbed controller to write the current overlay topology to
860 * a file. Naturally, the file will only contain a snapshot as the
861 * topology may evolve all the time.
863 * @param controller overlay controller to inspect
864 * @param filename name of the file the topology should
868 GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller,
869 const char *filename);
873 * Adapter function called to establish a connection to
877 * @param cfg configuration of the peer to connect to
878 * @return service handle to return in 'op_result', NULL on error
880 typedef void * (*GNUNET_TESTBED_ConnectAdapter)(void *cls,
881 const struct GNUNET_CONFIGURATION_Handle *cfg);
885 * Adapter function called to destroy a connection to
889 * @param op_result service handle returned from the connect adapter
891 typedef void (*GNUNET_TESTBED_DisconnectAdapter)(void *cls,
896 * Connect to a service offered by the given peer. Will ensure that
897 * the request is queued to not overwhelm our ability to create and
898 * maintain connections with other systems. The actual service
899 * handle is then returned via the 'op_result' member in the event
900 * callback. The 'ca' callback is used to create the connection
901 * when the time is right; the 'da' callback will be used to
902 * destroy the connection (upon 'GNUNET_TESTBED_operation_done').
903 * 'GNUNET_TESTBED_operation_cancel' can be used to abort this
904 * operation until the event callback has been called.
906 * @param op_cls closure to pass in operation event
907 * @param peer peer that runs the service
908 * @param service_name name of the service to connect to
909 * @param ca helper function to establish the connection
910 * @param da helper function to close the connection
911 * @param cada_cls closure for ca and da
912 * @return handle for the operation
914 struct GNUNET_TESTBED_Operation *
915 GNUNET_TESTBED_service_connect (void *op_cls,
916 struct GNUNET_TESTBED_Peer *peer,
917 const char *service_name,
918 GNUNET_TESTBED_ConnectAdapter ca,
919 GNUNET_TESTBED_DisconnectAdapter da,
924 * Cancel a pending operation. Releases all resources
925 * of the operation and will ensure that no event
926 * is generated for the operation. Does NOT guarantee
927 * that the operation will be fully undone (or that
928 * nothing ever happened).
930 * @param operation operation to cancel
933 GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation);
937 * Signal that the information from an operation has been fully
938 * processed. This function MUST be called for each event
939 * of type 'operation_finished' to fully remove the operation
940 * from the operation queue. After calling this function, the
941 * 'op_result' becomes invalid (!).
943 * @param operation operation to signal completion for
946 GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation);
950 * Configure and run a testbed using the given
951 * master controller on 'num_hosts' starting
952 * 'num_peers' using the given peer configuration.
954 * @param controller master controller for the testbed
955 * (must not be destroyed until after the
956 * testbed is destroyed).
957 * @param num_hosts number of hosts in 'hosts', 0 to only
959 * @param hosts list of hosts to use for the testbed
960 * @param num_peers number of peers to start
961 * @param peer_cfg peer configuration template to use
962 * @param underlay_topology underlay topology to create
963 * @param va topology-specific options
964 * @return handle to the testbed
966 struct GNUNET_TESTBED_Testbed *
967 GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller,
968 unsigned int num_hosts,
969 struct GNUNET_TESTBED_Host **hosts,
970 unsigned int num_peers,
971 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
972 enum GNUNET_TESTBED_TopologyOption underlay_topology,
977 * Configure and run a testbed using the given
978 * master controller on 'num_hosts' starting
979 * 'num_peers' using the given peer configuration.
981 * @param controller master controller for the testbed
982 * (must not be destroyed until after the
983 * testbed is destroyed).
984 * @param num_hosts number of hosts in 'hosts', 0 to only
986 * @param hosts list of hosts to use for the testbed
987 * @param num_peers number of peers to start
988 * @param peer_cfg peer configuration template to use
989 * @param underlay_topology underlay topology to create
990 * @param ... topology-specific options
992 struct GNUNET_TESTBED_Testbed *
993 GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller,
994 unsigned int num_hosts,
995 struct GNUNET_TESTBED_Host **hosts,
996 unsigned int num_peers,
997 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
998 enum GNUNET_TESTBED_TopologyOption underlay_topology,
1003 * Destroy a testbed. Stops all running peers and then
1004 * destroys all peers. Does NOT destroy the master controller.
1006 * @param testbed testbed to destroy
1009 GNUNET_TESTBED_destroy (struct GNUNET_TESTBED_Testbed *testbed);
1013 * Convenience method for running a testbed with
1014 * a single call. Underlay and overlay topology
1015 * are configured using the "UNDERLAY" and "OVERLAY"
1016 * options in the "[testbed]" section of the configuration\
1017 * (with possible options given in "UNDERLAY_XXX" and/or
1020 * The testbed is to be terminated using a call to
1021 * "GNUNET_SCHEDULER_shutdown".
1023 * @param host_filename name of the file with the 'hosts', NULL
1024 * to run everything on 'localhost'
1025 * @param cfg configuration to use (for testbed, controller and peers)
1026 * @param num_peers number of peers to start; FIXME: maybe put that ALSO into cfg?
1027 * @param event_mask bit mask with set of events to call 'cc' for;
1028 * or-ed values of "1LL" shifted by the
1029 * respective 'enum GNUNET_TESTBED_EventType'
1030 * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
1031 * @param cc controller callback to invoke on events
1032 * @param cc_cls closure for cc
1033 * @param master task to run once the testbed is ready
1034 * @param master_cls closure for 'task'.
1037 GNUNET_TESTBED_run (const char *host_filename,
1038 const struct GNUNET_CONFIGURATION_Handle *cfg,
1039 unsigned int num_peers,
1040 uint64_t event_mask,
1041 GNUNET_TESTBED_ControllerCallback cc,
1043 GNUNET_SCHEDULER_Task master,
1048 * Signature of a main function for a testcase.
1050 * @param cls closure
1051 * @param num_peers number of peers in 'peers'
1052 * @param peers handle to peers run in the testbed
1054 typedef void (*GNUNET_TESTBED_TestMaster)(void *cls,
1055 unsigned int num_peers,
1056 struct GNUNET_TESTBED_Peer **peers);
1060 * Convenience method for running a "simple" test on the local system
1061 * with a single call from 'main'. Underlay and overlay topology are
1062 * configured using the "UNDERLAY" and "OVERLAY" options in the
1063 * "[testbed]" section of the configuration (with possible options
1064 * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").
1066 * The test is to be terminated using a call to
1067 * "GNUNET_SCHEDULER_shutdown". If starting the test fails,
1068 * the program is stopped without 'master' ever being run.
1070 * NOTE: this function should be called from 'main', NOT from
1071 * within a GNUNET_SCHEDULER-loop. This function will initialze
1072 * the scheduler loop, the testbed and then pass control to
1075 * @param testname name of the testcase (to configure logging, etc.)
1076 * @param cfg_filename configuration filename to use
1077 * (for testbed, controller and peers)
1078 * @param num_peers number of peers to start
1079 * @param test_master task to run once the test is ready
1080 * @param test_master_cls closure for 'task'.
1083 GNUNET_TESTBED_test_run (const char *testname,
1084 const char *cfg_filename,
1085 unsigned int num_peers,
1086 GNUNET_TESTBED_TestMaster test_master,
1087 void *test_master_cls);
1090 #if 0 /* keep Emacsens' auto-indent happy */