-host registration with controller
authorSree Harsha Totakura <totakura@in.tum.de>
Fri, 29 Jun 2012 15:26:52 +0000 (15:26 +0000)
committerSree Harsha Totakura <totakura@in.tum.de>
Fri, 29 Jun 2012 15:26:52 +0000 (15:26 +0000)
src/testbed/testbed_api.c
src/testbed/testbed_api_hosts.c
src/testbed/testbed_api_hosts.h

index 6f5ed2d6e16ebe782c00711b85e68a27eeb4db38..20e6810afbe7cfb663604f7617faf7e80e4eb5bd 100644 (file)
@@ -255,7 +255,7 @@ handle_addhostconfirm (struct GNUNET_TESTBED_Controller *c,
   if (sizeof (struct GNUNET_TESTBED_HostConfirmedMessage) == msg_size)
   {
     LOG_DEBUG ("Host %u successfully registered\n", ntohl (msg->host_id));
-    GNUNET_TESTBED_mark_host_as_registered_  (rh->host);
+    GNUNET_TESTBED_mark_host_as_registered_  (rh->host, c);
     rh->cc (rh->cc_cls, NULL);
     GNUNET_free (rh);
     return GNUNET_OK;
@@ -541,7 +541,7 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
   if (NULL != controller->rh)
     return NULL;
   hostname = GNUNET_TESTBED_host_get_hostname_ (host);
-  if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host))
+  if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
          "Host hostname: %s already registered\n",
@@ -638,9 +638,9 @@ GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
   uint16_t msg_size;
 
   GNUNET_assert (GNUNET_YES == 
-                GNUNET_TESTBED_is_host_registered_ (delegated_host));
+                GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
   GNUNET_assert (GNUNET_YES == 
-                GNUNET_TESTBED_is_host_registered_ (slave_host));
+                GNUNET_TESTBED_is_host_registered_ (slave_host, master));
   config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size);
   cc_size = compressBound ((uLong) config_size);
   cconfig = GNUNET_malloc (cc_size);
index 766a87ad2c318684ff8442d571a4d47710e5795c..3df6e14fed4b02ac7ffd0586b3724ea18355f91a 100644 (file)
@@ -63,6 +63,11 @@ struct GNUNET_TESTBED_Host
    */
   const char *username;
 
+  /**
+   * The controller at which this host is registered
+   */
+  const struct GNUNET_TESTBED_Controller *controller;
+
   /**
    * Global ID we use to refer to a host on the network
    */
@@ -73,10 +78,6 @@ struct GNUNET_TESTBED_Host
    */
   uint16_t port;
 
-  /**
-   * Set this flag to 1 if host is registered with a controller; 0 if not
-   */
-  uint8_t is_registered;
 };
 
 
@@ -385,11 +386,14 @@ GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle)
  * Marks a host as registered with a controller
  *
  * @param host the host to mark
+ * @param controller the controller at which this host is registered
  */
 void
-GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host)
+GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host,
+                                        const struct GNUNET_TESTBED_Controller
+                                        *controller)
 {
-  host->is_registered = 1;
+  host->controller = controller;
 }
 
 
@@ -397,12 +401,15 @@ GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host)
  * Checks whether a host has been registered
  *
  * @param host the host to check
+ * @param controller the controller at which host's registration is checked
  * @return GNUNET_YES if registered; GNUNET_NO if not
  */
 int
-GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host)
+GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
+                                   const struct GNUNET_TESTBED_Controller
+                                   *controller)
 {
-  return (1 == host->is_registered) ? GNUNET_YES : GNUNET_NO;
+  return (controller == host->controller) ? GNUNET_YES : GNUNET_NO;
 }
 
 
index db7392b49e12518fcec7589bc075c767983da35c..c941608f4a2cd048ae4017b95bc6668480b80b59 100644 (file)
@@ -129,19 +129,25 @@ GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle);
  * Marks a host as registered with a controller
  *
  * @param host the host to mark
+ * @param controller the controller at which this host is registered
  */
 void
-GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host);
+GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host,
+                                        const struct GNUNET_TESTBED_Controller
+                                        *controller);
 
 
 /**
- * Checks whether a host has been registered
+ * Checks whether a host has been registered with the given controller
  *
  * @param host the host to check
+ * @param controller the controller at which host's registration is checked
  * @return GNUNET_YES if registered; GNUNET_NO if not
  */
 int
-GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host);
+GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
+                                   const struct GNUNET_TESTBED_Controller
+                                        *controller);
 
 #endif
 /* end of testbed_api_hosts.h */