diff options
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/generate-underlay-topology.c | 210 | ||||
-rw-r--r-- | src/testbed/gnunet-helper-testbed.c | 2 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_3peers_3controllers.c | 4 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_controllerlink.c | 135 | ||||
-rw-r--r-- | src/testbed/testbed_api_hosts.c | 332 |
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 @@ | |||
30 | #include "testbed_api_topology.h" | 30 | #include "testbed_api_topology.h" |
31 | #include "sqlite3.h" | 31 | #include "sqlite3.h" |
32 | 32 | ||
33 | #define LOG(type, ...) \ | 33 | #define LOG(type, ...) GNUNET_log (type, __VA_ARGS__) |
34 | GNUNET_log (type, __VA_ARGS__) | ||
35 | 34 | ||
36 | 35 | ||
37 | #define LOG_ERROR(...) \ | 36 | #define LOG_ERROR(...) LOG (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__) |
38 | LOG (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__) | ||
39 | 37 | ||
40 | /** | 38 | /** |
41 | * Log an error message at log-level 'level' that indicates | 39 | * Log an error message at log-level 'level' that indicates |
42 | * a failure of the command 'cmd' on file 'filename' | 40 | * a failure of the command 'cmd' on file 'filename' |
43 | * with the message given by strerror(errno). | 41 | * with the message given by strerror(errno). |
44 | */ | 42 | */ |
45 | #define LOG_SQLITE(db, msg, level, cmd) \ | 43 | #define LOG_SQLITE(db, msg, level, cmd) \ |
46 | do { \ | 44 | do \ |
47 | GNUNET_log_from (level, "sqlite", _("`%s' failed at %s:%d with error: %s\n"), \ | 45 | { \ |
48 | cmd, __FILE__,__LINE__, sqlite3_errmsg(db)); \ | 46 | GNUNET_log_from (level, \ |
49 | if (msg != NULL) \ | 47 | "sqlite", \ |
50 | GNUNET_asprintf(msg, _("`%s' failed at %s:%u with error: %s"), cmd, \ | 48 | _ ("`%s' failed at %s:%d with error: %s\n"), \ |
51 | __FILE__, __LINE__, sqlite3_errmsg(db)); \ | 49 | cmd, \ |
52 | } while(0) | 50 | __FILE__, \ |
51 | __LINE__, \ | ||
52 | sqlite3_errmsg (db)); \ | ||
53 | if (msg != NULL) \ | ||
54 | GNUNET_asprintf (msg, \ | ||
55 | _ ("`%s' failed at %s:%u with error: %s"), \ | ||
56 | cmd, \ | ||
57 | __FILE__, \ | ||
58 | __LINE__, \ | ||
59 | sqlite3_errmsg (db)); \ | ||
60 | } while (0) | ||
53 | 61 | ||
54 | 62 | ||
55 | /** | 63 | /** |
@@ -97,11 +105,11 @@ link_processor (void *cls, | |||
97 | unsigned int latency, | 105 | unsigned int latency, |
98 | unsigned int loss) | 106 | unsigned int loss) |
99 | { | 107 | { |
100 | if ( (SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, A)) || | 108 | if ((SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, A)) || |
101 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, B)) || | 109 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, B)) || |
102 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 3, bandwidth)) || | 110 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 3, bandwidth)) || |
103 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 4, latency)) || | 111 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 4, latency)) || |
104 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 5, loss)) ) | 112 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 5, loss))) |
105 | { | 113 | { |
106 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int"); | 114 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int"); |
107 | return GNUNET_SYSERR; | 115 | return GNUNET_SYSERR; |
@@ -111,11 +119,11 @@ link_processor (void *cls, | |||
111 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_step"); | 119 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_step"); |
112 | return GNUNET_SYSERR; | 120 | return GNUNET_SYSERR; |
113 | } | 121 | } |
114 | FPRINTF (stdout, "%u -> %u\n", A, B); | 122 | fprintf (stdout, "%u -> %u\n", A, B); |
115 | GNUNET_break (SQLITE_OK == sqlite3_reset (stmt_insert)); | 123 | GNUNET_break (SQLITE_OK == sqlite3_reset (stmt_insert)); |
116 | //GNUNET_break (SQLITE_OK == sqlite3_clear_bindings (stmt_insert)); | 124 | //GNUNET_break (SQLITE_OK == sqlite3_clear_bindings (stmt_insert)); |
117 | if ( (SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, B)) || | 125 | if ((SQLITE_OK != sqlite3_bind_int (stmt_insert, 1, B)) || |
118 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, A)) ) | 126 | (SQLITE_OK != sqlite3_bind_int (stmt_insert, 2, A))) |
119 | { | 127 | { |
120 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int"); | 128 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int"); |
121 | return GNUNET_SYSERR; | 129 | return GNUNET_SYSERR; |
@@ -125,7 +133,7 @@ link_processor (void *cls, | |||
125 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_step"); | 133 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_step"); |
126 | return GNUNET_SYSERR; | 134 | return GNUNET_SYSERR; |
127 | } | 135 | } |
128 | FPRINTF (stdout, "%u -> %u\n", B, A); | 136 | fprintf (stdout, "%u -> %u\n", B, A); |
129 | GNUNET_break (SQLITE_OK == sqlite3_reset (stmt_insert)); | 137 | GNUNET_break (SQLITE_OK == sqlite3_reset (stmt_insert)); |
130 | return GNUNET_OK; | 138 | return GNUNET_OK; |
131 | } | 139 | } |
@@ -142,31 +150,29 @@ link_processor (void *cls, | |||
142 | static int | 150 | static int |
143 | setup_db (const char *dbfile) | 151 | setup_db (const char *dbfile) |
144 | { | 152 | { |
145 | const char *query_create = | 153 | const char *query_create = "CREATE TABLE whitelist (" |
146 | "CREATE TABLE whitelist (" | 154 | "id INTEGER," |
147 | "id INTEGER," | 155 | "oid INTEGER," |
148 | "oid INTEGER," | 156 | "bandwidth INTEGER DEFAULT NULL," |
149 | "bandwidth INTEGER DEFAULT NULL," | 157 | "latency INTEGER DEFAULT NULL," |
150 | "latency INTEGER DEFAULT NULL," | 158 | "loss INTEGER DEFAULT NULL," |
151 | "loss INTEGER DEFAULT NULL," | 159 | " UNIQUE (" |
152 | " UNIQUE (" | 160 | " id," |
153 | " id," | 161 | " oid" |
154 | " oid" | 162 | " ) ON CONFLICT IGNORE" |
155 | " ) ON CONFLICT IGNORE" | 163 | ");"; |
156 | ");"; | 164 | const char *query_insert = "INSERT INTO whitelist(" |
157 | const char *query_insert = | 165 | " id," |
158 | "INSERT INTO whitelist(" | 166 | " oid," |
159 | " id," | 167 | " bandwidth," |
160 | " oid," | 168 | " latency," |
161 | " bandwidth," | 169 | " loss" |
162 | " latency," | 170 | ") VALUES (" |
163 | " loss" | 171 | " ?1," |
164 | ") VALUES (" | 172 | " ?2," |
165 | " ?1," | 173 | " ?3," |
166 | " ?2," | 174 | " ?4," |
167 | " ?3," | 175 | " ?5);"; |
168 | " ?4," | ||
169 | " ?5);"; | ||
170 | int ret; | 176 | int ret; |
171 | 177 | ||
172 | ret = GNUNET_SYSERR; | 178 | ret = GNUNET_SYSERR; |
@@ -178,21 +184,23 @@ setup_db (const char *dbfile) | |||
178 | if (0 != sqlite3_exec (db, query_create, NULL, NULL, NULL)) | 184 | if (0 != sqlite3_exec (db, query_create, NULL, NULL, NULL)) |
179 | { | 185 | { |
180 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec"); | 186 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec"); |
181 | FPRINTF (stderr, "Error: %d. Perhaps the database `%s' already exits.\n", | 187 | fprintf (stderr, |
188 | "Error: %d. Perhaps the database `%s' already exits.\n", | ||
182 | sqlite3_errcode (db), | 189 | sqlite3_errcode (db), |
183 | dbfile); | 190 | dbfile); |
184 | goto err_ret; | 191 | goto err_ret; |
185 | } | 192 | } |
186 | GNUNET_break (0 == sqlite3_exec (db, "PRAGMA synchronous = 0;", NULL, NULL, NULL)); | 193 | GNUNET_break (0 == |
187 | if (SQLITE_OK != sqlite3_prepare_v2 (db, query_insert, -1, | 194 | sqlite3_exec (db, "PRAGMA synchronous = 0;", NULL, NULL, NULL)); |
188 | &stmt_insert, NULL)) | 195 | if (SQLITE_OK != |
196 | sqlite3_prepare_v2 (db, query_insert, -1, &stmt_insert, NULL)) | ||
189 | { | 197 | { |
190 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_prepare_v2"); | 198 | LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_prepare_v2"); |
191 | goto err_ret; | 199 | goto err_ret; |
192 | } | 200 | } |
193 | ret = GNUNET_OK; | 201 | ret = GNUNET_OK; |
194 | 202 | ||
195 | err_ret: | 203 | err_ret: |
196 | return ret; | 204 | return ret; |
197 | } | 205 | } |
198 | 206 | ||
@@ -206,7 +214,9 @@ setup_db (const char *dbfile) | |||
206 | * @param cfg the configuration file handle | 214 | * @param cfg the configuration file handle |
207 | */ | 215 | */ |
208 | static void | 216 | static void |
209 | run (void *cls, char *const *args, const char *cfgfile, | 217 | run (void *cls, |
218 | char *const *args, | ||
219 | const char *cfgfile, | ||
210 | const struct GNUNET_CONFIGURATION_Handle *config) | 220 | const struct GNUNET_CONFIGURATION_Handle *config) |
211 | { | 221 | { |
212 | const char *dbfile; | 222 | const char *dbfile; |
@@ -222,24 +232,24 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
222 | arg_uint2 = 0; /* make compilers happy */ | 232 | arg_uint2 = 0; /* make compilers happy */ |
223 | if (NULL == args) | 233 | if (NULL == args) |
224 | { | 234 | { |
225 | LOG_ERROR (_("Need at least 2 arguments\n")); | 235 | LOG_ERROR (_ ("Need at least 2 arguments\n")); |
226 | return; | 236 | return; |
227 | } | 237 | } |
228 | if (NULL == (dbfile = args[argc++])) | 238 | if (NULL == (dbfile = args[argc++])) |
229 | { | 239 | { |
230 | LOG_ERROR (_("Database filename missing\n")); | 240 | LOG_ERROR (_ ("Database filename missing\n")); |
231 | return; | 241 | return; |
232 | } | 242 | } |
233 | if (GNUNET_OK != setup_db (dbfile)) | 243 | if (GNUNET_OK != setup_db (dbfile)) |
234 | return; | 244 | return; |
235 | if (NULL == (topology_string = args[argc++])) | 245 | if (NULL == (topology_string = args[argc++])) |
236 | { | 246 | { |
237 | LOG_ERROR (_("Topology string missing\n")); | 247 | LOG_ERROR (_ ("Topology string missing\n")); |
238 | return; | 248 | return; |
239 | } | 249 | } |
240 | if (GNUNET_YES != GNUNET_TESTBED_topology_get_ (&topology, topology_string)) | 250 | if (GNUNET_YES != GNUNET_TESTBED_topology_get_ (&topology, topology_string)) |
241 | { | 251 | { |
242 | LOG_ERROR (_("Invalid topology: %s\n"), topology_string); | 252 | LOG_ERROR (_ ("Invalid topology: %s\n"), topology_string); |
243 | return; | 253 | return; |
244 | } | 254 | } |
245 | arg_str1 = NULL; | 255 | arg_str1 = NULL; |
@@ -252,13 +262,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
252 | case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE: | 262 | case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE: |
253 | if (NULL == (value = args[argc++])) | 263 | if (NULL == (value = args[argc++])) |
254 | { | 264 | { |
255 | LOG_ERROR (_("An argument is missing for given topology `%s'\n"), | 265 | LOG_ERROR (_ ("An argument is missing for given topology `%s'\n"), |
256 | topology_string); | 266 | topology_string); |
257 | return; | 267 | return; |
258 | } | 268 | } |
259 | if (-1 == SSCANF (value, "%u", &arg_uint1)) | 269 | if (-1 == sscanf (value, "%u", &arg_uint1)) |
260 | { | 270 | { |
261 | LOG_ERROR (_("Invalid argument `%s' given as topology argument\n"), | 271 | LOG_ERROR (_ ("Invalid argument `%s' given as topology argument\n"), |
262 | value); | 272 | value); |
263 | return; | 273 | return; |
264 | } | 274 | } |
@@ -266,7 +276,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
266 | case GNUNET_TESTBED_TOPOLOGY_FROM_FILE: | 276 | case GNUNET_TESTBED_TOPOLOGY_FROM_FILE: |
267 | if (NULL == (arg_str1 = args[argc++])) | 277 | if (NULL == (arg_str1 = args[argc++])) |
268 | { | 278 | { |
269 | LOG_ERROR (_("Filename argument missing for topology `%s'\n"), | 279 | LOG_ERROR (_ ("Filename argument missing for topology `%s'\n"), |
270 | topology_string); | 280 | topology_string); |
271 | return; | 281 | return; |
272 | } | 282 | } |
@@ -280,13 +290,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
280 | case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE: | 290 | case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE: |
281 | if (NULL == (value = args[argc++])) | 291 | if (NULL == (value = args[argc++])) |
282 | { | 292 | { |
283 | LOG_ERROR (_("Second argument for topology `%s' is missing\n"), | 293 | LOG_ERROR (_ ("Second argument for topology `%s' is missing\n"), |
284 | topology_string); | 294 | topology_string); |
285 | return; | 295 | return; |
286 | } | 296 | } |
287 | if (-1 == SSCANF (value, "%u", &arg_uint2)) | 297 | if (-1 == sscanf (value, "%u", &arg_uint2)) |
288 | { | 298 | { |
289 | LOG_ERROR (_("Invalid argument `%s'; expecting unsigned int\n"), value); | 299 | LOG_ERROR (_ ("Invalid argument `%s'; expecting unsigned int\n"), value); |
290 | return; | 300 | return; |
291 | } | 301 | } |
292 | break; | 302 | break; |
@@ -301,23 +311,31 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
301 | case GNUNET_TESTBED_TOPOLOGY_STAR: | 311 | case GNUNET_TESTBED_TOPOLOGY_STAR: |
302 | case GNUNET_TESTBED_TOPOLOGY_CLIQUE: | 312 | case GNUNET_TESTBED_TOPOLOGY_CLIQUE: |
303 | case GNUNET_TESTBED_TOPOLOGY_2D_TORUS: | 313 | case GNUNET_TESTBED_TOPOLOGY_2D_TORUS: |
304 | GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL, | 314 | GNUNET_TESTBED_underlay_construct_ (num_peers, |
315 | link_processor, | ||
316 | NULL, | ||
305 | topology); | 317 | topology); |
306 | break; | 318 | break; |
307 | case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI: | 319 | case GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI: |
308 | case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING: | 320 | case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING: |
309 | case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD: | 321 | case GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD: |
310 | GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL, | 322 | GNUNET_TESTBED_underlay_construct_ (num_peers, |
323 | link_processor, | ||
324 | NULL, | ||
311 | topology, | 325 | topology, |
312 | arg_uint1); | 326 | arg_uint1); |
313 | break; | 327 | break; |
314 | case GNUNET_TESTBED_TOPOLOGY_FROM_FILE: | 328 | case GNUNET_TESTBED_TOPOLOGY_FROM_FILE: |
315 | GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL, | 329 | GNUNET_TESTBED_underlay_construct_ (num_peers, |
330 | link_processor, | ||
331 | NULL, | ||
316 | topology, | 332 | topology, |
317 | arg_str1); | 333 | arg_str1); |
318 | break; | 334 | break; |
319 | case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE: | 335 | case GNUNET_TESTBED_TOPOLOGY_SCALE_FREE: |
320 | GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL, | 336 | GNUNET_TESTBED_underlay_construct_ (num_peers, |
337 | link_processor, | ||
338 | NULL, | ||
321 | topology, | 339 | topology, |
322 | arg_uint1, | 340 | arg_uint1, |
323 | arg_uint2); | 341 | arg_uint2); |
@@ -337,37 +355,41 @@ main (int argc, char *const argv[]) | |||
337 | struct GNUNET_GETOPT_CommandLineOption option[] = { | 355 | struct GNUNET_GETOPT_CommandLineOption option[] = { |
338 | 356 | ||
339 | GNUNET_GETOPT_option_uint ('p', | 357 | GNUNET_GETOPT_option_uint ('p', |
340 | "num-peers", | 358 | "num-peers", |
341 | "COUNT", | 359 | "COUNT", |
342 | gettext_noop ("create COUNT number of peers"), | 360 | gettext_noop ("create COUNT number of peers"), |
343 | &num_peers), | 361 | &num_peers), |
344 | GNUNET_GETOPT_OPTION_END | 362 | GNUNET_GETOPT_OPTION_END}; |
345 | }; | ||
346 | 363 | ||
347 | int ret; | 364 | int ret; |
348 | 365 | ||
349 | exit_result = GNUNET_SYSERR; | 366 | exit_result = GNUNET_SYSERR; |
350 | ret = | 367 | ret = GNUNET_PROGRAM_run ( |
351 | GNUNET_PROGRAM_run (argc, argv, "gnunet-underlay-topology", | 368 | argc, |
352 | _("Generates SQLite3 database representing a given underlay topology.\n" | 369 | argv, |
353 | "Usage: gnunet-underlay-topology [OPTIONS] db-filename TOPO [TOPOOPTS]\n" | 370 | "gnunet-underlay-topology", |
354 | "The following options are available for TOPO followed by TOPOOPTS if applicable:\n" | 371 | _ ( |
355 | "\t LINE\n" | 372 | "Generates SQLite3 database representing a given underlay topology.\n" |
356 | "\t RING\n" | 373 | "Usage: gnunet-underlay-topology [OPTIONS] db-filename TOPO [TOPOOPTS]\n" |
357 | "\t RANDOM <num_rnd_links>\n" | 374 | "The following options are available for TOPO followed by TOPOOPTS if applicable:\n" |
358 | "\t SMALL_WORLD <num_rnd_links>\n" | 375 | "\t LINE\n" |
359 | "\t SMALL_WORLD_RING <num_rnd_links>\n" | 376 | "\t RING\n" |
360 | "\t CLIQUE\n" | 377 | "\t RANDOM <num_rnd_links>\n" |
361 | "\t 2D_TORUS\n" | 378 | "\t SMALL_WORLD <num_rnd_links>\n" |
362 | "\t SCALE_FREE <cap> <m>\n" | 379 | "\t SMALL_WORLD_RING <num_rnd_links>\n" |
363 | "\t FROM_FILE <filename>\n" | 380 | "\t CLIQUE\n" |
364 | "TOPOOPTS:\n" | 381 | "\t 2D_TORUS\n" |
365 | "\t num_rnd_links: The number of random links\n" | 382 | "\t SCALE_FREE <cap> <m>\n" |
366 | "\t cap: the maximum number of links a node can have\n" | 383 | "\t FROM_FILE <filename>\n" |
367 | "\t m: the number of links a node should have while joining the network\n" | 384 | "TOPOOPTS:\n" |
368 | "\t filename: the path of the file which contains topology information\n" | 385 | "\t num_rnd_links: The number of random links\n" |
369 | "NOTE: the format of the above file is descibed here: https://www.gnunet.org/content/topology-file-format\n"), | 386 | "\t cap: the maximum number of links a node can have\n" |
370 | option, &run, NULL); | 387 | "\t m: the number of links a node should have while joining the network\n" |
388 | "\t filename: the path of the file which contains topology information\n" | ||
389 | "NOTE: the format of the above file is descibed here: https://www.gnunet.org/content/topology-file-format\n"), | ||
390 | option, | ||
391 | &run, | ||
392 | NULL); | ||
371 | if (NULL != stmt_insert) | 393 | if (NULL != stmt_insert) |
372 | sqlite3_finalize (stmt_insert); | 394 | sqlite3_finalize (stmt_insert); |
373 | if (NULL != db) | 395 | 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) | |||
267 | GNUNET_OS_process_destroy (testbed); | 267 | GNUNET_OS_process_destroy (testbed); |
268 | testbed = NULL; | 268 | testbed = NULL; |
269 | /* Send SIGTERM to our process group */ | 269 | /* Send SIGTERM to our process group */ |
270 | if (0 != PLIBC_KILL (0, GNUNET_TERM_SIG)) | 270 | if (0 != kill (0, GNUNET_TERM_SIG)) |
271 | { | 271 | { |
272 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal"); | 272 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal"); |
273 | GNUNET_SCHEDULER_shutdown (); /* Couldn't send the signal, we shutdown frowning */ | 273 | 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, | |||
853 | hc_handle = NULL; | 853 | hc_handle = NULL; |
854 | if (GNUNET_NO == status) | 854 | if (GNUNET_NO == status) |
855 | { | 855 | { |
856 | (void) PRINTF ("%s", | 856 | (void) printf ("%s", |
857 | "Unable to run the test as this system is not configured " | 857 | "Unable to run the test as this system is not configured " |
858 | "to use password less SSH logins to localhost.\n" | 858 | "to use password less SSH logins to localhost.\n" |
859 | "Skipping test\n"); | 859 | "Skipping test\n"); |
@@ -895,7 +895,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
895 | { | 895 | { |
896 | GNUNET_TESTBED_host_destroy (host); | 896 | GNUNET_TESTBED_host_destroy (host); |
897 | host = NULL; | 897 | host = NULL; |
898 | (void) PRINTF ("%s", | 898 | (void) printf ("%s", |
899 | "Unable to run the test as this system is not configured " | 899 | "Unable to run the test as this system is not configured " |
900 | "to use password less SSH logins to localhost.\n" | 900 | "to use password less SSH logins to localhost.\n" |
901 | "Skipping test\n"); | 901 | "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 @@ | |||
45 | /** | 45 | /** |
46 | * Generic logging shortcut | 46 | * Generic logging shortcut |
47 | */ | 47 | */ |
48 | #define LOG(kind,...) \ | 48 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
49 | GNUNET_log (kind, __VA_ARGS__) | ||
50 | 49 | ||
51 | /** | 50 | /** |
52 | * Debug logging shorthand | 51 | * Debug logging shorthand |
53 | */ | 52 | */ |
54 | #define LOG_DEBUG(...) \ | 53 | #define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
55 | LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | ||
56 | 54 | ||
57 | /** | 55 | /** |
58 | * Different stages in testing | 56 | * Different stages in testing |
@@ -294,15 +292,18 @@ static enum Stage result; | |||
294 | /** | 292 | /** |
295 | * shortcut to exit during failure | 293 | * shortcut to exit during failure |
296 | */ | 294 | */ |
297 | #define FAIL_TEST(cond) do { \ | 295 | #define FAIL_TEST(cond) \ |
298 | if (!(cond)) { \ | 296 | do \ |
299 | GNUNET_break(0); \ | 297 | { \ |
300 | if (NULL != abort_task) \ | 298 | if (! (cond)) \ |
301 | GNUNET_SCHEDULER_cancel (abort_task); \ | 299 | { \ |
302 | abort_task = NULL; \ | 300 | GNUNET_break (0); \ |
303 | GNUNET_SCHEDULER_shutdown (); \ | 301 | if (NULL != abort_task) \ |
304 | return; \ | 302 | GNUNET_SCHEDULER_cancel (abort_task); \ |
305 | } \ | 303 | abort_task = NULL; \ |
304 | GNUNET_SCHEDULER_shutdown (); \ | ||
305 | return; \ | ||
306 | } \ | ||
306 | } while (0) | 307 | } while (0) |
307 | 308 | ||
308 | 309 | ||
@@ -357,9 +358,7 @@ do_shutdown (void *cls) | |||
357 | static void | 358 | static void |
358 | do_abort (void *cls) | 359 | do_abort (void *cls) |
359 | { | 360 | { |
360 | LOG (GNUNET_ERROR_TYPE_WARNING, | 361 | LOG (GNUNET_ERROR_TYPE_WARNING, "Aborting in stage %d\n", result); |
361 | "Aborting in stage %d\n", | ||
362 | result); | ||
363 | abort_task = NULL; | 362 | abort_task = NULL; |
364 | GNUNET_SCHEDULER_shutdown (); | 363 | GNUNET_SCHEDULER_shutdown (); |
365 | } | 364 | } |
@@ -430,9 +429,7 @@ delay_task (void *cls) | |||
430 | * @param emsg NULL if peer is not NULL; else MAY contain the error description | 429 | * @param emsg NULL if peer is not NULL; else MAY contain the error description |
431 | */ | 430 | */ |
432 | static void | 431 | static void |
433 | peer_create_cb (void *cls, | 432 | peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) |
434 | struct GNUNET_TESTBED_Peer *peer, | ||
435 | const char *emsg) | ||
436 | { | 433 | { |
437 | FAIL_TEST (NULL != peer); | 434 | FAIL_TEST (NULL != peer); |
438 | FAIL_TEST (NULL == emsg); | 435 | FAIL_TEST (NULL == emsg); |
@@ -455,11 +452,10 @@ peer_create_cb (void *cls, | |||
455 | slave2_peer = peer; | 452 | slave2_peer = peer; |
456 | GNUNET_TESTBED_operation_done (op); | 453 | GNUNET_TESTBED_operation_done (op); |
457 | op = NULL; | 454 | op = NULL; |
458 | delay_task_id = | 455 | delay_task_id = GNUNET_SCHEDULER_add_delayed ( |
459 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 456 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), |
460 | (GNUNET_TIME_UNIT_SECONDS, 1), | 457 | &delay_task, |
461 | &delay_task, | 458 | NULL); |
462 | NULL); | ||
463 | return; | 459 | return; |
464 | case SLAVE3_STARTED: | 460 | case SLAVE3_STARTED: |
465 | result = SLAVE3_PEER_CREATE_SUCCESS; | 461 | result = SLAVE3_PEER_CREATE_SUCCESS; |
@@ -500,8 +496,7 @@ check_operation_success (const struct GNUNET_TESTBED_EventInformation *event) | |||
500 | * @param event information about the event | 496 | * @param event information about the event |
501 | */ | 497 | */ |
502 | static void | 498 | static void |
503 | controller_cb (void *cls, | 499 | controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) |
504 | const struct GNUNET_TESTBED_EventInformation *event) | ||
505 | { | 500 | { |
506 | switch (result) | 501 | switch (result) |
507 | { | 502 | { |
@@ -558,8 +553,8 @@ controller_cb (void *cls, | |||
558 | result = SLAVE3_PEER_START_SUCCESS; | 553 | result = SLAVE3_PEER_START_SUCCESS; |
559 | sleep (1); | 554 | sleep (1); |
560 | LOG_DEBUG ("**************************************\n"); | 555 | LOG_DEBUG ("**************************************\n"); |
561 | op = GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, slave2_peer, | 556 | op = |
562 | slave3_peer); | 557 | GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, slave2_peer, slave3_peer); |
563 | FAIL_TEST (NULL != op); | 558 | FAIL_TEST (NULL != op); |
564 | break; | 559 | break; |
565 | case SLAVE3_PEER_START_SUCCESS: | 560 | case SLAVE3_PEER_START_SUCCESS: |
@@ -570,10 +565,10 @@ controller_cb (void *cls, | |||
570 | result = SLAVE2_SLAVE3_PEERS_CONNECTED; | 565 | result = SLAVE2_SLAVE3_PEERS_CONNECTED; |
571 | GNUNET_TESTBED_operation_done (op); | 566 | GNUNET_TESTBED_operation_done (op); |
572 | op = NULL; | 567 | op = NULL; |
573 | delay_task_id = | 568 | delay_task_id = GNUNET_SCHEDULER_add_delayed ( |
574 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 569 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), |
575 | (GNUNET_TIME_UNIT_SECONDS, 1), &delay_task, | 570 | &delay_task, |
576 | NULL); | 571 | NULL); |
577 | break; | 572 | break; |
578 | case SLAVE1_PEER_STOP_SUCCESS: | 573 | case SLAVE1_PEER_STOP_SUCCESS: |
579 | FAIL_TEST (GNUNET_TESTBED_ET_PEER_START == event->type); | 574 | FAIL_TEST (GNUNET_TESTBED_ET_PEER_START == event->type); |
@@ -581,8 +576,8 @@ controller_cb (void *cls, | |||
581 | FAIL_TEST (event->details.peer_start.peer == slave2_peer); | 576 | FAIL_TEST (event->details.peer_start.peer == slave2_peer); |
582 | GNUNET_TESTBED_operation_done (op); | 577 | GNUNET_TESTBED_operation_done (op); |
583 | result = SLAVE2_PEER_START_SUCCESS; | 578 | result = SLAVE2_PEER_START_SUCCESS; |
584 | op = GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, master_peer, | 579 | op = |
585 | slave2_peer); | 580 | GNUNET_TESTBED_overlay_connect (mc, NULL, NULL, master_peer, slave2_peer); |
586 | break; | 581 | break; |
587 | case SLAVE2_PEER_START_SUCCESS: | 582 | case SLAVE2_PEER_START_SUCCESS: |
588 | FAIL_TEST (NULL != event); | 583 | FAIL_TEST (NULL != event); |
@@ -592,10 +587,10 @@ controller_cb (void *cls, | |||
592 | result = MASTER_SLAVE2_PEERS_CONNECTED; | 587 | result = MASTER_SLAVE2_PEERS_CONNECTED; |
593 | GNUNET_TESTBED_operation_done (op); | 588 | GNUNET_TESTBED_operation_done (op); |
594 | op = NULL; | 589 | op = NULL; |
595 | delay_task_id = | 590 | delay_task_id = GNUNET_SCHEDULER_add_delayed ( |
596 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 591 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), |
597 | (GNUNET_TIME_UNIT_SECONDS, 1), &delay_task, | 592 | &delay_task, |
598 | NULL); | 593 | NULL); |
599 | break; | 594 | break; |
600 | case SLAVE2_SLAVE3_PEERS_CONNECTED: | 595 | case SLAVE2_SLAVE3_PEERS_CONNECTED: |
601 | FAIL_TEST (GNUNET_TESTBED_ET_PEER_STOP == event->type); | 596 | FAIL_TEST (GNUNET_TESTBED_ET_PEER_STOP == event->type); |
@@ -714,7 +709,8 @@ registration_cont (void *cls, const char *emsg) | |||
714 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | 709 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case |
715 | */ | 710 | */ |
716 | static void | 711 | static void |
717 | status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, | 712 | status_cb (void *cls, |
713 | const struct GNUNET_CONFIGURATION_Handle *config, | ||
718 | int status) | 714 | int status) |
719 | { | 715 | { |
720 | switch (result) | 716 | switch (result) |
@@ -726,8 +722,10 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, | |||
726 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); | 722 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); |
727 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); | 723 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); |
728 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 724 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
729 | mc = GNUNET_TESTBED_controller_connect (host, event_mask, | 725 | mc = GNUNET_TESTBED_controller_connect (host, |
730 | &controller_cb, NULL); | 726 | event_mask, |
727 | &controller_cb, | ||
728 | NULL); | ||
731 | FAIL_TEST (NULL != mc); | 729 | FAIL_TEST (NULL != mc); |
732 | result = MASTER_STARTED; | 730 | result = MASTER_STARTED; |
733 | op = GNUNET_TESTBED_peer_create (mc, host, cfg, peer_create_cb, NULL); | 731 | op = GNUNET_TESTBED_peer_create (mc, host, cfg, peer_create_cb, NULL); |
@@ -759,7 +757,7 @@ host_habitable_cb (void *cls, | |||
759 | hc_handle = NULL; | 757 | hc_handle = NULL; |
760 | if (GNUNET_NO == status) | 758 | if (GNUNET_NO == status) |
761 | { | 759 | { |
762 | (void) PRINTF ("%s", | 760 | (void) printf ("%s", |
763 | "Unable to run the test as this system is not configured " | 761 | "Unable to run the test as this system is not configured " |
764 | "to use password less SSH logins to localhost.\n" | 762 | "to use password less SSH logins to localhost.\n" |
765 | "Skipping test\n"); | 763 | "Skipping test\n"); |
@@ -769,8 +767,7 @@ host_habitable_cb (void *cls, | |||
769 | result = SKIP; | 767 | result = SKIP; |
770 | return; | 768 | return; |
771 | } | 769 | } |
772 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, status_cb, | 770 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, status_cb, NULL); |
773 | NULL); | ||
774 | } | 771 | } |
775 | 772 | ||
776 | 773 | ||
@@ -783,34 +780,35 @@ host_habitable_cb (void *cls, | |||
783 | * @param cfg the configuration file handle | 780 | * @param cfg the configuration file handle |
784 | */ | 781 | */ |
785 | static void | 782 | static void |
786 | run (void *cls, char *const *args, const char *cfgfile, | 783 | run (void *cls, |
784 | char *const *args, | ||
785 | const char *cfgfile, | ||
787 | const struct GNUNET_CONFIGURATION_Handle *config) | 786 | const struct GNUNET_CONFIGURATION_Handle *config) |
788 | { | 787 | { |
789 | cfg = GNUNET_CONFIGURATION_dup (config); | 788 | cfg = GNUNET_CONFIGURATION_dup (config); |
790 | host = GNUNET_TESTBED_host_create (NULL, NULL, cfg, 0); | 789 | host = GNUNET_TESTBED_host_create (NULL, NULL, cfg, 0); |
791 | FAIL_TEST (NULL != host); | 790 | FAIL_TEST (NULL != host); |
792 | if (NULL == | 791 | if (NULL == (hc_handle = GNUNET_TESTBED_is_host_habitable (host, |
793 | (hc_handle = | 792 | config, |
794 | GNUNET_TESTBED_is_host_habitable (host, config, &host_habitable_cb, | 793 | &host_habitable_cb, |
795 | NULL))) | 794 | NULL))) |
796 | { | 795 | { |
797 | GNUNET_TESTBED_host_destroy (host); | 796 | GNUNET_TESTBED_host_destroy (host); |
798 | GNUNET_CONFIGURATION_destroy (cfg); | 797 | GNUNET_CONFIGURATION_destroy (cfg); |
799 | cfg = NULL; | 798 | cfg = NULL; |
800 | host = NULL; | 799 | host = NULL; |
801 | (void) PRINTF ("%s", | 800 | (void) printf ("%s", |
802 | "Unable to run the test as this system is not configured " | 801 | "Unable to run the test as this system is not configured " |
803 | "to use password less SSH logins to localhost.\n" | 802 | "to use password less SSH logins to localhost.\n" |
804 | "Marking test as successful\n"); | 803 | "Marking test as successful\n"); |
805 | result = SKIP; | 804 | result = SKIP; |
806 | return; | 805 | return; |
807 | } | 806 | } |
808 | abort_task = | 807 | abort_task = GNUNET_SCHEDULER_add_delayed ( |
809 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 808 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), |
810 | (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, | 809 | &do_abort, |
811 | NULL); | 810 | NULL); |
812 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 811 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
813 | NULL); | ||
814 | } | 812 | } |
815 | 813 | ||
816 | 814 | ||
@@ -820,20 +818,21 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
820 | int | 818 | int |
821 | main (int argc, char **argv) | 819 | main (int argc, char **argv) |
822 | { | 820 | { |
823 | char *const argv2[] = { "test_testbed_api_controllerlink", | 821 | char *const argv2[] = {"test_testbed_api_controllerlink", |
824 | "-c", "test_testbed_api.conf", | 822 | "-c", |
825 | NULL | 823 | "test_testbed_api.conf", |
826 | }; | 824 | NULL}; |
827 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 825 | struct GNUNET_GETOPT_CommandLineOption options[] = {GNUNET_GETOPT_OPTION_END}; |
828 | GNUNET_GETOPT_OPTION_END | ||
829 | }; | ||
830 | int ret; | 826 | int ret; |
831 | 827 | ||
832 | result = INIT; | 828 | result = INIT; |
833 | ret = | 829 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, |
834 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 830 | argv2, |
835 | "test_testbed_api_controllerlink", "nohelp", options, | 831 | "test_testbed_api_controllerlink", |
836 | &run, NULL); | 832 | "nohelp", |
833 | options, | ||
834 | &run, | ||
835 | NULL); | ||
837 | if (GNUNET_OK != ret) | 836 | if (GNUNET_OK != ret) |
838 | return 1; | 837 | return 1; |
839 | switch (result) | 838 | switch (result) |
@@ -841,7 +840,7 @@ main (int argc, char **argv) | |||
841 | case SUCCESS: | 840 | case SUCCESS: |
842 | return 0; | 841 | return 0; |
843 | case SKIP: | 842 | case SKIP: |
844 | return 77; /* Mark test as skipped */ | 843 | return 77; /* Mark test as skipped */ |
845 | default: | 844 | default: |
846 | return 1; | 845 | return 1; |
847 | } | 846 | } |
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 @@ | |||
42 | /** | 42 | /** |
43 | * Generic logging shorthand | 43 | * Generic logging shorthand |
44 | */ | 44 | */ |
45 | #define LOG(kind, ...) \ | 45 | #define LOG(kind, ...) GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__); |
46 | GNUNET_log_from (kind, "testbed-api-hosts", __VA_ARGS__); | ||
47 | 46 | ||
48 | /** | 47 | /** |
49 | * Debug logging shorthand | 48 | * Debug logging shorthand |
50 | */ | 49 | */ |
51 | #define LOG_DEBUG(...) \ | 50 | #define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__); |
52 | LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__); | ||
53 | 51 | ||
54 | /** | 52 | /** |
55 | * Prints API violation message | 53 | * Prints API violation message |
56 | */ | 54 | */ |
57 | #define API_VIOLATION(cond,errstr) \ | 55 | #define API_VIOLATION(cond, errstr) \ |
58 | do { \ | 56 | do \ |
59 | if (cond) \ | 57 | { \ |
60 | break; \ | 58 | if (cond) \ |
59 | break; \ | ||
61 | LOG (GNUNET_ERROR_TYPE_ERROR, "API violation detected: %s\n", errstr); \ | 60 | LOG (GNUNET_ERROR_TYPE_ERROR, "API violation detected: %s\n", errstr); \ |
62 | GNUNET_assert (0); \ | 61 | GNUNET_assert (0); \ |
63 | } while (0) | 62 | } while (0) |
64 | 63 | ||
65 | /** | 64 | /** |
66 | * Log an error message at log-level 'level' that indicates a failure of the | 65 | * Log an error message at log-level 'level' that indicates a failure of the |
67 | * command 'cmd' with the message given by gai_strerror(rc). | 66 | * command 'cmd' with the message given by gai_strerror(rc). |
68 | */ | 67 | */ |
69 | #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) | 68 | #define LOG_GAI(level, cmd, rc) \ |
69 | do \ | ||
70 | { \ | ||
71 | LOG (level, \ | ||
72 | _ ("`%s' failed at %s:%d with error: %s\n"), \ | ||
73 | cmd, \ | ||
74 | __FILE__, \ | ||
75 | __LINE__, \ | ||
76 | gai_strerror (rc)); \ | ||
77 | } while (0) | ||
70 | 78 | ||
71 | /** | 79 | /** |
72 | * Number of extra elements we create space for when we grow host list | 80 | * Number of extra elements we create space for when we grow host list |
@@ -157,7 +165,6 @@ struct GNUNET_TESTBED_Host | |||
157 | * The port which is to be used for SSH | 165 | * The port which is to be used for SSH |
158 | */ | 166 | */ |
159 | uint16_t port; | 167 | uint16_t port; |
160 | |||
161 | }; | 168 | }; |
162 | 169 | ||
163 | 170 | ||
@@ -201,8 +208,9 @@ GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id) | |||
201 | * @return handle to the host, NULL on error | 208 | * @return handle to the host, NULL on error |
202 | */ | 209 | */ |
203 | struct GNUNET_TESTBED_Host * | 210 | struct GNUNET_TESTBED_Host * |
204 | GNUNET_TESTBED_host_create_by_id_ (uint32_t id, | 211 | GNUNET_TESTBED_host_create_by_id_ ( |
205 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 212 | uint32_t id, |
213 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
206 | { | 214 | { |
207 | return GNUNET_TESTBED_host_create_with_id (id, NULL, NULL, cfg, 0); | 215 | return GNUNET_TESTBED_host_create_with_id (id, NULL, NULL, cfg, 0); |
208 | } | 216 | } |
@@ -216,7 +224,7 @@ GNUNET_TESTBED_host_create_by_id_ (uint32_t id, | |||
216 | * 'localhost', but then obviously not globally unique) | 224 | * 'localhost', but then obviously not globally unique) |
217 | */ | 225 | */ |
218 | uint32_t | 226 | uint32_t |
219 | GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host * host) | 227 | GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host) |
220 | { | 228 | { |
221 | return host->id; | 229 | return host->id; |
222 | } | 230 | } |
@@ -255,7 +263,7 @@ GNUNET_TESTBED_host_get_username_ (const struct GNUNET_TESTBED_Host *host) | |||
255 | * @return username to login to the host | 263 | * @return username to login to the host |
256 | */ | 264 | */ |
257 | uint16_t | 265 | uint16_t |
258 | GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host * host) | 266 | GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host) |
259 | { | 267 | { |
260 | return host->port; | 268 | return host->port; |
261 | } | 269 | } |
@@ -294,8 +302,9 @@ GNUNET_TESTBED_host_get_cfg_ (const struct GNUNET_TESTBED_Host *host) | |||
294 | * @param new_cfg the new configuration to replace the old one | 302 | * @param new_cfg the new configuration to replace the old one |
295 | */ | 303 | */ |
296 | void | 304 | void |
297 | GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host, | 305 | GNUNET_TESTBED_host_replace_cfg_ ( |
298 | const struct GNUNET_CONFIGURATION_Handle *new_cfg) | 306 | struct GNUNET_TESTBED_Host *host, |
307 | const struct GNUNET_CONFIGURATION_Handle *new_cfg) | ||
299 | { | 308 | { |
300 | GNUNET_CONFIGURATION_destroy (host->cfg); | 309 | GNUNET_CONFIGURATION_destroy (host->cfg); |
301 | host->cfg = GNUNET_CONFIGURATION_dup (new_cfg); | 310 | host->cfg = GNUNET_CONFIGURATION_dup (new_cfg); |
@@ -316,11 +325,12 @@ GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host, | |||
316 | * @return handle to the host, NULL on error | 325 | * @return handle to the host, NULL on error |
317 | */ | 326 | */ |
318 | struct GNUNET_TESTBED_Host * | 327 | struct GNUNET_TESTBED_Host * |
319 | GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname, | 328 | GNUNET_TESTBED_host_create_with_id ( |
320 | const char *username, | 329 | uint32_t id, |
321 | const struct GNUNET_CONFIGURATION_Handle | 330 | const char *hostname, |
322 | *cfg, | 331 | const char *username, |
323 | uint16_t port) | 332 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
333 | uint16_t port) | ||
324 | { | 334 | { |
325 | struct GNUNET_TESTBED_Host *host; | 335 | struct GNUNET_TESTBED_Host *host; |
326 | unsigned int new_size; | 336 | unsigned int new_size; |
@@ -337,8 +347,8 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname, | |||
337 | host->port = (0 == port) ? 22 : port; | 347 | host->port = (0 == port) ? 22 : port; |
338 | host->cfg = GNUNET_CONFIGURATION_dup (cfg); | 348 | host->cfg = GNUNET_CONFIGURATION_dup (cfg); |
339 | host->opq_parallel_overlay_connect_operations = | 349 | host->opq_parallel_overlay_connect_operations = |
340 | GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_ADAPTIVE, | 350 | GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_ADAPTIVE, |
341 | UINT_MAX); | 351 | UINT_MAX); |
342 | new_size = host_list_size; | 352 | new_size = host_list_size; |
343 | while (id >= new_size) | 353 | while (id >= new_size) |
344 | new_size += HOST_LIST_GROW_STEP; | 354 | new_size += HOST_LIST_GROW_STEP; |
@@ -363,17 +373,24 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname, | |||
363 | * @return handle to the host, NULL on error | 373 | * @return handle to the host, NULL on error |
364 | */ | 374 | */ |
365 | struct GNUNET_TESTBED_Host * | 375 | struct GNUNET_TESTBED_Host * |
366 | GNUNET_TESTBED_host_create (const char *hostname, const char *username, | 376 | GNUNET_TESTBED_host_create (const char *hostname, |
377 | const char *username, | ||
367 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 378 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
368 | uint16_t port) | 379 | uint16_t port) |
369 | { | 380 | { |
370 | static uint32_t uid_generator; | 381 | static uint32_t uid_generator; |
371 | 382 | ||
372 | if (NULL == hostname) | 383 | if (NULL == hostname) |
373 | return GNUNET_TESTBED_host_create_with_id (0, hostname, username, | 384 | return GNUNET_TESTBED_host_create_with_id (0, |
374 | cfg, port); | 385 | hostname, |
375 | return GNUNET_TESTBED_host_create_with_id (++uid_generator, hostname, | 386 | username, |
376 | username, cfg, port); | 387 | cfg, |
388 | port); | ||
389 | return GNUNET_TESTBED_host_create_with_id (++uid_generator, | ||
390 | hostname, | ||
391 | username, | ||
392 | cfg, | ||
393 | port); | ||
377 | } | 394 | } |
378 | 395 | ||
379 | 396 | ||
@@ -389,10 +406,10 @@ GNUNET_TESTBED_host_create (const char *hostname, const char *username, | |||
389 | * @return number of hosts returned in 'hosts', 0 on error | 406 | * @return number of hosts returned in 'hosts', 0 on error |
390 | */ | 407 | */ |
391 | unsigned int | 408 | unsigned int |
392 | GNUNET_TESTBED_hosts_load_from_file (const char *filename, | 409 | GNUNET_TESTBED_hosts_load_from_file ( |
393 | const struct GNUNET_CONFIGURATION_Handle | 410 | const char *filename, |
394 | *cfg, | 411 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
395 | struct GNUNET_TESTBED_Host ***hosts) | 412 | struct GNUNET_TESTBED_Host ***hosts) |
396 | { | 413 | { |
397 | struct GNUNET_TESTBED_Host *starting_host; | 414 | struct GNUNET_TESTBED_Host *starting_host; |
398 | char *data; | 415 | char *data; |
@@ -410,7 +427,7 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename, | |||
410 | GNUNET_assert (NULL != filename); | 427 | GNUNET_assert (NULL != filename); |
411 | if (GNUNET_YES != GNUNET_DISK_file_test (filename)) | 428 | if (GNUNET_YES != GNUNET_DISK_file_test (filename)) |
412 | { | 429 | { |
413 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s not found\n"), filename); | 430 | LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Hosts file %s not found\n"), filename); |
414 | return 0; | 431 | return 0; |
415 | } | 432 | } |
416 | if (GNUNET_OK != | 433 | if (GNUNET_OK != |
@@ -418,14 +435,17 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename, | |||
418 | fs = 0; | 435 | fs = 0; |
419 | if (0 == fs) | 436 | if (0 == fs) |
420 | { | 437 | { |
421 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s has no data\n"), filename); | 438 | LOG (GNUNET_ERROR_TYPE_WARNING, |
439 | _ ("Hosts file %s has no data\n"), | ||
440 | filename); | ||
422 | return 0; | 441 | return 0; |
423 | } | 442 | } |
424 | data = GNUNET_malloc (fs); | 443 | data = GNUNET_malloc (fs); |
425 | if (fs != GNUNET_DISK_fn_read (filename, data, fs)) | 444 | if (fs != GNUNET_DISK_fn_read (filename, data, fs)) |
426 | { | 445 | { |
427 | GNUNET_free (data); | 446 | GNUNET_free (data); |
428 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Hosts file %s cannot be read\n"), | 447 | LOG (GNUNET_ERROR_TYPE_WARNING, |
448 | _ ("Hosts file %s cannot be read\n"), | ||
429 | filename); | 449 | filename); |
430 | return 0; | 450 | return 0; |
431 | } | 451 | } |
@@ -450,11 +470,12 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename, | |||
450 | username = NULL; | 470 | username = NULL; |
451 | hostname = NULL; | 471 | hostname = NULL; |
452 | port = 0; | 472 | port = 0; |
453 | if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0)) | 473 | if ((REG_NOMATCH == regexec (&rex, buf, 6, pmatch, 0)) || |
454 | || (-1 == pmatch[3].rm_so)) | 474 | (-1 == pmatch[3].rm_so)) |
455 | { | 475 | { |
456 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 476 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
457 | "Error reading line `%s' in hostfile\n", buf); | 477 | "Error reading line `%s' in hostfile\n", |
478 | buf); | ||
458 | buf = &data[offset + 1]; | 479 | buf = &data[offset + 1]; |
459 | continue; | 480 | continue; |
460 | } | 481 | } |
@@ -462,19 +483,17 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename, | |||
462 | { | 483 | { |
463 | size = pmatch[2].rm_eo - pmatch[2].rm_so; | 484 | size = pmatch[2].rm_eo - pmatch[2].rm_so; |
464 | username = GNUNET_malloc (size + 1); | 485 | username = GNUNET_malloc (size + 1); |
465 | GNUNET_assert(0 != GNUNET_strlcpy (username, | 486 | GNUNET_assert ( |
466 | buf + pmatch[2].rm_so, | 487 | 0 != GNUNET_strlcpy (username, buf + pmatch[2].rm_so, size + 1)); |
467 | size + 1)); | ||
468 | } | 488 | } |
469 | if (-1 != pmatch[5].rm_so) | 489 | if (-1 != pmatch[5].rm_so) |
470 | { | 490 | { |
471 | (void) SSCANF (buf + pmatch[5].rm_so, "%5hd", &port); | 491 | (void) sscanf (buf + pmatch[5].rm_so, "%5hd", &port); |
472 | } | 492 | } |
473 | size = pmatch[3].rm_eo - pmatch[3].rm_so; | 493 | size = pmatch[3].rm_eo - pmatch[3].rm_so; |
474 | hostname = GNUNET_malloc (size + 1); | 494 | hostname = GNUNET_malloc (size + 1); |
475 | GNUNET_assert(0 != GNUNET_strlcpy (hostname, | 495 | GNUNET_assert ( |
476 | buf + pmatch[3].rm_so, | 496 | 0 != GNUNET_strlcpy (hostname, buf + pmatch[3].rm_so, size + 1)); |
477 | size + 1)); | ||
478 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 497 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
479 | "Successfully read host %s, port %d and user %s from file\n", | 498 | "Successfully read host %s, port %d and user %s from file\n", |
480 | (NULL == hostname) ? "NULL" : hostname, | 499 | (NULL == hostname) ? "NULL" : hostname, |
@@ -483,8 +502,8 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename, | |||
483 | /* We store hosts in a static list; hence we only require the starting | 502 | /* We store hosts in a static list; hence we only require the starting |
484 | * host pointer in that list to access the newly created list of hosts */ | 503 | * host pointer in that list to access the newly created list of hosts */ |
485 | if (NULL == starting_host) | 504 | if (NULL == starting_host) |
486 | starting_host = GNUNET_TESTBED_host_create (hostname, username, cfg, | 505 | starting_host = |
487 | port); | 506 | GNUNET_TESTBED_host_create (hostname, username, cfg, port); |
488 | else | 507 | else |
489 | (void) GNUNET_TESTBED_host_create (hostname, username, cfg, port); | 508 | (void) GNUNET_TESTBED_host_create (hostname, username, cfg, port); |
490 | count++; | 509 | count++; |
@@ -522,7 +541,7 @@ simple_resolve (const char *host) | |||
522 | struct addrinfo hint; | 541 | struct addrinfo hint; |
523 | unsigned int rc; | 542 | unsigned int rc; |
524 | 543 | ||
525 | hint.ai_family = AF_INET; /* IPv4 */ | 544 | hint.ai_family = AF_INET; /* IPv4 */ |
526 | hint.ai_socktype = 0; | 545 | hint.ai_socktype = 0; |
527 | hint.ai_protocol = 0; | 546 | hint.ai_protocol = 0; |
528 | hint.ai_addrlen = 0; | 547 | hint.ai_addrlen = 0; |
@@ -562,13 +581,13 @@ simple_resolve (const char *host) | |||
562 | * @return number of hosts returned in 'hosts', 0 on error | 581 | * @return number of hosts returned in 'hosts', 0 on error |
563 | */ | 582 | */ |
564 | unsigned int | 583 | unsigned int |
565 | GNUNET_TESTBED_hosts_load_from_loadleveler (const struct | 584 | GNUNET_TESTBED_hosts_load_from_loadleveler ( |
566 | GNUNET_CONFIGURATION_Handle *cfg, | 585 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
567 | struct GNUNET_TESTBED_Host ***hosts) | 586 | struct GNUNET_TESTBED_Host ***hosts) |
568 | { | 587 | { |
569 | #if !ENABLE_SUPERMUC | 588 | #if ! ENABLE_SUPERMUC |
570 | LOG (GNUNET_ERROR_TYPE_ERROR, | 589 | LOG (GNUNET_ERROR_TYPE_ERROR, |
571 | _("The function %s is only available when compiled with (--with-ll)\n"), | 590 | _ ("The function %s is only available when compiled with (--with-ll)\n"), |
572 | __func__); | 591 | __func__); |
573 | GNUNET_assert (0); | 592 | GNUNET_assert (0); |
574 | #else | 593 | #else |
@@ -607,8 +626,8 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) | |||
607 | } | 626 | } |
608 | GNUNET_free_non_null ((char *) host->username); | 627 | GNUNET_free_non_null ((char *) host->username); |
609 | GNUNET_free_non_null ((char *) host->hostname); | 628 | GNUNET_free_non_null ((char *) host->hostname); |
610 | GNUNET_TESTBED_operation_queue_destroy_ | 629 | GNUNET_TESTBED_operation_queue_destroy_ ( |
611 | (host->opq_parallel_overlay_connect_operations); | 630 | host->opq_parallel_overlay_connect_operations); |
612 | GNUNET_CONFIGURATION_destroy (host->cfg); | 631 | GNUNET_CONFIGURATION_destroy (host->cfg); |
613 | GNUNET_free (host); | 632 | GNUNET_free (host); |
614 | while (host_list_size >= HOST_LIST_GROW_STEP) | 633 | while (host_list_size >= HOST_LIST_GROW_STEP) |
@@ -624,8 +643,8 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) | |||
624 | host_list_size -= HOST_LIST_GROW_STEP; | 643 | host_list_size -= HOST_LIST_GROW_STEP; |
625 | } | 644 | } |
626 | host_list = | 645 | host_list = |
627 | GNUNET_realloc (host_list, | 646 | GNUNET_realloc (host_list, |
628 | sizeof (struct GNUNET_TESTBED_Host *) * host_list_size); | 647 | sizeof (struct GNUNET_TESTBED_Host *) * host_list_size); |
629 | } | 648 | } |
630 | 649 | ||
631 | 650 | ||
@@ -636,15 +655,15 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) | |||
636 | * @param controller the controller at which this host is registered | 655 | * @param controller the controller at which this host is registered |
637 | */ | 656 | */ |
638 | void | 657 | void |
639 | GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, | 658 | GNUNET_TESTBED_mark_host_registered_at_ ( |
640 | const struct GNUNET_TESTBED_Controller | 659 | struct GNUNET_TESTBED_Host *host, |
641 | *const controller) | 660 | const struct GNUNET_TESTBED_Controller *const controller) |
642 | { | 661 | { |
643 | struct RegisteredController *rc; | 662 | struct RegisteredController *rc; |
644 | 663 | ||
645 | for (rc = host->rc_head; NULL != rc; rc = rc->next) | 664 | for (rc = host->rc_head; NULL != rc; rc = rc->next) |
646 | { | 665 | { |
647 | if (controller == rc->controller) /* already registered at controller */ | 666 | if (controller == rc->controller) /* already registered at controller */ |
648 | { | 667 | { |
649 | GNUNET_break (0); | 668 | GNUNET_break (0); |
650 | return; | 669 | return; |
@@ -663,13 +682,13 @@ GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, | |||
663 | * @param controller the controller at which this host has to be unmarked | 682 | * @param controller the controller at which this host has to be unmarked |
664 | */ | 683 | */ |
665 | void | 684 | void |
666 | GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host, | 685 | GNUNET_TESTBED_deregister_host_at_ ( |
667 | const struct GNUNET_TESTBED_Controller | 686 | struct GNUNET_TESTBED_Host *host, |
668 | *const controller) | 687 | const struct GNUNET_TESTBED_Controller *const controller) |
669 | { | 688 | { |
670 | struct RegisteredController *rc; | 689 | struct RegisteredController *rc; |
671 | 690 | ||
672 | for (rc = host->rc_head; NULL != rc; rc=rc->next) | 691 | for (rc = host->rc_head; NULL != rc; rc = rc->next) |
673 | if (controller == rc->controller) | 692 | if (controller == rc->controller) |
674 | break; | 693 | break; |
675 | if (NULL == rc) | 694 | if (NULL == rc) |
@@ -690,15 +709,15 @@ GNUNET_TESTBED_deregister_host_at_ (struct GNUNET_TESTBED_Host *host, | |||
690 | * @return GNUNET_YES if registered; GNUNET_NO if not | 709 | * @return GNUNET_YES if registered; GNUNET_NO if not |
691 | */ | 710 | */ |
692 | int | 711 | int |
693 | GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host, | 712 | GNUNET_TESTBED_is_host_registered_ ( |
694 | const struct GNUNET_TESTBED_Controller | 713 | const struct GNUNET_TESTBED_Host *host, |
695 | *const controller) | 714 | const struct GNUNET_TESTBED_Controller *const controller) |
696 | { | 715 | { |
697 | struct RegisteredController *rc; | 716 | struct RegisteredController *rc; |
698 | 717 | ||
699 | for (rc = host->rc_head; NULL != rc; rc = rc->next) | 718 | for (rc = host->rc_head; NULL != rc; rc = rc->next) |
700 | { | 719 | { |
701 | if (controller == rc->controller) /* already registered at controller */ | 720 | if (controller == rc->controller) /* already registered at controller */ |
702 | { | 721 | { |
703 | return GNUNET_YES; | 722 | return GNUNET_YES; |
704 | } | 723 | } |
@@ -746,7 +765,6 @@ struct GNUNET_TESTBED_ControllerProc | |||
746 | * The message corresponding to send handle | 765 | * The message corresponding to send handle |
747 | */ | 766 | */ |
748 | struct GNUNET_MessageHeader *msg; | 767 | struct GNUNET_MessageHeader *msg; |
749 | |||
750 | }; | 768 | }; |
751 | 769 | ||
752 | 770 | ||
@@ -763,7 +781,8 @@ copy_argv (const char *const *argv) | |||
763 | unsigned int argp; | 781 | unsigned int argp; |
764 | 782 | ||
765 | GNUNET_assert (NULL != argv); | 783 | GNUNET_assert (NULL != argv); |
766 | for (argp = 0; NULL != argv[argp]; argp++) ; | 784 | for (argp = 0; NULL != argv[argp]; argp++) |
785 | ; | ||
767 | argv_dup = GNUNET_malloc (sizeof (char *) * (argp + 1)); | 786 | argv_dup = GNUNET_malloc (sizeof (char *) * (argp + 1)); |
768 | for (argp = 0; NULL != argv[argp]; argp++) | 787 | for (argp = 0; NULL != argv[argp]; argp++) |
769 | argv_dup[argp] = GNUNET_strdup (argv[argp]); | 788 | argv_dup[argp] = GNUNET_strdup (argv[argp]); |
@@ -836,19 +855,18 @@ free_argv (char **argv) | |||
836 | static char ** | 855 | static char ** |
837 | gen_rsh_args (const char *port, const char *hostname, const char *username) | 856 | gen_rsh_args (const char *port, const char *hostname, const char *username) |
838 | { | 857 | { |
839 | static const char *default_ssh_args[] = { | 858 | static const char *default_ssh_args[] = |
840 | "ssh", | 859 | {"ssh", |
841 | "-o", | 860 | "-o", |
842 | "BatchMode=yes", | 861 | "BatchMode=yes", |
843 | "-o", | 862 | "-o", |
844 | "NoHostAuthenticationForLocalhost=yes", | 863 | "NoHostAuthenticationForLocalhost=yes", |
845 | "-o", | 864 | "-o", |
846 | "StrictHostKeyChecking=no", | 865 | "StrictHostKeyChecking=no", |
847 | "-o", | 866 | "-o", |
848 | "PasswordAuthentication=no", | 867 | "PasswordAuthentication=no", |
849 | "%h", | 868 | "%h", |
850 | NULL | 869 | NULL}; |
851 | }; | ||
852 | char **ssh_args; | 870 | char **ssh_args; |
853 | char *ssh_cmd; | 871 | char *ssh_cmd; |
854 | char *ssh_cmd_cp; | 872 | char *ssh_cmd_cp; |
@@ -915,7 +933,7 @@ gen_rsh_args (const char *port, const char *hostname, const char *username) | |||
915 | * @return NULL-terminated args | 933 | * @return NULL-terminated args |
916 | */ | 934 | */ |
917 | static char ** | 935 | static char ** |
918 | gen_rsh_suffix_args (const char * const *append_args) | 936 | gen_rsh_suffix_args (const char *const *append_args) |
919 | { | 937 | { |
920 | char **rshell_args; | 938 | char **rshell_args; |
921 | char *rshell_cmd; | 939 | char *rshell_cmd; |
@@ -937,7 +955,9 @@ gen_rsh_suffix_args (const char * const *append_args) | |||
937 | if (NULL != append_args) | 955 | if (NULL != append_args) |
938 | { | 956 | { |
939 | for (append_cnt = 0; NULL != append_args[append_cnt]; append_cnt++) | 957 | for (append_cnt = 0; NULL != append_args[append_cnt]; append_cnt++) |
940 | GNUNET_array_append (rshell_args, cnt, GNUNET_strdup (append_args[append_cnt])); | 958 | GNUNET_array_append (rshell_args, |
959 | cnt, | ||
960 | GNUNET_strdup (append_args[append_cnt])); | ||
941 | } | 961 | } |
942 | GNUNET_array_append (rshell_args, cnt, NULL); | 962 | GNUNET_array_append (rshell_args, cnt, NULL); |
943 | return rshell_args; | 963 | return rshell_args; |
@@ -957,8 +977,7 @@ gen_rsh_suffix_args (const char * const *append_args) | |||
957 | * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing | 977 | * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing |
958 | */ | 978 | */ |
959 | static int | 979 | static int |
960 | helper_mst (void *cls, | 980 | helper_mst (void *cls, const struct GNUNET_MessageHeader *message) |
961 | const struct GNUNET_MessageHeader *message) | ||
962 | { | 981 | { |
963 | struct GNUNET_TESTBED_ControllerProc *cp = cls; | 982 | struct GNUNET_TESTBED_ControllerProc *cp = cls; |
964 | const struct GNUNET_TESTBED_HelperReply *msg; | 983 | const struct GNUNET_TESTBED_HelperReply *msg; |
@@ -973,27 +992,28 @@ helper_mst (void *cls, | |||
973 | GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY == | 992 | GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY == |
974 | ntohs (msg->header.type)); | 993 | ntohs (msg->header.type)); |
975 | config_size = (uLongf) ntohs (msg->config_size); | 994 | config_size = (uLongf) ntohs (msg->config_size); |
976 | xconfig_size = | 995 | xconfig_size = (uLongf) (ntohs (msg->header.size) - |
977 | (uLongf) (ntohs (msg->header.size) - | 996 | sizeof (struct GNUNET_TESTBED_HelperReply)); |
978 | sizeof (struct GNUNET_TESTBED_HelperReply)); | ||
979 | config = GNUNET_malloc (config_size); | 997 | config = GNUNET_malloc (config_size); |
980 | GNUNET_assert (Z_OK == | 998 | GNUNET_assert (Z_OK == uncompress ((Bytef *) config, |
981 | uncompress ((Bytef *) config, &config_size, | 999 | &config_size, |
982 | (const Bytef *) &msg[1], xconfig_size)); | 1000 | (const Bytef *) &msg[1], |
1001 | xconfig_size)); | ||
983 | /* Replace the configuration template present in the host with the | 1002 | /* Replace the configuration template present in the host with the |
984 | controller's running configuration */ | 1003 | controller's running configuration */ |
985 | GNUNET_CONFIGURATION_destroy (cp->host->cfg); | 1004 | GNUNET_CONFIGURATION_destroy (cp->host->cfg); |
986 | cp->host->cfg = GNUNET_CONFIGURATION_create (); | 1005 | cp->host->cfg = GNUNET_CONFIGURATION_create (); |
987 | GNUNET_assert (GNUNET_CONFIGURATION_deserialize | 1006 | GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->host->cfg, |
988 | (cp->host->cfg, | 1007 | config, |
989 | config, | 1008 | config_size, |
990 | config_size, | 1009 | NULL)); |
991 | NULL)); | ||
992 | GNUNET_free (config); | 1010 | GNUNET_free (config); |
993 | if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host))) | 1011 | if (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host))) |
994 | hostname = "localhost"; | 1012 | hostname = "localhost"; |
995 | /* Change the hostname so that we can connect to it */ | 1013 | /* Change the hostname so that we can connect to it */ |
996 | GNUNET_CONFIGURATION_set_value_string (cp->host->cfg, "testbed", "hostname", | 1014 | GNUNET_CONFIGURATION_set_value_string (cp->host->cfg, |
1015 | "testbed", | ||
1016 | "hostname", | ||
997 | hostname); | 1017 | hostname); |
998 | cp->host->locked = GNUNET_NO; | 1018 | cp->host->locked = GNUNET_NO; |
999 | cp->host->controller_started = GNUNET_YES; | 1019 | cp->host->controller_started = GNUNET_YES; |
@@ -1077,24 +1097,27 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip, | |||
1077 | struct GNUNET_TESTBED_HelperInit *msg; | 1097 | struct GNUNET_TESTBED_HelperInit *msg; |
1078 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 1098 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
1079 | const char *hostname; | 1099 | const char *hostname; |
1080 | static char *const binary_argv[] = { | 1100 | static char *const binary_argv[] = {HELPER_TESTBED_BINARY, NULL}; |
1081 | HELPER_TESTBED_BINARY, NULL | ||
1082 | }; | ||
1083 | 1101 | ||
1084 | GNUNET_assert (NULL != host); | 1102 | GNUNET_assert (NULL != host); |
1085 | GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host))); | 1103 | GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host))); |
1086 | hostname = NULL; | 1104 | hostname = NULL; |
1087 | API_VIOLATION (GNUNET_NO == host->locked, | 1105 | API_VIOLATION ( |
1088 | "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()"); | 1106 | GNUNET_NO == host->locked, |
1107 | "Host is already locked by a previous call to GNUNET_TESTBED_controller_start()"); | ||
1089 | host->locked = GNUNET_YES; | 1108 | host->locked = GNUNET_YES; |
1090 | API_VIOLATION (GNUNET_NO == host->controller_started, | 1109 | API_VIOLATION ( |
1091 | "Attempting to start a controller on a host which is already started a controller"); | 1110 | GNUNET_NO == host->controller_started, |
1111 | "Attempting to start a controller on a host which is already started a controller"); | ||
1092 | cp = GNUNET_new (struct GNUNET_TESTBED_ControllerProc); | 1112 | cp = GNUNET_new (struct GNUNET_TESTBED_ControllerProc); |
1093 | if (0 == GNUNET_TESTBED_host_get_id_ (host)) | 1113 | if (0 == GNUNET_TESTBED_host_get_id_ (host)) |
1094 | { | 1114 | { |
1095 | cp->helper = | 1115 | cp->helper = GNUNET_HELPER_start (GNUNET_YES, |
1096 | GNUNET_HELPER_start (GNUNET_YES, HELPER_TESTBED_BINARY, binary_argv, | 1116 | HELPER_TESTBED_BINARY, |
1097 | &helper_mst, &helper_exp_cb, cp); | 1117 | binary_argv, |
1118 | &helper_mst, | ||
1119 | &helper_exp_cb, | ||
1120 | cp); | ||
1098 | } | 1121 | } |
1099 | else | 1122 | else |
1100 | { | 1123 | { |
@@ -1112,16 +1135,18 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip, | |||
1112 | GNUNET_asprintf (&port, "%u", host->port); | 1135 | GNUNET_asprintf (&port, "%u", host->port); |
1113 | LOG_DEBUG ("Starting remote connection to destination %s\n", hostname); | 1136 | LOG_DEBUG ("Starting remote connection to destination %s\n", hostname); |
1114 | if (GNUNET_OK != | 1137 | if (GNUNET_OK != |
1115 | GNUNET_CONFIGURATION_get_value_filename (cfg, "testbed", | 1138 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
1116 | "HELPER_BINARY_PATH", | 1139 | "testbed", |
1117 | &helper_binary_path_args[0])) | 1140 | "HELPER_BINARY_PATH", |
1141 | &helper_binary_path_args[0])) | ||
1118 | helper_binary_path_args[0] = | 1142 | helper_binary_path_args[0] = |
1119 | GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY); | 1143 | GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY); |
1120 | helper_binary_path_args[1] = NULL; | 1144 | helper_binary_path_args[1] = NULL; |
1121 | rsh_args = gen_rsh_args (port, hostname, username); | 1145 | rsh_args = gen_rsh_args (port, hostname, username); |
1122 | rsh_suffix_args = gen_rsh_suffix_args ((const char **) helper_binary_path_args); | 1146 | rsh_suffix_args = |
1147 | gen_rsh_suffix_args ((const char **) helper_binary_path_args); | ||
1123 | cp->helper_argv = | 1148 | cp->helper_argv = |
1124 | join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args); | 1149 | join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args); |
1125 | free_argv (rsh_args); | 1150 | free_argv (rsh_args); |
1126 | free_argv (rsh_suffix_args); | 1151 | free_argv (rsh_suffix_args); |
1127 | GNUNET_free (port); | 1152 | GNUNET_free (port); |
@@ -1129,14 +1154,18 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip, | |||
1129 | for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++) | 1154 | for (cnt = 0; NULL != cp->helper_argv[cnt]; cnt++) |
1130 | { | 1155 | { |
1131 | aux = argstr; | 1156 | aux = argstr; |
1132 | GNUNET_assert (0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt])); | 1157 | GNUNET_assert ( |
1158 | 0 < GNUNET_asprintf (&argstr, "%s %s", aux, cp->helper_argv[cnt])); | ||
1133 | GNUNET_free (aux); | 1159 | GNUNET_free (aux); |
1134 | } | 1160 | } |
1135 | LOG_DEBUG ("Helper cmd str: %s\n", argstr); | 1161 | LOG_DEBUG ("Helper cmd str: %s\n", argstr); |
1136 | GNUNET_free (argstr); | 1162 | GNUNET_free (argstr); |
1137 | cp->helper = | 1163 | cp->helper = GNUNET_HELPER_start (GNUNET_NO, |
1138 | GNUNET_HELPER_start (GNUNET_NO, cp->helper_argv[0], cp->helper_argv, &helper_mst, | 1164 | cp->helper_argv[0], |
1139 | &helper_exp_cb, cp); | 1165 | cp->helper_argv, |
1166 | &helper_mst, | ||
1167 | &helper_exp_cb, | ||
1168 | cp); | ||
1140 | GNUNET_free (helper_binary_path_args[0]); | 1169 | GNUNET_free (helper_binary_path_args[0]); |
1141 | } | 1170 | } |
1142 | if (NULL == cp->helper) | 1171 | if (NULL == cp->helper) |
@@ -1152,7 +1181,7 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip, | |||
1152 | msg = GNUNET_TESTBED_create_helper_init_msg_ (trusted_ip, hostname, cfg); | 1181 | msg = GNUNET_TESTBED_create_helper_init_msg_ (trusted_ip, hostname, cfg); |
1153 | cp->msg = &msg->header; | 1182 | cp->msg = &msg->header; |
1154 | cp->shandle = | 1183 | cp->shandle = |
1155 | GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp); | 1184 | GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp); |
1156 | if (NULL == cp->shandle) | 1185 | if (NULL == cp->shandle) |
1157 | { | 1186 | { |
1158 | GNUNET_free (msg); | 1187 | GNUNET_free (msg); |
@@ -1249,14 +1278,13 @@ struct GNUNET_TESTBED_HostHabitableCheckHandle | |||
1249 | /** | 1278 | /** |
1250 | * Task id for the habitability check task | 1279 | * Task id for the habitability check task |
1251 | */ | 1280 | */ |
1252 | struct GNUNET_SCHEDULER_Task * habitability_check_task; | 1281 | struct GNUNET_SCHEDULER_Task *habitability_check_task; |
1253 | 1282 | ||
1254 | /** | 1283 | /** |
1255 | * How long we wait before checking the process status. Should grow | 1284 | * How long we wait before checking the process status. Should grow |
1256 | * exponentially | 1285 | * exponentially |
1257 | */ | 1286 | */ |
1258 | struct GNUNET_TIME_Relative wait_time; | 1287 | struct GNUNET_TIME_Relative wait_time; |
1259 | |||
1260 | }; | 1288 | }; |
1261 | 1289 | ||
1262 | 1290 | ||
@@ -1288,7 +1316,7 @@ habitability_check (void *cls) | |||
1288 | { | 1316 | { |
1289 | h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time); | 1317 | h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time); |
1290 | h->habitability_check_task = | 1318 | h->habitability_check_task = |
1291 | GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h); | 1319 | GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h); |
1292 | return; | 1320 | return; |
1293 | } | 1321 | } |
1294 | GNUNET_OS_process_destroy (h->auxp); | 1322 | GNUNET_OS_process_destroy (h->auxp); |
@@ -1320,11 +1348,11 @@ call_cb: | |||
1320 | * GNUNET_TESTBED_is_host_habitable_cancel() | 1348 | * GNUNET_TESTBED_is_host_habitable_cancel() |
1321 | */ | 1349 | */ |
1322 | struct GNUNET_TESTBED_HostHabitableCheckHandle * | 1350 | struct GNUNET_TESTBED_HostHabitableCheckHandle * |
1323 | GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host, | 1351 | GNUNET_TESTBED_is_host_habitable ( |
1324 | const struct GNUNET_CONFIGURATION_Handle | 1352 | const struct GNUNET_TESTBED_Host *host, |
1325 | *config, | 1353 | const struct GNUNET_CONFIGURATION_Handle *config, |
1326 | GNUNET_TESTBED_HostHabitableCallback cb, | 1354 | GNUNET_TESTBED_HostHabitableCallback cb, |
1327 | void *cb_cls) | 1355 | void *cb_cls) |
1328 | { | 1356 | { |
1329 | struct GNUNET_TESTBED_HostHabitableCheckHandle *h; | 1357 | struct GNUNET_TESTBED_HostHabitableCheckHandle *h; |
1330 | char **rsh_args; | 1358 | char **rsh_args; |
@@ -1339,11 +1367,11 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host, | |||
1339 | h->host = host; | 1367 | h->host = host; |
1340 | hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname; | 1368 | hostname = (NULL == host->hostname) ? "127.0.0.1" : host->hostname; |
1341 | if (GNUNET_OK != | 1369 | if (GNUNET_OK != |
1342 | GNUNET_CONFIGURATION_get_value_filename (config, "testbed", | 1370 | GNUNET_CONFIGURATION_get_value_filename (config, |
1343 | "HELPER_BINARY_PATH", | 1371 | "testbed", |
1344 | &stat_args[1])) | 1372 | "HELPER_BINARY_PATH", |
1345 | stat_args[1] = | 1373 | &stat_args[1])) |
1346 | GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY); | 1374 | stat_args[1] = GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY); |
1347 | GNUNET_asprintf (&port, "%u", host->port); | 1375 | GNUNET_asprintf (&port, "%u", host->port); |
1348 | rsh_args = gen_rsh_args (port, hostname, host->username); | 1376 | rsh_args = gen_rsh_args (port, hostname, host->username); |
1349 | GNUNET_free (port); | 1377 | GNUNET_free (port); |
@@ -1352,22 +1380,26 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host, | |||
1352 | stat_args[2] = NULL; | 1380 | stat_args[2] = NULL; |
1353 | rsh_suffix_args = gen_rsh_suffix_args ((const char **) stat_args); | 1381 | rsh_suffix_args = gen_rsh_suffix_args ((const char **) stat_args); |
1354 | GNUNET_free (stat_args[1]); | 1382 | GNUNET_free (stat_args[1]); |
1355 | h->helper_argv = join_argv ((const char **) rsh_args, | 1383 | h->helper_argv = |
1356 | (const char **) rsh_suffix_args); | 1384 | join_argv ((const char **) rsh_args, (const char **) rsh_suffix_args); |
1357 | free_argv (rsh_suffix_args); | 1385 | free_argv (rsh_suffix_args); |
1358 | free_argv (rsh_args); | 1386 | free_argv (rsh_args); |
1359 | h->auxp = | 1387 | h->auxp = GNUNET_OS_start_process_vap (GNUNET_NO, |
1360 | GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ERR, NULL, | 1388 | GNUNET_OS_INHERIT_STD_ERR, |
1361 | NULL, NULL, h->helper_argv[0], h->helper_argv); | 1389 | NULL, |
1390 | NULL, | ||
1391 | NULL, | ||
1392 | h->helper_argv[0], | ||
1393 | h->helper_argv); | ||
1362 | if (NULL == h->auxp) | 1394 | if (NULL == h->auxp) |
1363 | { | 1395 | { |
1364 | GNUNET_break (0); /* Cannot exec SSH? */ | 1396 | GNUNET_break (0); /* Cannot exec SSH? */ |
1365 | GNUNET_free (h); | 1397 | GNUNET_free (h); |
1366 | return NULL; | 1398 | return NULL; |
1367 | } | 1399 | } |
1368 | h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time); | 1400 | h->wait_time = GNUNET_TIME_STD_BACKOFF (h->wait_time); |
1369 | h->habitability_check_task = | 1401 | h->habitability_check_task = |
1370 | GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h); | 1402 | GNUNET_SCHEDULER_add_delayed (h->wait_time, &habitability_check, h); |
1371 | return h; | 1403 | return h; |
1372 | } | 1404 | } |
1373 | 1405 | ||
@@ -1378,9 +1410,8 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host, | |||
1378 | * @param handle the habitability check handle | 1410 | * @param handle the habitability check handle |
1379 | */ | 1411 | */ |
1380 | void | 1412 | void |
1381 | GNUNET_TESTBED_is_host_habitable_cancel (struct | 1413 | GNUNET_TESTBED_is_host_habitable_cancel ( |
1382 | GNUNET_TESTBED_HostHabitableCheckHandle | 1414 | struct GNUNET_TESTBED_HostHabitableCheckHandle *handle) |
1383 | *handle) | ||
1384 | { | 1415 | { |
1385 | GNUNET_SCHEDULER_cancel (handle->habitability_check_task); | 1416 | GNUNET_SCHEDULER_cancel (handle->habitability_check_task); |
1386 | (void) GNUNET_OS_process_kill (handle->auxp, GNUNET_TERM_SIG); | 1417 | (void) GNUNET_OS_process_kill (handle->auxp, GNUNET_TERM_SIG); |
@@ -1427,7 +1458,8 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, | |||
1427 | hostname = GNUNET_TESTBED_host_get_hostname (host); | 1458 | hostname = GNUNET_TESTBED_host_get_hostname (host); |
1428 | if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller)) | 1459 | if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller)) |
1429 | { | 1460 | { |
1430 | LOG (GNUNET_ERROR_TYPE_WARNING, "Host hostname: %s already registered\n", | 1461 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1462 | "Host hostname: %s already registered\n", | ||
1431 | (NULL == hostname) ? "localhost" : hostname); | 1463 | (NULL == hostname) ? "localhost" : hostname); |
1432 | return NULL; | 1464 | return NULL; |
1433 | } | 1465 | } |
@@ -1486,8 +1518,8 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, | |||
1486 | * @param handle the registration handle to cancel | 1518 | * @param handle the registration handle to cancel |
1487 | */ | 1519 | */ |
1488 | void | 1520 | void |
1489 | GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle | 1521 | GNUNET_TESTBED_cancel_registration ( |
1490 | *handle) | 1522 | struct GNUNET_TESTBED_HostRegistrationHandle *handle) |
1491 | { | 1523 | { |
1492 | if (handle != handle->c->rh) | 1524 | if (handle != handle->c->rh) |
1493 | { | 1525 | { |
@@ -1511,8 +1543,8 @@ void | |||
1511 | GNUNET_TESTBED_host_queue_oc_ (struct GNUNET_TESTBED_Host *h, | 1543 | GNUNET_TESTBED_host_queue_oc_ (struct GNUNET_TESTBED_Host *h, |
1512 | struct GNUNET_TESTBED_Operation *op) | 1544 | struct GNUNET_TESTBED_Operation *op) |
1513 | { | 1545 | { |
1514 | GNUNET_TESTBED_operation_queue_insert_ | 1546 | GNUNET_TESTBED_operation_queue_insert_ (h->opq_parallel_overlay_connect_operations, |
1515 | (h->opq_parallel_overlay_connect_operations, op); | 1547 | op); |
1516 | } | 1548 | } |
1517 | 1549 | ||
1518 | 1550 | ||