diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-06-29 15:26:52 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-06-29 15:26:52 +0000 |
commit | b510c934e38ef0eb4ea959af5be94f4490ddb667 (patch) | |
tree | 810e8209ce9ce099421263eb498fc844816ecda0 | |
parent | dcd48df648a5c8bf0a7c01ae30d292868ff49cb7 (diff) | |
download | gnunet-b510c934e38ef0eb4ea959af5be94f4490ddb667.tar.gz gnunet-b510c934e38ef0eb4ea959af5be94f4490ddb667.zip |
-host registration with controller
-rw-r--r-- | src/testbed/testbed_api.c | 8 | ||||
-rw-r--r-- | src/testbed/testbed_api_hosts.c | 23 | ||||
-rw-r--r-- | src/testbed/testbed_api_hosts.h | 12 |
3 files changed, 28 insertions, 15 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 6f5ed2d6e..20e6810af 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -255,7 +255,7 @@ handle_addhostconfirm (struct GNUNET_TESTBED_Controller *c, | |||
255 | if (sizeof (struct GNUNET_TESTBED_HostConfirmedMessage) == msg_size) | 255 | if (sizeof (struct GNUNET_TESTBED_HostConfirmedMessage) == msg_size) |
256 | { | 256 | { |
257 | LOG_DEBUG ("Host %u successfully registered\n", ntohl (msg->host_id)); | 257 | LOG_DEBUG ("Host %u successfully registered\n", ntohl (msg->host_id)); |
258 | GNUNET_TESTBED_mark_host_as_registered_ (rh->host); | 258 | GNUNET_TESTBED_mark_host_as_registered_ (rh->host, c); |
259 | rh->cc (rh->cc_cls, NULL); | 259 | rh->cc (rh->cc_cls, NULL); |
260 | GNUNET_free (rh); | 260 | GNUNET_free (rh); |
261 | return GNUNET_OK; | 261 | return GNUNET_OK; |
@@ -541,7 +541,7 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, | |||
541 | if (NULL != controller->rh) | 541 | if (NULL != controller->rh) |
542 | return NULL; | 542 | return NULL; |
543 | hostname = GNUNET_TESTBED_host_get_hostname_ (host); | 543 | hostname = GNUNET_TESTBED_host_get_hostname_ (host); |
544 | if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host)) | 544 | if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller)) |
545 | { | 545 | { |
546 | LOG (GNUNET_ERROR_TYPE_WARNING, | 546 | LOG (GNUNET_ERROR_TYPE_WARNING, |
547 | "Host hostname: %s already registered\n", | 547 | "Host hostname: %s already registered\n", |
@@ -638,9 +638,9 @@ GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master, | |||
638 | uint16_t msg_size; | 638 | uint16_t msg_size; |
639 | 639 | ||
640 | GNUNET_assert (GNUNET_YES == | 640 | GNUNET_assert (GNUNET_YES == |
641 | GNUNET_TESTBED_is_host_registered_ (delegated_host)); | 641 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); |
642 | GNUNET_assert (GNUNET_YES == | 642 | GNUNET_assert (GNUNET_YES == |
643 | GNUNET_TESTBED_is_host_registered_ (slave_host)); | 643 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); |
644 | config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size); | 644 | config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size); |
645 | cc_size = compressBound ((uLong) config_size); | 645 | cc_size = compressBound ((uLong) config_size); |
646 | cconfig = GNUNET_malloc (cc_size); | 646 | cconfig = GNUNET_malloc (cc_size); |
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index 766a87ad2..3df6e14fe 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c | |||
@@ -64,6 +64,11 @@ struct GNUNET_TESTBED_Host | |||
64 | const char *username; | 64 | const char *username; |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * The controller at which this host is registered | ||
68 | */ | ||
69 | const struct GNUNET_TESTBED_Controller *controller; | ||
70 | |||
71 | /** | ||
67 | * Global ID we use to refer to a host on the network | 72 | * Global ID we use to refer to a host on the network |
68 | */ | 73 | */ |
69 | uint32_t unique_id; | 74 | uint32_t unique_id; |
@@ -73,10 +78,6 @@ struct GNUNET_TESTBED_Host | |||
73 | */ | 78 | */ |
74 | uint16_t port; | 79 | uint16_t port; |
75 | 80 | ||
76 | /** | ||
77 | * Set this flag to 1 if host is registered with a controller; 0 if not | ||
78 | */ | ||
79 | uint8_t is_registered; | ||
80 | }; | 81 | }; |
81 | 82 | ||
82 | 83 | ||
@@ -385,11 +386,14 @@ GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle) | |||
385 | * Marks a host as registered with a controller | 386 | * Marks a host as registered with a controller |
386 | * | 387 | * |
387 | * @param host the host to mark | 388 | * @param host the host to mark |
389 | * @param controller the controller at which this host is registered | ||
388 | */ | 390 | */ |
389 | void | 391 | void |
390 | GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host) | 392 | GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host, |
393 | const struct GNUNET_TESTBED_Controller | ||
394 | *controller) | ||
391 | { | 395 | { |
392 | host->is_registered = 1; | 396 | host->controller = controller; |
393 | } | 397 | } |
394 | 398 | ||
395 | 399 | ||
@@ -397,12 +401,15 @@ GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host) | |||
397 | * Checks whether a host has been registered | 401 | * Checks whether a host has been registered |
398 | * | 402 | * |
399 | * @param host the host to check | 403 | * @param host the host to check |
404 | * @param controller the controller at which host's registration is checked | ||
400 | * @return GNUNET_YES if registered; GNUNET_NO if not | 405 | * @return GNUNET_YES if registered; GNUNET_NO if not |
401 | */ | 406 | */ |
402 | int | 407 | int |
403 | GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host) | 408 | GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host, |
409 | const struct GNUNET_TESTBED_Controller | ||
410 | *controller) | ||
404 | { | 411 | { |
405 | return (1 == host->is_registered) ? GNUNET_YES : GNUNET_NO; | 412 | return (controller == host->controller) ? GNUNET_YES : GNUNET_NO; |
406 | } | 413 | } |
407 | 414 | ||
408 | 415 | ||
diff --git a/src/testbed/testbed_api_hosts.h b/src/testbed/testbed_api_hosts.h index db7392b49..c941608f4 100644 --- a/src/testbed/testbed_api_hosts.h +++ b/src/testbed/testbed_api_hosts.h | |||
@@ -129,19 +129,25 @@ GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle); | |||
129 | * Marks a host as registered with a controller | 129 | * Marks a host as registered with a controller |
130 | * | 130 | * |
131 | * @param host the host to mark | 131 | * @param host the host to mark |
132 | * @param controller the controller at which this host is registered | ||
132 | */ | 133 | */ |
133 | void | 134 | void |
134 | GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host); | 135 | GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host, |
136 | const struct GNUNET_TESTBED_Controller | ||
137 | *controller); | ||
135 | 138 | ||
136 | 139 | ||
137 | /** | 140 | /** |
138 | * Checks whether a host has been registered | 141 | * Checks whether a host has been registered with the given controller |
139 | * | 142 | * |
140 | * @param host the host to check | 143 | * @param host the host to check |
144 | * @param controller the controller at which host's registration is checked | ||
141 | * @return GNUNET_YES if registered; GNUNET_NO if not | 145 | * @return GNUNET_YES if registered; GNUNET_NO if not |
142 | */ | 146 | */ |
143 | int | 147 | int |
144 | GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host); | 148 | GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host, |
149 | const struct GNUNET_TESTBED_Controller | ||
150 | *controller); | ||
145 | 151 | ||
146 | #endif | 152 | #endif |
147 | /* end of testbed_api_hosts.h */ | 153 | /* end of testbed_api_hosts.h */ |