1 2003-09-26 Jeffrey Stedfast <fejj@ximian.com>
3 * e-host-utils.c (e_gethostbyaddr_r): IPv6 implementation
4 rewritten to use getnameinfo() which is the proper function to use
5 in this case. Fixes bug #46006.
8 ===================================================================
9 RCS file: /cvs/gnome/evolution/e-util/e-host-utils.c,v
10 retrieving revision 1.14
11 diff -u -r1.14 e-host-utils.c
12 --- e-util/e-host-utils.c 29 Apr 2003 02:14:37 -0000 1.14
13 +++ e-util/e-host-utils.c 26 Sep 2003 15:51:10 -0000
15 char *buf, size_t buflen, int *herr)
18 - struct addrinfo hints, *res;
22 - if ((name = inet_ntop (type, addr, buf, buflen)) == NULL) {
23 - if (errno == ENOSPC)
29 - memset (&hints, 0, sizeof (struct addrinfo));
30 - hints.ai_flags = AI_CANONNAME;
31 - hints.ai_family = type == AF_INET6 ? PF_INET6 : PF_INET;
32 - hints.ai_socktype = 0;
33 - hints.ai_protocol = 0;
35 - if ((retval = getaddrinfo (name, NULL, &hints, &res)) != 0) {
36 + if ((retval = getnameinfo (addr, addrlen, buf, buflen, NULL, 0, NI_NAMEREQD)) != 0) {
37 *herr = ai_to_herr (retval);
41 - len = ALIGN (strlen (res->ai_canonname) + 1);
42 - if (buflen < IPv6_BUFLEN_MIN + len + res->ai_addrlen + sizeof (char *))
43 + len = ALIGN (strlen (buf) + 1);
44 + if (buflen < IPv6_BUFLEN_MIN + len + addrlen + sizeof (char *))
48 - strcpy (buf, res->ai_canonname);
53 buf += sizeof (char *);
55 /* h_addrtype and h_length */
56 - host->h_length = res->ai_addrlen;
57 - if (res->ai_family == PF_INET6) {
58 - host->h_addrtype = AF_INET6;
60 - addr = (char *) &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
62 - host->h_addrtype = AF_INET;
64 - addr = (char *) &((struct sockaddr_in *) res->ai_addr)->sin_addr;
66 + host->h_length = addrlen;
67 + host->h_addrtype = type;
69 memcpy (buf, addr, host->h_length);
72 ((char **) buf)[0] = addr;
73 ((char **) buf)[1] = NULL;
74 host->h_addr_list = (char **) buf;
79 #else /* No support for IPv6 addresses */