aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/gnunet-cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/gnunet-cmd.c')
-rw-r--r--src/testbed/gnunet-cmd.c54
1 files changed, 42 insertions, 12 deletions
diff --git a/src/testbed/gnunet-cmd.c b/src/testbed/gnunet-cmd.c
index 477c3c454..7889750ba 100644
--- a/src/testbed/gnunet-cmd.c
+++ b/src/testbed/gnunet-cmd.c
@@ -36,6 +36,9 @@
36 */ 36 */
37#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) 37#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
38 38
39#define NODE_BASE_IP "192.168.15."
40
41#define ROUTER_BASE_IP "92.68.150."
39 42
40/** 43/**
41 * Handle for a plugin. 44 * Handle for a plugin.
@@ -51,29 +54,44 @@ struct Plugin
51 * Plugin API. 54 * Plugin API.
52 */ 55 */
53 struct GNUNET_TESTING_PluginFunctions *api; 56 struct GNUNET_TESTING_PluginFunctions *api;
57
58 char *node_ip;
59
60 char *plugin_name;
61
62 char *global_n;
63
64 char *local_m;
65
66 char *n;
67
68 char *m;
54}; 69};
55 70
56 71
57/** 72/**
58 * Main function to run the test cases. 73 * Main function to run the test cases.
59 * 74 *
60 * @param cls not used. 75 * @param cls plugin to use.
61 * 76 *
62 */ 77 */
63static void 78static void
64run (void *cls) 79run (void *cls)
65{ 80{
66 struct Plugin *plugin; 81 struct Plugin *plugin = cls;
82 char *router_ip;
83 char *node_ip;
84
85 router_ip = GNUNET_malloc (strlen (ROUTER_BASE_IP) + strlen (plugin->m) + 1);
86 strcpy (router_ip, ROUTER_BASE_IP);
87 strcat (router_ip, plugin->m);
88
89 node_ip = GNUNET_malloc (strlen (NODE_BASE_IP) + strlen (plugin->n) + 1);
90 strcat (node_ip, NODE_BASE_IP);
91 strcat (node_ip, plugin->n);
92
93 plugin->api->start_testcase (NULL, router_ip, node_ip);
67 94
68 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "gnunet-cmd",
69 "running plugin.\n");
70 LOG (GNUNET_ERROR_TYPE_ERROR,
71 "running plugin.\n");
72 plugin = GNUNET_new (struct Plugin);
73 plugin->api = GNUNET_PLUGIN_load ("libgnunet_plugin_testcmd",
74 NULL);
75 plugin->library_name = GNUNET_strdup ("libgnunet_plugin_testcmd");
76 plugin->api->start_testcase ();
77} 95}
78 96
79 97
@@ -81,13 +99,25 @@ int
81main (int argc, char *const *argv) 99main (int argc, char *const *argv)
82{ 100{
83 int rv = 0; 101 int rv = 0;
102 struct Plugin *plugin;
84 103
85 GNUNET_log_setup ("gnunet-cmd", 104 GNUNET_log_setup ("gnunet-cmd",
86 "DEBUG", 105 "DEBUG",
87 NULL); 106 NULL);
88 107
108 plugin = GNUNET_new (struct Plugin);
109 plugin->api = GNUNET_PLUGIN_load (argv[0],
110 NULL);
111 plugin->library_name = GNUNET_strdup (argv[0]);
112
113 plugin->global_n = argv[1];
114 plugin->local_m = argv[2];
115 plugin->n = argv[3];
116 plugin->m = argv[4];
117
89 GNUNET_SCHEDULER_run (&run, 118 GNUNET_SCHEDULER_run (&run,
90 NULL); 119 plugin);
91 120
121 GNUNET_free (plugin);
92 return rv; 122 return rv;
93} 123}