summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-10-04 14:02:44 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-10-04 14:02:44 +0000
commitb96afc0513d3d70a50dc2faa21601ce7cefc1d6f (patch)
treece31c4054d311d11b7372fdc0024add1b97c436e
parent98c7ca502554ae53580d5553070af98c889178fc (diff)
downloadgnunet-b96afc0513d3d70a50dc2faa21601ce7cefc1d6f.tar.gz
gnunet-b96afc0513d3d70a50dc2faa21601ce7cefc1d6f.zip
added operation closure to GNUNET_TESTBED_controller_link()
-rw-r--r--src/include/gnunet_testbed_service.h39
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c6
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c8
-rw-r--r--src/testbed/testbed_api.c225
4 files changed, 174 insertions, 104 deletions
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h
index 04868ed0d..065cd0c0f 100644
--- a/src/include/gnunet_testbed_service.h
+++ b/src/include/gnunet_testbed_service.h
@@ -543,28 +543,37 @@ typedef void (*GNUNET_TESTBED_OperationCompletionCallback) (void *cls,
543 * master controller is asked to start a peer at the delegated controller the 543 * master controller is asked to start a peer at the delegated controller the
544 * request will be routed towards slave controller (if a route exists). The 544 * request will be routed towards slave controller (if a route exists). The
545 * slave controller will then route it to the delegated controller. The 545 * slave controller will then route it to the delegated controller. The
546 * configuration of the slave controller is given and to be used to either 546 * configuration of the delegated controller is given and is used to either
547 * create the slave controller or to connect to an existing slave controller 547 * create the delegated controller or to connect to an existing controller. Note
548 * process. 'is_subordinate' specifies if the given slave controller should be 548 * that while starting the delegated controller the configuration will be
549 * started and managed by the master controller, or if the slave already has a 549 * modified to accommodate available free ports. the 'is_subordinate' specifies
550 * master and this is just a secondary master that is also allowed to use the 550 * if the given delegated controller should be started and managed by the slave
551 * existing slave. 551 * controller, or if the delegated controller already has a master and the slave
552 * controller connects to it as a non master controller. The success or failure
553 * of this operation will be signalled through the
554 * GNUNET_TESTBED_ControllerCallback() with an event of type
555 * GNUNET_TESTBED_ET_OPERATION_FINISHED
552 * 556 *
557 * @param op_cls the operation closure for the event which is generated to
558 * signal success or failure of this operation
553 * @param master handle to the master controller who creates the association 559 * @param master handle to the master controller who creates the association
554 * @param delegated_host requests to which host should be delegated; cannot be NULL 560 * @param delegated_host requests to which host should be delegated; cannot be NULL
555 * @param slave_host which host is used to run the slave controller; use NULL to 561 * @param slave_host which host is used to run the slave controller; use NULL to
556 * make the master controller connect to the delegated host 562 * make the master controller connect to the delegated host
557 * @param slave_cfg configuration to use for the slave controller 563 * @param slave_cfg configuration to use for the slave controller
558 * @param is_subordinate GNUNET_YES if the controller at delegated_host should 564 * @param is_subordinate GNUNET_YES if the controller at delegated_host should
559 * be started by the master controller; GNUNET_NO if we are just 565 * be started by the slave controller; GNUNET_NO if the slave
560 * allowed to use the slave via TCP/IP 566 * controller has to connect to the already started delegated
567 * controller via TCP/IP
561 * @return the operation handle 568 * @return the operation handle
562 */ 569 */
563struct GNUNET_TESTBED_Operation * 570struct GNUNET_TESTBED_Operation *
564GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master, 571GNUNET_TESTBED_controller_link (void *op_cls,
572 struct GNUNET_TESTBED_Controller *master,
565 struct GNUNET_TESTBED_Host *delegated_host, 573 struct GNUNET_TESTBED_Host *delegated_host,
566 struct GNUNET_TESTBED_Host *slave_host, 574 struct GNUNET_TESTBED_Host *slave_host,
567 const struct GNUNET_CONFIGURATION_Handle *slave_cfg, 575 const struct GNUNET_CONFIGURATION_Handle
576 *slave_cfg,
568 int is_subordinate); 577 int is_subordinate);
569 578
570 579
@@ -572,6 +581,8 @@ GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
572 * Same as the GNUNET_TESTBED_controller_link, however expects configuration in 581 * Same as the GNUNET_TESTBED_controller_link, however expects configuration in
573 * serialized and compressed 582 * serialized and compressed
574 * 583 *
584 * @param op_cls the operation closure for the event which is generated to
585 * signal success or failure of this operation
575 * @param master handle to the master controller who creates the association 586 * @param master handle to the master controller who creates the association
576 * @param delegated_host requests to which host should be delegated; cannot be NULL 587 * @param delegated_host requests to which host should be delegated; cannot be NULL
577 * @param slave_host which host is used to run the slave controller; use NULL to 588 * @param slave_host which host is used to run the slave controller; use NULL to
@@ -580,12 +591,14 @@ GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
580 * @param sxcfg_size the size sxcfg 591 * @param sxcfg_size the size sxcfg
581 * @param scfg_size the size of uncompressed serialized configuration 592 * @param scfg_size the size of uncompressed serialized configuration
582 * @param is_subordinate GNUNET_YES if the controller at delegated_host should 593 * @param is_subordinate GNUNET_YES if the controller at delegated_host should
583 * be started by the master controller; GNUNET_NO if we are just 594 * be started by the slave controller; GNUNET_NO if the slave
584 * allowed to use the slave via TCP/IP 595 * controller has to connect to the already started delegated
596 * controller via TCP/IP
585 * @return the operation handle 597 * @return the operation handle
586 */ 598 */
587struct GNUNET_TESTBED_Operation * 599struct GNUNET_TESTBED_Operation *
588GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, 600GNUNET_TESTBED_controller_link_2 (void *op_cls,
601 struct GNUNET_TESTBED_Controller *master,
589 struct GNUNET_TESTBED_Host *delegated_host, 602 struct GNUNET_TESTBED_Host *delegated_host,
590 struct GNUNET_TESTBED_Host *slave_host, 603 struct GNUNET_TESTBED_Host *slave_host,
591 const char *sxcfg, 604 const char *sxcfg,
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c
index fd64d987b..0634bf87e 100644
--- a/src/testbed/test_testbed_api_3peers_3controllers.c
+++ b/src/testbed/test_testbed_api_3peers_3controllers.c
@@ -509,7 +509,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
509 GNUNET_TESTBED_operation_done (common_operation); 509 GNUNET_TESTBED_operation_done (common_operation);
510 result = CONTROLLER_CFG_ACQUIRED; 510 result = CONTROLLER_CFG_ACQUIRED;
511 common_operation = 511 common_operation =
512 GNUNET_TESTBED_controller_link (controller1, neighbour2, neighbour1, 512 GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2, neighbour1,
513 cfg2, GNUNET_NO); 513 cfg2, GNUNET_NO);
514 break; 514 break;
515 case CONTROLLER_CFG_ACQUIRED: 515 case CONTROLLER_CFG_ACQUIRED:
@@ -534,7 +534,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
534 peer1.operation = NULL; 534 peer1.operation = NULL;
535 result = PEER1_STARTED; 535 result = PEER1_STARTED;
536 common_operation = 536 common_operation =
537 GNUNET_TESTBED_controller_link (controller1, neighbour1, NULL, cfg, 537 GNUNET_TESTBED_controller_link (NULL, controller1, neighbour1, NULL, cfg,
538 GNUNET_YES); 538 GNUNET_YES);
539 break; 539 break;
540 case PEER2_CREATED: 540 case PEER2_CREATED:
@@ -545,7 +545,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
545 result = PEER2_STARTED; 545 result = PEER2_STARTED;
546 GNUNET_assert (NULL == common_operation); 546 GNUNET_assert (NULL == common_operation);
547 common_operation = 547 common_operation =
548 GNUNET_TESTBED_controller_link (controller1, neighbour2, NULL, cfg, 548 GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2, NULL, cfg,
549 GNUNET_YES); 549 GNUNET_YES);
550 GNUNET_assert (NULL != common_operation); 550 GNUNET_assert (NULL != common_operation);
551 break; 551 break;
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c
index 2a9add64a..e11de7eab 100644
--- a/src/testbed/test_testbed_api_controllerlink.c
+++ b/src/testbed/test_testbed_api_controllerlink.c
@@ -400,7 +400,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
400 result = SLAVE1_LINK_SUCCESS; 400 result = SLAVE1_LINK_SUCCESS;
401 GNUNET_assert (NULL != slave2); 401 GNUNET_assert (NULL != slave2);
402 GNUNET_assert (NULL != slave); 402 GNUNET_assert (NULL != slave);
403 op = GNUNET_TESTBED_controller_link (mc, slave2, slave, cfg, GNUNET_YES); 403 op = GNUNET_TESTBED_controller_link (NULL, mc, slave2, slave, cfg, GNUNET_YES);
404 GNUNET_assert (NULL != op); 404 GNUNET_assert (NULL != op);
405 break; 405 break;
406 case SLAVE1_LINK_SUCCESS: 406 case SLAVE1_LINK_SUCCESS:
@@ -479,7 +479,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
479 cfg3 = GNUNET_CONFIGURATION_dup (event->details.operation_finished.generic); 479 cfg3 = GNUNET_CONFIGURATION_dup (event->details.operation_finished.generic);
480 GNUNET_TESTBED_operation_done (op); 480 GNUNET_TESTBED_operation_done (op);
481 result = SLAVE3_GET_CONFIG_SUCCESS; 481 result = SLAVE3_GET_CONFIG_SUCCESS;
482 op = GNUNET_TESTBED_controller_link (mc, slave3, slave, cfg3, GNUNET_NO); 482 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, slave, cfg3, GNUNET_NO);
483 break; 483 break;
484 case SLAVE3_GET_CONFIG_SUCCESS: 484 case SLAVE3_GET_CONFIG_SUCCESS:
485 result = SLAVE3_LINK_SUCCESS; 485 result = SLAVE3_LINK_SUCCESS;
@@ -520,7 +520,7 @@ registration_cont (void *cls, const char *emsg)
520 GNUNET_assert (NULL != mc); 520 GNUNET_assert (NULL != mc);
521 result = SLAVE2_REGISTERED; 521 result = SLAVE2_REGISTERED;
522 GNUNET_assert (NULL != cfg); 522 GNUNET_assert (NULL != cfg);
523 op = GNUNET_TESTBED_controller_link (mc, slave, NULL, cfg, GNUNET_YES); 523 op = GNUNET_TESTBED_controller_link (NULL, mc, slave, NULL, cfg, GNUNET_YES);
524 GNUNET_assert (NULL != op); 524 GNUNET_assert (NULL != op);
525 break; 525 break;
526 case SLAVE2_PEER_DESTROY_SUCCESS: 526 case SLAVE2_PEER_DESTROY_SUCCESS:
@@ -528,7 +528,7 @@ registration_cont (void *cls, const char *emsg)
528 GNUNET_assert (NULL != mc); 528 GNUNET_assert (NULL != mc);
529 GNUNET_assert (NULL == op); 529 GNUNET_assert (NULL == op);
530 result = SLAVE3_REGISTERED; 530 result = SLAVE3_REGISTERED;
531 op = GNUNET_TESTBED_controller_link (mc, slave3, NULL, cfg, GNUNET_YES); 531 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, NULL, cfg, GNUNET_YES);
532 GNUNET_assert (NULL != op); 532 GNUNET_assert (NULL != op);
533 break; 533 break;
534 default: 534 default:
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 202ccc58d..953488af1 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -75,6 +75,59 @@
75 75
76 76
77/** 77/**
78 * Handle for controller process
79 */
80struct GNUNET_TESTBED_ControllerProc
81{
82 /**
83 * The process handle
84 */
85 struct GNUNET_HELPER_Handle *helper;
86
87 /**
88 * The host where the helper is run
89 */
90 struct GNUNET_TESTBED_Host *host;
91
92 /**
93 * The controller error callback
94 */
95 GNUNET_TESTBED_ControllerStatusCallback cb;
96
97 /**
98 * The closure for the above callback
99 */
100 void *cls;
101
102 /**
103 * The send handle for the helper
104 */
105 struct GNUNET_HELPER_SendHandle *shandle;
106
107 /**
108 * The message corresponding to send handle
109 */
110 struct GNUNET_MessageHeader *msg;
111
112 /**
113 * The port number for ssh; used for helpers starting ssh
114 */
115 char *port;
116
117 /**
118 * The ssh destination string; used for helpers starting ssh
119 */
120 char *dst;
121
122 /**
123 * The configuration of the running testbed service
124 */
125 struct GNUNET_CONFIGURATION_Handle *cfg;
126
127};
128
129
130/**
78 * The message queue for sending messages to the controller service 131 * The message queue for sending messages to the controller service
79 */ 132 */
80struct MessageQueue 133struct MessageQueue
@@ -200,6 +253,24 @@ struct GetSlaveConfigData
200 253
201 254
202/** 255/**
256 * Context data for controller link operations
257 */
258struct ControllerLinkData
259{
260 /**
261 * The controller link message
262 */
263 struct GNUNET_TESTBED_ControllerLinkMessage *msg;
264
265 /**
266 * The operation closure
267 */
268 void *op_cls;
269
270};
271
272
273/**
203 * Returns the operation context with the given id if found in the Operation 274 * Returns the operation context with the given id if found in the Operation
204 * context queues of the controller 275 * context queues of the controller
205 * 276 *
@@ -324,6 +395,11 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c,
324 LOG_DEBUG ("Operation not found\n"); 395 LOG_DEBUG ("Operation not found\n");
325 return GNUNET_YES; 396 return GNUNET_YES;
326 } 397 }
398 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
399 event.details.operation_finished.operation = opc->op;
400 event.details.operation_finished.op_cls = NULL;
401 event.details.operation_finished.emsg = NULL;
402 event.details.operation_finished.generic = NULL;
327 switch (opc->type) 403 switch (opc->type)
328 { 404 {
329 case OP_FORWARDED: 405 case OP_FORWARDED:
@@ -344,15 +420,19 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c,
344 } 420 }
345 break; 421 break;
346 case OP_LINK_CONTROLLERS: 422 case OP_LINK_CONTROLLERS:
423 {
424 struct ControllerLinkData *data;
425
426 data = opc->data;
427 GNUNET_assert (NULL != data);
428 event.details.operation_finished.op_cls = data->op_cls;
429 GNUNET_free (data);
430 opc->data = NULL;
431 }
347 break; 432 break;
348 default: 433 default:
349 GNUNET_assert (0); 434 GNUNET_assert (0);
350 } 435 }
351 event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
352 event.details.operation_finished.operation = opc->op;
353 event.details.operation_finished.op_cls = NULL;
354 event.details.operation_finished.emsg = NULL;
355 event.details.operation_finished.generic = NULL;
356 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); 436 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
357 opc->state = OPC_STATE_FINISHED; 437 opc->state = OPC_STATE_FINISHED;
358 if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED))) 438 if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED)))
@@ -1032,59 +1112,6 @@ GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc)
1032 1112
1033 1113
1034/** 1114/**
1035 * Handle for controller process
1036 */
1037struct GNUNET_TESTBED_ControllerProc
1038{
1039 /**
1040 * The process handle
1041 */
1042 struct GNUNET_HELPER_Handle *helper;
1043
1044 /**
1045 * The host where the helper is run
1046 */
1047 struct GNUNET_TESTBED_Host *host;
1048
1049 /**
1050 * The controller error callback
1051 */
1052 GNUNET_TESTBED_ControllerStatusCallback cb;
1053
1054 /**
1055 * The closure for the above callback
1056 */
1057 void *cls;
1058
1059 /**
1060 * The send handle for the helper
1061 */
1062 struct GNUNET_HELPER_SendHandle *shandle;
1063
1064 /**
1065 * The message corresponding to send handle
1066 */
1067 struct GNUNET_MessageHeader *msg;
1068
1069 /**
1070 * The port number for ssh; used for helpers starting ssh
1071 */
1072 char *port;
1073
1074 /**
1075 * The ssh destination string; used for helpers starting ssh
1076 */
1077 char *dst;
1078
1079 /**
1080 * The configuration of the running testbed service
1081 */
1082 struct GNUNET_CONFIGURATION_Handle *cfg;
1083
1084};
1085
1086
1087/**
1088 * Functions with this signature are called whenever a 1115 * Functions with this signature are called whenever a
1089 * complete message is received by the tokenizer. 1116 * complete message is received by the tokenizer.
1090 * 1117 *
@@ -1186,11 +1213,13 @@ static void
1186opstart_link_controllers (void *cls) 1213opstart_link_controllers (void *cls)
1187{ 1214{
1188 struct OperationContext *opc = cls; 1215 struct OperationContext *opc = cls;
1216 struct ControllerLinkData *data;
1189 struct GNUNET_TESTBED_ControllerLinkMessage *msg; 1217 struct GNUNET_TESTBED_ControllerLinkMessage *msg;
1190 1218
1191 GNUNET_assert (NULL != opc->data); 1219 GNUNET_assert (NULL != opc->data);
1192 msg = opc->data; 1220 data = opc->data;
1193 opc->data = NULL; 1221 msg = data->msg;
1222 data->msg = NULL;
1194 opc->state = OPC_STATE_STARTED; 1223 opc->state = OPC_STATE_STARTED;
1195 GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc); 1224 GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc);
1196 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); 1225 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
@@ -1206,11 +1235,21 @@ static void
1206oprelease_link_controllers (void *cls) 1235oprelease_link_controllers (void *cls)
1207{ 1236{
1208 struct OperationContext *opc = cls; 1237 struct OperationContext *opc = cls;
1238 struct ControllerLinkData *data;
1209 1239
1210 if (OPC_STATE_INIT == opc->state) 1240 data = opc->data;
1211 GNUNET_free (opc->data); 1241 switch (opc->state)
1212 if (OPC_STATE_STARTED == opc->state) 1242 {
1243 case OPC_STATE_INIT:
1244 GNUNET_free (data->msg);
1245 break;
1246 case OPC_STATE_STARTED:
1213 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); 1247 GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
1248 break;
1249 case OPC_STATE_FINISHED:
1250 break;
1251 }
1252 GNUNET_free_non_null (data);
1214 GNUNET_free (opc); 1253 GNUNET_free (opc);
1215} 1254}
1216 1255
@@ -1660,19 +1699,24 @@ GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle
1660 * Same as the GNUNET_TESTBED_controller_link, however expects configuration in 1699 * Same as the GNUNET_TESTBED_controller_link, however expects configuration in
1661 * serialized and compressed 1700 * serialized and compressed
1662 * 1701 *
1702 * @param op_cls the operation closure for the event which is generated to
1703 * signal success or failure of this operation
1663 * @param master handle to the master controller who creates the association 1704 * @param master handle to the master controller who creates the association
1664 * @param delegated_host requests to which host should be delegated; cannot be NULL 1705 * @param delegated_host requests to which host should be delegated; cannot be NULL
1665 * @param slave_host which host is used to run the slave controller; use NULL to 1706 * @param slave_host which host is used to run the slave controller; use NULL to
1666 * make the master controller connect to the delegated host 1707 * make the master controller connect to the delegated host
1667 * @param sxcfg serialized and compressed configuration 1708 * @param sxcfg serialized and compressed configuration
1668 * @param sxcfg_size the size scfg 1709 * @param sxcfg_size the size sxcfg
1669 * @param scfg_size the size of uncompressed serialized configuration 1710 * @param scfg_size the size of uncompressed serialized configuration
1670 * @param is_subordinate GNUNET_YES if the controller at delegated_host should 1711 * @param is_subordinate GNUNET_YES if the controller at delegated_host should
1671 * be started by the master controller; GNUNET_NO if we are just 1712 * be started by the slave controller; GNUNET_NO if the slave
1672 * allowed to use the slave via TCP/IP 1713 * controller has to connect to the already started delegated
1714 * controller via TCP/IP
1715 * @return the operation handle
1673 */ 1716 */
1674struct GNUNET_TESTBED_Operation * 1717struct GNUNET_TESTBED_Operation *
1675GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, 1718GNUNET_TESTBED_controller_link_2 (void *op_cls,
1719 struct GNUNET_TESTBED_Controller *master,
1676 struct GNUNET_TESTBED_Host *delegated_host, 1720 struct GNUNET_TESTBED_Host *delegated_host,
1677 struct GNUNET_TESTBED_Host *slave_host, 1721 struct GNUNET_TESTBED_Host *slave_host,
1678 const char *sxcfg, size_t sxcfg_size, 1722 const char *sxcfg, size_t sxcfg_size,
@@ -1680,6 +1724,7 @@ GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master,
1680{ 1724{
1681 struct OperationContext *opc; 1725 struct OperationContext *opc;
1682 struct GNUNET_TESTBED_ControllerLinkMessage *msg; 1726 struct GNUNET_TESTBED_ControllerLinkMessage *msg;
1727 struct ControllerLinkData *data;
1683 uint16_t msg_size; 1728 uint16_t msg_size;
1684 1729
1685 GNUNET_assert (GNUNET_YES == 1730 GNUNET_assert (GNUNET_YES ==
@@ -1698,9 +1743,12 @@ GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master,
1698 msg->config_size = htons ((uint16_t) scfg_size); 1743 msg->config_size = htons ((uint16_t) scfg_size);
1699 msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0; 1744 msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
1700 memcpy (&msg[1], sxcfg, sxcfg_size); 1745 memcpy (&msg[1], sxcfg, sxcfg_size);
1746 data = GNUNET_malloc (sizeof (struct ControllerLinkData));
1747 data->msg = msg;
1748 data->op_cls = op_cls;
1701 opc = GNUNET_malloc (sizeof (struct OperationContext)); 1749 opc = GNUNET_malloc (sizeof (struct OperationContext));
1702 opc->c = master; 1750 opc->c = master;
1703 opc->data = msg; 1751 opc->data = data;
1704 opc->type = OP_LINK_CONTROLLERS; 1752 opc->type = OP_LINK_CONTROLLERS;
1705 opc->id = master->operation_counter++; 1753 opc->id = master->operation_counter++;
1706 opc->state = OPC_STATE_INIT; 1754 opc->state = OPC_STATE_INIT;
@@ -1744,24 +1792,33 @@ GNUNET_TESTBED_compress_config_ (const char *config, size_t size,
1744 * master controller is asked to start a peer at the delegated controller the 1792 * master controller is asked to start a peer at the delegated controller the
1745 * request will be routed towards slave controller (if a route exists). The 1793 * request will be routed towards slave controller (if a route exists). The
1746 * slave controller will then route it to the delegated controller. The 1794 * slave controller will then route it to the delegated controller. The
1747 * configuration of the slave controller is given and to be used to either 1795 * configuration of the delegated controller is given and is used to either
1748 * create the slave controller or to connect to an existing slave controller 1796 * create the delegated controller or to connect to an existing controller. Note
1749 * process. 'is_subordinate' specifies if the given slave controller should be 1797 * that while starting the delegated controller the configuration will be
1750 * started and managed by the master controller, or if the slave already has a 1798 * modified to accommodate available free ports. the 'is_subordinate' specifies
1751 * master and this is just a secondary master that is also allowed to use the 1799 * if the given delegated controller should be started and managed by the slave
1752 * existing slave. 1800 * controller, or if the delegated controller already has a master and the slave
1801 * controller connects to it as a non master controller. The success or failure
1802 * of this operation will be signalled through the
1803 * GNUNET_TESTBED_ControllerCallback() with an event of type
1804 * GNUNET_TESTBED_ET_OPERATION_FINISHED
1753 * 1805 *
1806 * @param op_cls the operation closure for the event which is generated to
1807 * signal success or failure of this operation
1754 * @param master handle to the master controller who creates the association 1808 * @param master handle to the master controller who creates the association
1755 * @param delegated_host requests to which host should be delegated 1809 * @param delegated_host requests to which host should be delegated; cannot be NULL
1756 * @param slave_host which host is used to run the slave controller 1810 * @param slave_host which host is used to run the slave controller; use NULL to
1811 * make the master controller connect to the delegated host
1757 * @param slave_cfg configuration to use for the slave controller 1812 * @param slave_cfg configuration to use for the slave controller
1758 * @param is_subordinate GNUNET_YES if the slave should be started (and stopped) 1813 * @param is_subordinate GNUNET_YES if the controller at delegated_host should
1759 * by the master controller; GNUNET_NO if we are just 1814 * be started by the slave controller; GNUNET_NO if the slave
1760 * allowed to use the slave via TCP/IP 1815 * controller has to connect to the already started delegated
1816 * controller via TCP/IP
1761 * @return the operation handle 1817 * @return the operation handle
1762 */ 1818 */
1763struct GNUNET_TESTBED_Operation * 1819struct GNUNET_TESTBED_Operation *
1764GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master, 1820GNUNET_TESTBED_controller_link (void *op_cls,
1821 struct GNUNET_TESTBED_Controller *master,
1765 struct GNUNET_TESTBED_Host *delegated_host, 1822 struct GNUNET_TESTBED_Host *delegated_host,
1766 struct GNUNET_TESTBED_Host *slave_host, 1823 struct GNUNET_TESTBED_Host *slave_host,
1767 const struct GNUNET_CONFIGURATION_Handle 1824 const struct GNUNET_CONFIGURATION_Handle
@@ -1784,9 +1841,9 @@ GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
1784 /* Configuration doesn't fit in 1 message */ 1841 /* Configuration doesn't fit in 1 message */
1785 GNUNET_assert ((UINT16_MAX - 1842 GNUNET_assert ((UINT16_MAX -
1786 sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) >= cc_size); 1843 sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) >= cc_size);
1787 op = GNUNET_TESTBED_controller_link_2 (master, delegated_host, slave_host, 1844 op = GNUNET_TESTBED_controller_link_2 (op_cls, master, delegated_host,
1788 (const char *) cconfig, cc_size, 1845 slave_host, (const char *) cconfig,
1789 config_size, is_subordinate); 1846 cc_size, config_size, is_subordinate);
1790 GNUNET_free (cconfig); 1847 GNUNET_free (cconfig);
1791 return op; 1848 return op;
1792} 1849}