- h = gethostbyaddr( (char *)&Addr->sin_addr, sizeof( Addr->sin_addr ), AF_INET );
- if (!h) {
-#ifdef h_errno
- Log_Resolver( LOG_WARNING, "Can't resolve address \"%s\": %s!", inet_ntoa( Addr->sin_addr ), Get_Error( h_errno ));
+ if (!res) /* no result */
+ return;
+ if (!array_cats(resolved_addr, res))
+ Log_Resolver(LOG_WARNING, "Resolver: Cannot copy IDENT result: %s!", strerror(errno));
+
+ free(res);
+#else
+ (void) identsock;
+ (void) resolved_addr;
+#endif
+}
+
+
+/**
+ * perform reverse DNS lookup and put result string into resbuf.
+ * If no hostname could be obtained, this function stores the string representation of
+ * the IP address in resbuf and returns false.
+ * @param IpAddr ip address to resolve
+ * @param resbuf result buffer to store DNS name/string representation of ip address
+ * @param reslen size of result buffer (must be >= NGT_INET_ADDRSTRLEN)
+ * @return true if reverse lookup successful, false otherwise
+ */
+static bool
+ReverseLookup(const ng_ipaddr_t *IpAddr, char *resbuf, size_t reslen)
+{
+ char tmp_ip_str[NG_INET_ADDRSTRLEN];
+ const char *errmsg;
+#ifdef HAVE_GETNAMEINFO
+ static const char funcname[]="getnameinfo";
+ int res;
+
+ *resbuf = 0;
+
+ res = getnameinfo((struct sockaddr *) IpAddr, ng_ipaddr_salen(IpAddr),
+ resbuf, (socklen_t)reslen, NULL, 0, NI_NAMEREQD);
+ if (res == 0)
+ return true;
+
+ if (res == EAI_SYSTEM)
+ errmsg = strerror(errno);
+ else
+ errmsg = gai_strerror(res);