diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-02-21 17:06:37 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-02-21 17:06:37 +0000 |
commit | d0d8c2ef267acbf339f27cb2277ed49beeb0afbb (patch) | |
tree | 713b74f9564b49f7f3f07ddc75eff1a5e713881f | |
parent | 9736f59357b31df37940cad1c4604d23ea0b9020 (diff) | |
download | gnunet-d0d8c2ef267acbf339f27cb2277ed49beeb0afbb.tar.gz gnunet-d0d8c2ef267acbf339f27cb2277ed49beeb0afbb.zip |
send configurations of newly started slave controllers as part of controller link operations
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 91 | ||||
-rw-r--r-- | src/testbed/gnunet-service-testbed.h | 2 | ||||
-rw-r--r-- | src/testbed/testbed.h | 38 | ||||
-rw-r--r-- | src/testbed/testbed_api.c | 161 | ||||
-rw-r--r-- | src/testbed/testbed_api.h | 14 | ||||
-rw-r--r-- | src/testbed/testbed_api_hosts.c | 15 | ||||
-rw-r--r-- | src/testbed/testbed_api_hosts.h | 11 |
7 files changed, 302 insertions, 30 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index c9cfd87b0..ff7580f26 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -475,7 +475,61 @@ send_operation_success_msg (struct GNUNET_SERVER_Client *client, | |||
475 | 475 | ||
476 | 476 | ||
477 | /** | 477 | /** |
478 | * Callback which will be called to after a host registration succeeded or failed | 478 | * Function to send a failure reponse for controller link operation |
479 | * | ||
480 | * @param client the client to send the message to | ||
481 | * @param operation_id the operation ID of the controller link request | ||
482 | * @param cfg the configuration with which the delegated controller is started. | ||
483 | * Can be NULL if the delegated controller is not started but just | ||
484 | * linked to. | ||
485 | * @param emsg set to an error message explaining why the controller link | ||
486 | * failed. Setting this to NULL signifies success. !This should be | ||
487 | * NULL if cfg is set! | ||
488 | */ | ||
489 | static void | ||
490 | send_controller_link_response (struct GNUNET_SERVER_Client *client, | ||
491 | uint64_t operation_id, | ||
492 | const struct GNUNET_CONFIGURATION_Handle | ||
493 | *cfg, | ||
494 | const char *emsg) | ||
495 | { | ||
496 | struct GNUNET_TESTBED_ControllerLinkResponse *msg; | ||
497 | char *xconfig; | ||
498 | size_t config_size; | ||
499 | size_t xconfig_size; | ||
500 | uint16_t msize; | ||
501 | |||
502 | GNUNET_assert ((NULL == cfg) || (NULL == emsg)); | ||
503 | xconfig = NULL; | ||
504 | xconfig_size = 0; | ||
505 | config_size = 0; | ||
506 | msize = sizeof (struct GNUNET_TESTBED_ControllerLinkResponse); | ||
507 | if (NULL != cfg) | ||
508 | { | ||
509 | xconfig = GNUNET_TESTBED_compress_cfg_ (cfg, | ||
510 | &config_size, | ||
511 | &xconfig_size); | ||
512 | msize += xconfig_size; | ||
513 | } | ||
514 | if (NULL != emsg) | ||
515 | msize += strlen (emsg); | ||
516 | msg = GNUNET_malloc (msize); | ||
517 | msg->header.type = htons | ||
518 | (GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT); | ||
519 | msg->header.size = htons (msize); | ||
520 | if (NULL == emsg) | ||
521 | msg->success = htons (GNUNET_YES); | ||
522 | msg->operation_id = GNUNET_htonll (operation_id); | ||
523 | msg->config_size = htons ((uint16_t) config_size); | ||
524 | if (NULL != xconfig) | ||
525 | memcpy (&msg[1], xconfig, xconfig_size); | ||
526 | if (NULL != emsg) | ||
527 | memcpy (&msg[1], emsg, strlen (emsg)); | ||
528 | GST_queue_message (client, &msg->header); | ||
529 | } | ||
530 | |||
531 | /** | ||
532 | * Callback which will be called after a host registration succeeded or failed | ||
479 | * | 533 | * |
480 | * @param cls the handle to the slave at which the registration is completed | 534 | * @param cls the handle to the slave at which the registration is completed |
481 | * @param emsg the error message; NULL if host registration is successful | 535 | * @param emsg the error message; NULL if host registration is successful |
@@ -704,10 +758,18 @@ lcf_forwarded_operation_timeout (void *cls, | |||
704 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 758 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
705 | { | 759 | { |
706 | struct LCFContext *lcf = cls; | 760 | struct LCFContext *lcf = cls; |
761 | struct ForwardedOperationContext *fopc = lcf->fopc; | ||
707 | 762 | ||
708 | GNUNET_assert (NULL != lcf->fopc); | 763 | GNUNET_assert (NULL != lcf->fopc); |
709 | lcf->fopc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 764 | lcf->fopc->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
710 | GST_forwarded_operation_timeout (lcf->fopc, tc); | 765 | // GST_forwarded_operation_timeout (lcf->fopc, tc); |
766 | GNUNET_TESTBED_forward_operation_msg_cancel_ (fopc->opc); | ||
767 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
768 | "A forwarded operation as part of controller linking has timed out\n"); | ||
769 | send_controller_link_response (fopc->client, fopc->operation_id, NULL, "Timeout"); | ||
770 | GNUNET_SERVER_client_drop (fopc->client); | ||
771 | GNUNET_CONTAINER_DLL_remove (fopcq_head, fopcq_tail, fopc); | ||
772 | GNUNET_free (fopc); | ||
711 | lcf->fopc = NULL; | 773 | lcf->fopc = NULL; |
712 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | 774 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); |
713 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | 775 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); |
@@ -867,13 +929,13 @@ slave_status_callback (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
867 | slave); | 929 | slave); |
868 | if (NULL != slave->controller) | 930 | if (NULL != slave->controller) |
869 | { | 931 | { |
870 | send_operation_success_msg (lcc->client, lcc->operation_id); | 932 | send_controller_link_response (lcc->client, lcc->operation_id, cfg, NULL); |
871 | slave->cfg = GNUNET_CONFIGURATION_dup (cfg); | 933 | slave->cfg = GNUNET_CONFIGURATION_dup (cfg); |
872 | } | 934 | } |
873 | else | 935 | else |
874 | { | 936 | { |
875 | GST_send_operation_fail_msg (lcc->client, lcc->operation_id, | 937 | send_controller_link_response (lcc->client, lcc->operation_id, NULL, |
876 | "Could not connect to delegated controller"); | 938 | "Could not connect to delegated controller"); |
877 | GNUNET_TESTBED_controller_stop (slave->controller_proc); | 939 | GNUNET_TESTBED_controller_stop (slave->controller_proc); |
878 | GST_slave_list[slave->host_id] = NULL; | 940 | GST_slave_list[slave->host_id] = NULL; |
879 | GNUNET_free (slave); | 941 | GNUNET_free (slave); |
@@ -1168,7 +1230,7 @@ static void | |||
1168 | handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | 1230 | handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, |
1169 | const struct GNUNET_MessageHeader *message) | 1231 | const struct GNUNET_MessageHeader *message) |
1170 | { | 1232 | { |
1171 | const struct GNUNET_TESTBED_ControllerLinkMessage *msg; | 1233 | const struct GNUNET_TESTBED_ControllerLinkRequest *msg; |
1172 | struct GNUNET_CONFIGURATION_Handle *cfg; | 1234 | struct GNUNET_CONFIGURATION_Handle *cfg; |
1173 | struct LCFContextQueue *lcfq; | 1235 | struct LCFContextQueue *lcfq; |
1174 | struct Route *route; | 1236 | struct Route *route; |
@@ -1187,13 +1249,13 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | |||
1187 | return; | 1249 | return; |
1188 | } | 1250 | } |
1189 | msize = ntohs (message->size); | 1251 | msize = ntohs (message->size); |
1190 | if (sizeof (struct GNUNET_TESTBED_ControllerLinkMessage) >= msize) | 1252 | if (sizeof (struct GNUNET_TESTBED_ControllerLinkRequest) >= msize) |
1191 | { | 1253 | { |
1192 | GNUNET_break (0); | 1254 | GNUNET_break (0); |
1193 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1255 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1194 | return; | 1256 | return; |
1195 | } | 1257 | } |
1196 | msg = (const struct GNUNET_TESTBED_ControllerLinkMessage *) message; | 1258 | msg = (const struct GNUNET_TESTBED_ControllerLinkRequest *) message; |
1197 | delegated_host_id = ntohl (msg->delegated_host_id); | 1259 | delegated_host_id = ntohl (msg->delegated_host_id); |
1198 | if (delegated_host_id == GST_context->host_id) | 1260 | if (delegated_host_id == GST_context->host_id) |
1199 | { | 1261 | { |
@@ -1231,7 +1293,7 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | |||
1231 | struct Slave *slave; | 1293 | struct Slave *slave; |
1232 | struct LinkControllersContext *lcc; | 1294 | struct LinkControllersContext *lcc; |
1233 | 1295 | ||
1234 | msize -= sizeof (struct GNUNET_TESTBED_ControllerLinkMessage); | 1296 | msize -= sizeof (struct GNUNET_TESTBED_ControllerLinkRequest); |
1235 | config_size = ntohs (msg->config_size); | 1297 | config_size = ntohs (msg->config_size); |
1236 | if ((delegated_host_id < GST_slave_list_size) && (NULL != GST_slave_list[delegated_host_id])) /* We have already added */ | 1298 | if ((delegated_host_id < GST_slave_list_size) && (NULL != GST_slave_list[delegated_host_id])) /* We have already added */ |
1237 | { | 1299 | { |
@@ -1287,10 +1349,15 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | |||
1287 | slave); | 1349 | slave); |
1288 | slave->cfg = cfg; | 1350 | slave->cfg = cfg; |
1289 | if (NULL != slave->controller) | 1351 | if (NULL != slave->controller) |
1290 | send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id)); | 1352 | send_controller_link_response (client, |
1353 | GNUNET_ntohll (msg->operation_id), | ||
1354 | NULL, | ||
1355 | NULL); | ||
1291 | else | 1356 | else |
1292 | GST_send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), | 1357 | send_controller_link_response (client, |
1293 | "Could not connect to delegated controller"); | 1358 | GNUNET_ntohll (msg->operation_id), |
1359 | NULL, | ||
1360 | "Could not connect to delegated controller"); | ||
1294 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1361 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1295 | return; | 1362 | return; |
1296 | } | 1363 | } |
diff --git a/src/testbed/gnunet-service-testbed.h b/src/testbed/gnunet-service-testbed.h index 1d465318c..984cf438a 100644 --- a/src/testbed/gnunet-service-testbed.h +++ b/src/testbed/gnunet-service-testbed.h | |||
@@ -509,7 +509,7 @@ struct LCFContext | |||
509 | /** | 509 | /** |
510 | * The controller link message that has to be forwarded to | 510 | * The controller link message that has to be forwarded to |
511 | */ | 511 | */ |
512 | struct GNUNET_TESTBED_ControllerLinkMessage *msg; | 512 | struct GNUNET_TESTBED_ControllerLinkRequest *msg; |
513 | 513 | ||
514 | /** | 514 | /** |
515 | * The client which has asked to perform this operation | 515 | * The client which has asked to perform this operation |
diff --git a/src/testbed/testbed.h b/src/testbed/testbed.h index 3bed4ed56..c94e6a54b 100644 --- a/src/testbed/testbed.h +++ b/src/testbed/testbed.h | |||
@@ -166,7 +166,7 @@ struct GNUNET_TESTBED_ConfigureSharedServiceMessage | |||
166 | * requests for a particular client to a particular | 166 | * requests for a particular client to a particular |
167 | * sub-controller. | 167 | * sub-controller. |
168 | */ | 168 | */ |
169 | struct GNUNET_TESTBED_ControllerLinkMessage | 169 | struct GNUNET_TESTBED_ControllerLinkRequest |
170 | { | 170 | { |
171 | 171 | ||
172 | /** | 172 | /** |
@@ -207,6 +207,42 @@ struct GNUNET_TESTBED_ControllerLinkMessage | |||
207 | 207 | ||
208 | 208 | ||
209 | /** | 209 | /** |
210 | * Response message for ControllerLinkRequest message | ||
211 | */ | ||
212 | struct GNUNET_TESTBED_ControllerLinkResponse | ||
213 | { | ||
214 | |||
215 | /** | ||
216 | * Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT | ||
217 | */ | ||
218 | struct GNUNET_MessageHeader header; | ||
219 | |||
220 | /** | ||
221 | * The size of the compressed configuration. Can be ZERO if the controller is | ||
222 | * not started (depends on the ControllerLinkRequest). NBO. | ||
223 | */ | ||
224 | uint16_t config_size GNUNET_PACKED; | ||
225 | |||
226 | /** | ||
227 | * Set to GNUNET_YES to signify SUCCESS; GNUNET_NO to signify failure | ||
228 | */ | ||
229 | uint16_t success GNUNET_PACKED; | ||
230 | |||
231 | /** | ||
232 | * The id of the operation which created this message. NBO | ||
233 | */ | ||
234 | uint64_t operation_id GNUNET_PACKED; | ||
235 | |||
236 | /* If controller linking is successful and configuration is present, then here | ||
237 | * comes the serialized gzip configuration with which the controller is | ||
238 | * running at the delegate host */ | ||
239 | |||
240 | /* In case of failure, here comes the error message (without \0 termination)*/ | ||
241 | |||
242 | }; | ||
243 | |||
244 | |||
245 | /** | ||
210 | * Message sent from client to testing service to | 246 | * Message sent from client to testing service to |
211 | * create (configure, but not start) a peer. | 247 | * create (configure, but not start) a peer. |
212 | */ | 248 | */ |
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 993883023..19c0b7699 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -169,7 +169,12 @@ struct ControllerLinkData | |||
169 | /** | 169 | /** |
170 | * The controller link message | 170 | * The controller link message |
171 | */ | 171 | */ |
172 | struct GNUNET_TESTBED_ControllerLinkMessage *msg; | 172 | struct GNUNET_TESTBED_ControllerLinkRequest *msg; |
173 | |||
174 | /** | ||
175 | * The id of the host which is hosting the controller to be linked | ||
176 | */ | ||
177 | uint32_t host_id; | ||
173 | 178 | ||
174 | }; | 179 | }; |
175 | 180 | ||
@@ -280,16 +285,6 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
280 | //PEERDESTROYDATA | 285 | //PEERDESTROYDATA |
281 | } | 286 | } |
282 | break; | 287 | break; |
283 | case OP_LINK_CONTROLLERS: | ||
284 | { | ||
285 | struct ControllerLinkData *data; | ||
286 | |||
287 | data = opc->data; | ||
288 | GNUNET_assert (NULL != data); | ||
289 | GNUNET_free (data); | ||
290 | opc->data = NULL; | ||
291 | } | ||
292 | break; | ||
293 | default: | 288 | default: |
294 | GNUNET_assert (0); | 289 | GNUNET_assert (0); |
295 | } | 290 | } |
@@ -748,6 +743,93 @@ handle_slave_config (struct GNUNET_TESTBED_Controller *c, | |||
748 | 743 | ||
749 | 744 | ||
750 | /** | 745 | /** |
746 | * Handler for GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG message from controller | ||
747 | * (testbed service) | ||
748 | * | ||
749 | * @param c the controller handler | ||
750 | * @param msg message received | ||
751 | * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if | ||
752 | * not | ||
753 | */ | ||
754 | static int | ||
755 | handle_link_controllers_result (struct GNUNET_TESTBED_Controller *c, | ||
756 | const struct | ||
757 | GNUNET_TESTBED_ControllerLinkResponse *msg) | ||
758 | { | ||
759 | struct OperationContext *opc; | ||
760 | struct ControllerLinkData *data; | ||
761 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
762 | struct GNUNET_TESTBED_Host *host; | ||
763 | char *emsg; | ||
764 | uint64_t op_id; | ||
765 | struct GNUNET_TESTBED_EventInformation event; | ||
766 | |||
767 | op_id = GNUNET_ntohll (msg->operation_id); | ||
768 | if (NULL == (opc = find_opc (c, op_id))) | ||
769 | { | ||
770 | LOG_DEBUG ("Operation not found\n"); | ||
771 | return GNUNET_YES; | ||
772 | } | ||
773 | if (OP_FORWARDED == opc->type) | ||
774 | { | ||
775 | handle_forwarded_operation_msg (c, opc, | ||
776 | (const struct GNUNET_MessageHeader *) msg); | ||
777 | return GNUNET_YES; | ||
778 | } | ||
779 | if (OP_LINK_CONTROLLERS != opc->type) | ||
780 | { | ||
781 | GNUNET_break (0); | ||
782 | return GNUNET_YES; | ||
783 | } | ||
784 | data = opc->data; | ||
785 | GNUNET_assert (NULL != data); | ||
786 | host = GNUNET_TESTBED_host_lookup_by_id_ (data->host_id); | ||
787 | GNUNET_assert (NULL != host); | ||
788 | GNUNET_free (data); | ||
789 | opc->data = NULL; | ||
790 | event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; | ||
791 | event.details.operation_finished.operation = opc->op; | ||
792 | event.details.operation_finished.op_cls = opc->op_cls; | ||
793 | event.details.operation_finished.emsg = NULL; | ||
794 | event.details.operation_finished.generic = NULL; | ||
795 | emsg = NULL; | ||
796 | cfg = NULL; | ||
797 | if (GNUNET_NO == ntohs (msg->success)) | ||
798 | { | ||
799 | emsg = GNUNET_malloc (ntohs (msg->header.size) | ||
800 | - sizeof (struct | ||
801 | GNUNET_TESTBED_ControllerLinkResponse) + 1); | ||
802 | memcpy (emsg, &msg[1], ntohs (msg->header.size) | ||
803 | - sizeof (struct | ||
804 | GNUNET_TESTBED_ControllerLinkResponse)); | ||
805 | event.details.operation_finished.emsg = emsg; | ||
806 | } | ||
807 | else | ||
808 | { | ||
809 | if (0 != ntohs (msg->config_size)) | ||
810 | { | ||
811 | cfg = GNUNET_TESTBED_extract_config_ ((const struct GNUNET_MessageHeader *) msg); | ||
812 | GNUNET_assert (NULL != cfg); | ||
813 | GNUNET_TESTBED_host_replace_cfg_ (host, cfg); | ||
814 | } | ||
815 | } | ||
816 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | ||
817 | opc->state = OPC_STATE_FINISHED; | ||
818 | if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED))) | ||
819 | { | ||
820 | if (NULL != c->cc) | ||
821 | c->cc (c->cc_cls, &event); | ||
822 | } | ||
823 | else | ||
824 | LOG_DEBUG ("Not calling callback\n"); | ||
825 | if (NULL != cfg) | ||
826 | GNUNET_CONFIGURATION_destroy (cfg); | ||
827 | GNUNET_free_non_null (emsg); | ||
828 | return GNUNET_YES; | ||
829 | } | ||
830 | |||
831 | |||
832 | /** | ||
751 | * Handler for messages from controller (testbed service) | 833 | * Handler for messages from controller (testbed service) |
752 | * | 834 | * |
753 | * @param cls the controller handler | 835 | * @param cls the controller handler |
@@ -840,6 +922,13 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
840 | (const struct GNUNET_TESTBED_SlaveConfiguration *) | 922 | (const struct GNUNET_TESTBED_SlaveConfiguration *) |
841 | msg); | 923 | msg); |
842 | break; | 924 | break; |
925 | case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT: | ||
926 | status = | ||
927 | handle_link_controllers_result (c, | ||
928 | (const struct | ||
929 | GNUNET_TESTBED_ControllerLinkResponse | ||
930 | *) msg); | ||
931 | break; | ||
843 | default: | 932 | default: |
844 | GNUNET_assert (0); | 933 | GNUNET_assert (0); |
845 | } | 934 | } |
@@ -1010,7 +1099,7 @@ opstart_link_controllers (void *cls) | |||
1010 | { | 1099 | { |
1011 | struct OperationContext *opc = cls; | 1100 | struct OperationContext *opc = cls; |
1012 | struct ControllerLinkData *data; | 1101 | struct ControllerLinkData *data; |
1013 | struct GNUNET_TESTBED_ControllerLinkMessage *msg; | 1102 | struct GNUNET_TESTBED_ControllerLinkRequest *msg; |
1014 | 1103 | ||
1015 | GNUNET_assert (NULL != opc->data); | 1104 | GNUNET_assert (NULL != opc->data); |
1016 | data = opc->data; | 1105 | data = opc->data; |
@@ -1311,11 +1400,11 @@ GNUNET_TESTBED_controller_link_2_ (void *op_cls, | |||
1311 | int is_subordinate) | 1400 | int is_subordinate) |
1312 | { | 1401 | { |
1313 | struct OperationContext *opc; | 1402 | struct OperationContext *opc; |
1314 | struct GNUNET_TESTBED_ControllerLinkMessage *msg; | 1403 | struct GNUNET_TESTBED_ControllerLinkRequest *msg; |
1315 | struct ControllerLinkData *data; | 1404 | struct ControllerLinkData *data; |
1316 | uint16_t msg_size; | 1405 | uint16_t msg_size; |
1317 | 1406 | ||
1318 | msg_size = sxcfg_size + sizeof (struct GNUNET_TESTBED_ControllerLinkMessage); | 1407 | msg_size = sxcfg_size + sizeof (struct GNUNET_TESTBED_ControllerLinkRequest); |
1319 | msg = GNUNET_malloc (msg_size); | 1408 | msg = GNUNET_malloc (msg_size); |
1320 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS); | 1409 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS); |
1321 | msg->header.size = htons (msg_size); | 1410 | msg->header.size = htons (msg_size); |
@@ -1326,6 +1415,7 @@ GNUNET_TESTBED_controller_link_2_ (void *op_cls, | |||
1326 | memcpy (&msg[1], sxcfg, sxcfg_size); | 1415 | memcpy (&msg[1], sxcfg, sxcfg_size); |
1327 | data = GNUNET_malloc (sizeof (struct ControllerLinkData)); | 1416 | data = GNUNET_malloc (sizeof (struct ControllerLinkData)); |
1328 | data->msg = msg; | 1417 | data->msg = msg; |
1418 | data->host_id = delegated_host_id; | ||
1329 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | 1419 | opc = GNUNET_malloc (sizeof (struct OperationContext)); |
1330 | opc->c = master; | 1420 | opc->c = master; |
1331 | opc->data = data; | 1421 | opc->data = data; |
@@ -1416,6 +1506,33 @@ GNUNET_TESTBED_compress_config_ (const char *config, size_t size, | |||
1416 | 1506 | ||
1417 | 1507 | ||
1418 | /** | 1508 | /** |
1509 | * Function to serialize and compress using zlib a configuration through a | ||
1510 | * configuration handle | ||
1511 | * | ||
1512 | * @param cfg the configuration | ||
1513 | * @param size the size of configuration when serialize. Will be set on success. | ||
1514 | * @param xsize the sizeo of the compressed configuration. Will be set on success. | ||
1515 | * @return the serialized and compressed configuration | ||
1516 | */ | ||
1517 | char * | ||
1518 | GNUNET_TESTBED_compress_cfg_ (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
1519 | size_t *size, size_t *xsize) | ||
1520 | { | ||
1521 | char *config; | ||
1522 | char *xconfig; | ||
1523 | size_t size_; | ||
1524 | size_t xsize_; | ||
1525 | |||
1526 | config = GNUNET_CONFIGURATION_serialize (cfg, &size_); | ||
1527 | xsize_ = GNUNET_TESTBED_compress_config_ (config, size_, &xconfig); | ||
1528 | GNUNET_free (config); | ||
1529 | *size = size_; | ||
1530 | *xsize = xsize_; | ||
1531 | return xconfig; | ||
1532 | } | ||
1533 | |||
1534 | |||
1535 | /** | ||
1419 | * Same as the GNUNET_TESTBED_controller_link, but with ids for delegated host | 1536 | * Same as the GNUNET_TESTBED_controller_link, but with ids for delegated host |
1420 | * and slave host | 1537 | * and slave host |
1421 | * | 1538 | * |
@@ -1453,7 +1570,7 @@ GNUNET_TESTBED_controller_link_ (void *op_cls, | |||
1453 | GNUNET_free (config); | 1570 | GNUNET_free (config); |
1454 | /* Configuration doesn't fit in 1 message */ | 1571 | /* Configuration doesn't fit in 1 message */ |
1455 | GNUNET_assert ((UINT16_MAX - | 1572 | GNUNET_assert ((UINT16_MAX - |
1456 | sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) >= | 1573 | sizeof (struct GNUNET_TESTBED_ControllerLinkRequest)) >= |
1457 | cc_size); | 1574 | cc_size); |
1458 | op = GNUNET_TESTBED_controller_link_2_ (op_cls, master, delegated_host_id, | 1575 | op = GNUNET_TESTBED_controller_link_2_ (op_cls, master, delegated_host_id, |
1459 | slave_host_id, (const char *) cconfig, | 1576 | slave_host_id, (const char *) cconfig, |
@@ -1697,7 +1814,8 @@ GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation) | |||
1697 | * given message should be of the following types: | 1814 | * given message should be of the following types: |
1698 | * GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION, | 1815 | * GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION, |
1699 | * GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, | 1816 | * GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, |
1700 | * GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST | 1817 | * GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, |
1818 | * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT | ||
1701 | * | 1819 | * |
1702 | * @param msg the message containing compressed configuration | 1820 | * @param msg the message containing compressed configuration |
1703 | * @return handle to the parsed configuration; NULL upon error while parsing the message | 1821 | * @return handle to the parsed configuration; NULL upon error while parsing the message |
@@ -1752,6 +1870,17 @@ GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg) | |||
1752 | xdata = (const Bytef *) ((const void *) imsg + osize); | 1870 | xdata = (const Bytef *) ((const void *) imsg + osize); |
1753 | } | 1871 | } |
1754 | break; | 1872 | break; |
1873 | case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT: | ||
1874 | { | ||
1875 | const struct GNUNET_TESTBED_ControllerLinkResponse *imsg; | ||
1876 | |||
1877 | imsg = (const struct GNUNET_TESTBED_ControllerLinkResponse *) msg; | ||
1878 | data_len = ntohs (imsg->config_size); | ||
1879 | xdata_len = ntohs (imsg->header.size) - | ||
1880 | sizeof (const struct GNUNET_TESTBED_ControllerLinkResponse); | ||
1881 | xdata = (const Bytef *) &imsg[1]; | ||
1882 | } | ||
1883 | break; | ||
1755 | default: | 1884 | default: |
1756 | GNUNET_assert (0); | 1885 | GNUNET_assert (0); |
1757 | } | 1886 | } |
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index 28a19daaf..a90acbf81 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h | |||
@@ -318,6 +318,20 @@ GNUNET_TESTBED_compress_config_ (const char *config, size_t size, | |||
318 | 318 | ||
319 | 319 | ||
320 | /** | 320 | /** |
321 | * Function to serialize and compress using zlib a configuration through a | ||
322 | * configuration handle | ||
323 | * | ||
324 | * @param cfg the configuration | ||
325 | * @param size the size of configuration when serialize. Will be set on success. | ||
326 | * @param xsize the sizeo of the compressed configuration. Will be set on success. | ||
327 | * @return the serialized and compressed configuration | ||
328 | */ | ||
329 | char * | ||
330 | GNUNET_TESTBED_compress_cfg_ (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
331 | size_t *size, size_t *xsize); | ||
332 | |||
333 | |||
334 | /** | ||
321 | * Adds an operation to the queue of operations | 335 | * Adds an operation to the queue of operations |
322 | * | 336 | * |
323 | * @param op the operation to add | 337 | * @param op the operation to add |
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index 65217ebdd..198e72c0e 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c | |||
@@ -337,6 +337,21 @@ GNUNET_TESTBED_host_get_cfg_ (const struct GNUNET_TESTBED_Host *host) | |||
337 | 337 | ||
338 | 338 | ||
339 | /** | 339 | /** |
340 | * Function to replace host's configuration | ||
341 | * | ||
342 | * @param host the host handle | ||
343 | * @param new_cfg the new configuration to replace the old one | ||
344 | */ | ||
345 | void | ||
346 | GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host, | ||
347 | const struct GNUNET_CONFIGURATION_Handle *new_cfg) | ||
348 | { | ||
349 | GNUNET_CONFIGURATION_destroy (host->cfg); | ||
350 | host->cfg = GNUNET_CONFIGURATION_dup (new_cfg); | ||
351 | } | ||
352 | |||
353 | |||
354 | /** | ||
340 | * Create a host to run peers and controllers on. | 355 | * Create a host to run peers and controllers on. |
341 | * | 356 | * |
342 | * @param id global host ID assigned to the host; 0 is | 357 | * @param id global host ID assigned to the host; 0 is |
diff --git a/src/testbed/testbed_api_hosts.h b/src/testbed/testbed_api_hosts.h index 91fea72b7..7ce949789 100644 --- a/src/testbed/testbed_api_hosts.h +++ b/src/testbed/testbed_api_hosts.h | |||
@@ -103,6 +103,17 @@ GNUNET_TESTBED_host_get_cfg_ (const struct GNUNET_TESTBED_Host *host); | |||
103 | 103 | ||
104 | 104 | ||
105 | /** | 105 | /** |
106 | * Function to replace host's configuration | ||
107 | * | ||
108 | * @param host the host handle | ||
109 | * @param new_cfg the new configuration to replace the old one | ||
110 | */ | ||
111 | void | ||
112 | GNUNET_TESTBED_host_replace_cfg_ (struct GNUNET_TESTBED_Host *host, | ||
113 | const struct GNUNET_CONFIGURATION_Handle *new_cfg); | ||
114 | |||
115 | |||
116 | /** | ||
106 | * Marks a host as registered with a controller | 117 | * Marks a host as registered with a controller |
107 | * | 118 | * |
108 | * @param host the host to mark | 119 | * @param host the host to mark |