aboutsummaryrefslogtreecommitdiff
path: root/src/testing/gnunet-cmds-helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/gnunet-cmds-helper.c')
-rw-r--r--src/testing/gnunet-cmds-helper.c81
1 files changed, 21 insertions, 60 deletions
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 8114d156d..477c8c60f 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -43,12 +43,13 @@
43#include "gnunet_testing_netjail_lib.h" 43#include "gnunet_testing_netjail_lib.h"
44#include "testing_cmds.h" 44#include "testing_cmds.h"
45#include "gnunet_testing_plugin.h" 45#include "gnunet_testing_plugin.h"
46#include "gnunet_testing_barrier.h"
46#include <zlib.h> 47#include <zlib.h>
47 48
48 49
49/** 50/**
50 * Generic logging shortcut 51 * Generic logging shortcut
51testing_api_cmd_block_until_all_peers_started.c */ 52 */
52#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) 53#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
53 54
54/** 55/**
@@ -65,58 +66,6 @@ testing_api_cmd_block_until_all_peers_started.c */
65struct GNUNET_SCHEDULER_Task *finished_task; 66struct GNUNET_SCHEDULER_Task *finished_task;
66 67
67/** 68/**
68 * Handle for a plugin.
69 */
70struct Plugin
71{
72 /**
73 * Name of the shared library.
74 */
75 char *library_name;
76
77 /**
78 * Plugin API.
79 */
80 struct GNUNET_TESTING_PluginFunctions *api;
81
82 /**
83 * IP address of the specific node the helper is running for.
84 *
85 */
86 char *node_ip;
87
88 /**
89 * Name of the test case plugin.
90 *
91 */
92 char *plugin_name;
93
94 /**
95 * The number of namespaces
96 *
97 */
98 char *global_n;
99
100 /**
101 * The number of local nodes per namespace.
102 *
103 */
104 char *local_m;
105
106 /**
107 * The number of the namespace this node is in.
108 *
109 */
110 char *n;
111
112 /**
113 * The number of the node in the namespace.
114 *
115 */
116 char *m;
117};
118
119/**
120 * Struct with information about a specific node and the whole network namespace setup. 69 * Struct with information about a specific node and the whole network namespace setup.
121 * 70 *
122 */ 71 */
@@ -371,8 +320,8 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
371{ 320{
372 321
373 struct NodeIdentifier *ni = cls; 322 struct NodeIdentifier *ni = cls;
374 const struct GNUNET_CMDS_HelperInit *msg; 323 const struct GNUNET_TESTING_CommandHelperInit *msg;
375 struct GNUNET_CMDS_HelperReply *reply; 324 struct GNUNET_TESTING_CommandHelperReply *reply;
376 char *binary; 325 char *binary;
377 char *plugin_name; 326 char *plugin_name;
378 size_t plugin_name_size; 327 size_t plugin_name_size;
@@ -390,9 +339,9 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
390 msize = ntohs (message->size); 339 msize = ntohs (message->size);
391 if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type)) 340 if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type))
392 { 341 {
393 msg = (const struct GNUNET_CMDS_HelperInit *) message; 342 msg = (const struct GNUNET_TESTING_CommandHelperInit *) message;
394 plugin_name_size = ntohs (msg->plugin_name_size); 343 plugin_name_size = ntohs (msg->plugin_name_size);
395 if ((sizeof(struct GNUNET_CMDS_HelperInit) + plugin_name_size) > msize) 344 if ((sizeof(struct GNUNET_TESTING_CommandHelperInit) + plugin_name_size) > msize)
396 { 345 {
397 GNUNET_break (0); 346 GNUNET_break (0);
398 LOG (GNUNET_ERROR_TYPE_WARNING, 347 LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -445,8 +394,8 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
445 plugin->n, plugin->local_m, ni->topology_data, 394 plugin->n, plugin->local_m, ni->topology_data,
446 ni->read_file, &finished_cb); 395 ni->read_file, &finished_cb);
447 396
448 msg_length = sizeof(struct GNUNET_CMDS_HelperReply); 397 msg_length = sizeof(struct GNUNET_TESTING_CommandHelperReply);
449 reply = GNUNET_new (struct GNUNET_CMDS_HelperReply); 398 reply = GNUNET_new (struct GNUNET_TESTING_CommandHelperReply);
450 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY); 399 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY);
451 reply->header.size = htons ((uint16_t) msg_length); 400 reply->header.size = htons ((uint16_t) msg_length);
452 401
@@ -458,6 +407,14 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
458 407
459 return GNUNET_OK; 408 return GNUNET_OK;
460 } 409 }
410 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED == ntohs (
411 message->type))
412 {
413 struct GNUNET_TESTING_CommandBarrierAdvanced *adm = (struct GNUNET_TESTING_CommandBarrierAdvanced *) message;
414
415 plugin->api->barrier_advanced (adm->barrier_name);
416 return GNUNET_OK;
417 }
461 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( 418 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs (
462 message->type)) 419 message->type))
463 { 420 {
@@ -554,7 +511,8 @@ run (void *cls,
554{ 511{
555 struct NodeIdentifier *ni = cls; 512 struct NodeIdentifier *ni = cls;
556 513
557 LOG_DEBUG ("Starting interpreter loop helper...\n"); 514 LOG (GNUNET_ERROR_TYPE_DEBUG,
515 "Starting interpreter loop helper...\n");
558 516
559 tokenizer = GNUNET_MST_create (&tokenizer_cb, ni); 517 tokenizer = GNUNET_MST_create (&tokenizer_cb, ni);
560 stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); 518 stdin_fd = GNUNET_DISK_get_handle_from_native (stdin);
@@ -564,6 +522,8 @@ run (void *cls,
564 &read_task, 522 &read_task,
565 NULL); 523 NULL);
566 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); 524 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
525 LOG (GNUNET_ERROR_TYPE_DEBUG,
526 "Interpreter loop helper started.\n");
567} 527}
568 528
569 529
@@ -662,6 +622,7 @@ main (int argc, char **argv)
662 } 622 }
663 shc_chld = 623 shc_chld =
664 GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); 624 GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
625
665 ret = GNUNET_PROGRAM_run (argc, 626 ret = GNUNET_PROGRAM_run (argc,
666 argv, 627 argv,
667 "gnunet-cmds-helper", 628 "gnunet-cmds-helper",