summaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_peers.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-09-05 10:50:56 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-09-05 10:50:56 +0000
commit270a6392703fe1cb99f69ed8a35c1be0c864b11f (patch)
tree1c65d01fefab939684c58757880987d2a00fd060 /src/testbed/testbed_api_peers.c
parentc09edda8e8071c6e5ca6b76e7c75a7b8402010ed (diff)
downloadgnunet-270a6392703fe1cb99f69ed8a35c1be0c864b11f.tar.gz
gnunet-270a6392703fe1cb99f69ed8a35c1be0c864b11f.zip
changed testbed API to include convenience callbacks
Diffstat (limited to 'src/testbed/testbed_api_peers.c')
-rw-r--r--src/testbed/testbed_api_peers.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c
index 9ced75973..9465c66bb 100644
--- a/src/testbed/testbed_api_peers.c
+++ b/src/testbed/testbed_api_peers.c
@@ -279,7 +279,7 @@ static void
279oprelease_peer_getinfo (void *cls) 279oprelease_peer_getinfo (void *cls)
280{ 280{
281 struct OperationContext *opc = cls; 281 struct OperationContext *opc = cls;
282 struct PeerInfoData2 *data; 282 struct GNUNET_TESTBED_PeerInformation *data;
283 283
284 if (OPC_STATE_FINISHED != opc->state) 284 if (OPC_STATE_FINISHED != opc->state)
285 { 285 {
@@ -293,10 +293,10 @@ oprelease_peer_getinfo (void *cls)
293 switch (data->pit) 293 switch (data->pit)
294 { 294 {
295 case GNUNET_TESTBED_PIT_CONFIGURATION: 295 case GNUNET_TESTBED_PIT_CONFIGURATION:
296 GNUNET_CONFIGURATION_destroy (data->details.cfg); 296 GNUNET_CONFIGURATION_destroy (data->result.cfg);
297 break; 297 break;
298 case GNUNET_TESTBED_PIT_IDENTITY: 298 case GNUNET_TESTBED_PIT_IDENTITY:
299 GNUNET_free (data->details.peer_identity); 299 GNUNET_free (data->result.id);
300 break; 300 break;
301 default: 301 default:
302 GNUNET_assert (0); /* We should never reach here */ 302 GNUNET_assert (0); /* We should never reach here */
@@ -532,16 +532,23 @@ GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer)
532 532
533 533
534/** 534/**
535 * Request information about a peer. 535 * Request information about a peer. The controller callback will be called with
536 * event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this
537 * operation is available
536 * 538 *
537 * @param peer peer to request information about 539 * @param peer peer to request information about
538 * @param pit desired information 540 * @param pit desired information
541 * @param cb the convenience callback to be called when results for this
542 * operation are available
543 * @param cb_cls the closure for the above callback
539 * @return handle to the operation 544 * @return handle to the operation
540 */ 545 */
541struct GNUNET_TESTBED_Operation * 546struct GNUNET_TESTBED_Operation *
542GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, 547GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
543 enum GNUNET_TESTBED_PeerInformationType 548 enum GNUNET_TESTBED_PeerInformationType
544 pit) 549 pit,
550 GNUNET_TESTBED_PeerInfoCallback cb,
551 void *cb_cls)
545{ 552{
546 struct OperationContext *opc; 553 struct OperationContext *opc;
547 struct PeerInfoData *data; 554 struct PeerInfoData *data;
@@ -550,6 +557,8 @@ GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
550 data = GNUNET_malloc (sizeof (struct PeerInfoData)); 557 data = GNUNET_malloc (sizeof (struct PeerInfoData));
551 data->peer = peer; 558 data->peer = peer;
552 data->pit = pit; 559 data->pit = pit;
560 data->cb = cb;
561 data->cb_cls = cb_cls;
553 opc = GNUNET_malloc (sizeof (struct OperationContext)); 562 opc = GNUNET_malloc (sizeof (struct OperationContext));
554 opc->c = peer->controller; 563 opc->c = peer->controller;
555 opc->data = data; 564 opc->data = data;
@@ -635,13 +644,14 @@ GNUNET_TESTBED_underlay_configure_link (void *op_cls,
635} 644}
636 645
637 646
638
639/** 647/**
640 * Both peers must have been started before calling this function. 648 * Both peers must have been started before calling this function.
641 * This function then obtains a HELLO from 'p1', gives it to 'p2' 649 * This function then obtains a HELLO from 'p1', gives it to 'p2'
642 * and asks 'p2' to connect to 'p1'. 650 * and asks 'p2' to connect to 'p1'.
643 * 651 *
644 * @param op_cls closure argument to give with the operation event 652 * @param op_cls closure argument to give with the operation event
653 * @param cb the callback to call when this operation has finished
654 * @param cb_cls the closure for the above callback
645 * @param p1 first peer 655 * @param p1 first peer
646 * @param p2 second peer 656 * @param p2 second peer
647 * @return handle to the operation, NULL if connecting these two 657 * @return handle to the operation, NULL if connecting these two
@@ -649,8 +659,11 @@ GNUNET_TESTBED_underlay_configure_link (void *op_cls,
649 * not running or underlay disallows) 659 * not running or underlay disallows)
650 */ 660 */
651struct GNUNET_TESTBED_Operation * 661struct GNUNET_TESTBED_Operation *
652GNUNET_TESTBED_overlay_connect (void *op_cls, struct GNUNET_TESTBED_Peer *p1, 662GNUNET_TESTBED_overlay_connect (void *op_cls,
653 struct GNUNET_TESTBED_Peer *p2) 663 GNUNET_TESTBED_OperationCompletionCallback cb,
664 void *cb_cls,
665 struct GNUNET_TESTBED_Peer *p1,
666 struct GNUNET_TESTBED_Peer *p2)
654{ 667{
655 struct OperationContext *opc; 668 struct OperationContext *opc;
656 struct OverlayConnectData *data; 669 struct OverlayConnectData *data;
@@ -660,6 +673,8 @@ GNUNET_TESTBED_overlay_connect (void *op_cls, struct GNUNET_TESTBED_Peer *p1,
660 data = GNUNET_malloc (sizeof (struct OverlayConnectData)); 673 data = GNUNET_malloc (sizeof (struct OverlayConnectData));
661 data->p1 = p1; 674 data->p1 = p1;
662 data->p2 = p2; 675 data->p2 = p2;
676 data->cb = cb;
677 data->cb_cls = cb_cls;
663 opc = GNUNET_malloc (sizeof (struct OperationContext)); 678 opc = GNUNET_malloc (sizeof (struct OperationContext));
664 opc->data = data; 679 opc->data = data;
665 opc->c = p1->controller; 680 opc->c = p1->controller;