aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api.c')
-rw-r--r--src/testbed/testbed_api.c1858
1 files changed, 933 insertions, 925 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 8ca96dcbe..38913509b 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -44,30 +44,31 @@
44/** 44/**
45 * Generic logging shorthand 45 * Generic logging shorthand
46 */ 46 */
47#define LOG(kind, ...) GNUNET_log_from(kind, "testbed-api", __VA_ARGS__) 47#define LOG(kind, ...) GNUNET_log_from (kind, "testbed-api", __VA_ARGS__)
48 48
49/** 49/**
50 * Debug logging 50 * Debug logging
51 */ 51 */
52#define LOG_DEBUG(...) LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) 52#define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
53 53
54/** 54/**
55 * Relative time seconds shorthand 55 * Relative time seconds shorthand
56 */ 56 */
57#define TIME_REL_SECS(sec) \ 57#define TIME_REL_SECS(sec) \
58 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, sec) 58 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
59 59
60 60
61/** 61/**
62 * Default server message sending retry timeout 62 * Default server message sending retry timeout
63 */ 63 */
64#define TIMEOUT_REL TIME_REL_SECS(1) 64#define TIMEOUT_REL TIME_REL_SECS (1)
65 65
66 66
67/** 67/**
68 * Context data for forwarded Operation 68 * Context data for forwarded Operation
69 */ 69 */
70struct ForwardedOperationData { 70struct ForwardedOperationData
71{
71 /** 72 /**
72 * The callback to call when reply is available 73 * The callback to call when reply is available
73 */ 74 */
@@ -83,7 +84,8 @@ struct ForwardedOperationData {
83/** 84/**
84 * Context data for get slave config operations 85 * Context data for get slave config operations
85 */ 86 */
86struct GetSlaveConfigData { 87struct GetSlaveConfigData
88{
87 /** 89 /**
88 * The id of the slave controller 90 * The id of the slave controller
89 */ 91 */
@@ -94,7 +96,8 @@ struct GetSlaveConfigData {
94/** 96/**
95 * Context data for controller link operations 97 * Context data for controller link operations
96 */ 98 */
97struct ControllerLinkData { 99struct ControllerLinkData
100{
98 /** 101 /**
99 * The controller link message 102 * The controller link message
100 */ 103 */
@@ -110,7 +113,8 @@ struct ControllerLinkData {
110/** 113/**
111 * Date context for OP_SHUTDOWN_PEERS operations 114 * Date context for OP_SHUTDOWN_PEERS operations
112 */ 115 */
113struct ShutdownPeersData { 116struct ShutdownPeersData
117{
114 /** 118 /**
115 * The operation completion callback to call 119 * The operation completion callback to call
116 */ 120 */
@@ -126,7 +130,8 @@ struct ShutdownPeersData {
126/** 130/**
127 * An entry in the stack for keeping operations which are about to expire 131 * An entry in the stack for keeping operations which are about to expire
128 */ 132 */
129struct ExpireOperationEntry { 133struct ExpireOperationEntry
134{
130 /** 135 /**
131 * DLL head; new entries are to be inserted here 136 * DLL head; new entries are to be inserted here
132 */ 137 */
@@ -161,13 +166,13 @@ static struct ExpireOperationEntry *exop_tail;
161 * @param op the operation to insert 166 * @param op the operation to insert
162 */ 167 */
163static void 168static void
164exop_insert(struct GNUNET_TESTBED_Operation *op) 169exop_insert (struct GNUNET_TESTBED_Operation *op)
165{ 170{
166 struct ExpireOperationEntry *entry; 171 struct ExpireOperationEntry *entry;
167 172
168 entry = GNUNET_new(struct ExpireOperationEntry); 173 entry = GNUNET_new (struct ExpireOperationEntry);
169 entry->op = op; 174 entry->op = op;
170 GNUNET_CONTAINER_DLL_insert_tail(exop_head, exop_tail, entry); 175 GNUNET_CONTAINER_DLL_insert_tail (exop_head, exop_tail, entry);
171} 176}
172 177
173 178
@@ -183,7 +188,7 @@ exop_insert(struct GNUNET_TESTBED_Operation *op)
183 * paramenter will return GNUNET_NO) 188 * paramenter will return GNUNET_NO)
184 */ 189 */
185static int 190static int
186exop_check(const struct GNUNET_TESTBED_Operation *const op) 191exop_check (const struct GNUNET_TESTBED_Operation *const op)
187{ 192{
188 struct ExpireOperationEntry *entry; 193 struct ExpireOperationEntry *entry;
189 struct ExpireOperationEntry *entry2; 194 struct ExpireOperationEntry *entry2;
@@ -192,24 +197,24 @@ exop_check(const struct GNUNET_TESTBED_Operation *const op)
192 found = GNUNET_NO; 197 found = GNUNET_NO;
193 entry = exop_head; 198 entry = exop_head;
194 while (NULL != entry) 199 while (NULL != entry)
200 {
201 if (op == entry->op)
195 { 202 {
196 if (op == entry->op) 203 found = GNUNET_YES;
197 { 204 break;
198 found = GNUNET_YES;
199 break;
200 }
201 entry = entry->next;
202 } 205 }
206 entry = entry->next;
207 }
203 if (GNUNET_NO == found) 208 if (GNUNET_NO == found)
204 return GNUNET_NO; 209 return GNUNET_NO;
205 /* Truncate the tail */ 210 /* Truncate the tail */
206 while (NULL != entry) 211 while (NULL != entry)
207 { 212 {
208 entry2 = entry->next; 213 entry2 = entry->next;
209 GNUNET_CONTAINER_DLL_remove(exop_head, exop_tail, entry); 214 GNUNET_CONTAINER_DLL_remove (exop_head, exop_tail, entry);
210 GNUNET_free(entry); 215 GNUNET_free (entry);
211 entry = entry2; 216 entry = entry2;
212 } 217 }
213 return GNUNET_YES; 218 return GNUNET_YES;
214} 219}
215 220
@@ -217,7 +222,8 @@ exop_check(const struct GNUNET_TESTBED_Operation *const op)
217/** 222/**
218 * Context information to be used while searching for operation contexts 223 * Context information to be used while searching for operation contexts
219 */ 224 */
220struct SearchContext { 225struct SearchContext
226{
221 /** 227 /**
222 * The result of the search 228 * The result of the search
223 */ 229 */
@@ -240,13 +246,13 @@ struct SearchContext {
240 * #GNUNET_NO if not. 246 * #GNUNET_NO if not.
241 */ 247 */
242static int 248static int
243opc_search_iterator(void *cls, uint32_t key, void *value) 249opc_search_iterator (void *cls, uint32_t key, void *value)
244{ 250{
245 struct SearchContext *sc = cls; 251 struct SearchContext *sc = cls;
246 struct OperationContext *opc = value; 252 struct OperationContext *opc = value;
247 253
248 GNUNET_assert(NULL != opc); 254 GNUNET_assert (NULL != opc);
249 GNUNET_assert(NULL == sc->opc); 255 GNUNET_assert (NULL == sc->opc);
250 if (opc->id != sc->id) 256 if (opc->id != sc->id)
251 return GNUNET_YES; 257 return GNUNET_YES;
252 sc->opc = opc; 258 sc->opc = opc;
@@ -263,18 +269,18 @@ opc_search_iterator(void *cls, uint32_t key, void *value)
263 * @return the matching operation context; NULL if no match found 269 * @return the matching operation context; NULL if no match found
264 */ 270 */
265static struct OperationContext * 271static struct OperationContext *
266find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id) 272find_opc (const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
267{ 273{
268 struct SearchContext sc; 274 struct SearchContext sc;
269 275
270 sc.id = id; 276 sc.id = id;
271 sc.opc = NULL; 277 sc.opc = NULL;
272 GNUNET_assert(NULL != c->opc_map); 278 GNUNET_assert (NULL != c->opc_map);
273 if (GNUNET_SYSERR != 279 if (GNUNET_SYSERR !=
274 GNUNET_CONTAINER_multihashmap32_get_multiple(c->opc_map, 280 GNUNET_CONTAINER_multihashmap32_get_multiple (c->opc_map,
275 (uint32_t)id, 281 (uint32_t) id,
276 &opc_search_iterator, 282 &opc_search_iterator,
277 &sc)) 283 &sc))
278 return NULL; 284 return NULL;
279 return sc.opc; 285 return sc.opc;
280} 286}
@@ -289,16 +295,16 @@ find_opc(const struct GNUNET_TESTBED_Controller *c, const uint64_t id)
289 * @param opc the operation context to be inserted 295 * @param opc the operation context to be inserted
290 */ 296 */
291void 297void
292GNUNET_TESTBED_insert_opc_(struct GNUNET_TESTBED_Controller *c, 298GNUNET_TESTBED_insert_opc_ (struct GNUNET_TESTBED_Controller *c,
293 struct OperationContext *opc) 299 struct OperationContext *opc)
294{ 300{
295 if (NULL == c->opc_map) 301 if (NULL == c->opc_map)
296 c->opc_map = GNUNET_CONTAINER_multihashmap32_create(256); 302 c->opc_map = GNUNET_CONTAINER_multihashmap32_create (256);
297 GNUNET_assert(GNUNET_OK == GNUNET_CONTAINER_multihashmap32_put( 303 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap32_put (
298 c->opc_map, 304 c->opc_map,
299 (uint32_t)opc->id, 305 (uint32_t) opc->id,
300 opc, 306 opc,
301 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 307 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
302} 308}
303 309
304 310
@@ -310,17 +316,17 @@ GNUNET_TESTBED_insert_opc_(struct GNUNET_TESTBED_Controller *c,
310 * @param opc the operation context to remove 316 * @param opc the operation context to remove
311 */ 317 */
312void 318void
313GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c, 319GNUNET_TESTBED_remove_opc_ (const struct GNUNET_TESTBED_Controller *c,
314 struct OperationContext *opc) 320 struct OperationContext *opc)
315{ 321{
316 GNUNET_assert(NULL != c->opc_map); 322 GNUNET_assert (NULL != c->opc_map);
317 GNUNET_assert(GNUNET_YES == 323 GNUNET_assert (GNUNET_YES ==
318 GNUNET_CONTAINER_multihashmap32_remove(c->opc_map, 324 GNUNET_CONTAINER_multihashmap32_remove (c->opc_map,
319 (uint32_t)opc->id, 325 (uint32_t) opc->id,
320 opc)); 326 opc));
321 if ((0 == GNUNET_CONTAINER_multihashmap32_size(c->opc_map)) && 327 if ((0 == GNUNET_CONTAINER_multihashmap32_size (c->opc_map)) &&
322 (NULL != c->opcq_empty_cb)) 328 (NULL != c->opcq_empty_cb))
323 c->opcq_empty_cb(c->opcq_empty_cls); 329 c->opcq_empty_cb (c->opcq_empty_cls);
324} 330}
325 331
326 332
@@ -332,22 +338,22 @@ GNUNET_TESTBED_remove_opc_(const struct GNUNET_TESTBED_Controller *c,
332 * @return #GNUNET_OK if message is well-formed 338 * @return #GNUNET_OK if message is well-formed
333 */ 339 */
334static int 340static int
335check_add_host_confirm(void *cls, 341check_add_host_confirm (void *cls,
336 const struct GNUNET_TESTBED_HostConfirmedMessage *msg) 342 const struct GNUNET_TESTBED_HostConfirmedMessage *msg)
337{ 343{
338 const char *emsg; 344 const char *emsg;
339 uint16_t msg_size; 345 uint16_t msg_size;
340 346
341 msg_size = ntohs(msg->header.size) - sizeof(*msg); 347 msg_size = ntohs (msg->header.size) - sizeof(*msg);
342 if (0 == msg_size) 348 if (0 == msg_size)
343 return GNUNET_OK; 349 return GNUNET_OK;
344 /* We have an error message */ 350 /* We have an error message */
345 emsg = (const char *)&msg[1]; 351 emsg = (const char *) &msg[1];
346 if ('\0' != emsg[msg_size - 1]) 352 if ('\0' != emsg[msg_size - 1])
347 { 353 {
348 GNUNET_break(0); 354 GNUNET_break (0);
349 return GNUNET_SYSERR; 355 return GNUNET_SYSERR;
350 } 356 }
351 return GNUNET_OK; 357 return GNUNET_OK;
352} 358}
353 359
@@ -360,8 +366,8 @@ check_add_host_confirm(void *cls,
360 * @param msg message received 366 * @param msg message received
361 */ 367 */
362static void 368static void
363handle_add_host_confirm(void *cls, 369handle_add_host_confirm (void *cls,
364 const struct GNUNET_TESTBED_HostConfirmedMessage *msg) 370 const struct GNUNET_TESTBED_HostConfirmedMessage *msg)
365{ 371{
366 struct GNUNET_TESTBED_Controller *c = cls; 372 struct GNUNET_TESTBED_Controller *c = cls;
367 struct GNUNET_TESTBED_HostRegistrationHandle *rh = c->rh; 373 struct GNUNET_TESTBED_HostRegistrationHandle *rh = c->rh;
@@ -370,31 +376,31 @@ handle_add_host_confirm(void *cls,
370 376
371 if (NULL == rh) 377 if (NULL == rh)
372 return; 378 return;
373 if (GNUNET_TESTBED_host_get_id_(rh->host) != ntohl(msg->host_id)) 379 if (GNUNET_TESTBED_host_get_id_ (rh->host) != ntohl (msg->host_id))
374 { 380 {
375 LOG_DEBUG("Mismatch in host id's %u, %u of host confirm msg\n", 381 LOG_DEBUG ("Mismatch in host id's %u, %u of host confirm msg\n",
376 GNUNET_TESTBED_host_get_id_(rh->host), 382 GNUNET_TESTBED_host_get_id_ (rh->host),
377 ntohl(msg->host_id)); 383 ntohl (msg->host_id));
378 return; 384 return;
379 } 385 }
380 c->rh = NULL; 386 c->rh = NULL;
381 msg_size = ntohs(msg->header.size) - sizeof(*msg); 387 msg_size = ntohs (msg->header.size) - sizeof(*msg);
382 if (0 == msg_size) 388 if (0 == msg_size)
383 { 389 {
384 LOG_DEBUG("Host %u successfully registered\n", ntohl(msg->host_id)); 390 LOG_DEBUG ("Host %u successfully registered\n", ntohl (msg->host_id));
385 GNUNET_TESTBED_mark_host_registered_at_(rh->host, c); 391 GNUNET_TESTBED_mark_host_registered_at_ (rh->host, c);
386 rh->cc(rh->cc_cls, NULL); 392 rh->cc (rh->cc_cls, NULL);
387 GNUNET_free(rh); 393 GNUNET_free (rh);
388 return; 394 return;
389 } 395 }
390 /* We have an error message */ 396 /* We have an error message */
391 emsg = (const char *)&msg[1]; 397 emsg = (const char *) &msg[1];
392 LOG(GNUNET_ERROR_TYPE_ERROR, 398 LOG (GNUNET_ERROR_TYPE_ERROR,
393 _("Adding host %u failed with error: %s\n"), 399 _ ("Adding host %u failed with error: %s\n"),
394 ntohl(msg->host_id), 400 ntohl (msg->host_id),
395 emsg); 401 emsg);
396 rh->cc(rh->cc_cls, emsg); 402 rh->cc (rh->cc_cls, emsg);
397 GNUNET_free(rh); 403 GNUNET_free (rh);
398} 404}
399 405
400 406
@@ -406,19 +412,19 @@ handle_add_host_confirm(void *cls,
406 * @param msg the message 412 * @param msg the message
407 */ 413 */
408static void 414static void
409handle_forwarded_operation_msg(void *cls, 415handle_forwarded_operation_msg (void *cls,
410 struct OperationContext *opc, 416 struct OperationContext *opc,
411 const struct GNUNET_MessageHeader *msg) 417 const struct GNUNET_MessageHeader *msg)
412{ 418{
413 struct GNUNET_TESTBED_Controller *c = cls; 419 struct GNUNET_TESTBED_Controller *c = cls;
414 struct ForwardedOperationData *fo_data; 420 struct ForwardedOperationData *fo_data;
415 421
416 fo_data = opc->data; 422 fo_data = opc->data;
417 if (NULL != fo_data->cc) 423 if (NULL != fo_data->cc)
418 fo_data->cc(fo_data->cc_cls, msg); 424 fo_data->cc (fo_data->cc_cls, msg);
419 GNUNET_TESTBED_remove_opc_(c, opc); 425 GNUNET_TESTBED_remove_opc_ (c, opc);
420 GNUNET_free(fo_data); 426 GNUNET_free (fo_data);
421 GNUNET_free(opc); 427 GNUNET_free (opc);
422} 428}
423 429
424 430
@@ -430,7 +436,7 @@ handle_forwarded_operation_msg(void *cls,
430 * @param msg message received 436 * @param msg message received
431 */ 437 */
432static void 438static void
433handle_opsuccess( 439handle_opsuccess (
434 void *cls, 440 void *cls,
435 const struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg) 441 const struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg)
436{ 442{
@@ -441,13 +447,13 @@ handle_opsuccess(
441 struct GNUNET_TESTBED_EventInformation event; 447 struct GNUNET_TESTBED_EventInformation event;
442 uint64_t op_id; 448 uint64_t op_id;
443 449
444 op_id = GNUNET_ntohll(msg->operation_id); 450 op_id = GNUNET_ntohll (msg->operation_id);
445 LOG_DEBUG("Operation %lu successful\n", op_id); 451 LOG_DEBUG ("Operation %lu successful\n", op_id);
446 if (NULL == (opc = find_opc(c, op_id))) 452 if (NULL == (opc = find_opc (c, op_id)))
447 { 453 {
448 LOG_DEBUG("Operation not found\n"); 454 LOG_DEBUG ("Operation not found\n");
449 return; 455 return;
450 } 456 }
451 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 457 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
452 event.op = opc->op; 458 event.op = opc->op;
453 event.op_cls = opc->op_cls; 459 event.op_cls = opc->op_cls;
@@ -456,71 +462,72 @@ handle_opsuccess(
456 op_comp_cb = NULL; 462 op_comp_cb = NULL;
457 op_comp_cb_cls = NULL; 463 op_comp_cb_cls = NULL;
458 switch (opc->type) 464 switch (opc->type)
459 { 465 {
460 case OP_FORWARDED: { 466 case OP_FORWARDED: {
461 handle_forwarded_operation_msg(c, 467 handle_forwarded_operation_msg (c,
462 opc, 468 opc,
463 (const struct GNUNET_MessageHeader *)msg); 469 (const struct
470 GNUNET_MessageHeader *) msg);
464 return; 471 return;
465 } 472 }
466 break; 473 break;
467 474
468 case OP_PEER_DESTROY: { 475 case OP_PEER_DESTROY: {
469 struct GNUNET_TESTBED_Peer *peer; 476 struct GNUNET_TESTBED_Peer *peer;
470 477
471 peer = opc->data; 478 peer = opc->data;
472 GNUNET_TESTBED_peer_deregister_(peer); 479 GNUNET_TESTBED_peer_deregister_ (peer);
473 GNUNET_free(peer); 480 GNUNET_free (peer);
474 opc->data = NULL; 481 opc->data = NULL;
475 //PEERDESTROYDATA 482 // PEERDESTROYDATA
476 } 483 }
477 break; 484 break;
478 485
479 case OP_SHUTDOWN_PEERS: { 486 case OP_SHUTDOWN_PEERS: {
480 struct ShutdownPeersData *data; 487 struct ShutdownPeersData *data;
481 488
482 data = opc->data; 489 data = opc->data;
483 op_comp_cb = data->cb; 490 op_comp_cb = data->cb;
484 op_comp_cb_cls = data->cb_cls; 491 op_comp_cb_cls = data->cb_cls;
485 GNUNET_free(data); 492 GNUNET_free (data);
486 opc->data = NULL; 493 opc->data = NULL;
487 GNUNET_TESTBED_cleanup_peers_(); 494 GNUNET_TESTBED_cleanup_peers_ ();
488 } 495 }
489 break; 496 break;
490 497
491 case OP_MANAGE_SERVICE: { 498 case OP_MANAGE_SERVICE: {
492 struct ManageServiceData *data; 499 struct ManageServiceData *data;
493 500
494 GNUNET_assert(NULL != (data = opc->data)); 501 GNUNET_assert (NULL != (data = opc->data));
495 op_comp_cb = data->cb; 502 op_comp_cb = data->cb;
496 op_comp_cb_cls = data->cb_cls; 503 op_comp_cb_cls = data->cb_cls;
497 GNUNET_free(data); 504 GNUNET_free (data);
498 opc->data = NULL; 505 opc->data = NULL;
499 } 506 }
500 break; 507 break;
501 508
502 case OP_PEER_RECONFIGURE: 509 case OP_PEER_RECONFIGURE:
503 break; 510 break;
504 511
505 default: 512 default:
506 GNUNET_assert(0); 513 GNUNET_assert (0);
507 } 514 }
508 GNUNET_TESTBED_remove_opc_(opc->c, opc); 515 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
509 opc->state = OPC_STATE_FINISHED; 516 opc->state = OPC_STATE_FINISHED;
510 exop_insert(event.op); 517 exop_insert (event.op);
511 if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED))) 518 if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED)))
512 { 519 {
513 if (NULL != c->cc) 520 if (NULL != c->cc)
514 c->cc(c->cc_cls, &event); 521 c->cc (c->cc_cls, &event);
515 if (GNUNET_NO == exop_check(event.op)) 522 if (GNUNET_NO == exop_check (event.op))
516 return; 523 return;
517 } 524 }
518 else 525 else
519 LOG_DEBUG("Not calling callback\n"); 526 LOG_DEBUG ("Not calling callback\n");
520 if (NULL != op_comp_cb) 527 if (NULL != op_comp_cb)
521 op_comp_cb(op_comp_cb_cls, event.op, NULL); 528 op_comp_cb (op_comp_cb_cls, event.op, NULL);
522 /* You could have marked the operation as done by now */ 529 /* You could have marked the operation as done by now */
523 GNUNET_break(GNUNET_NO == exop_check(event.op)); 530 GNUNET_break (GNUNET_NO == exop_check (event.op));
524} 531}
525 532
526 533
@@ -532,7 +539,7 @@ handle_opsuccess(
532 * @param msg message received 539 * @param msg message received
533 */ 540 */
534static void 541static void
535handle_peer_create_success( 542handle_peer_create_success (
536 void *cls, 543 void *cls,
537 const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *msg) 544 const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *msg)
538{ 545{
@@ -545,40 +552,40 @@ handle_peer_create_success(
545 void *cb_cls; 552 void *cb_cls;
546 uint64_t op_id; 553 uint64_t op_id;
547 554
548 GNUNET_assert(sizeof(struct GNUNET_TESTBED_PeerCreateSuccessEventMessage) == 555 GNUNET_assert (sizeof(struct GNUNET_TESTBED_PeerCreateSuccessEventMessage) ==
549 ntohs(msg->header.size)); 556 ntohs (msg->header.size));
550 op_id = GNUNET_ntohll(msg->operation_id); 557 op_id = GNUNET_ntohll (msg->operation_id);
551 if (NULL == (opc = find_opc(c, op_id))) 558 if (NULL == (opc = find_opc (c, op_id)))
552 { 559 {
553 LOG_DEBUG("Operation context for PeerCreateSuccessEvent not found\n"); 560 LOG_DEBUG ("Operation context for PeerCreateSuccessEvent not found\n");
554 return; 561 return;
555 } 562 }
556 if (OP_FORWARDED == opc->type) 563 if (OP_FORWARDED == opc->type)
557 { 564 {
558 handle_forwarded_operation_msg(c, 565 handle_forwarded_operation_msg (c,
559 opc, 566 opc,
560 (const struct GNUNET_MessageHeader *)msg); 567 (const struct GNUNET_MessageHeader *) msg);
561 return; 568 return;
562 } 569 }
563 GNUNET_assert(OP_PEER_CREATE == opc->type); 570 GNUNET_assert (OP_PEER_CREATE == opc->type);
564 GNUNET_assert(NULL != opc->data); 571 GNUNET_assert (NULL != opc->data);
565 data = opc->data; 572 data = opc->data;
566 GNUNET_assert(NULL != data->peer); 573 GNUNET_assert (NULL != data->peer);
567 peer = data->peer; 574 peer = data->peer;
568 GNUNET_assert(peer->unique_id == ntohl(msg->peer_id)); 575 GNUNET_assert (peer->unique_id == ntohl (msg->peer_id));
569 peer->state = TESTBED_PS_CREATED; 576 peer->state = TESTBED_PS_CREATED;
570 GNUNET_TESTBED_peer_register_(peer); 577 GNUNET_TESTBED_peer_register_ (peer);
571 cb = data->cb; 578 cb = data->cb;
572 cb_cls = data->cls; 579 cb_cls = data->cls;
573 op = opc->op; 580 op = opc->op;
574 GNUNET_free(opc->data); 581 GNUNET_free (opc->data);
575 GNUNET_TESTBED_remove_opc_(opc->c, opc); 582 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
576 opc->state = OPC_STATE_FINISHED; 583 opc->state = OPC_STATE_FINISHED;
577 exop_insert(op); 584 exop_insert (op);
578 if (NULL != cb) 585 if (NULL != cb)
579 cb(cb_cls, peer, NULL); 586 cb (cb_cls, peer, NULL);
580 /* You could have marked the operation as done by now */ 587 /* You could have marked the operation as done by now */
581 GNUNET_break(GNUNET_NO == exop_check(op)); 588 GNUNET_break (GNUNET_NO == exop_check (op));
582} 589}
583 590
584 591
@@ -590,7 +597,7 @@ handle_peer_create_success(
590 * @param msg message received 597 * @param msg message received
591 */ 598 */
592static void 599static void
593handle_peer_event(void *cls, const struct GNUNET_TESTBED_PeerEventMessage *msg) 600handle_peer_event (void *cls, const struct GNUNET_TESTBED_PeerEventMessage *msg)
594{ 601{
595 struct GNUNET_TESTBED_Controller *c = cls; 602 struct GNUNET_TESTBED_Controller *c = cls;
596 struct OperationContext *opc; 603 struct OperationContext *opc;
@@ -602,64 +609,64 @@ handle_peer_event(void *cls, const struct GNUNET_TESTBED_PeerEventMessage *msg)
602 uint64_t op_id; 609 uint64_t op_id;
603 uint64_t mask; 610 uint64_t mask;
604 611
605 GNUNET_assert(sizeof(struct GNUNET_TESTBED_PeerEventMessage) == 612 GNUNET_assert (sizeof(struct GNUNET_TESTBED_PeerEventMessage) ==
606 ntohs(msg->header.size)); 613 ntohs (msg->header.size));
607 op_id = GNUNET_ntohll(msg->operation_id); 614 op_id = GNUNET_ntohll (msg->operation_id);
608 if (NULL == (opc = find_opc(c, op_id))) 615 if (NULL == (opc = find_opc (c, op_id)))
609 { 616 {
610 LOG_DEBUG("Operation not found\n"); 617 LOG_DEBUG ("Operation not found\n");
611 return; 618 return;
612 } 619 }
613 if (OP_FORWARDED == opc->type) 620 if (OP_FORWARDED == opc->type)
614 { 621 {
615 handle_forwarded_operation_msg(c, 622 handle_forwarded_operation_msg (c,
616 opc, 623 opc,
617 (const struct GNUNET_MessageHeader *)msg); 624 (const struct GNUNET_MessageHeader *) msg);
618 return; 625 return;
619 } 626 }
620 GNUNET_assert((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type)); 627 GNUNET_assert ((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type));
621 data = opc->data; 628 data = opc->data;
622 GNUNET_assert(NULL != data); 629 GNUNET_assert (NULL != data);
623 peer = data->peer; 630 peer = data->peer;
624 GNUNET_assert(NULL != peer); 631 GNUNET_assert (NULL != peer);
625 event.type = (enum GNUNET_TESTBED_EventType)ntohl(msg->event_type); 632 event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type);
626 event.op = opc->op; 633 event.op = opc->op;
627 event.op_cls = opc->op_cls; 634 event.op_cls = opc->op_cls;
628 switch (event.type) 635 switch (event.type)
629 { 636 {
630 case GNUNET_TESTBED_ET_PEER_START: 637 case GNUNET_TESTBED_ET_PEER_START:
631 peer->state = TESTBED_PS_STARTED; 638 peer->state = TESTBED_PS_STARTED;
632 event.details.peer_start.host = peer->host; 639 event.details.peer_start.host = peer->host;
633 event.details.peer_start.peer = peer; 640 event.details.peer_start.peer = peer;
634 break; 641 break;
635 642
636 case GNUNET_TESTBED_ET_PEER_STOP: 643 case GNUNET_TESTBED_ET_PEER_STOP:
637 peer->state = TESTBED_PS_STOPPED; 644 peer->state = TESTBED_PS_STOPPED;
638 event.details.peer_stop.peer = peer; 645 event.details.peer_stop.peer = peer;
639 break; 646 break;
640 647
641 default: 648 default:
642 GNUNET_assert(0); /* We should never reach this state */ 649 GNUNET_assert (0); /* We should never reach this state */
643 } 650 }
644 pcc = data->pcc; 651 pcc = data->pcc;
645 pcc_cls = data->pcc_cls; 652 pcc_cls = data->pcc_cls;
646 GNUNET_free(data); 653 GNUNET_free (data);
647 GNUNET_TESTBED_remove_opc_(opc->c, opc); 654 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
648 opc->state = OPC_STATE_FINISHED; 655 opc->state = OPC_STATE_FINISHED;
649 exop_insert(event.op); 656 exop_insert (event.op);
650 mask = 1LL << GNUNET_TESTBED_ET_PEER_START; 657 mask = 1LL << GNUNET_TESTBED_ET_PEER_START;
651 mask |= 1LL << GNUNET_TESTBED_ET_PEER_STOP; 658 mask |= 1LL << GNUNET_TESTBED_ET_PEER_STOP;
652 if (0 != (mask & c->event_mask)) 659 if (0 != (mask & c->event_mask))
653 { 660 {
654 if (NULL != c->cc) 661 if (NULL != c->cc)
655 c->cc(c->cc_cls, &event); 662 c->cc (c->cc_cls, &event);
656 if (GNUNET_NO == exop_check(event.op)) 663 if (GNUNET_NO == exop_check (event.op))
657 return; 664 return;
658 } 665 }
659 if (NULL != pcc) 666 if (NULL != pcc)
660 pcc(pcc_cls, NULL); 667 pcc (pcc_cls, NULL);
661 /* You could have marked the operation as done by now */ 668 /* You could have marked the operation as done by now */
662 GNUNET_break(GNUNET_NO == exop_check(event.op)); 669 GNUNET_break (GNUNET_NO == exop_check (event.op));
663} 670}
664 671
665 672
@@ -671,8 +678,8 @@ handle_peer_event(void *cls, const struct GNUNET_TESTBED_PeerEventMessage *msg)
671 * @param msg message received 678 * @param msg message received
672 */ 679 */
673static void 680static void
674handle_peer_conevent(void *cls, 681handle_peer_conevent (void *cls,
675 const struct GNUNET_TESTBED_ConnectionEventMessage *msg) 682 const struct GNUNET_TESTBED_ConnectionEventMessage *msg)
676{ 683{
677 struct GNUNET_TESTBED_Controller *c = cls; 684 struct GNUNET_TESTBED_Controller *c = cls;
678 struct OperationContext *opc; 685 struct OperationContext *opc;
@@ -683,59 +690,59 @@ handle_peer_conevent(void *cls,
683 uint64_t op_id; 690 uint64_t op_id;
684 uint64_t mask; 691 uint64_t mask;
685 692
686 op_id = GNUNET_ntohll(msg->operation_id); 693 op_id = GNUNET_ntohll (msg->operation_id);
687 if (NULL == (opc = find_opc(c, op_id))) 694 if (NULL == (opc = find_opc (c, op_id)))
688 { 695 {
689 LOG_DEBUG("Operation not found\n"); 696 LOG_DEBUG ("Operation not found\n");
690 return; 697 return;
691 } 698 }
692 if (OP_FORWARDED == opc->type) 699 if (OP_FORWARDED == opc->type)
693 { 700 {
694 handle_forwarded_operation_msg(c, 701 handle_forwarded_operation_msg (c,
695 opc, 702 opc,
696 (const struct GNUNET_MessageHeader *)msg); 703 (const struct GNUNET_MessageHeader *) msg);
697 return; 704 return;
698 } 705 }
699 GNUNET_assert(OP_OVERLAY_CONNECT == opc->type); 706 GNUNET_assert (OP_OVERLAY_CONNECT == opc->type);
700 GNUNET_assert(NULL != (data = opc->data)); 707 GNUNET_assert (NULL != (data = opc->data));
701 GNUNET_assert((ntohl(msg->peer1) == data->p1->unique_id) && 708 GNUNET_assert ((ntohl (msg->peer1) == data->p1->unique_id) &&
702 (ntohl(msg->peer2) == data->p2->unique_id)); 709 (ntohl (msg->peer2) == data->p2->unique_id));
703 event.type = (enum GNUNET_TESTBED_EventType)ntohl(msg->event_type); 710 event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type);
704 event.op = opc->op; 711 event.op = opc->op;
705 event.op_cls = opc->op_cls; 712 event.op_cls = opc->op_cls;
706 switch (event.type) 713 switch (event.type)
707 { 714 {
708 case GNUNET_TESTBED_ET_CONNECT: 715 case GNUNET_TESTBED_ET_CONNECT:
709 event.details.peer_connect.peer1 = data->p1; 716 event.details.peer_connect.peer1 = data->p1;
710 event.details.peer_connect.peer2 = data->p2; 717 event.details.peer_connect.peer2 = data->p2;
711 break; 718 break;
712 719
713 case GNUNET_TESTBED_ET_DISCONNECT: 720 case GNUNET_TESTBED_ET_DISCONNECT:
714 GNUNET_assert(0); /* FIXME: implement */ 721 GNUNET_assert (0); /* FIXME: implement */
715 break; 722 break;
716 723
717 default: 724 default:
718 GNUNET_assert(0); /* Should never reach here */ 725 GNUNET_assert (0); /* Should never reach here */
719 break; 726 break;
720 } 727 }
721 cb = data->cb; 728 cb = data->cb;
722 cb_cls = data->cb_cls; 729 cb_cls = data->cb_cls;
723 GNUNET_TESTBED_remove_opc_(opc->c, opc); 730 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
724 opc->state = OPC_STATE_FINISHED; 731 opc->state = OPC_STATE_FINISHED;
725 exop_insert(event.op); 732 exop_insert (event.op);
726 mask = 1LL << GNUNET_TESTBED_ET_CONNECT; 733 mask = 1LL << GNUNET_TESTBED_ET_CONNECT;
727 mask |= 1LL << GNUNET_TESTBED_ET_DISCONNECT; 734 mask |= 1LL << GNUNET_TESTBED_ET_DISCONNECT;
728 if (0 != (mask & c->event_mask)) 735 if (0 != (mask & c->event_mask))
729 { 736 {
730 if (NULL != c->cc) 737 if (NULL != c->cc)
731 c->cc(c->cc_cls, &event); 738 c->cc (c->cc_cls, &event);
732 if (GNUNET_NO == exop_check(event.op)) 739 if (GNUNET_NO == exop_check (event.op))
733 return; 740 return;
734 } 741 }
735 if (NULL != cb) 742 if (NULL != cb)
736 cb(cb_cls, opc->op, NULL); 743 cb (cb_cls, opc->op, NULL);
737 /* You could have marked the operation as done by now */ 744 /* You could have marked the operation as done by now */
738 GNUNET_break(GNUNET_NO == exop_check(event.op)); 745 GNUNET_break (GNUNET_NO == exop_check (event.op));
739} 746}
740 747
741 748
@@ -747,7 +754,7 @@ handle_peer_conevent(void *cls,
747 * @param msg message received 754 * @param msg message received
748 */ 755 */
749static int 756static int
750check_peer_config( 757check_peer_config (
751 void *cls, 758 void *cls,
752 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg) 759 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg)
753{ 760{
@@ -764,7 +771,7 @@ check_peer_config(
764 * @param msg message received 771 * @param msg message received
765 */ 772 */
766static void 773static void
767handle_peer_config( 774handle_peer_config (
768 void *cls, 775 void *cls,
769 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg) 776 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg)
770{ 777{
@@ -777,51 +784,51 @@ handle_peer_config(
777 void *cb_cls; 784 void *cb_cls;
778 uint64_t op_id; 785 uint64_t op_id;
779 786
780 op_id = GNUNET_ntohll(msg->operation_id); 787 op_id = GNUNET_ntohll (msg->operation_id);
781 if (NULL == (opc = find_opc(c, op_id))) 788 if (NULL == (opc = find_opc (c, op_id)))
782 { 789 {
783 LOG_DEBUG("Operation not found\n"); 790 LOG_DEBUG ("Operation not found\n");
784 return; 791 return;
785 } 792 }
786 if (OP_FORWARDED == opc->type) 793 if (OP_FORWARDED == opc->type)
787 { 794 {
788 handle_forwarded_operation_msg(c, opc, &msg->header); 795 handle_forwarded_operation_msg (c, opc, &msg->header);
789 return; 796 return;
790 } 797 }
791 data = opc->data; 798 data = opc->data;
792 GNUNET_assert(NULL != data); 799 GNUNET_assert (NULL != data);
793 peer = data->peer; 800 peer = data->peer;
794 GNUNET_assert(NULL != peer); 801 GNUNET_assert (NULL != peer);
795 GNUNET_assert(ntohl(msg->peer_id) == peer->unique_id); 802 GNUNET_assert (ntohl (msg->peer_id) == peer->unique_id);
796 pinfo = GNUNET_new(struct GNUNET_TESTBED_PeerInformation); 803 pinfo = GNUNET_new (struct GNUNET_TESTBED_PeerInformation);
797 pinfo->pit = data->pit; 804 pinfo->pit = data->pit;
798 cb = data->cb; 805 cb = data->cb;
799 cb_cls = data->cb_cls; 806 cb_cls = data->cb_cls;
800 GNUNET_assert(NULL != cb); 807 GNUNET_assert (NULL != cb);
801 GNUNET_free(data); 808 GNUNET_free (data);
802 opc->data = NULL; 809 opc->data = NULL;
803 switch (pinfo->pit) 810 switch (pinfo->pit)
804 { 811 {
805 case GNUNET_TESTBED_PIT_IDENTITY: 812 case GNUNET_TESTBED_PIT_IDENTITY:
806 pinfo->result.id = GNUNET_new(struct GNUNET_PeerIdentity); 813 pinfo->result.id = GNUNET_new (struct GNUNET_PeerIdentity);
807 GNUNET_memcpy(pinfo->result.id, 814 GNUNET_memcpy (pinfo->result.id,
808 &msg->peer_identity, 815 &msg->peer_identity,
809 sizeof(struct GNUNET_PeerIdentity)); 816 sizeof(struct GNUNET_PeerIdentity));
810 break; 817 break;
811 818
812 case GNUNET_TESTBED_PIT_CONFIGURATION: 819 case GNUNET_TESTBED_PIT_CONFIGURATION:
813 pinfo->result.cfg = /* Freed in oprelease_peer_getinfo */ 820 pinfo->result.cfg = /* Freed in oprelease_peer_getinfo */
814 GNUNET_TESTBED_extract_config_(&msg->header); 821 GNUNET_TESTBED_extract_config_ (&msg->header);
815 break; 822 break;
816 823
817 case GNUNET_TESTBED_PIT_GENERIC: 824 case GNUNET_TESTBED_PIT_GENERIC:
818 GNUNET_assert(0); /* never reach here */ 825 GNUNET_assert (0); /* never reach here */
819 break; 826 break;
820 } 827 }
821 opc->data = pinfo; 828 opc->data = pinfo;
822 GNUNET_TESTBED_remove_opc_(opc->c, opc); 829 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
823 opc->state = OPC_STATE_FINISHED; 830 opc->state = OPC_STATE_FINISHED;
824 cb(cb_cls, opc->op, pinfo, NULL); 831 cb (cb_cls, opc->op, pinfo, NULL);
825 /* We dont check whether the operation is marked as done here as the 832 /* We dont check whether the operation is marked as done here as the
826 operation contains data (cfg/identify) which will be freed at a later point 833 operation contains data (cfg/identify) which will be freed at a later point
827 */ 834 */
@@ -837,7 +844,7 @@ handle_peer_config(
837 * @return #GNUNET_OK if message is well-formed 844 * @return #GNUNET_OK if message is well-formed
838 */ 845 */
839static int 846static int
840check_op_fail_event( 847check_op_fail_event (
841 void *cls, 848 void *cls,
842 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg) 849 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
843{ 850{
@@ -854,7 +861,7 @@ check_op_fail_event(
854 * @param msg message received 861 * @param msg message received
855 */ 862 */
856static void 863static void
857handle_op_fail_event( 864handle_op_fail_event (
858 void *cls, 865 void *cls,
859 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg) 866 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
860{ 867{
@@ -865,34 +872,34 @@ handle_op_fail_event(
865 uint64_t mask; 872 uint64_t mask;
866 struct GNUNET_TESTBED_EventInformation event; 873 struct GNUNET_TESTBED_EventInformation event;
867 874
868 op_id = GNUNET_ntohll(msg->operation_id); 875 op_id = GNUNET_ntohll (msg->operation_id);
869 if (NULL == (opc = find_opc(c, op_id))) 876 if (NULL == (opc = find_opc (c, op_id)))
870 { 877 {
871 LOG_DEBUG("Operation not found\n"); 878 LOG_DEBUG ("Operation not found\n");
872 return; 879 return;
873 } 880 }
874 if (OP_FORWARDED == opc->type) 881 if (OP_FORWARDED == opc->type)
875 { 882 {
876 handle_forwarded_operation_msg(c, 883 handle_forwarded_operation_msg (c,
877 opc, 884 opc,
878 (const struct GNUNET_MessageHeader *)msg); 885 (const struct GNUNET_MessageHeader *) msg);
879 return; 886 return;
880 } 887 }
881 GNUNET_TESTBED_remove_opc_(opc->c, opc); 888 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
882 opc->state = OPC_STATE_FINISHED; 889 opc->state = OPC_STATE_FINISHED;
883 emsg = GNUNET_TESTBED_parse_error_string_(msg); 890 emsg = GNUNET_TESTBED_parse_error_string_ (msg);
884 if (NULL == emsg) 891 if (NULL == emsg)
885 emsg = "Unknown error"; 892 emsg = "Unknown error";
886 if (OP_PEER_INFO == opc->type) 893 if (OP_PEER_INFO == opc->type)
887 { 894 {
888 struct PeerInfoData *data; 895 struct PeerInfoData *data;
889 896
890 data = opc->data; 897 data = opc->data;
891 if (NULL != data->cb) 898 if (NULL != data->cb)
892 data->cb(data->cb_cls, opc->op, NULL, emsg); 899 data->cb (data->cb_cls, opc->op, NULL, emsg);
893 GNUNET_free(data); 900 GNUNET_free (data);
894 return; /* We do not call controller callback for peer info */ 901 return; /* We do not call controller callback for peer info */
895 } 902 }
896 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 903 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
897 event.op = opc->op; 904 event.op = opc->op;
898 event.op_cls = opc->op_cls; 905 event.op_cls = opc->op_cls;
@@ -900,88 +907,88 @@ handle_op_fail_event(
900 event.details.operation_finished.generic = NULL; 907 event.details.operation_finished.generic = NULL;
901 mask = (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 908 mask = (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
902 if ((0 != (mask & c->event_mask)) && (NULL != c->cc)) 909 if ((0 != (mask & c->event_mask)) && (NULL != c->cc))
903 { 910 {
904 exop_insert(event.op); 911 exop_insert (event.op);
905 c->cc(c->cc_cls, &event); 912 c->cc (c->cc_cls, &event);
906 if (GNUNET_NO == exop_check(event.op)) 913 if (GNUNET_NO == exop_check (event.op))
907 return; 914 return;
908 } 915 }
909 switch (opc->type) 916 switch (opc->type)
910 { 917 {
911 case OP_PEER_CREATE: { 918 case OP_PEER_CREATE: {
912 struct PeerCreateData *data; 919 struct PeerCreateData *data;
913 920
914 data = opc->data; 921 data = opc->data;
915 GNUNET_free(data->peer); 922 GNUNET_free (data->peer);
916 if (NULL != data->cb) 923 if (NULL != data->cb)
917 data->cb(data->cls, NULL, emsg); 924 data->cb (data->cls, NULL, emsg);
918 GNUNET_free(data); 925 GNUNET_free (data);
919 } 926 }
920 break; 927 break;
921 928
922 case OP_PEER_START: 929 case OP_PEER_START:
923 case OP_PEER_STOP: { 930 case OP_PEER_STOP: {
924 struct PeerEventData *data; 931 struct PeerEventData *data;
925 932
926 data = opc->data; 933 data = opc->data;
927 if (NULL != data->pcc) 934 if (NULL != data->pcc)
928 data->pcc(data->pcc_cls, emsg); 935 data->pcc (data->pcc_cls, emsg);
929 GNUNET_free(data); 936 GNUNET_free (data);
930 } 937 }
931 break; 938 break;
932 939
933 case OP_PEER_DESTROY: 940 case OP_PEER_DESTROY:
934 break; 941 break;
935 942
936 case OP_PEER_INFO: 943 case OP_PEER_INFO:
937 GNUNET_assert(0); 944 GNUNET_assert (0);
938 945
939 case OP_OVERLAY_CONNECT: { 946 case OP_OVERLAY_CONNECT: {
940 struct OverlayConnectData *data; 947 struct OverlayConnectData *data;
941 948
942 data = opc->data; 949 data = opc->data;
943 GNUNET_TESTBED_operation_mark_failed(opc->op); 950 GNUNET_TESTBED_operation_mark_failed (opc->op);
944 if (NULL != data->cb) 951 if (NULL != data->cb)
945 data->cb(data->cb_cls, opc->op, emsg); 952 data->cb (data->cb_cls, opc->op, emsg);
946 } 953 }
947 break; 954 break;
948 955
949 case OP_FORWARDED: 956 case OP_FORWARDED:
950 GNUNET_assert(0); 957 GNUNET_assert (0);
951 958
952 case OP_LINK_CONTROLLERS: /* No secondary callback */ 959 case OP_LINK_CONTROLLERS: /* No secondary callback */
953 break; 960 break;
954 961
955 case OP_SHUTDOWN_PEERS: { 962 case OP_SHUTDOWN_PEERS: {
956 struct ShutdownPeersData *data; 963 struct ShutdownPeersData *data;
957 964
958 data = opc->data; 965 data = opc->data;
959 GNUNET_free(data); /* FIXME: Decide whether we call data->op_cb */ 966 GNUNET_free (data); /* FIXME: Decide whether we call data->op_cb */
960 opc->data = NULL; 967 opc->data = NULL;
961 } 968 }
962 break; 969 break;
963 970
964 case OP_MANAGE_SERVICE: { 971 case OP_MANAGE_SERVICE: {
965 struct ManageServiceData *data = opc->data; 972 struct ManageServiceData *data = opc->data;
966 GNUNET_TESTBED_OperationCompletionCallback cb; 973 GNUNET_TESTBED_OperationCompletionCallback cb;
967 void *cb_cls; 974 void *cb_cls;
968 975
969 GNUNET_assert(NULL != data); 976 GNUNET_assert (NULL != data);
970 cb = data->cb; 977 cb = data->cb;
971 cb_cls = data->cb_cls; 978 cb_cls = data->cb_cls;
972 GNUNET_free(data); 979 GNUNET_free (data);
973 opc->data = NULL; 980 opc->data = NULL;
974 exop_insert(event.op); 981 exop_insert (event.op);
975 if (NULL != cb) 982 if (NULL != cb)
976 cb(cb_cls, opc->op, emsg); 983 cb (cb_cls, opc->op, emsg);
977 /* You could have marked the operation as done by now */ 984 /* You could have marked the operation as done by now */
978 GNUNET_break(GNUNET_NO == exop_check(event.op)); 985 GNUNET_break (GNUNET_NO == exop_check (event.op));
979 } 986 }
980 break; 987 break;
981 988
982 default: 989 default:
983 GNUNET_break(0); 990 GNUNET_break (0);
984 } 991 }
985} 992}
986 993
987 994
@@ -993,18 +1000,18 @@ handle_op_fail_event(
993 * @return newly allocated SlaveGetConfigurationMessage 1000 * @return newly allocated SlaveGetConfigurationMessage
994 */ 1001 */
995static struct GNUNET_TESTBED_SlaveGetConfigurationMessage * 1002static struct GNUNET_TESTBED_SlaveGetConfigurationMessage *
996GNUNET_TESTBED_generate_slavegetconfig_msg_(uint64_t op_id, uint32_t slave_id) 1003GNUNET_TESTBED_generate_slavegetconfig_msg_ (uint64_t op_id, uint32_t slave_id)
997{ 1004{
998 struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; 1005 struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg;
999 uint16_t msize; 1006 uint16_t msize;
1000 1007
1001 msize = sizeof(struct GNUNET_TESTBED_SlaveGetConfigurationMessage); 1008 msize = sizeof(struct GNUNET_TESTBED_SlaveGetConfigurationMessage);
1002 msg = GNUNET_malloc(msize); 1009 msg = GNUNET_malloc (msize);
1003 msg->header.size = htons(msize); 1010 msg->header.size = htons (msize);
1004 msg->header.type = 1011 msg->header.type =
1005 htons(GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION); 1012 htons (GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION);
1006 msg->operation_id = GNUNET_htonll(op_id); 1013 msg->operation_id = GNUNET_htonll (op_id);
1007 msg->slave_id = htonl(slave_id); 1014 msg->slave_id = htonl (slave_id);
1008 return msg; 1015 return msg;
1009} 1016}
1010 1017
@@ -1017,8 +1024,8 @@ GNUNET_TESTBED_generate_slavegetconfig_msg_(uint64_t op_id, uint32_t slave_id)
1017 * @param msg message received 1024 * @param msg message received
1018 */ 1025 */
1019static int 1026static int
1020check_slave_config(void *cls, 1027check_slave_config (void *cls,
1021 const struct GNUNET_TESTBED_SlaveConfiguration *msg) 1028 const struct GNUNET_TESTBED_SlaveConfiguration *msg)
1022{ 1029{
1023 /* anything goes? */ 1030 /* anything goes? */
1024 return GNUNET_OK; 1031 return GNUNET_OK;
@@ -1033,8 +1040,8 @@ check_slave_config(void *cls,
1033 * @param msg message received 1040 * @param msg message received
1034 */ 1041 */
1035static void 1042static void
1036handle_slave_config(void *cls, 1043handle_slave_config (void *cls,
1037 const struct GNUNET_TESTBED_SlaveConfiguration *msg) 1044 const struct GNUNET_TESTBED_SlaveConfiguration *msg)
1038{ 1045{
1039 struct GNUNET_TESTBED_Controller *c = cls; 1046 struct GNUNET_TESTBED_Controller *c = cls;
1040 struct OperationContext *opc; 1047 struct OperationContext *opc;
@@ -1042,30 +1049,30 @@ handle_slave_config(void *cls,
1042 uint64_t mask; 1049 uint64_t mask;
1043 struct GNUNET_TESTBED_EventInformation event; 1050 struct GNUNET_TESTBED_EventInformation event;
1044 1051
1045 op_id = GNUNET_ntohll(msg->operation_id); 1052 op_id = GNUNET_ntohll (msg->operation_id);
1046 if (NULL == (opc = find_opc(c, op_id))) 1053 if (NULL == (opc = find_opc (c, op_id)))
1047 { 1054 {
1048 LOG_DEBUG("Operation not found\n"); 1055 LOG_DEBUG ("Operation not found\n");
1049 return; 1056 return;
1050 } 1057 }
1051 if (OP_GET_SLAVE_CONFIG != opc->type) 1058 if (OP_GET_SLAVE_CONFIG != opc->type)
1052 { 1059 {
1053 GNUNET_break(0); 1060 GNUNET_break (0);
1054 return; 1061 return;
1055 } 1062 }
1056 opc->state = OPC_STATE_FINISHED; 1063 opc->state = OPC_STATE_FINISHED;
1057 GNUNET_TESTBED_remove_opc_(opc->c, opc); 1064 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1058 mask = 1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED; 1065 mask = 1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED;
1059 if ((0 != (mask & c->event_mask)) && (NULL != c->cc)) 1066 if ((0 != (mask & c->event_mask)) && (NULL != c->cc))
1060 { 1067 {
1061 opc->data = GNUNET_TESTBED_extract_config_(&msg->header); 1068 opc->data = GNUNET_TESTBED_extract_config_ (&msg->header);
1062 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 1069 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
1063 event.op = opc->op; 1070 event.op = opc->op;
1064 event.op_cls = opc->op_cls; 1071 event.op_cls = opc->op_cls;
1065 event.details.operation_finished.generic = opc->data; 1072 event.details.operation_finished.generic = opc->data;
1066 event.details.operation_finished.emsg = NULL; 1073 event.details.operation_finished.emsg = NULL;
1067 c->cc(c->cc_cls, &event); 1074 c->cc (c->cc_cls, &event);
1068 } 1075 }
1069} 1076}
1070 1077
1071 1078
@@ -1078,7 +1085,7 @@ handle_slave_config(void *cls,
1078 * @return #GNUNET_OK if @a msg is well-formed 1085 * @return #GNUNET_OK if @a msg is well-formed
1079 */ 1086 */
1080static int 1087static int
1081check_link_controllers_result( 1088check_link_controllers_result (
1082 void *cls, 1089 void *cls,
1083 const struct GNUNET_TESTBED_ControllerLinkResponse *msg) 1090 const struct GNUNET_TESTBED_ControllerLinkResponse *msg)
1084{ 1091{
@@ -1095,7 +1102,7 @@ check_link_controllers_result(
1095 * @param msg message received 1102 * @param msg message received
1096 */ 1103 */
1097static void 1104static void
1098handle_link_controllers_result( 1105handle_link_controllers_result (
1099 void *cls, 1106 void *cls,
1100 const struct GNUNET_TESTBED_ControllerLinkResponse *msg) 1107 const struct GNUNET_TESTBED_ControllerLinkResponse *msg)
1101{ 1108{
@@ -1108,31 +1115,31 @@ handle_link_controllers_result(
1108 uint64_t op_id; 1115 uint64_t op_id;
1109 struct GNUNET_TESTBED_EventInformation event; 1116 struct GNUNET_TESTBED_EventInformation event;
1110 1117
1111 op_id = GNUNET_ntohll(msg->operation_id); 1118 op_id = GNUNET_ntohll (msg->operation_id);
1112 if (NULL == (opc = find_opc(c, op_id))) 1119 if (NULL == (opc = find_opc (c, op_id)))
1113 { 1120 {
1114 LOG_DEBUG("Operation not found\n"); 1121 LOG_DEBUG ("Operation not found\n");
1115 return; 1122 return;
1116 } 1123 }
1117 if (OP_FORWARDED == opc->type) 1124 if (OP_FORWARDED == opc->type)
1118 { 1125 {
1119 handle_forwarded_operation_msg(c, 1126 handle_forwarded_operation_msg (c,
1120 opc, 1127 opc,
1121 (const struct GNUNET_MessageHeader *)msg); 1128 (const struct GNUNET_MessageHeader *) msg);
1122 return; 1129 return;
1123 } 1130 }
1124 if (OP_LINK_CONTROLLERS != opc->type) 1131 if (OP_LINK_CONTROLLERS != opc->type)
1125 { 1132 {
1126 GNUNET_break(0); 1133 GNUNET_break (0);
1127 return; 1134 return;
1128 } 1135 }
1129 GNUNET_assert(NULL != (data = opc->data)); 1136 GNUNET_assert (NULL != (data = opc->data));
1130 host = GNUNET_TESTBED_host_lookup_by_id_(data->host_id); 1137 host = GNUNET_TESTBED_host_lookup_by_id_ (data->host_id);
1131 GNUNET_assert(NULL != host); 1138 GNUNET_assert (NULL != host);
1132 GNUNET_free(data); 1139 GNUNET_free (data);
1133 opc->data = NULL; 1140 opc->data = NULL;
1134 opc->state = OPC_STATE_FINISHED; 1141 opc->state = OPC_STATE_FINISHED;
1135 GNUNET_TESTBED_remove_opc_(opc->c, opc); 1142 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1136 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 1143 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
1137 event.op = opc->op; 1144 event.op = opc->op;
1138 event.op_cls = opc->op_cls; 1145 event.op_cls = opc->op_cls;
@@ -1140,37 +1147,38 @@ handle_link_controllers_result(
1140 event.details.operation_finished.generic = NULL; 1147 event.details.operation_finished.generic = NULL;
1141 emsg = NULL; 1148 emsg = NULL;
1142 cfg = NULL; 1149 cfg = NULL;
1143 if (GNUNET_NO == ntohs(msg->success)) 1150 if (GNUNET_NO == ntohs (msg->success))
1144 { 1151 {
1145 emsg = 1152 emsg =
1146 GNUNET_malloc(ntohs(msg->header.size) - 1153 GNUNET_malloc (ntohs (msg->header.size)
1147 sizeof(struct GNUNET_TESTBED_ControllerLinkResponse) + 1); 1154 - sizeof(struct GNUNET_TESTBED_ControllerLinkResponse)
1148 GNUNET_memcpy(emsg, 1155 + 1);
1149 &msg[1], 1156 GNUNET_memcpy (emsg,
1150 ntohs(msg->header.size) - 1157 &msg[1],
1151 sizeof(struct GNUNET_TESTBED_ControllerLinkResponse)); 1158 ntohs (msg->header.size)
1152 event.details.operation_finished.emsg = emsg; 1159 - sizeof(struct GNUNET_TESTBED_ControllerLinkResponse));
1153 } 1160 event.details.operation_finished.emsg = emsg;
1161 }
1154 else 1162 else
1163 {
1164 if (0 != ntohs (msg->config_size))
1155 { 1165 {
1156 if (0 != ntohs(msg->config_size)) 1166 cfg = GNUNET_TESTBED_extract_config_ (
1157 { 1167 (const struct GNUNET_MessageHeader *) msg);
1158 cfg = GNUNET_TESTBED_extract_config_( 1168 GNUNET_assert (NULL != cfg);
1159 (const struct GNUNET_MessageHeader *)msg); 1169 GNUNET_TESTBED_host_replace_cfg_ (host, cfg);
1160 GNUNET_assert(NULL != cfg);
1161 GNUNET_TESTBED_host_replace_cfg_(host, cfg);
1162 }
1163 } 1170 }
1171 }
1164 if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED))) 1172 if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED)))
1165 { 1173 {
1166 if (NULL != c->cc) 1174 if (NULL != c->cc)
1167 c->cc(c->cc_cls, &event); 1175 c->cc (c->cc_cls, &event);
1168 } 1176 }
1169 else 1177 else
1170 LOG_DEBUG("Not calling callback\n"); 1178 LOG_DEBUG ("Not calling callback\n");
1171 if (NULL != cfg) 1179 if (NULL != cfg)
1172 GNUNET_CONFIGURATION_destroy(cfg); 1180 GNUNET_CONFIGURATION_destroy (cfg);
1173 GNUNET_free_non_null(emsg); 1181 GNUNET_free_non_null (emsg);
1174} 1182}
1175 1183
1176 1184
@@ -1184,8 +1192,8 @@ handle_link_controllers_result(
1184 * down signalling an error (message malformed) 1192 * down signalling an error (message malformed)
1185 */ 1193 */
1186static int 1194static int
1187check_barrier_status(void *cls, 1195check_barrier_status (void *cls,
1188 const struct GNUNET_TESTBED_BarrierStatusMsg *msg) 1196 const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
1189{ 1197{
1190 uint16_t msize; 1198 uint16_t msize;
1191 uint16_t name_len; 1199 uint16_t name_len;
@@ -1193,31 +1201,31 @@ check_barrier_status(void *cls,
1193 const char *name; 1201 const char *name;
1194 size_t emsg_len; 1202 size_t emsg_len;
1195 1203
1196 msize = ntohs(msg->header.size); 1204 msize = ntohs (msg->header.size);
1197 name = msg->data; 1205 name = msg->data;
1198 name_len = ntohs(msg->name_len); 1206 name_len = ntohs (msg->name_len);
1199 1207
1200 if (sizeof(struct GNUNET_TESTBED_BarrierStatusMsg) + name_len + 1 > msize) 1208 if (sizeof(struct GNUNET_TESTBED_BarrierStatusMsg) + name_len + 1 > msize)
1201 { 1209 {
1202 GNUNET_break_op(0); 1210 GNUNET_break_op (0);
1203 return GNUNET_SYSERR; 1211 return GNUNET_SYSERR;
1204 } 1212 }
1205 if ('\0' != name[name_len]) 1213 if ('\0' != name[name_len])
1206 { 1214 {
1207 GNUNET_break_op(0); 1215 GNUNET_break_op (0);
1208 return GNUNET_SYSERR; 1216 return GNUNET_SYSERR;
1209 } 1217 }
1210 status = ntohs(msg->status); 1218 status = ntohs (msg->status);
1211 if (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status) 1219 if (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status)
1220 {
1221 emsg_len = msize - (sizeof(struct GNUNET_TESTBED_BarrierStatusMsg)
1222 + name_len + 1); /* +1!? */
1223 if (0 == emsg_len)
1212 { 1224 {
1213 emsg_len = msize - (sizeof(struct GNUNET_TESTBED_BarrierStatusMsg) + 1225 GNUNET_break_op (0);
1214 name_len + 1); /* +1!? */ 1226 return GNUNET_SYSERR;
1215 if (0 == emsg_len)
1216 {
1217 GNUNET_break_op(0);
1218 return GNUNET_SYSERR;
1219 }
1220 } 1227 }
1228 }
1221 return GNUNET_OK; 1229 return GNUNET_OK;
1222} 1230}
1223 1231
@@ -1230,8 +1238,8 @@ check_barrier_status(void *cls,
1230 * @param msg the barrier status message 1238 * @param msg the barrier status message
1231 */ 1239 */
1232static void 1240static void
1233handle_barrier_status(void *cls, 1241handle_barrier_status (void *cls,
1234 const struct GNUNET_TESTBED_BarrierStatusMsg *msg) 1242 const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
1235{ 1243{
1236 struct GNUNET_TESTBED_Controller *c = cls; 1244 struct GNUNET_TESTBED_Controller *c = cls;
1237 struct GNUNET_TESTBED_Barrier *barrier; 1245 struct GNUNET_TESTBED_Barrier *barrier;
@@ -1245,68 +1253,68 @@ handle_barrier_status(void *cls,
1245 1253
1246 emsg = NULL; 1254 emsg = NULL;
1247 barrier = NULL; 1255 barrier = NULL;
1248 msize = ntohs(msg->header.size); 1256 msize = ntohs (msg->header.size);
1249 if (msize <= sizeof(struct GNUNET_TESTBED_BarrierStatusMsg)) 1257 if (msize <= sizeof(struct GNUNET_TESTBED_BarrierStatusMsg))
1250 { 1258 {
1251 GNUNET_break_op(0); 1259 GNUNET_break_op (0);
1252 goto cleanup; 1260 goto cleanup;
1253 } 1261 }
1254 name = msg->data; 1262 name = msg->data;
1255 name_len = ntohs(msg->name_len); 1263 name_len = ntohs (msg->name_len);
1256 if (name_len >= //name_len is strlen(barrier_name) 1264 if (name_len >= // name_len is strlen(barrier_name)
1257 (msize - ((sizeof msg->header) + sizeof(msg->status)))) 1265 (msize - ((sizeof msg->header) + sizeof(msg->status))))
1258 { 1266 {
1259 GNUNET_break_op(0); 1267 GNUNET_break_op (0);
1260 goto cleanup; 1268 goto cleanup;
1261 } 1269 }
1262 if ('\0' != name[name_len]) 1270 if ('\0' != name[name_len])
1263 { 1271 {
1264 GNUNET_break_op(0); 1272 GNUNET_break_op (0);
1265 goto cleanup; 1273 goto cleanup;
1266 } 1274 }
1267 LOG_DEBUG("Received BARRIER_STATUS msg\n"); 1275 LOG_DEBUG ("Received BARRIER_STATUS msg\n");
1268 status = ntohs(msg->status); 1276 status = ntohs (msg->status);
1269 if (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status) 1277 if (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status)
1278 {
1279 status = -1;
1280 // unlike name_len, emsg_len includes the trailing zero
1281 emsg_len = msize - (sizeof(struct GNUNET_TESTBED_BarrierStatusMsg)
1282 + (name_len + 1));
1283 if (0 == emsg_len)
1270 { 1284 {
1271 status = -1; 1285 GNUNET_break_op (0);
1272 //unlike name_len, emsg_len includes the trailing zero
1273 emsg_len = msize - (sizeof(struct GNUNET_TESTBED_BarrierStatusMsg) +
1274 (name_len + 1));
1275 if (0 == emsg_len)
1276 {
1277 GNUNET_break_op(0);
1278 goto cleanup;
1279 }
1280 if ('\0' != (msg->data[(name_len + 1) + (emsg_len - 1)]))
1281 {
1282 GNUNET_break_op(0);
1283 goto cleanup;
1284 }
1285 emsg = GNUNET_malloc(emsg_len);
1286 GNUNET_memcpy(emsg, msg->data + name_len + 1, emsg_len);
1287 }
1288 if (NULL == c->barrier_map)
1289 {
1290 GNUNET_break_op(0);
1291 goto cleanup; 1286 goto cleanup;
1292 } 1287 }
1293 GNUNET_CRYPTO_hash(name, name_len, &key); 1288 if ('\0' != (msg->data[(name_len + 1) + (emsg_len - 1)]))
1294 barrier = GNUNET_CONTAINER_multihashmap_get(c->barrier_map, &key);
1295 if (NULL == barrier)
1296 { 1289 {
1297 GNUNET_break_op(0); 1290 GNUNET_break_op (0);
1298 goto cleanup; 1291 goto cleanup;
1299 } 1292 }
1300 GNUNET_assert(NULL != barrier->cb); 1293 emsg = GNUNET_malloc (emsg_len);
1294 GNUNET_memcpy (emsg, msg->data + name_len + 1, emsg_len);
1295 }
1296 if (NULL == c->barrier_map)
1297 {
1298 GNUNET_break_op (0);
1299 goto cleanup;
1300 }
1301 GNUNET_CRYPTO_hash (name, name_len, &key);
1302 barrier = GNUNET_CONTAINER_multihashmap_get (c->barrier_map, &key);
1303 if (NULL == barrier)
1304 {
1305 GNUNET_break_op (0);
1306 goto cleanup;
1307 }
1308 GNUNET_assert (NULL != barrier->cb);
1301 if ((GNUNET_YES == barrier->echo) && 1309 if ((GNUNET_YES == barrier->echo) &&
1302 (GNUNET_TESTBED_BARRIERSTATUS_CROSSED == status)) 1310 (GNUNET_TESTBED_BARRIERSTATUS_CROSSED == status))
1303 GNUNET_TESTBED_queue_message_(c, GNUNET_copy_message(&msg->header)); 1311 GNUNET_TESTBED_queue_message_ (c, GNUNET_copy_message (&msg->header));
1304 barrier->cb(barrier->cls, name, barrier, status, emsg); 1312 barrier->cb (barrier->cls, name, barrier, status, emsg);
1305 if (GNUNET_TESTBED_BARRIERSTATUS_INITIALISED == status) 1313 if (GNUNET_TESTBED_BARRIERSTATUS_INITIALISED == status)
1306 return; /* just initialised; skip cleanup */ 1314 return; /* just initialised; skip cleanup */
1307 1315
1308cleanup: 1316cleanup:
1309 GNUNET_free_non_null(emsg); 1317 GNUNET_free_non_null (emsg);
1310 /** 1318 /**
1311 * Do not remove the barrier if we did not echo the status back; this is 1319 * Do not remove the barrier if we did not echo the status back; this is
1312 * required at the chained testbed controller setup to ensure the only the 1320 * required at the chained testbed controller setup to ensure the only the
@@ -1314,7 +1322,7 @@ cleanup:
1314 * propagates the status. 1322 * propagates the status.
1315 */ 1323 */
1316 if ((NULL != barrier) && (GNUNET_YES == barrier->echo)) 1324 if ((NULL != barrier) && (GNUNET_YES == barrier->echo))
1317 GNUNET_TESTBED_barrier_remove_(barrier); 1325 GNUNET_TESTBED_barrier_remove_ (barrier);
1318} 1326}
1319 1327
1320 1328
@@ -1325,22 +1333,22 @@ cleanup:
1325 * @param msg the message to queue 1333 * @param msg the message to queue
1326 */ 1334 */
1327void 1335void
1328GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, 1336GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller,
1329 struct GNUNET_MessageHeader *msg) 1337 struct GNUNET_MessageHeader *msg)
1330{ 1338{
1331 struct GNUNET_MQ_Envelope *env; 1339 struct GNUNET_MQ_Envelope *env;
1332 struct GNUNET_MessageHeader *m2; 1340 struct GNUNET_MessageHeader *m2;
1333 uint16_t type; 1341 uint16_t type;
1334 uint16_t size; 1342 uint16_t size;
1335 1343
1336 type = ntohs(msg->type); 1344 type = ntohs (msg->type);
1337 size = ntohs(msg->size); 1345 size = ntohs (msg->size);
1338 GNUNET_assert((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) && 1346 GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) &&
1339 (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type)); 1347 (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type));
1340 env = GNUNET_MQ_msg_extra(m2, size - sizeof(*m2), type); 1348 env = GNUNET_MQ_msg_extra (m2, size - sizeof(*m2), type);
1341 GNUNET_memcpy(m2, msg, size); 1349 GNUNET_memcpy (m2, msg, size);
1342 GNUNET_free(msg); 1350 GNUNET_free (msg);
1343 GNUNET_MQ_send(controller->mq, env); 1351 GNUNET_MQ_send (controller->mq, env);
1344} 1352}
1345 1353
1346 1354
@@ -1359,7 +1367,7 @@ GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller,
1359 * operation 1367 * operation
1360 */ 1368 */
1361struct OperationContext * 1369struct OperationContext *
1362GNUNET_TESTBED_forward_operation_msg_( 1370GNUNET_TESTBED_forward_operation_msg_ (
1363 struct GNUNET_TESTBED_Controller *controller, 1371 struct GNUNET_TESTBED_Controller *controller,
1364 uint64_t operation_id, 1372 uint64_t operation_id,
1365 const struct GNUNET_MessageHeader *msg, 1373 const struct GNUNET_MessageHeader *msg,
@@ -1370,21 +1378,21 @@ GNUNET_TESTBED_forward_operation_msg_(
1370 struct ForwardedOperationData *data; 1378 struct ForwardedOperationData *data;
1371 struct GNUNET_MQ_Envelope *env; 1379 struct GNUNET_MQ_Envelope *env;
1372 struct GNUNET_MessageHeader *m2; 1380 struct GNUNET_MessageHeader *m2;
1373 uint16_t type = ntohs(msg->type); 1381 uint16_t type = ntohs (msg->type);
1374 uint16_t size = ntohs(msg->size); 1382 uint16_t size = ntohs (msg->size);
1375 1383
1376 env = GNUNET_MQ_msg_extra(m2, size - sizeof(*m2), type); 1384 env = GNUNET_MQ_msg_extra (m2, size - sizeof(*m2), type);
1377 GNUNET_memcpy(m2, msg, size); 1385 GNUNET_memcpy (m2, msg, size);
1378 GNUNET_MQ_send(controller->mq, env); 1386 GNUNET_MQ_send (controller->mq, env);
1379 data = GNUNET_new(struct ForwardedOperationData); 1387 data = GNUNET_new (struct ForwardedOperationData);
1380 data->cc = cc; 1388 data->cc = cc;
1381 data->cc_cls = cc_cls; 1389 data->cc_cls = cc_cls;
1382 opc = GNUNET_new(struct OperationContext); 1390 opc = GNUNET_new (struct OperationContext);
1383 opc->c = controller; 1391 opc->c = controller;
1384 opc->type = OP_FORWARDED; 1392 opc->type = OP_FORWARDED;
1385 opc->data = data; 1393 opc->data = data;
1386 opc->id = operation_id; 1394 opc->id = operation_id;
1387 GNUNET_TESTBED_insert_opc_(controller, opc); 1395 GNUNET_TESTBED_insert_opc_ (controller, opc);
1388 return opc; 1396 return opc;
1389} 1397}
1390 1398
@@ -1396,11 +1404,11 @@ GNUNET_TESTBED_forward_operation_msg_(
1396 * @param opc the operation context from GNUNET_TESTBED_forward_operation_msg_() 1404 * @param opc the operation context from GNUNET_TESTBED_forward_operation_msg_()
1397 */ 1405 */
1398void 1406void
1399GNUNET_TESTBED_forward_operation_msg_cancel_(struct OperationContext *opc) 1407GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc)
1400{ 1408{
1401 GNUNET_TESTBED_remove_opc_(opc->c, opc); 1409 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1402 GNUNET_free(opc->data); 1410 GNUNET_free (opc->data);
1403 GNUNET_free(opc); 1411 GNUNET_free (opc);
1404} 1412}
1405 1413
1406 1414
@@ -1411,19 +1419,19 @@ GNUNET_TESTBED_forward_operation_msg_cancel_(struct OperationContext *opc)
1411 * @param cls the closure from GNUNET_TESTBED_operation_create_() 1419 * @param cls the closure from GNUNET_TESTBED_operation_create_()
1412 */ 1420 */
1413static void 1421static void
1414opstart_link_controllers(void *cls) 1422opstart_link_controllers (void *cls)
1415{ 1423{
1416 struct OperationContext *opc = cls; 1424 struct OperationContext *opc = cls;
1417 struct ControllerLinkData *data; 1425 struct ControllerLinkData *data;
1418 struct GNUNET_TESTBED_ControllerLinkRequest *msg; 1426 struct GNUNET_TESTBED_ControllerLinkRequest *msg;
1419 1427
1420 GNUNET_assert(NULL != opc->data); 1428 GNUNET_assert (NULL != opc->data);
1421 data = opc->data; 1429 data = opc->data;
1422 msg = data->msg; 1430 msg = data->msg;
1423 data->msg = NULL; 1431 data->msg = NULL;
1424 opc->state = OPC_STATE_STARTED; 1432 opc->state = OPC_STATE_STARTED;
1425 GNUNET_TESTBED_insert_opc_(opc->c, opc); 1433 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
1426 GNUNET_TESTBED_queue_message_(opc->c, &msg->header); 1434 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
1427} 1435}
1428 1436
1429 1437
@@ -1433,27 +1441,27 @@ opstart_link_controllers(void *cls)
1433 * @param cls the closure from GNUNET_TESTBED_operation_create_() 1441 * @param cls the closure from GNUNET_TESTBED_operation_create_()
1434 */ 1442 */
1435static void 1443static void
1436oprelease_link_controllers(void *cls) 1444oprelease_link_controllers (void *cls)
1437{ 1445{
1438 struct OperationContext *opc = cls; 1446 struct OperationContext *opc = cls;
1439 struct ControllerLinkData *data; 1447 struct ControllerLinkData *data;
1440 1448
1441 data = opc->data; 1449 data = opc->data;
1442 switch (opc->state) 1450 switch (opc->state)
1443 { 1451 {
1444 case OPC_STATE_INIT: 1452 case OPC_STATE_INIT:
1445 GNUNET_free(data->msg); 1453 GNUNET_free (data->msg);
1446 break; 1454 break;
1447 1455
1448 case OPC_STATE_STARTED: 1456 case OPC_STATE_STARTED:
1449 GNUNET_TESTBED_remove_opc_(opc->c, opc); 1457 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1450 break; 1458 break;
1451 1459
1452 case OPC_STATE_FINISHED: 1460 case OPC_STATE_FINISHED:
1453 break; 1461 break;
1454 } 1462 }
1455 GNUNET_free_non_null(data); 1463 GNUNET_free_non_null (data);
1456 GNUNET_free(opc); 1464 GNUNET_free (opc);
1457} 1465}
1458 1466
1459 1467
@@ -1463,19 +1471,19 @@ oprelease_link_controllers(void *cls)
1463 * @param cls the OperationContext of type OP_GET_SLAVE_CONFIG 1471 * @param cls the OperationContext of type OP_GET_SLAVE_CONFIG
1464 */ 1472 */
1465static void 1473static void
1466opstart_get_slave_config(void *cls) 1474opstart_get_slave_config (void *cls)
1467{ 1475{
1468 struct OperationContext *opc = cls; 1476 struct OperationContext *opc = cls;
1469 struct GetSlaveConfigData *data = opc->data; 1477 struct GetSlaveConfigData *data = opc->data;
1470 struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; 1478 struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg;
1471 1479
1472 GNUNET_assert(NULL != data); 1480 GNUNET_assert (NULL != data);
1473 msg = GNUNET_TESTBED_generate_slavegetconfig_msg_(opc->id, data->slave_id); 1481 msg = GNUNET_TESTBED_generate_slavegetconfig_msg_ (opc->id, data->slave_id);
1474 GNUNET_free(opc->data); 1482 GNUNET_free (opc->data);
1475 data = NULL; 1483 data = NULL;
1476 opc->data = NULL; 1484 opc->data = NULL;
1477 GNUNET_TESTBED_insert_opc_(opc->c, opc); 1485 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
1478 GNUNET_TESTBED_queue_message_(opc->c, &msg->header); 1486 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
1479 opc->state = OPC_STATE_STARTED; 1487 opc->state = OPC_STATE_STARTED;
1480} 1488}
1481 1489
@@ -1486,26 +1494,26 @@ opstart_get_slave_config(void *cls)
1486 * @param cls the OperationContext of type OP_GET_SLAVE_CONFIG 1494 * @param cls the OperationContext of type OP_GET_SLAVE_CONFIG
1487 */ 1495 */
1488static void 1496static void
1489oprelease_get_slave_config(void *cls) 1497oprelease_get_slave_config (void *cls)
1490{ 1498{
1491 struct OperationContext *opc = cls; 1499 struct OperationContext *opc = cls;
1492 1500
1493 switch (opc->state) 1501 switch (opc->state)
1494 { 1502 {
1495 case OPC_STATE_INIT: 1503 case OPC_STATE_INIT:
1496 GNUNET_free(opc->data); 1504 GNUNET_free (opc->data);
1497 break; 1505 break;
1498 1506
1499 case OPC_STATE_STARTED: 1507 case OPC_STATE_STARTED:
1500 GNUNET_TESTBED_remove_opc_(opc->c, opc); 1508 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
1501 break; 1509 break;
1502 1510
1503 case OPC_STATE_FINISHED: 1511 case OPC_STATE_FINISHED:
1504 if (NULL != opc->data) 1512 if (NULL != opc->data)
1505 GNUNET_CONFIGURATION_destroy(opc->data); 1513 GNUNET_CONFIGURATION_destroy (opc->data);
1506 break; 1514 break;
1507 } 1515 }
1508 GNUNET_free(opc); 1516 GNUNET_free (opc);
1509} 1517}
1510 1518
1511 1519
@@ -1518,13 +1526,13 @@ oprelease_get_slave_config(void *cls)
1518 * @param error error code 1526 * @param error error code
1519 */ 1527 */
1520static void 1528static void
1521mq_error_handler(void *cls, enum GNUNET_MQ_Error error) 1529mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
1522{ 1530{
1523 /* struct GNUNET_TESTBED_Controller *c = cls; */ 1531 /* struct GNUNET_TESTBED_Controller *c = cls; */
1524 1532
1525 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Encountered MQ error: %d\n", error); 1533 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Encountered MQ error: %d\n", error);
1526 /* now what? */ 1534 /* now what? */
1527 GNUNET_SCHEDULER_shutdown(); /* seems most reasonable */ 1535 GNUNET_SCHEDULER_shutdown (); /* seems most reasonable */
1528} 1536}
1529 1537
1530 1538
@@ -1544,58 +1552,58 @@ mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
1544 * @return handle to the controller 1552 * @return handle to the controller
1545 */ 1553 */
1546struct GNUNET_TESTBED_Controller * 1554struct GNUNET_TESTBED_Controller *
1547GNUNET_TESTBED_controller_connect(struct GNUNET_TESTBED_Host *host, 1555GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1548 uint64_t event_mask, 1556 uint64_t event_mask,
1549 GNUNET_TESTBED_ControllerCallback cc, 1557 GNUNET_TESTBED_ControllerCallback cc,
1550 void *cc_cls) 1558 void *cc_cls)
1551{ 1559{
1552 struct GNUNET_TESTBED_Controller *controller = 1560 struct GNUNET_TESTBED_Controller *controller =
1553 GNUNET_new(struct GNUNET_TESTBED_Controller); 1561 GNUNET_new (struct GNUNET_TESTBED_Controller);
1554 struct GNUNET_MQ_MessageHandler handlers[] = 1562 struct GNUNET_MQ_MessageHandler handlers[] =
1555 { GNUNET_MQ_hd_var_size(add_host_confirm, 1563 { GNUNET_MQ_hd_var_size (add_host_confirm,
1556 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS, 1564 GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS,
1557 struct GNUNET_TESTBED_HostConfirmedMessage, 1565 struct GNUNET_TESTBED_HostConfirmedMessage,
1558 controller), 1566 controller),
1559 GNUNET_MQ_hd_fixed_size(peer_conevent, 1567 GNUNET_MQ_hd_fixed_size (peer_conevent,
1560 GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT, 1568 GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT,
1561 struct GNUNET_TESTBED_ConnectionEventMessage, 1569 struct GNUNET_TESTBED_ConnectionEventMessage,
1562 controller), 1570 controller),
1563 GNUNET_MQ_hd_fixed_size(opsuccess, 1571 GNUNET_MQ_hd_fixed_size (opsuccess,
1564 GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS, 1572 GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS,
1565 struct 1573 struct
1566 GNUNET_TESTBED_GenericOperationSuccessEventMessage, 1574 GNUNET_TESTBED_GenericOperationSuccessEventMessage,
1567 controller), 1575 controller),
1568 GNUNET_MQ_hd_var_size(op_fail_event, 1576 GNUNET_MQ_hd_var_size (op_fail_event,
1569 GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT, 1577 GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT,
1570 struct GNUNET_TESTBED_OperationFailureEventMessage, 1578 struct GNUNET_TESTBED_OperationFailureEventMessage,
1571 controller), 1579 controller),
1572 GNUNET_MQ_hd_fixed_size(peer_create_success, 1580 GNUNET_MQ_hd_fixed_size (peer_create_success,
1573 GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS, 1581 GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS,
1574 struct 1582 struct
1575 GNUNET_TESTBED_PeerCreateSuccessEventMessage, 1583 GNUNET_TESTBED_PeerCreateSuccessEventMessage,
1576 controller), 1584 controller),
1577 GNUNET_MQ_hd_fixed_size(peer_event, 1585 GNUNET_MQ_hd_fixed_size (peer_event,
1578 GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT, 1586 GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT,
1579 struct GNUNET_TESTBED_PeerEventMessage, 1587 struct GNUNET_TESTBED_PeerEventMessage,
1580 controller), 1588 controller),
1581 GNUNET_MQ_hd_var_size(peer_config, 1589 GNUNET_MQ_hd_var_size (peer_config,
1582 GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, 1590 GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION,
1583 struct 1591 struct
1584 GNUNET_TESTBED_PeerConfigurationInformationMessage, 1592 GNUNET_TESTBED_PeerConfigurationInformationMessage,
1585 controller), 1593 controller),
1586 GNUNET_MQ_hd_var_size(slave_config, 1594 GNUNET_MQ_hd_var_size (slave_config,
1587 GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, 1595 GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION,
1588 struct GNUNET_TESTBED_SlaveConfiguration, 1596 struct GNUNET_TESTBED_SlaveConfiguration,
1589 controller), 1597 controller),
1590 GNUNET_MQ_hd_var_size(link_controllers_result, 1598 GNUNET_MQ_hd_var_size (link_controllers_result,
1591 GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT, 1599 GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT,
1592 struct GNUNET_TESTBED_ControllerLinkResponse, 1600 struct GNUNET_TESTBED_ControllerLinkResponse,
1593 controller), 1601 controller),
1594 GNUNET_MQ_hd_var_size(barrier_status, 1602 GNUNET_MQ_hd_var_size (barrier_status,
1595 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS, 1603 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS,
1596 struct GNUNET_TESTBED_BarrierStatusMsg, 1604 struct GNUNET_TESTBED_BarrierStatusMsg,
1597 controller), 1605 controller),
1598 GNUNET_MQ_handler_end() }; 1606 GNUNET_MQ_handler_end () };
1599 struct GNUNET_TESTBED_InitMessage *msg; 1607 struct GNUNET_TESTBED_InitMessage *msg;
1600 struct GNUNET_MQ_Envelope *env; 1608 struct GNUNET_MQ_Envelope *env;
1601 const struct GNUNET_CONFIGURATION_Handle *cfg; 1609 const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -1605,75 +1613,75 @@ GNUNET_TESTBED_controller_connect(struct GNUNET_TESTBED_Host *host,
1605 unsigned long long max_parallel_topology_config_operations; 1613 unsigned long long max_parallel_topology_config_operations;
1606 size_t slen; 1614 size_t slen;
1607 1615
1608 GNUNET_assert(NULL != (cfg = GNUNET_TESTBED_host_get_cfg_(host))); 1616 GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
1609 if (GNUNET_OK != 1617 if (GNUNET_OK !=
1610 GNUNET_CONFIGURATION_get_value_number(cfg, 1618 GNUNET_CONFIGURATION_get_value_number (cfg,
1611 "testbed", 1619 "testbed",
1612 "MAX_PARALLEL_OPERATIONS", 1620 "MAX_PARALLEL_OPERATIONS",
1613 &max_parallel_operations)) 1621 &max_parallel_operations))
1614 { 1622 {
1615 GNUNET_break(0); 1623 GNUNET_break (0);
1616 GNUNET_free(controller); 1624 GNUNET_free (controller);
1617 return NULL; 1625 return NULL;
1618 } 1626 }
1619 if (GNUNET_OK != 1627 if (GNUNET_OK !=
1620 GNUNET_CONFIGURATION_get_value_number(cfg, 1628 GNUNET_CONFIGURATION_get_value_number (cfg,
1621 "testbed", 1629 "testbed",
1622 "MAX_PARALLEL_SERVICE_CONNECTIONS", 1630 "MAX_PARALLEL_SERVICE_CONNECTIONS",
1623 &max_parallel_service_connections)) 1631 &max_parallel_service_connections))
1624 { 1632 {
1625 GNUNET_break(0); 1633 GNUNET_break (0);
1626 GNUNET_free(controller); 1634 GNUNET_free (controller);
1627 return NULL; 1635 return NULL;
1628 } 1636 }
1629 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number( 1637 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (
1630 cfg, 1638 cfg,
1631 "testbed", 1639 "testbed",
1632 "MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS", 1640 "MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS",
1633 &max_parallel_topology_config_operations)) 1641 &max_parallel_topology_config_operations))
1634 { 1642 {
1635 GNUNET_break(0); 1643 GNUNET_break (0);
1636 GNUNET_free(controller); 1644 GNUNET_free (controller);
1637 return NULL; 1645 return NULL;
1638 } 1646 }
1639 controller->cc = cc; 1647 controller->cc = cc;
1640 controller->cc_cls = cc_cls; 1648 controller->cc_cls = cc_cls;
1641 controller->event_mask = event_mask; 1649 controller->event_mask = event_mask;
1642 controller->cfg = GNUNET_CONFIGURATION_dup(cfg); 1650 controller->cfg = GNUNET_CONFIGURATION_dup (cfg);
1643 controller->mq = GNUNET_CLIENT_connect(controller->cfg, 1651 controller->mq = GNUNET_CLIENT_connect (controller->cfg,
1644 "testbed", 1652 "testbed",
1645 handlers, 1653 handlers,
1646 &mq_error_handler, 1654 &mq_error_handler,
1647 controller); 1655 controller);
1648 if (NULL == controller->mq) 1656 if (NULL == controller->mq)
1649 { 1657 {
1650 GNUNET_break(0); 1658 GNUNET_break (0);
1651 GNUNET_TESTBED_controller_disconnect(controller); 1659 GNUNET_TESTBED_controller_disconnect (controller);
1652 return NULL; 1660 return NULL;
1653 } 1661 }
1654 GNUNET_TESTBED_mark_host_registered_at_(host, controller); 1662 GNUNET_TESTBED_mark_host_registered_at_ (host, controller);
1655 controller->host = host; 1663 controller->host = host;
1656 controller->opq_parallel_operations = 1664 controller->opq_parallel_operations =
1657 GNUNET_TESTBED_operation_queue_create_(OPERATION_QUEUE_TYPE_FIXED, 1665 GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_FIXED,
1658 (unsigned int) 1666 (unsigned int)
1659 max_parallel_operations); 1667 max_parallel_operations);
1660 controller->opq_parallel_service_connections = 1668 controller->opq_parallel_service_connections =
1661 GNUNET_TESTBED_operation_queue_create_(OPERATION_QUEUE_TYPE_FIXED, 1669 GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_FIXED,
1662 (unsigned int) 1670 (unsigned int)
1663 max_parallel_service_connections); 1671 max_parallel_service_connections);
1664 controller->opq_parallel_topology_config_operations = 1672 controller->opq_parallel_topology_config_operations =
1665 GNUNET_TESTBED_operation_queue_create_( 1673 GNUNET_TESTBED_operation_queue_create_ (
1666 OPERATION_QUEUE_TYPE_FIXED, 1674 OPERATION_QUEUE_TYPE_FIXED,
1667 (unsigned int)max_parallel_topology_config_operations); 1675 (unsigned int) max_parallel_topology_config_operations);
1668 controller_hostname = GNUNET_TESTBED_host_get_hostname(host); 1676 controller_hostname = GNUNET_TESTBED_host_get_hostname (host);
1669 if (NULL == controller_hostname) 1677 if (NULL == controller_hostname)
1670 controller_hostname = "127.0.0.1"; 1678 controller_hostname = "127.0.0.1";
1671 slen = strlen(controller_hostname) + 1; 1679 slen = strlen (controller_hostname) + 1;
1672 env = GNUNET_MQ_msg_extra(msg, slen, GNUNET_MESSAGE_TYPE_TESTBED_INIT); 1680 env = GNUNET_MQ_msg_extra (msg, slen, GNUNET_MESSAGE_TYPE_TESTBED_INIT);
1673 msg->host_id = htonl(GNUNET_TESTBED_host_get_id_(host)); 1681 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1674 msg->event_mask = GNUNET_htonll(controller->event_mask); 1682 msg->event_mask = GNUNET_htonll (controller->event_mask);
1675 GNUNET_memcpy(&msg[1], controller_hostname, slen); 1683 GNUNET_memcpy (&msg[1], controller_hostname, slen);
1676 GNUNET_MQ_send(controller->mq, env); 1684 GNUNET_MQ_send (controller->mq, env);
1677 return controller; 1685 return controller;
1678} 1686}
1679 1687
@@ -1688,16 +1696,16 @@ GNUNET_TESTBED_controller_connect(struct GNUNET_TESTBED_Host *host,
1688 * #GNUNET_NO if not. 1696 * #GNUNET_NO if not.
1689 */ 1697 */
1690static int 1698static int
1691opc_free_iterator(void *cls, uint32_t key, void *value) 1699opc_free_iterator (void *cls, uint32_t key, void *value)
1692{ 1700{
1693 struct GNUNET_CONTAINER_MultiHashMap32 *map = cls; 1701 struct GNUNET_CONTAINER_MultiHashMap32 *map = cls;
1694 struct OperationContext *opc = value; 1702 struct OperationContext *opc = value;
1695 1703
1696 GNUNET_assert(NULL != opc); 1704 GNUNET_assert (NULL != opc);
1697 GNUNET_break(0); 1705 GNUNET_break (0);
1698 GNUNET_assert(GNUNET_YES == 1706 GNUNET_assert (GNUNET_YES ==
1699 GNUNET_CONTAINER_multihashmap32_remove(map, key, value)); 1707 GNUNET_CONTAINER_multihashmap32_remove (map, key, value));
1700 GNUNET_free(opc); 1708 GNUNET_free (opc);
1701 return GNUNET_YES; 1709 return GNUNET_YES;
1702} 1710}
1703 1711
@@ -1710,30 +1718,30 @@ opc_free_iterator(void *cls, uint32_t key, void *value)
1710 * @param c handle to controller to stop 1718 * @param c handle to controller to stop
1711 */ 1719 */
1712void 1720void
1713GNUNET_TESTBED_controller_disconnect(struct GNUNET_TESTBED_Controller *c) 1721GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *c)
1714{ 1722{
1715 if (NULL != c->mq) 1723 if (NULL != c->mq)
1716 { 1724 {
1717 GNUNET_MQ_destroy(c->mq); 1725 GNUNET_MQ_destroy (c->mq);
1718 c->mq = NULL; 1726 c->mq = NULL;
1719 } 1727 }
1720 if (NULL != c->host) 1728 if (NULL != c->host)
1721 GNUNET_TESTBED_deregister_host_at_(c->host, c); 1729 GNUNET_TESTBED_deregister_host_at_ (c->host, c);
1722 GNUNET_CONFIGURATION_destroy(c->cfg); 1730 GNUNET_CONFIGURATION_destroy (c->cfg);
1723 GNUNET_TESTBED_operation_queue_destroy_(c->opq_parallel_operations); 1731 GNUNET_TESTBED_operation_queue_destroy_ (c->opq_parallel_operations);
1724 GNUNET_TESTBED_operation_queue_destroy_(c->opq_parallel_service_connections); 1732 GNUNET_TESTBED_operation_queue_destroy_ (c->opq_parallel_service_connections);
1725 GNUNET_TESTBED_operation_queue_destroy_( 1733 GNUNET_TESTBED_operation_queue_destroy_ (
1726 c->opq_parallel_topology_config_operations); 1734 c->opq_parallel_topology_config_operations);
1727 if (NULL != c->opc_map) 1735 if (NULL != c->opc_map)
1728 { 1736 {
1729 GNUNET_assert(GNUNET_SYSERR != 1737 GNUNET_assert (GNUNET_SYSERR !=
1730 GNUNET_CONTAINER_multihashmap32_iterate(c->opc_map, 1738 GNUNET_CONTAINER_multihashmap32_iterate (c->opc_map,
1731 &opc_free_iterator, 1739 &opc_free_iterator,
1732 c->opc_map)); 1740 c->opc_map));
1733 GNUNET_assert(0 == GNUNET_CONTAINER_multihashmap32_size(c->opc_map)); 1741 GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (c->opc_map));
1734 GNUNET_CONTAINER_multihashmap32_destroy(c->opc_map); 1742 GNUNET_CONTAINER_multihashmap32_destroy (c->opc_map);
1735 } 1743 }
1736 GNUNET_free(c); 1744 GNUNET_free (c);
1737} 1745}
1738 1746
1739 1747
@@ -1747,19 +1755,19 @@ GNUNET_TESTBED_controller_disconnect(struct GNUNET_TESTBED_Controller *c)
1747 * @return the size of the xconfig 1755 * @return the size of the xconfig
1748 */ 1756 */
1749size_t 1757size_t
1750GNUNET_TESTBED_compress_config_(const char *config, 1758GNUNET_TESTBED_compress_config_ (const char *config,
1751 size_t size, 1759 size_t size,
1752 char **xconfig) 1760 char **xconfig)
1753{ 1761{
1754 size_t xsize; 1762 size_t xsize;
1755 1763
1756 xsize = compressBound((uLong)size); 1764 xsize = compressBound ((uLong) size);
1757 *xconfig = GNUNET_malloc(xsize); 1765 *xconfig = GNUNET_malloc (xsize);
1758 GNUNET_assert(Z_OK == compress2((Bytef *)*xconfig, 1766 GNUNET_assert (Z_OK == compress2 ((Bytef *) *xconfig,
1759 (uLongf *)&xsize, 1767 (uLongf *) &xsize,
1760 (const Bytef *)config, 1768 (const Bytef *) config,
1761 (uLongf)size, 1769 (uLongf) size,
1762 Z_BEST_SPEED)); 1770 Z_BEST_SPEED));
1763 return xsize; 1771 return xsize;
1764} 1772}
1765 1773
@@ -1774,18 +1782,18 @@ GNUNET_TESTBED_compress_config_(const char *config,
1774 * @return the serialized and compressed configuration 1782 * @return the serialized and compressed configuration
1775 */ 1783 */
1776char * 1784char *
1777GNUNET_TESTBED_compress_cfg_(const struct GNUNET_CONFIGURATION_Handle *cfg, 1785GNUNET_TESTBED_compress_cfg_ (const struct GNUNET_CONFIGURATION_Handle *cfg,
1778 size_t *size, 1786 size_t *size,
1779 size_t *xsize) 1787 size_t *xsize)
1780{ 1788{
1781 char *config; 1789 char *config;
1782 char *xconfig; 1790 char *xconfig;
1783 size_t size_; 1791 size_t size_;
1784 size_t xsize_; 1792 size_t xsize_;
1785 1793
1786 config = GNUNET_CONFIGURATION_serialize(cfg, &size_); 1794 config = GNUNET_CONFIGURATION_serialize (cfg, &size_);
1787 xsize_ = GNUNET_TESTBED_compress_config_(config, size_, &xconfig); 1795 xsize_ = GNUNET_TESTBED_compress_config_ (config, size_, &xconfig);
1788 GNUNET_free(config); 1796 GNUNET_free (config);
1789 *size = size_; 1797 *size = size_;
1790 *xsize = xsize_; 1798 *xsize = xsize_;
1791 return xconfig; 1799 return xconfig;
@@ -1821,11 +1829,11 @@ GNUNET_TESTBED_compress_cfg_(const struct GNUNET_CONFIGURATION_Handle *cfg,
1821 * @return the operation handle 1829 * @return the operation handle
1822 */ 1830 */
1823struct GNUNET_TESTBED_Operation * 1831struct GNUNET_TESTBED_Operation *
1824GNUNET_TESTBED_controller_link(void *op_cls, 1832GNUNET_TESTBED_controller_link (void *op_cls,
1825 struct GNUNET_TESTBED_Controller *master, 1833 struct GNUNET_TESTBED_Controller *master,
1826 struct GNUNET_TESTBED_Host *delegated_host, 1834 struct GNUNET_TESTBED_Host *delegated_host,
1827 struct GNUNET_TESTBED_Host *slave_host, 1835 struct GNUNET_TESTBED_Host *slave_host,
1828 int is_subordinate) 1836 int is_subordinate)
1829{ 1837{
1830 struct OperationContext *opc; 1838 struct OperationContext *opc;
1831 struct GNUNET_TESTBED_ControllerLinkRequest *msg; 1839 struct GNUNET_TESTBED_ControllerLinkRequest *msg;
@@ -1834,38 +1842,38 @@ GNUNET_TESTBED_controller_link(void *op_cls,
1834 uint32_t delegated_host_id; 1842 uint32_t delegated_host_id;
1835 uint16_t msg_size; 1843 uint16_t msg_size;
1836 1844
1837 GNUNET_assert(GNUNET_YES == 1845 GNUNET_assert (GNUNET_YES ==
1838 GNUNET_TESTBED_is_host_registered_(delegated_host, master)); 1846 GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
1839 slave_host_id = GNUNET_TESTBED_host_get_id_( 1847 slave_host_id = GNUNET_TESTBED_host_get_id_ (
1840 (NULL != slave_host) ? slave_host : master->host); 1848 (NULL != slave_host) ? slave_host : master->host);
1841 delegated_host_id = GNUNET_TESTBED_host_get_id_(delegated_host); 1849 delegated_host_id = GNUNET_TESTBED_host_get_id_ (delegated_host);
1842 if ((NULL != slave_host) && (0 != slave_host_id)) 1850 if ((NULL != slave_host) && (0 != slave_host_id))
1843 GNUNET_assert(GNUNET_YES == 1851 GNUNET_assert (GNUNET_YES ==
1844 GNUNET_TESTBED_is_host_registered_(slave_host, master)); 1852 GNUNET_TESTBED_is_host_registered_ (slave_host, master));
1845 msg_size = sizeof(struct GNUNET_TESTBED_ControllerLinkRequest); 1853 msg_size = sizeof(struct GNUNET_TESTBED_ControllerLinkRequest);
1846 msg = GNUNET_malloc(msg_size); 1854 msg = GNUNET_malloc (msg_size);
1847 msg->header.type = htons(GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS); 1855 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS);
1848 msg->header.size = htons(msg_size); 1856 msg->header.size = htons (msg_size);
1849 msg->delegated_host_id = htonl(delegated_host_id); 1857 msg->delegated_host_id = htonl (delegated_host_id);
1850 msg->slave_host_id = htonl(slave_host_id); 1858 msg->slave_host_id = htonl (slave_host_id);
1851 msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0; 1859 msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
1852 data = GNUNET_new(struct ControllerLinkData); 1860 data = GNUNET_new (struct ControllerLinkData);
1853 data->msg = msg; 1861 data->msg = msg;
1854 data->host_id = delegated_host_id; 1862 data->host_id = delegated_host_id;
1855 opc = GNUNET_new(struct OperationContext); 1863 opc = GNUNET_new (struct OperationContext);
1856 opc->c = master; 1864 opc->c = master;
1857 opc->data = data; 1865 opc->data = data;
1858 opc->type = OP_LINK_CONTROLLERS; 1866 opc->type = OP_LINK_CONTROLLERS;
1859 opc->id = GNUNET_TESTBED_get_next_op_id(opc->c); 1867 opc->id = GNUNET_TESTBED_get_next_op_id (opc->c);
1860 opc->state = OPC_STATE_INIT; 1868 opc->state = OPC_STATE_INIT;
1861 opc->op_cls = op_cls; 1869 opc->op_cls = op_cls;
1862 msg->operation_id = GNUNET_htonll(opc->id); 1870 msg->operation_id = GNUNET_htonll (opc->id);
1863 opc->op = GNUNET_TESTBED_operation_create_(opc, 1871 opc->op = GNUNET_TESTBED_operation_create_ (opc,
1864 &opstart_link_controllers, 1872 &opstart_link_controllers,
1865 &oprelease_link_controllers); 1873 &oprelease_link_controllers);
1866 GNUNET_TESTBED_operation_queue_insert_(master->opq_parallel_operations, 1874 GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations,
1867 opc->op); 1875 opc->op);
1868 GNUNET_TESTBED_operation_begin_wait_(opc->op); 1876 GNUNET_TESTBED_operation_begin_wait_ (opc->op);
1869 return opc->op; 1877 return opc->op;
1870} 1878}
1871 1879
@@ -1883,28 +1891,28 @@ GNUNET_TESTBED_controller_link(void *op_cls,
1883 * @return the operation handle; 1891 * @return the operation handle;
1884 */ 1892 */
1885struct GNUNET_TESTBED_Operation * 1893struct GNUNET_TESTBED_Operation *
1886GNUNET_TESTBED_get_slave_config_(void *op_cls, 1894GNUNET_TESTBED_get_slave_config_ (void *op_cls,
1887 struct GNUNET_TESTBED_Controller *master, 1895 struct GNUNET_TESTBED_Controller *master,
1888 uint32_t slave_host_id) 1896 uint32_t slave_host_id)
1889{ 1897{
1890 struct OperationContext *opc; 1898 struct OperationContext *opc;
1891 struct GetSlaveConfigData *data; 1899 struct GetSlaveConfigData *data;
1892 1900
1893 data = GNUNET_new(struct GetSlaveConfigData); 1901 data = GNUNET_new (struct GetSlaveConfigData);
1894 data->slave_id = slave_host_id; 1902 data->slave_id = slave_host_id;
1895 opc = GNUNET_new(struct OperationContext); 1903 opc = GNUNET_new (struct OperationContext);
1896 opc->state = OPC_STATE_INIT; 1904 opc->state = OPC_STATE_INIT;
1897 opc->c = master; 1905 opc->c = master;
1898 opc->id = GNUNET_TESTBED_get_next_op_id(master); 1906 opc->id = GNUNET_TESTBED_get_next_op_id (master);
1899 opc->type = OP_GET_SLAVE_CONFIG; 1907 opc->type = OP_GET_SLAVE_CONFIG;
1900 opc->data = data; 1908 opc->data = data;
1901 opc->op_cls = op_cls; 1909 opc->op_cls = op_cls;
1902 opc->op = GNUNET_TESTBED_operation_create_(opc, 1910 opc->op = GNUNET_TESTBED_operation_create_ (opc,
1903 &opstart_get_slave_config, 1911 &opstart_get_slave_config,
1904 &oprelease_get_slave_config); 1912 &oprelease_get_slave_config);
1905 GNUNET_TESTBED_operation_queue_insert_(master->opq_parallel_operations, 1913 GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations,
1906 opc->op); 1914 opc->op);
1907 GNUNET_TESTBED_operation_begin_wait_(opc->op); 1915 GNUNET_TESTBED_operation_begin_wait_ (opc->op);
1908 return opc->op; 1916 return opc->op;
1909} 1917}
1910 1918
@@ -1925,16 +1933,16 @@ GNUNET_TESTBED_get_slave_config_(void *op_cls,
1925 * master 1933 * master
1926 */ 1934 */
1927struct GNUNET_TESTBED_Operation * 1935struct GNUNET_TESTBED_Operation *
1928GNUNET_TESTBED_get_slave_config(void *op_cls, 1936GNUNET_TESTBED_get_slave_config (void *op_cls,
1929 struct GNUNET_TESTBED_Controller *master, 1937 struct GNUNET_TESTBED_Controller *master,
1930 struct GNUNET_TESTBED_Host *slave_host) 1938 struct GNUNET_TESTBED_Host *slave_host)
1931{ 1939{
1932 if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_(slave_host, master)) 1940 if (GNUNET_NO == GNUNET_TESTBED_is_host_registered_ (slave_host, master))
1933 return NULL; 1941 return NULL;
1934 return GNUNET_TESTBED_get_slave_config_(op_cls, 1942 return GNUNET_TESTBED_get_slave_config_ (op_cls,
1935 master, 1943 master,
1936 GNUNET_TESTBED_host_get_id_( 1944 GNUNET_TESTBED_host_get_id_ (
1937 slave_host)); 1945 slave_host));
1938} 1946}
1939 1947
1940 1948
@@ -1948,11 +1956,11 @@ GNUNET_TESTBED_get_slave_config(void *op_cls,
1948 * be written to. 1956 * be written to.
1949 */ 1957 */
1950void 1958void
1951GNUNET_TESTBED_overlay_write_topology_to_file( 1959GNUNET_TESTBED_overlay_write_topology_to_file (
1952 struct GNUNET_TESTBED_Controller *controller, 1960 struct GNUNET_TESTBED_Controller *controller,
1953 const char *filename) 1961 const char *filename)
1954{ 1962{
1955 GNUNET_break(0); 1963 GNUNET_break (0);
1956} 1964}
1957 1965
1958 1966
@@ -1970,7 +1978,7 @@ GNUNET_TESTBED_overlay_write_topology_to_file(
1970 * @return the initialization message 1978 * @return the initialization message
1971 */ 1979 */
1972struct GNUNET_TESTBED_HelperInit * 1980struct GNUNET_TESTBED_HelperInit *
1973GNUNET_TESTBED_create_helper_init_msg_( 1981GNUNET_TESTBED_create_helper_init_msg_ (
1974 const char *trusted_ip, 1982 const char *trusted_ip,
1975 const char *hostname, 1983 const char *hostname,
1976 const struct GNUNET_CONFIGURATION_Handle *cfg) 1984 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -1984,30 +1992,30 @@ GNUNET_TESTBED_create_helper_init_msg_(
1984 uint16_t hostname_len; 1992 uint16_t hostname_len;
1985 uint16_t msg_size; 1993 uint16_t msg_size;
1986 1994
1987 config = GNUNET_CONFIGURATION_serialize(cfg, &config_size); 1995 config = GNUNET_CONFIGURATION_serialize (cfg, &config_size);
1988 GNUNET_assert(NULL != config); 1996 GNUNET_assert (NULL != config);
1989 xconfig_size = 1997 xconfig_size =
1990 GNUNET_TESTBED_compress_config_(config, config_size, &xconfig); 1998 GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
1991 GNUNET_free(config); 1999 GNUNET_free (config);
1992 trusted_ip_len = strlen(trusted_ip); 2000 trusted_ip_len = strlen (trusted_ip);
1993 hostname_len = (NULL == hostname) ? 0 : strlen(hostname); 2001 hostname_len = (NULL == hostname) ? 0 : strlen (hostname);
1994 msg_size = xconfig_size + trusted_ip_len + 1 + 2002 msg_size = xconfig_size + trusted_ip_len + 1
1995 sizeof(struct GNUNET_TESTBED_HelperInit); 2003 + sizeof(struct GNUNET_TESTBED_HelperInit);
1996 msg_size += hostname_len; 2004 msg_size += hostname_len;
1997 msg = GNUNET_realloc(xconfig, msg_size); 2005 msg = GNUNET_realloc (xconfig, msg_size);
1998 (void)memmove(((void *)&msg[1]) + trusted_ip_len + 1 + hostname_len, 2006 (void) memmove (((void *) &msg[1]) + trusted_ip_len + 1 + hostname_len,
1999 msg, 2007 msg,
2000 xconfig_size); 2008 xconfig_size);
2001 msg->header.size = htons(msg_size); 2009 msg->header.size = htons (msg_size);
2002 msg->header.type = htons(GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT); 2010 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT);
2003 msg->trusted_ip_size = htons(trusted_ip_len); 2011 msg->trusted_ip_size = htons (trusted_ip_len);
2004 msg->hostname_size = htons(hostname_len); 2012 msg->hostname_size = htons (hostname_len);
2005 msg->config_size = htons(config_size); 2013 msg->config_size = htons (config_size);
2006 (void)strcpy((char *)&msg[1], trusted_ip); 2014 (void) strcpy ((char *) &msg[1], trusted_ip);
2007 if (0 != hostname_len) 2015 if (0 != hostname_len)
2008 GNUNET_memcpy((char *)&msg[1] + trusted_ip_len + 1, 2016 GNUNET_memcpy ((char *) &msg[1] + trusted_ip_len + 1,
2009 hostname, 2017 hostname,
2010 hostname_len); 2018 hostname_len);
2011 return msg; 2019 return msg;
2012} 2020}
2013 2021
@@ -2034,10 +2042,10 @@ GNUNET_TESTBED_create_helper_init_msg_(
2034 * @param operation operation to signal completion or cancellation 2042 * @param operation operation to signal completion or cancellation
2035 */ 2043 */
2036void 2044void
2037GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation) 2045GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation)
2038{ 2046{
2039 (void)exop_check(operation); 2047 (void) exop_check (operation);
2040 GNUNET_TESTBED_operation_release_(operation); 2048 GNUNET_TESTBED_operation_release_ (operation);
2041} 2049}
2042 2050
2043 2051
@@ -2056,7 +2064,7 @@ GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
2056 * @return handle to the parsed configuration; NULL upon error while parsing the message 2064 * @return handle to the parsed configuration; NULL upon error while parsing the message
2057 */ 2065 */
2058struct GNUNET_CONFIGURATION_Handle * 2066struct GNUNET_CONFIGURATION_Handle *
2059GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg) 2067GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg)
2060{ 2068{
2061 struct GNUNET_CONFIGURATION_Handle *cfg; 2069 struct GNUNET_CONFIGURATION_Handle *cfg;
2062 Bytef *data; 2070 Bytef *data;
@@ -2065,99 +2073,99 @@ GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg)
2065 uLong xdata_len; 2073 uLong xdata_len;
2066 int ret; 2074 int ret;
2067 2075
2068 switch (ntohs(msg->type)) 2076 switch (ntohs (msg->type))
2069 { 2077 {
2070 case GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION: { 2078 case GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION: {
2071 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg; 2079 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg;
2072 2080
2073 imsg = 2081 imsg =
2074 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *)msg; 2082 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg;
2075 data_len = (uLong)ntohs(imsg->config_size); 2083 data_len = (uLong) ntohs (imsg->config_size);
2076 xdata_len = 2084 xdata_len =
2077 ntohs(imsg->header.size) - 2085 ntohs (imsg->header.size)
2078 sizeof(struct GNUNET_TESTBED_PeerConfigurationInformationMessage); 2086 - sizeof(struct GNUNET_TESTBED_PeerConfigurationInformationMessage);
2079 xdata = (const Bytef *)&imsg[1]; 2087 xdata = (const Bytef *) &imsg[1];
2080 } 2088 }
2081 break; 2089 break;
2082 2090
2083 case GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION: { 2091 case GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION: {
2084 const struct GNUNET_TESTBED_SlaveConfiguration *imsg; 2092 const struct GNUNET_TESTBED_SlaveConfiguration *imsg;
2085 2093
2086 imsg = (const struct GNUNET_TESTBED_SlaveConfiguration *)msg; 2094 imsg = (const struct GNUNET_TESTBED_SlaveConfiguration *) msg;
2087 data_len = (uLong)ntohs(imsg->config_size); 2095 data_len = (uLong) ntohs (imsg->config_size);
2088 xdata_len = ntohs(imsg->header.size) - 2096 xdata_len = ntohs (imsg->header.size)
2089 sizeof(struct GNUNET_TESTBED_SlaveConfiguration); 2097 - sizeof(struct GNUNET_TESTBED_SlaveConfiguration);
2090 xdata = (const Bytef *)&imsg[1]; 2098 xdata = (const Bytef *) &imsg[1];
2091 } 2099 }
2092 break; 2100 break;
2093 2101
2094 case GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST: { 2102 case GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST: {
2095 const struct GNUNET_TESTBED_AddHostMessage *imsg; 2103 const struct GNUNET_TESTBED_AddHostMessage *imsg;
2096 uint16_t osize; 2104 uint16_t osize;
2097 2105
2098 imsg = (const struct GNUNET_TESTBED_AddHostMessage *)msg; 2106 imsg = (const struct GNUNET_TESTBED_AddHostMessage *) msg;
2099 data_len = (uLong)ntohs(imsg->config_size); 2107 data_len = (uLong) ntohs (imsg->config_size);
2100 osize = sizeof(struct GNUNET_TESTBED_AddHostMessage) + 2108 osize = sizeof(struct GNUNET_TESTBED_AddHostMessage)
2101 ntohs(imsg->username_length) + ntohs(imsg->hostname_length); 2109 + ntohs (imsg->username_length) + ntohs (imsg->hostname_length);
2102 xdata_len = ntohs(imsg->header.size) - osize; 2110 xdata_len = ntohs (imsg->header.size) - osize;
2103 xdata = (const Bytef *)((const void *)imsg + osize); 2111 xdata = (const Bytef *) ((const void *) imsg + osize);
2104 } 2112 }
2105 break; 2113 break;
2106 2114
2107 case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT: { 2115 case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT: {
2108 const struct GNUNET_TESTBED_ControllerLinkResponse *imsg; 2116 const struct GNUNET_TESTBED_ControllerLinkResponse *imsg;
2109 2117
2110 imsg = (const struct GNUNET_TESTBED_ControllerLinkResponse *)msg; 2118 imsg = (const struct GNUNET_TESTBED_ControllerLinkResponse *) msg;
2111 data_len = ntohs(imsg->config_size); 2119 data_len = ntohs (imsg->config_size);
2112 xdata_len = ntohs(imsg->header.size) - 2120 xdata_len = ntohs (imsg->header.size)
2113 sizeof(const struct GNUNET_TESTBED_ControllerLinkResponse); 2121 - sizeof(const struct GNUNET_TESTBED_ControllerLinkResponse);
2114 xdata = (const Bytef *)&imsg[1]; 2122 xdata = (const Bytef *) &imsg[1];
2115 } 2123 }
2116 break; 2124 break;
2117 2125
2118 case GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER: { 2126 case GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER: {
2119 const struct GNUNET_TESTBED_PeerCreateMessage *imsg; 2127 const struct GNUNET_TESTBED_PeerCreateMessage *imsg;
2120 2128
2121 imsg = (const struct GNUNET_TESTBED_PeerCreateMessage *)msg; 2129 imsg = (const struct GNUNET_TESTBED_PeerCreateMessage *) msg;
2122 data_len = ntohs(imsg->config_size); 2130 data_len = ntohs (imsg->config_size);
2123 xdata_len = ntohs(imsg->header.size) - 2131 xdata_len = ntohs (imsg->header.size)
2124 sizeof(struct GNUNET_TESTBED_PeerCreateMessage); 2132 - sizeof(struct GNUNET_TESTBED_PeerCreateMessage);
2125 xdata = (const Bytef *)&imsg[1]; 2133 xdata = (const Bytef *) &imsg[1];
2126 } 2134 }
2127 break; 2135 break;
2128 2136
2129 case GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER: { 2137 case GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER: {
2130 const struct GNUNET_TESTBED_PeerReconfigureMessage *imsg; 2138 const struct GNUNET_TESTBED_PeerReconfigureMessage *imsg;
2131 2139
2132 imsg = (const struct GNUNET_TESTBED_PeerReconfigureMessage *)msg; 2140 imsg = (const struct GNUNET_TESTBED_PeerReconfigureMessage *) msg;
2133 data_len = ntohs(imsg->config_size); 2141 data_len = ntohs (imsg->config_size);
2134 xdata_len = ntohs(imsg->header.size) - 2142 xdata_len = ntohs (imsg->header.size)
2135 sizeof(struct GNUNET_TESTBED_PeerReconfigureMessage); 2143 - sizeof(struct GNUNET_TESTBED_PeerReconfigureMessage);
2136 xdata = (const Bytef *)&imsg[1]; 2144 xdata = (const Bytef *) &imsg[1];
2137 } 2145 }
2138 break; 2146 break;
2139 2147
2140 default: 2148 default:
2141 GNUNET_assert(0); 2149 GNUNET_assert (0);
2142 } 2150 }
2143 data = GNUNET_malloc(data_len); 2151 data = GNUNET_malloc (data_len);
2144 if (Z_OK != (ret = uncompress(data, &data_len, xdata, xdata_len))) 2152 if (Z_OK != (ret = uncompress (data, &data_len, xdata, xdata_len)))
2145 { 2153 {
2146 GNUNET_free(data); 2154 GNUNET_free (data);
2147 GNUNET_break_op(0); /* Un-compression failure */ 2155 GNUNET_break_op (0); /* Un-compression failure */
2148 return NULL; 2156 return NULL;
2149 } 2157 }
2150 cfg = GNUNET_CONFIGURATION_create(); 2158 cfg = GNUNET_CONFIGURATION_create ();
2151 if (GNUNET_OK != GNUNET_CONFIGURATION_deserialize(cfg, 2159 if (GNUNET_OK != GNUNET_CONFIGURATION_deserialize (cfg,
2152 (const char *)data, 2160 (const char *) data,
2153 (size_t)data_len, 2161 (size_t) data_len,
2154 NULL)) 2162 NULL))
2155 { 2163 {
2156 GNUNET_free(data); 2164 GNUNET_free (data);
2157 GNUNET_break_op(0); /* De-serialization failure */ 2165 GNUNET_break_op (0); /* De-serialization failure */
2158 return NULL; 2166 return NULL;
2159 } 2167 }
2160 GNUNET_free(data); 2168 GNUNET_free (data);
2161 return cfg; 2169 return cfg;
2162} 2170}
2163 2171
@@ -2170,22 +2178,22 @@ GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg)
2170 * @return the error message 2178 * @return the error message
2171 */ 2179 */
2172const char * 2180const char *
2173GNUNET_TESTBED_parse_error_string_( 2181GNUNET_TESTBED_parse_error_string_ (
2174 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg) 2182 const struct GNUNET_TESTBED_OperationFailureEventMessage *msg)
2175{ 2183{
2176 uint16_t msize; 2184 uint16_t msize;
2177 const char *emsg; 2185 const char *emsg;
2178 2186
2179 msize = ntohs(msg->header.size); 2187 msize = ntohs (msg->header.size);
2180 if (sizeof(struct GNUNET_TESTBED_OperationFailureEventMessage) >= msize) 2188 if (sizeof(struct GNUNET_TESTBED_OperationFailureEventMessage) >= msize)
2181 return NULL; 2189 return NULL;
2182 msize -= sizeof(struct GNUNET_TESTBED_OperationFailureEventMessage); 2190 msize -= sizeof(struct GNUNET_TESTBED_OperationFailureEventMessage);
2183 emsg = (const char *)&msg[1]; 2191 emsg = (const char *) &msg[1];
2184 if ('\0' != emsg[msize - 1]) 2192 if ('\0' != emsg[msize - 1])
2185 { 2193 {
2186 GNUNET_break(0); 2194 GNUNET_break (0);
2187 return NULL; 2195 return NULL;
2188 } 2196 }
2189 return emsg; 2197 return emsg;
2190} 2198}
2191 2199
@@ -2198,13 +2206,13 @@ GNUNET_TESTBED_parse_error_string_(
2198 * @return the incremented operation id. 2206 * @return the incremented operation id.
2199 */ 2207 */
2200uint64_t 2208uint64_t
2201GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller) 2209GNUNET_TESTBED_get_next_op_id (struct GNUNET_TESTBED_Controller *controller)
2202{ 2210{
2203 uint64_t op_id; 2211 uint64_t op_id;
2204 2212
2205 op_id = (uint64_t)GNUNET_TESTBED_host_get_id_(controller->host); 2213 op_id = (uint64_t) GNUNET_TESTBED_host_get_id_ (controller->host);
2206 op_id = op_id << 32; 2214 op_id = op_id << 32;
2207 op_id |= (uint64_t)controller->operation_counter++; 2215 op_id |= (uint64_t) controller->operation_counter++;
2208 return op_id; 2216 return op_id;
2209} 2217}
2210 2218
@@ -2215,17 +2223,17 @@ GNUNET_TESTBED_get_next_op_id(struct GNUNET_TESTBED_Controller *controller)
2215 * @param cls the closure from GNUNET_TESTBED_operation_create_() 2223 * @param cls the closure from GNUNET_TESTBED_operation_create_()
2216 */ 2224 */
2217static void 2225static void
2218opstart_shutdown_peers(void *cls) 2226opstart_shutdown_peers (void *cls)
2219{ 2227{
2220 struct OperationContext *opc = cls; 2228 struct OperationContext *opc = cls;
2221 struct GNUNET_MQ_Envelope *env; 2229 struct GNUNET_MQ_Envelope *env;
2222 struct GNUNET_TESTBED_ShutdownPeersMessage *msg; 2230 struct GNUNET_TESTBED_ShutdownPeersMessage *msg;
2223 2231
2224 opc->state = OPC_STATE_STARTED; 2232 opc->state = OPC_STATE_STARTED;
2225 env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS); 2233 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS);
2226 msg->operation_id = GNUNET_htonll(opc->id); 2234 msg->operation_id = GNUNET_htonll (opc->id);
2227 GNUNET_TESTBED_insert_opc_(opc->c, opc); 2235 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
2228 GNUNET_MQ_send(opc->c->mq, env); 2236 GNUNET_MQ_send (opc->c->mq, env);
2229} 2237}
2230 2238
2231 2239
@@ -2235,24 +2243,24 @@ opstart_shutdown_peers(void *cls)
2235 * @param cls the closure from GNUNET_TESTBED_operation_create_() 2243 * @param cls the closure from GNUNET_TESTBED_operation_create_()
2236 */ 2244 */
2237static void 2245static void
2238oprelease_shutdown_peers(void *cls) 2246oprelease_shutdown_peers (void *cls)
2239{ 2247{
2240 struct OperationContext *opc = cls; 2248 struct OperationContext *opc = cls;
2241 2249
2242 switch (opc->state) 2250 switch (opc->state)
2243 { 2251 {
2244 case OPC_STATE_STARTED: 2252 case OPC_STATE_STARTED:
2245 GNUNET_TESTBED_remove_opc_(opc->c, opc); 2253 GNUNET_TESTBED_remove_opc_ (opc->c, opc);
2246 2254
2247 /* no break; continue */ 2255 /* no break; continue */
2248 case OPC_STATE_INIT: 2256 case OPC_STATE_INIT:
2249 GNUNET_free(opc->data); 2257 GNUNET_free (opc->data);
2250 break; 2258 break;
2251 2259
2252 case OPC_STATE_FINISHED: 2260 case OPC_STATE_FINISHED:
2253 break; 2261 break;
2254 } 2262 }
2255 GNUNET_free(opc); 2263 GNUNET_free (opc);
2256} 2264}
2257 2265
2258 2266
@@ -2272,32 +2280,32 @@ oprelease_shutdown_peers(void *cls)
2272 * present 2280 * present
2273 */ 2281 */
2274struct GNUNET_TESTBED_Operation * 2282struct GNUNET_TESTBED_Operation *
2275GNUNET_TESTBED_shutdown_peers(struct GNUNET_TESTBED_Controller *c, 2283GNUNET_TESTBED_shutdown_peers (struct GNUNET_TESTBED_Controller *c,
2276 void *op_cls, 2284 void *op_cls,
2277 GNUNET_TESTBED_OperationCompletionCallback cb, 2285 GNUNET_TESTBED_OperationCompletionCallback cb,
2278 void *cb_cls) 2286 void *cb_cls)
2279{ 2287{
2280 struct OperationContext *opc; 2288 struct OperationContext *opc;
2281 struct ShutdownPeersData *data; 2289 struct ShutdownPeersData *data;
2282 2290
2283 if (0 != GNUNET_CONTAINER_multihashmap32_size(c->opc_map)) 2291 if (0 != GNUNET_CONTAINER_multihashmap32_size (c->opc_map))
2284 return NULL; 2292 return NULL;
2285 data = GNUNET_new(struct ShutdownPeersData); 2293 data = GNUNET_new (struct ShutdownPeersData);
2286 data->cb = cb; 2294 data->cb = cb;
2287 data->cb_cls = cb_cls; 2295 data->cb_cls = cb_cls;
2288 opc = GNUNET_new(struct OperationContext); 2296 opc = GNUNET_new (struct OperationContext);
2289 opc->c = c; 2297 opc->c = c;
2290 opc->op_cls = op_cls; 2298 opc->op_cls = op_cls;
2291 opc->data = data; 2299 opc->data = data;
2292 opc->id = GNUNET_TESTBED_get_next_op_id(c); 2300 opc->id = GNUNET_TESTBED_get_next_op_id (c);
2293 opc->type = OP_SHUTDOWN_PEERS; 2301 opc->type = OP_SHUTDOWN_PEERS;
2294 opc->state = OPC_STATE_INIT; 2302 opc->state = OPC_STATE_INIT;
2295 opc->op = GNUNET_TESTBED_operation_create_(opc, 2303 opc->op = GNUNET_TESTBED_operation_create_ (opc,
2296 &opstart_shutdown_peers, 2304 &opstart_shutdown_peers,
2297 &oprelease_shutdown_peers); 2305 &oprelease_shutdown_peers);
2298 GNUNET_TESTBED_operation_queue_insert_(opc->c->opq_parallel_operations, 2306 GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations,
2299 opc->op); 2307 opc->op);
2300 GNUNET_TESTBED_operation_begin_wait_(opc->op); 2308 GNUNET_TESTBED_operation_begin_wait_ (opc->op);
2301 return opc->op; 2309 return opc->op;
2302} 2310}
2303 2311
@@ -2311,7 +2319,7 @@ GNUNET_TESTBED_shutdown_peers(struct GNUNET_TESTBED_Controller *c,
2311 * @return The peer's unique ID. 2319 * @return The peer's unique ID.
2312 */ 2320 */
2313uint32_t 2321uint32_t
2314GNUNET_TESTBED_get_index(const struct GNUNET_TESTBED_Peer *peer) 2322GNUNET_TESTBED_get_index (const struct GNUNET_TESTBED_Peer *peer)
2315{ 2323{
2316 return peer->unique_id; 2324 return peer->unique_id;
2317} 2325}
@@ -2324,22 +2332,22 @@ GNUNET_TESTBED_get_index(const struct GNUNET_TESTBED_Peer *peer)
2324 * @param barrier the barrier to remove 2332 * @param barrier the barrier to remove
2325 */ 2333 */
2326void 2334void
2327GNUNET_TESTBED_barrier_remove_(struct GNUNET_TESTBED_Barrier *barrier) 2335GNUNET_TESTBED_barrier_remove_ (struct GNUNET_TESTBED_Barrier *barrier)
2328{ 2336{
2329 struct GNUNET_TESTBED_Controller *c = barrier->c; 2337 struct GNUNET_TESTBED_Controller *c = barrier->c;
2330 2338
2331 GNUNET_assert(NULL != c->barrier_map); /* No barriers present */ 2339 GNUNET_assert (NULL != c->barrier_map); /* No barriers present */
2332 GNUNET_assert(GNUNET_OK == 2340 GNUNET_assert (GNUNET_OK ==
2333 GNUNET_CONTAINER_multihashmap_remove(c->barrier_map, 2341 GNUNET_CONTAINER_multihashmap_remove (c->barrier_map,
2334 &barrier->key, 2342 &barrier->key,
2335 barrier)); 2343 barrier));
2336 GNUNET_free(barrier->name); 2344 GNUNET_free (barrier->name);
2337 GNUNET_free(barrier); 2345 GNUNET_free (barrier);
2338 if (0 == GNUNET_CONTAINER_multihashmap_size(c->barrier_map)) 2346 if (0 == GNUNET_CONTAINER_multihashmap_size (c->barrier_map))
2339 { 2347 {
2340 GNUNET_CONTAINER_multihashmap_destroy(c->barrier_map); 2348 GNUNET_CONTAINER_multihashmap_destroy (c->barrier_map);
2341 c->barrier_map = NULL; 2349 c->barrier_map = NULL;
2342 } 2350 }
2343} 2351}
2344 2352
2345 2353
@@ -2360,12 +2368,12 @@ GNUNET_TESTBED_barrier_remove_(struct GNUNET_TESTBED_Barrier *barrier)
2360 * @return barrier handle; NULL upon error 2368 * @return barrier handle; NULL upon error
2361 */ 2369 */
2362struct GNUNET_TESTBED_Barrier * 2370struct GNUNET_TESTBED_Barrier *
2363GNUNET_TESTBED_barrier_init_(struct GNUNET_TESTBED_Controller *controller, 2371GNUNET_TESTBED_barrier_init_ (struct GNUNET_TESTBED_Controller *controller,
2364 const char *name, 2372 const char *name,
2365 unsigned int quorum, 2373 unsigned int quorum,
2366 GNUNET_TESTBED_barrier_status_cb cb, 2374 GNUNET_TESTBED_barrier_status_cb cb,
2367 void *cls, 2375 void *cls,
2368 int echo) 2376 int echo)
2369{ 2377{
2370 struct GNUNET_TESTBED_BarrierInit *msg; 2378 struct GNUNET_TESTBED_BarrierInit *msg;
2371 struct GNUNET_MQ_Envelope *env; 2379 struct GNUNET_MQ_Envelope *env;
@@ -2373,41 +2381,41 @@ GNUNET_TESTBED_barrier_init_(struct GNUNET_TESTBED_Controller *controller,
2373 struct GNUNET_HashCode key; 2381 struct GNUNET_HashCode key;
2374 size_t name_len; 2382 size_t name_len;
2375 2383
2376 GNUNET_assert(quorum <= 100); 2384 GNUNET_assert (quorum <= 100);
2377 GNUNET_assert(NULL != cb); 2385 GNUNET_assert (NULL != cb);
2378 name_len = strlen(name); 2386 name_len = strlen (name);
2379 GNUNET_assert(0 < name_len); 2387 GNUNET_assert (0 < name_len);
2380 GNUNET_CRYPTO_hash(name, name_len, &key); 2388 GNUNET_CRYPTO_hash (name, name_len, &key);
2381 if (NULL == controller->barrier_map) 2389 if (NULL == controller->barrier_map)
2382 controller->barrier_map = 2390 controller->barrier_map =
2383 GNUNET_CONTAINER_multihashmap_create(3, GNUNET_YES); 2391 GNUNET_CONTAINER_multihashmap_create (3, GNUNET_YES);
2384 if (GNUNET_YES == 2392 if (GNUNET_YES ==
2385 GNUNET_CONTAINER_multihashmap_contains(controller->barrier_map, &key)) 2393 GNUNET_CONTAINER_multihashmap_contains (controller->barrier_map, &key))
2386 { 2394 {
2387 GNUNET_break(0); 2395 GNUNET_break (0);
2388 return NULL; 2396 return NULL;
2389 } 2397 }
2390 LOG_DEBUG("Initialising barrier `%s'\n", name); 2398 LOG_DEBUG ("Initialising barrier `%s'\n", name);
2391 barrier = GNUNET_new(struct GNUNET_TESTBED_Barrier); 2399 barrier = GNUNET_new (struct GNUNET_TESTBED_Barrier);
2392 barrier->c = controller; 2400 barrier->c = controller;
2393 barrier->name = GNUNET_strdup(name); 2401 barrier->name = GNUNET_strdup (name);
2394 barrier->cb = cb; 2402 barrier->cb = cb;
2395 barrier->cls = cls; 2403 barrier->cls = cls;
2396 barrier->echo = echo; 2404 barrier->echo = echo;
2397 GNUNET_memcpy(&barrier->key, &key, sizeof(struct GNUNET_HashCode)); 2405 GNUNET_memcpy (&barrier->key, &key, sizeof(struct GNUNET_HashCode));
2398 GNUNET_assert(GNUNET_OK == 2406 GNUNET_assert (GNUNET_OK ==
2399 GNUNET_CONTAINER_multihashmap_put( 2407 GNUNET_CONTAINER_multihashmap_put (
2400 controller->barrier_map, 2408 controller->barrier_map,
2401 &barrier->key, 2409 &barrier->key,
2402 barrier, 2410 barrier,
2403 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); 2411 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
2404 2412
2405 env = GNUNET_MQ_msg_extra(msg, 2413 env = GNUNET_MQ_msg_extra (msg,
2406 name_len, 2414 name_len,
2407 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT); 2415 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT);
2408 msg->quorum = (uint8_t)quorum; 2416 msg->quorum = (uint8_t) quorum;
2409 GNUNET_memcpy(msg->name, barrier->name, name_len); 2417 GNUNET_memcpy (msg->name, barrier->name, name_len);
2410 GNUNET_MQ_send(barrier->c->mq, env); 2418 GNUNET_MQ_send (barrier->c->mq, env);
2411 return barrier; 2419 return barrier;
2412} 2420}
2413 2421
@@ -2427,18 +2435,18 @@ GNUNET_TESTBED_barrier_init_(struct GNUNET_TESTBED_Controller *controller,
2427 * @return barrier handle; NULL upon error 2435 * @return barrier handle; NULL upon error
2428 */ 2436 */
2429struct GNUNET_TESTBED_Barrier * 2437struct GNUNET_TESTBED_Barrier *
2430GNUNET_TESTBED_barrier_init(struct GNUNET_TESTBED_Controller *controller, 2438GNUNET_TESTBED_barrier_init (struct GNUNET_TESTBED_Controller *controller,
2431 const char *name, 2439 const char *name,
2432 unsigned int quorum, 2440 unsigned int quorum,
2433 GNUNET_TESTBED_barrier_status_cb cb, 2441 GNUNET_TESTBED_barrier_status_cb cb,
2434 void *cls) 2442 void *cls)
2435{ 2443{
2436 return GNUNET_TESTBED_barrier_init_(controller, 2444 return GNUNET_TESTBED_barrier_init_ (controller,
2437 name, 2445 name,
2438 quorum, 2446 quorum,
2439 cb, 2447 cb,
2440 cls, 2448 cls,
2441 GNUNET_YES); 2449 GNUNET_YES);
2442} 2450}
2443 2451
2444 2452
@@ -2448,18 +2456,18 @@ GNUNET_TESTBED_barrier_init(struct GNUNET_TESTBED_Controller *controller,
2448 * @param barrier the barrier handle 2456 * @param barrier the barrier handle
2449 */ 2457 */
2450void 2458void
2451GNUNET_TESTBED_barrier_cancel(struct GNUNET_TESTBED_Barrier *barrier) 2459GNUNET_TESTBED_barrier_cancel (struct GNUNET_TESTBED_Barrier *barrier)
2452{ 2460{
2453 struct GNUNET_MQ_Envelope *env; 2461 struct GNUNET_MQ_Envelope *env;
2454 struct GNUNET_TESTBED_BarrierCancel *msg; 2462 struct GNUNET_TESTBED_BarrierCancel *msg;
2455 size_t slen; 2463 size_t slen;
2456 2464
2457 slen = strlen(barrier->name); 2465 slen = strlen (barrier->name);
2458 env = 2466 env =
2459 GNUNET_MQ_msg_extra(msg, slen, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL); 2467 GNUNET_MQ_msg_extra (msg, slen, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL);
2460 GNUNET_memcpy(msg->name, barrier->name, slen); 2468 GNUNET_memcpy (msg->name, barrier->name, slen);
2461 GNUNET_MQ_send(barrier->c->mq, env); 2469 GNUNET_MQ_send (barrier->c->mq, env);
2462 GNUNET_TESTBED_barrier_remove_(barrier); 2470 GNUNET_TESTBED_barrier_remove_ (barrier);
2463} 2471}
2464 2472
2465 2473