From 44b78f15b4e846463958b295bfa2725d5dbb49a6 Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Wed, 18 Jul 2012 11:56:05 +0000 Subject: [PATCH] implemented controller_start success callback --- src/testbed/test_gnunet_testbed_helper.c | 3 ++ src/testbed/testbed_api.c | 39 ++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/testbed/test_gnunet_testbed_helper.c b/src/testbed/test_gnunet_testbed_helper.c index 78f6ee69d..a0e1dd619 100644 --- a/src/testbed/test_gnunet_testbed_helper.c +++ b/src/testbed/test_gnunet_testbed_helper.c @@ -151,6 +151,8 @@ mst_cb (void *cls, void *client, const struct GNUNET_MessageHeader *message) uLongf xconfig_size; msg = (const struct GNUNET_TESTBED_HelperReply *) message; + config_size = 0; + xconfig_size = 0; GNUNET_assert (sizeof (struct GNUNET_TESTBED_HelperReply) < ntohs (msg->header.size)); GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY @@ -161,6 +163,7 @@ mst_cb (void *cls, void *client, const struct GNUNET_MessageHeader *message) config = GNUNET_malloc (config_size); GNUNET_assert (Z_OK == uncompress ((Bytef *) config, &config_size, (const Bytef *) &msg[1], xconfig_size)); + GNUNET_free (config); if (GNUNET_SCHEDULER_NO_TASK == shutdown_task) shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 3a42e87a8..1815c5ec8 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c @@ -430,6 +430,11 @@ struct GNUNET_TESTBED_ControllerProc */ struct GNUNET_HELPER_Handle *helper; + /** + * The host where the helper is run + */ + struct GNUNET_TESTBED_Host *host; + /** * The controller error callback */ @@ -439,7 +444,6 @@ struct GNUNET_TESTBED_ControllerProc * The closure for the above callback */ void *cls; - /** * The send handle for the helper */ @@ -455,6 +459,11 @@ struct GNUNET_TESTBED_ControllerProc */ char *dst; + /** + * The configuration of the running testbed service + */ + struct GNUNET_CONFIGURATION_Handle *cfg; + }; @@ -473,7 +482,32 @@ struct GNUNET_TESTBED_ControllerProc static int helper_mst (void *cls, void *client, const struct GNUNET_MessageHeader *message) { - GNUNET_break (0); + struct GNUNET_TESTBED_ControllerProc *cp = cls; + const struct GNUNET_TESTBED_HelperReply *msg; + char *config; + uLongf config_size; + uLongf xconfig_size; + + msg = (const struct GNUNET_TESTBED_HelperReply *) message; + GNUNET_assert (sizeof (struct GNUNET_TESTBED_HelperReply) + < ntohs (msg->header.size)); + GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY + == ntohs (msg->header.type)); + config_size = (uLongf) ntohs (msg->config_size); + xconfig_size = (uLongf) (ntohs (msg->header.size) + - sizeof (struct GNUNET_TESTBED_HelperReply)); + config = GNUNET_malloc (config_size); + GNUNET_assert (Z_OK == uncompress ((Bytef *) config, &config_size, + (const Bytef *) &msg[1], xconfig_size)); + GNUNET_assert (NULL == cp->cfg); + cp->cfg = GNUNET_CONFIGURATION_create (); + GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->cfg, config, + config_size, GNUNET_NO)); + /* Change the hostname so that we can connect to it */ + GNUNET_CONFIGURATION_set_value_string (cp->cfg, "testbed", "hostname", + (NULL == cp->cfg) ? "localhost" : + GNUNET_TESTBED_host_get_hostname_ (cp->host)); + cp->cb (cp->cls, cp->cfg, GNUNET_OK); return GNUNET_OK; } @@ -587,6 +621,7 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, GNUNET_free (cp); return NULL; } + cp->host = host; cp->cb = cb; cp->cls = cls; msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg); -- 2.25.1