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