summaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/generate-underlay-topology.c210
-rw-r--r--src/testbed/gnunet-helper-testbed.c2
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c4
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c135
-rw-r--r--src/testbed/testbed_api_hosts.c332
5 files changed, 368 insertions, 315 deletions
diff --git a/src/testbed/generate-underlay-topology.c b/src/testbed/generate-underlay-topology.c
index 1bfbfda50..7857652e0 100644
--- a/src/testbed/generate-underlay-topology.c
+++ b/src/testbed/generate-underlay-topology.c
@@ -30,26 +30,34 @@
#include "testbed_api_topology.h"
#include "sqlite3.h"
-#define LOG(type, ...) \
- GNUNET_log (type, __VA_ARGS__)
+#define LOG(type, ...) GNUNET_log (type, __VA_ARGS__)
-#define LOG_ERROR(...) \
- LOG (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__)
+#define LOG_ERROR(...) LOG (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__)
/**
* Log an error message at log-level 'level' that indicates
* a failure of the command 'cmd' on file 'filename'
* with the message given by strerror(errno).
*/
-#define LOG_SQLITE(db, msg, level, cmd) \
- do { \
- GNUNET_log_from (level, "sqlite", _("`%s' failed at %s:%d with error: %s\n"), \
- cmd, __FILE__,__LINE__, sqlite3_errmsg(db)); \
- if (msg != NULL) \
- GNUNET_asprintf(msg, _("`%s' failed at %s:%u with error: %s"), cmd, \
- __FILE__, __LINE__, sqlite3_errmsg(db)); \
- } while(0)
+#define LOG_SQLITE(db, msg, level, cmd) \
+ do \
+ { \
+ GNUNET_log_from (level, \
+ "sqlite", \
+ _ ("`%s' failed at %s:%d with error: %s\n"), \
+ cmd, \
+ __FILE__, \
+ __LINE__, \
+ sqlite3_errmsg (db)); \
+ if (msg != NULL) \
+ GNUNET_asprintf (msg, \
+ _ ("`%s' failed at %s:%u with error: %s"), \
+ cmd, \
+ __FILE__, \
+ __LINE__, \
+ sqlite3_errmsg (db)); \
+ } while (0)
/**
@@ -97,11 +105,11 @@ link_processor (void *cls,
unsigned int latency,
unsigned int loss)
{
- if ( (SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, A)) ||
- (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, B)) ||
- (SQLITE_OK != sqlite3_bind_int (stmt_insert, 3, bandwidth)) ||
- (SQLITE_OK != sqlite3_bind_int (stmt_insert, 4, latency)) ||
- (SQLITE_OK != sqlite3_bind_int (stmt_insert, 5, loss)) )
+ if ((SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, A)) ||
+ (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, B)) ||
+ (SQLITE_OK != sqlite3_bind_int (stmt_insert, 3, bandwidth)) ||
+ (SQLITE_OK != sqlite3_bind_int (stmt_insert, 4, latency)) ||
+ (SQLITE_OK != sqlite3_bind_int (stmt_insert, 5, loss)))
{
LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int");
return GNUNET_SYSERR;
@@ -111,11 +119,11 @@ link_processor (void *cls,
LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_step");
return GNUNET_SYSERR;
}
- FPRINTF (stdout, "%u -> %u\n", A, B);
+ fprintf (stdout, "%u -> %u\n", A, B);
GNUNET_break (SQLITE_OK == sqlite3_reset (stmt_insert));
//GNUNET_break (SQLITE_OK == sqlite3_clear_bindings (stmt_insert));
- if ( (SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, B)) ||
- (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, A)) )
+ if ((SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, B)) ||
+ (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, A)))
{
LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int");
return GNUNET_SYSERR;
@@ -125,7 +133,7 @@ link_processor (void *cls,
LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_step");
return GNUNET_SYSERR;
}
- FPRINTF (stdout, "%u -> %u\n", B, A);
+ fprintf (stdout, "%u -> %u\n", B, A);
GNUNET_break (SQLITE_OK == sqlite3_reset (stmt_insert));
return GNUNET_OK;
}
@@ -142,31 +150,29 @@ link_processor (void *cls,
static int
setup_db (const char *dbfile)
{
- const char *query_create =
- "CREATE TABLE whitelist ("
- "id INTEGER,"
- "oid INTEGER,"
- "bandwidth INTEGER DEFAULT NULL,"
- "latency INTEGER DEFAULT NULL,"
- "loss INTEGER DEFAULT NULL,"
- " UNIQUE ("
- " id,"
- " oid"
- " ) ON CONFLICT IGNORE"
- ");";
- const char *query_insert =
- "INSERT INTO whitelist("
- " id,"
- " oid,"
- " bandwidth,"
- " latency,"
- " loss"
- ") VALUES ("
- " ?1,"
- " ?2,"
- " ?3,"
- " ?4,"
- " ?5);";
+ const char *query_create = "CREATE TABLE whitelist ("
+ "id INTEGER,"
+ "oid INTEGER,"
+ "bandwidth INTEGER DEFAULT NULL,"
+ "latency INTEGER DEFAULT NULL,"
+ "loss INTEGER DEFAULT NULL,"
+ " UNIQUE ("
+ " id,"
+ " oid"
+ " ) ON CONFLICT IGNORE"
+ ");";
+ const char *query_insert = "INSERT INTO whitelist("
+ " id,"
+ " oid,"
+ " bandwidth,"
+ " latency,"
+ " loss"
+ ") VALUES ("
+ " ?1,"
+ " ?2,"
+ " ?3,"
+ " ?4,"
+ " ?5);";
int ret;
ret = GNUNET_SYSERR;
@@ -178,21 +184,23 @@ setup_db (const char *dbfile)
if (0 != sqlite3_exec (db, query_create, NULL, NULL, NULL))
{
LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec");
- FPRINTF (stderr, "Error: %d. Perhaps the database `%s' already exits.\n",
+ fprintf (stderr,
+ "Error: %d. Perhaps the database `%s' already exits.\n",
sqlite3_errcode (db),
dbfile);
goto err_ret;
}
- GNUNET_break (0 == sqlite3_exec (db, "PRAGMA synchronous = 0;", NULL, NULL, NULL));
- if (SQLITE_OK != sqlite3_prepare_v2 (db, query_insert, -1,
- &stmt_insert, NULL))
+ GNUNET_break (0 ==
+ sqlite3_exec (db, "PRAGMA synchronous = 0;", NULL, NULL, NULL));
+ if (SQLITE_OK !=
+ sqlite3_prepare_v2 (db, query_insert, -1, &stmt_insert, NULL))
{
LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_prepare_v2");
goto err_ret;
}
ret = GNUNET_OK;
- err_ret:
+err_ret:
return ret;
}
@@ -206,7 +214,9 @@ setup_db (const char *dbfile)
* @param cfg the configuration file handle
*/
static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *config)
{
const char *dbfile;
@@ -222,24 +232,24 @@ run (void *cls, char *const *args, const char *cfgfile,
arg_uint2 = 0; /* make compilers happy */
if (NULL == args)
{
- LOG_ERROR (_("Need at least 2 arguments\n"));
+ LOG_ERROR (_ ("Need at least 2 arguments\n"));
return;
}
if (NULL == (dbfile = args[argc++]))
{
- LOG_ERROR (_("Database filename missing\n"));
+ LOG_ERROR (_ ("Database filename missing\n"));
return;
}
if (GNUNET_OK != setup_db (dbfile))
return;
if (NULL == (topology_string = args[argc++]))
{
- LOG_ERROR (_("Topology string missing\n"));
+ LOG_ERROR (_ ("Topology string missing\n"));
return;
}
if (GNUNET_YES != GNUNET_TESTBED_topology_get_ (&topology, topology_string))
{
- LOG_ERROR (_("Invalid topology: %s\n"), topology_string);
+ LOG_ERROR (_ ("Invalid topology: %s\n"), topology_string);
return;
}
arg_str1 = NULL;
@@ -252,13 +262,13 @@ run (void *cls, char *const *args, const char *cfgfile,
case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE:
if (NULL == (value = args[argc++]))
{
- LOG_ERROR (_("An argument is missing for given topology `%s'\n"),
+ LOG_ERROR (_ ("An argument is missing for given topology `%s'\n"),
topology_string);
return;
}
- if (-1 == SSCANF (value, "%u", &arg_uint1))
+ if (-1 == sscanf (value, "%u", &arg_uint1))
{
- LOG_ERROR (_("Invalid argument `%s' given as topology argument\n"),
+ LOG_ERROR (_ ("Invalid argument `%s' given as topology argument\n"),
value);
return;
}
@@ -266,7 +276,7 @@ run (void *cls, char *const *args, const char *cfgfile,
case GNUNET_TESTBED_TOPOLOGY_FROM_FILE:
if (NULL == (arg_str1 = args[argc++]))
{
- LOG_ERROR (_("Filename argument missing for topology `%s'\n"),
+ LOG_ERROR (_ ("Filename argument missing for topology `%s'\n"),
topology_string);
return;
}
@@ -280,13 +290,13 @@ run (void *cls, char *const *args, const char *cfgfile,
case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE:
if (NULL == (value = args[argc++]))
{
- LOG_ERROR (_("Second argument for topology `%s' is missing\n"),
+ LOG_ERROR (_ ("Second argument for topology `%s' is missing\n"),
topology_string);
return;
}
- if (-1 == SSCANF (value, "%u", &arg_uint2))
+ if (-1 == sscanf (value, "%u", &arg_uint2))
{
- LOG_ERROR (_("Invalid argument `%s'; expecting unsigned int\n"), value);
+ LOG_ERROR (_ ("Invalid argument `%s'; expecting unsigned int\n"), value);
return;
}
break;
@@ -301,23 +311,31 @@ run (void *cls, char *const *args, const char *cfgfile,
case GNUNET_TESTBED_TOPOLOGY_STAR:
case GNUNET_TESTBED_TOPOLOGY_CLIQUE:
case GNUNET_TESTBED_TOPOLOGY_2D_TORUS:
- GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL,
+ GNUNET_TESTBED_underlay_construct_ (num_peers,
+ link_processor,
+ NULL,
topology);
break;
case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI:
case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING:
case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD:
- GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL,
+ GNUNET_TESTBED_underlay_construct_ (num_peers,
+ link_processor,
+ NULL,
topology,
arg_uint1);
break;
case GNUNET_TESTBED_TOPOLOGY_FROM_FILE:
- GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL,
+ GNUNET_TESTBED_underlay_construct_ (num_peers,
+ link_processor,
+ NULL,
topology,
arg_str1);
break;
case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE:
- GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL,
+ GNUNET_TESTBED_underlay_construct_ (num_peers,
+ link_processor,
+ NULL,
topology,
arg_uint1,
arg_uint2);
@@ -337,37 +355,41 @@ main (int argc, char *const argv[])
struct GNUNET_GETOPT_CommandLineOption option[] = {
GNUNET_GETOPT_option_uint ('p',
- "num-peers",
- "COUNT",
- gettext_noop ("create COUNT number of peers"),
- &num_peers),
- GNUNET_GETOPT_OPTION_END
- };
+ "num-peers",
+ "COUNT",
+ gettext_noop ("create COUNT number of peers"),
+ &num_peers),
+ GNUNET_GETOPT_OPTION_END};
int ret;
exit_result = GNUNET_SYSERR;
- ret =
- GNUNET_PROGRAM_run (argc, argv, "gnunet-underlay-topology",
- _("Generates SQLite3 database representing a given underlay topology.\n"
- "Usage: gnunet-underlay-topology [OPTIONS] db-filename TOPO [TOPOOPTS]\n"
- "The following options are available for TOPO followed by TOPOOPTS if applicable:\n"
- "\t LINE\n"
- "\t RING\n"
- "\t RANDOM <num_rnd_links>\n"
- "\t SMALL_WORLD <num_rnd_links>\n"
- "\t SMALL_WORLD_RING <num_rnd_links>\n"
- "\t CLIQUE\n"
- "\t 2D_TORUS\n"
- "\t SCALE_FREE <cap> <m>\n"
- "\t FROM_FILE <filename>\n"
- "TOPOOPTS:\n"
- "\t num_rnd_links: The number of random links\n"
- "\t cap: the maximum number of links a node can have\n"
- "\t m: the number of links a node should have while joining the network\n"
- "\t filename: the path of the file which contains topology information\n"
- "NOTE: the format of the above file is descibed here: https://www.gnunet.org/content/topology-file-format\n"),
- option, &run, NULL);
+ ret = GNUNET_PROGRAM_run (
+ argc,
+ argv,
+ "gnunet-underlay-topology",
+ _ (
+ "Generates SQLite3 database representing a given underlay topology.\n"
+ "Usage: gnunet-underlay-topology [OPTIONS] db-filename TOPO [TOPOOPTS]\n"
+ "The following options are available for TOPO followed by TOPOOPTS if applicable:\n"
+ "\t LINE\n"
+ "\t RING\n"
+ "\t RANDOM <num_rnd_links>\n"
+ "\t SMALL_WORLD <num_rnd_links>\n"
+ "\t SMALL_WORLD_RING <num_rnd_links>\n"
+ "\t CLIQUE\n"
+ "\t 2D_TORUS\n"
+ "\t SCALE_FREE <cap> <m>\n"
+ "\t FROM_FILE <filename>\n"
+ "TOPOOPTS:\n"
+ "\t num_rnd_links: The number of random links\n"
+ "\t cap: the maximum number of links a node can have\n"
+ "\t m: the number of links a node should have while joining the network\n"
+ "\t filename: the path of the file which contains topology information\n"
+ "NOTE: the format of the above file is descibed here: https://www.gnunet.org/content/topology-file-format\n"),
+ option,
+ &run,
+ NULL);
if (NULL != stmt_insert)
sqlite3_finalize (stmt_insert);
if (NULL != db)
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c
index 72d7fe16f..a45f8de03 100644
--- a/src/testbed/gnunet-helper-testbed.c
+++ b/src/testbed/gnunet-helper-testbed.c
@@ -267,7 +267,7 @@ child_death_task (void *cls)
GNUNET_OS_process_destroy (testbed);
testbed = NULL;
/* Send SIGTERM to our process group */
- if (0 != PLIBC_KILL (0, GNUNET_TERM_SIG))
+ if (0 != kill (0, GNUNET_TERM_SIG))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal");
GNUNET_SCHEDULER_shutdown (); /* Couldn't send the signal, we shutdown frowning */
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c
index 8c976e13b..1d1d1ce44 100644
--- a/src/testbed/test_testbed_api_3peers_3controllers.c
+++ b/src/testbed/test_testbed_api_3peers_3controllers.c
@@ -853,7 +853,7 @@ host_habitable_cb (void *cls,
hc_handle = NULL;
if (GNUNET_NO == status)
{
- (void) PRINTF ("%s",
+ (void) printf ("%s",
"Unable to run the test as this system is not configured "
"to use password less SSH logins to localhost.\n"
"Skipping test\n");
@@ -895,7 +895,7 @@ run (void *cls, char *const *args, const char *cfgfile,
{
GNUNET_TESTBED_host_destroy (host);
host = NULL;
- (void) PRINTF ("%s",
+ (void) printf ("%s",
"Unable to run the test as this system is not configured "
"to use password less SSH logins to localhost.\n"
"Skipping test\n");
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c
index 181d7d86d..6c1a24f9c 100644
--- a/src/testbed/test_testbed_api_controllerlink.c
+++ b/src/testbed/test_testbed_api_controllerlink.c
@@ -45,14 +45,12 @@
/**
* Generic logging shortcut
*/
-#define LOG(kind,...) \
- GNUNET_log (kind, __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log (kind, __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__)
/**
* Different stages in testing
@@ -294,15 +292,18 @@ static enum Stage result;
/**
* shortcut to exit during failure
*/
-#define FAIL_TEST(cond) do { \
- if (!(cond)) { \
- GNUNET_break(0); \
- if (NULL != abort_task) \
- GNUNET_SCHEDULER_cancel (abort_task); \
- abort_task = NULL; \
- GNUNET_SCHEDULER_shutdown (); \
- return; \
- } \
+#define FAIL_TEST(cond) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_break (0); \
+ if (NULL != abort_task) \
+ GNUNET_SCHEDULER_cancel (abort_task); \
+ abort_task = NULL; \
+ GNUNET_SCHEDULER_shutdown (); \
+ return; \
+ } \
} while (0)
@@ -357,9 +358,7 @@ do_shutdown (void *cls)
static void
do_abort (void *cls)
{
- LOG (GNUNET_ERROR_TYPE_WARNING,
- "Aborting in stage %d\n",
- result);
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Aborting in stage %d\n", result);
abort_task = NULL;
GNUNET_SCHEDULER_shutdown ();
}
@@ -430,9 +429,7 @@ delay_task (void *cls)
* @param emsg NULL if peer is not NULL; else MAY contain the error description
*/
static void
-peer_create_cb (void *cls,
- struct GNUNET_TESTBED_Peer *peer,
- const char *emsg)
+peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
{
FAIL_TEST (NULL != peer);
FAIL_TEST (NULL == emsg);
@@ -455,11 +452,10 @@ peer_create_cb (void *cls,
slave2_peer = peer;
GNUNET_TESTBED_operation_done (op);
op = NULL;
- delay_task_id =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 1),
- &delay_task,
- NULL);
+ delay_task_id = GNUNET_SCHEDULER_add_delayed (
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
+ &delay_task,
+ NULL);
return;
case SLAVE3_STARTED:
result = SLAVE3_PEER_CREATE_SUCCESS;
@@ -500,8 +496,7 @@ check_operation_success (const struct GNUNET_TESTBED_EventInformation *event)
* @param event information about the event
*/
static void
-controller_cb (void *cls,
- const struct GNUNET_TESTBED_EventInformation *event)
+controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
{
switch (result)
{
@@ -558,8 +553,8 @@ controller_cb (void *cls,
result = SLAVE3_PEER_START_SUCCESS;
sleep (1);
LOG_DEBUG ("**************************************\n");
- op = GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, slave2_peer,
- slave3_peer);
+ op =
+ GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, slave2_peer, slave3_peer);
FAIL_TEST (NULL != op);
break;
case SLAVE3_PEER_START_SUCCESS:
@@ -570,10 +565,10 @@ controller_cb (void *cls,
result = SLAVE2_SLAVE3_PEERS_CONNECTED;
GNUNET_TESTBED_operation_done (op);
op = NULL;
- delay_task_id =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 1), &delay_task,
- NULL);
+ delay_task_id = GNUNET_SCHEDULER_add_delayed (
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
+ &delay_task,
+ NULL);
break;
case SLAVE1_PEER_STOP_SUCCESS:
FAIL_TEST (GNUNET_TESTBED_ET_PEER_START == event->type);
@@ -581,8 +576,8 @@ controller_cb (void *cls,
FAIL_TEST (event->details.peer_start.peer == slave2_peer);
GNUNET_TESTBED_operation_done (op);
result = SLAVE2_PEER_START_SUCCESS;
- op = GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, master_peer,
- slave2_peer);
+ op =
+ GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, master_peer, slave2_peer);
break;
case SLAVE2_PEER_START_SUCCESS:
FAIL_TEST (NULL != event);
@@ -592,10 +587,10 @@ controller_cb (void *cls,
result = MASTER_SLAVE2_PEERS_CONNECTED;
GNUNET_TESTBED_operation_done (op);
op = NULL;
- delay_task_id =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 1), &delay_task,
- NULL);
+ delay_task_id = GNUNET_SCHEDULER_add_delayed (
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
+ &delay_task,
+ NULL);
break;
case SLAVE2_SLAVE3_PEERS_CONNECTED:
FAIL_TEST (GNUNET_TESTBED_ET_PEER_STOP == event->type);
@@ -714,7 +709,8 @@ registration_cont (void *cls, const char *emsg)
* GNUNET_TESTBED_controller_stop() shouldn't be called in this case
*/
static void
-status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
+status_cb (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *config,
int status)
{
switch (result)
@@ -726,8 +722,10 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP);
event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT);
event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED);
- mc = GNUNET_TESTBED_controller_connect (host, event_mask,
- &controller_cb, NULL);
+ mc = GNUNET_TESTBED_controller_connect (host,
+ event_mask,
+ &controller_cb,
+ NULL);
FAIL_TEST (NULL != mc);
result = MASTER_STARTED;
op = GNUNET_TESTBED_peer_create (mc, host, cfg, peer_create_cb, NULL);
@@ -759,7 +757,7 @@ host_habitable_cb (void *cls,
hc_handle = NULL;
if (GNUNET_NO == status)
{
- (void) PRINTF ("%s",
+ (void) printf ("%s",
"Unable to run the test as this system is not configured "
"to use password less SSH logins to localhost.\n"
"Skipping test\n");
@@ -769,8 +767,7 @@ host_habitable_cb (void *cls,
result = SKIP;
return;
}
- cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, status_cb,
- NULL);
+ cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, status_cb, NULL);
}
@@ -783,34 +780,35 @@ host_habitable_cb (void *cls,
* @param cfg the configuration file handle
*/
static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *config)
{
cfg = GNUNET_CONFIGURATION_dup (config);
host = GNUNET_TESTBED_host_create (NULL, NULL, cfg, 0);
FAIL_TEST (NULL != host);
- if (NULL ==
- (hc_handle =
- GNUNET_TESTBED_is_host_habitable (host, config, &host_habitable_cb,
- NULL)))
+ if (NULL == (hc_handle = GNUNET_TESTBED_is_host_habitable (host,
+ config,
+ &host_habitable_cb,
+ NULL)))
{
GNUNET_TESTBED_host_destroy (host);
GNUNET_CONFIGURATION_destroy (cfg);
cfg = NULL;
host = NULL;
- (void) PRINTF ("%s",
+ (void) printf ("%s",
"Unable to run the test as this system is not configured "
"to use password less SSH logins to localhost.\n"
"Marking test as successful\n");
result = SKIP;
return;
}
- abort_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
- NULL);
+ abort_task = GNUNET_SCHEDULER_add_delayed (
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5),
+ &do_abort,
+ NULL);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
}
@@ -820,20 +818,21 @@ run (void *cls, char *const *args, const char *cfgfile,
int
main (int argc, char **argv)
{
- char *const argv2[] = { "test_testbed_api_controllerlink",
- "-c", "test_testbed_api.conf",
- NULL
- };
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
+ char *const argv2[] = {"test_testbed_api_controllerlink",
+ "-c",
+ "test_testbed_api.conf",
+ NULL};
+ struct GNUNET_GETOPT_CommandLineOption options[] = {GNUNET_GETOPT_OPTION_END};
int ret;
result = INIT;
- ret =
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_testbed_api_controllerlink", "nohelp", options,
- &run, NULL);
+ ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1,
+ argv2,
+ "test_testbed_api_controllerlink",
+ "nohelp",
+ options,
+ &run,
+ NULL);
if (GNUNET_OK != ret)
return 1;
switch (result)
@@ -841,7 +840,7 @@ main (int argc, char **argv)
case SUCCESS:
return 0;
case SKIP:
- return 77; /* Mark test as skipped */
+ return 77; /* Mark test as skipped */
default:
return 1;
}
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);
}