summaryrefslogtreecommitdiff
path: root/src/testbed/gnunet-service-testbed.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/gnunet-service-testbed.c')
-rw-r--r--src/testbed/gnunet-service-testbed.c919
1 files changed, 462 insertions, 457 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index 8babeeb13..26f1a9c26 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -1,22 +1,22 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2008--2013, 2016 GNUnet e.V. 3 Copyright (C) 2008--2013, 2016 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License, 7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file testbed/gnunet-service-testbed.c 22 * @file testbed/gnunet-service-testbed.c
@@ -96,18 +96,18 @@ static char *hostname;
96 * already in use 96 * already in use
97 */ 97 */
98static int 98static int
99host_list_add (struct GNUNET_TESTBED_Host *host) 99host_list_add(struct GNUNET_TESTBED_Host *host)
100{ 100{
101 uint32_t host_id; 101 uint32_t host_id;
102 102
103 host_id = GNUNET_TESTBED_host_get_id_ (host); 103 host_id = GNUNET_TESTBED_host_get_id_(host);
104 if (GST_host_list_size <= host_id) 104 if (GST_host_list_size <= host_id)
105 GST_array_grow_large_enough (GST_host_list, GST_host_list_size, host_id); 105 GST_array_grow_large_enough(GST_host_list, GST_host_list_size, host_id);
106 if (NULL != GST_host_list[host_id]) 106 if (NULL != GST_host_list[host_id])
107 { 107 {
108 LOG_DEBUG ("A host with id: %u already exists\n", host_id); 108 LOG_DEBUG("A host with id: %u already exists\n", host_id);
109 return GNUNET_SYSERR; 109 return GNUNET_SYSERR;
110 } 110 }
111 GST_host_list[host_id] = host; 111 GST_host_list[host_id] = host;
112 return GNUNET_OK; 112 return GNUNET_OK;
113} 113}
@@ -121,25 +121,25 @@ host_list_add (struct GNUNET_TESTBED_Host *host)
121 * @param emsg the error message; can be NULL 121 * @param emsg the error message; can be NULL
122 */ 122 */
123void 123void
124GST_send_operation_fail_msg (struct GNUNET_SERVICE_Client *client, 124GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client,
125 uint64_t operation_id, 125 uint64_t operation_id,
126 const char *emsg) 126 const char *emsg)
127{ 127{
128 struct GNUNET_MQ_Envelope *env; 128 struct GNUNET_MQ_Envelope *env;
129 struct GNUNET_TESTBED_OperationFailureEventMessage *msg; 129 struct GNUNET_TESTBED_OperationFailureEventMessage *msg;
130 uint16_t emsg_len; 130 uint16_t emsg_len;
131 131
132 emsg_len = (NULL == emsg) ? 0 : strlen (emsg) + 1; 132 emsg_len = (NULL == emsg) ? 0 : strlen(emsg) + 1;
133 env = GNUNET_MQ_msg_extra (msg, 133 env = GNUNET_MQ_msg_extra(msg,
134 emsg_len, 134 emsg_len,
135 GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT); 135 GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT);
136 msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED); 136 msg->event_type = htonl(GNUNET_TESTBED_ET_OPERATION_FINISHED);
137 msg->operation_id = GNUNET_htonll (operation_id); 137 msg->operation_id = GNUNET_htonll(operation_id);
138 GNUNET_memcpy (&msg[1], 138 GNUNET_memcpy(&msg[1],
139 emsg, 139 emsg,
140 emsg_len); 140 emsg_len);
141 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 141 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client),
142 env); 142 env);
143} 143}
144 144
145 145
@@ -150,18 +150,18 @@ GST_send_operation_fail_msg (struct GNUNET_SERVICE_Client *client,
150 * @param operation_id the id of the operation which was successful 150 * @param operation_id the id of the operation which was successful
151 */ 151 */
152void 152void
153GST_send_operation_success_msg (struct GNUNET_SERVICE_Client *client, 153GST_send_operation_success_msg(struct GNUNET_SERVICE_Client *client,
154 uint64_t operation_id) 154 uint64_t operation_id)
155{ 155{
156 struct GNUNET_MQ_Envelope *env; 156 struct GNUNET_MQ_Envelope *env;
157 struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg; 157 struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg;
158 158
159 env = GNUNET_MQ_msg (msg, 159 env = GNUNET_MQ_msg(msg,
160 GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS); 160 GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS);
161 msg->operation_id = GNUNET_htonll (operation_id); 161 msg->operation_id = GNUNET_htonll(operation_id);
162 msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED); 162 msg->event_type = htonl(GNUNET_TESTBED_ET_OPERATION_FINISHED);
163 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 163 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client),
164 env); 164 env);
165} 165}
166 166
167 167
@@ -172,8 +172,8 @@ GST_send_operation_success_msg (struct GNUNET_SERVICE_Client *client,
172 * @param emsg the error message; NULL if host registration is successful 172 * @param emsg the error message; NULL if host registration is successful
173 */ 173 */
174static void 174static void
175hr_completion (void *cls, 175hr_completion(void *cls,
176 const char *emsg); 176 const char *emsg);
177 177
178 178
179/** 179/**
@@ -183,21 +183,21 @@ hr_completion (void *cls,
183 * for host registrations 183 * for host registrations
184 */ 184 */
185static void 185static void
186register_next_host (struct Slave *slave) 186register_next_host(struct Slave *slave)
187{ 187{
188 struct HostRegistration *hr; 188 struct HostRegistration *hr;
189 189
190 hr = slave->hr_dll_head; 190 hr = slave->hr_dll_head;
191 GNUNET_assert (NULL != hr); 191 GNUNET_assert(NULL != hr);
192 GNUNET_assert (NULL == slave->rhandle); 192 GNUNET_assert(NULL == slave->rhandle);
193 LOG (GNUNET_ERROR_TYPE_DEBUG, "Registering host %u at %u\n", 193 LOG(GNUNET_ERROR_TYPE_DEBUG, "Registering host %u at %u\n",
194 GNUNET_TESTBED_host_get_id_ (hr->host), 194 GNUNET_TESTBED_host_get_id_(hr->host),
195 GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id])); 195 GNUNET_TESTBED_host_get_id_(GST_host_list[slave->host_id]));
196 slave->rhandle 196 slave->rhandle
197 = GNUNET_TESTBED_register_host (slave->controller, 197 = GNUNET_TESTBED_register_host(slave->controller,
198 hr->host, 198 hr->host,
199 hr_completion, 199 hr_completion,
200 slave); 200 slave);
201} 201}
202 202
203 203
@@ -208,28 +208,28 @@ register_next_host (struct Slave *slave)
208 * @param emsg the error message; NULL if host registration is successful 208 * @param emsg the error message; NULL if host registration is successful
209 */ 209 */
210static void 210static void
211hr_completion (void *cls, 211hr_completion(void *cls,
212 const char *emsg) 212 const char *emsg)
213{ 213{
214 struct Slave *slave = cls; 214 struct Slave *slave = cls;
215 struct HostRegistration *hr; 215 struct HostRegistration *hr;
216 216
217 slave->rhandle = NULL; 217 slave->rhandle = NULL;
218 hr = slave->hr_dll_head; 218 hr = slave->hr_dll_head;
219 GNUNET_assert (NULL != hr); 219 GNUNET_assert(NULL != hr);
220 LOG (GNUNET_ERROR_TYPE_DEBUG, 220 LOG(GNUNET_ERROR_TYPE_DEBUG,
221 "Registering host %u at %u successful\n", 221 "Registering host %u at %u successful\n",
222 GNUNET_TESTBED_host_get_id_ (hr->host), 222 GNUNET_TESTBED_host_get_id_(hr->host),
223 GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id])); 223 GNUNET_TESTBED_host_get_id_(GST_host_list[slave->host_id]));
224 GNUNET_CONTAINER_DLL_remove (slave->hr_dll_head, 224 GNUNET_CONTAINER_DLL_remove(slave->hr_dll_head,
225 slave->hr_dll_tail, 225 slave->hr_dll_tail,
226 hr); 226 hr);
227 if (NULL != hr->cb) 227 if (NULL != hr->cb)
228 hr->cb (hr->cb_cls, 228 hr->cb(hr->cb_cls,
229 emsg); 229 emsg);
230 GNUNET_free (hr); 230 GNUNET_free(hr);
231 if (NULL != slave->hr_dll_head) 231 if (NULL != slave->hr_dll_head)
232 register_next_host (slave); 232 register_next_host(slave);
233} 233}
234 234
235 235
@@ -243,28 +243,28 @@ hr_completion (void *cls,
243 * @param host the host which has to be registered 243 * @param host the host which has to be registered
244 */ 244 */
245void 245void
246GST_queue_host_registration (struct Slave *slave, 246GST_queue_host_registration(struct Slave *slave,
247 GNUNET_TESTBED_HostRegistrationCompletion cb, 247 GNUNET_TESTBED_HostRegistrationCompletion cb,
248 void *cb_cls, 248 void *cb_cls,
249 struct GNUNET_TESTBED_Host *host) 249 struct GNUNET_TESTBED_Host *host)
250{ 250{
251 struct HostRegistration *hr; 251 struct HostRegistration *hr;
252 int call_register; 252 int call_register;
253 253
254 LOG (GNUNET_ERROR_TYPE_DEBUG, 254 LOG(GNUNET_ERROR_TYPE_DEBUG,
255 "Queueing host registration for host %u at %u\n", 255 "Queueing host registration for host %u at %u\n",
256 GNUNET_TESTBED_host_get_id_ (host), 256 GNUNET_TESTBED_host_get_id_(host),
257 GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id])); 257 GNUNET_TESTBED_host_get_id_(GST_host_list[slave->host_id]));
258 hr = GNUNET_new (struct HostRegistration); 258 hr = GNUNET_new(struct HostRegistration);
259 hr->cb = cb; 259 hr->cb = cb;
260 hr->cb_cls = cb_cls; 260 hr->cb_cls = cb_cls;
261 hr->host = host; 261 hr->host = host;
262 call_register = (NULL == slave->hr_dll_head) ? GNUNET_YES : GNUNET_NO; 262 call_register = (NULL == slave->hr_dll_head) ? GNUNET_YES : GNUNET_NO;
263 GNUNET_CONTAINER_DLL_insert_tail (slave->hr_dll_head, 263 GNUNET_CONTAINER_DLL_insert_tail(slave->hr_dll_head,
264 slave->hr_dll_tail, 264 slave->hr_dll_tail,
265 hr); 265 hr);
266 if (GNUNET_YES == call_register) 266 if (GNUNET_YES == call_register)
267 register_next_host (slave); 267 register_next_host(slave);
268} 268}
269 269
270 270
@@ -275,23 +275,23 @@ GST_queue_host_registration (struct Slave *slave,
275 * @param msg the message to relay 275 * @param msg the message to relay
276 */ 276 */
277void 277void
278GST_forwarded_operation_reply_relay (void *cls, 278GST_forwarded_operation_reply_relay(void *cls,
279 const struct GNUNET_MessageHeader *msg) 279 const struct GNUNET_MessageHeader *msg)
280{ 280{
281 struct ForwardedOperationContext *fopc = cls; 281 struct ForwardedOperationContext *fopc = cls;
282 struct GNUNET_MQ_Envelope *env; 282 struct GNUNET_MQ_Envelope *env;
283 283
284 LOG_DEBUG ("Relaying message with type: %u, size: %u\n", 284 LOG_DEBUG("Relaying message with type: %u, size: %u\n",
285 ntohs (msg->type), 285 ntohs(msg->type),
286 ntohs (msg->size)); 286 ntohs(msg->size));
287 env = GNUNET_MQ_msg_copy (msg); 287 env = GNUNET_MQ_msg_copy(msg);
288 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (fopc->client), 288 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(fopc->client),
289 env); 289 env);
290 GNUNET_SCHEDULER_cancel (fopc->timeout_task); 290 GNUNET_SCHEDULER_cancel(fopc->timeout_task);
291 GNUNET_CONTAINER_DLL_remove (fopcq_head, 291 GNUNET_CONTAINER_DLL_remove(fopcq_head,
292 fopcq_tail, 292 fopcq_tail,
293 fopc); 293 fopc);
294 GNUNET_free (fopc); 294 GNUNET_free(fopc);
295} 295}
296 296
297 297
@@ -301,21 +301,21 @@ GST_forwarded_operation_reply_relay (void *cls,
301 * @param cls the ForwardedOperationContext 301 * @param cls the ForwardedOperationContext
302 */ 302 */
303void 303void
304GST_forwarded_operation_timeout (void *cls) 304GST_forwarded_operation_timeout(void *cls)
305{ 305{
306 struct ForwardedOperationContext *fopc = cls; 306 struct ForwardedOperationContext *fopc = cls;
307 307
308 fopc->timeout_task = NULL; 308 fopc->timeout_task = NULL;
309 GNUNET_TESTBED_forward_operation_msg_cancel_ (fopc->opc); 309 GNUNET_TESTBED_forward_operation_msg_cancel_(fopc->opc);
310 LOG (GNUNET_ERROR_TYPE_DEBUG, 310 LOG(GNUNET_ERROR_TYPE_DEBUG,
311 "A forwarded operation has timed out\n"); 311 "A forwarded operation has timed out\n");
312 GST_send_operation_fail_msg (fopc->client, 312 GST_send_operation_fail_msg(fopc->client,
313 fopc->operation_id, 313 fopc->operation_id,
314 "A forwarded operation has timed out"); 314 "A forwarded operation has timed out");
315 GNUNET_CONTAINER_DLL_remove (fopcq_head, 315 GNUNET_CONTAINER_DLL_remove(fopcq_head,
316 fopcq_tail, 316 fopcq_tail,
317 fopc); 317 fopc);
318 GNUNET_free (fopc); 318 GNUNET_free(fopc);
319} 319}
320 320
321 321
@@ -329,51 +329,52 @@ GST_forwarded_operation_timeout (void *cls)
329 * upon empty service sharing specification. 329 * upon empty service sharing specification.
330 */ 330 */
331static struct GNUNET_TESTING_SharedService * 331static struct GNUNET_TESTING_SharedService *
332parse_shared_services (char *ss_str, 332parse_shared_services(char *ss_str,
333 struct GNUNET_CONFIGURATION_Handle *cfg) 333 struct GNUNET_CONFIGURATION_Handle *cfg)
334{ 334{
335 struct GNUNET_TESTING_SharedService ss; 335 struct GNUNET_TESTING_SharedService ss;
336 struct GNUNET_TESTING_SharedService *slist; 336 struct GNUNET_TESTING_SharedService *slist;
337 char service[256]; 337 char service[256];
338 char *arg; 338 char *arg;
339 unsigned int n; 339 unsigned int n;
340
340#define GROW_SS \ 341#define GROW_SS \
341 do { \ 342 do { \
342 GNUNET_array_grow (slist, n, n+1); \ 343 GNUNET_array_grow(slist, n, n + 1); \
343 GNUNET_memcpy (&slist[n - 1], &ss, \ 344 GNUNET_memcpy(&slist[n - 1], &ss, \
344 sizeof (struct GNUNET_TESTING_SharedService)); \ 345 sizeof(struct GNUNET_TESTING_SharedService)); \
345 } while (0) 346 } while (0)
346 347
347 slist = NULL; 348 slist = NULL;
348 n = 0; 349 n = 0;
349 ss.cfg = cfg; 350 ss.cfg = cfg;
350 for (; NULL != (arg = strtok (ss_str, " ")); ss_str = NULL) 351 for (; NULL != (arg = strtok(ss_str, " ")); ss_str = NULL)
351 {
352 ss.service = NULL;
353 ss.share = 0;
354 if (2 != sscanf (arg, "%255[^:]:%u",
355 service,
356 &ss.share))
357 { 352 {
358 LOG (GNUNET_ERROR_TYPE_WARNING, 353 ss.service = NULL;
359 "Ignoring shared service spec: %s", 354 ss.share = 0;
360 arg); 355 if (2 != sscanf(arg, "%255[^:]:%u",
361 continue; 356 service,
357 &ss.share))
358 {
359 LOG(GNUNET_ERROR_TYPE_WARNING,
360 "Ignoring shared service spec: %s",
361 arg);
362 continue;
363 }
364 LOG_DEBUG("Will be sharing %s service among %u peers\n",
365 service,
366 ss.share);
367 ss.service = GNUNET_strdup(service);
368 GROW_SS;
362 } 369 }
363 LOG_DEBUG ("Will be sharing %s service among %u peers\n",
364 service,
365 ss.share);
366 ss.service = GNUNET_strdup (service);
367 GROW_SS;
368 }
369 if (NULL != slist) 370 if (NULL != slist)
370 { 371 {
371 /* Add trailing NULL block */ 372 /* Add trailing NULL block */
372 (void) memset (&ss, 373 (void)memset(&ss,
373 0, 374 0,
374 sizeof (struct GNUNET_TESTING_SharedService)); 375 sizeof(struct GNUNET_TESTING_SharedService));
375 GROW_SS; 376 GROW_SS;
376 } 377 }
377 return slist; 378 return slist;
378#undef GROW_SS 379#undef GROW_SS
379} 380}
@@ -387,19 +388,19 @@ parse_shared_services (char *ss_str,
387 * @return #GNUNET_OK if @a message is well-formed 388 * @return #GNUNET_OK if @a message is well-formed
388 */ 389 */
389static int 390static int
390check_init (void *cls, 391check_init(void *cls,
391 const struct GNUNET_TESTBED_InitMessage *msg) 392 const struct GNUNET_TESTBED_InitMessage *msg)
392{ 393{
393 const char *controller_hostname; 394 const char *controller_hostname;
394 uint16_t msize; 395 uint16_t msize;
395 396
396 msize = ntohs (msg->header.size) - sizeof (struct GNUNET_TESTBED_InitMessage); 397 msize = ntohs(msg->header.size) - sizeof(struct GNUNET_TESTBED_InitMessage);
397 controller_hostname = (const char *) &msg[1]; 398 controller_hostname = (const char *)&msg[1];
398 if ('\0' != controller_hostname[msize - 1]) 399 if ('\0' != controller_hostname[msize - 1])
399 { 400 {
400 GNUNET_break (0); 401 GNUNET_break(0);
401 return GNUNET_SYSERR; 402 return GNUNET_SYSERR;
402 } 403 }
403 return GNUNET_OK; 404 return GNUNET_OK;
404} 405}
405 406
@@ -411,8 +412,8 @@ check_init (void *cls,
411 * @param message the actual message 412 * @param message the actual message
412 */ 413 */
413static void 414static void
414handle_init (void *cls, 415handle_init(void *cls,
415 const struct GNUNET_TESTBED_InitMessage *msg) 416 const struct GNUNET_TESTBED_InitMessage *msg)
416{ 417{
417 struct GNUNET_SERVICE_Client *client = cls; 418 struct GNUNET_SERVICE_Client *client = cls;
418 struct GNUNET_TESTBED_Host *host; 419 struct GNUNET_TESTBED_Host *host;
@@ -422,56 +423,56 @@ handle_init (void *cls,
422 unsigned int cnt; 423 unsigned int cnt;
423 424
424 if (NULL != GST_context) 425 if (NULL != GST_context)
425 { 426 {
426 LOG_DEBUG ("We are being connected to laterally\n"); 427 LOG_DEBUG("We are being connected to laterally\n");
427 GNUNET_SERVICE_client_continue (client); 428 GNUNET_SERVICE_client_continue(client);
428 return; 429 return;
429 } 430 }
430 controller_hostname = (const char *) &msg[1]; 431 controller_hostname = (const char *)&msg[1];
431 ss_str = NULL; 432 ss_str = NULL;
432 ss = NULL; 433 ss = NULL;
433 if (GNUNET_OK == 434 if (GNUNET_OK ==
434 GNUNET_CONFIGURATION_get_value_string (GST_config, 435 GNUNET_CONFIGURATION_get_value_string(GST_config,
435 "TESTBED", 436 "TESTBED",
436 "SHARED_SERVICES", 437 "SHARED_SERVICES",
437 &ss_str)) 438 &ss_str))
438 { 439 {
439 ss = parse_shared_services (ss_str, 440 ss = parse_shared_services(ss_str,
440 GST_config); 441 GST_config);
441 GNUNET_free (ss_str); 442 GNUNET_free(ss_str);
442 ss_str = NULL; 443 ss_str = NULL;
443 } 444 }
444 GST_context = GNUNET_new (struct Context); 445 GST_context = GNUNET_new(struct Context);
445 GST_context->client = client; 446 GST_context->client = client;
446 GST_context->host_id = ntohl (msg->host_id); 447 GST_context->host_id = ntohl(msg->host_id);
447 GST_context->master_ip = GNUNET_strdup (controller_hostname); 448 GST_context->master_ip = GNUNET_strdup(controller_hostname);
448 LOG_DEBUG ("Our IP: %s\n", 449 LOG_DEBUG("Our IP: %s\n",
449 GST_context->master_ip); 450 GST_context->master_ip);
450 GST_context->system 451 GST_context->system
451 = GNUNET_TESTING_system_create ("testbed", 452 = GNUNET_TESTING_system_create("testbed",
452 GST_context->master_ip, 453 GST_context->master_ip,
453 hostname, 454 hostname,
454 ss); 455 ss);
455 if (NULL != ss) 456 if (NULL != ss)
456 {
457 for (cnt = 0; NULL != ss[cnt].service; cnt++)
458 { 457 {
459 ss_str = (char *) ss[cnt].service; 458 for (cnt = 0; NULL != ss[cnt].service; cnt++)
460 GNUNET_free (ss_str); 459 {
460 ss_str = (char *)ss[cnt].service;
461 GNUNET_free(ss_str);
462 }
463 GNUNET_free(ss);
464 ss = NULL;
461 } 465 }
462 GNUNET_free (ss);
463 ss = NULL;
464 }
465 host = 466 host =
466 GNUNET_TESTBED_host_create_with_id (GST_context->host_id, 467 GNUNET_TESTBED_host_create_with_id(GST_context->host_id,
467 GST_context->master_ip, 468 GST_context->master_ip,
468 NULL, 469 NULL,
469 GST_config, 470 GST_config,
470 0); 471 0);
471 host_list_add (host); 472 host_list_add(host);
472 LOG_DEBUG ("Created master context with host ID: %u\n", 473 LOG_DEBUG("Created master context with host ID: %u\n",
473 GST_context->host_id); 474 GST_context->host_id);
474 GNUNET_SERVICE_client_continue (client); 475 GNUNET_SERVICE_client_continue(client);
475} 476}
476 477
477 478
@@ -483,29 +484,29 @@ handle_init (void *cls,
483 * @return #GNUNET_OK if @a message is well-formed 484 * @return #GNUNET_OK if @a message is well-formed
484 */ 485 */
485static int 486static int
486check_add_host (void *cls, 487check_add_host(void *cls,
487 const struct GNUNET_TESTBED_AddHostMessage *msg) 488 const struct GNUNET_TESTBED_AddHostMessage *msg)
488{ 489{
489 uint16_t username_length; 490 uint16_t username_length;
490 uint16_t hostname_length; 491 uint16_t hostname_length;
491 uint16_t msize; 492 uint16_t msize;
492 493
493 msize = ntohs (msg->header.size) - sizeof (struct GNUNET_TESTBED_AddHostMessage); 494 msize = ntohs(msg->header.size) - sizeof(struct GNUNET_TESTBED_AddHostMessage);
494 username_length = ntohs (msg->username_length); 495 username_length = ntohs(msg->username_length);
495 hostname_length = ntohs (msg->hostname_length); 496 hostname_length = ntohs(msg->hostname_length);
496 /* msg must contain hostname */ 497 /* msg must contain hostname */
497 if ( (msize <= username_length) || 498 if ((msize <= username_length) ||
498 (0 == hostname_length) ) 499 (0 == hostname_length))
499 { 500 {
500 GNUNET_break (0); 501 GNUNET_break(0);
501 return GNUNET_SYSERR; 502 return GNUNET_SYSERR;
502 } 503 }
503 /* msg must contain configuration */ 504 /* msg must contain configuration */
504 if (msize <= username_length + hostname_length) 505 if (msize <= username_length + hostname_length)
505 { 506 {
506 GNUNET_break (0); 507 GNUNET_break(0);
507 return GNUNET_SYSERR; 508 return GNUNET_SYSERR;
508 } 509 }
509 return GNUNET_OK; 510 return GNUNET_OK;
510} 511}
511 512
@@ -517,8 +518,8 @@ check_add_host (void *cls,
517 * @param msg the actual message 518 * @param msg the actual message
518 */ 519 */
519static void 520static void
520handle_add_host (void *cls, 521handle_add_host(void *cls,
521 const struct GNUNET_TESTBED_AddHostMessage *msg) 522 const struct GNUNET_TESTBED_AddHostMessage *msg)
522{ 523{
523 struct GNUNET_SERVICE_Client *client = cls; 524 struct GNUNET_SERVICE_Client *client = cls;
524 struct GNUNET_TESTBED_Host *host; 525 struct GNUNET_TESTBED_Host *host;
@@ -533,77 +534,77 @@ handle_add_host (void *cls,
533 uint16_t hostname_length; 534 uint16_t hostname_length;
534 struct GNUNET_MQ_Envelope *env; 535 struct GNUNET_MQ_Envelope *env;
535 536
536 username_length = ntohs (msg->username_length); 537 username_length = ntohs(msg->username_length);
537 hostname_length = ntohs (msg->hostname_length); 538 hostname_length = ntohs(msg->hostname_length);
538 username = NULL; 539 username = NULL;
539 hostname = NULL; 540 hostname = NULL;
540 ptr = &msg[1]; 541 ptr = &msg[1];
541 if (0 != username_length) 542 if (0 != username_length)
542 { 543 {
543 username = GNUNET_malloc (username_length + 1); 544 username = GNUNET_malloc(username_length + 1);
544 GNUNET_strlcpy (username, ptr, username_length + 1); 545 GNUNET_strlcpy(username, ptr, username_length + 1);
545 ptr += username_length; 546 ptr += username_length;
546 } 547 }
547 hostname = GNUNET_malloc (hostname_length + 1); 548 hostname = GNUNET_malloc(hostname_length + 1);
548 GNUNET_strlcpy (hostname, ptr, hostname_length + 1); 549 GNUNET_strlcpy(hostname, ptr, hostname_length + 1);
549 if (NULL == (host_cfg = GNUNET_TESTBED_extract_config_ (&msg->header))) 550 if (NULL == (host_cfg = GNUNET_TESTBED_extract_config_(&msg->header)))
550 { 551 {
551 GNUNET_free_non_null (username); 552 GNUNET_free_non_null(username);
552 GNUNET_free_non_null (hostname); 553 GNUNET_free_non_null(hostname);
553 GNUNET_break_op (0); 554 GNUNET_break_op(0);
554 GNUNET_SERVICE_client_drop (client); 555 GNUNET_SERVICE_client_drop(client);
555 return; 556 return;
556 } 557 }
557 host_id = ntohl (msg->host_id); 558 host_id = ntohl(msg->host_id);
558 LOG_DEBUG ("Received ADDHOST %u message\n", host_id); 559 LOG_DEBUG("Received ADDHOST %u message\n", host_id);
559 LOG_DEBUG ("-------host id: %u\n", host_id); 560 LOG_DEBUG("-------host id: %u\n", host_id);
560 LOG_DEBUG ("-------hostname: %s\n", hostname); 561 LOG_DEBUG("-------hostname: %s\n", hostname);
561 if (NULL != username) 562 if (NULL != username)
562 LOG_DEBUG ("-------username: %s\n", username); 563 LOG_DEBUG("-------username: %s\n", username);
563 else 564 else
564 LOG_DEBUG ("-------username: <not given>\n"); 565 LOG_DEBUG("-------username: <not given>\n");
565 LOG_DEBUG ("-------ssh port: %u\n", ntohs (msg->ssh_port)); 566 LOG_DEBUG("-------ssh port: %u\n", ntohs(msg->ssh_port));
566 host = GNUNET_TESTBED_host_create_with_id (host_id, 567 host = GNUNET_TESTBED_host_create_with_id(host_id,
567 hostname, 568 hostname,
568 username, 569 username,
569 host_cfg, 570 host_cfg,
570 ntohs (msg->ssh_port)); 571 ntohs(msg->ssh_port));
571 GNUNET_free_non_null (username); 572 GNUNET_free_non_null(username);
572 GNUNET_free (hostname); 573 GNUNET_free(hostname);
573 GNUNET_CONFIGURATION_destroy (host_cfg); 574 GNUNET_CONFIGURATION_destroy(host_cfg);
574 if (NULL == host) 575 if (NULL == host)
575 { 576 {
576 GNUNET_break_op (0); 577 GNUNET_break_op(0);
577 GNUNET_SERVICE_client_drop (client); 578 GNUNET_SERVICE_client_drop(client);
578 return; 579 return;
579 } 580 }
580 if (GNUNET_OK != host_list_add (host)) 581 if (GNUNET_OK != host_list_add(host))
581 { 582 {
582 /* We are unable to add a host */ 583 /* We are unable to add a host */
583 emsg = "A host exists with given host-id"; 584 emsg = "A host exists with given host-id";
584 LOG_DEBUG ("%s: %u", 585 LOG_DEBUG("%s: %u",
585 emsg, 586 emsg,
586 host_id); 587 host_id);
587 GNUNET_TESTBED_host_destroy (host); 588 GNUNET_TESTBED_host_destroy(host);
588 env = GNUNET_MQ_msg_extra (reply, 589 env = GNUNET_MQ_msg_extra(reply,
589 strlen (emsg) + 1, 590 strlen(emsg) + 1,
590 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS); 591 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS);
591 GNUNET_memcpy (&reply[1], 592 GNUNET_memcpy(&reply[1],
592 emsg, 593 emsg,
593 strlen (emsg) + 1); 594 strlen(emsg) + 1);
594 } 595 }
595 else 596 else
596 { 597 {
597 LOG_DEBUG ("Added host %u at %u\n", 598 LOG_DEBUG("Added host %u at %u\n",
598 host_id, 599 host_id,
599 GST_context->host_id); 600 GST_context->host_id);
600 env = GNUNET_MQ_msg (reply, 601 env = GNUNET_MQ_msg(reply,
601 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS); 602 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS);
602 } 603 }
603 reply->host_id = htonl (host_id); 604 reply->host_id = htonl(host_id);
604 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 605 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client),
605 env); 606 env);
606 GNUNET_SERVICE_client_continue (client); 607 GNUNET_SERVICE_client_continue(client);
607} 608}
608 609
609 610
@@ -614,8 +615,8 @@ handle_add_host (void *cls,
614 * @param msg the actual message 615 * @param msg the actual message
615 */ 616 */
616static void 617static void
617handle_slave_get_config (void *cls, 618handle_slave_get_config(void *cls,
618 const struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg) 619 const struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg)
619{ 620{
620 struct GNUNET_SERVICE_Client *client = cls; 621 struct GNUNET_SERVICE_Client *client = cls;
621 struct Slave *slave; 622 struct Slave *slave;
@@ -629,42 +630,42 @@ handle_slave_get_config (void *cls,
629 uint64_t op_id; 630 uint64_t op_id;
630 uint32_t slave_id; 631 uint32_t slave_id;
631 632
632 slave_id = ntohl (msg->slave_id); 633 slave_id = ntohl(msg->slave_id);
633 op_id = GNUNET_ntohll (msg->operation_id); 634 op_id = GNUNET_ntohll(msg->operation_id);
634 if ( (GST_slave_list_size <= slave_id) || 635 if ((GST_slave_list_size <= slave_id) ||
635 (NULL == GST_slave_list[slave_id]) ) 636 (NULL == GST_slave_list[slave_id]))
636 { 637 {
637 /* FIXME: Add forwardings for this type of message here.. */ 638 /* FIXME: Add forwardings for this type of message here.. */
638 GST_send_operation_fail_msg (client, 639 GST_send_operation_fail_msg(client,
639 op_id, 640 op_id,
640 "Slave not found"); 641 "Slave not found");
641 GNUNET_SERVICE_client_continue (client); 642 GNUNET_SERVICE_client_continue(client);
642 return; 643 return;
643 } 644 }
644 slave = GST_slave_list[slave_id]; 645 slave = GST_slave_list[slave_id];
645 GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (GST_host_list[slave->host_id]))); 646 GNUNET_assert(NULL != (cfg = GNUNET_TESTBED_host_get_cfg_(GST_host_list[slave->host_id])));
646 config = GNUNET_CONFIGURATION_serialize (cfg, 647 config = GNUNET_CONFIGURATION_serialize(cfg,
647 &config_size); 648 &config_size);
648 /* FIXME: maybe we want to transmit the delta to the default here? */ 649 /* FIXME: maybe we want to transmit the delta to the default here? */
649 xconfig_size = GNUNET_TESTBED_compress_config_ (config, 650 xconfig_size = GNUNET_TESTBED_compress_config_(config,
650 config_size, 651 config_size,
651 &xconfig); 652 &xconfig);
652 GNUNET_free (config); 653 GNUNET_free(config);
653 GNUNET_assert (xconfig_size + sizeof (struct GNUNET_TESTBED_SlaveConfiguration) <= UINT16_MAX); 654 GNUNET_assert(xconfig_size + sizeof(struct GNUNET_TESTBED_SlaveConfiguration) <= UINT16_MAX);
654 GNUNET_assert (xconfig_size <= UINT16_MAX); 655 GNUNET_assert(xconfig_size <= UINT16_MAX);
655 env = GNUNET_MQ_msg_extra (reply, 656 env = GNUNET_MQ_msg_extra(reply,
656 xconfig_size, 657 xconfig_size,
657 GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION); 658 GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION);
658 reply->slave_id = msg->slave_id; 659 reply->slave_id = msg->slave_id;
659 reply->operation_id = msg->operation_id; 660 reply->operation_id = msg->operation_id;
660 reply->config_size = htons ((uint16_t) config_size); 661 reply->config_size = htons((uint16_t)config_size);
661 GNUNET_memcpy (&reply[1], 662 GNUNET_memcpy(&reply[1],
662 xconfig, 663 xconfig,
663 xconfig_size); 664 xconfig_size);
664 GNUNET_free (xconfig); 665 GNUNET_free(xconfig);
665 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 666 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client),
666 env); 667 env);
667 GNUNET_SERVICE_client_continue (client); 668 GNUNET_SERVICE_client_continue(client);
668} 669}
669 670
670 671
@@ -672,48 +673,52 @@ handle_slave_get_config (void *cls,
672 * Clears the forwarded operations queue 673 * Clears the forwarded operations queue
673 */ 674 */
674void 675void
675GST_clear_fopcq () 676GST_clear_fopcq()
676{ 677{
677 struct ForwardedOperationContext *fopc; 678 struct ForwardedOperationContext *fopc;
678 679
679 while (NULL != (fopc = fopcq_head)) 680 while (NULL != (fopc = fopcq_head))
680 {
681 GNUNET_CONTAINER_DLL_remove (fopcq_head,
682 fopcq_tail,
683 fopc);
684 GNUNET_TESTBED_forward_operation_msg_cancel_ (fopc->opc);
685 if (NULL != fopc->timeout_task)
686 GNUNET_SCHEDULER_cancel (fopc->timeout_task);
687 switch (fopc->type)
688 { 681 {
689 case OP_PEER_CREATE: 682 GNUNET_CONTAINER_DLL_remove(fopcq_head,
690 GNUNET_free (fopc->cls); 683 fopcq_tail,
691 break; 684 fopc);
692 case OP_SHUTDOWN_PEERS: 685 GNUNET_TESTBED_forward_operation_msg_cancel_(fopc->opc);
693 { 686 if (NULL != fopc->timeout_task)
694 struct HandlerContext_ShutdownPeers *hc = fopc->cls; 687 GNUNET_SCHEDULER_cancel(fopc->timeout_task);
695 688 switch (fopc->type)
696 GNUNET_assert (0 < hc->nslaves); 689 {
697 hc->nslaves--; 690 case OP_PEER_CREATE:
698 if (0 == hc->nslaves) 691 GNUNET_free(fopc->cls);
699 GNUNET_free (hc); 692 break;
700 } 693
701 break; 694 case OP_SHUTDOWN_PEERS:
702 case OP_PEER_START: 695 {
703 case OP_PEER_STOP: 696 struct HandlerContext_ShutdownPeers *hc = fopc->cls;
704 case OP_PEER_DESTROY: 697
705 case OP_PEER_INFO: 698 GNUNET_assert(0 < hc->nslaves);
706 case OP_OVERLAY_CONNECT: 699 hc->nslaves--;
707 case OP_LINK_CONTROLLERS: 700 if (0 == hc->nslaves)
708 case OP_GET_SLAVE_CONFIG: 701 GNUNET_free(hc);
709 case OP_MANAGE_SERVICE: 702 }
710 case OP_PEER_RECONFIGURE: 703 break;
711 break; 704
712 case OP_FORWARDED: 705 case OP_PEER_START:
713 GNUNET_assert (0); 706 case OP_PEER_STOP:
714 }; 707 case OP_PEER_DESTROY:
715 GNUNET_free (fopc); 708 case OP_PEER_INFO:
716 } 709 case OP_OVERLAY_CONNECT:
710 case OP_LINK_CONTROLLERS:
711 case OP_GET_SLAVE_CONFIG:
712 case OP_MANAGE_SERVICE:
713 case OP_PEER_RECONFIGURE:
714 break;
715
716 case OP_FORWARDED:
717 GNUNET_assert(0);
718 }
719 ;
720 GNUNET_free(fopc);
721 }
717} 722}
718 723
719 724
@@ -723,49 +728,49 @@ GST_clear_fopcq ()
723 * @param cls NULL 728 * @param cls NULL
724 */ 729 */
725static void 730static void
726shutdown_task (void *cls) 731shutdown_task(void *cls)
727{ 732{
728 uint32_t id; 733 uint32_t id;
729 734
730 LOG_DEBUG ("Shutting down testbed service\n"); 735 LOG_DEBUG("Shutting down testbed service\n");
731 /* cleanup any remaining forwarded operations */ 736 /* cleanup any remaining forwarded operations */
732 GST_clear_fopcq (); 737 GST_clear_fopcq();
733 GST_free_lcf (); 738 GST_free_lcf();
734 GST_free_mctxq (); 739 GST_free_mctxq();
735 GST_free_occq (); 740 GST_free_occq();
736 GST_free_roccq (); 741 GST_free_roccq();
737 GST_free_nccq (); 742 GST_free_nccq();
738 GST_neighbour_list_clean(); 743 GST_neighbour_list_clean();
739 GST_free_prcq (); 744 GST_free_prcq();
740 /* Clear peer list */ 745 /* Clear peer list */
741 GST_destroy_peers (); 746 GST_destroy_peers();
742 /* Clear route list */ 747 /* Clear route list */
743 GST_route_list_clear (); 748 GST_route_list_clear();
744 /* Clear GST_slave_list */ 749 /* Clear GST_slave_list */
745 GST_slave_list_clear (); 750 GST_slave_list_clear();
746 /* Clear host list */ 751 /* Clear host list */
747 for (id = 0; id < GST_host_list_size; id++) 752 for (id = 0; id < GST_host_list_size; id++)
748 if (NULL != GST_host_list[id]) 753 if (NULL != GST_host_list[id])
749 GNUNET_TESTBED_host_destroy (GST_host_list[id]); 754 GNUNET_TESTBED_host_destroy(GST_host_list[id]);
750 GNUNET_free_non_null (GST_host_list); 755 GNUNET_free_non_null(GST_host_list);
751 if (NULL != GST_context) 756 if (NULL != GST_context)
752 { 757 {
753 GNUNET_free_non_null (GST_context->master_ip); 758 GNUNET_free_non_null(GST_context->master_ip);
754 if (NULL != GST_context->system) 759 if (NULL != GST_context->system)
755 GNUNET_TESTING_system_destroy (GST_context->system, 760 GNUNET_TESTING_system_destroy(GST_context->system,
756 GNUNET_YES); 761 GNUNET_YES);
757 GNUNET_free (GST_context); 762 GNUNET_free(GST_context);
758 GST_context = NULL; 763 GST_context = NULL;
759 } 764 }
760 GNUNET_free_non_null (hostname); 765 GNUNET_free_non_null(hostname);
761 /* Free hello cache */ 766 /* Free hello cache */
762 GST_cache_clear (); 767 GST_cache_clear();
763 GST_connection_pool_destroy (); 768 GST_connection_pool_destroy();
764 GNUNET_TESTBED_operation_queue_destroy_ (GST_opq_openfds); 769 GNUNET_TESTBED_operation_queue_destroy_(GST_opq_openfds);
765 GST_opq_openfds = NULL; 770 GST_opq_openfds = NULL;
766 GST_stats_destroy (); 771 GST_stats_destroy();
767 GST_barriers_destroy (); 772 GST_barriers_destroy();
768 GNUNET_CONFIGURATION_destroy (GST_config); 773 GNUNET_CONFIGURATION_destroy(GST_config);
769} 774}
770 775
771 776
@@ -778,9 +783,9 @@ shutdown_task (void *cls)
778 * @return @a client 783 * @return @a client
779 */ 784 */
780static void * 785static void *
781client_connect_cb (void *cls, 786client_connect_cb(void *cls,
782 struct GNUNET_SERVICE_Client *client, 787 struct GNUNET_SERVICE_Client *client,
783 struct GNUNET_MQ_Handle *mq) 788 struct GNUNET_MQ_Handle *mq)
784{ 789{
785 return client; 790 return client;
786} 791}
@@ -794,41 +799,41 @@ client_connect_cb (void *cls,
794 * @param app_ctx should match @a client 799 * @param app_ctx should match @a client
795 */ 800 */
796static void 801static void
797client_disconnect_cb (void *cls, 802client_disconnect_cb(void *cls,
798 struct GNUNET_SERVICE_Client *client, 803 struct GNUNET_SERVICE_Client *client,
799 void *app_ctx) 804 void *app_ctx)
800{ 805{
801 struct ForwardedOperationContext *fopc; 806 struct ForwardedOperationContext *fopc;
802 struct ForwardedOperationContext *fopcn; 807 struct ForwardedOperationContext *fopcn;
803 808
804 GNUNET_assert (client == app_ctx); 809 GNUNET_assert(client == app_ctx);
805 GST_notify_client_disconnect_oc (client); 810 GST_notify_client_disconnect_oc(client);
806 GST_link_notify_disconnect (client); 811 GST_link_notify_disconnect(client);
807 GST_notify_client_disconnect_peers (client); 812 GST_notify_client_disconnect_peers(client);
808 for (fopc = fopcq_head; NULL != fopc; fopc = fopcn) 813 for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
809 {
810 fopcn = fopc->next;
811 if (fopc->client == client)
812 { 814 {
813 /* handle as if it were a timeout */ 815 fopcn = fopc->next;
814 GNUNET_SCHEDULER_cancel (fopc->timeout_task); 816 if (fopc->client == client)
815 GST_forwarded_operation_timeout (fopc); 817 {
818 /* handle as if it were a timeout */
819 GNUNET_SCHEDULER_cancel(fopc->timeout_task);
820 GST_forwarded_operation_timeout(fopc);
821 }
816 } 822 }
817 }
818 if (NULL == GST_context) 823 if (NULL == GST_context)
819 return; 824 return;
820 if (client == GST_context->client) 825 if (client == GST_context->client)
821 { 826 {
822 LOG (GNUNET_ERROR_TYPE_DEBUG, 827 LOG(GNUNET_ERROR_TYPE_DEBUG,
823 "Master client disconnected\n"); 828 "Master client disconnected\n");
824 GST_context->client = NULL; 829 GST_context->client = NULL;
825 /* should not be needed as we're terminated by failure to read 830 /* should not be needed as we're terminated by failure to read
826 * from stdin, but if stdin fails for some reason, this shouldn't 831 * from stdin, but if stdin fails for some reason, this shouldn't
827 * hurt for now --- might need to revise this later if we ever 832 * hurt for now --- might need to revise this later if we ever
828 * decide that master connections might be temporarily down 833 * decide that master connections might be temporarily down
829 * for some reason */ 834 * for some reason */
830 //GNUNET_SCHEDULER_shutdown (); 835 //GNUNET_SCHEDULER_shutdown ();
831 } 836 }
832} 837}
833 838
834 839
@@ -840,54 +845,54 @@ client_disconnect_cb (void *cls,
840 * @param service the initialized server 845 * @param service the initialized server
841 */ 846 */
842static void 847static void
843testbed_run (void *cls, 848testbed_run(void *cls,
844 const struct GNUNET_CONFIGURATION_Handle *cfg, 849 const struct GNUNET_CONFIGURATION_Handle *cfg,
845 struct GNUNET_SERVICE_Handle *service) 850 struct GNUNET_SERVICE_Handle *service)
846{ 851{
847 char *logfile; 852 char *logfile;
848 unsigned long long num; 853 unsigned long long num;
849 854
850 LOG_DEBUG ("Starting testbed\n"); 855 LOG_DEBUG("Starting testbed\n");
851 if (GNUNET_OK == 856 if (GNUNET_OK ==
852 GNUNET_CONFIGURATION_get_value_filename (cfg, "TESTBED", "LOG_FILE", 857 GNUNET_CONFIGURATION_get_value_filename(cfg, "TESTBED", "LOG_FILE",
853 &logfile)) 858 &logfile))
854 { 859 {
855 GNUNET_break (GNUNET_OK == 860 GNUNET_break(GNUNET_OK ==
856 GNUNET_log_setup ("testbed", 861 GNUNET_log_setup("testbed",
857 "DEBUG", 862 "DEBUG",
858 logfile)); 863 logfile));
859 GNUNET_free (logfile); 864 GNUNET_free(logfile);
860 } 865 }
861 GNUNET_assert (GNUNET_OK == 866 GNUNET_assert(GNUNET_OK ==
862 GNUNET_CONFIGURATION_get_value_number (cfg, 867 GNUNET_CONFIGURATION_get_value_number(cfg,
863 "testbed", 868 "testbed",
864 "CACHE_SIZE", 869 "CACHE_SIZE",
865 &num)); 870 &num));
866 GST_cache_init ((unsigned int) num); 871 GST_cache_init((unsigned int)num);
867 GST_connection_pool_init ((unsigned int) num); 872 GST_connection_pool_init((unsigned int)num);
868 GNUNET_assert (GNUNET_OK == 873 GNUNET_assert(GNUNET_OK ==
869 GNUNET_CONFIGURATION_get_value_number (cfg, 874 GNUNET_CONFIGURATION_get_value_number(cfg,
870 "testbed", 875 "testbed",
871 "MAX_OPEN_FDS", 876 "MAX_OPEN_FDS",
872 &num)); 877 &num));
873 GST_opq_openfds = GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_FIXED, 878 GST_opq_openfds = GNUNET_TESTBED_operation_queue_create_(OPERATION_QUEUE_TYPE_FIXED,
874 (unsigned int) num); 879 (unsigned int)num);
875 GNUNET_assert (GNUNET_OK == 880 GNUNET_assert(GNUNET_OK ==
876 GNUNET_CONFIGURATION_get_value_time (cfg, 881 GNUNET_CONFIGURATION_get_value_time(cfg,
882 "testbed",
883 "OPERATION_TIMEOUT",
884 &GST_timeout));
885 GNUNET_assert(GNUNET_OK ==
886 GNUNET_CONFIGURATION_get_value_string(cfg,
877 "testbed", 887 "testbed",
878 "OPERATION_TIMEOUT", 888 "HOSTNAME",
879 &GST_timeout)); 889 &hostname));
880 GNUNET_assert (GNUNET_OK == 890 GST_config = GNUNET_CONFIGURATION_dup(cfg);
881 GNUNET_CONFIGURATION_get_value_string (cfg, 891 GNUNET_SCHEDULER_add_shutdown(&shutdown_task,
882 "testbed", 892 NULL);
883 "HOSTNAME", 893 LOG_DEBUG("Testbed startup complete\n");
884 &hostname)); 894 GST_stats_init(GST_config);
885 GST_config = GNUNET_CONFIGURATION_dup (cfg); 895 GST_barriers_init(GST_config);
886 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
887 NULL);
888 LOG_DEBUG ("Testbed startup complete\n");
889 GST_stats_init (GST_config);
890 GST_barriers_init (GST_config);
891} 896}
892 897
893 898
@@ -895,81 +900,81 @@ testbed_run (void *cls,
895 * Define "main" method using service macro. 900 * Define "main" method using service macro.
896 */ 901 */
897GNUNET_SERVICE_MAIN 902GNUNET_SERVICE_MAIN
898("testbed", 903 ("testbed",
899 GNUNET_SERVICE_OPTION_NONE, 904 GNUNET_SERVICE_OPTION_NONE,
900 &testbed_run, 905 &testbed_run,
901 &client_connect_cb, 906 &client_connect_cb,
902 &client_disconnect_cb, 907 &client_disconnect_cb,
903 NULL, 908 NULL,
904 GNUNET_MQ_hd_var_size (init, 909 GNUNET_MQ_hd_var_size(init,
905 GNUNET_MESSAGE_TYPE_TESTBED_INIT, 910 GNUNET_MESSAGE_TYPE_TESTBED_INIT,
906 struct GNUNET_TESTBED_InitMessage, 911 struct GNUNET_TESTBED_InitMessage,
907 NULL), 912 NULL),
908 GNUNET_MQ_hd_var_size (add_host, 913 GNUNET_MQ_hd_var_size(add_host,
909 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, 914 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST,
910 struct GNUNET_TESTBED_AddHostMessage, 915 struct GNUNET_TESTBED_AddHostMessage,
911 NULL), 916 NULL),
912 GNUNET_MQ_hd_fixed_size (slave_get_config, 917 GNUNET_MQ_hd_fixed_size(slave_get_config,
913 GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION, 918 GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION,
914 struct GNUNET_TESTBED_SlaveGetConfigurationMessage, 919 struct GNUNET_TESTBED_SlaveGetConfigurationMessage,
915 NULL), 920 NULL),
916 GNUNET_MQ_hd_fixed_size (link_controllers, 921 GNUNET_MQ_hd_fixed_size(link_controllers,
917 GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS, 922 GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS,
918 struct GNUNET_TESTBED_ControllerLinkRequest, 923 struct GNUNET_TESTBED_ControllerLinkRequest,
919 NULL), 924 NULL),
920 GNUNET_MQ_hd_var_size (remote_overlay_connect, 925 GNUNET_MQ_hd_var_size(remote_overlay_connect,
921 GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT, 926 GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT,
922 struct GNUNET_TESTBED_RemoteOverlayConnectMessage, 927 struct GNUNET_TESTBED_RemoteOverlayConnectMessage,
923 NULL), 928 NULL),
924 GNUNET_MQ_hd_fixed_size (overlay_connect, 929 GNUNET_MQ_hd_fixed_size(overlay_connect,
925 GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT, 930 GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT,
926 struct GNUNET_TESTBED_OverlayConnectMessage, 931 struct GNUNET_TESTBED_OverlayConnectMessage,
927 NULL), 932 NULL),
928 GNUNET_MQ_hd_var_size (peer_create, 933 GNUNET_MQ_hd_var_size(peer_create,
929 GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER, 934 GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER,
930 struct GNUNET_TESTBED_PeerCreateMessage, 935 struct GNUNET_TESTBED_PeerCreateMessage,
931 NULL), 936 NULL),
932 GNUNET_MQ_hd_fixed_size (peer_destroy, 937 GNUNET_MQ_hd_fixed_size(peer_destroy,
933 GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER, 938 GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER,
934 struct GNUNET_TESTBED_PeerDestroyMessage, 939 struct GNUNET_TESTBED_PeerDestroyMessage,
935 NULL), 940 NULL),
936 GNUNET_MQ_hd_fixed_size (peer_start, 941 GNUNET_MQ_hd_fixed_size(peer_start,
937 GNUNET_MESSAGE_TYPE_TESTBED_START_PEER, 942 GNUNET_MESSAGE_TYPE_TESTBED_START_PEER,
938 struct GNUNET_TESTBED_PeerStartMessage, 943 struct GNUNET_TESTBED_PeerStartMessage,
939 NULL), 944 NULL),
940 GNUNET_MQ_hd_fixed_size (peer_stop, 945 GNUNET_MQ_hd_fixed_size(peer_stop,
941 GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER, 946 GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER,
942 struct GNUNET_TESTBED_PeerStopMessage, 947 struct GNUNET_TESTBED_PeerStopMessage,
943 NULL), 948 NULL),
944 GNUNET_MQ_hd_fixed_size (peer_get_config, 949 GNUNET_MQ_hd_fixed_size(peer_get_config,
945 GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION, 950 GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION,
946 struct GNUNET_TESTBED_PeerGetConfigurationMessage, 951 struct GNUNET_TESTBED_PeerGetConfigurationMessage,
947 NULL), 952 NULL),
948 GNUNET_MQ_hd_var_size (manage_peer_service, 953 GNUNET_MQ_hd_var_size(manage_peer_service,
949 GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE, 954 GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE,
950 struct GNUNET_TESTBED_ManagePeerServiceMessage, 955 struct GNUNET_TESTBED_ManagePeerServiceMessage,
951 NULL), 956 NULL),
952 GNUNET_MQ_hd_fixed_size (shutdown_peers, 957 GNUNET_MQ_hd_fixed_size(shutdown_peers,
953 GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS, 958 GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS,
954 struct GNUNET_TESTBED_ShutdownPeersMessage, 959 struct GNUNET_TESTBED_ShutdownPeersMessage,
955 NULL), 960 NULL),
956 GNUNET_MQ_hd_var_size (peer_reconfigure, 961 GNUNET_MQ_hd_var_size(peer_reconfigure,
957 GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER, 962 GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER,
958 struct GNUNET_TESTBED_PeerReconfigureMessage, 963 struct GNUNET_TESTBED_PeerReconfigureMessage,
959 NULL), 964 NULL),
960 GNUNET_MQ_hd_var_size (barrier_init, 965 GNUNET_MQ_hd_var_size(barrier_init,
961 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT, 966 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT,
962 struct GNUNET_TESTBED_BarrierInit, 967 struct GNUNET_TESTBED_BarrierInit,
963 NULL), 968 NULL),
964 GNUNET_MQ_hd_var_size (barrier_cancel, 969 GNUNET_MQ_hd_var_size(barrier_cancel,
965 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL, 970 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL,
966 struct GNUNET_TESTBED_BarrierCancel, 971 struct GNUNET_TESTBED_BarrierCancel,
967 NULL), 972 NULL),
968 GNUNET_MQ_hd_var_size (barrier_status, 973 GNUNET_MQ_hd_var_size(barrier_status,
969 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS, 974 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS,
970 struct GNUNET_TESTBED_BarrierStatusMsg, 975 struct GNUNET_TESTBED_BarrierStatusMsg,
971 NULL), 976 NULL),
972 GNUNET_MQ_handler_end ()); 977 GNUNET_MQ_handler_end());
973 978
974 979
975/* end of gnunet-service-testbed.c */ 980/* end of gnunet-service-testbed.c */