-static int
-check ()
-{
- int ok = 1 + 2 + 4 + 8;
- char *fn;
- char *pfx;
- 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
- };
- pfx = GNUNET_OS_installation_get_path(GNUNET_OS_IPK_BINDIR);
- GNUNET_asprintf(&fn, "%s%cgnunet-service-resolver",
- pfx,
- DIR_SEPARATOR);
- GNUNET_free (pfx);
- pid = GNUNET_OS_start_process (NULL, NULL, 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 ();
+ check_local_fqdn (NULL, own_fqdn);
+ GNUNET_free_non_null (own_fqdn);
+
+ /*
+ * Testing non-local DNS resolution
+ * DNS rootserver to test: a.root-servers.net - 198.41.0.4
+ */
+ const char *rootserver_name = ROOTSERVER_NAME;
+ struct hostent *rootserver;
+
+ rootserver = gethostbyname (rootserver_name);
+ if (rootserver == NULL)
+ {
+ /* 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 (rootserver->h_addr_list[count_ips] != NULL)
+ 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 (strcmp
+ (inet_ntoa (*(struct in_addr *) rootserver->h_addr_list[0]),
+ ROOTSERVER_IP) != 0)
+ {
+ 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);
+
+ /*
+ * Success: forward lookups work as expected
+ * Next step: reverse lookups
+ */
+
+ struct in_addr rootserver_addr;
+
+ rootserver->h_name = "";
+ 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 (&rootserver_addr, sizeof (rootserver_addr), AF_INET);
+ if (rootserver == NULL)
+ {
+ /* Error: resolving IP addresses does not work */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("gethostbyaddr() could not lookup hostname: %s\n"),
+ hstrerror (h_errno));
+ GNUNET_break (0);
+ }
+ else
+ {
+ if (0 != strcmp (rootserver->h_name, ROOTSERVER_NAME))