[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24196 - in gnunet/src: include testbed testing transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24196 - in gnunet/src: include testbed testing transport |
Date: |
Fri, 5 Oct 2012 16:12:49 +0200 |
Author: harsha
Date: 2012-10-05 16:12:49 +0200 (Fri, 05 Oct 2012)
New Revision: 24196
Modified:
gnunet/src/include/gnunet_testing_lib-new.h
gnunet/src/testbed/gnunet-helper-testbed.c
gnunet/src/testbed/gnunet-service-testbed.c
gnunet/src/testbed/test_gnunet_helper_testbed.c
gnunet/src/testbed/testbed_api.c
gnunet/src/testbed/testbed_api.h
gnunet/src/testbed/testbed_helper.h
gnunet/src/testing/gnunet-testing.c
gnunet/src/testing/test_testing_peerstartup.c
gnunet/src/testing/test_testing_portreservation.c
gnunet/src/testing/testing.c
gnunet/src/transport/transport-testing.c
Log:
testing now includes valid hostname rewriting
Modified: gnunet/src/include/gnunet_testing_lib-new.h
===================================================================
--- gnunet/src/include/gnunet_testing_lib-new.h 2012-10-05 14:01:08 UTC (rev
24195)
+++ gnunet/src/include/gnunet_testing_lib-new.h 2012-10-05 14:12:49 UTC (rev
24196)
@@ -59,21 +59,23 @@
/**
- * Create a system handle. There must only be one system
- * handle per operating system. Uses a default range for allowed ports.
- * Ports are still tested for availability.
+ * Create a system handle. There must only be one system handle per operating
+ * system. Uses a default range for allowed ports. Ports are still tested for
+ * availability.
*
- * @param testdir only the directory name without any path. This is used for
- * all service homes; the directory will be created in a temporary
- * location depending on the underlying OS
- * @param controller hostname of the controlling host,
- * service configurations are modified to allow
- * control connections from this host; can be NULL
+ * @param testdir only the directory name without any path. This is used for
all
+ * service homes; the directory will be created in a temporary
location
+ * depending on the underlying OS
+ * @param controller hostname of the controlling host, service configurations
+ * are modified to allow control connections from this host; can be NULL
+ * @param hostname the hostname of the system we are using for testing; NULL
for
+ * localhost
* @return handle to this system, NULL on error
*/
struct GNUNET_TESTING_System *
GNUNET_TESTING_system_create (const char *testdir,
- const char *controller);
+ const char *controller,
+ const char *hostname);
/**
@@ -89,6 +91,8 @@
* @param controller hostname of the controlling host,
* service configurations are modified to allow
* control connections from this host; can be NULL
+ * @param hostname the hostname of the system we are using for testing; NULL
for
+ * localhost
* @param lowport lowest port number this system is allowed to allocate
(inclusive)
* @param highport highest port number this system is allowed to allocate
(exclusive)
* @return handle to this system, NULL on error
@@ -96,6 +100,7 @@
struct GNUNET_TESTING_System *
GNUNET_TESTING_system_create_with_portrange (const char *testdir,
const char *controller,
+ const char *hostname,
uint16_t lowport,
uint16_t highport);
Modified: gnunet/src/testbed/gnunet-helper-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-helper-testbed.c 2012-10-05 14:01:08 UTC (rev
24195)
+++ gnunet/src/testbed/gnunet-helper-testbed.c 2012-10-05 14:12:49 UTC (rev
24196)
@@ -226,14 +226,18 @@
struct GNUNET_CONFIGURATION_Handle *cfg;
struct WriteContext *wc;
char *controller;
+ char *hostname;
char *config;
char *xconfig;
size_t config_size;
uLongf ul_config_size;
size_t xconfig_size;
uint16_t cname_size;
-
- if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= ntohs (message->size)) ||
+ uint16_t hostname_size;
+ uint16_t msize;
+
+ msize = ntohs (message->size);
+ if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= msize) ||
(GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type)))
{
LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message --
exiting\n");
@@ -248,6 +252,14 @@
"Controller name cannot be empty -- exiting\n");
goto error;
}
+ hostname_size = ntohs (msg->hostname_size);
+ if ((sizeof (struct GNUNET_TESTBED_HelperInit) + cname_size + 1 +
+ hostname_size) >= msize)
+ {
+ GNUNET_break (0);
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message --
exiting\n");
+ goto error;
+ }
ul_config_size = (uLongf) ntohs (msg->config_size);
config = GNUNET_malloc (ul_config_size);
xconfig_size =
@@ -255,7 +267,7 @@
sizeof (struct GNUNET_TESTBED_HelperInit));
if (Z_OK !=
uncompress ((Bytef *) config, &ul_config_size,
- (const Bytef *) (controller + cname_size + 1),
+ (const Bytef *) (controller + cname_size + 1 +
hostname_size),
(uLongf) xconfig_size))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -273,7 +285,17 @@
goto error;
}
GNUNET_free (config);
- test_system = GNUNET_TESTING_system_create ("testbed-helper", controller);
+ hostname = NULL;
+ if (0 != hostname_size)
+ {
+ hostname = GNUNET_malloc (hostname_size + 1);
+ (void) strncpy (hostname, ((char *) &msg[1]) + cname_size + 1,
hostname_size);
+ hostname[hostname_size] = '\0';
+ }
+ test_system = GNUNET_TESTING_system_create ("testbed-helper", controller,
+ hostname);
+ GNUNET_free_non_null (hostname);
+ hostname = NULL;
GNUNET_assert (NULL != test_system);
GNUNET_assert (GNUNET_OK ==
GNUNET_TESTING_configuration_create (test_system, cfg));
Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-10-05 14:01:08 UTC (rev
24195)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-10-05 14:12:49 UTC (rev
24196)
@@ -538,6 +538,11 @@
*/
static struct Context *master_context;
+/**
+ * Our hostname; we give this to all the peers we start
+ */
+static char *hostname;
+
/***********/
/* Handles */
/***********/
@@ -1237,7 +1242,7 @@
master_context->master_ip = GNUNET_strdup (controller_hostname);
LOG_DEBUG ("Master Controller IP: %s\n", master_context->master_ip);
master_context->system =
- GNUNET_TESTING_system_create ("testbed", master_context->master_ip);
+ GNUNET_TESTING_system_create ("testbed", master_context->master_ip,
hostname);
host =
GNUNET_TESTBED_host_create_with_id (master_context->host_id, NULL, NULL,
0);
@@ -2832,6 +2837,7 @@
GNUNET_free (master_context);
master_context = NULL;
}
+ GNUNET_free_non_null (hostname);
}
@@ -2896,6 +2902,8 @@
{NULL}
};
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string
+ (cfg, "testbed", "HOSTNAME", &hostname));
GNUNET_SERVER_add_handlers (server, message_handlers);
GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL);
ss_map = GNUNET_CONTAINER_multihashmap_create (5);
Modified: gnunet/src/testbed/test_gnunet_helper_testbed.c
===================================================================
--- gnunet/src/testbed/test_gnunet_helper_testbed.c 2012-10-05 14:01:08 UTC
(rev 24195)
+++ gnunet/src/testbed/test_gnunet_helper_testbed.c 2012-10-05 14:12:49 UTC
(rev 24196)
@@ -212,7 +212,7 @@
&mst_cb, &exp_cb, NULL);
GNUNET_assert (NULL != helper);
cfg = GNUNET_CONFIGURATION_dup (cfg2);
- msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_name, cfg);
+ msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_name, NULL, cfg);
shandle =
GNUNET_HELPER_send (helper, &msg->header, GNUNET_NO, &cont_cb, NULL);
GNUNET_assert (NULL != shandle);
Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c 2012-10-05 14:01:08 UTC (rev 24195)
+++ gnunet/src/testbed/testbed_api.c 2012-10-05 14:12:49 UTC (rev 24196)
@@ -1338,10 +1338,12 @@
{
struct GNUNET_TESTBED_ControllerProc *cp;
struct GNUNET_TESTBED_HelperInit *msg;
+ const char *hostname;
static char *const binary_argv[] = {
HELPER_TESTBED_BINARY, NULL
};
+ hostname = NULL;
cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc));
if ((NULL == host) || (0 == GNUNET_TESTBED_host_get_id_ (host)))
cp->helper =
@@ -1352,7 +1354,6 @@
char *remote_args[8];
unsigned int argp;
const char *username;
- const char *hostname;
username = GNUNET_TESTBED_host_get_username_ (host);
hostname = GNUNET_TESTBED_host_get_hostname_ (host);
@@ -1386,7 +1387,7 @@
cp->host = host;
cp->cb = cb;
cp->cls = cls;
- msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg);
+ msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, hostname, cfg);
cp->msg = &msg->header;
cp->shandle =
GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp);
@@ -1915,12 +1916,14 @@
* want to use this in testing
*
* @param cname the ip address of the controlling host
+ * @param hostname the hostname of the destination this message is intended for
* @param cfg the configuration that has to used to start the testbed service
* thru helper
* @return the initialization message
*/
struct GNUNET_TESTBED_HelperInit *
GNUNET_TESTBED_create_helper_init_msg_ (const char *cname,
+ const char *hostname,
const struct
GNUNET_CONFIGURATION_Handle
*cfg)
{
@@ -1930,6 +1933,7 @@
size_t config_size;
size_t xconfig_size;
uint16_t cname_len;
+ uint16_t hostname_len;
uint16_t msg_size;
config = GNUNET_CONFIGURATION_serialize (cfg, &config_size);
@@ -1938,15 +1942,22 @@
GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
GNUNET_free (config);
cname_len = strlen (cname);
+ hostname_len = (NULL == hostname) ? 0 : strlen (hostname);
msg_size =
xconfig_size + cname_len + 1 + sizeof (struct GNUNET_TESTBED_HelperInit);
+ msg_size += hostname_len;
msg = GNUNET_realloc (xconfig, msg_size);
- (void) memmove (((void *) &msg[1]) + cname_len + 1, msg, xconfig_size);
+ (void) memmove (((void *) &msg[1]) + cname_len + 1 + hostname_len,
+ msg,
+ xconfig_size);
msg->header.size = htons (msg_size);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT);
msg->cname_size = htons (cname_len);
+ msg->hostname_size = htons (hostname_len);
msg->config_size = htons (config_size);
(void) strcpy ((char *) &msg[1], cname);
+ if (0 != hostname_len)
+ (void) strncpy (((char *) &msg[1]) + cname_len + 1, hostname,
hostname_len);
return msg;
}
Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h 2012-10-05 14:01:08 UTC (rev 24195)
+++ gnunet/src/testbed/testbed_api.h 2012-10-05 14:12:49 UTC (rev 24196)
@@ -356,12 +356,14 @@
* Creates a helper initialization message. Only for testing.
*
* @param cname the ip address of the controlling host
+ * @param hostname the hostname of the destination this message is intended for
* @param cfg the configuration that has to used to start the testbed service
* thru helper
* @return the initialization message
*/
struct GNUNET_TESTBED_HelperInit *
GNUNET_TESTBED_create_helper_init_msg_ (const char *cname,
+ const char *hostname,
const struct
GNUNET_CONFIGURATION_Handle
*cfg);
Modified: gnunet/src/testbed/testbed_helper.h
===================================================================
--- gnunet/src/testbed/testbed_helper.h 2012-10-05 14:01:08 UTC (rev 24195)
+++ gnunet/src/testbed/testbed_helper.h 2012-10-05 14:12:49 UTC (rev 24196)
@@ -28,6 +28,8 @@
#ifndef TESTBED_HELPER_H
#define TESTBED_HELPER_H
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Initialization message for gnunet-helper-testbed to start testbed service
*/
@@ -45,12 +47,21 @@
uint16_t cname_size GNUNET_PACKED;
/**
+ * The hostname size excluding the NULL termination character - strlen
+ * (hostname); cannot be zero
+ */
+ uint16_t hostname_size GNUNET_PACKED;
+
+ /**
* The size of the uncompressed configuration
*/
uint16_t config_size GNUNET_PACKED;
/* Followed by NULL terminated controller hostname */
+ /* Followed by hostname of the machine on which helper runs. This is not NULL
+ terminated */
+
/* Followed by serialized and compressed configuration which should be
* config_size long when un-compressed */
};
@@ -74,6 +85,8 @@
* un-compressed */
};
+GNUNET_NETWORK_STRUCT_END
+
#endif
/* end of testbed_helper.h */
Modified: gnunet/src/testing/gnunet-testing.c
===================================================================
--- gnunet/src/testing/gnunet-testing.c 2012-10-05 14:01:08 UTC (rev 24195)
+++ gnunet/src/testing/gnunet-testing.c 2012-10-05 14:12:49 UTC (rev 24196)
@@ -77,7 +77,7 @@
}
fail = GNUNET_NO;
- system = GNUNET_TESTING_system_create ("testing", NULL /* controller */);
+ system = GNUNET_TESTING_system_create ("testing", NULL /* controller */,
NULL);
for (cur = 0; cur < no; cur++)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n",
cur);
@@ -124,7 +124,7 @@
struct GNUNET_CRYPTO_RsaPrivateKey *pk;
struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb;
- system = GNUNET_TESTING_system_create ("testing", NULL);
+ system = GNUNET_TESTING_system_create ("testing", NULL, NULL);
pk = GNUNET_TESTING_hostkey_get (system, create_no, &id);
if (NULL == pk)
{
Modified: gnunet/src/testing/test_testing_peerstartup.c
===================================================================
--- gnunet/src/testing/test_testing_peerstartup.c 2012-10-05 14:01:08 UTC
(rev 24195)
+++ gnunet/src/testing/test_testing_peerstartup.c 2012-10-05 14:12:49 UTC
(rev 24196)
@@ -90,7 +90,7 @@
struct GNUNET_PeerIdentity id;
system = GNUNET_TESTING_system_create ("test-gnunet-testing",
- "127.0.0.1");
+ "127.0.0.1", NULL);
GNUNET_assert (NULL != system);
new_cfg = GNUNET_CONFIGURATION_dup (cfg);
emsg = NULL;
Modified: gnunet/src/testing/test_testing_portreservation.c
===================================================================
--- gnunet/src/testing/test_testing_portreservation.c 2012-10-05 14:01:08 UTC
(rev 24195)
+++ gnunet/src/testing/test_testing_portreservation.c 2012-10-05 14:12:49 UTC
(rev 24196)
@@ -45,7 +45,7 @@
uint16_t old_port1;
system = GNUNET_TESTING_system_create ("/tmp/gnunet-testing-new",
- "localhost");
+ "localhost", NULL);
GNUNET_assert (NULL != system);
new_port1 = GNUNET_TESTING_reserve_port (system, GNUNET_YES);
LOG (GNUNET_ERROR_TYPE_DEBUG,
Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c 2012-10-05 14:01:08 UTC (rev 24195)
+++ gnunet/src/testing/testing.c 2012-10-05 14:12:49 UTC (rev 24196)
@@ -74,6 +74,11 @@
char *controller;
/**
+ * our hostname
+ */
+ char *hostname;
+
+ /**
* Hostkeys data, contains "HOSTKEYFILESIZE * total_hostkeys" bytes.
*/
char *hostkeys_data;
@@ -262,6 +267,8 @@
* @param controller hostname of the controlling host,
* service configurations are modified to allow
* control connections from this host; can be NULL
+ * @param hostname the hostname of the system we are using for testing; NULL
for
+ * localhost
* @param lowport lowest port number this system is allowed to allocate
(inclusive)
* @param highport highest port number this system is allowed to allocate
(exclusive)
* @return handle to this system, NULL on error
@@ -269,6 +276,7 @@
struct GNUNET_TESTING_System *
GNUNET_TESTING_system_create_with_portrange (const char *testdir,
const char *controller,
+ const char *hostname,
uint16_t lowport,
uint16_t highport)
{
@@ -286,6 +294,8 @@
}
if (NULL != controller)
system->controller = GNUNET_strdup (controller);
+ if (NULL != hostname)
+ system->hostname = GNUNET_strdup (hostname);
if (GNUNET_OK != hostkeys_load (system))
{
GNUNET_TESTING_system_destroy (system, GNUNET_YES);
@@ -296,24 +306,27 @@
/**
- * Create a system handle. There must only be one system
- * handle per operating system.
+ * Create a system handle. There must only be one system handle per operating
+ * system. Uses a default range for allowed ports. Ports are still tested for
+ * availability.
*
- * @param testdir only the directory name without any path. This is used for
- * all service homes; the directory will be created in a temporary
- * location depending on the underlying OS
- *
- * @param controller hostname of the controlling host,
- * service configurations are modified to allow
- * control connections from this host; can be NULL
+ * @param testdir only the directory name without any path. This is used for
all
+ * service homes; the directory will be created in a temporary
location
+ * depending on the underlying OS
+ * @param controller hostname of the controlling host, service configurations
+ * are modified to allow control connections from this host; can be NULL
+ * @param hostname the hostname of the system we are using for testing; NULL
for
+ * localhost
* @return handle to this system, NULL on error
*/
struct GNUNET_TESTING_System *
GNUNET_TESTING_system_create (const char *testdir,
- const char *controller)
+ const char *controller,
+ const char *hostname)
{
return GNUNET_TESTING_system_create_with_portrange (testdir,
controller,
+ hostname,
LOW_PORT,
HIGH_PORT);
}
@@ -336,6 +349,7 @@
GNUNET_DISK_directory_remove (system->tmppath);
GNUNET_free (system->tmppath);
GNUNET_free_non_null (system->controller);
+ GNUNET_free_non_null (system->hostname);
GNUNET_free (system);
}
@@ -635,9 +649,9 @@
GNUNET_break(0); /* FIXME */
}
}
- if ((0 == strcmp (option, "HOSTNAME")) && (NULL != uc->system->controller))
+ if (0 == strcmp (option, "HOSTNAME"))
{
- value = uc->system->controller;
+ value = (NULL == uc->system->hostname) ? "localhost" :
uc->system->hostname;
}
GNUNET_free (single_variable);
GNUNET_free (per_host_variable);
@@ -1119,7 +1133,7 @@
struct GNUNET_CONFIGURATION_Handle *cfg;
GNUNET_log_setup (testdir, "WARNING", NULL);
- system = GNUNET_TESTING_system_create (testdir, "127.0.0.1");
+ system = GNUNET_TESTING_system_create (testdir, "127.0.0.1", NULL);
if (NULL == system)
return 1;
cfg = GNUNET_CONFIGURATION_create ();
Modified: gnunet/src/transport/transport-testing.c
===================================================================
--- gnunet/src/transport/transport-testing.c 2012-10-05 14:01:08 UTC (rev
24195)
+++ gnunet/src/transport/transport-testing.c 2012-10-05 14:12:49 UTC (rev
24196)
@@ -584,7 +584,7 @@
tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
/* Init testing the testing lib */
- tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", NULL);
+ tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", NULL,
NULL);
if (NULL == tth->tl_system)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize testing
library!\n"));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24196 - in gnunet/src: include testbed testing transport,
gnunet <=