summaryrefslogtreecommitdiff
path: root/src/core/network.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/network.c')
-rw-r--r--src/core/network.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/core/network.c b/src/core/network.c
index e034e609..5a6e276a 100644
--- a/src/core/network.c
+++ b/src/core/network.c
@@ -340,7 +340,7 @@ int net_gethostbyname(const char *addr, IPADDR *ip)
freeaddrinfo(ai);
#else
hp = gethostbyname(addr);
- if (hp == NULL) return -1;
+ if (hp == NULL) return h_errno;
ip->family = AF_INET;
memcpy(&ip->addr, hp->h_addr, 4);
@@ -467,7 +467,7 @@ const char *net_gethosterror(int error)
return gai_strerror(error);
#else
- switch (h_errno) {
+ switch (error) {
case HOST_NOT_FOUND:
return _("Host not found");
case NO_ADDRESS:
@@ -483,6 +483,17 @@ const char *net_gethosterror(int error)
#endif
}
+/* return TRUE if host lookup failed because it didn't exist (ie. not
+ some error with name server) */
+int net_hosterror_notfound(int error)
+{
+#ifdef HAVE_IPV6
+ return error != 1 && (error == EAI_NONAME || error == EAI_NODATA);
+#else
+ return error == HOST_NOT_FOUND || error == NO_ADDRESS;
+#endif
+}
+
int is_ipv4_address(const char *host)
{
while (*host != '\0') {