aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/gnunet-helper-testbed.c58
-rw-r--r--src/testbed/testbed_api_hosts.c6
2 files changed, 2 insertions, 62 deletions
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c
index 43766796e..be9154fdc 100644
--- a/src/testbed/gnunet-helper-testbed.c
+++ b/src/testbed/gnunet-helper-testbed.c
@@ -58,12 +58,6 @@
58#define LOG_DEBUG(...) \ 58#define LOG_DEBUG(...) \
59 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) 59 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
60 60
61/**
62 * Log an error message at log-level 'level' that indicates a failure of the
63 * command 'cmd' with the message given by gai_strerror(rc).
64 */
65#define LOG_GAI(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gai_strerror(rc)); } while(0)
66
67 61
68/** 62/**
69 * We need pipe control only on WINDOWS 63 * We need pipe control only on WINDOWS
@@ -319,48 +313,6 @@ child_death_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
319 313
320 314
321/** 315/**
322 * Resolves a hostname using getaddrinfo
323 *
324 * @param host the hostname
325 * @return the string representing the IPv4 address of the given host; NULL upon error
326 */
327const char *
328simple_resolve (const char *host)
329{
330 struct addrinfo *res;
331 const struct sockaddr_in *in_addr;
332 char *hostip;
333 struct addrinfo hint;
334 unsigned int rc;
335
336 hint.ai_family = AF_INET; /* IPv4 */
337 hint.ai_socktype = 0;
338 hint.ai_protocol = 0;
339 hint.ai_addrlen = 0;
340 hint.ai_addr = NULL;
341 hint.ai_canonname = NULL;
342 hint.ai_next = NULL;
343 hint.ai_flags = AI_NUMERICSERV;
344 res = NULL;
345 LOG_DEBUG ("Resolving [%s]\n", host);
346 if (0 != (rc = getaddrinfo (host, "22", &hint, &res)))
347 {
348 LOG_GAI (GNUNET_ERROR_TYPE_ERROR, "getaddrinfo", rc);
349 return NULL;
350 }
351 GNUNET_assert (NULL != res);
352 GNUNET_assert (NULL != res->ai_addr);
353 GNUNET_assert (sizeof (struct sockaddr_in) == res->ai_addrlen);
354 in_addr = (const struct sockaddr_in *) res->ai_addr;
355 hostip = inet_ntoa (in_addr->sin_addr);
356 GNUNET_assert (NULL != hostip);
357 freeaddrinfo (res);
358 LOG_DEBUG ("Resolved [%s] to [%s]\n", host, hostip);
359 return hostip;
360}
361
362
363/**
364 * Functions with this signature are called whenever a 316 * Functions with this signature are called whenever a
365 * complete message is received by the tokenizer. 317 * complete message is received by the tokenizer.
366 * 318 *
@@ -383,7 +335,6 @@ tokenizer_cb (void *cls, void *client,
383 char *binary; 335 char *binary;
384 char *trusted_ip; 336 char *trusted_ip;
385 char *hostname; 337 char *hostname;
386 const char *hostip;
387 char *config; 338 char *config;
388 char *xconfig; 339 char *xconfig;
389 size_t config_size; 340 size_t config_size;
@@ -449,17 +400,10 @@ tokenizer_cb (void *cls, void *client,
449 hostname_size); 400 hostname_size);
450 hostname[hostname_size] = '\0'; 401 hostname[hostname_size] = '\0';
451 } 402 }
452 hostip = NULL;
453 if ( (NULL != hostname) && (NULL == (hostip = simple_resolve (hostname))) )
454 {
455 GNUNET_free (hostname);
456 hostname = NULL;
457 }
458 test_system = 403 test_system =
459 GNUNET_TESTING_system_create ("testbed-helper", trusted_ip, hostip, NULL); 404 GNUNET_TESTING_system_create ("testbed-helper", trusted_ip, hostname, NULL);
460 GNUNET_free_non_null (hostname); 405 GNUNET_free_non_null (hostname);
461 hostname = NULL; 406 hostname = NULL;
462 hostip = NULL;
463 GNUNET_assert (NULL != test_system); 407 GNUNET_assert (NULL != test_system);
464 GNUNET_assert (GNUNET_OK == 408 GNUNET_assert (GNUNET_OK ==
465 GNUNET_TESTING_configuration_create (test_system, cfg)); 409 GNUNET_TESTING_configuration_create (test_system, cfg));
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 4b9d12f80..40e9e5be4 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -1062,7 +1062,6 @@ helper_mst (void *cls, void *client, const struct GNUNET_MessageHeader *message)
1062 struct GNUNET_TESTBED_ControllerProc *cp = cls; 1062 struct GNUNET_TESTBED_ControllerProc *cp = cls;
1063 const struct GNUNET_TESTBED_HelperReply *msg; 1063 const struct GNUNET_TESTBED_HelperReply *msg;
1064 const char *hostname; 1064 const char *hostname;
1065 const char *hostip;
1066 char *config; 1065 char *config;
1067 uLongf config_size; 1066 uLongf config_size;
1068 uLongf xconfig_size; 1067 uLongf xconfig_size;
@@ -1090,12 +1089,9 @@ helper_mst (void *cls, void *client, const struct GNUNET_MessageHeader *message)
1090 if ((NULL == cp->host) || 1089 if ((NULL == cp->host) ||
1091 (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host)))) 1090 (NULL == (hostname = GNUNET_TESTBED_host_get_hostname (cp->host))))
1092 hostname = "localhost"; 1091 hostname = "localhost";
1093 hostip = simple_resolve (hostname);
1094 if (NULL == hostip)
1095 hostip = "127.0.0.1";
1096 /* Change the hostname so that we can connect to it */ 1092 /* Change the hostname so that we can connect to it */
1097 GNUNET_CONFIGURATION_set_value_string (cp->host->cfg, "testbed", "hostname", 1093 GNUNET_CONFIGURATION_set_value_string (cp->host->cfg, "testbed", "hostname",
1098 hostip); 1094 hostname);
1099 cp->host->locked = GNUNET_NO; 1095 cp->host->locked = GNUNET_NO;
1100 cp->host->controller_started = GNUNET_YES; 1096 cp->host->controller_started = GNUNET_YES;
1101 cp->cb (cp->cls, cp->host->cfg, GNUNET_OK); 1097 cp->cb (cp->cls, cp->host->cfg, GNUNET_OK);