Options for 2D Torus
[oweals/gnunet.git] / src / include / gnunet_testbed_service.h
1 /*
2       This file is part of GNUnet
3       (C) 2008, 2009, 2012 Christian Grothoff (and other contributing authors)
4
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.
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       General Public License for more details.
14
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.
19  */
20
21 /**
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
26  */
27
28 #ifndef GNUNET_TESTBED_SERVICE_H
29 #define GNUNET_TESTBED_SERVICE_H
30
31 #include "gnunet_util_lib.h"
32 #include "gnunet_testing_lib-new.h"
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #if 0                           /* keep Emacsens' auto-indent happy */
38 }
39 #endif
40 #endif
41
42
43 /**
44  * Opaque handle to a host running experiments managed by the testbed framework.
45  * The master process must be able to SSH to this host without password (via
46  * ssh-agent).
47  */
48 struct GNUNET_TESTBED_Host;
49
50 /**
51  * Opaque handle to a peer controlled by the testbed framework.  A peer runs
52  * at a particular host.
53  */
54 struct GNUNET_TESTBED_Peer;
55
56 /**
57  * Opaque handle to an abstract operation to be executed by the testbed framework.
58  */
59 struct GNUNET_TESTBED_Operation;
60
61 /**
62  * Handle to interact with a GNUnet testbed controller.  Each
63  * controller has at least one master handle which is created when the
64  * controller is created; this master handle interacts with the
65  * controller process, destroying it destroys the controller (by
66  * closing stdin of the controller process).  Additionally,
67  * controllers can interact with each other (in a P2P fashion); those
68  * links are established via TCP/IP on the controller's service port.
69  */
70 struct GNUNET_TESTBED_Controller;
71
72 /**
73  * Handle to a large-scale testbed that is managed at a high level.
74  */
75 struct GNUNET_TESTBED_Testbed;
76
77
78 /**
79  * Create a host to run peers and controllers on.
80  *
81  * @param hostname name of the host, use "NULL" for localhost
82  * @param username username to use for the login; may be NULL
83  * @param port port number to use for ssh; use 0 to let ssh decide
84  * @return handle to the host, NULL on error
85  */
86 struct GNUNET_TESTBED_Host *
87 GNUNET_TESTBED_host_create (const char *hostname,
88                             const char *username,
89                             uint16_t port);
90
91
92
93 /**
94  * Create a host to run peers and controllers on.  This function is used
95  * if a peer learns about a host via IPC between controllers (and thus
96  * some higher-level controller has already determined the unique IDs).
97  *
98  * @param id global host ID assigned to the host; 0 is
99  *        reserved to always mean 'localhost'
100  * @param hostname name of the host, use "NULL" for localhost
101  * @param username username to use for the login; may be NULL
102  * @param port port number to use for ssh; use 0 to let ssh decide
103  * @return handle to the host, NULL on error
104  */
105 struct GNUNET_TESTBED_Host *
106 GNUNET_TESTBED_host_create_with_id (uint32_t id,
107                                     const char *hostname,
108                                     const char *username,
109                                     uint16_t port);
110
111
112 /**
113  * Load a set of hosts from a configuration file.
114  *
115  * @param filename file with the host specification
116  * @param hosts set to the hosts found in the file; caller must free this if
117  *          number of hosts returned is greater than 0
118  * @return number of hosts returned in 'hosts', 0 on error
119  */
120 unsigned int
121 GNUNET_TESTBED_hosts_load_from_file (const char *filename,
122                                      struct GNUNET_TESTBED_Host ***hosts);
123
124
125 /**
126  * Destroy a host handle.  Must only be called once everything
127  * running on that host has been stopped.
128  *
129  * @param host handle to destroy
130  */
131 void
132 GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host);
133
134
135 /**
136  * Checks whether a host can be used to start testbed service
137  *
138  * @param host the host to check
139  * @param config the configuration handle to lookup the path of the testbed helper
140  * @return GNUNET_YES if testbed service can be started on the given host
141  *           remotely; GNUNET_NO if not
142  */
143 int
144 GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
145                                   const struct GNUNET_CONFIGURATION_Handle *config);
146
147
148 /**
149  * Obtain the host's hostname.
150  *
151  * @param host handle to the host, NULL means 'localhost'
152  * @return hostname of the host
153  */
154 const char *
155 GNUNET_TESTBED_host_get_hostname (const struct GNUNET_TESTBED_Host *host);
156
157
158 /**
159  * Enumeration with (at most 64) possible event types that
160  * can be monitored using the testbed framework.
161  */
162 enum GNUNET_TESTBED_EventType
163 {
164   /**
165    * A peer has been started.
166    */
167   GNUNET_TESTBED_ET_PEER_START = 0,
168
169   /**
170    * A peer has been stopped.
171    */
172   GNUNET_TESTBED_ET_PEER_STOP = 1,
173
174   /**
175    * A connection between two peers was established.
176    */
177   GNUNET_TESTBED_ET_CONNECT = 2,
178
179   /**
180    * A connection between two peers was torn down.
181    */
182   GNUNET_TESTBED_ET_DISCONNECT = 3,
183
184   /**
185    * A requested testbed operation has been completed.
186    */
187   GNUNET_TESTBED_ET_OPERATION_FINISHED = 4,
188
189   /**
190    * The 'GNUNET_TESTBED_run' operation has been completed
191    */
192   GNUNET_TESTBED_ET_TESTBED_ONLINE = 5
193
194 };
195
196
197 /**
198  * Types of information that can be requested about a peer.
199  */
200 enum GNUNET_TESTBED_PeerInformationType
201 {
202
203   /**
204    * Special value (not valid for requesting information)
205    * that is used in the event struct if a 'generic' pointer
206    * is returned (for other operations not related to this
207    * enumeration).
208    */
209   GNUNET_TESTBED_PIT_GENERIC = 0,
210
211   /**
212    * What configuration is the peer using?  Returns a 'const struct
213    * GNUNET_CONFIGURATION_Handle *'.  Valid until
214    * 'GNUNET_TESTNIG_operation_done' is called.  However, the
215    * values may be inaccurate if the peer is reconfigured in
216    * the meantime.
217    */
218   GNUNET_TESTBED_PIT_CONFIGURATION,
219
220   /**
221    * What is the identity of the peer?  Returns a
222    * 'const struct GNUNET_PeerIdentity *'.  Valid until
223    * 'GNUNET_TESTNIG_operation_done' is called.
224    */
225   GNUNET_TESTBED_PIT_IDENTITY
226
227 };
228
229
230 /**
231  * Argument to GNUNET_TESTBED_ControllerCallback with details about
232  * the event.
233  */
234 struct GNUNET_TESTBED_EventInformation
235 {
236
237   /**
238    * Type of the event.
239    */
240   enum GNUNET_TESTBED_EventType type;
241
242   /**
243    * Details about the event.
244    */
245   union
246   {
247
248     /**
249      * Details about peer start event.
250      */
251     struct
252     {
253       /**
254        * Handle for the host where the peer
255        * was started.
256        */
257       struct GNUNET_TESTBED_Host *host;
258
259       /**
260        * Handle for the peer that was started.
261        */
262       struct GNUNET_TESTBED_Peer *peer;
263
264     } peer_start;
265
266     /**
267      * Details about peer stop event.
268      */
269     struct
270     {
271
272       /**
273        * Handle for the peer that was started.
274        */
275       struct GNUNET_TESTBED_Peer *peer;
276
277     } peer_stop;
278
279     /**
280      * Details about connect event.
281      */
282     struct
283     {
284       /**
285        * Handle for one of the connected peers.
286        */
287       struct GNUNET_TESTBED_Peer *peer1;
288
289       /**
290        * Handle for one of the connected peers.
291        */
292       struct GNUNET_TESTBED_Peer *peer2;
293
294     } peer_connect;
295
296     /**
297      * Details about disconnect event.
298      */
299     struct
300     {
301       /**
302        * Handle for one of the disconnected peers.
303        */
304       struct GNUNET_TESTBED_Peer *peer1;
305
306       /**
307        * Handle for one of the disconnected peers.
308        */
309       struct GNUNET_TESTBED_Peer *peer2;
310
311     } peer_disconnect;
312
313     /**
314      * Details about an operation finished event.
315      */
316     struct
317     {
318
319       /**
320        * Handle for the operation that was finished.
321        */
322       struct GNUNET_TESTBED_Operation *operation;
323
324       /**
325        * Closure that was passed in when the event was
326        * requested.
327        */
328       void *op_cls;
329
330       /**
331        * Error message for the operation, NULL on success.
332        */
333       const char *emsg;
334
335       /**
336        * No result (NULL pointer) or generic result
337        * (whatever the GNUNET_TESTBED_ConnectAdapter returned).
338        */
339       void *generic;
340
341     } operation_finished;
342
343     /**
344      * Details about an testbed run completed event.
345      */
346     struct
347     {
348
349       /**
350        * Error message for the operation, NULL on success.
351        */
352       const char *emsg;
353
354       /**
355        * Array of peers now running (valid until
356        * 'GNUNET_TESTBED_testbed_stop' is called).  Note that it is
357        * not allowed to call 'GNUNET_TESTBED_peer_destroy' on peers
358        * from this array.
359        */
360       struct GNUNET_TESTBED_Peer **peers;
361
362       /**
363        * Size of the 'peers' array.
364        */
365       unsigned int num_peers;
366
367     } testbed_run_finished;
368
369   } details;
370
371 };
372
373
374 /**
375  * Signature of the event handler function called by the
376  * respective event controller.
377  *
378  * @param cls closure
379  * @param event information about the event
380  */
381 typedef void (*GNUNET_TESTBED_ControllerCallback)(void *cls,
382                                                   const struct GNUNET_TESTBED_EventInformation *event);
383
384
385 /**
386  * Opaque Handle for Controller process
387  */
388 struct GNUNET_TESTBED_ControllerProc;
389
390
391 /**
392  * Callback to signal successfull startup of the controller process
393  *
394  * @param cls the closure from GNUNET_TESTBED_controller_start()
395  * @param cfg the configuration with which the controller has been started;
396  *          NULL if status is not GNUNET_OK
397  * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not,
398  *          GNUNET_TESTBED_controller_stop() shouldn't be called in this case
399  */
400 typedef void (*GNUNET_TESTBED_ControllerStatusCallback) (void *cls,
401                                                         const struct GNUNET_CONFIGURATION_Handle *cfg,
402                                                         int status);
403
404
405 /**
406  * Starts a controller process at the host.
407  *
408  * @param controller_ip the ip address of the controller. Will be set as TRUSTED
409  *          host when starting testbed controller at host
410  * @param host the host where the controller has to be started; NULL for
411  *          localhost
412  * @param cfg template configuration to use for the remote controller; the
413  *          remote controller will be started with a slightly modified
414  *          configuration (port numbers, unix domain sockets and service home
415  *          values are changed as per TESTING library on the remote host)
416  * @param cb function called when the controller is successfully started or
417  *          dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be
418  *          called if cb is called with GNUNET_SYSERR as status. Will never be
419  *          called in the same task as 'GNUNET_TESTBED_controller_start'
420  *          (synchronous errors will be signalled by returning NULL). This
421  *          parameter cannot be NULL.
422  * @param cls closure for above callbacks
423  * @return the controller process handle, NULL on errors
424  */
425 struct GNUNET_TESTBED_ControllerProc *
426 GNUNET_TESTBED_controller_start (const char *controller_ip,
427                                  struct GNUNET_TESTBED_Host *host,
428                                  const struct GNUNET_CONFIGURATION_Handle *cfg,
429                                  GNUNET_TESTBED_ControllerStatusCallback cb,
430                                  void *cls);
431
432
433 /**
434  * Stop the controller process (also will terminate all peers and controllers
435  * dependent on this controller).  This function blocks until the testbed has
436  * been fully terminated (!). The controller status cb from
437  * GNUNET_TESTBED_controller_start() will not be called.
438  *
439  * @param cproc the controller process handle
440  */
441 void
442 GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cproc);
443
444
445 /**
446  * Connect to a controller process using the given configuration at the
447  * given host.
448  *
449  * @param cfg configuration to use
450  * @param host host to run the controller on; This should be the same host if
451  *          the controller was previously started with
452  *          GNUNET_TESTBED_controller_start; NULL for localhost
453  * @param host host where this controller is being run;
454  * @param event_mask bit mask with set of events to call 'cc' for;
455  *                   or-ed values of "1LL" shifted by the
456  *                   respective 'enum GNUNET_TESTBED_EventType'
457  *                   (i.e.  "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
458  * @param cc controller callback to invoke on events
459  * @param cc_cls closure for cc
460  * @return handle to the controller
461  */
462 struct GNUNET_TESTBED_Controller *
463 GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
464                                    struct GNUNET_TESTBED_Host *host,
465                                    uint64_t event_mask,
466                                    GNUNET_TESTBED_ControllerCallback cc,
467                                    void *cc_cls);
468
469
470 /**
471  * Configure shared services at a controller.  Using this function,
472  * you can specify that certain services (such as "resolver")
473  * should not be run for each peer but instead be shared
474  * across N peers on the specified host.  This function
475  * must be called before any peers are created at the host.
476  *
477  * @param controller controller to configure
478  * @param service_name name of the service to share
479  * @param num_peers number of peers that should share one instance
480  *        of the specified service (1 for no sharing is the default),
481  *        use 0 to disable the service
482  */
483 void
484 GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller *controller,
485                                              const char *service_name,
486                                              uint32_t num_peers);
487
488
489 /**
490  * Stop the given controller (also will terminate all peers and
491  * controllers dependent on this controller).  This function
492  * blocks until the testbed has been fully terminated (!).
493  *
494  * @param controller handle to controller to stop
495  */
496 void
497 GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *controller);
498
499
500 /**
501  * Opaque handle for host registration
502  */
503 struct GNUNET_TESTBED_HostRegistrationHandle;
504
505
506 /**
507  * Callback which will be called to after a host registration succeeded or failed
508  *
509  * @param cls the closure
510  * @param emsg the error message; NULL if host registration is successful
511  */
512 typedef void (* GNUNET_TESTBED_HostRegistrationCompletion) (void *cls,
513                                                             const char *emsg);
514
515
516 /**
517  * Register a host with the controller
518  *
519  * @param controller the controller handle
520  * @param host the host to register
521  * @param cc the completion callback to call to inform the status of
522  *          registration. After calling this callback the registration handle
523  *          will be invalid. Cannot be NULL
524  * @param cc_cls the closure for the cc
525  * @return handle to the host registration which can be used to cancel the
526  *           registration; NULL if another registration handle is present and
527  *           is not cancelled
528  */
529 struct GNUNET_TESTBED_HostRegistrationHandle *
530 GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
531                               struct GNUNET_TESTBED_Host *host,
532                               GNUNET_TESTBED_HostRegistrationCompletion cc,
533                               void *cc_cls);
534
535
536 /**
537  * Cancel the pending registration. Note that the registration message will
538  * already be queued to be sent to the service, cancellation has only the
539  * effect that the registration completion callback for the registration is
540  * never called and from our perspective the host is not registered until the
541  * completion callback is called.
542  *
543  * @param handle the registration handle to cancel
544  */
545 void
546 GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle
547                                     *handle);
548
549
550 /**
551  * Callback to be called when an operation is completed
552  *
553  * @param cls the callback closure from functions generating an operation
554  * @param op the operation that has been finished
555  * @param emsg error message in case the operation has failed; will be NULL if
556  *          operation has executed successfully.
557  */
558 typedef void (*GNUNET_TESTBED_OperationCompletionCallback) (void *cls,
559                                                             struct
560                                                             GNUNET_TESTBED_Operation
561                                                             *op,
562                                                             const char *emsg);
563
564
565 /**
566  * Create a link from slave controller to delegated controller. Whenever the
567  * master controller is asked to start a peer at the delegated controller the
568  * request will be routed towards slave controller (if a route exists). The
569  * slave controller will then route it to the delegated controller. The
570  * configuration of the delegated controller is given and is used to either
571  * create the delegated controller or to connect to an existing controller. Note
572  * that while starting the delegated controller the configuration will be
573  * modified to accommodate available free ports.  the 'is_subordinate' specifies
574  * if the given delegated controller should be started and managed by the slave
575  * controller, or if the delegated controller already has a master and the slave
576  * controller connects to it as a non master controller. The success or failure
577  * of this operation will be signalled through the
578  * GNUNET_TESTBED_ControllerCallback() with an event of type
579  * GNUNET_TESTBED_ET_OPERATION_FINISHED
580  *
581  * @param op_cls the operation closure for the event which is generated to
582  *          signal success or failure of this operation
583  * @param master handle to the master controller who creates the association
584  * @param delegated_host requests to which host should be delegated; cannot be NULL
585  * @param slave_host which host is used to run the slave controller; use NULL to
586  *          make the master controller connect to the delegated host
587  * @param slave_cfg configuration to use for the slave controller
588  * @param is_subordinate GNUNET_YES if the controller at delegated_host should
589  *          be started by the slave controller; GNUNET_NO if the slave
590  *          controller has to connect to the already started delegated
591  *          controller via TCP/IP
592  * @return the operation handle
593  */
594 struct GNUNET_TESTBED_Operation *
595 GNUNET_TESTBED_controller_link (void *op_cls,
596                                 struct GNUNET_TESTBED_Controller *master,
597                                 struct GNUNET_TESTBED_Host *delegated_host,
598                                 struct GNUNET_TESTBED_Host *slave_host,
599                                 const struct GNUNET_CONFIGURATION_Handle
600                                 *slave_cfg,
601                                 int is_subordinate);
602
603
604 /**
605  * Same as the GNUNET_TESTBED_controller_link, however expects configuration in
606  * serialized and compressed
607  *
608  * @param op_cls the operation closure for the event which is generated to
609  *          signal success or failure of this operation
610  * @param master handle to the master controller who creates the association
611  * @param delegated_host requests to which host should be delegated; cannot be NULL
612  * @param slave_host which host is used to run the slave controller; use NULL to
613  *          make the master controller connect to the delegated host
614  * @param sxcfg serialized and compressed configuration
615  * @param sxcfg_size the size sxcfg
616  * @param scfg_size the size of uncompressed serialized configuration
617  * @param is_subordinate GNUNET_YES if the controller at delegated_host should
618  *          be started by the slave controller; GNUNET_NO if the slave
619  *          controller has to connect to the already started delegated
620  *          controller via TCP/IP
621  * @return the operation handle
622  */
623 struct GNUNET_TESTBED_Operation *
624 GNUNET_TESTBED_controller_link_2 (void *op_cls,
625                                   struct GNUNET_TESTBED_Controller *master,
626                                   struct GNUNET_TESTBED_Host *delegated_host,
627                                   struct GNUNET_TESTBED_Host *slave_host,
628                                   const char *sxcfg,
629                                   size_t sxcfg_size,
630                                   size_t scfg_size,
631                                   int is_subordinate);
632
633
634 /**
635  * Function to acquire the configuration of a running slave controller. The
636  * completion of the operation is signalled through the controller_cb from
637  * GNUNET_TESTBED_controller_connect(). If the operation is successful the
638  * handle to the configuration is available in the generic pointer of
639  * operation_finished field of struct GNUNET_TESTBED_EventInformation.
640  *
641  * @param op_cls the closure for the operation
642  * @param master the handle to master controller
643  * @param slave_host the host where the slave controller is running; the handle
644  *          to the slave_host should remain valid until this operation is
645  *          cancelled or marked as finished
646  * @return the operation handle; NULL if the slave_host is not registered at
647  *           master
648  */
649 struct GNUNET_TESTBED_Operation *
650 GNUNET_TESTBED_get_slave_config (void *op_cls,
651                                  struct GNUNET_TESTBED_Controller *master,
652                                  struct GNUNET_TESTBED_Host *slave_host);
653
654
655 /**
656  * Functions of this signature are called when a peer has been successfully
657  * created
658  *
659  * @param cls the closure from GNUNET_TESTBED_peer_create()
660  * @param peer the handle for the created peer; NULL on any error during
661  *          creation
662  * @param emsg NULL if peer is not NULL; else MAY contain the error description
663  */
664 typedef void (*GNUNET_TESTBED_PeerCreateCallback) (void *cls,
665                                                    struct GNUNET_TESTBED_Peer *peer,
666                                                    const char *emsg);
667
668
669 /**
670  * Create the given peer at the specified host using the given
671  * controller.  If the given controller is not running on the target
672  * host, it should find or create a controller at the target host and
673  * delegate creating the peer.  Explicit delegation paths can be setup
674  * using 'GNUNET_TESTBED_controller_link'.  If no explicit delegation
675  * path exists, a direct link with a subordinate controller is setup
676  * for the first delegated peer to a particular host; the subordinate
677  * controller is then destroyed once the last peer that was delegated
678  * to the remote host is stopped.
679  *
680  * Creating the peer only creates the handle to manipulate and further
681  * configure the peer; use "GNUNET_TESTBED_peer_start" and
682  * "GNUNET_TESTBED_peer_stop" to actually start/stop the peer's
683  * processes.
684  *
685  * Note that the given configuration will be adjusted by the
686  * controller to avoid port/path conflicts with other peers.
687  * The "final" configuration can be obtained using
688  * 'GNUNET_TESTBED_peer_get_information'.
689  *
690  * @param controller controller process to use
691  * @param host host to run the peer on
692  * @param cfg Template configuration to use for the peer. Should exist until
693  *          operation is cancelled or GNUNET_TESTBED_operation_done() is called
694  * @param cb the callback to call when the peer has been created
695  * @param cls the closure to the above callback
696  * @return the operation handle
697  */
698 struct GNUNET_TESTBED_Operation *
699 GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller,
700                             struct GNUNET_TESTBED_Host *host,
701                             const struct GNUNET_CONFIGURATION_Handle *cfg,
702                             GNUNET_TESTBED_PeerCreateCallback cb,
703                             void *cls);
704
705
706 /**
707  * Functions of this signature are called when a peer has been successfully
708  * started or stopped.
709  *
710  * @param cls the closure from GNUNET_TESTBED_peer_start/stop()
711  * @param emsg NULL on success; otherwise an error description
712  */
713 typedef void (*GNUNET_TESTBED_PeerChurnCallback) (void *cls,
714                                                   const char *emsg);
715
716
717 /**
718  * Start the given peer.
719  *
720  * @param op_cls the closure for this operation; will be set in
721  *          event->details.operation_finished.op_cls when this operation fails.
722  * @param peer peer to start
723  * @param pcc function to call upon completion
724  * @param pcc_cls closure for 'pcc'
725  * @return handle to the operation
726  */
727 struct GNUNET_TESTBED_Operation *
728 GNUNET_TESTBED_peer_start (void *op_cls,
729                            struct GNUNET_TESTBED_Peer *peer,
730                            GNUNET_TESTBED_PeerChurnCallback pcc,
731                            void *pcc_cls);
732
733
734 /**
735  * Stop the given peer.  The handle remains valid (use
736  * "GNUNET_TESTBED_peer_destroy" to fully clean up the
737  * state of the peer).
738  *
739  * @param peer peer to stop
740  * @param pcc function to call upon completion
741  * @param pcc_cls closure for 'pcc'
742  * @return handle to the operation
743  */
744 struct GNUNET_TESTBED_Operation *
745 GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer,
746                           GNUNET_TESTBED_PeerChurnCallback pcc,
747                           void *pcc_cls);
748
749
750 /**
751  * Data returned from GNUNET_TESTBED_peer_get_information
752  */
753 struct GNUNET_TESTBED_PeerInformation
754 {
755   /**
756    * Peer information type; captures which of the types
757    * in the 'op_result' is actually in use.
758    */
759   enum GNUNET_TESTBED_PeerInformationType pit;
760
761   /**
762    * The result of the get information operation; Choose according to the pit
763    */
764   union
765   {
766     /**
767      * The configuration of the peer
768      */
769     struct GNUNET_CONFIGURATION_Handle *cfg;
770
771     /**
772      * The identity of the peer
773      */
774     struct GNUNET_PeerIdentity *id;
775   } result;
776 };
777
778
779 /**
780  * Callback to be called when the requested peer information is available
781  *
782  * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information()
783  * @param op the operation this callback corresponds to
784  * @param pinfo the result; will be NULL if the operation has failed
785  * @param emsg error message if the operation has failed; will be NULL if the
786  *          operation is successfull
787  */
788 typedef void (*GNUNET_TESTBED_PeerInfoCallback) (void *cb_cls,
789                                                  struct GNUNET_TESTBED_Operation
790                                                  *op,
791                                                  const struct
792                                                  GNUNET_TESTBED_PeerInformation
793                                                  *pinfo,
794                                                  const char *emsg);
795
796
797 /**
798  * Request information about a peer. The controller callback will not be called
799  * with event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this
800  * operation is available. Instead, the GNUNET_TESTBED_PeerInfoCallback() will
801  * be called.
802  *
803  * @param peer peer to request information about
804  * @param pit desired information
805  * @param cb the convenience callback to be called when results for this
806  *          operation are available
807  * @param cb_cls the closure for the above callback
808  * @return handle to the operation
809  */
810 struct GNUNET_TESTBED_Operation *
811 GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
812                                      enum GNUNET_TESTBED_PeerInformationType
813                                      pit,
814                                      GNUNET_TESTBED_PeerInfoCallback cb,
815                                      void *cb_cls);
816
817
818 /**
819  * Change peer configuration.  Must only be called while the
820  * peer is stopped.  Ports and paths cannot be changed this
821  * way.
822  *
823  * @param peer peer to change configuration for
824  * @param cfg new configuration (differences to existing
825  *            configuration only)
826  * @return handle to the operation
827  */
828 struct GNUNET_TESTBED_Operation *
829 GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer,
830                                           const struct GNUNET_CONFIGURATION_Handle *cfg);
831
832
833 /**
834  * Destroy the given peer; the peer should have been
835  * stopped first (if it was started).
836  *
837  * @param peer peer to stop
838  * @return handle to the operation
839  */
840 struct GNUNET_TESTBED_Operation *
841 GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer);
842
843
844 /**
845  * Options for peer connections.
846  */
847 enum GNUNET_TESTBED_ConnectOption
848 {
849   /**
850    * No option (not valid as an argument).
851    */
852   GNUNET_TESTBED_CO_NONE = 0,
853
854   /**
855    * Allow or disallow a connection between the specified peers.
856    * Followed by GNUNET_NO (int) if a connection is disallowed
857    * or GNUNET_YES if a connection is allowed.  Note that the
858    * default (all connections allowed or disallowed) is
859    * specified in the configuration of the controller.
860    */
861   GNUNET_TESTBED_CO_ALLOW = 1,
862
863   /**
864    * FIXME: add (and implement) options to limit connection to
865    * particular transports, force simulation of particular latencies
866    * or message loss rates, or set bandwidth limitations.
867    */
868
869 };
870
871
872 /**
873  * Manipulate the P2P underlay topology by configuring a link
874  * between two peers.
875  *
876  * @param op_cls closure argument to give with the operation event
877  * @param p1 first peer
878  * @param p2 second peer
879  * @param co option to change
880  * @param ap option-specific values
881  * @return handle to the operation, NULL if configuring the link at this
882  *         time is not allowed
883  */
884 struct GNUNET_TESTBED_Operation *
885 GNUNET_TESTBED_underlay_configure_link_va (void *op_cls,
886                                            struct GNUNET_TESTBED_Peer *p1,
887                                            struct GNUNET_TESTBED_Peer *p2,
888                                            enum GNUNET_TESTBED_ConnectOption co,
889                                            va_list ap);
890
891
892 /**
893  * Manipulate the P2P underlay topology by configuring a link
894  * between two peers.
895  *
896  * @param op_cls closure argument to give with the operation event
897  * @param p1 first peer
898  * @param p2 second peer
899  * @param co option to change
900  * @param ... option-specific values
901  * @return handle to the operation, NULL if configuring the link at this
902  *         time is not allowed
903  */
904 struct GNUNET_TESTBED_Operation *
905 GNUNET_TESTBED_underlay_configure_link (void *op_cls,
906                                         struct GNUNET_TESTBED_Peer *p1,
907                                         struct GNUNET_TESTBED_Peer *p2,
908                                         enum GNUNET_TESTBED_ConnectOption co, ...);
909
910
911
912 /**
913  * Topologies and topology options supported for testbeds. Options should always
914  * end with GNUNET_TESTBED_TOPOLOGY_OPTION_END
915  */
916 enum GNUNET_TESTBED_TopologyOption
917 {
918   /**
919    * A clique (everyone connected to everyone else).  No options. If there are N
920    * peers this topology results in (N * (N -1)) connections.
921    */
922   GNUNET_TESTBED_TOPOLOGY_CLIQUE,
923
924   /**
925    * Small-world network (2d torus plus random links).  Followed
926    * by the number of random links to add (unsigned int).
927    */
928   GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD,
929
930   /**
931    * Small-world network (ring plus random links).  Followed
932    * by the number of random links to add (unsigned int).
933    */
934   GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING,
935
936   /**
937    * Ring topology.  No options.
938    */
939   GNUNET_TESTBED_TOPOLOGY_RING,
940
941   /**
942    * 2-d torus.  Followed by the number `x' (unsigned int) of peers along the
943    * poloidal and the number `y' (unsigned int) of peers along the toroidal. The
944    * total number of peers must be equal to `(x * y)'
945    */
946   GNUNET_TESTBED_TOPOLOGY_2D_TORUS,
947
948   /**
949    * Random graph.  Followed by the number of random links to be established
950    * (unsigned int)
951    */
952   GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
953
954   /**
955    * Certain percentage of peers are unable to communicate directly
956    * replicating NAT conditions.  Followed by the fraction of
957    * NAT'ed peers (float).
958    */
959   GNUNET_TESTBED_TOPOLOGY_INTERNAT,
960
961   /**
962    * Scale free topology.   FIXME: options?
963    */
964   GNUNET_TESTBED_TOPOLOGY_SCALE_FREE,
965
966   /**
967    * Straight line topology.  No options.
968    */
969   GNUNET_TESTBED_TOPOLOGY_LINE,
970
971   /**
972    * Read a topology from a given file.  Followed by the name of the file (const char *).
973    */
974   GNUNET_TESTBED_TOPOLOGY_FROM_FILE,
975
976   /**
977    * All peers are disconnected.  No options.
978    */
979   GNUNET_TESTBED_TOPOLOGY_NONE,
980
981   /**
982    * The options should always end with this
983    */
984   GNUNET_TESTBED_TOPOLOGY_OPTION_END,
985
986   /* The following are not topologies but influence how the topology has to be
987      setup. These options should follow the topology specific options (if
988      required by the chosen topology). Note that these should be given before
989      GNUNET_TESTBED_TOPOLOGY_OPTION_END */
990
991   /**
992    * Disable automatic retrying for failed overlay connections. The default is
993    * to always retry failed overlay connections. This parameter takes no options.
994    */
995   GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY
996 };
997
998
999 /**
1000  * Configure overall network topology to have a particular shape.
1001  *
1002  * @param op_cls closure argument to give with the operation event
1003  * @param num_peers number of peers in 'peers'
1004  * @param peers array of 'num_peers' with the peers to configure
1005  * @param topo desired underlay topology to use
1006  * @param ap topology-specific options
1007  * @return handle to the operation, NULL if configuring the topology
1008  *         is not allowed at this time
1009  */
1010 struct GNUNET_TESTBED_Operation *
1011 GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls,
1012                                                unsigned int num_peers,
1013                                                struct GNUNET_TESTBED_Peer **peers,
1014                                                enum GNUNET_TESTBED_TopologyOption topo,
1015                                                va_list ap);
1016
1017
1018 /**
1019  * Configure overall network topology to have a particular shape.
1020  *
1021  * @param op_cls closure argument to give with the operation event
1022  * @param num_peers number of peers in 'peers'
1023  * @param peers array of 'num_peers' with the peers to configure
1024  * @param topo desired underlay topology to use
1025  * @param ... topology-specific options
1026  * @return handle to the operation, NULL if configuring the topology
1027  *         is not allowed at this time
1028  */
1029 struct GNUNET_TESTBED_Operation *
1030 GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
1031                                             unsigned int num_peers,
1032                                             struct GNUNET_TESTBED_Peer **peers,
1033                                             enum GNUNET_TESTBED_TopologyOption topo,
1034                                             ...);
1035
1036
1037 /**
1038  * Both peers must have been started before calling this function.
1039  * This function then obtains a HELLO from 'p1', gives it to 'p2'
1040  * and asks 'p2' to connect to 'p1'.
1041  *
1042  * @param op_cls closure argument to give with the operation event
1043  * @param cb the callback to call when this operation has finished
1044  * @param cb_cls the closure for the above callback
1045  * @param p1 first peer
1046  * @param p2 second peer
1047  * @return handle to the operation, NULL if connecting these two
1048  *         peers is fundamentally not possible at this time (peers
1049  *         not running or underlay disallows)
1050  */
1051 struct GNUNET_TESTBED_Operation *
1052 GNUNET_TESTBED_overlay_connect (void *op_cls,
1053                                 GNUNET_TESTBED_OperationCompletionCallback cb,
1054                                 void *cb_cls,
1055                                 struct GNUNET_TESTBED_Peer *p1,
1056                                 struct GNUNET_TESTBED_Peer *p2);
1057
1058
1059 /**
1060  * All peers must have been started before calling this function.
1061  * This function then connects the given peers in the P2P overlay
1062  * using the given topology.
1063  *
1064  * @param op_cls closure argument to give with the operation event
1065  * @param num_peers number of peers in 'peers'
1066  * @param peers array of 'num_peers' with the peers to configure
1067  * @param topo desired underlay topology to use
1068  * @param va topology-specific options
1069  * @return handle to the operation, NULL if connecting these
1070  *         peers is fundamentally not possible at this time (peers
1071  *         not running or underlay disallows) or if num_peers is less than 2
1072  */
1073 struct GNUNET_TESTBED_Operation *
1074 GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
1075                                               unsigned int num_peers,
1076                                               struct GNUNET_TESTBED_Peer **peers,
1077                                               enum GNUNET_TESTBED_TopologyOption topo,
1078                                               va_list va);
1079
1080
1081 /**
1082  * All peers must have been started before calling this function.
1083  * This function then connects the given peers in the P2P overlay
1084  * using the given topology.
1085  *
1086  * @param op_cls closure argument to give with the operation event
1087  * @param num_peers number of peers in 'peers'
1088  * @param peers array of 'num_peers' with the peers to configure
1089  * @param topo desired underlay topology to use
1090  * @param ... topology-specific options
1091  * @return handle to the operation, NULL if connecting these
1092  *         peers is fundamentally not possible at this time (peers
1093  *         not running or underlay disallows) or if num_peers is less than 2
1094  */
1095 struct GNUNET_TESTBED_Operation *
1096 GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
1097                                            unsigned int num_peers,
1098                                            struct GNUNET_TESTBED_Peer **peers,
1099                                            enum GNUNET_TESTBED_TopologyOption topo,
1100                                            ...);
1101
1102
1103 /**
1104  * Ask the testbed controller to write the current overlay topology to
1105  * a file.  Naturally, the file will only contain a snapshot as the
1106  * topology may evolve all the time.
1107  * FIXME: needs continuation!?
1108  *
1109  * @param controller overlay controller to inspect
1110  * @param filename name of the file the topology should
1111  *        be written to.
1112  */
1113 void
1114 GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller,
1115                                                const char *filename);
1116
1117
1118 /**
1119  * Adapter function called to establish a connection to
1120  * a service.
1121  *
1122  * @param cls closure
1123  * @param cfg configuration of the peer to connect to; will be available until
1124  *          GNUNET_TESTBED_operation_done() is called on the operation returned
1125  *          from GNUNET_TESTBED_service_connect()
1126  * @return service handle to return in 'op_result', NULL on error
1127  */
1128 typedef void * (*GNUNET_TESTBED_ConnectAdapter)(void *cls,
1129                                                 const struct GNUNET_CONFIGURATION_Handle *cfg);
1130
1131
1132 /**
1133  * Adapter function called to destroy a connection to
1134  * a service.
1135  *
1136  * @param cls closure
1137  * @param op_result service handle returned from the connect adapter
1138  */
1139 typedef void (*GNUNET_TESTBED_DisconnectAdapter)(void *cls,
1140                                                  void *op_result);
1141
1142
1143 /**
1144  * Callback to be called when a service connect operation is completed
1145  *
1146  * @param cls the callback closure from functions generating an operation
1147  * @param op the operation that has been finished
1148  * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
1149  * @param emsg error message in case the operation has failed; will be NULL if
1150  *          operation has executed successfully.
1151  */
1152 typedef void (*GNUNET_TESTBED_ServiceConnectCompletionCallback) (void *cls,
1153                                                                  struct
1154                                                                  GNUNET_TESTBED_Operation
1155                                                                  *op,
1156                                                                  void
1157                                                                  *ca_result,
1158                                                                  const char
1159                                                                  *emsg );
1160
1161
1162 /**
1163  * Connect to a service offered by the given peer.  Will ensure that
1164  * the request is queued to not overwhelm our ability to create and
1165  * maintain connections with other systems.  The actual service
1166  * handle is then returned via the 'op_result' member in the event
1167  * callback.  The 'ca' callback is used to create the connection
1168  * when the time is right; the 'da' callback will be used to
1169  * destroy the connection (upon 'GNUNET_TESTBED_operation_done').
1170  * 'GNUNET_TESTBED_operation_cancel' can be used to abort this
1171  * operation until the event callback has been called.
1172  *
1173  * @param op_cls closure to pass in operation event
1174  * @param peer peer that runs the service
1175  * @param service_name name of the service to connect to
1176  * @param cb the callback to call when this operation finishes
1177  * @param cb_cls closure for the above callback
1178  * @param ca helper function to establish the connection
1179  * @param da helper function to close the connection
1180  * @param cada_cls closure for ca and da
1181  * @return handle for the operation
1182  */
1183 struct GNUNET_TESTBED_Operation *
1184 GNUNET_TESTBED_service_connect (void *op_cls,
1185                                 struct GNUNET_TESTBED_Peer *peer,
1186                                 const char *service_name,
1187                                 GNUNET_TESTBED_ServiceConnectCompletionCallback cb,
1188                                 void *cb_cls,
1189                                 GNUNET_TESTBED_ConnectAdapter ca,
1190                                 GNUNET_TESTBED_DisconnectAdapter da,
1191                                 void *cada_cls);
1192
1193
1194 /**
1195  * This function is used to signal that the event information (struct
1196  * GNUNET_TESTBED_EventInformation) from an operation has been fully processed
1197  * i.e. if the event callback is ever called for this operation. If the event
1198  * callback for this operation has not yet been called, calling this function
1199  * cancels the operation, frees its resources and ensures the no event is
1200  * generated with respect to this operation. Note that however cancelling an
1201  * operation does NOT guarantee that the operation will be fully undone (or that
1202  * nothing ever happened). 
1203  *
1204  * This function MUST be called for every operation to fully remove the
1205  * operation from the operation queue.  After calling this function, if
1206  * operation is completed and its event information is of type
1207  * GNUNET_TESTBED_ET_OPERATION_FINISHED, the 'op_result' becomes invalid (!).
1208
1209  * If the operation is generated from GNUNET_TESTBED_service_connect() then
1210  * calling this function on such as operation calls the disconnect adapter if
1211  * the connect adapter was ever called.
1212  *
1213  * @param operation operation to signal completion or cancellation
1214  */
1215 void
1216 GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation);
1217
1218
1219 /**
1220  * Configure and run a testbed using the given
1221  * master controller on 'num_hosts' starting
1222  * 'num_peers' using the given peer configuration.
1223  *
1224  * @param controller master controller for the testbed
1225  *                   (must not be destroyed until after the
1226  *                    testbed is destroyed).
1227  * @param num_hosts number of hosts in 'hosts', 0 to only
1228  *        use 'localhost'
1229  * @param hosts list of hosts to use for the testbed
1230  * @param num_peers number of peers to start
1231  * @param peer_cfg peer configuration template to use
1232  * @param underlay_topology underlay topology to create
1233  * @param va topology-specific options
1234  * @return handle to the testbed
1235  */
1236 struct GNUNET_TESTBED_Testbed *
1237 GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller,
1238                           unsigned int num_hosts,
1239                           struct GNUNET_TESTBED_Host **hosts,
1240                           unsigned int num_peers,
1241                           const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
1242                           enum GNUNET_TESTBED_TopologyOption underlay_topology,
1243                           va_list va);
1244
1245
1246 /**
1247  * Configure and run a testbed using the given
1248  * master controller on 'num_hosts' starting
1249  * 'num_peers' using the given peer configuration.
1250  *
1251  * @param controller master controller for the testbed
1252  *                   (must not be destroyed until after the
1253  *                    testbed is destroyed).
1254  * @param num_hosts number of hosts in 'hosts', 0 to only
1255  *        use 'localhost'
1256  * @param hosts list of hosts to use for the testbed
1257  * @param num_peers number of peers to start
1258  * @param peer_cfg peer configuration template to use
1259  * @param underlay_topology underlay topology to create
1260  * @param ... topology-specific options
1261  */
1262 struct GNUNET_TESTBED_Testbed *
1263 GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller,
1264                        unsigned int num_hosts,
1265                        struct GNUNET_TESTBED_Host **hosts,
1266                        unsigned int num_peers,
1267                        const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
1268                        enum GNUNET_TESTBED_TopologyOption underlay_topology,
1269                        ...);
1270
1271
1272 /**
1273  * Destroy a testbed.  Stops all running peers and then
1274  * destroys all peers.  Does NOT destroy the master controller.
1275  *
1276  * @param testbed testbed to destroy
1277  */
1278 void
1279 GNUNET_TESTBED_destroy (struct GNUNET_TESTBED_Testbed *testbed);
1280
1281
1282 /**
1283  * Callback function to process statistic values from all peers.
1284  *
1285  * @param cls closure
1286  * @param peer the peer the statistic belong to
1287  * @param subsystem name of subsystem that created the statistic
1288  * @param name the name of the datum
1289  * @param value the current value
1290  * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
1291  * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
1292  */
1293 typedef int (*GNUNET_TESTBED_StatisticsIterator) (void *cls,
1294                                                   const struct GNUNET_TESTBED_Peer *peer,
1295                                                   const char *subsystem,
1296                                                   const char *name,
1297                                                   uint64_t value,
1298                                                   int is_persistent);
1299
1300
1301 /**
1302  * Convenience method that iterates over all (running) peers
1303  * and retrieves all statistics from each peer.
1304  *
1305  * @param num_peers number of peers to iterate over
1306  * @param peers array of peers to iterate over
1307  * @param proc processing function for each statistic retrieved
1308  * @param cont continuation to call once call is completed(?)
1309  * @param cls closure to pass to proc and cont
1310  * @return operation handle to cancel the operation
1311  */
1312 struct GNUNET_TESTBED_Operation *
1313 GNUNET_TESTBED_get_statistics (unsigned int num_peers,
1314                                struct GNUNET_TESTBED_Peer **peers,
1315                                GNUNET_TESTBED_StatisticsIterator proc,
1316                                GNUNET_TESTBED_OperationCompletionCallback cont,
1317                                void *cls);
1318
1319
1320 /**
1321  * Convenience method for running a testbed with
1322  * a single call.  Underlay and overlay topology
1323  * are configured using the "UNDERLAY" and "OVERLAY"
1324  * options in the "[testbed]" section of the configuration\
1325  * (with possible options given in "UNDERLAY_XXX" and/or
1326  * "OVERLAY_XXX").
1327  *
1328  * The testbed is to be terminated using a call to
1329  * "GNUNET_SCHEDULER_shutdown".
1330  *
1331  * @param host_filename name of the file with the 'hosts', NULL
1332  *        to run everything on 'localhost'
1333  * @param cfg configuration to use (for testbed, controller and peers)
1334  * @param num_peers number of peers to start; FIXME: maybe put that ALSO into
1335  *        cfg?; should be greater than 0
1336  * @param event_mask bit mask with set of events to call 'cc' for;
1337  *                   or-ed values of "1LL" shifted by the
1338  *                   respective 'enum GNUNET_TESTBED_EventType'
1339  *                   (i.e.  "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
1340  * @param cc controller callback to invoke on events; This callback is called
1341  *        for all peer start events even if GNUNET_TESTBED_ET_PEER_START isn't
1342  *        set in the event_mask as this is the only way get access to the
1343  *        handle of each peer
1344  * @param cc_cls closure for cc
1345  * @param master task to run once the testbed is ready
1346  * @param master_cls closure for 'task'.
1347  */
1348 void
1349 GNUNET_TESTBED_run (const char *host_filename,
1350                     const struct GNUNET_CONFIGURATION_Handle *cfg,
1351                     unsigned int num_peers,
1352                     uint64_t event_mask,
1353                     GNUNET_TESTBED_ControllerCallback cc,
1354                     void *cc_cls,
1355                     GNUNET_SCHEDULER_Task master,
1356                     void *master_cls);
1357
1358
1359 /**
1360  * Signature of a main function for a testcase.
1361  *
1362  * @param cls closure
1363  * @param num_peers number of peers in 'peers'
1364  * @param peers handle to peers run in the testbed
1365  */
1366 typedef void (*GNUNET_TESTBED_TestMaster)(void *cls,
1367                                           unsigned int num_peers,
1368                                           struct GNUNET_TESTBED_Peer **peers);
1369
1370
1371 /**
1372  * Convenience method for running a "simple" test on the local system
1373  * with a single call from 'main'.  Underlay and overlay topology are
1374  * configured using the "UNDERLAY" and "OVERLAY" options in the
1375  * "[testbed]" section of the configuration (with possible options
1376  * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").
1377  *
1378  * The test is to be terminated using a call to
1379  * "GNUNET_SCHEDULER_shutdown".  If starting the test fails,
1380  * the program is stopped without 'master' ever being run.
1381  *
1382  * NOTE: this function should be called from 'main', NOT from
1383  * within a GNUNET_SCHEDULER-loop.  This function will initialze
1384  * the scheduler loop, the testbed and then pass control to
1385  * 'master'.
1386  *
1387  * @param testname name of the testcase (to configure logging, etc.)
1388  * @param cfg_filename configuration filename to use
1389  *              (for testbed, controller and peers)
1390  * @param num_peers number of peers to start; should be greter than 0
1391  * @param event_mask bit mask with set of events to call 'cc' for;
1392  *                   or-ed values of "1LL" shifted by the
1393  *                   respective 'enum GNUNET_TESTBED_EventType'
1394  *                   (i.e.  "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
1395  * @param cc controller callback to invoke on events; This callback is called
1396  *        for all peer start events even if GNUNET_TESTBED_ET_PEER_START isn't
1397  *        set in the event_mask as this is the only way get access to the
1398  *        handle of each peer
1399  * @param cc_cls closure for cc
1400  * @param test_master task to run once the test is ready
1401  * @param test_master_cls closure for 'task'.
1402  */
1403 void
1404 GNUNET_TESTBED_test_run (const char *testname,
1405                          const char *cfg_filename,
1406                          unsigned int num_peers,
1407                          uint64_t event_mask,
1408                          GNUNET_TESTBED_ControllerCallback cc,
1409                          void *cc_cls,
1410                          GNUNET_TESTBED_TestMaster test_master,
1411                          void *test_master_cls);
1412
1413
1414 #if 0                           /* keep Emacsens' auto-indent happy */
1415 {
1416 #endif
1417
1418
1419 #ifdef __cplusplus
1420 }
1421 #endif
1422
1423 #endif