handle errors better
[oweals/gnunet.git] / src / util / resolver_api.c
index f4844a490ef8aec20bd0ca0506033cbb529a4018..430c4ebae721b18d4e288c58b556960bcd5d8f6e 100644 (file)
@@ -225,7 +225,6 @@ handle_address_response (void *cls, const struct GNUNET_MessageHeader *msg)
   const struct sockaddr *sa;
   socklen_t salen;
 
-
   if (msg == NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -669,13 +668,13 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched,
 
 
 /**
- * Get local hostname
- * @return hostname
+ * Get local fully qualified domain name
+ * @return fqdn
  */
 char *
-GNUNET_RESOLVER_local_hostname_get ( )
+GNUNET_RESOLVER_local_fqdn_get ( void )
 {
-
+  struct hostent *host;
   char hostname[GNUNET_OS_get_hostname_max_length() + 1];
 
 
@@ -687,9 +686,17 @@ GNUNET_RESOLVER_local_hostname_get ( )
     }
 #if DEBUG_RESOLVER
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              _("Resolving our hostname `%s'\n"), hostname);
+              _("Resolving our FQDN `%s'\n"), hostname);
 #endif
-  return GNUNET_strdup (hostname);
+  host = gethostbyname ( hostname );
+  if ( NULL == host)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                _("Could not resolve our FQDN : %s\n"),
+                hstrerror (h_errno));
+    return NULL;
+  }
+  return GNUNET_strdup (host->h_name);
 }
 
 /**