return 0;
}
+int net_gethostbyaddr(const struct ip_addr *ip, const char **name_r)
+{
+ union sockaddr_union so;
+ socklen_t addrlen = sizeof(so);
+ char hbuf[NI_MAXHOST];
+ int ret;
+
+ memset(&so, 0, sizeof(so));
+ sin_set_ip(&so, ip);
+ ret = getnameinfo(&so.sa, addrlen, hbuf, sizeof(hbuf), NULL, 0,
+ NI_NAMEREQD);
+ if (ret != 0)
+ return ret;
+
+ *name_r = t_strdup(hbuf);
+ return 0;
+}
+
int net_getsockname(int fd, struct ip_addr *addr, unsigned int *port)
{
union sockaddr_union so;
to be free'd. Returns 0 = ok, others = error code for net_gethosterror() */
int net_gethostbyname(const char *addr, struct ip_addr **ips,
unsigned int *ips_count);
+/* Return host for the IP address. Returns 0 = ok, others = error code for
+ net_gethosterror(). */
+int net_gethostbyaddr(const struct ip_addr *ip, const char **name_r);
/* get error of net_gethostname() */
const char *net_gethosterror(int error) ATTR_CONST;
/* return TRUE if host lookup failed because it didn't exist (ie. not