- mark old API calls used for previous VPN implementation as deprecated
[oweals/gnunet.git] / src / include / gnunet_testbed_service.h
index 6b50efe97c4e96534737070e9c3e50b718d9126f..e6997db1fee6959b7a1e8c3c2c876efcfc36358c 100644 (file)
@@ -88,6 +88,26 @@ GNUNET_TESTBED_host_create (const char *hostname,
                            uint16_t port);
 
 
+
+/**
+ * Create a host to run peers and controllers on.  This function is used
+ * if a peer learns about a host via IPC between controllers (and thus 
+ * some higher-level controller has already determined the unique IDs).
+ * 
+ * @param id global host ID assigned to the host; 0 is
+ *        reserved to always mean 'localhost'
+ * @param hostname name of the host, use "NULL" for localhost
+ * @param username username to use for the login; may be NULL
+ * @param port port number to use for ssh; use 0 to let ssh decide
+ * @return handle to the host, NULL on error
+ */
+struct GNUNET_TESTBED_Host *
+GNUNET_TESTBED_host_create_with_id (uint32_t id,
+                                   const char *hostname,
+                                   const char *username,
+                                   uint16_t port);
+
+
 /**
  * Load a set of hosts from a configuration file.
  *
@@ -372,15 +392,45 @@ struct GNUNET_TESTBED_EventInformation
  * @param event information about the event
  */
 typedef void (*GNUNET_TESTBED_ControllerCallback)(void *cls,
-                                                 const struct GNUNET_TESTBED_EventInformation *event);                                           
+                                                 const struct GNUNET_TESTBED_EventInformation *event);
 
 
 /**
- * Start a controller process using the given configuration at the
+ * Opaque Handle for Controller process
+ */
+struct GNUNET_TESTBED_ControllerProc;
+
+
+/**
+ * Starts a controller process at the host
+ *
+ * @param host the host where the controller has to be started; NULL for localhost
+ * @return the controller process handle
+ */
+struct GNUNET_TESTBED_ControllerProc *
+GNUNET_TESTBED_controller_start (struct GNUNET_TESTBED_Host *host);
+
+
+/**
+ * Stop the controller process (also will terminate all peers and controllers
+ * dependent on this controller).  This function blocks until the testbed has
+ * been fully terminated (!).
+ *
+ * @param cproc the controller process handle
+ */
+void
+GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cproc);
+
+
+/**
+ * Connect to a controller process using the given configuration at the
  * given host.
  *
  * @param cfg configuration to use
- * @param host host to run the controller on, NULL for 'localhost'
+ * @param host host to run the controller on; This should be the same host if
+ *          the controller was previously started with
+ *          GNUNET_TESTBED_controller_start; NULL for localhost
+ * @param host host where this controller is being run;
  * @param event_mask bit mask with set of events to call 'cc' for;
  *                   or-ed values of "1LL" shifted by the
  *                   respective 'enum GNUNET_TESTBED_EventType'
@@ -390,11 +440,11 @@ typedef void (*GNUNET_TESTBED_ControllerCallback)(void *cls,
  * @return handle to the controller
  */
 struct GNUNET_TESTBED_Controller *
-GNUNET_TESTBED_controller_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                struct GNUNET_TESTBED_Host *host,
-                                uint64_t event_mask,
-                                GNUNET_TESTBED_ControllerCallback cc,
-                                void *cc_cls);
+GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                                  struct GNUNET_TESTBED_Host *host,
+                                  uint64_t event_mask,
+                                  GNUNET_TESTBED_ControllerCallback cc,
+                                  void *cc_cls);
 
 
 /**
@@ -424,30 +474,79 @@ GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller *c
  * @param controller handle to controller to stop
  */
 void
-GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_Controller *controller);
+GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *controller);
+
+
+/**
+ * Opaque handle for host registration
+ */
+struct GNUNET_TESTBED_HostRegistrationHandle;
+
+
+/**
+ * Callback which will be called to after a host registration succeeded or failed
+ *
+ * @param cls the closure
+ * @param emsg the error message; NULL if host registration is successful
+ */
+typedef void (* GNUNET_TESTBED_HostRegistrationCompletion) (void *cls, 
+                                                            const char *emsg);
+
+
+/**
+ * Register a host with the controller
+ *
+ * @param controller the controller handle
+ * @param host the host to register
+ * @param cc the completion callback to call to inform the status of
+ *          registration. After calling this callback the registration handle
+ *          will be invalid. Cannot be NULL
+ * @param cc_cls the closure for the cc
+ * @return handle to the host registration which can be used to cancel the
+ *           registration; NULL if another registration handle is present and
+ *           is not cancelled
+ */
+struct GNUNET_TESTBED_HostRegistrationHandle *
+GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
+                              struct GNUNET_TESTBED_Host *host,
+                              GNUNET_TESTBED_HostRegistrationCompletion cc,
+                              void *cc_cls);
+
+
+/**
+ * Cancel the pending registration. Note that the registration message will
+ * already be queued to be sent to the service, cancellation has only the
+ * effect that the registration completion callback for the registration is
+ * never called and from our perspective the host is not registered until the
+ * completion callback is called.
+ *
+ * @param handle the registration handle to cancel
+ */
+void
+GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle
+                                    *handle);
 
 
 /**
- * Create a link from a 'master' controller to a slave controller.
- * Whenever the master controller is asked to start a peer at the
- * given 'delegated_host', it will delegate the request to the
- * specified slave controller.  Note that the slave controller runs at
- * the 'slave_host', which may or may not be the same host as the
- * 'delegated_host' (for hierarchical delegations).  The configuration
- * of the slave controller is given and to be used to either create
- * the slave controller or to connect to an existing slave controller
- * process.  'is_subordinate' specifies if the given slave controller
- * should be started and managed by the master controller, or if the
- * slave already has a master and this is just a secondary master that
- * is also allowed to use the existing slave.
+ * Create a link from slave controller to delegated controller. Whenever the
+ * master controller is asked to start a peer at the delegated controller the
+ * request will be routed towards slave controller (if a route exists). The
+ * slave controller will then route it to the delegated controller. The
+ * configuration of the slave controller is given and to be used to either
+ * create the slave controller or to connect to an existing slave controller
+ * process.  'is_subordinate' specifies if the given slave controller should be
+ * started and managed by the master controller, or if the slave already has a
+ * master and this is just a secondary master that is also allowed to use the
+ * existing slave.
  *
  * @param master handle to the master controller who creates the association
- * @param delegated_host requests to which host should be delegated
- * @param slave_host which host is used to run the slave controller 
+ * @param delegated_host requests to which host should be delegated; cannot be NULL
+ * @param slave_host which host is used to run the slave controller; use NULL to
+ *          make the master controller connect to the delegated host
  * @param slave_cfg configuration to use for the slave controller
- * @param is_subordinate GNUNET_YES if the slave should be started (and stopped)
- *                       by the master controller; GNUNET_NO if we are just
- *                       allowed to use the slave via TCP/IP
+ * @param is_subordinate GNUNET_YES if the controller at delegated_host should
+ *          be started by the master controller; GNUNET_NO if we are just
+ *          allowed to use the slave via TCP/IP
  */
 void
 GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
@@ -457,6 +556,31 @@ GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
                                int is_subordinate);
 
 
+/**
+ * Same as the GNUNET_TESTBED_controller_link, however expects configuration in
+ * serialized and compressed
+ *
+ * @param master handle to the master controller who creates the association
+ * @param delegated_host requests to which host should be delegated; cannot be NULL
+ * @param slave_host which host is used to run the slave controller; use NULL to
+ *          make the master controller connect to the delegated host
+ * @param sxcfg serialized and compressed configuration
+ * @param sxcfg_size the size scfg
+ * @param scfg_size the size of uncompressed serialized configuration
+ * @param is_subordinate GNUNET_YES if the controller at delegated_host should
+ *          be started by the master controller; GNUNET_NO if we are just
+ *          allowed to use the slave via TCP/IP
+ */
+void
+GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master,
+                                 struct GNUNET_TESTBED_Host *delegated_host,
+                                 struct GNUNET_TESTBED_Host *slave_host,
+                                 const char *sxcfg,
+                                 size_t sxcfg_size,
+                                 size_t scfg_size,
+                                 int is_subordinate); 
+
+
 /**
  * Create the given peer at the specified host using the given
  * controller.  If the given controller is not running on the target
@@ -785,7 +909,6 @@ GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
                                           ...);
 
 
-
 /**
  * Ask the testbed controller to write the current overlay topology to
  * a file.  Naturally, the file will only contain a snapshot as the