summaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_hosts.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api_hosts.c')
-rw-r--r--src/testbed/testbed_api_hosts.c332
1 files changed, 182 insertions, 150 deletions
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 6dbd99bc9..e824a5f23 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -42,31 +42,39 @@
/**
* Generic logging shorthand
*/
-#define LOG(kind, ...) \
- GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__);
+#define LOG(kind, ...) GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__);
/**
* Debug logging shorthand
*/
-#define LOG_DEBUG(...) \
- LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);
+#define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);
/**
* Prints API violation message
*/
-#define API_VIOLATION(cond,errstr) \
- do { \
- if (cond) \
- break; \
+#define API_VIOLATION(cond, errstr) \
+ do \
+ { \
+ if (cond) \
+ break; \
LOG (GNUNET_ERROR_TYPE_ERROR, "API violation detected: %s\n", errstr); \
- GNUNET_assert (0); \
+ GNUNET_assert (0); \
} while (0)
/**
* Log an error message at log-level 'level' that indicates a failure of the
* command 'cmd' with the message given by gai_strerror(rc).
*/
-#define LOG_GAI(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gai_strerror(rc)); } while(0)
+#define LOG_GAI(level, cmd, rc) \
+ do \
+ { \
+ LOG (level, \
+ _ ("`%s' failed at %s:%d with error: %s\n"), \
+ cmd, \
+ __FILE__, \
+ __LINE__, \
+ gai_strerror (rc)); \
+ } while (0)
/**
* Number of extra elements we create space for when we grow host list
@@ -157,7 +165,6 @@ struct GNUNET_TESTBED_Host
* The port which is to be used for SSH
*/
uint16_t port;
-
};
@@ -201,8 +208,9 @@ GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id)
* @return handle to the host, NULL on error
*/
struct GNUNET_TESTBED_Host *
-GNUNET_TESTBED_host_create_by_id_ (uint32_t id,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+GNUNET_TESTBED_host_create_by_id_ (
+ uint32_t id,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
return GNUNET_TESTBED_host_create_with_id (id, NULL, NULL, cfg, 0);
}
@@ -216,7 +224,7 @@ GNUNET_TESTBED_host_create_by_id_ (uint32_t id,
* 'localhost', but then obviously not globally unique)
*/
uint32_t
-GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host * host)
+GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host)
{
return host->id;
}
@@ -255,7 +263,7 @@ GNUNET_TESTBED_host_get_username_ (const struct GNUNET_TESTBED_Host *host)
* @return username to login to the host
*/
uint16_t
-GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host * host)
+GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host)
{
return host->port;
}
@@ -294,8 +302,9 @@ GNUNET_TESTBED_host_get_cfg_ (const struct GNUNET_TESTBED_Host *host)
* @param new_cfg the new configuration to replace the old one
*/
void
-GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host,
- const struct GNUNET_CONFIGURATION_Handle *new_cfg)
+GNUNET_TESTBED_host_replace_cfg_ (
+ struct GNUNET_TESTBED_Host *host,
+ const struct GNUNET_CONFIGURATION_Handle *new_cfg)
{
GNUNET_CONFIGURATION_destroy (host->cfg);
host->cfg = GNUNET_CONFIGURATION_dup (new_cfg);
@@ -316,11 +325,12 @@ GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host,
* @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,
- const struct GNUNET_CONFIGURATION_Handle
- *cfg,
- uint16_t port)
+GNUNET_TESTBED_host_create_with_id (
+ uint32_t id,
+ const char *hostname,
+ const char *username,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ uint16_t port)
{
struct GNUNET_TESTBED_Host *host;
unsigned int new_size;
@@ -337,8 +347,8 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname,
host->port = (0 == port) ? 22 : port;
host->cfg = GNUNET_CONFIGURATION_dup (cfg);
host->opq_parallel_overlay_connect_operations =
- GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_ADAPTIVE,
- UINT_MAX);
+ GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_ADAPTIVE,
+ UINT_MAX);
new_size = host_list_size;
while (id >= new_size)
new_size += HOST_LIST_GROW_STEP;
@@ -363,17 +373,24 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname,
* @return handle to the host, NULL on error
*/
struct GNUNET_TESTBED_Host *
-GNUNET_TESTBED_host_create (const char *hostname, const char *username,
+GNUNET_TESTBED_host_create (const char *hostname,
+ const char *username,
const struct GNUNET_CONFIGURATION_Handle *cfg,
uint16_t port)
{
static uint32_t uid_generator;
if (NULL == hostname)
- return GNUNET_TESTBED_host_create_with_id (0, hostname, username,
- cfg, port);
- return GNUNET_TESTBED_host_create_with_id (++uid_generator, hostname,
- username, cfg, port);
+ return GNUNET_TESTBED_host_create_with_id (0,
+ hostname,
+ username,
+ cfg,
+ port);
+ return GNUNET_TESTBED_host_create_with_id (++uid_generator,
+ hostname,
+ username,
+ cfg,
+ port);
}
@@ -389,10 +406,10 @@ GNUNET_TESTBED_host_create (const char *hostname, const char *username,
* @return number of hosts returned in 'hosts', 0 on error
*/
unsigned int
-GNUNET_TESTBED_hosts_load_from_file (const char *filename,
- const struct GNUNET_CONFIGURATION_Handle
- *cfg,
- struct GNUNET_TESTBED_Host ***hosts)
+GNUNET_TESTBED_hosts_load_from_file (
+ const char *filename,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTBED_Host ***hosts)
{
struct GNUNET_TESTBED_Host *starting_host;
char *data;
@@ -410,7 +427,7 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
GNUNET_assert (NULL != filename);
if (GNUNET_YES != GNUNET_DISK_file_test (filename))
{
- LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s not found\n"), filename);
+ LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Hosts file %s not found\n"), filename);
return 0;
}
if (GNUNET_OK !=
@@ -418,14 +435,17 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
fs = 0;
if (0 == fs)
{
- LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s has no data\n"), filename);
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _ ("Hosts file %s has no data\n"),
+ filename);
return 0;
}
data = GNUNET_malloc (fs);
if (fs != GNUNET_DISK_fn_read (filename, data, fs))
{
GNUNET_free (data);
- LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s cannot be read\n"),
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _ ("Hosts file %s cannot be read\n"),
filename);
return 0;
}
@@ -450,11 +470,12 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
username = NULL;
hostname = NULL;
port = 0;
- if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0))
- || (-1 == pmatch[3].rm_so))
+ if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0)) ||
+ (-1 == pmatch[3].rm_so))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Error reading line `%s' in hostfile\n", buf);
+ "Error reading line `%s' in hostfile\n",
+ buf);
buf = &data[offset + 1];
continue;
}
@@ -462,19 +483,17 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
{
size = pmatch[2].rm_eo - pmatch[2].rm_so;
username = GNUNET_malloc (size + 1);
- GNUNET_assert(0 != GNUNET_strlcpy (username,
- buf + pmatch[2].rm_so,
- size + 1));
+ GNUNET_assert (
+ 0 != GNUNET_strlcpy (username, buf + pmatch[2].rm_so, size + 1));
}
if (-1 != pmatch[5].rm_so)
{
- (void) SSCANF (buf + pmatch[5].rm_so, "%5hd", &port);
+ (void) sscanf (buf + pmatch[5].rm_so, "%5hd", &port);
}
size = pmatch[3].rm_eo - pmatch[3].rm_so;
hostname = GNUNET_malloc (size + 1);
- GNUNET_assert(0 != GNUNET_strlcpy (hostname,
- buf + pmatch[3].rm_so,
- size + 1));
+ GNUNET_assert (
+ 0 != GNUNET_strlcpy (hostname, buf + pmatch[3].rm_so, size + 1));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Successfully read host %s, port %d and user %s from file\n",
(NULL == hostname) ? "NULL" : hostname,
@@ -483,8 +502,8 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
/* We store hosts in a static list; hence we only require the starting
* host pointer in that list to access the newly created list of hosts */
if (NULL == starting_host)
- starting_host = GNUNET_TESTBED_host_create (hostname, username, cfg,
- port);
+ starting_host =
+ GNUNET_TESTBED_host_create (hostname, username, cfg, port);
else
(void) GNUNET_TESTBED_host_create (hostname, username, cfg, port);
count++;
@@ -522,7 +541,7 @@ simple_resolve (const char *host)
struct addrinfo hint;
unsigned int rc;
- hint.ai_family = AF_INET; /* IPv4 */
+ hint.ai_family = AF_INET; /* IPv4 */
hint.ai_socktype = 0;
hint.ai_protocol = 0;
hint.ai_addrlen = 0;
@@ -562,13 +581,13 @@ simple_resolve (const char *host)
* @return number of hosts returned in 'hosts', 0 on error
*/
unsigned int
-GNUNET_TESTBED_hosts_load_from_loadleveler (const struct
- GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTBED_Host ***hosts)
+GNUNET_TESTBED_hosts_load_from_loadleveler (
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTBED_Host ***hosts)
{
-#if !ENABLE_SUPERMUC
+#if ! ENABLE_SUPERMUC
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("The function %s is only available when compiled with (--with-ll)\n"),
+ _ ("The function %s is only available when compiled with (--with-ll)\n"),
__func__);
GNUNET_assert (0);
#else
@@ -607,8 +626,8 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
}
GNUNET_free_non_null ((char *) host->username);
GNUNET_free_non_null ((char *) host->hostname);
- GNUNET_TESTBED_operation_queue_destroy_
- (host->opq_parallel_overlay_connect_operations);
+ GNUNET_TESTBED_operation_queue_destroy_ (
+ host->opq_parallel_overlay_connect_operations);
GNUNET_CONFIGURATION_destroy (host->cfg);
GNUNET_free (host);
while (host_list_size >= HOST_LIST_GROW_STEP)
@@ -624,8 +643,8 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
host_list_size -= HOST_LIST_GROW_STEP;
}
host_list =
- GNUNET_realloc (host_list,
- sizeof (struct GNUNET_TESTBED_Host *) * host_list_size);
+ GNUNET_realloc (host_list,
+ sizeof (struct GNUNET_TESTBED_Host *) * host_list_size);
}
@@ -636,15 +655,15 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
* @param controller the controller at which this host is registered
*/
void
-GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
- const struct GNUNET_TESTBED_Controller
- *const controller)
+GNUNET_TESTBED_mark_host_registered_at_ (
+ struct GNUNET_TESTBED_Host *host,
+ const struct GNUNET_TESTBED_Controller *const controller)
{
struct RegisteredController *rc;
for (rc = host->rc_head; NULL != rc; rc = rc->next)
{
- if (controller == rc->controller) /* already registered at controller */
+ if (controller == rc->controller) /* already registered at controller */
{
GNUNET_break (0);
return;
@@ -663,13 +682,13 @@ GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
* @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)
+GNUNET_TESTBED_deregister_host_at_ (
+ struct GNUNET_TESTBED_Host *host,
+ const struct GNUNET_TESTBED_Controller *const controller)
{
struct RegisteredController *rc;
- for (rc = host->rc_head; NULL != rc; rc=rc->next)
+ for (rc = host->rc_head; NULL != rc; rc = rc->next)
if (controller == rc->controller)
break;
if (NULL == rc)
@@ -690,15 +709,15 @@ GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host,
* @return GNUNET_YES if registered; GNUNET_NO if not
*/
int
-GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
- const struct GNUNET_TESTBED_Controller
- *const controller)
+GNUNET_TESTBED_is_host_registered_ (
+ const struct GNUNET_TESTBED_Host *host,
+ const struct GNUNET_TESTBED_Controller *const controller)
{
struct RegisteredController *rc;
for (rc = host->rc_head; NULL != rc; rc = rc->next)
{
- if (controller == rc->controller) /* already registered at controller */
+ if (controller == rc->controller) /* already registered at controller */
{
return GNUNET_YES;
}
@@ -746,7 +765,6 @@ struct GNUNET_TESTBED_ControllerProc
* The message corresponding to send handle
*/
struct GNUNET_MessageHeader *msg;
-
};
@@ -763,7 +781,8 @@ copy_argv (const char *const *argv)
unsigned int argp;
GNUNET_assert (NULL != argv);
- for (argp = 0; NULL != argv[argp]; argp++) ;
+ for (argp = 0; NULL != argv[argp]; argp++)
+ ;
argv_dup = GNUNET_malloc (sizeof (char *) * (argp + 1));
for (argp = 0; NULL != argv[argp]; argp++)
argv_dup[argp] = GNUNET_strdup (argv[argp]);
@@ -836,19 +855,18 @@ free_argv (char **argv)
static char **
gen_rsh_args (const char *port, const char *hostname, const char *username)
{
- static const char *default_ssh_args[] = {
- "ssh",
- "-o",
- "BatchMode=yes",
- "-o",
- "NoHostAuthenticationForLocalhost=yes",
- "-o",
- "StrictHostKeyChecking=no",
- "-o",
- "PasswordAuthentication=no",
- "%h",
- NULL
- };
+ static const char *default_ssh_args[] =
+ {"ssh",
+ "-o",
+ "BatchMode=yes",
+ "-o",
+ "NoHostAuthenticationForLocalhost=yes",
+ "-o",
+ "StrictHostKeyChecking=no",
+ "-o",
+ "PasswordAuthentication=no",
+ "%h",
+ NULL};
char **ssh_args;
char *ssh_cmd;
char *ssh_cmd_cp;
@@ -915,7 +933,7 @@ gen_rsh_args (const char *port, const char *hostname, const char *username)
* @return NULL-terminated args
*/
static char **
-gen_rsh_suffix_args (const char * const *append_args)
+gen_rsh_suffix_args (const char *const *append_args)
{
char **rshell_args;
char *rshell_cmd;
@@ -937,7 +955,9 @@ gen_rsh_suffix_args (const char * const *append_args)
if (NULL != append_args)
{
for (append_cnt = 0; NULL != append_args[append_cnt]; append_cnt++)
- GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (append_args[append_cnt]));
+ GNUNET_array_append (rshell_args,
+ cnt,
+ GNUNET_strdup (append_args[append_cnt]));
}
GNUNET_array_append (rshell_args, cnt, NULL);
return rshell_args;
@@ -957,8 +977,7 @@ gen_rsh_suffix_args (const char * const *append_args)
* @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing
*/
static int
-helper_mst (void *cls,
- const struct GNUNET_MessageHeader *message)
+helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
{
struct GNUNET_TESTBED_ControllerProc *cp = cls;
const struct GNUNET_TESTBED_HelperReply *msg;
@@ -973,27 +992,28 @@ helper_mst (void *cls,
GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY ==
ntohs (msg->header.type));
config_size = (uLongf) ntohs (msg->config_size);
- xconfig_size =
- (uLongf) (ntohs (msg->header.size) -
- sizeof (struct GNUNET_TESTBED_HelperReply));
+ xconfig_size = (uLongf) (ntohs (msg->header.size) -
+ sizeof (struct GNUNET_TESTBED_HelperReply));
config = GNUNET_malloc (config_size);
- GNUNET_assert (Z_OK ==
- uncompress ((Bytef *) config, &config_size,
- (const Bytef *) &msg[1], xconfig_size));
+ GNUNET_assert (Z_OK == uncompress ((Bytef *) config,
+ &config_size,
+ (const Bytef *) &msg[1],
+ xconfig_size));
/* Replace the configuration template present in the host with the
controller's running configuration */
GNUNET_CONFIGURATION_destroy (cp->host->cfg);
cp->host->cfg = GNUNET_CONFIGURATION_create ();
- GNUNET_assert (GNUNET_CONFIGURATION_deserialize
- (cp->host->cfg,
- config,
- config_size,
- NULL));
+ GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->host->cfg,
+ config,
+ config_size,
+ NULL));
GNUNET_free (config);
if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host)))
hostname = "localhost";
/* Change the hostname so that we can connect to it */
- GNUNET_CONFIGURATION_set_value_string (cp->host->cfg, "testbed", "hostname",
+ GNUNET_CONFIGURATION_set_value_string (cp->host->cfg,
+ "testbed",
+ "hostname",
hostname);
cp->host->locked = GNUNET_NO;
cp->host->controller_started = GNUNET_YES;
@@ -1077,24 +1097,27 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
struct GNUNET_TESTBED_HelperInit *msg;
const struct GNUNET_CONFIGURATION_Handle *cfg;
const char *hostname;
- static char *const binary_argv[] = {
- HELPER_TESTBED_BINARY, NULL
- };
+ static char *const binary_argv[] = {HELPER_TESTBED_BINARY, NULL};
GNUNET_assert (NULL != host);
GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
hostname = NULL;
- API_VIOLATION (GNUNET_NO == host->locked,
- "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
+ API_VIOLATION (
+ GNUNET_NO == host->locked,
+ "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()");
host->locked = GNUNET_YES;
- API_VIOLATION (GNUNET_NO == host->controller_started,
- "Attempting to start a controller on a host which is already started a controller");
+ API_VIOLATION (
+ GNUNET_NO == host->controller_started,
+ "Attempting to start a controller on a host which is already started a controller");
cp = GNUNET_new (struct GNUNET_TESTBED_ControllerProc);
if (0 == GNUNET_TESTBED_host_get_id_ (host))
{
- cp->helper =
- GNUNET_HELPER_start (GNUNET_YES, HELPER_TESTBED_BINARY, binary_argv,
- &helper_mst, &helper_exp_cb, cp);
+ cp->helper = GNUNET_HELPER_start (GNUNET_YES,
+ HELPER_TESTBED_BINARY,
+ binary_argv,
+ &helper_mst,
+ &helper_exp_cb,
+ cp);
}
else
{
@@ -1112,16 +1135,18 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
GNUNET_asprintf (&port, "%u", host->port);
LOG_DEBUG ("Starting remote connection to destination %s\n", hostname);
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg, "testbed",
- "HELPER_BINARY_PATH",
- &helper_binary_path_args[0]))
+ GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "testbed",
+ "HELPER_BINARY_PATH",
+ &helper_binary_path_args[0]))
helper_binary_path_args[0] =
- GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
+ GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
helper_binary_path_args[1] = NULL;
rsh_args = gen_rsh_args (port, hostname, username);
- rsh_suffix_args = gen_rsh_suffix_args ((const char **) helper_binary_path_args);
+ rsh_suffix_args =
+ gen_rsh_suffix_args ((const char **) helper_binary_path_args);
cp->helper_argv =
- join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
+ join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
free_argv (rsh_args);
free_argv (rsh_suffix_args);
GNUNET_free (port);
@@ -1129,14 +1154,18 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++)
{
aux = argstr;
- GNUNET_assert (0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt]));
+ GNUNET_assert (
+ 0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt]));
GNUNET_free (aux);
}
LOG_DEBUG ("Helper cmd str: %s\n", argstr);
GNUNET_free (argstr);
- cp->helper =
- GNUNET_HELPER_start (GNUNET_NO, cp->helper_argv[0], cp->helper_argv, &helper_mst,
- &helper_exp_cb, cp);
+ cp->helper = GNUNET_HELPER_start (GNUNET_NO,
+ cp->helper_argv[0],
+ cp->helper_argv,
+ &helper_mst,
+ &helper_exp_cb,
+ cp);
GNUNET_free (helper_binary_path_args[0]);
}
if (NULL == cp->helper)
@@ -1152,7 +1181,7 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip,
msg = GNUNET_TESTBED_create_helper_init_msg_ (trusted_ip, hostname, cfg);
cp->msg = &msg->header;
cp->shandle =
- GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
+ GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
if (NULL == cp->shandle)
{
GNUNET_free (msg);
@@ -1249,14 +1278,13 @@ struct GNUNET_TESTBED_HostHabitableCheckHandle
/**
* Task id for the habitability check task
*/
- struct GNUNET_SCHEDULER_Task * habitability_check_task;
+ struct GNUNET_SCHEDULER_Task *habitability_check_task;
/**
* How long we wait before checking the process status. Should grow
* exponentially
*/
struct GNUNET_TIME_Relative wait_time;
-
};
@@ -1288,7 +1316,7 @@ habitability_check (void *cls)
{
h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time);
h->habitability_check_task =
- GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
+ GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
return;
}
GNUNET_OS_process_destroy (h->auxp);
@@ -1320,11 +1348,11 @@ call_cb:
* GNUNET_TESTBED_is_host_habitable_cancel()
*/
struct GNUNET_TESTBED_HostHabitableCheckHandle *
-GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
- const struct GNUNET_CONFIGURATION_Handle
- *config,
- GNUNET_TESTBED_HostHabitableCallback cb,
- void *cb_cls)
+GNUNET_TESTBED_is_host_habitable (
+ const struct GNUNET_TESTBED_Host *host,
+ const struct GNUNET_CONFIGURATION_Handle *config,
+ GNUNET_TESTBED_HostHabitableCallback cb,
+ void *cb_cls)
{
struct GNUNET_TESTBED_HostHabitableCheckHandle *h;
char **rsh_args;
@@ -1339,11 +1367,11 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
h->host = host;
hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (config, "testbed",
- "HELPER_BINARY_PATH",
- &stat_args[1]))
- stat_args[1] =
- GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
+ GNUNET_CONFIGURATION_get_value_filename (config,
+ "testbed",
+ "HELPER_BINARY_PATH",
+ &stat_args[1]))
+ stat_args[1] = GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
GNUNET_asprintf (&port, "%u", host->port);
rsh_args = gen_rsh_args (port, hostname, host->username);
GNUNET_free (port);
@@ -1352,22 +1380,26 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
stat_args[2] = NULL;
rsh_suffix_args = gen_rsh_suffix_args ((const char **) stat_args);
GNUNET_free (stat_args[1]);
- h->helper_argv = join_argv ((const char **) rsh_args,
- (const char **) rsh_suffix_args);
+ h->helper_argv =
+ join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args);
free_argv (rsh_suffix_args);
free_argv (rsh_args);
- h->auxp =
- GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ERR, NULL,
- NULL, NULL, h->helper_argv[0], h->helper_argv);
+ h->auxp = GNUNET_OS_start_process_vap (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ERR,
+ NULL,
+ NULL,
+ NULL,
+ h->helper_argv[0],
+ h->helper_argv);
if (NULL == h->auxp)
{
- GNUNET_break (0); /* Cannot exec SSH? */
+ GNUNET_break (0); /* Cannot exec SSH? */
GNUNET_free (h);
return NULL;
}
h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time);
h->habitability_check_task =
- GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
+ GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h);
return h;
}
@@ -1378,9 +1410,8 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
* @param handle the habitability check handle
*/
void
-GNUNET_TESTBED_is_host_habitable_cancel (struct
- GNUNET_TESTBED_HostHabitableCheckHandle
- *handle)
+GNUNET_TESTBED_is_host_habitable_cancel (
+ struct GNUNET_TESTBED_HostHabitableCheckHandle *handle)
{
GNUNET_SCHEDULER_cancel (handle->habitability_check_task);
(void) GNUNET_OS_process_kill (handle->auxp, GNUNET_TERM_SIG);
@@ -1427,7 +1458,8 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
hostname = GNUNET_TESTBED_host_get_hostname (host);
if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller))
{
- LOG (GNUNET_ERROR_TYPE_WARNING, "Host hostname: %s already registered\n",
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Host hostname: %s already registered\n",
(NULL == hostname) ? "localhost" : hostname);
return NULL;
}
@@ -1486,8 +1518,8 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
* @param handle the registration handle to cancel
*/
void
-GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle
- *handle)
+GNUNET_TESTBED_cancel_registration (
+ struct GNUNET_TESTBED_HostRegistrationHandle *handle)
{
if (handle != handle->c->rh)
{
@@ -1511,8 +1543,8 @@ void
GNUNET_TESTBED_host_queue_oc_ (struct GNUNET_TESTBED_Host *h,
struct GNUNET_TESTBED_Operation *op)
{
- GNUNET_TESTBED_operation_queue_insert_
- (h->opq_parallel_overlay_connect_operations, op);
+ GNUNET_TESTBED_operation_queue_insert_ (h->opq_parallel_overlay_connect_operations,
+ op);
}