aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_hosts.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-07-03 13:14:15 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-07-03 13:14:15 +0000
commit640ff05da5015bdf48bed436eb617d42528a664c (patch)
treee6747ede975bfb25963f981fdf3c0ad2a110a5d2 /src/testbed/testbed_api_hosts.c
parent9ae6238e0fb4c09531f5ae8b00f017f90232ab7a (diff)
downloadgnunet-640ff05da5015bdf48bed436eb617d42528a664c.tar.gz
gnunet-640ff05da5015bdf48bed436eb617d42528a664c.zip
-LCFContext
Diffstat (limited to 'src/testbed/testbed_api_hosts.c')
-rw-r--r--src/testbed/testbed_api_hosts.c70
1 files changed, 62 insertions, 8 deletions
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 3df6e14fe..6c0877cea 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -33,7 +33,26 @@
33#include "gnunet_hello_lib.h" 33#include "gnunet_hello_lib.h"
34#include "gnunet_container_lib.h" 34#include "gnunet_container_lib.h"
35 35
36/**
37 * A list entry for registered controllers list
38 */
39struct RegisteredController
40{
41 /**
42 * The controller at which this host is registered
43 */
44 const struct GNUNET_TESTBED_Controller *controller;
45
46 /**
47 * The next ptr for DLL
48 */
49 struct RegisteredController *next;
36 50
51 /**
52 * The prev ptr for DLL
53 */
54 struct RegisteredController *prev;
55};
37 56
38/** 57/**
39 * Opaque handle to a host running experiments managed by the testing framework. 58 * Opaque handle to a host running experiments managed by the testing framework.
@@ -64,9 +83,14 @@ struct GNUNET_TESTBED_Host
64 const char *username; 83 const char *username;
65 84
66 /** 85 /**
67 * The controller at which this host is registered 86 * The head for the list of controllers where this host is registered
68 */ 87 */
69 const struct GNUNET_TESTBED_Controller *controller; 88 struct RegisteredController *rc_head;
89
90 /**
91 * The tail for the list of controllers where this host is registered
92 */
93 struct RegisteredController *rc_tail;
70 94
71 /** 95 /**
72 * Global ID we use to refer to a host on the network 96 * Global ID we use to refer to a host on the network
@@ -261,7 +285,15 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
261void 285void
262GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) 286GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
263{ 287{
264 GNUNET_CONTAINER_DLL_remove (host_list_head, host_list_tail, host); 288 struct RegisteredController *rc;
289
290 GNUNET_CONTAINER_DLL_remove (host_list_head, host_list_tail, host);
291 /* clear registered controllers list */
292 for (rc=host->rc_head; NULL != rc; rc=host->rc_head)
293 {
294 GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc);
295 GNUNET_free (rc);
296 }
265 GNUNET_free (host); 297 GNUNET_free (host);
266} 298}
267 299
@@ -389,11 +421,24 @@ GNUNET_TESTBED_host_stop_ (struct GNUNET_TESTBED_HelperHandle *handle)
389 * @param controller the controller at which this host is registered 421 * @param controller the controller at which this host is registered
390 */ 422 */
391void 423void
392GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host, 424GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host,
393 const struct GNUNET_TESTBED_Controller 425 const struct GNUNET_TESTBED_Controller
394 *controller) 426 * const controller)
395{ 427{
396 host->controller = controller; 428 struct RegisteredController *rc;
429
430 for (rc=host->rc_head; NULL != rc; rc=rc->next)
431 {
432 if (controller == rc->controller) /* already registered at controller */
433 {
434 GNUNET_break (0);
435 return;
436 }
437 }
438 rc = GNUNET_malloc (sizeof (struct RegisteredController));
439 rc->controller = controller;
440 //host->controller = controller;
441 GNUNET_CONTAINER_DLL_insert_tail (host->rc_head, host->rc_tail, rc);
397} 442}
398 443
399 444
@@ -407,9 +452,18 @@ GNUNET_TESTBED_mark_host_as_registered_ (struct GNUNET_TESTBED_Host *host,
407int 452int
408GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host, 453GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
409 const struct GNUNET_TESTBED_Controller 454 const struct GNUNET_TESTBED_Controller
410 *controller) 455 *const controller)
411{ 456{
412 return (controller == host->controller) ? GNUNET_YES : GNUNET_NO; 457 struct RegisteredController *rc;
458
459 for (rc=host->rc_head; NULL != rc; rc=rc->next)
460 {
461 if (controller == rc->controller) /* already registered at controller */
462 {
463 return GNUNET_YES;
464 }
465 }
466 return GNUNET_NO;
413} 467}
414 468
415 469