-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  * @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.  No options.
943    */
944   GNUNET_TESTBED_TOPOLOGY_2D_TORUS,
945
946   /**
947    * Random graph.  Followed by the number of random links to be established
948    * (unsigned int)
949    */
950   GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI,
951
952   /**
953    * Certain percentage of peers are unable to communicate directly
954    * replicating NAT conditions.  Followed by the fraction of
955    * NAT'ed peers (float).
956    */
957   GNUNET_TESTBED_TOPOLOGY_INTERNAT,
958
959   /**
960    * Scale free topology.   FIXME: options?
961    */
962   GNUNET_TESTBED_TOPOLOGY_SCALE_FREE,
963
964   /**
965    * Straight line topology.  No options.
966    */
967   GNUNET_TESTBED_TOPOLOGY_LINE,
968
969   /**
970    * All peers are disconnected.  No options.
971    */
972   GNUNET_TESTBED_TOPOLOGY_NONE,
973
974   /**
975    * Read a topology from a given file.  Followed by the name of the file (const char *).
976    */
977   GNUNET_TESTBED_TOPOLOGY_FROM_FILE,
978
979   /**
980    * The options should always end with this
981    */
982   GNUNET_TESTBED_TOPOLOGY_OPTION_END,
983
984   /* The following are not topologies but influence how the topology has to be
985      setup. These options should follow the topology specific options (if
986      required by the chosen topology). Note that these should be given before
987      GNUNET_TESTBED_TOPOLOGY_OPTION_END */
988
989   /**
990    * Disable automatic retrying for failed overlay connections. The default is
991    * to always retry failed overlay connections. This parameter takes no options.
992    */
993   GNUNET_TESTBED_TOPOLOGY_DISABLE_AUTO_RETRY
994 };
995
996
997 /**
998  * Configure overall network topology to have a particular shape.
999  *
1000  * @param op_cls closure argument to give with the operation event
1001  * @param num_peers number of peers in 'peers'
1002  * @param peers array of 'num_peers' with the peers to configure
1003  * @param topo desired underlay topology to use
1004  * @param ap topology-specific options
1005  * @return handle to the operation, NULL if configuring the topology
1006  *         is not allowed at this time
1007  */
1008 struct GNUNET_TESTBED_Operation *
1009 GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls,
1010                                                unsigned int num_peers,
1011                                                struct GNUNET_TESTBED_Peer **peers,
1012                                                enum GNUNET_TESTBED_TopologyOption topo,
1013                                                va_list ap);
1014
1015
1016 /**
1017  * Configure overall network topology to have a particular shape.
1018  *
1019  * @param op_cls closure argument to give with the operation event
1020  * @param num_peers number of peers in 'peers'
1021  * @param peers array of 'num_peers' with the peers to configure
1022  * @param topo desired underlay topology to use
1023  * @param ... topology-specific options
1024  * @return handle to the operation, NULL if configuring the topology
1025  *         is not allowed at this time
1026  */
1027 struct GNUNET_TESTBED_Operation *
1028 GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
1029                                             unsigned int num_peers,
1030                                             struct GNUNET_TESTBED_Peer **peers,
1031                                             enum GNUNET_TESTBED_TopologyOption topo,
1032                                             ...);
1033
1034
1035 /**
1036  * Both peers must have been started before calling this function.
1037  * This function then obtains a HELLO from 'p1', gives it to 'p2'
1038  * and asks 'p2' to connect to 'p1'.
1039  *
1040  * @param op_cls closure argument to give with the operation event
1041  * @param cb the callback to call when this operation has finished
1042  * @param cb_cls the closure for the above callback
1043  * @param p1 first peer
1044  * @param p2 second peer
1045  * @return handle to the operation, NULL if connecting these two
1046  *         peers is fundamentally not possible at this time (peers
1047  *         not running or underlay disallows)
1048  */
1049 struct GNUNET_TESTBED_Operation *
1050 GNUNET_TESTBED_overlay_connect (void *op_cls,
1051                                 GNUNET_TESTBED_OperationCompletionCallback cb,
1052                                 void *cb_cls,
1053                                 struct GNUNET_TESTBED_Peer *p1,
1054                                 struct GNUNET_TESTBED_Peer *p2);
1055
1056
1057 /**
1058  * All peers must have been started before calling this function.
1059  * This function then connects the given peers in the P2P overlay
1060  * using the given topology.
1061  *
1062  * @param op_cls closure argument to give with the operation event
1063  * @param num_peers number of peers in 'peers'
1064  * @param peers array of 'num_peers' with the peers to configure
1065  * @param topo desired underlay topology to use
1066  * @param va topology-specific options
1067  * @return handle to the operation, NULL if connecting these
1068  *         peers is fundamentally not possible at this time (peers
1069  *         not running or underlay disallows) or if num_peers is less than 2
1070  */
1071 struct GNUNET_TESTBED_Operation *
1072 GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
1073                                               unsigned int num_peers,
1074                                               struct GNUNET_TESTBED_Peer **peers,
1075                                               enum GNUNET_TESTBED_TopologyOption topo,
1076                                               va_list va);
1077
1078
1079 /**
1080  * All peers must have been started before calling this function.
1081  * This function then connects the given peers in the P2P overlay
1082  * using the given topology.
1083  *
1084  * @param op_cls closure argument to give with the operation event
1085  * @param num_peers number of peers in 'peers'
1086  * @param peers array of 'num_peers' with the peers to configure
1087  * @param topo desired underlay topology to use
1088  * @param ... topology-specific options
1089  * @return handle to the operation, NULL if connecting these
1090  *         peers is fundamentally not possible at this time (peers
1091  *         not running or underlay disallows) or if num_peers is less than 2
1092  */
1093 struct GNUNET_TESTBED_Operation *
1094 GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
1095                                            unsigned int num_peers,
1096                                            struct GNUNET_TESTBED_Peer **peers,
1097                                            enum GNUNET_TESTBED_TopologyOption topo,
1098                                            ...);
1099
1100
1101 /**
1102  * Ask the testbed controller to write the current overlay topology to
1103  * a file.  Naturally, the file will only contain a snapshot as the
1104  * topology may evolve all the time.
1105  * FIXME: needs continuation!?
1106  *
1107  * @param controller overlay controller to inspect
1108  * @param filename name of the file the topology should
1109  *        be written to.
1110  */
1111 void
1112 GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller,
1113                                                const char *filename);
1114
1115
1116 /**
1117  * Adapter function called to establish a connection to
1118  * a service.
1119  *
1120  * @param cls closure
1121  * @param cfg configuration of the peer to connect to; will be available until
1122  *          GNUNET_TESTBED_operation_done() is called on the operation returned
1123  *          from GNUNET_TESTBED_service_connect()
1124  * @return service handle to return in 'op_result', NULL on error
1125  */
1126 typedef void * (*GNUNET_TESTBED_ConnectAdapter)(void *cls,
1127                                                 const struct GNUNET_CONFIGURATION_Handle *cfg);
1128
1129
1130 /**
1131  * Adapter function called to destroy a connection to
1132  * a service.
1133  *
1134  * @param cls closure
1135  * @param op_result service handle returned from the connect adapter
1136  */
1137 typedef void (*GNUNET_TESTBED_DisconnectAdapter)(void *cls,
1138                                                  void *op_result);
1139
1140
1141 /**
1142  * Callback to be called when a service connect operation is completed
1143  *
1144  * @param cls the callback closure from functions generating an operation
1145  * @param op the operation that has been finished
1146  * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
1147  * @param emsg error message in case the operation has failed; will be NULL if
1148  *          operation has executed successfully.
1149  */
1150 typedef void (*GNUNET_TESTBED_ServiceConnectCompletionCallback) (void *cls,
1151                                                                  struct
1152                                                                  GNUNET_TESTBED_Operation
1153                                                                  *op,
1154                                                                  void
1155                                                                  *ca_result,
1156                                                                  const char
1157                                                                  *emsg );
1158
1159
1160 /**
1161  * Connect to a service offered by the given peer.  Will ensure that
1162  * the request is queued to not overwhelm our ability to create and
1163  * maintain connections with other systems.  The actual service
1164  * handle is then returned via the 'op_result' member in the event
1165  * callback.  The 'ca' callback is used to create the connection
1166  * when the time is right; the 'da' callback will be used to
1167  * destroy the connection (upon 'GNUNET_TESTBED_operation_done').
1168  * 'GNUNET_TESTBED_operation_cancel' can be used to abort this
1169  * operation until the event callback has been called.
1170  *
1171  * @param op_cls closure to pass in operation event
1172  * @param peer peer that runs the service
1173  * @param service_name name of the service to connect to
1174  * @param cb the callback to call when this operation finishes
1175  * @param cb_cls closure for the above callback
1176  * @param ca helper function to establish the connection
1177  * @param da helper function to close the connection
1178  * @param cada_cls closure for ca and da
1179  * @return handle for the operation
1180  */
1181 struct GNUNET_TESTBED_Operation *
1182 GNUNET_TESTBED_service_connect (void *op_cls,
1183                                 struct GNUNET_TESTBED_Peer *peer,
1184                                 const char *service_name,
1185                                 GNUNET_TESTBED_ServiceConnectCompletionCallback cb,
1186                                 void *cb_cls,
1187                                 GNUNET_TESTBED_ConnectAdapter ca,
1188                                 GNUNET_TESTBED_DisconnectAdapter da,
1189                                 void *cada_cls);
1190
1191
1192 /**
1193  * This function is used to signal that the event information (struct
1194  * GNUNET_TESTBED_EventInformation) from an operation has been fully processed
1195  * i.e. if the event callback is ever called for this operation. If the event
1196  * callback for this operation has not yet been called, calling this function
1197  * cancels the operation, frees its resources and ensures the no event is
1198  * generated with respect to this operation. Note that however cancelling an
1199  * operation does NOT guarantee that the operation will be fully undone (or that
1200  * nothing ever happened). 
1201  *
1202  * This function MUST be called for every operation to fully remove the
1203  * operation from the operation queue.  After calling this function, if
1204  * operation is completed and its event information is of type
1205  * GNUNET_TESTBED_ET_OPERATION_FINISHED, the 'op_result' becomes invalid (!).
1206
1207  * If the operation is generated from GNUNET_TESTBED_service_connect() then
1208  * calling this function on such as operation calls the disconnect adapter if
1209  * the connect adapter was ever called.
1210  *
1211  * @param operation operation to signal completion or cancellation
1212  */
1213 void
1214 GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation);
1215
1216
1217 /**
1218  * Configure and run a testbed using the given
1219  * master controller on 'num_hosts' starting
1220  * 'num_peers' using the given peer configuration.
1221  *
1222  * @param controller master controller for the testbed
1223  *                   (must not be destroyed until after the
1224  *                    testbed is destroyed).
1225  * @param num_hosts number of hosts in 'hosts', 0 to only
1226  *        use 'localhost'
1227  * @param hosts list of hosts to use for the testbed
1228  * @param num_peers number of peers to start
1229  * @param peer_cfg peer configuration template to use
1230  * @param underlay_topology underlay topology to create
1231  * @param va topology-specific options
1232  * @return handle to the testbed
1233  */
1234 struct GNUNET_TESTBED_Testbed *
1235 GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller,
1236                           unsigned int num_hosts,
1237                           struct GNUNET_TESTBED_Host **hosts,
1238                           unsigned int num_peers,
1239                           const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
1240                           enum GNUNET_TESTBED_TopologyOption underlay_topology,
1241                           va_list va);
1242
1243
1244 /**
1245  * Configure and run a testbed using the given
1246  * master controller on 'num_hosts' starting
1247  * 'num_peers' using the given peer configuration.
1248  *
1249  * @param controller master controller for the testbed
1250  *                   (must not be destroyed until after the
1251  *                    testbed is destroyed).
1252  * @param num_hosts number of hosts in 'hosts', 0 to only
1253  *        use 'localhost'
1254  * @param hosts list of hosts to use for the testbed
1255  * @param num_peers number of peers to start
1256  * @param peer_cfg peer configuration template to use
1257  * @param underlay_topology underlay topology to create
1258  * @param ... topology-specific options
1259  */
1260 struct GNUNET_TESTBED_Testbed *
1261 GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller,
1262                        unsigned int num_hosts,
1263                        struct GNUNET_TESTBED_Host **hosts,
1264                        unsigned int num_peers,
1265                        const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
1266                        enum GNUNET_TESTBED_TopologyOption underlay_topology,
1267                        ...);
1268
1269
1270 /**
1271  * Destroy a testbed.  Stops all running peers and then
1272  * destroys all peers.  Does NOT destroy the master controller.
1273  *
1274  * @param testbed testbed to destroy
1275  */
1276 void
1277 GNUNET_TESTBED_destroy (struct GNUNET_TESTBED_Testbed *testbed);
1278
1279
1280 /**
1281  * Callback function to process statistic values from all peers.
1282  *
1283  * @param cls closure
1284  * @param peer the peer the statistic belong to
1285  * @param subsystem name of subsystem that created the statistic
1286  * @param name the name of the datum
1287  * @param value the current value
1288  * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
1289  * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
1290  */
1291 typedef int (*GNUNET_TESTBED_StatisticsIterator) (void *cls,
1292                                                   const struct GNUNET_TESTBED_Peer *peer,
1293                                                   const char *subsystem,
1294                                                   const char *name,
1295                                                   uint64_t value,
1296                                                   int is_persistent);
1297
1298
1299 /**
1300  * Convenience method that iterates over all (running) peers
1301  * and retrieves all statistics from each peer.
1302  *
1303  * @param num_peers number of peers to iterate over
1304  * @param peers array of peers to iterate over
1305  * @param proc processing function for each statistic retrieved
1306  * @param cont continuation to call once call is completed(?)
1307  * @param cls closure to pass to proc and cont
1308  * @return operation handle to cancel the operation
1309  */
1310 struct GNUNET_TESTBED_Operation *
1311 GNUNET_TESTBED_get_statistics (unsigned int num_peers,
1312                                struct GNUNET_TESTBED_Peer **peers,
1313                                GNUNET_TESTBED_StatisticsIterator proc,
1314                                GNUNET_TESTBED_OperationCompletionCallback cont,
1315                                void *cls);
1316
1317
1318 /**
1319  * Convenience method for running a testbed with
1320  * a single call.  Underlay and overlay topology
1321  * are configured using the "UNDERLAY" and "OVERLAY"
1322  * options in the "[testbed]" section of the configuration\
1323  * (with possible options given in "UNDERLAY_XXX" and/or
1324  * "OVERLAY_XXX").
1325  *
1326  * The testbed is to be terminated using a call to
1327  * "GNUNET_SCHEDULER_shutdown".
1328  *
1329  * @param host_filename name of the file with the 'hosts', NULL
1330  *        to run everything on 'localhost'
1331  * @param cfg configuration to use (for testbed, controller and peers)
1332  * @param num_peers number of peers to start; FIXME: maybe put that ALSO into
1333  *        cfg?; should be greater than 0
1334  * @param event_mask bit mask with set of events to call 'cc' for;
1335  *                   or-ed values of "1LL" shifted by the
1336  *                   respective 'enum GNUNET_TESTBED_EventType'
1337  *                   (i.e.  "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
1338  * @param cc controller callback to invoke on events; This callback is called
1339  *        for all peer start events even if GNUNET_TESTBED_ET_PEER_START isn't
1340  *        set in the event_mask as this is the only way get access to the
1341  *        handle of each peer
1342  * @param cc_cls closure for cc
1343  * @param master task to run once the testbed is ready
1344  * @param master_cls closure for 'task'.
1345  */
1346 void
1347 GNUNET_TESTBED_run (const char *host_filename,
1348                     const struct GNUNET_CONFIGURATION_Handle *cfg,
1349                     unsigned int num_peers,
1350                     uint64_t event_mask,
1351                     GNUNET_TESTBED_ControllerCallback cc,
1352                     void *cc_cls,
1353                     GNUNET_SCHEDULER_Task master,
1354                     void *master_cls);
1355
1356
1357 /**
1358  * Signature of a main function for a testcase.
1359  *
1360  * @param cls closure
1361  * @param num_peers number of peers in 'peers'
1362  * @param peers handle to peers run in the testbed
1363  */
1364 typedef void (*GNUNET_TESTBED_TestMaster)(void *cls,
1365                                           unsigned int num_peers,
1366                                           struct GNUNET_TESTBED_Peer **peers);
1367
1368
1369 /**
1370  * Convenience method for running a "simple" test on the local system
1371  * with a single call from 'main'.  Underlay and overlay topology are
1372  * configured using the "UNDERLAY" and "OVERLAY" options in the
1373  * "[testbed]" section of the configuration (with possible options
1374  * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").
1375  *
1376  * The test is to be terminated using a call to
1377  * "GNUNET_SCHEDULER_shutdown".  If starting the test fails,
1378  * the program is stopped without 'master' ever being run.
1379  *
1380  * NOTE: this function should be called from 'main', NOT from
1381  * within a GNUNET_SCHEDULER-loop.  This function will initialze
1382  * the scheduler loop, the testbed and then pass control to
1383  * 'master'.
1384  *
1385  * @param testname name of the testcase (to configure logging, etc.)
1386  * @param cfg_filename configuration filename to use
1387  *              (for testbed, controller and peers)
1388  * @param num_peers number of peers to start; should be greter than 0
1389  * @param event_mask bit mask with set of events to call 'cc' for;
1390  *                   or-ed values of "1LL" shifted by the
1391  *                   respective 'enum GNUNET_TESTBED_EventType'
1392  *                   (i.e.  "(1LL << GNUNET_TESTBED_ET_CONNECT) || ...")
1393  * @param cc controller callback to invoke on events; This callback is called
1394  *        for all peer start events even if GNUNET_TESTBED_ET_PEER_START isn't
1395  *        set in the event_mask as this is the only way get access to the
1396  *        handle of each peer
1397  * @param cc_cls closure for cc
1398  * @param test_master task to run once the test is ready
1399  * @param test_master_cls closure for 'task'.
1400  */
1401 void
1402 GNUNET_TESTBED_test_run (const char *testname,
1403                          const char *cfg_filename,
1404                          unsigned int num_peers,
1405                          uint64_t event_mask,
1406                          GNUNET_TESTBED_ControllerCallback cc,
1407                          void *cc_cls,
1408                          GNUNET_TESTBED_TestMaster test_master,
1409                          void *test_master_cls);
1410
1411
1412 #if 0                           /* keep Emacsens' auto-indent happy */
1413 {
1414 #endif
1415
1416
1417 #ifdef __cplusplus
1418 }
1419 #endif
1420
1421 #endif