aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_cmd_controller.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api_cmd_controller.c')
-rw-r--r--src/testbed/testbed_api_cmd_controller.c104
1 files changed, 7 insertions, 97 deletions
diff --git a/src/testbed/testbed_api_cmd_controller.c b/src/testbed/testbed_api_cmd_controller.c
index e3044eaa7..794b1ccf3 100644
--- a/src/testbed/testbed_api_cmd_controller.c
+++ b/src/testbed/testbed_api_cmd_controller.c
@@ -39,26 +39,6 @@
39 39
40 40
41/** 41/**
42 * abort task to run on test timed out
43 *
44 * @param cls NULL
45 * @param tc the task context
46 */
47static void
48do_abort (void *cls)
49{
50 struct ControllerState *cs = cls;
51
52 if (GNUNET_NO == cs->host_ready)
53 {
54 LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
55 cs->abort_task = NULL;
56 GNUNET_TESTBED_shutdown_controller (cs);
57 }
58}
59
60
61/**
62* 42*
63* 43*
64* @param cls closure 44* @param cls closure
@@ -98,83 +78,20 @@ controller_cb (void *cls,
98} 78}
99 79
100 80
101/**
102 * Callback which will be called to after a host registration succeeded or failed
103 *
104 * @param cls the host which has been registered
105 * @param emsg the error message; NULL if host registration is successful
106 */
107static void 81static void
108registration_comp (void *cls, 82controller_run (void *cls,
109 const char *emsg) 83 const struct GNUNET_TESTING_Command *cmd,
110{ 84 struct GNUNET_TESTING_Interpreter *is)
111 struct ControllerState *cs = cls;
112
113 if (NULL != emsg)
114 {
115 LOG (GNUNET_ERROR_TYPE_ERROR,
116 "There was an error during host registration: %s\n",
117 emsg);
118 GNUNET_TESTBED_shutdown_controller (cs);
119 }
120 else
121 {
122 cs->reg_handle = NULL;
123 cs->host_ready = GNUNET_YES;
124 }
125}
126
127
128/**
129 * Callback to signal successful startup of the controller process
130 *
131 * @param cls the closure from GNUNET_TESTBED_controller_start()
132 * @param cfg the configuration with which the controller has been started;
133 * NULL if status is not #GNUNET_OK
134 * @param status #GNUNET_OK if the startup is successful; #GNUNET_SYSERR if not,
135 * GNUNET_TESTBED_controller_stop() shouldn't be called in this case
136 */
137static void
138controller_status_cb (void *cls,
139 const struct GNUNET_CONFIGURATION_Handle *cfg_,
140 int status)
141{ 85{
142 struct ControllerState *cs = cls; 86 struct ControllerState *cs = cls;
143 87
144 if (GNUNET_OK != status) 88 cs->is = is;
145 {
146 cs->cp = NULL;
147 return;
148 }
149 89
150 cs->controller = 90 cs->controller =
151 GNUNET_TESTBED_controller_connect (cs->host, cs->event_mask, &controller_cb, 91 GNUNET_TESTBED_controller_connect (cs->host, cs->event_mask, &controller_cb,
152 cs); 92 cs);
153 cs->reg_handle =
154 GNUNET_TESTBED_register_host (cs->controller, cs->host, &registration_comp,
155 cs);
156}
157 93
158 94
159static void
160controller_run (void *cls,
161 const struct GNUNET_TESTING_Command *cmd,
162 struct GNUNET_TESTING_Interpreter *is)
163{
164 struct ControllerState *cs = cls;
165
166 cs->is = is;
167 cs->host = GNUNET_TESTBED_host_create (cs->hostname, cs->username, cs->cfg,
168 cs->port);
169 cs->cp = GNUNET_TESTBED_controller_start (cs->trusted_ip,
170 cs->host,
171 &controller_status_cb,
172 cs);
173 cs->abort_task =
174 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
175 (GNUNET_TIME_UNIT_MINUTES, 5),
176 &do_abort,
177 cs);
178} 95}
179 96
180/** 97/**
@@ -264,22 +181,15 @@ GNUNET_TESTBED_shutdown_controller (struct ControllerState *cs)
264 181
265struct GNUNET_TESTING_Command 182struct GNUNET_TESTING_Command
266GNUNET_TESTBED_cmd_controller (const char *label, 183GNUNET_TESTBED_cmd_controller (const char *label,
267 const char *trusted_ip, 184 const char *host,
268 const char *hostname,
269 const char *username,
270 uint16_t port,
271 struct GNUNET_CONFIGURATION_Handle *cfg,
272 uint64_t event_mask) 185 uint64_t event_mask)
273{ 186{
274 struct ControllerState *cs; 187 struct ControllerState *cs;
275 188
276 cs = GNUNET_new (struct ControllerState); 189 cs = GNUNET_new (struct ControllerState);
277 cs->event_mask = event_mask; 190 cs->event_mask = event_mask;
278 cs->trusted_ip = trusted_ip; 191 cs->hostname = host;
279 cs->hostname = hostname; 192
280 cs->username = username;
281 cs->port = port;
282 cs->cfg = cfg;
283 193
284 struct GNUNET_TESTING_Command cmd = { 194 struct GNUNET_TESTING_Command cmd = {
285 .cls = cs, 195 .cls = cs,