aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-host-utils.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-09-27 00:04:12 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-09-27 00:04:12 +0800
commit2e42040bad4c8998c7c2aef3f5f34db2730245a6 (patch)
tree686fc3e3d897c50195b60518f8c81acd29227492 /e-util/e-host-utils.c
parent99c61843f0d1da7f9b3b73b99bab0e918ce99e5b (diff)
downloadgsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.tar.gz
gsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.tar.zst
gsoc2013-evolution-2e42040bad4c8998c7c2aef3f5f34db2730245a6.zip
IPv6 implementation rewritten to use getnameinfo() which is the proper
2003-09-26 Jeffrey Stedfast <fejj@ximian.com> * e-host-utils.c (e_gethostbyaddr_r): IPv6 implementation rewritten to use getnameinfo() which is the proper function to use in this case. Fixes bug #46006 the Right Way (tm). svn path=/trunk/; revision=22720
Diffstat (limited to 'e-util/e-host-utils.c')
-rw-r--r--e-util/e-host-utils.c49
1 files changed, 5 insertions, 44 deletions
diff --git a/e-util/e-host-utils.c b/e-util/e-host-utils.c
index 1d685019cc..c4057113df 100644
--- a/e-util/e-host-utils.c
+++ b/e-util/e-host-utils.c
@@ -291,47 +291,18 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host
char *buf, size_t buflen, int *herr)
{
#ifdef ENABLE_IPv6
- struct addrinfo hints, *res;
- const char *name;
int retval, len;
- if ((name = inet_ntop (type, addr, buf, buflen)) == NULL) {
- if (errno == ENOSPC)
- return ERANGE;
-
- return -1;
- }
-
- memset (&hints, 0, sizeof (struct addrinfo));
- hints.ai_flags = AI_CANONNAME;
- hints.ai_family = type == AF_INET6 ? PF_INET6 : PF_INET;
- hints.ai_socktype = 0;
- hints.ai_protocol = 0;
-
- if ((retval = getaddrinfo (name, NULL, &hints, &res)) != 0) {
+ if ((retval = getnameinfo (addr, addrlen, buf, buflen, NULL, 0, NI_NAMEREQD)) != 0) {
*herr = ai_to_herr (retval);
return -1;
}
- /* If nodename is not null, and if requested by the AI_CANONNAME flag, the ai_canonname
- * field of the first returned addrinfo structure shall point to a null-terminated
- * string containing the canonical name corresponding to the input nodename; if the
- * canonical name is not available, then ai_canonname shall refer to the nodename
- * argument or a string with the same contents.
- *
- * Note: NetBSD seems to set res->ai_canonname to NULL in this case instead.
- */
- if (!res->ai_canonname || !strcmp (res->ai_canonname, name)) {
- *herr = HOST_NOT_FOUND;
- return -1;
- }
-
- len = ALIGN (strlen (res->ai_canonname) + 1);
- if (buflen < IPv6_BUFLEN_MIN + len + res->ai_addrlen + sizeof (char *))
+ len = ALIGN (strlen (buf) + 1);
+ if (buflen < IPv6_BUFLEN_MIN + len + addrlen + sizeof (char *))
return ERANGE;
/* h_name */
- strcpy (buf, res->ai_canonname);
host->h_name = buf;
buf += len;
@@ -341,16 +312,8 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host
buf += sizeof (char *);
/* h_addrtype and h_length */
- host->h_length = res->ai_addrlen;
- if (res->ai_family == PF_INET6) {
- host->h_addrtype = AF_INET6;
-
- addr = (char *) &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
- } else {
- host->h_addrtype = AF_INET;
-
- addr = (char *) &((struct sockaddr_in *) res->ai_addr)->sin_addr;
- }
+ host->h_length = addrlen;
+ host->h_addrtype = type;
memcpy (buf, addr, host->h_length);
addr = buf;
@@ -361,8 +324,6 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host
((char **) buf)[1] = NULL;
host->h_addr_list = (char **) buf;
- freeaddrinfo (res);
-
return 0;
#else /* No support for IPv6 addresses */
#ifdef HAVE_GETHOSTBYADDR_R
0.10-removal&id=071186fd6d22f1abd16554cae92bf26af9d1cb4e'>- convert USE_CMAKE to USESmakc2013-03-231-1/+1 * Bump PORTREVISION after DESKTOP_ENTRIES updatemakc2013-01-231-0/+1 * - Update to 1.2.1madpilot2013-01-191-6/+2 * - Update to 1.2.0madpilot2012-08-041-2/+2 * - Convert USE_QT_VER=4 and QT_COMPONETS to USE_QT4miwi2012-06-061-2/+1 * - update png to 1.5.10dinoex2012-06-011-0/+1 * - Update to 1.1.1beech2011-09-161-3/+3 * Update to 1.1.0makc2011-05-081-12/+8 * Update to 1.0.2makc2010-05-111-1/+1