+ static const char funcname[]="gethostbyaddr";
+
+ h = gethostbyaddr((char *)&Addr->sin_addr, sizeof(Addr->sin_addr), AF_INET);
+ if (h) {
+ if (strlcpy(resbuf, h->h_name, reslen) < reslen)
+ return true;
+ errmsg = "hostname too long";
+ } else {
+# ifdef h_errno
+ errmsg = Get_Error(h_errno);
+# else
+ errmsg = "unknown error";
+# endif /* h_errno */
+ }
+#endif /* HAVE_GETNAMEINFO */
+
+ assert(errmsg);
+ assert(reslen >= NG_INET_ADDRSTRLEN);
+ ng_ipaddr_tostr_r(IpAddr, tmp_ip_str);
+
+ Log_Subprocess(LOG_WARNING, "%s: Can't resolve address \"%s\": %s",
+ funcname, tmp_ip_str, errmsg);
+ strlcpy(resbuf, tmp_ip_str, reslen);
+ return false;
+}
+
+
+/**
+ * perform DNS lookup of given host name and fill IpAddr with a list of
+ * ip addresses associated with that name.
+ * ip addresses found are stored in the "array *IpAddr" argument (type ng_ipaddr_t)
+ * @param hostname The domain name to look up.
+ * @param IpAddr pointer to empty and initialized array to store results
+ * @return true if lookup successful, false if domain name not found
+ */
+static bool
+ForwardLookup(const char *hostname, array *IpAddr, int af)
+{
+ ng_ipaddr_t addr;
+
+#ifdef HAVE_GETADDRINFO
+ int res;
+ struct addrinfo *a, *ai_results;
+ static struct addrinfo hints;