+#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)
+{
+ ng_ipaddr_t addr;
+
+#ifdef HAVE_GETADDRINFO
+ int res;
+ struct addrinfo *a, *ai_results;
+ static struct addrinfo hints;
+
+#ifndef WANT_IPV6
+ hints.ai_family = AF_INET;
+#endif
+#ifdef AI_ADDRCONFIG /* glibc has this, but not e.g. netbsd 4.0 */
+ hints.ai_flags = AI_ADDRCONFIG;
+#endif
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+
+#ifdef WANT_IPV6
+ assert(Conf_ConnectIPv6 || Conf_ConnectIPv4);