aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_testbed.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-09-06 14:38:24 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-09-06 14:38:24 +0000
commit2ca4b8a208f6f910c819bbaa6785a25ae2955501 (patch)
tree7328fb7cfc62189197dfa34035502a80b0acdcd3 /src/testbed/testbed_api_testbed.c
parent8d46a214ce11653b5160d32e330786fa487e3ae6 (diff)
downloadgnunet-2ca4b8a208f6f910c819bbaa6785a25ae2955501.tar.gz
gnunet-2ca4b8a208f6f910c819bbaa6785a25ae2955501.zip
- give out run handle through which master controller's handle can be retrieved
Diffstat (limited to 'src/testbed/testbed_api_testbed.c')
-rw-r--r--src/testbed/testbed_api_testbed.c62
1 files changed, 29 insertions, 33 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index 3da5f9058..b00e2825c 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -50,10 +50,6 @@
50 */ 50 */
51#define DEFAULT_SETUP_TIMEOUT 300 51#define DEFAULT_SETUP_TIMEOUT 300
52 52
53/**
54 * Testbed Run Handle
55 */
56struct RunContext;
57 53
58/** 54/**
59 * Context information for the operation we start 55 * Context information for the operation we start
@@ -68,7 +64,7 @@ struct RunContextOperation
68 /** 64 /**
69 * Context information for GNUNET_TESTBED_run() 65 * Context information for GNUNET_TESTBED_run()
70 */ 66 */
71 struct RunContext *rc; 67 struct GNUNET_TESTBED_RunHandle *rc;
72 68
73 /** 69 /**
74 * Closure 70 * Closure
@@ -130,7 +126,7 @@ struct CompatibilityCheckContext
130 /** 126 /**
131 * The run context 127 * The run context
132 */ 128 */
133 struct RunContext *rc; 129 struct GNUNET_TESTBED_RunHandle *rc;
134 130
135 /** 131 /**
136 * Handle for the compability check 132 * Handle for the compability check
@@ -147,7 +143,7 @@ struct CompatibilityCheckContext
147/** 143/**
148 * Testbed Run Handle 144 * Testbed Run Handle
149 */ 145 */
150struct RunContext 146struct GNUNET_TESTBED_RunHandle
151{ 147{
152 /** 148 /**
153 * The controller handle 149 * The controller handle
@@ -381,7 +377,7 @@ search_iterator (void *cls, uint32_t key, void *value)
381 * @return the matching RunContextOperation if found; NULL if not 377 * @return the matching RunContextOperation if found; NULL if not
382 */ 378 */
383static struct RunContextOperation * 379static struct RunContextOperation *
384search_rcop (struct RunContext *rc, struct GNUNET_TESTBED_Operation *op) 380search_rcop (struct GNUNET_TESTBED_RunHandle *rc, struct GNUNET_TESTBED_Operation *op)
385{ 381{
386 struct SearchContext sc; 382 struct SearchContext sc;
387 383
@@ -407,7 +403,7 @@ search_rcop (struct RunContext *rc, struct GNUNET_TESTBED_Operation *op)
407 * @param rcop the RunContextOperation to insert 403 * @param rcop the RunContextOperation to insert
408 */ 404 */
409static void 405static void
410insert_rcop (struct RunContext *rc, struct RunContextOperation *rcop) 406insert_rcop (struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
411{ 407{
412 GNUNET_assert (GNUNET_OK == 408 GNUNET_assert (GNUNET_OK ==
413 GNUNET_CONTAINER_multihashmap32_put (rc->rcop_map, 409 GNUNET_CONTAINER_multihashmap32_put (rc->rcop_map,
@@ -424,7 +420,7 @@ insert_rcop (struct RunContext *rc, struct RunContextOperation *rcop)
424 * @param rcop the RunContextOperation 420 * @param rcop the RunContextOperation
425 */ 421 */
426static void 422static void
427remove_rcop (struct RunContext *rc, struct RunContextOperation *rcop) 423remove_rcop (struct GNUNET_TESTBED_RunHandle *rc, struct RunContextOperation *rcop)
428{ 424{
429 GNUNET_assert (GNUNET_YES == 425 GNUNET_assert (GNUNET_YES ==
430 GNUNET_CONTAINER_multihashmap32_remove (rc->rcop_map, 426 GNUNET_CONTAINER_multihashmap32_remove (rc->rcop_map,
@@ -440,7 +436,7 @@ remove_rcop (struct RunContext *rc, struct RunContextOperation *rcop)
440static void 436static void
441cleanup (void *cls) 437cleanup (void *cls)
442{ 438{
443 struct RunContext *rc = cls; 439 struct GNUNET_TESTBED_RunHandle *rc = cls;
444 unsigned int hid; 440 unsigned int hid;
445 441
446 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rc->register_hosts_task); 442 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rc->register_hosts_task);
@@ -478,7 +474,7 @@ cleanup (void *cls)
478static int 474static int
479rcop_cleanup_iterator (void *cls, uint32_t key, void *value) 475rcop_cleanup_iterator (void *cls, uint32_t key, void *value)
480{ 476{
481 struct RunContext *rc = cls; 477 struct GNUNET_TESTBED_RunHandle *rc = cls;
482 struct RunContextOperation *rcop = value; 478 struct RunContextOperation *rcop = value;
483 479
484 GNUNET_assert (rc == rcop->rc); 480 GNUNET_assert (rc == rcop->rc);
@@ -495,7 +491,7 @@ rcop_cleanup_iterator (void *cls, uint32_t key, void *value)
495 * @param rc the RunContext 491 * @param rc the RunContext
496 */ 492 */
497static void 493static void
498rc_cleanup_operations (struct RunContext *rc) 494rc_cleanup_operations (struct GNUNET_TESTBED_RunHandle *rc)
499{ 495{
500 struct CompatibilityCheckContext *hc; 496 struct CompatibilityCheckContext *hc;
501 unsigned int nhost; 497 unsigned int nhost;
@@ -546,7 +542,7 @@ rc_cleanup_operations (struct RunContext *rc)
546 * @param rc the run context 542 * @param rc the run context
547 */ 543 */
548static void 544static void
549cancel_interrupt_task (struct RunContext *rc) 545cancel_interrupt_task (struct GNUNET_TESTBED_RunHandle *rc)
550{ 546{
551 GNUNET_SCHEDULER_cancel (rc->interrupt_task); 547 GNUNET_SCHEDULER_cancel (rc->interrupt_task);
552 rc->interrupt_task = GNUNET_SCHEDULER_NO_TASK; 548 rc->interrupt_task = GNUNET_SCHEDULER_NO_TASK;
@@ -562,7 +558,7 @@ cancel_interrupt_task (struct RunContext *rc)
562static void 558static void
563wait_op_completion (void *cls) 559wait_op_completion (void *cls)
564{ 560{
565 struct RunContext *rc = cls; 561 struct GNUNET_TESTBED_RunHandle *rc = cls;
566 struct RunContextOperation *rcop; 562 struct RunContextOperation *rcop;
567 563
568 if ( (NULL == rc->cproc) 564 if ( (NULL == rc->cproc)
@@ -604,7 +600,7 @@ wait_op_completion (void *cls)
604static void 600static void
605interrupt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 601interrupt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
606{ 602{
607 struct RunContext *rc = cls; 603 struct GNUNET_TESTBED_RunHandle *rc = cls;
608 struct GNUNET_TESTBED_Controller *c = rc->c; 604 struct GNUNET_TESTBED_Controller *c = rc->c;
609 unsigned int size; 605 unsigned int size;
610 606
@@ -634,7 +630,7 @@ interrupt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
634 * @return the representation string; this is NOT reentrant 630 * @return the representation string; this is NOT reentrant
635 */ 631 */
636static const char * 632static const char *
637prof_time (struct RunContext *rc) 633prof_time (struct GNUNET_TESTBED_RunHandle *rc)
638{ 634{
639 struct GNUNET_TIME_Relative ptime; 635 struct GNUNET_TIME_Relative ptime;
640 636
@@ -652,7 +648,7 @@ prof_time (struct RunContext *rc)
652static void 648static void
653start_peers_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 649start_peers_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
654{ 650{
655 struct RunContext *rc = cls; 651 struct GNUNET_TESTBED_RunHandle *rc = cls;
656 struct RunContextOperation *rcop; 652 struct RunContextOperation *rcop;
657 unsigned int peer; 653 unsigned int peer;
658 654
@@ -684,7 +680,7 @@ static void
684peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) 680peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
685{ 681{
686 struct RunContextOperation *rcop = cls; 682 struct RunContextOperation *rcop = cls;
687 struct RunContext *rc; 683 struct GNUNET_TESTBED_RunHandle *rc;
688 684
689 GNUNET_assert (NULL != rcop); 685 GNUNET_assert (NULL != rcop);
690 GNUNET_assert (NULL != (rc = rcop->rc)); 686 GNUNET_assert (NULL != (rc = rcop->rc));
@@ -715,12 +711,12 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
715 * @param rc the RunContext 711 * @param rc the RunContext
716 */ 712 */
717static void 713static void
718call_master (struct RunContext *rc) 714call_master (struct GNUNET_TESTBED_RunHandle *rc)
719{ 715{
720 GNUNET_SCHEDULER_cancel (rc->timeout_task); 716 GNUNET_SCHEDULER_cancel (rc->timeout_task);
721 rc->timeout_task = GNUNET_SCHEDULER_NO_TASK; 717 rc->timeout_task = GNUNET_SCHEDULER_NO_TASK;
722 if (NULL != rc->test_master) 718 if (NULL != rc->test_master)
723 rc->test_master (rc->test_master_cls, rc->num_peers, rc->peers, 719 rc->test_master (rc->test_master_cls, rc, rc->num_peers, rc->peers,
724 rc->links_succeeded, rc->links_failed); 720 rc->links_succeeded, rc->links_failed);
725} 721}
726 722
@@ -738,7 +734,7 @@ static void
738topology_completion_callback (void *cls, unsigned int nsuccess, 734topology_completion_callback (void *cls, unsigned int nsuccess,
739 unsigned int nfailures) 735 unsigned int nfailures)
740{ 736{
741 struct RunContext *rc = cls; 737 struct GNUNET_TESTBED_RunHandle *rc = cls;
742 738
743 DEBUG ("Overlay topology generated in %s\n", prof_time (rc)); 739 DEBUG ("Overlay topology generated in %s\n", prof_time (rc));
744 GNUNET_TESTBED_operation_done (rc->topology_operation); 740 GNUNET_TESTBED_operation_done (rc->topology_operation);
@@ -756,7 +752,7 @@ topology_completion_callback (void *cls, unsigned int nsuccess,
756 * @param rc the RunContext 752 * @param rc the RunContext
757 */ 753 */
758static void 754static void
759create_peers (struct RunContext *rc) 755create_peers (struct GNUNET_TESTBED_RunHandle *rc)
760{ 756{
761 struct RunContextOperation *rcop; 757 struct RunContextOperation *rcop;
762 unsigned int peer; 758 unsigned int peer;
@@ -793,7 +789,7 @@ create_peers (struct RunContext *rc)
793static void 789static void
794event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) 790event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
795{ 791{
796 struct RunContext *rc = cls; 792 struct GNUNET_TESTBED_RunHandle *rc = cls;
797 struct RunContextOperation *rcop; 793 struct RunContextOperation *rcop;
798 794
799 if (RC_INIT == rc->state) 795 if (RC_INIT == rc->state)
@@ -940,7 +936,7 @@ register_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
940static void 936static void
941host_registration_completion (void *cls, const char *emsg) 937host_registration_completion (void *cls, const char *emsg)
942{ 938{
943 struct RunContext *rc = cls; 939 struct GNUNET_TESTBED_RunHandle *rc = cls;
944 940
945 rc->reg_handle = NULL; 941 rc->reg_handle = NULL;
946 if (NULL != emsg) 942 if (NULL != emsg)
@@ -963,7 +959,7 @@ host_registration_completion (void *cls, const char *emsg)
963static void 959static void
964register_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 960register_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
965{ 961{
966 struct RunContext *rc = cls; 962 struct GNUNET_TESTBED_RunHandle *rc = cls;
967 struct RunContextOperation *rcop; 963 struct RunContextOperation *rcop;
968 unsigned int slave; 964 unsigned int slave;
969 965
@@ -1005,7 +1001,7 @@ static void
1005controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, 1001controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
1006 int status) 1002 int status)
1007{ 1003{
1008 struct RunContext *rc = cls; 1004 struct GNUNET_TESTBED_RunHandle *rc = cls;
1009 uint64_t event_mask; 1005 uint64_t event_mask;
1010 1006
1011 if (status != GNUNET_OK) 1007 if (status != GNUNET_OK)
@@ -1052,7 +1048,7 @@ netint_proc (void *cls, const char *name, int isDefault,
1052 const struct sockaddr *addr, const struct sockaddr *broadcast_addr, 1048 const struct sockaddr *addr, const struct sockaddr *broadcast_addr,
1053 const struct sockaddr *netmask, socklen_t addrlen) 1049 const struct sockaddr *netmask, socklen_t addrlen)
1054{ 1050{
1055 struct RunContext *rc = cls; 1051 struct GNUNET_TESTBED_RunHandle *rc = cls;
1056 char hostip[NI_MAXHOST]; 1052 char hostip[NI_MAXHOST];
1057 char *buf; 1053 char *buf;
1058 1054
@@ -1088,7 +1084,7 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host,
1088 int status) 1084 int status)
1089{ 1085{
1090 struct CompatibilityCheckContext *hc = cls; 1086 struct CompatibilityCheckContext *hc = cls;
1091 struct RunContext *rc; 1087 struct GNUNET_TESTBED_RunHandle *rc;
1092 struct GNUNET_TESTBED_Host **old_hosts; 1088 struct GNUNET_TESTBED_Host **old_hosts;
1093 unsigned int nhost; 1089 unsigned int nhost;
1094 1090
@@ -1157,13 +1153,13 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host,
1157static void 1153static void
1158timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1154timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1159{ 1155{
1160 struct RunContext *rc = cls; 1156 struct GNUNET_TESTBED_RunHandle *rc = cls;
1161 1157
1162 rc->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1158 rc->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1163 LOG (GNUNET_ERROR_TYPE_ERROR, _("Shutting down testbed due to timeout while setup.\n")); 1159 LOG (GNUNET_ERROR_TYPE_ERROR, _("Shutting down testbed due to timeout while setup.\n"));
1164 GNUNET_SCHEDULER_shutdown (); 1160 GNUNET_SCHEDULER_shutdown ();
1165 if (NULL != rc->test_master) 1161 if (NULL != rc->test_master)
1166 rc->test_master (rc->test_master_cls, 0, NULL, 0, 0); 1162 rc->test_master (rc->test_master_cls, rc, 0, NULL, 0, 0);
1167 rc->test_master = NULL; 1163 rc->test_master = NULL;
1168} 1164}
1169 1165
@@ -1203,7 +1199,7 @@ GNUNET_TESTBED_run (const char *host_filename,
1203 GNUNET_TESTBED_TestMaster test_master, 1199 GNUNET_TESTBED_TestMaster test_master,
1204 void *test_master_cls) 1200 void *test_master_cls)
1205{ 1201{
1206 struct RunContext *rc; 1202 struct GNUNET_TESTBED_RunHandle *rc;
1207 char *topology; 1203 char *topology;
1208 struct CompatibilityCheckContext *hc; 1204 struct CompatibilityCheckContext *hc;
1209 struct GNUNET_TIME_Relative timeout; 1205 struct GNUNET_TIME_Relative timeout;
@@ -1212,7 +1208,7 @@ GNUNET_TESTBED_run (const char *host_filename,
1212 unsigned int nhost; 1208 unsigned int nhost;
1213 1209
1214 GNUNET_assert (num_peers > 0); 1210 GNUNET_assert (num_peers > 0);
1215 rc = GNUNET_malloc (sizeof (struct RunContext)); 1211 rc = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_RunHandle));
1216 rc->cfg = GNUNET_CONFIGURATION_dup (cfg); 1212 rc->cfg = GNUNET_CONFIGURATION_dup (cfg);
1217#if ENABLE_LL 1213#if ENABLE_LL
1218 rc->num_hosts = GNUNET_TESTBED_hosts_load_from_loadleveler (rc->cfg, 1214 rc->num_hosts = GNUNET_TESTBED_hosts_load_from_loadleveler (rc->cfg,