iterate topoogy header related stuff
[oweals/gnunet.git] / src / include / gnunet_testing_lib.h
1 /*
2       This file is part of GNUnet
3       (C) 2008, 2009 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_testing_lib.h
23  * @brief convenience API for writing testcases for GNUnet
24  *        Many testcases need to start and stop gnunetd,
25  *        and this library is supposed to make that easier
26  *        for TESTCASES.  Normal programs should always
27  *        use functions from gnunet_{util,arm}_lib.h.  This API is
28  *        ONLY for writing testcases!
29  * @author Christian Grothoff
30  */
31
32 #ifndef GNUNET_TESTING_LIB_H
33 #define GNUNET_TESTING_LIB_H
34
35 #include "gnunet_util_lib.h"
36
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #if 0                           /* keep Emacsens' auto-indent happy */
41 }
42 #endif
43 #endif
44
45 /**
46  * Handle for a GNUnet daemon (technically a set of
47  * daemons; the handle is really for the master ARM
48  * daemon) started by the testing library.
49  */
50 struct GNUNET_TESTING_Daemon;
51
52 /**
53  * Linked list of hostnames to use for starting daemons.
54  */
55 struct GNUNET_TESTING_Host
56 {
57   struct GNUNET_TESTING_Host *next;
58   char *hostname;
59 };
60
61 /**
62  * Prototype of a function that will be called whenever
63  * a daemon was started by the testing library.
64  *
65  * @param cls closure
66  * @param id identifier for the daemon, NULL on error
67  * @param d handle for the daemon
68  * @param emsg error message (NULL on success)
69  */
70 typedef void (*GNUNET_TESTING_NotifyHostkeyCreated)(void *cls,
71                                                     const struct GNUNET_PeerIdentity *id,
72                                                     struct GNUNET_TESTING_Daemon *d,
73                                                     const char *emsg);
74
75 /**
76  * Prototype of a function that will be called whenever
77  * a daemon was started by the testing library.
78  *
79  * @param cls closure
80  * @param id identifier for the daemon, NULL on error
81  * @param cfg configuration used by this daemon
82  * @param d handle for the daemon
83  * @param emsg error message (NULL on success)
84  */
85 typedef void (*GNUNET_TESTING_NotifyDaemonRunning)(void *cls,
86                                                    const struct GNUNET_PeerIdentity *id,
87                                                    const struct GNUNET_CONFIGURATION_Handle *cfg,
88                                                    struct GNUNET_TESTING_Daemon *d,
89                                                    const char *emsg);
90
91
92 /**
93  * Handle to an entire testbed of GNUnet peers.
94  */
95 struct GNUNET_TESTING_Testbed;
96
97 /**
98  * Phases of starting GNUnet on a system.
99  */
100 enum GNUNET_TESTING_StartPhase
101 {
102   /**
103    * Copy the configuration file to the target system.
104    */
105   SP_COPYING,
106
107   /**
108    * Configuration file has been copied, generate hostkey.
109    */
110   SP_COPIED,
111
112   /**
113    * Create the hostkey for the peer.
114    */
115   SP_HOSTKEY_CREATE,
116
117   /**
118    * Hostkey generated, wait for topology to be finished.
119    */
120   SP_HOSTKEY_CREATED,
121
122   /**
123    * Topology has been created, now start ARM.
124    */
125   SP_TOPOLOGY_SETUP,
126
127   /**
128    * ARM has been started, check that it has properly daemonized and
129    * then try to connect to the CORE service (which should be
130    * auto-started by ARM).
131    */
132   SP_START_ARMING,
133
134   /**
135    * We're waiting for CORE to start.
136    */
137   SP_START_CORE,
138
139   /**
140    * Core has notified us that we've established a connection to the service.
141    * The main FSM halts here and waits to be moved to UPDATE or CLEANUP.
142    */
143   SP_START_DONE,
144
145   /**
146    * We've been asked to terminate the instance and are now waiting for
147    * the remote command to stop the gnunet-arm process and delete temporary
148    * files.
149    */
150   SP_SHUTDOWN_START,
151
152   /**
153    * We've received a configuration update and are currently waiting for
154    * the copy process for the update to complete.  Once it is, we will
155    * return to "SP_START_DONE" (and rely on ARM to restart all affected
156    * services).
157    */
158   SP_CONFIG_UPDATE
159 };
160
161 /**
162  * Prototype of a function that will be called when a
163  * particular operation was completed the testing library.
164  *
165  * @param cls closure
166  * @param emsg NULL on success
167  */
168 typedef void (*GNUNET_TESTING_NotifyCompletion)(void *cls,
169                                                 const char *emsg);
170
171 /**
172  * Prototype of a function that will be called with the
173  * number of connections created for a particular topology.
174  *
175  * @param cls closure
176  * @param num_connections the number of connections created
177  */
178 typedef void (*GNUNET_TESTING_NotifyConnections)(void *cls,
179                                                 unsigned int num_connections);
180
181 /**
182  * Handle for a GNUnet daemon (technically a set of
183  * daemons; the handle is really for the master ARM
184  * daemon) started by the testing library.
185  */
186 struct GNUNET_TESTING_Daemon
187 {
188   /**
189    * Our scheduler.
190    */
191   struct GNUNET_SCHEDULER_Handle *sched;
192
193   /**
194    * Our configuration.
195    */
196   struct GNUNET_CONFIGURATION_Handle *cfg;
197
198   /**
199    * At what time to give up starting the peer
200    */
201   struct GNUNET_TIME_Absolute max_timeout;
202
203   /**
204    * Host to run GNUnet on.
205    */
206   char *hostname;
207
208   /**
209    * Result of GNUNET_i2s of this peer,
210    * for printing
211    */
212   char *shortname;
213
214   /**
215    * Username we are using.
216    */
217   char *username;
218
219   /**
220    * Name of the configuration file
221    */
222   char *cfgfile;
223
224   /**
225    * Callback to inform initiator that the peer's
226    * hostkey has been created.
227    */
228   GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback;
229
230   /**
231    * Closure for hostkey creation callback.
232    */
233   void *hostkey_cls;
234
235   /**
236    * Function to call when the peer is running.
237    */
238   GNUNET_TESTING_NotifyDaemonRunning cb;
239
240   /**
241    * Closure for cb.
242    */
243   void *cb_cls;
244
245   /**
246    * Arguments from "daemon_stop" call.
247    */
248   GNUNET_TESTING_NotifyCompletion dead_cb;
249
250   /**
251    * Closure for 'dead_cb'.
252    */
253   void *dead_cb_cls;
254
255   /**
256    * Arguments from "daemon_stop" call.
257    */
258   GNUNET_TESTING_NotifyCompletion update_cb;
259
260   /**
261    * Closure for 'update_cb'.
262    */
263   void *update_cb_cls;
264
265   /**
266    * Identity of this peer (once started).
267    */
268   struct GNUNET_PeerIdentity id;
269
270   /**
271    * Flag to indicate that we've already been asked
272    * to terminate (but could not because some action
273    * was still pending).
274    */
275   int dead;
276
277   /**
278    * PID of the process that we started last.
279    */
280   pid_t pid;
281
282   /**
283    * In which phase are we during the start of
284    * this process?
285    */
286   enum GNUNET_TESTING_StartPhase phase;
287
288   /**
289    * ID of the current task.
290    */
291   GNUNET_SCHEDULER_TaskIdentifier task;
292
293   /**
294    * Handle to the server.
295    */
296   struct GNUNET_CORE_Handle *server;
297
298   /**
299    * Handle to the transport service of this peer
300    */
301   struct GNUNET_TRANSPORT_Handle *th;
302
303   /**
304    * HELLO message for this peer
305    */
306   struct GNUNET_HELLO_Message *hello;
307
308   /**
309    * Handle to a pipe for reading the hostkey.
310    */
311   struct GNUNET_DISK_PipeHandle *pipe_stdout;
312
313   /**
314    * Output from gnunet-peerinfo is read into this buffer.
315    */
316   char hostkeybuf[105];
317
318   /**
319    * Current position in 'hostkeybuf' (for reading from gnunet-peerinfo)
320    */
321   unsigned int hostkeybufpos;
322
323   /**
324    * Set to GNUNET_YES once the peer is up.
325    */
326   int running;
327
328   /**
329    * Used to tell shutdown not to remove configuration for the peer
330    * (if it's going to be restarted later)
331    */
332   int churn;
333 };
334
335
336 /**
337  * Handle to a group of GNUnet peers.
338  */
339 struct GNUNET_TESTING_PeerGroup;
340
341
342 /**
343  * Prototype of a function that will be called whenever
344  * two daemons are connected by the testing library.
345  *
346  * @param cls closure
347  * @param first peer id for first daemon
348  * @param second peer id for the second daemon
349  * @param distance distance between the connected peers
350  * @param first_cfg config for the first daemon
351  * @param second_cfg config for the second daemon
352  * @param first_daemon handle for the first daemon
353  * @param second_daemon handle for the second daemon
354  * @param emsg error message (NULL on success)
355  */
356 typedef void (*GNUNET_TESTING_NotifyConnection)(void *cls,
357                                                 const struct GNUNET_PeerIdentity *first,
358                                                 const struct GNUNET_PeerIdentity *second,
359                                                 uint32_t distance,
360                                                 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
361                                                 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
362                                                 struct GNUNET_TESTING_Daemon *first_daemon,
363                                                 struct GNUNET_TESTING_Daemon *second_daemon,
364                                                 const char *emsg);
365
366 /**
367  * Prototype of a callback function indicating that two peers
368  * are currently connected.
369  *
370  * @param cls closure
371  * @param first peer id for first daemon
372  * @param second peer id for the second daemon
373  * @param distance distance between the connected peers
374  * @param emsg error message (NULL on success)
375  */
376 typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls,
377                                               const struct GNUNET_PeerIdentity *first,
378                                               const struct GNUNET_PeerIdentity *second,
379                                               struct GNUNET_TIME_Relative latency,
380                                               uint32_t distance,
381                                               const char *emsg);
382
383 /**
384  * Starts a GNUnet daemon.  GNUnet must be installed on the target
385  * system and available in the PATH.  The machine must furthermore be
386  * reachable via "ssh" (unless the hostname is "NULL") without the
387  * need to enter a password.
388  *
389  * @param sched scheduler to use
390  * @param cfg configuration to use
391  * @param timeout how long to wait starting up peers
392  * @param hostname name of the machine where to run GNUnet
393  *        (use NULL for localhost).
394  * @param hostkey_callback function to call once the hostkey has been
395  *        generated for this peer, but it hasn't yet been started
396  *        (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start)
397  * @param hostkey_cls closure for hostkey callback
398  * @param cb function to call with the result
399  * @param cb_cls closure for cb
400  * @return handle to the daemon (actual start will be completed asynchronously)
401  */
402 struct GNUNET_TESTING_Daemon *
403 GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
404                              const struct GNUNET_CONFIGURATION_Handle *cfg,
405                              struct GNUNET_TIME_Relative timeout,
406                              const char *hostname,
407                              GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback,
408                              void *hostkey_cls,
409                              GNUNET_TESTING_NotifyDaemonRunning cb,
410                              void *cb_cls);
411
412 /**
413  * Continues GNUnet daemon startup when user wanted to be notified
414  * once a hostkey was generated (for creating friends files, blacklists,
415  * etc.).
416  *
417  * @param daemon the daemon to finish starting
418  */
419 void
420 GNUNET_TESTING_daemon_continue_startup(struct GNUNET_TESTING_Daemon *daemon);
421
422 /**
423  * Restart (stop and start) a GNUnet daemon.
424  *
425  * @param d the daemon that should be restarted
426  * @param cb function called once the daemon is (re)started
427  * @param cb_cls closure for cb
428  */
429 void
430 GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
431                                GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls);
432
433 /**
434  * Start a peer that has previously been stopped using the daemon_stop
435  * call (and files weren't deleted and the allow restart flag)
436  *
437  * @param daemon the daemon to start (has been previously stopped)
438  * @param timeout how long to wait for restart
439  * @param cb the callback for notification when the peer is running
440  * @param cb_cls closure for the callback
441  */
442 void
443 GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
444                                      struct GNUNET_TIME_Relative timeout,
445                                      GNUNET_TESTING_NotifyDaemonRunning cb,
446                                      void *cb_cls);
447
448 /**
449  * Get a certain testing daemon handle.
450  *
451  * @param pg handle to the set of running peers
452  * @param position the number of the peer to return
453  */
454 struct GNUNET_TESTING_Daemon *
455 GNUNET_TESTING_daemon_get (struct GNUNET_TESTING_PeerGroup *pg, 
456                            unsigned int position);
457
458
459 /**
460  * Stops a GNUnet daemon.
461  *
462  * @param d the daemon that should be stopped
463  * @param timeout how long to wait for process for shutdown to complete
464  * @param cb function called once the daemon was stopped
465  * @param cb_cls closure for cb
466  * @param delete_files GNUNET_YES to remove files, GNUNET_NO
467  *        to leave them (i.e. for restarting at a later time,
468  *        or logfile inspection once finished)
469  * @param allow_restart GNUNET_YES to restart peer later (using this API)
470  *        GNUNET_NO to kill off and clean up for good
471  */
472 void
473 GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
474                             struct GNUNET_TIME_Relative timeout,
475                             GNUNET_TESTING_NotifyCompletion cb, void *cb_cls,
476                             int delete_files, int allow_restart);
477
478
479 /**
480  * Changes the configuration of a GNUnet daemon.
481  *
482  * @param d the daemon that should be modified
483  * @param cfg the new configuration for the daemon
484  * @param cb function called once the configuration was changed
485  * @param cb_cls closure for cb
486  */
487 void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
488                                         struct GNUNET_CONFIGURATION_Handle *cfg,
489                                         GNUNET_TESTING_NotifyCompletion cb,
490                                         void * cb_cls);
491
492
493 /**
494  * Establish a connection between two GNUnet daemons.
495  *
496  * @param d1 handle for the first daemon
497  * @param d2 handle for the second daemon
498  * @param timeout how long is the connection attempt
499  *        allowed to take?
500  * @param max_connect_attempts how many times should we try to reconnect
501  *        (within timeout)
502  * @param cb function to call at the end
503  * @param cb_cls closure for cb
504  */
505 void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
506                                      struct GNUNET_TESTING_Daemon *d2,
507                                      struct GNUNET_TIME_Relative timeout,
508                                      unsigned int max_connect_attempts,
509                                      GNUNET_TESTING_NotifyConnection cb,
510                                      void *cb_cls);
511
512
513
514
515 /**
516  * Start count gnunetd processes with the same set of transports and
517  * applications.  The port numbers (any option called "PORT") will be
518  * adjusted to ensure that no two peers running on the same system
519  * have the same port(s) in their respective configurations.
520  *
521  * @param sched scheduler to use
522  * @param cfg configuration template to use
523  * @param total number of daemons to start
524  * @param timeout total time allowed for peers to start
525  * @param hostkey_callback function to call on each peers hostkey generation
526  *        if NULL, peers will be started by this call, if non-null,
527  *        GNUNET_TESTING_daemons_continue_startup must be called after
528  *        successful hostkey generation
529  * @param hostkey_cls closure for hostkey callback
530  * @param cb function to call on each daemon that was started
531  * @param cb_cls closure for cb
532  * @param connect_callback function to call each time two hosts are connected
533  * @param connect_callback_cls closure for connect_callback
534  * @param hostnames linked list of hosts to use to start peers on (NULL to run on localhost only)
535  *
536  * @return NULL on error, otherwise handle to control peer group
537  */
538 struct GNUNET_TESTING_PeerGroup *
539 GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
540                               const struct GNUNET_CONFIGURATION_Handle *cfg,
541                               unsigned int total,
542                               struct GNUNET_TIME_Relative timeout,
543                               GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback,
544                               void *hostkey_cls,
545                               GNUNET_TESTING_NotifyDaemonRunning cb,
546                               void *cb_cls,
547                               GNUNET_TESTING_NotifyConnection
548                               connect_callback, void *connect_callback_cls,
549                               const struct GNUNET_TESTING_Host *hostnames);
550
551 /**
552  * Function which continues a peer group starting up
553  * after successfully generating hostkeys for each peer.
554  *
555  * @param pg the peer group to continue starting
556  */
557 void
558 GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg);
559
560 /**
561  * Restart all peers in the given group.
562  *
563  * @param pg the handle to the peer group
564  * @param callback function to call on completion (or failure)
565  * @param callback_cls closure for the callback function
566  */
567 void
568 GNUNET_TESTING_daemons_restart (struct GNUNET_TESTING_PeerGroup *pg,
569                                 GNUNET_TESTING_NotifyCompletion callback,
570                                 void *callback_cls);
571
572
573 /**
574  * Shutdown all peers started in the given group.
575  *
576  * @param pg handle to the peer group
577  * @param timeout how long to wait for shutdown
578  * @param cb callback to notify upon success or failure
579  * @param cb_cls closure for cb
580  */
581 void
582 GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg, 
583                              struct GNUNET_TIME_Relative timeout,
584                              GNUNET_TESTING_NotifyCompletion cb,
585                              void *cb_cls);
586
587
588 /**
589  * Simulate churn by stopping some peers (and possibly
590  * re-starting others if churn is called multiple times).  This
591  * function can only be used to create leave-join churn (peers "never"
592  * leave for good).  First "voff" random peers that are currently
593  * online will be taken offline; then "von" random peers that are then
594  * offline will be put back online.  No notifications will be
595  * generated for any of these operations except for the callback upon
596  * completion.  Note that the implementation is at liberty to keep
597  * the ARM service itself (but none of the other services or daemons)
598  * running even though the "peer" is being varied offline.
599  *
600  * @param pg handle for the peer group
601  * @param voff number of peers that should go offline
602  * @param von number of peers that should come back online;
603  *            must be zero on first call (since "testbed_start"
604  *            always starts all of the peers)
605  * @param timeout how long to wait for operations to finish before
606  *        giving up
607  * @param cb function to call at the end
608  * @param cb_cls closure for cb
609  */
610 void
611 GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
612                               unsigned int voff,
613                               unsigned int von,
614                               struct GNUNET_TIME_Relative timeout,
615                               GNUNET_TESTING_NotifyCompletion cb,
616                               void *cb_cls);
617
618
619 /**
620  * Topologies supported for testbeds.
621  */
622 enum GNUNET_TESTING_Topology
623 {
624   /**
625    * A clique (everyone connected to everyone else).
626    */
627   GNUNET_TESTING_TOPOLOGY_CLIQUE,
628
629   /**
630    * Small-world network (2d torus plus random links).
631    */
632   GNUNET_TESTING_TOPOLOGY_SMALL_WORLD,
633
634   /**
635    * Small-world network (ring plus random links).
636    */
637   GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING,
638
639   /**
640    * Ring topology.
641    */
642   GNUNET_TESTING_TOPOLOGY_RING,
643
644   /**
645    * 2-d torus.
646    */
647   GNUNET_TESTING_TOPOLOGY_2D_TORUS,
648
649   /**
650    * Random graph.
651    */
652   GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI,
653
654   /**
655    * Certain percentage of peers are unable to communicate directly
656    * replicating NAT conditions
657    */
658   GNUNET_TESTING_TOPOLOGY_INTERNAT,
659
660   /**
661    * Scale free topology.
662    */
663   GNUNET_TESTING_TOPOLOGY_SCALE_FREE,
664
665   /**
666    * Straight line topology.
667    */
668   GNUNET_TESTING_TOPOLOGY_LINE,
669
670   /**
671    * All peers are disconnected.
672    */
673   GNUNET_TESTING_TOPOLOGY_NONE
674 };
675
676 /**
677  * Options for connecting a topology.
678  */
679 enum GNUNET_TESTING_TopologyOption
680 {
681   /**
682    * Try to connect all peers specified in the topology.
683    */
684   GNUNET_TESTING_TOPOLOGY_OPTION_ALL,
685
686   /**
687    * Choose a random subset of connections to create.
688    */
689   GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM,
690
691   /**
692    * Create at least X connections for each peer.
693    */
694   GNUNET_TESTING_TOPOLOGY_OPTION_MINIMUM,
695
696   /**
697    * Using a depth first search, create one connection
698    * per peer.  If any are missed (graph disconnected)
699    * start over at those peers until all have at least one
700    * connection.
701    */
702   GNUNET_TESTING_TOPOLOGY_OPTION_DFS,
703
704   /**
705    * No options specified.
706    */
707   GNUNET_TESTING_TOPOLOGY_OPTION_NONE
708 };
709
710
711 /**
712  * Get a topology from a string input.
713  *
714  * @param topology where to write the retrieved topology
715  * @param topology_string The string to attempt to
716  *        get a configuration value from
717  * @return GNUNET_YES if topology string matched a
718  *         known topology, GNUNET_NO if not
719  */
720 int
721 GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, char * topology_string);
722
723 /**
724  * Get connect topology option from string input.
725  *
726  * @param topology_option where to write the retrieved topology
727  * @param topology_string The string to attempt to
728  *        get a configuration value from
729  * @return GNUNET_YES if topology string matched a
730  *         known topology, GNUNET_NO if not
731  */
732 int
733 GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology_option,
734                                    char * topology_string);
735
736
737 /**
738  * Takes a peer group and creates a topology based on the
739  * one specified.  Creates a topology means generates friend
740  * files for the peers so they can only connect to those allowed
741  * by the topology.  This will only have an effect once peers
742  * are started if the FRIENDS_ONLY option is set in the base
743  * config.  Also takes an optional restrict topology which
744  * disallows direct TCP connections UNLESS they are specified in
745  * the restricted topology.
746  *
747  * @param pg the peer group struct representing the running peers
748  * @param topology which topology to connect the peers in
749  * @param restrict_topology allow only direct TCP connections in this topology
750  * @param restrict_transports space delimited list of transports to blacklist
751  *                            to create restricted topology
752  *
753  * @return the maximum number of connections were all allowed peers
754  *         connected to each other
755  */
756 int
757 GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
758                                 enum GNUNET_TESTING_Topology topology,
759                                 enum GNUNET_TESTING_Topology restrict_topology,
760                                 char *restrict_transports);
761
762 /**
763  * Iterate over all (running) peers in the peer group, retrieve
764  * all connections that each currently has.
765  *
766  * @param pg the peer group we are concerned with
767  * @param cb callback for topology information
768  * @param cls closure for callback
769  */
770 void
771 GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_NotifyTopology cb, void *cls);
772
773 /**
774  * There are many ways to connect peers that are supported by this function.
775  * To connect peers in the same topology that was created via the
776  * GNUNET_TESTING_create_topology, the topology variable must be set to
777  * GNUNET_TESTING_TOPOLOGY_NONE.  If the topology variable is specified,
778  * a new instance of that topology will be generated and attempted to be
779  * connected.  This could result in some connections being impossible,
780  * because some topologies are non-deterministic.
781  *
782  * @param pg the peer group struct representing the running peers
783  * @param topology which topology to connect the peers in
784  * @param options options for connecting the topology
785  * @param option_modifier modifier for options that take a parameter
786  * @return the number of connections that will be attempted, GNUNET_SYSERR on error
787  */
788 int
789 GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
790                                  enum GNUNET_TESTING_Topology topology,
791                                  enum GNUNET_TESTING_TopologyOption options,
792                                  double option_modifier);
793
794 /**
795  * Start or stop an individual peer from the given group.
796  *
797  * @param pg handle to the peer group
798  * @param offset which peer to start or stop
799  * @param desired_status GNUNET_YES to have it running, GNUNET_NO to stop it
800  * @param timeout how long to wait for shutdown
801  * @param cb function to call at the end
802  * @param cb_cls closure for cb
803  */
804 void
805 GNUNET_TESTING_daemons_vary (struct GNUNET_TESTING_PeerGroup *pg, 
806                              unsigned int offset,
807                              int desired_status,
808                              struct GNUNET_TIME_Relative timeout,
809                              GNUNET_TESTING_NotifyCompletion cb,
810                              void *cb_cls);
811
812
813 #if 0                           /* keep Emacsens' auto-indent happy */
814 {
815 #endif
816 #ifdef __cplusplus
817 }
818 #endif
819
820 #endif