From: Sree Harsha Totakura Date: Tue, 2 Oct 2012 08:54:39 +0000 (+0000) Subject: slave get config service implementation X-Git-Tag: initial-import-from-subversion-38251~11529 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8fff269cbc57f900940ab2a9b850b67f98412022;p=oweals%2Fgnunet.git slave get config service implementation --- diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index 92d3af32c..cddb1c195 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c @@ -2662,6 +2662,13 @@ handle_slave_get_config (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; + struct Slave *slave; + struct GNUNET_TESTBED_SlaveConfiguration *reply; + char *config; + char *xconfig; + size_t config_size; + size_t xconfig_size; + size_t reply_size; uint64_t op_id; uint32_t slave_id; @@ -2674,7 +2681,30 @@ handle_slave_get_config (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_SERVER_receive_done (client, GNUNET_OK); return; } - GNUNET_break (0); + slave = slave_list[slave_id]; + if (NULL == slave->cfg) + { + send_operation_fail_msg (client, op_id, + "Configuration not found (slave not started by me)"); + GNUNET_SERVER_receive_done (client, GNUNET_OK); + return; + } + config = GNUNET_CONFIGURATION_serialize (slave->cfg, &config_size); + xconfig_size = GNUNET_TESTBED_compress_config_ (config, config_size, + &xconfig); + GNUNET_free (config); + reply_size = xconfig_size + sizeof (struct GNUNET_TESTBED_SlaveConfiguration); + GNUNET_break (reply_size <= UINT16_MAX); + GNUNET_break (config_size <= UINT32_MAX); + reply = GNUNET_realloc (xconfig, reply_size); + (void) memmove (&reply[1], reply, xconfig_size); + reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG); + reply->header.size = htons ((uint16_t) reply_size); + reply->slave_id = msg->slave_id; + reply->operation_id = msg->operation_id; + reply->config_size = htonl ((uint32_t) config_size); + queue_message (client, &reply->header); + GNUNET_SERVER_receive_done (client, GNUNET_OK); }