aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/gnunet-helper-testbed.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-05-17 08:04:15 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-05-17 08:04:15 +0000
commitc47979fd1c48558a4981ca853348d8b8d4c4197d (patch)
tree0d367426aad8ca31d8f2ad384c5c4a0e173577b3 /src/testbed/gnunet-helper-testbed.c
parenta4eea61eb191e8151ec0e2be01e4ec41b88ad062 (diff)
downloadgnunet-c47979fd1c48558a4981ca853348d8b8d4c4197d.tar.gz
gnunet-c47979fd1c48558a4981ca853348d8b8d4c4197d.zip
- revert 27109,27108
Diffstat (limited to 'src/testbed/gnunet-helper-testbed.c')
-rw-r--r--src/testbed/gnunet-helper-testbed.c58
1 files changed, 1 insertions, 57 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));