}
static void
-check_local_hostname(void *cls, const char *hostname)
+check_local_fqdn(void *cls, const char *gnunet_fqdn)
{
int result = 0;
- char own_hostname[GNUNET_OS_get_hostname_max_length() + 1];
+ struct hostent *host;
+ char hostname[GNUNET_OS_get_hostname_max_length() + 1];
+
+ if (0 != gethostname (hostname, sizeof (hostname) - 1))
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR |
+ GNUNET_ERROR_TYPE_BULK, "gethostname");
+ return;
+ }
#if DEBUG_RESOLVER
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Hostname resolved here is `%s'.\n", own_hostname);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Hostname resolved using resolver is `%s'.\n", hostname);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Resolving our FQDN `%s'\n"), hostname);
#endif
-
- result = gethostname (own_hostname, sizeof (own_hostname) - 1);
-
- if ( 0 != result )
+ host = gethostbyname ( hostname );
+ if ( NULL == host)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not resolve local hostname\n", own_hostname);
+ _("Could not resolve our FQDN : %s %u\n"),
+ hstrerror (h_errno), h_errno);
+ return;
}
- GNUNET_assert( 0 == result);
- result = strcmp(hostname, own_hostname);
+ GNUNET_assert( 0 != host);
+
+ result = strcmp(host->h_name, gnunet_fqdn);
if ( 0 != result )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Local resolved and resolver resolved hostnames are not equal\n", own_hostname);
+ "Local resolved and resolver resolved fqdns are not equal\n");
}
GNUNET_assert( 0 == result);
}
+
static void
check_rootserver_ip(void *cls, const struct sockaddr *sa, socklen_t salen)
{
struct GNUNET_TIME_Relative timeout = GNUNET_TIME_relative_multiply(
GNUNET_TIME_UNIT_MILLISECONDS, 2500);
int count_ips = 0;
- char * own_hostname;
+ char * own_fqdn;
memset(&sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
GNUNET_RESOLVER_hostname_resolve(sched, cfg, AF_UNSPEC, timeout,
&check_hostname, cls);
+
/*
- * Looking up our own hostname
+ * Looking up our own fqdn
*/
- own_hostname = GNUNET_RESOLVER_local_hostname_get();
- check_local_hostname( NULL, own_hostname);
- GNUNET_free (own_hostname);
+ own_fqdn = GNUNET_RESOLVER_local_fqdn_get();
+ check_local_fqdn( NULL, own_fqdn);
+ GNUNET_free_non_null (own_fqdn);
/*
* Testing non-local DNS resolution
_("gethostbyname() could not lookup IP address: %s\n"),
hstrerror (h_errno));
#endif
- GNUNET_break(0);
+ fprintf (stderr,
+ "System seems to be off-line, will not run all DNS tests\n");
return;
}
memset(&sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
+#ifndef MINGW
inet_aton(ROOTSERVER_IP, &sa.sin_addr);
-
+#else
+ sa.sin_addr.S_un.S_addr = inet_addr(ROOTSERVER_IP);
+#endif
GNUNET_RESOLVER_hostname_get(sched, cfg, (const struct sockaddr *) &sa,
sizeof(struct sockaddr), GNUNET_YES, timeout, &check_rootserver_name, cls);
}