aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_cmd_netjail_start_testbed.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api_cmd_netjail_start_testbed.c')
-rw-r--r--src/testbed/testbed_api_cmd_netjail_start_testbed.c99
1 files changed, 36 insertions, 63 deletions
diff --git a/src/testbed/testbed_api_cmd_netjail_start_testbed.c b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
index db9cf7508..3d1a1d893 100644
--- a/src/testbed/testbed_api_cmd_netjail_start_testbed.c
+++ b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
@@ -30,7 +30,7 @@
30#include "testbed_api_hosts.h" 30#include "testbed_api_hosts.h"
31#include "testbed_helper.h" 31#include "testbed_helper.h"
32 32
33#define NETJAIL_EXEC_SCRIPT "./../testbed/netjail_exec.sh" 33#define NETJAIL_EXEC_SCRIPT "./../testing/netjail_exec.sh"
34 34
35struct HelperMessage; 35struct HelperMessage;
36 36
@@ -87,23 +87,16 @@ struct NetJailState
87 87
88 unsigned int n_msg; 88 unsigned int n_msg;
89 89
90 unsigned int number_of_testbeds_started; 90 unsigned int number_of_testsystems_started;
91 91
92 unsigned int number_of_peers_started; 92 unsigned int number_of_peers_started;
93 93
94 unsigned int number_of_local_test_finished; 94 unsigned int number_of_local_test_finished;
95 95
96 /**
97 * The host where the controller is running
98 */
99 struct GNUNET_TESTBED_Host **host;
100
101 unsigned int n_host;
102
103 char *plugin_name; 96 char *plugin_name;
104}; 97};
105 98
106struct TestbedCount 99struct TestingSystemCount
107{ 100{
108 unsigned int count; 101 unsigned int count;
109 102
@@ -168,14 +161,14 @@ netjail_exec_traits (void *cls,
168 161
169 162
170/** 163/**
171 * Offer handles to testbed helper from trait 164 * Offer handles to testing cmd helper from trait
172 * 165 *
173 * @param cmd command to extract the message from. 166 * @param cmd command to extract the message from.
174 * @param pt pointer to message. 167 * @param pt pointer to message.
175 * @return #GNUNET_OK on success. 168 * @return #GNUNET_OK on success.
176 */ 169 */
177int 170int
178GNUNET_TESTBED_get_trait_helper_handles (const struct 171GNUNET_TESTING_get_trait_helper_handles (const struct
179 GNUNET_TESTING_Command *cmd, 172 GNUNET_TESTING_Command *cmd,
180 struct GNUNET_HELPER_Handle ***helper) 173 struct GNUNET_HELPER_Handle ***helper)
181{ 174{
@@ -186,14 +179,14 @@ GNUNET_TESTBED_get_trait_helper_handles (const struct
186} 179}
187 180
188/** 181/**
189 * Offer handles to testbed helper from trait 182 * Offer messages received via testing cmd helper from trait
190 * 183 *
191 * @param cmd command to extract the message from. 184 * @param cmd command to extract the message from.
192 * @param pt pointer to message. 185 * @param pt pointer to message.
193 * @return #GNUNET_OK on success. 186 * @return #GNUNET_OK on success.
194 */ 187 */
195int 188int
196GNUNET_TESTBED_get_trait_helper_messages (const struct 189GNUNET_TESTING_get_trait_helper_messages (const struct
197 GNUNET_TESTING_Command *cmd, 190 GNUNET_TESTING_Command *cmd,
198 struct HelperMessage *** 191 struct HelperMessage ***
199 hp_messages_head) 192 hp_messages_head)
@@ -216,7 +209,7 @@ GNUNET_TESTBED_get_trait_helper_messages (const struct
216static void 209static void
217clear_msg (void *cls, int result) 210clear_msg (void *cls, int result)
218{ 211{
219 struct TestbedCount *tbc = cls; 212 struct TestingSystemCount *tbc = cls;
220 struct NetJailState *ns = tbc->ns; 213 struct NetJailState *ns = tbc->ns;
221 214
222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 215 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -244,7 +237,7 @@ clear_msg (void *cls, int result)
244static int 237static int
245helper_mst (void *cls, const struct GNUNET_MessageHeader *message) 238helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
246{ 239{
247 struct TestbedCount *tbc = cls; 240 struct TestingSystemCount *tbc = cls;
248 struct NetJailState *ns = tbc->ns; 241 struct NetJailState *ns = tbc->ns;
249 struct HelperMessage *hp_msg; 242 struct HelperMessage *hp_msg;
250 243
@@ -253,10 +246,9 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 246 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
254 "helper_mst tbc->count: %d\n", 247 "helper_mst tbc->count: %d\n",
255 tbc->count); 248 tbc->count);
256 // GNUNET_TESTBED_extract_cfg (host, message);
257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
258 "Received message from helper.\n"); 250 "Received message from helper.\n");
259 ns->number_of_testbeds_started++; 251 ns->number_of_testsystems_started++;
260 } 252 }
261 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs ( 253 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs (
262 message->type)) 254 message->type))
@@ -320,57 +312,38 @@ create_helper_init_msg_ (char *m_char,
320 312
321 313
322static void 314static void
323start_testbed (struct NetJailState *ns, struct 315start_helper (struct NetJailState *ns, struct
324 GNUNET_CONFIGURATION_Handle *config, 316 GNUNET_CONFIGURATION_Handle *config,
325 char *m_char, 317 char *m_char,
326 char *n_char) 318 char *n_char)
327{ 319{
328 // struct GNUNET_CONFIGURATION_Handle *cfg; 320 // struct GNUNET_CONFIGURATION_Handle *cfg;
329 struct GNUNET_CMDS_HelperInit *msg; 321 struct GNUNET_CMDS_HelperInit *msg;
330 struct TestbedCount *tbc; 322 struct TestingSystemCount *tbc;
331 char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, 323 char *const script_argv[] = {NETJAIL_EXEC_SCRIPT,
332 m_char, 324 m_char,
333 n_char, 325 n_char,
334 GNUNET_OS_get_libexec_binary_path(HELPER_CMDS_BINARY), 326 GNUNET_OS_get_libexec_binary_path (
327 HELPER_CMDS_BINARY),
335 ns->global_n, 328 ns->global_n,
336 ns->local_m, 329 ns->local_m,
337 NULL}; 330 NULL};
338 unsigned int m = atoi (m_char); 331 unsigned int m = atoi (m_char);
339 unsigned int n = atoi (n_char); 332 unsigned int n = atoi (n_char);
340 unsigned int helper_check = GNUNET_OS_check_helper_binary (NETJAIL_EXEC_SCRIPT, 333 unsigned int helper_check = GNUNET_OS_check_helper_binary (
341 GNUNET_YES, 334 NETJAIL_EXEC_SCRIPT,
342 NULL); 335 GNUNET_YES,
336 NULL);
343 337
344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 338 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
345 "m: %d n: %d\n", 339 "m: %d n: %d\n",
346 m, 340 m,
347 n); 341 n);
348 342
349 tbc = GNUNET_new (struct TestbedCount); 343 tbc = GNUNET_new (struct TestingSystemCount);
350 tbc->ns = ns; 344 tbc->ns = ns;
351 tbc->count = (n - 1) * atoi (ns->local_m) + m; 345 tbc->count = (n - 1) * atoi (ns->local_m) + m;
352 346
353 // cfg = GNUNET_CONFIGURATION_dup (config);
354
355 // TODO We do not need this?
356 /*GNUNET_array_append (ns->host, ns->n_host,
357 GNUNET_TESTBED_host_create_with_id (tbc->count - 1,
358 NULL,
359 NULL,
360 cfg,
361 0));*/
362
363 /*if ((GNUNET_YES != GNUNET_DISK_file_test ("test_testbed_api.conf")) ||
364 (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (config,
365 "test_testbed_api.conf")))
366 {
367 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
368 _ (
369 "Unreadable or malformed configuration file `%s', exit ...\n"),
370 "test_testbed_api.conf");
371 }*/
372
373
374 347
375 if (GNUNET_NO == helper_check) 348 if (GNUNET_NO == helper_check)
376 { 349 {
@@ -396,13 +369,13 @@ start_testbed (struct NetJailState *ns, struct
396 tbc)); 369 tbc));
397 370
398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 371 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
399 "First using helper %d %d\n", 372 "First using helper %d %d\n",
400 tbc->count - 1, 373 tbc->count - 1,
401 ns->n_helper); 374 ns->n_helper);
402 struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1]; 375 struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1];
403 376
404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
405 "First using helper %d %d %p\n", 378 "First using helper %d %d %p\n",
406 tbc->count - 1, 379 tbc->count - 1,
407 ns->n_helper, 380 ns->n_helper,
408 helper); 381 helper);
@@ -456,9 +429,9 @@ netjail_exec_run (void *cls,
456 { 429 {
457 sprintf (str_n, "%d", i); 430 sprintf (str_n, "%d", i);
458 sprintf (str_m, "%d", j); 431 sprintf (str_m, "%d", j);
459 start_testbed (ns, config, 432 start_helper (ns, config,
460 str_m, 433 str_m,
461 str_n); 434 str_n);
462 } 435 }
463 } 436 }
464} 437}
@@ -475,7 +448,7 @@ netjail_start_finish (void *cls,
475 struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; 448 struct GNUNET_CMDS_ALL_PEERS_STARTED *reply;
476 size_t msg_length; 449 size_t msg_length;
477 struct GNUNET_HELPER_Handle *helper; 450 struct GNUNET_HELPER_Handle *helper;
478 struct TestbedCount *tbc; 451 struct TestingSystemCount *tbc;
479 452
480 if (ns->number_of_local_test_finished == total_number) 453 if (ns->number_of_local_test_finished == total_number)
481 { 454 {
@@ -483,11 +456,11 @@ netjail_start_finish (void *cls,
483 cont (cont_cls); 456 cont (cont_cls);
484 } 457 }
485 458
486 if (ns->number_of_testbeds_started == total_number) 459 if (ns->number_of_testsystems_started == total_number)
487 { 460 {
488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 461 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
489 "All helpers started!\n"); 462 "All helpers started!\n");
490 ns->number_of_testbeds_started = 0; 463 ns->number_of_testsystems_started = 0;
491 } 464 }
492 465
493 if (ns->number_of_peers_started == total_number) 466 if (ns->number_of_peers_started == total_number)
@@ -498,7 +471,7 @@ netjail_start_finish (void *cls,
498 for (int i = 1; i <= atoi (ns->global_n); i++) { 471 for (int i = 1; i <= atoi (ns->global_n); i++) {
499 for (int j = 1; j <= atoi (ns->local_m); j++) 472 for (int j = 1; j <= atoi (ns->local_m); j++)
500 { 473 {
501 tbc = GNUNET_new (struct TestbedCount); 474 tbc = GNUNET_new (struct TestingSystemCount);
502 tbc->ns = ns; 475 tbc->ns = ns;
503 // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. 476 // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone.
504 tbc->count = (i - 1) * atoi (ns->local_m) + j + total_number; 477 tbc->count = (i - 1) * atoi (ns->local_m) + j + total_number;
@@ -544,11 +517,11 @@ netjail_start_finish (void *cls,
544 * @return command. 517 * @return command.
545 */ 518 */
546struct GNUNET_TESTING_Command 519struct GNUNET_TESTING_Command
547GNUNET_TESTBED_cmd_netjail_start_testbed (const char *label, 520GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label,
548 char *local_m, 521 char *local_m,
549 char *global_n, 522 char *global_n,
550 char *plugin_name, 523 char *plugin_name,
551 unsigned int *rv) 524 unsigned int *rv)
552{ 525{
553 struct NetJailState *ns; 526 struct NetJailState *ns;
554 527