gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r22413 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r22413 - gnunet/src/testbed
Date: Sun, 1 Jul 2012 17:37:23 +0200

Author: harsha
Date: 2012-07-01 17:37:23 +0200 (Sun, 01 Jul 2012)
New Revision: 22413

Modified:
   gnunet/src/testbed/gnunet-service-testbed.c
   gnunet/src/testbed/testbed.h
   gnunet/src/testbed/testbed_api.c
Log:
link controller handler

Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-07-01 15:34:25 UTC (rev 
22412)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-07-01 15:37:23 UTC (rev 
22413)
@@ -27,6 +27,7 @@
 #include "platform.h"
 #include "gnunet_service_lib.h"
 #include "gnunet_server_lib.h"
+#include <zlib.h>
 
 #include "testbed.h"
 #include "gnunet_testbed_service.h"
@@ -413,14 +414,14 @@
                                  struct GNUNET_SERVER_Client *client,
                                  const struct GNUNET_MessageHeader *message)
 {
-  struct GNUNET_TESTBED_ConfigureSharedServiceMessage *msg;
+  const struct GNUNET_TESTBED_ConfigureSharedServiceMessage *msg;
   struct SharedService *ss;
   char *service_name;
   struct GNUNET_HashCode hash;
   uint16_t msg_size;
   uint16_t service_name_size;
     
-  msg = (struct GNUNET_TESTBED_ConfigureSharedServiceMessage *) message;
+  msg = (const struct GNUNET_TESTBED_ConfigureSharedServiceMessage *) message;
   msg_size = ntohs (message->size);
   if (msg_size <= sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage))
   {
@@ -467,6 +468,80 @@
 
 
 /**
+ * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message
+ *
+ * @param cls NULL
+ * @param client identification of the client
+ * @param message the actual message
+ */
+static void 
+handle_link_controllers (void *cls,
+                         struct GNUNET_SERVER_Client *client,
+                         const struct GNUNET_MessageHeader *message)
+{
+  const struct GNUNET_TESTBED_ControllerLinkMessage *msg;
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+  char *config;  
+  uLongf dest_size;
+  size_t config_size;
+  uint32_t delegated_host_id;
+  uint32_t slave_host_id;
+  uint16_t msize;
+   
+  msize = ntohs (message->size);
+  if (sizeof (struct GNUNET_TESTBED_ControllerLinkMessage) >= msize)
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+  msg = (const struct GNUNET_TESTBED_ControllerLinkMessage *) message;
+  delegated_host_id = ntohl (msg->delegated_host_id);
+  if ((delegated_host_id >= host_list_size) || 
+      (NULL == host_list[delegated_host_id]))
+  {
+    GNUNET_break (0);           /* Delegated host not registered with us */
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+  slave_host_id = ntohl (msg->slave_host_id);
+  if ((slave_host_id >= host_list_size) || (NULL == host_list[slave_host_id]))
+  {
+    GNUNET_break (0);           /* Slave host not registered with us */
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+  config_size = ntohs (msg->config_size);
+  config = GNUNET_malloc (config_size);
+  dest_size = (uLongf) config_size;
+  msize -= sizeof (struct GNUNET_TESTBED_ControllerLinkMessage);
+  if (Z_OK != uncompress ((Bytef *) config, &dest_size,
+                          (const Bytef *) &msg[1], (uLong) msize))
+  {
+    GNUNET_break (0);           /* Compression error */
+    GNUNET_free (config);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+  GNUNET_assert (config_size == dest_size);
+  cfg = GNUNET_CONFIGURATION_create ();
+  if (GNUNET_OK != GNUNET_CONFIGURATION_deserialize (cfg, config, config_size,
+                                                     GNUNET_NO))
+  {
+    GNUNET_break (0);           /* Configuration parsing error */
+    GNUNET_break (config);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+  GNUNET_free (config);
+  /* FIXME: start the slave controller if is_subordinate is yes; else store it
+  in routing */
+
+  GNUNET_CONFIGURATION_destroy (cfg);
+}
+
+
+/**
  * Iterator over hash map entries.
  *
  * @param cls closure
@@ -567,6 +642,8 @@
       {&handle_add_host, NULL, GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST, 0},
       {&handle_configure_shared_service, NULL,
        GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE, 0},
+      {&handle_link_controllers, NULL,
+       GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS, 0},
       {NULL}
     };
 

Modified: gnunet/src/testbed/testbed.h
===================================================================
--- gnunet/src/testbed/testbed.h        2012-07-01 15:34:25 UTC (rev 22412)
+++ gnunet/src/testbed/testbed.h        2012-07-01 15:37:23 UTC (rev 22413)
@@ -169,6 +169,11 @@
   uint32_t slave_host_id GNUNET_PACKED;
 
   /**
+   * The size of the uncompressed configuration
+   */
+  uint16_t config_size GNUNET_PACKED;
+
+  /**
    * Set to 1 if the receiving controller is the master controller for
    * the slave host (and thus responsible for starting it?). 0 if not
    */

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-07-01 15:34:25 UTC (rev 22412)
+++ gnunet/src/testbed/testbed_api.c    2012-07-01 15:37:23 UTC (rev 22413)
@@ -659,6 +659,7 @@
   msg->header.size = htons (msg_size);
   msg->delegated_host_id = htonl (GNUNET_TESTBED_host_get_id_ 
(delegated_host));
   msg->slave_host_id = htonl (GNUNET_TESTBED_host_get_id_ (slave_host));
+  msg->config_size = htons ((uint16_t) config_size);
   msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
   queue_message (master, (struct GNUNET_MessageHeader *) msg);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]