/*
This file is part of GNUnet
- (C) 2008--2012 Christian Grothoff (and other contributing authors)
+ (C) 2008--2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
#ifndef NEW_TESTING_API_HOSTS_H
#define NEW_TESTING_API_HOSTS_H
-#include "gnunet_testbed_service.h"
-#include "testbed_helper.h"
-
-
-/**
- * Wrapper around
- */
-struct GNUNET_TESTBED_HelperHandle
-{
- /**
- * The process handle
- */
- struct GNUNET_OS_Process *process;
-
- /**
- * Pipe connecting to stdin of the process.
- */
- struct GNUNET_DISK_PipeHandle *cpipe_in;
-
- /**
- * Pipe from the stdout of the process.
- */
- struct GNUNET_DISK_PipeHandle *cpipe_out;
-
- /**
- * The port number for ssh; used for helpers starting ssh
- */
- char *port;
-
- /**
- * The ssh destination string; used for helpers starting ssh
- */
- char *dst;
-};
+//#include "gnunet_testbed_service.h"
+//#include "testbed_helper.h"
+#include "testbed.h"
/**
* Lookup a host by ID.
- *
+ *
* @param id global host ID assigned to the host; 0 is
* reserved to always mean 'localhost'
* @return handle to the host, NULL on error
* Create a host by ID; given this host handle, we could not
* run peers at the host, but we can talk about the host
* internally.
- *
+ *
* @param id global host ID assigned to the host; 0 is
* reserved to always mean 'localhost'
+ * @param cfg the configuration to use as a template while starting a controller
+ * on this host. Operation queue sizes specific to a host are also
+ * read from this configuration handle
* @return handle to the host, NULL on error
*/
struct GNUNET_TESTBED_Host *
-GNUNET_TESTBED_host_create_by_id_ (uint32_t id);
+GNUNET_TESTBED_host_create_by_id_ (uint32_t id,
+ const struct GNUNET_CONFIGURATION_Handle
+ *cfg);
/**
* Obtain a host's unique global ID.
- *
+ *
* @param host handle to the host, NULL means 'localhost'
* @return id global host ID assigned to the host (0 is
* 'localhost', but then obviously not globally unique)
GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host);
-/**
- * Obtain the host's hostname.
- *
- * @param host handle to the host, NULL means 'localhost'
- * @return hostname of the host
- */
-const char *
-GNUNET_TESTBED_host_get_hostname_ (const struct GNUNET_TESTBED_Host *host);
-
-
/**
* Obtain the host's username
- *
+ *
* @param host handle to the host, NULL means 'localhost'
* @return username to login to the host
*/
/**
* Obtain the host's ssh port
- *
+ *
* @param host handle to the host, NULL means 'localhost'
* @return username to login to the host
*/
/**
- * Opaque wrapper around GNUNET_HELPER_Handle
- */
-struct GNUNET_TESTBED_HelperHandle;
-
-
-/**
- * Run a given helper process at the given host. Communication
- * with the helper will be via GNUnet messages on stdin/stdout.
- * Runs the process via 'ssh' at the specified host, or locally.
- * Essentially an SSH-wrapper around the 'gnunet_helper_lib.h' API.
- *
- * @param host host to use, use "NULL" for localhost
- * @param binary_argv binary name and command-line arguments to give to the binary
- * @return handle to terminate the command, NULL on error
+ * Obtain the host's configuration template
+ *
+ * @param host handle to the host
+ * @return the host's configuration template
*/
-struct GNUNET_TESTBED_HelperHandle *
-GNUNET_TESTBED_host_run_ (const struct GNUNET_TESTBED_Host *host,
- char *const binary_argv[]);
+const struct GNUNET_CONFIGURATION_Handle *
+GNUNET_TESTBED_host_get_cfg_ (const struct GNUNET_TESTBED_Host *host);
/**
- * Stops a helper in the HelperHandle using GNUNET_HELPER_stop
+ * Function to replace host's configuration
*
- * @param handle the handle returned from GNUNET_TESTBED_host_start_
+ * @param host the host handle
+ * @param new_cfg the new configuration to replace the old one
*/
void
-GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle);
+GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host,
+ const struct GNUNET_CONFIGURATION_Handle *new_cfg);
/**
*/
void
GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
- const struct GNUNET_TESTBED_Controller
- *controller);
+ const struct GNUNET_TESTBED_Controller
+ *controller);
+
+
+/**
+ * Unmarks a host registered at a controller
+ *
+ * @param host the host to unmark
+ * @param controller the controller at which this host has to be unmarked
+ */
+void
+GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host,
+ const struct GNUNET_TESTBED_Controller
+ *const controller);
/**
*/
int
GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
- const struct GNUNET_TESTBED_Controller
- *controller);
+ const struct GNUNET_TESTBED_Controller
+ *controller);
/**
- * Creates a helper initialization message. Only for testing.
+ * (re)sets the operation queue for parallel overlay connects
*
- * @param cname the ip address of the controlling host
- * @param cfg the configuration that has to used to start the testbed service
- * thru helper
- * @return the initialization message
+ * @param h the host handle
+ * @param npoc the number of parallel overlay connects - the queue size
*/
-struct GNUNET_TESTBED_HelperInit *
-GNUNET_TESTBED_create_helper_init_msg_ (const char *cname,
- const struct GNUNET_CONFIGURATION_Handle *cfg);
+void
+GNUNET_TESTBED_set_num_parallel_overlay_connects_ (struct
+ GNUNET_TESTBED_Host *h,
+ unsigned int npoc);
+
+/**
+ * Releases a time slot thus making it available for be used again
+ *
+ * @param h the host handle
+ * @param index the index of the the time slot
+ * @param key the key to prove ownership of the timeslot
+ * @return GNUNET_YES if the time slot is successfully removed; GNUNET_NO if the
+ * time slot cannot be removed - this could be because of the index
+ * greater than existing number of time slots or `key' being different
+ */
+int
+GNUNET_TESTBED_release_time_slot_ (struct GNUNET_TESTBED_Host *h,
+ unsigned int index, void *key);
+
+
+/**
+ * Function to update a time slot
+ *
+ * @param h the host handle
+ * @param index the index of the time slot to update
+ * @param key the key to identify ownership of the slot
+ * @param time the new time
+ * @param failed should this reading be treated as coming from a fail event
+ */
+void
+GNUNET_TESTBED_update_time_slot_ (struct GNUNET_TESTBED_Host *h,
+ unsigned int index, void *key,
+ struct GNUNET_TIME_Relative time, int failed);
+
+
+/**
+ * Returns a timing slot which will be exclusively locked
+ *
+ * @param h the host handle
+ * @param key a pointer which is associated to the returned slot; should not be
+ * NULL. It serves as a key to determine the correct owner of the slot
+ * @return the time slot index in the array of time slots in the controller
+ * handle
+ */
+unsigned int
+GNUNET_TESTBED_get_tslot_ (struct GNUNET_TESTBED_Host *h, void *key);
+
+
+/**
+ * Queues the given operation in the queue for parallel overlay connects of the
+ * given host
+ *
+ * @param h the host handle
+ * @param op the operation to queue in the given host's parally overlay connect
+ * queue
+ */
+void
+GNUNET_TESTBED_host_queue_oc_ (struct GNUNET_TESTBED_Host *h,
+ struct GNUNET_TESTBED_Operation *op);
+
+
+/**
+ * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from
+ * controller (testbed service)
+ *
+ * @param c the controller handler
+ * @param msg message received
+ * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * not
+ */
+int
+GNUNET_TESTBED_host_handle_addhostconfirm_ (struct GNUNET_TESTBED_Controller *c,
+ const struct
+ GNUNET_TESTBED_HostConfirmedMessage
+ *msg);
+
+
+/**
+ * Sends termination signal to the controller's helper process
+ *
+ * @param cproc the handle to the controller's helper process
+ */
+void
+GNUNET_TESTBED_controller_kill_ (struct GNUNET_TESTBED_ControllerProc *cproc);
+
+
+/**
+ * Cleans-up the controller's helper process handle
+ *
+ * @param cproc the handle to the controller's helper process
+ */
+void
+GNUNET_TESTBED_controller_destroy_ (struct GNUNET_TESTBED_ControllerProc
+ *cproc);
+
+
+/**
+ * Resolves the hostname of the host to an ip address
+ *
+ * @param host the host whose hostname is to be resolved
+ */
+void
+GNUNET_TESTBED_host_resolve_ (struct GNUNET_TESTBED_Host *host);
#endif