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