-static int
-check ()
-{
- int ok = 1 + 2 + 4 + 8;
- char *fn;
- pid_t pid;
- char *const argv[] = { "test-resolver-api",
- "-c",
- "test_resolver_api_data.conf",
-#if VERBOSE
- "-L", "DEBUG",
-#endif
- NULL
- };
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
- GNUNET_asprintf(&fn, "%s%cgnunet-service-resolver.exe",
- GNUNET_OS_installation_get_path(GNUNET_OS_IPK_BINDIR),
- DIR_SEPARATOR);
- pid = GNUNET_OS_start_process (fn,
- "gnunet-service-resolver",
-#if VERBOSE
- "-L", "DEBUG",
-#endif
- "-c", "test_resolver_api_data.conf", NULL);
- GNUNET_free (fn);
- GNUNET_assert (GNUNET_OK == GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
- argv, "test-resolver-api", "nohelp",
- options, &run, &ok));
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ /*
+ * Looking up our own fqdn
+ */
+ own_fqdn = GNUNET_RESOLVER_local_fqdn_get ();
+ /* can't really check, only thing we can safely
+ compare against is our own identical logic... */
+ GNUNET_free_non_null (own_fqdn);
+
+ /*
+ * Testing non-local DNS resolution
+ * DNS rootserver to test: a.root-servers.net - 198.41.0.4
+ */
+
+ rootserver = gethostbyname (rootserver_name);
+ if (NULL == rootserver)
+ {
+ /* Error: resolving ip addresses does not work */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("gethostbyname() could not lookup IP address: %s\n"),
+ hstrerror (h_errno));
+ FPRINTF (stderr,
+ "%s",
+ "System seems to be off-line, will not run all DNS tests\n");
+ *ok = 0; /* mark test as passing anyway */
+ return;
+ }
+
+ /* Counting returned IP addresses */
+ while (NULL != rootserver->h_addr_list[count_ips])
+ count_ips++;
+ if (count_ips > 1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "IP received range for root name server, but a root name server has only 1 IP\n");
+ GNUNET_break (0);
+ }
+
+ /* Comparing to resolved address to the address the root name server should have */
+ if (0 !=
+ strcmp (inet_ntoa (*(struct in_addr *) rootserver->h_addr_list[0]),
+ ROOTSERVER_IP))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "IP received and IP for root name server differ\n");
+ GNUNET_break (0);
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "System's own forward name resolution is working\n");
+ /* Resolve the same using GNUNET */
+ GNUNET_RESOLVER_ip_get (ROOTSERVER_NAME, AF_INET, timeout,
+ &check_rootserver_ip, cls);
+ GNUNET_RESOLVER_ip_get (ROOTSERVER_NAME, AF_INET, timeout,
+ &check_rootserver_ip, cls);
+
+ /*
+ * Success: forward lookups work as expected
+ * Next step: reverse lookups
+ */
+ if (1 != inet_pton (AF_INET,
+ ROOTSERVER_IP,
+ &rootserver_addr))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Could not transform root name server IP address\n");
+ GNUNET_break (0);
+ }
+
+ rootserver =
+ gethostbyaddr ((const void *) &rootserver_addr,
+ sizeof (rootserver_addr),
+ AF_INET);
+ if (NULL == rootserver)
+ {
+ /* Error: resolving IP addresses does not work */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "gethostbyaddr() could not lookup hostname: %s\n",
+ hstrerror (h_errno));
+ disable_rootserver_check = GNUNET_YES;
+ }
+ else
+ {
+ if (0 != strcmp (rootserver->h_name,
+ ROOTSERVER_NAME))