[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21931 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21931 - gnunet/src/testbed |
Date: |
Tue, 12 Jun 2012 22:54:19 +0200 |
Author: harsha
Date: 2012-06-12 22:54:19 +0200 (Tue, 12 Jun 2012)
New Revision: 21931
Modified:
gnunet/src/testbed/testbed_api_hosts.c
Log:
-implemented some functions from testbed_api_hosts
Modified: gnunet/src/testbed/testbed_api_hosts.c
===================================================================
--- gnunet/src/testbed/testbed_api_hosts.c 2012-06-12 20:23:00 UTC (rev
21930)
+++ gnunet/src/testbed/testbed_api_hosts.c 2012-06-12 20:54:19 UTC (rev
21931)
@@ -31,6 +31,7 @@
#include "gnunet_constants.h"
#include "gnunet_transport_service.h"
#include "gnunet_hello_lib.h"
+#include "gnunet_container_lib.h"
@@ -42,9 +43,24 @@
struct GNUNET_TESTBED_Host
{
+ /**
+ * The next pointer for DLL
+ */
+ struct GNUNET_TESTBED_Host *next;
+ /**
+ * The prev pointer for DLL
+ */
+ struct GNUNET_TESTBED_Host *prev;
+
+ /**
+ * The hostname of the host; NULL for localhost
+ */
const char *hostname;
+ /**
+ * The username to be used for SSH login
+ */
const char *username;
/**
@@ -52,21 +68,39 @@
*/
uint32_t unique_id;
+ /**
+ * The port which is to be used for SSH
+ */
uint16_t port;
};
/**
+ * Head element in the list of available hosts
+ */
+static struct GNUNET_TESTBED_Host *host_list_head;
+
+/**
+ * Tail element in the list of available hosts
+ */
+static struct GNUNET_TESTBED_Host *host_list_tail;
+
+
+/**
* Lookup a host by ID.
*
* @param id global host ID assigned to the host; 0 is
* reserved to always mean 'localhost'
- * @return handle to the host, NULL on error
+ * @return handle to the host, NULL if host not found
*/
struct GNUNET_TESTBED_Host *
GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id)
{
- GNUNET_break (0);
+ struct GNUNET_TESTBED_Host *host;
+
+ for (host = host_list_head; NULL != host; host=host->next)
+ if (id == host->unique_id)
+ return host;
return NULL;
}
@@ -83,6 +117,7 @@
struct GNUNET_TESTBED_Host *
GNUNET_TESTBED_host_create_by_id_ (uint32_t id)
{
+ GNUNET_break (0);
return NULL;
}
@@ -97,8 +132,7 @@
uint32_t
GNUNET_TESTBED_host_get_id_ (struct GNUNET_TESTBED_Host *host)
{
- GNUNET_break (0);
- return 0;
+ return host->unique_id;
}
@@ -112,14 +146,21 @@
* @param port port number to use for ssh; use 0 to let ssh decide
* @return handle to the host, NULL on error
*/
-struct GNUNET_TESTBED_Host *
+static struct GNUNET_TESTBED_Host *
GNUNET_TESTBED_host_create_with_id_ (uint32_t id,
const char *hostname,
const char *username,
uint16_t port)
{
- GNUNET_break (0);
- return NULL;
+ struct GNUNET_TESTBED_Host *host;
+
+ host = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host));
+ host->hostname = hostname;
+ host->username = username;
+ host->unique_id = id;
+ host->port = (0 == port) ? 22 : port;
+ GNUNET_CONTAINER_DLL_insert_tail (host_list_head, host_list_tail, host);
+ return host;
}
@@ -138,6 +179,8 @@
{
static uint32_t uid_generator;
+ if (NULL == hostname)
+ return GNUNET_TESTBED_host_create_with_id_ (0, hostname, username, port);
return GNUNET_TESTBED_host_create_with_id_ (++uid_generator,
hostname, username,
port);
@@ -168,8 +211,9 @@
*/
void
GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host)
-{
- GNUNET_break (0);
+{
+ GNUNET_CONTAINER_DLL_remove (host_list_head, host_list_tail, host);
+ GNUNET_free (host);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21931 - gnunet/src/testbed,
gnunet <=