-#define HOSTKEYFILESIZE 914
-
-/**
- * Handle for a GNUnet daemon (technically a set of
- * daemons; the handle is really for the master ARM
- * daemon) started by the testing library.
- */
-struct GNUNET_TESTING_Daemon;
-
-/**
- * Linked list of hostnames and ports to use for starting daemons.
- */
-struct GNUNET_TESTING_Host
-{
- /**
- * Pointer to next item in the list.
- */
- struct GNUNET_TESTING_Host *next;
-
- /**
- * Hostname to connect to.
- */
- char *hostname;
-
- /**
- * Username to use when connecting (may be null).
- */
- char *username;
-
- /**
- * Port to use for SSH connection (used for ssh
- * connection forwarding, 0 to let ssh decide)
- */
- uint16_t port;
-};
-
-/**
- * Prototype of a function that will be called whenever
- * a daemon was started by the testing library.
- *
- * @param cls closure
- * @param id identifier for the daemon, NULL on error
- * @param d handle for the daemon
- * @param emsg error message (NULL on success)
- */
-typedef void (*GNUNET_TESTING_NotifyHostkeyCreated) (void *cls,
- const struct
- GNUNET_PeerIdentity * id,
- struct
- GNUNET_TESTING_Daemon * d,
- const char *emsg);
-
-/**
- * Prototype of a function that will be called whenever
- * a daemon was started by the testing library.
- *
- * @param cls closure
- * @param id identifier for the daemon, NULL on error
- * @param cfg configuration used by this daemon
- * @param d handle for the daemon
- * @param emsg error message (NULL on success)
- */
-typedef void (*GNUNET_TESTING_NotifyDaemonRunning) (void *cls,
- const struct
- GNUNET_PeerIdentity * id,
- const struct
- GNUNET_CONFIGURATION_Handle
- * cfg,
- struct GNUNET_TESTING_Daemon
- * d, const char *emsg);
-
-/**
- * Handle to an entire testbed of GNUnet peers.
- */
-struct GNUNET_TESTING_Testbed;
-
-/**
- * Phases of starting GNUnet on a system.
- */
-enum GNUNET_TESTING_StartPhase
-{
- /**
- * Copy the configuration file to the target system.
- */
- SP_COPYING,
-
- /**
- * Configuration file has been copied, generate hostkey.
- */
- SP_COPIED,
-
- /**
- * Create the hostkey for the peer.
- */
- SP_HOSTKEY_CREATE,
-
- /**
- * Hostkey generated, wait for topology to be finished.
- */
- SP_HOSTKEY_CREATED,
-
- /**
- * Topology has been created, now start ARM.
- */
- SP_TOPOLOGY_SETUP,
-
- /**
- * ARM has been started, check that it has properly daemonized and
- * then try to connect to the CORE service (which should be
- * auto-started by ARM).
- */
- SP_START_ARMING,
-
- /**
- * We're waiting for CORE to start.
- */
- SP_START_CORE,
-
- /**
- * CORE is up, now make sure we get the HELLO for this peer.
- */
- SP_GET_HELLO,
-
- /**
- * Core has notified us that we've established a connection to the service.
- * The main FSM halts here and waits to be moved to UPDATE or CLEANUP.
- */
- SP_START_DONE,
-
- /**
- * We've been asked to terminate the instance and are now waiting for
- * the remote command to stop the gnunet-arm process and delete temporary
- * files.
- */
- SP_SHUTDOWN_START,
-
- /**
- * We should shutdown a *single* service via gnunet-arm. Call the dead_cb
- * upon notification from gnunet-arm that the service has been stopped.
- */
- SP_SERVICE_SHUTDOWN_START,
-
- /**
- * We should start a *single* service via gnunet-arm. Call the daemon cb
- * upon notification from gnunet-arm that the service has been started.
- */
- SP_SERVICE_START,
-
- /**
- * We've received a configuration update and are currently waiting for
- * the copy process for the update to complete. Once it is, we will
- * return to "SP_START_DONE" (and rely on ARM to restart all affected
- * services).
- */
- SP_CONFIG_UPDATE
-};
-
-/**
- * Prototype of a function that will be called when a
- * particular operation was completed the testing library.
- *
- * @param cls closure
- * @param emsg NULL on success
- */
-typedef void (*GNUNET_TESTING_NotifyCompletion) (void *cls, const char *emsg);
-
-/**
- * Prototype of a function that will be called with the
- * number of connections created for a particular topology.
- *
- * @param cls closure
- * @param num_connections the number of connections created
- */
-typedef void (*GNUNET_TESTING_NotifyConnections) (void *cls,
- unsigned int num_connections);
-
-/**
- * Handle for a GNUnet daemon (technically a set of
- * daemons; the handle is really for the master ARM
- * daemon) started by the testing library.
- */
-struct GNUNET_TESTING_Daemon
-{
- /**
- * Our configuration.
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * At what time to give up starting the peer
- */
- struct GNUNET_TIME_Absolute max_timeout;
-
- /**
- * Host to run GNUnet on.
- */
- char *hostname;
-
- /**
- * Port to use for ssh, NULL to let system choose default.
- */
- char *ssh_port_str;
-
- /**
- * Result of GNUNET_i2s of this peer,
- * for printing
- */
- char *shortname;
-
- /**
- * Username we are using.
- */
- char *username;
-
- /**
- * Name of the configuration file
- */
- char *cfgfile;
-
- /**
- * Callback to inform initiator that the peer's
- * hostkey has been created.
- */
- GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback;
-
- /**
- * Closure for hostkey creation callback.
- */
- void *hostkey_cls;
-
- /**
- * Function to call when the peer is running.
- */
- GNUNET_TESTING_NotifyDaemonRunning cb;
-
- /**
- * Closure for cb.
- */
- void *cb_cls;
-
- /**
- * Arguments from "daemon_stop" call.
- */
- GNUNET_TESTING_NotifyCompletion dead_cb;
-
- /**
- * Closure for 'dead_cb'.
- */
- void *dead_cb_cls;
-
- /**
- * Arguments from "daemon_stop" call.
- */
- GNUNET_TESTING_NotifyCompletion update_cb;
-
- /**
- * Closure for 'update_cb'.
- */
- void *update_cb_cls;
-
- /**
- * PID of the process that we started last.
- */
- struct GNUNET_OS_Process *proc;
-
- /**
- * Handle to the server.
- */
- struct GNUNET_CORE_Handle *server;
-
- /**
- * Handle to the transport service of this peer
- */
- struct GNUNET_TRANSPORT_Handle *th;
-
- /**
- * Handle for getting HELLOs from transport
- */
- struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
-
- /**
- * HELLO message for this peer
- */
- struct GNUNET_HELLO_Message *hello;
-
- /**
- * Handle to a pipe for reading the hostkey.
- */
- struct GNUNET_DISK_PipeHandle *pipe_stdout;
-
- /**
- * Currently, a single char * pointing to a service
- * that has been churned off.
- *
- * FIXME: make this a linked list of services that have been churned off!!!
- */
- char *churned_services;
-
- /**
- * ID of the current task.
- */
- GNUNET_SCHEDULER_TaskIdentifier task;
-
- /**
- * Identity of this peer (once started).
- */
- struct GNUNET_PeerIdentity id;
-
- /**
- * Flag to indicate that we've already been asked
- * to terminate (but could not because some action
- * was still pending).
- */
- int dead;
-
- /**
- * GNUNET_YES if the hostkey has been created
- * for this peer, GNUNET_NO otherwise.
- */
- int have_hostkey;
-
- /**
- * In which phase are we during the start of
- * this process?
- */
- enum GNUNET_TESTING_StartPhase phase;
-
- /**
- * Current position in 'hostkeybuf' (for reading from gnunet-peerinfo)
- */
- unsigned int hostkeybufpos;
-
- /**
- * Set to GNUNET_YES once the peer is up.
- */
- int running;
-
- /**
- * Used to tell shutdown not to remove configuration for the peer
- * (if it's going to be restarted later)
- */
- int churn;
-
- /**
- * Output from gnunet-peerinfo is read into this buffer.
- */
- char hostkeybuf[105];
-
-};
-
-
-/**
- * Handle to a group of GNUnet peers.
- */
-struct GNUNET_TESTING_PeerGroup;
-
-
-/**
- * Prototype of a function that will be called whenever
- * two daemons are connected by the testing library.
- *
- * @param cls closure
- * @param first peer id for first daemon
- * @param second peer id for the second daemon
- * @param distance distance between the connected peers
- * @param first_cfg config for the first daemon
- * @param second_cfg config for the second daemon
- * @param first_daemon handle for the first daemon
- * @param second_daemon handle for the second daemon
- * @param emsg error message (NULL on success)
- */
-typedef void (*GNUNET_TESTING_NotifyConnection) (void *cls,
- const struct
- GNUNET_PeerIdentity * first,
- const struct
- GNUNET_PeerIdentity * second,
- uint32_t distance,
- const struct
- GNUNET_CONFIGURATION_Handle *
- first_cfg,
- const struct
- GNUNET_CONFIGURATION_Handle *
- second_cfg,
- struct GNUNET_TESTING_Daemon *
- first_daemon,
- struct GNUNET_TESTING_Daemon *
- second_daemon,
- const char *emsg);
-
-
-/**
- * Prototype of a callback function indicating that two peers
- * are currently connected.
- *
- * @param cls closure
- * @param first peer id for first daemon
- * @param second peer id for the second daemon
- * @param distance distance between the connected peers
- * @param emsg error message (NULL on success)
- */
-typedef void (*GNUNET_TESTING_NotifyTopology) (void *cls,
- const struct GNUNET_PeerIdentity
- * first,
- const struct GNUNET_PeerIdentity
- * second, const char *emsg);
-
-
-/**
- * Starts a GNUnet daemon. GNUnet must be installed on the target
- * system and available in the PATH. The machine must furthermore be
- * reachable via "ssh" (unless the hostname is "NULL") without the
- * need to enter a password.
- *
- * @param cfg configuration to use
- * @param timeout how long to wait starting up peers
- * @param pretend GNUNET_YES to set up files but not start peer GNUNET_NO
- * to really start the peer (default)
- * @param hostname name of the machine where to run GNUnet
- * (use NULL for localhost).
- * @param ssh_username ssh username to use when connecting to hostname
- * @param sshport port to pass to ssh process when connecting to hostname
- * @param hostkey pointer to a hostkey to be written to disk (instead of being generated)
- * @param hostkey_callback function to call once the hostkey has been
- * generated for this peer, but it hasn't yet been started
- * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start)
- * @param hostkey_cls closure for hostkey callback
- * @param cb function to call once peer is up, or failed to start
- * @param cb_cls closure for cb
- * @return handle to the daemon (actual start will be completed asynchronously)
- */
-struct GNUNET_TESTING_Daemon *
-GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TIME_Relative timeout, int pretend,
- const char *hostname, const char *ssh_username,
- uint16_t sshport, const char *hostkey,
- GNUNET_TESTING_NotifyHostkeyCreated
- hostkey_callback, void *hostkey_cls,
- GNUNET_TESTING_NotifyDaemonRunning cb,
- void *cb_cls);
-
-/**
- * Continues GNUnet daemon startup when user wanted to be notified
- * once a hostkey was generated (for creating friends files, blacklists,
- * etc.).
- *
- * @param daemon the daemon to finish starting
- */
-void
-GNUNET_TESTING_daemon_continue_startup (struct GNUNET_TESTING_Daemon *daemon);
-
-
-/**
- * Check whether the given daemon is running.
- *
- * @param daemon the daemon to check
- * @return GNUNET_YES if the daemon is up, GNUNET_NO if the
- * daemon is down, GNUNET_SYSERR on error.
- */
-int
-GNUNET_TESTING_test_daemon_running (struct GNUNET_TESTING_Daemon *daemon);
-
-