aboutsummaryrefslogtreecommitdiffstats
path: root/driver.c
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2005-07-03 21:50:16 +0000
committerMatthias Andree <matthias.andree@gmx.de>2005-07-03 21:50:16 +0000
commit506cc73eb32fd40ad34e1e2e093b99c87a6ac2e1 (patch)
tree665942ca18806939724b5f79854463b4e823e23d /driver.c
parent0881df42aeb7104a7197f26938819204ad6d5712 (diff)
downloadfetchmail-506cc73eb32fd40ad34e1e2e093b99c87a6ac2e1.tar.gz
fetchmail-506cc73eb32fd40ad34e1e2e093b99c87a6ac2e1.tar.bz2
fetchmail-506cc73eb32fd40ad34e1e2e093b99c87a6ac2e1.zip
Use getaddrinfo to canonicalize hostnames if INET6_ENABLE. Patch by Matthias Andree.
svn path=/trunk/; revision=4078
Diffstat (limited to 'driver.c')
-rw-r--r--driver.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/driver.c b/driver.c
index f507b135..0bdd0371 100644
--- a/driver.c
+++ b/driver.c
@@ -28,6 +28,9 @@
#include <sys/wait.h>
#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
#ifdef HAVE_NET_SOCKET_H
#include <net/socket.h>
#endif
@@ -1005,8 +1008,35 @@ static int do_session(
}
else
{
+#ifdef INET6_ENABLE
+ struct addrinfo hints, *res;
+ int error;
+
+ memset(&hints, sizeof(hints), 0);
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_flags = AI_CANONNAME;
+
+ error = getaddrinfo(ctl->server.queryname, NULL, &hints, &res);
+ if (error)
+ {
+ report(stderr,
+ GT_("couldn't find canonical DNS name of %s (%s)\n"),
+ ctl->server.pollname, ctl->server.queryname);
+ err = PS_DNS;
+ set_timeout(0);
+ phase = oldphase;
+ goto closeUp;
+ }
+ else
+ {
+ ctl->server.truename=xstrdup(res->ai_canonname);
+ ctl->server.trueaddr=xmalloc(res->ai_addrlen);
+ memcpy(ctl->server.trueaddr, res->ai_addr, res->ai_addrlen);
+ }
+#else
struct hostent *namerec;
-
+
/*
* Get the host's IP, so we can report it like this:
*
@@ -1032,6 +1062,7 @@ static int do_session(
namerec->h_addr_list[0],
namerec->h_length);
}
+#endif
}
}
#endif /* HAVE_GETHOSTBYNAME */