diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2005-07-03 21:50:16 +0000 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2005-07-03 21:50:16 +0000 |
commit | 506cc73eb32fd40ad34e1e2e093b99c87a6ac2e1 (patch) | |
tree | 665942ca18806939724b5f79854463b4e823e23d /driver.c | |
parent | 0881df42aeb7104a7197f26938819204ad6d5712 (diff) | |
download | fetchmail-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.c | 33 |
1 files changed, 32 insertions, 1 deletions
@@ -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 */ |