diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-05 10:50:56 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-05 10:50:56 +0000 |
commit | 270a6392703fe1cb99f69ed8a35c1be0c864b11f (patch) | |
tree | 1c65d01fefab939684c58757880987d2a00fd060 /src/include/gnunet_testbed_service.h | |
parent | c09edda8e8071c6e5ca6b76e7c75a7b8402010ed (diff) | |
download | gnunet-270a6392703fe1cb99f69ed8a35c1be0c864b11f.tar.gz gnunet-270a6392703fe1cb99f69ed8a35c1be0c864b11f.zip |
changed testbed API to include convenience callbacks
Diffstat (limited to 'src/include/gnunet_testbed_service.h')
-rw-r--r-- | src/include/gnunet_testbed_service.h | 120 |
1 files changed, 84 insertions, 36 deletions
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h index 1be35c098..249b40752 100644 --- a/src/include/gnunet_testbed_service.h +++ b/src/include/gnunet_testbed_service.h | |||
@@ -309,41 +309,11 @@ struct GNUNET_TESTBED_EventInformation | |||
309 | const char *emsg; | 309 | const char *emsg; |
310 | 310 | ||
311 | /** | 311 | /** |
312 | * Peer information type; captures which of the types | 312 | * No result (NULL pointer) or generic result |
313 | * in the 'op_result' is actually in use. | 313 | * (whatever the GNUNET_TESTBED_ConnectAdapter returned). |
314 | */ | 314 | */ |
315 | enum GNUNET_TESTBED_PeerInformationType pit; | 315 | void *generic; |
316 | 316 | ||
317 | /** | ||
318 | * Pointer to an operation-specific return value; NULL on error; | ||
319 | * can be NULL for certain operations. Valid until | ||
320 | * 'GNUNET_TESTBED_operation_done' is called. | ||
321 | */ | ||
322 | union | ||
323 | { | ||
324 | /** | ||
325 | * No result (NULL pointer) or generic result | ||
326 | * (whatever the GNUNET_TESTBED_ConnectAdapter returned). | ||
327 | */ | ||
328 | void *generic; | ||
329 | |||
330 | /** | ||
331 | * Identity of host running the peer. | ||
332 | */ | ||
333 | struct GNUNET_TESTBED_Host *host; | ||
334 | |||
335 | /** | ||
336 | * Identity of the peer. | ||
337 | */ | ||
338 | const struct GNUNET_PeerIdentity *pid; | ||
339 | |||
340 | /** | ||
341 | * Configuration of the peer. | ||
342 | */ | ||
343 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
344 | |||
345 | } op_result; | ||
346 | |||
347 | } operation_finished; | 317 | } operation_finished; |
348 | 318 | ||
349 | 319 | ||
@@ -555,6 +525,21 @@ GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle | |||
555 | 525 | ||
556 | 526 | ||
557 | /** | 527 | /** |
528 | * Callback to be called when an operation is completed | ||
529 | * | ||
530 | * @param cls the callback closure from functions generating an operation | ||
531 | * @param op the operation that has been finished | ||
532 | * @param emsg error message in case the operation has failed; will be NULL if | ||
533 | * operation has executed successfully. | ||
534 | */ | ||
535 | typedef void (*GNUNET_TESTBED_OperationCompletionCallback) (void *cls, | ||
536 | struct | ||
537 | GNUNET_TESTBED_Operation | ||
538 | *op, | ||
539 | const char *emsg); | ||
540 | |||
541 | |||
542 | /** | ||
558 | * Create a link from slave controller to delegated controller. Whenever the | 543 | * Create a link from slave controller to delegated controller. Whenever the |
559 | * master controller is asked to start a peer at the delegated controller the | 544 | * master controller is asked to start a peer at the delegated controller the |
560 | * request will be routed towards slave controller (if a route exists). The | 545 | * request will be routed towards slave controller (if a route exists). The |
@@ -684,15 +669,70 @@ GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer); | |||
684 | 669 | ||
685 | 670 | ||
686 | /** | 671 | /** |
687 | * Request information about a peer. | 672 | * Data returned from GNUNET_TESTBED_peer_get_information |
673 | */ | ||
674 | struct GNUNET_TESTBED_PeerInformation | ||
675 | { | ||
676 | /** | ||
677 | * Peer information type; captures which of the types | ||
678 | * in the 'op_result' is actually in use. | ||
679 | */ | ||
680 | enum GNUNET_TESTBED_PeerInformationType pit; | ||
681 | |||
682 | /** | ||
683 | * The result of the get information operation; Choose according to the pit | ||
684 | */ | ||
685 | union | ||
686 | { | ||
687 | /** | ||
688 | * The configuration of the peer | ||
689 | */ | ||
690 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
691 | |||
692 | /** | ||
693 | * The identity of the peer | ||
694 | */ | ||
695 | struct GNUNET_PeerIdentity *id; | ||
696 | } result; | ||
697 | }; | ||
698 | |||
699 | |||
700 | /** | ||
701 | * Callback to be called when the requested peer information is available | ||
702 | * | ||
703 | * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information() | ||
704 | * @param op the operation this callback corresponds to | ||
705 | * @param pinfo the result; will be NULL if the operation has failed | ||
706 | * @param emsg error message if the operation has failed; will be NULL if the | ||
707 | * operation is successfull | ||
708 | */ | ||
709 | typedef void (*GNUNET_TESTBED_PeerInfoCallback) (void *cb_cls, | ||
710 | struct GNUNET_TESTBED_Operation | ||
711 | *op, | ||
712 | const struct | ||
713 | GNUNET_TESTBED_PeerInformation | ||
714 | *pinfo, | ||
715 | const char *emsg); | ||
716 | |||
717 | |||
718 | /** | ||
719 | * Request information about a peer. The controller callback will be called with | ||
720 | * event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this | ||
721 | * operation is available | ||
688 | * | 722 | * |
689 | * @param peer peer to request information about | 723 | * @param peer peer to request information about |
690 | * @param pit desired information | 724 | * @param pit desired information |
725 | * @param cb the convenience callback to be called when results for this | ||
726 | * operation are available | ||
727 | * @param cb_cls the closure for the above callback | ||
691 | * @return handle to the operation | 728 | * @return handle to the operation |
692 | */ | 729 | */ |
693 | struct GNUNET_TESTBED_Operation * | 730 | struct GNUNET_TESTBED_Operation * |
694 | GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, | 731 | GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, |
695 | enum GNUNET_TESTBED_PeerInformationType pit); | 732 | enum GNUNET_TESTBED_PeerInformationType |
733 | pit, | ||
734 | GNUNET_TESTBED_PeerInfoCallback cb, | ||
735 | void *cb_cls); | ||
696 | 736 | ||
697 | 737 | ||
698 | /** | 738 | /** |
@@ -901,6 +941,8 @@ GNUNET_TESTBED_underlay_configure_topology (void *op_cls, | |||
901 | * and asks 'p2' to connect to 'p1'. | 941 | * and asks 'p2' to connect to 'p1'. |
902 | * | 942 | * |
903 | * @param op_cls closure argument to give with the operation event | 943 | * @param op_cls closure argument to give with the operation event |
944 | * @param cb the callback to call when this operation has finished | ||
945 | * @param cb_cls the closure for the above callback | ||
904 | * @param p1 first peer | 946 | * @param p1 first peer |
905 | * @param p2 second peer | 947 | * @param p2 second peer |
906 | * @return handle to the operation, NULL if connecting these two | 948 | * @return handle to the operation, NULL if connecting these two |
@@ -909,6 +951,8 @@ GNUNET_TESTBED_underlay_configure_topology (void *op_cls, | |||
909 | */ | 951 | */ |
910 | struct GNUNET_TESTBED_Operation * | 952 | struct GNUNET_TESTBED_Operation * |
911 | GNUNET_TESTBED_overlay_connect (void *op_cls, | 953 | GNUNET_TESTBED_overlay_connect (void *op_cls, |
954 | GNUNET_TESTBED_OperationCompletionCallback cb, | ||
955 | void *cb_cls, | ||
912 | struct GNUNET_TESTBED_Peer *p1, | 956 | struct GNUNET_TESTBED_Peer *p1, |
913 | struct GNUNET_TESTBED_Peer *p2); | 957 | struct GNUNET_TESTBED_Peer *p2); |
914 | 958 | ||
@@ -1010,6 +1054,8 @@ typedef void (*GNUNET_TESTBED_DisconnectAdapter)(void *cls, | |||
1010 | * @param op_cls closure to pass in operation event | 1054 | * @param op_cls closure to pass in operation event |
1011 | * @param peer peer that runs the service | 1055 | * @param peer peer that runs the service |
1012 | * @param service_name name of the service to connect to | 1056 | * @param service_name name of the service to connect to |
1057 | * @param cb the callback to call when this operation finishes | ||
1058 | * @param cb_cls closure for the above callback | ||
1013 | * @param ca helper function to establish the connection | 1059 | * @param ca helper function to establish the connection |
1014 | * @param da helper function to close the connection | 1060 | * @param da helper function to close the connection |
1015 | * @param cada_cls closure for ca and da | 1061 | * @param cada_cls closure for ca and da |
@@ -1019,6 +1065,8 @@ struct GNUNET_TESTBED_Operation * | |||
1019 | GNUNET_TESTBED_service_connect (void *op_cls, | 1065 | GNUNET_TESTBED_service_connect (void *op_cls, |
1020 | struct GNUNET_TESTBED_Peer *peer, | 1066 | struct GNUNET_TESTBED_Peer *peer, |
1021 | const char *service_name, | 1067 | const char *service_name, |
1068 | GNUNET_TESTBED_OperationCompletionCallback cb, | ||
1069 | void *cb_cls, | ||
1022 | GNUNET_TESTBED_ConnectAdapter ca, | 1070 | GNUNET_TESTBED_ConnectAdapter ca, |
1023 | GNUNET_TESTBED_DisconnectAdapter da, | 1071 | GNUNET_TESTBED_DisconnectAdapter da, |
1024 | void *cada_cls); | 1072 | void *cada_cls); |