aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api.c')
-rw-r--r--src/testbed/testbed_api.c63
1 files changed, 24 insertions, 39 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 48c55e470..665c19486 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -322,8 +322,7 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c,
322 event->details.operation_finished.operation = opc->op; 322 event->details.operation_finished.operation = opc->op;
323 event->details.operation_finished.op_cls = NULL; 323 event->details.operation_finished.op_cls = NULL;
324 event->details.operation_finished.emsg = NULL; 324 event->details.operation_finished.emsg = NULL;
325 event->details.operation_finished.pit = GNUNET_TESTBED_PIT_GENERIC; 325 event->details.operation_finished.generic = NULL;
326 event->details.operation_finished.op_result.generic = NULL;
327 } 326 }
328 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); 327 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
329 opc->state = OPC_STATE_FINISHED; 328 opc->state = OPC_STATE_FINISHED;
@@ -480,6 +479,8 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c,
480{ 479{
481 struct OperationContext *opc; 480 struct OperationContext *opc;
482 struct OverlayConnectData *data; 481 struct OverlayConnectData *data;
482 GNUNET_TESTBED_OperationCompletionCallback cb;
483 void *cb_cls;
483 struct GNUNET_TESTBED_EventInformation event; 484 struct GNUNET_TESTBED_EventInformation event;
484 uint64_t op_id; 485 uint64_t op_id;
485 486
@@ -507,6 +508,8 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c,
507 GNUNET_assert (0); /* Should never reach here */ 508 GNUNET_assert (0); /* Should never reach here */
508 break; 509 break;
509 } 510 }
511 cb = data->cb;
512 cb_cls = data->cb_cls;
510 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); 513 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
511 opc->state = OPC_STATE_FINISHED; 514 opc->state = OPC_STATE_FINISHED;
512 GNUNET_free (data); 515 GNUNET_free (data);
@@ -517,6 +520,8 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c,
517 if (NULL != c->cc) 520 if (NULL != c->cc)
518 c->cc (c->cc_cls, &event); 521 c->cc (c->cc_cls, &event);
519 } 522 }
523 if (NULL != cb)
524 cb (cb_cls, opc->op, NULL);
520 return GNUNET_YES; 525 return GNUNET_YES;
521} 526}
522 527
@@ -538,8 +543,9 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c,
538 struct OperationContext *opc; 543 struct OperationContext *opc;
539 struct GNUNET_TESTBED_Peer *peer; 544 struct GNUNET_TESTBED_Peer *peer;
540 struct PeerInfoData *data; 545 struct PeerInfoData *data;
541 struct PeerInfoData2 *response_data; 546 struct GNUNET_TESTBED_PeerInformation *pinfo;
542 struct GNUNET_TESTBED_EventInformation info; 547 GNUNET_TESTBED_PeerInfoCallback cb;
548 void *cb_cls;
543 uint64_t op_id; 549 uint64_t op_id;
544 550
545 op_id = GNUNET_ntohll (msg->operation_id); 551 op_id = GNUNET_ntohll (msg->operation_id);
@@ -565,52 +571,32 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c,
565 peer = data->peer; 571 peer = data->peer;
566 GNUNET_assert (NULL != peer); 572 GNUNET_assert (NULL != peer);
567 GNUNET_assert (ntohl (msg->peer_id) == peer->unique_id); 573 GNUNET_assert (ntohl (msg->peer_id) == peer->unique_id);
568 if (0 == (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED))) 574 pinfo = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerInformation));
569 { 575 pinfo->pit = data->pit;
570 LOG_DEBUG ("Skipping operation callback as flag not set\n"); 576 cb = data->cb;
571 return GNUNET_YES; 577 cb_cls = data->cb_cls;
572 }
573 response_data = GNUNET_malloc (sizeof (struct PeerInfoData2));
574 response_data->pit = data->pit;
575 GNUNET_free (data); 578 GNUNET_free (data);
576 opc->data = NULL; 579 opc->data = NULL;
577 info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 580 switch (pinfo->pit)
578 info.details.operation_finished.operation = opc->op;
579 info.details.operation_finished.op_cls = NULL;
580 info.details.operation_finished.emsg = NULL;
581 info.details.operation_finished.pit = response_data->pit;
582 switch (response_data->pit)
583 { 581 {
584 case GNUNET_TESTBED_PIT_IDENTITY: 582 case GNUNET_TESTBED_PIT_IDENTITY:
585 { 583 pinfo->result.id = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
586 struct GNUNET_PeerIdentity *peer_identity; 584 (void) memcpy (pinfo->result.id, &msg->peer_identity,
587 585 sizeof (struct GNUNET_PeerIdentity));
588 peer_identity = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
589 (void) memcpy (peer_identity, &msg->peer_identity,
590 sizeof (struct GNUNET_PeerIdentity));
591 response_data->details.peer_identity = peer_identity;
592 info.details.operation_finished.op_result.pid = peer_identity;
593 }
594 break; 586 break;
595 case GNUNET_TESTBED_PIT_CONFIGURATION: 587 case GNUNET_TESTBED_PIT_CONFIGURATION:
596 response_data->details.cfg = /* Freed in oprelease_peer_getinfo */ 588 pinfo->result.cfg = /* Freed in oprelease_peer_getinfo */
597 GNUNET_TESTBED_get_config_from_peerinfo_msg_ (msg); 589 GNUNET_TESTBED_get_config_from_peerinfo_msg_ (msg);
598 info.details.operation_finished.op_result.cfg = response_data->details.cfg;
599 break; 590 break;
600 case GNUNET_TESTBED_PIT_GENERIC: 591 case GNUNET_TESTBED_PIT_GENERIC:
601 GNUNET_assert (0); /* never reach here */ 592 GNUNET_assert (0); /* never reach here */
602 break; 593 break;
603 } 594 }
604 opc->data = response_data; 595 opc->data = pinfo;
605 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); 596 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
606 opc->state = OPC_STATE_FINISHED; 597 opc->state = OPC_STATE_FINISHED;
607 if (0 != 598 if (NULL != cb)
608 ((GNUNET_TESTBED_ET_CONNECT | GNUNET_TESTBED_ET_DISCONNECT) & 599 cb (cb_cls, opc->op, pinfo, NULL);
609 c->event_mask))
610 {
611 if (NULL != c->cc)
612 c->cc (c->cc_cls, &info);
613 }
614 return GNUNET_YES; 600 return GNUNET_YES;
615} 601}
616 602
@@ -676,8 +662,7 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c,
676 event.details.operation_finished.operation = opc->op; 662 event.details.operation_finished.operation = opc->op;
677 event.details.operation_finished.op_cls = NULL; 663 event.details.operation_finished.op_cls = NULL;
678 event.details.operation_finished.emsg = emsg; 664 event.details.operation_finished.emsg = emsg;
679 event.details.operation_finished.pit = GNUNET_TESTBED_PIT_GENERIC; 665 event.details.operation_finished.generic = NULL;
680 event.details.operation_finished.op_result.generic = NULL;
681 c->cc (c->cc_cls, &event); 666 c->cc (c->cc_cls, &event);
682 } 667 }
683 return GNUNET_YES; 668 return GNUNET_YES;