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