1 --- XFree86-3.3.3.1/xc/lib/SM/sm_genid.c.ipv6 Sun Oct 4 16:36:38 1998
2 +++ XFree86-3.3.3.1/xc/lib/SM/sm_genid.c Thu Jun 24 12:39:44 1999
4 #define XOS_USE_NO_LOCKING
5 #define X_INCLUDE_NETDB_H
13 #if defined(TCPCONN) || defined(STREAMSCONN)
17 char temp[4], *ptr1, *ptr2;
18 unsigned char decimal[4];
20 _Xgethostbynameparams hparams;
21 struct hostent *hostp;
23 - if ((hostp = _XGethostbyname (hostname,hparams)) != NULL)
24 + if ((_res.options & RES_INIT) == 0)
26 + options = _res.options;
27 + _res.options &= ~RES_USE_INET6;
28 + hostp = _XGethostbyname (hostname,hparams);
29 + _res.options = options;
31 inet_addr = inet_ntoa (*(struct in_addr *)(hostp->h_addr));
34 --- XFree86-3.3.3.1/xc/lib/X11/ConnDis.c.ipv6 Sat Jan 18 07:51:49 1997
35 +++ XFree86-3.3.3.1/xc/lib/X11/ConnDis.c Thu Jun 24 12:39:45 1999
38 if (!lastc) return NULL; /* must have a colon */
40 - if ((lastp != lastc) && (*(lastc - 1) == ':')) {
41 + /* :: is DECnet, : and ::: are IPv6 */
42 + if ((lastp != lastc) && (*(lastc - 1) == ':') &&
43 + (lastp == lastc-1 || *(lastc - 2) != ':') ) {
44 /* DECnet display specified */
48 _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr);
51 - * The family is given in a socket format (ie AF_INET). This
52 + * The family is given in a socket format (ie AF_INET[6]). This
53 * will convert it to the format used by the authorization and
54 * X protocol (ie FamilyInternet).
56 @@ -1026,6 +1028,21 @@
57 for(i=4; i<8; i++) /* do sin_addr */
58 xdmcp_data[j++] = ((char *)addr)[i];
59 for(i=2; i<4; i++) /* do sin_port */
60 + xdmcp_data[j++] = ((char *)addr)[i];
68 + * addr will contain a sockaddr_in6 with all
69 + * of the members already in network byte order.
72 + for(i=20; i<24; i++) /* do sin6_addr last 4 bytes */
73 + xdmcp_data[j++] = ((char *)addr)[i];
74 + for(i=2; i<4; i++) /* do sin6_port */
75 xdmcp_data[j++] = ((char *)addr)[i];
78 --- XFree86-3.3.3.1/xc/lib/X11/Imakefile.ipv6 Fri Nov 6 17:32:30 1998
79 +++ XFree86-3.3.3.1/xc/lib/X11/Imakefile Thu Jun 24 12:39:46 1999
81 InstallLintLibrary(X11,$(LINTLIBDIR))
84 +SpecialCLibObjectRule(AuGetBest,$(ICONFIGFILES),$(CONN_DEFINES))
85 LinkSourceFile(AuDispose.c,$(XAUTHSRC))
86 LinkSourceFile(AuGetBest.c,$(XAUTHSRC))
87 LinkSourceFile(AuFileName.c,$(XAUTHSRC))
88 --- XFree86-3.3.3.1/xc/lib/Xau/AuGetBest.c.ipv6 Sun Dec 22 04:20:12 1996
89 +++ XFree86-3.3.3.1/xc/lib/Xau/AuGetBest.c Thu Jun 24 12:39:46 1999
95 +#include <netinet/in.h>
97 +#define MAPTOIPV4(a) ((char *)(a) + sizeof(struct in6_addr) - \
98 + sizeof(struct in_addr))
99 +#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
101 +inetMapEqual (a4, l4, a6, l6)
105 + /* compare IPv4 with special IPv6 : mapped, loopback */
106 + if (l4 == sizeof(struct in6_addr) && l6 == sizeof(struct in_addr)) {
110 + } else if (l6 != sizeof(struct in6_addr) || l4 != sizeof(struct in_addr))
112 + if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)a6))
113 + return !acmp(a4, MAPTOIPV4(a6), sizeof(*a4));
115 + return (a4[0] == 127 && a4[1] == 0 && a4[2] == 0 && a4[3] == 1 &&
116 + acmp(a6, &in6addr_loopback, sizeof(*a6)) == 0);
120 #if NeedFunctionPrototypes
122 XauGetBestAuthByAddr (
124 (entry->family == family &&
125 ((address_length == entry->address_length &&
126 binaryEqual (entry->address, address, (int)address_length))
127 +#if defined(TCPCONN)
128 + || (family == FamilyInternet &&
129 + address_length != entry->address_length &&
130 + inetMapEqual ((char *)entry->address,
131 + (int)entry->address_length,
132 + (char *)address, (int)address_length))
135 || (family == FamilyLocal &&
136 fully_qual_address_length == entry->address_length &&
137 --- XFree86-3.3.3.1/xc/lib/Xau/Imakefile.ipv6 Fri Nov 6 17:32:44 1998
138 +++ XFree86-3.3.3.1/xc/lib/Xau/Imakefile Thu Jun 24 12:39:46 1999
143 + CONN_DEFINES = ConnectionFlags
144 + DEPEND_DEFINES = $(CONN_DEFINES)
150 AuRead.o AuUnlock.o AuWrite.o $(K5ENCOBJ)
152 #include <Library.tmpl>
154 +SpecialCLibObjectRule(AuGetBest,$(ICONFIGFILES),$(CONN_DEFINES))
156 InstallLinkKitLibrary(Xau,$(LINKKITDIR)/lib)
158 --- XFree86-3.3.3.1/xc/lib/Xmu/CvtStdSel.c.ipv6 Sat Jan 18 07:52:13 1997
159 +++ XFree86-3.3.3.1/xc/lib/Xmu/CvtStdSel.c Thu Jun 24 12:39:47 1999
161 if ((hostp = _XGethostbyname (hostname,hparams)) == NULL)
164 - if (hostp->h_addrtype != AF_INET) return False;
165 + if ((hostp->h_addrtype != AF_INET) &&
166 + (hostp->h_addrtype != AF_INET6))
168 *length = hostp->h_length;
169 *value = XtMalloc(*length);
170 (void) memmove (*value, hostp->h_addr, *length);
171 --- XFree86-3.3.3.1/xc/lib/xtrans/Xtrans.c.ipv6 Thu Jun 24 12:39:35 1999
172 +++ XFree86-3.3.3.1/xc/lib/xtrans/Xtrans.c Thu Jun 24 12:39:47 1999
175 * If the protocol part is missing, then assume INET.
176 * If the protocol part and host part are missing, then assume local.
177 - * If a "::" is found then assume DNET.
178 + * If a "host::" is found then assume DNET.
179 + * For IPv6, pb with possible : in host --> use rightmost : and test
180 + * x:y->inet, x::y->dnet, x:::y->inet(v6)
183 char *mybuf, *tmpptr;
188 - if ((mybuf = strchr (mybuf,':')) == NULL)
189 + /* For IPv6, we need the rightmost : in the non-catalog part */
192 +#if defined(FONT_t) || defined(FS_t)
193 + char *f = strchr (mybuf, '/');
196 + p = strrchr (mybuf,':');
197 + if (p && p > mybuf && p[-1] == ':')
198 + if (p-1 == mybuf || p[-2] != ':')
201 +#if defined(FONT_t) || defined(FS_t)
209 --- XFree86-3.3.3.1/xc/lib/xtrans/Xtranssock.c.ipv6 Thu Jun 24 12:39:42 1999
210 +++ XFree86-3.3.3.1/xc/lib/xtrans/Xtranssock.c Thu Jun 24 12:39:47 1999
212 #define X_INCLUDE_NETDB_H
213 #define XOS_USE_NO_LOCKING
214 #include <X11/Xos_r.h>
221 static Sockettrans2dev Sockettrans2devtab[] = {
223 - {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
224 - {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
225 + {"inet",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
226 + {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
229 {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
231 XtransConnInfo ciptr;
234 - struct sockaddr_in sockname;
235 + struct sockaddr_in6 sockname;
236 #if defined(SVR4) || defined(SCO325)
237 size_t namelen = sizeof sockname;
243 - ciptr->family = sockname.sin_family;
244 + ciptr->family = sockname.sin6_family;
245 ciptr->addrlen = namelen;
246 memcpy (ciptr->addr, &sockname, ciptr->addrlen);
249 XtransConnInfo ciptr;
252 - struct sockaddr_in sockname;
253 + struct sockaddr_in6 sockname;
254 #if defined(SVR4) || defined(SCO325)
255 size_t namelen = sizeof sockname;
257 @@ -410,10 +411,11 @@
261 - if (Sockettrans2devtab[i].family == AF_INET)
262 + if ((Sockettrans2devtab[i].family == AF_INET) ||
263 + (Sockettrans2devtab[i].family == AF_INET6))
266 - * turn off TCP coalescence for INET sockets
267 + * turn off TCP coalescence for INET[6] sockets
271 @@ -546,10 +548,11 @@
275 - * SO_REUSEADDR only applied to AF_INET
276 + * SO_REUSEADDR only applied to AF_INET6
279 - if (Sockettrans2devtab[i].family == AF_INET)
280 + if ((Sockettrans2devtab[i].family == AF_INET) ||
281 + (Sockettrans2devtab[i].family == AF_INET6))
284 setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR,
287 PRMSG (3, "SocketCreateListener(%x,%d)\n", ciptr, fd, 0);
289 - if (Sockettrans2devtab[ciptr->index].family == AF_INET)
290 + if ((Sockettrans2devtab[ciptr->index].family == AF_INET) ||
291 + (Sockettrans2devtab[ciptr->index].family == AF_INET6))
296 #endif /* SO_REUSEDADDR */
299 - if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
300 + if ((Sockettrans2devtab[ciptr->index].family == AF_INET) ||
301 + (Sockettrans2devtab[ciptr->index].family == AF_INET)) {
303 setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
309 - struct sockaddr_in sockname;
310 + struct sockaddr_in6 sockname;
311 int namelen = sizeof(sockname);
314 @@ -878,22 +883,23 @@
316 return TRANS_CREATE_LISTENER_FAILED;
318 - sockname.sin_port = servp->s_port;
319 + sockname.sin6_port = servp->s_port;
323 tmpport = (short) atoi (port);
324 - sockname.sin_port = htons (tmpport);
325 + sockname.sin6_port = htons (tmpport);
329 - sockname.sin_port = htons (0);
330 + sockname.sin6_port = htons (0);
333 - sockname.sin_len = sizeof (sockname);
334 + sockname.sin6_len = sizeof (sockname);
336 - sockname.sin_family = AF_INET;
337 - sockname.sin_addr.s_addr = htonl (INADDR_ANY);
338 + sockname.sin6_family = AF_INET6;
339 + sockname.sin6_flowinfo = 0;
340 + sockname.sin6_addr = in6addr_any;
342 if ((status = TRANS(SocketCreateListener) (ciptr,
343 (struct sockaddr *) &sockname, namelen)) < 0)
344 @@ -1095,7 +1101,7 @@
347 XtransConnInfo newciptr;
348 - struct sockaddr_in sockname;
349 + struct sockaddr_in6 sockname;
350 int namelen = sizeof(sockname);
352 PRMSG (2, "SocketINETAccept(%x,%d)\n", ciptr, ciptr->fd, 0);
353 @@ -1258,7 +1264,7 @@
357 - struct sockaddr_in sockname;
358 + struct sockaddr_in6 sockname;
359 #if defined(SVR4) || defined(SCO325)
360 size_t namelen = sizeof sockname;
362 @@ -1268,14 +1274,15 @@
363 _Xgetservbynameparams sparams;
364 struct hostent *hostp;
365 struct servent *servp;
368 #define PORTBUFSIZE 64 /* what is a real size for this? */
369 char portbuf[PORTBUFSIZE];
373 - unsigned long tmpaddr;
374 char hostnamebuf[256]; /* tmp space */
375 + char v[64]; /* Vixie's tmp space */
377 PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port);
379 @@ -1311,67 +1318,44 @@
383 - sockname.sin_len = sizeof (struct sockaddr_in);
384 + sockname.sin6_len = sizeof (struct sockaddr_in6);
386 - sockname.sin_family = AF_INET;
387 + sockname.sin6_family = AF_INET6;
388 + sockname.sin6_flowinfo = 0;
392 + * fill in sin6_addr
395 - /* check for ww.xx.yy.zz host string */
397 - if (isascii (host[0]) && isdigit (host[0])) {
398 - tmpaddr = inet_addr (host); /* returns network byte order */
403 - PRMSG (4,"SocketINETConnect: inet_addr(%s) = %x\n",
405 + /* ww.xx.yy.zz host string done by _XGethostbyname() */
409 - if ((hostp = _XGethostbyname(host,hparams)) == NULL)
411 - PRMSG (1,"SocketINETConnect: Can't get address for %s\n",
414 - return TRANS_CONNECT_FAILED;
416 - if (hostp->h_addrtype != AF_INET) /* is IP host? */
418 - PRMSG (1,"SocketINETConnect: not INET host%s\n",
421 - return TRANS_CONNECT_FAILED;
424 -#if defined(CRAY) && defined(OLDTCP)
425 - /* Only Cray UNICOS3 and UNICOS4 will define this */
428 - memcpy ((char *)&t, (char *) hostp->h_addr, sizeof (t));
429 - sockname.sin_addr = t;
432 - memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr,
433 - sizeof (sockname.sin_addr));
434 -#endif /* CRAY and OLDTCP */
436 + if ((_res.options & RES_INIT) == 0)
438 + options = _res.options;
439 + _res.options |= RES_USE_INET6;
441 + hostp = _XGethostbyname(host,hparams);
442 + _res.options = options;
445 + PRMSG (1,"SocketINETConnect: Can't get address for %s\n",
448 + return TRANS_CONNECT_FAILED;
451 + if (hostp->h_addrtype != AF_INET6) /* is IPv6 host? */
453 -#if defined(CRAY) && defined(OLDTCP)
454 - /* Only Cray UNICOS3 and UNICOS4 will define this */
455 - sockname.sin_addr = tmpaddr;
457 - sockname.sin_addr.s_addr = tmpaddr;
458 -#endif /* CRAY and OLDTCP */
459 + PRMSG (1,"SocketINETConnect: not INET host%s\n",
462 + return TRANS_CONNECT_FAILED;
465 + memcpy ((char *) &sockname.sin6_addr, (char *) hostp->h_addr,
466 + sizeof (sockname.sin6_addr));
470 + * fill in sin6_port
473 /* Check for number in the port string */
474 @@ -1384,16 +1368,16 @@
476 return TRANS_CONNECT_FAILED;
478 - sockname.sin_port = servp->s_port;
479 + sockname.sin6_port = servp->s_port;
483 tmpport = (short) atoi (portbuf);
484 - sockname.sin_port = htons (tmpport);
485 + sockname.sin6_port = htons (tmpport);
488 - PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n",
489 - ntohs(sockname.sin_port), 0, 0);
490 + PRMSG (4,"SocketINETConnect: sockname.sin6_port = %d\n",
491 + ntohs(sockname.sin6_port), 0, 0);
495 @@ -1481,13 +1465,21 @@
496 * by TRANS(GetHostname)), then the two hostnames are equivalent,
497 * and we know that 'host' is really a local host.
499 - char specified_local_addr_list[10][4];
500 + char specified_local_addr_list[10][16];
501 int scount, equiv, i, j;
502 _Xgethostbynameparams hparams;
503 struct hostent *hostp;
506 - if ((hostp = _XGethostbyname (host,hparams)) == NULL)
507 + if ((_res.options & RES_INIT) == 0)
509 + options = _res.options;
510 + _res.options |= RES_USE_INET6;
512 + if ((hostp = _XGethostbyname (host,hparams)) == NULL) {
513 + _res.options = options;
518 while (hostp->h_addr_list[scount] && scount <= 8)
519 @@ -1497,17 +1489,14 @@
520 * from the 1st call, so we must save the address list.
523 - specified_local_addr_list[scount][0] =
524 - hostp->h_addr_list[scount][0];
525 - specified_local_addr_list[scount][1] =
526 - hostp->h_addr_list[scount][1];
527 - specified_local_addr_list[scount][2] =
528 - hostp->h_addr_list[scount][2];
529 - specified_local_addr_list[scount][3] =
530 - hostp->h_addr_list[scount][3];
531 + memcpy(specified_local_addr_list[scount],
532 + hostp->h_addr_list[scount],
536 - if ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL)
537 + hostp = _XGethostbyname (hostnamebuf,hparams);
538 + _res.options = options;
543 @@ -1519,14 +1508,9 @@
545 while (hostp->h_addr_list[j])
547 - if ((specified_local_addr_list[i][0] ==
548 - hostp->h_addr_list[j][0]) &&
549 - (specified_local_addr_list[i][1] ==
550 - hostp->h_addr_list[j][1]) &&
551 - (specified_local_addr_list[i][2] ==
552 - hostp->h_addr_list[j][2]) &&
553 - (specified_local_addr_list[i][3] ==
554 - hostp->h_addr_list[j][3]))
555 + if (memcmp(specified_local_addr_list[i],
556 + hostp->h_addr_list[j],
557 + hostp->h_length) == 0)
559 /* They're equal, so we're done */
561 --- XFree86-3.3.3.1/xc/lib/xtrans/Xtransutil.c.ipv6 Thu Jun 24 12:39:42 1999
562 +++ XFree86-3.3.3.1/xc/lib/xtrans/Xtransutil.c Thu Jun 24 12:39:47 1999
565 * TRANS(ConvertAddress) converts a sockaddr based address to an
566 * X authorization based address. Some of this is defined as part of
567 - * the ChangeHost protocol. The rest is just doen in a consistent manner.
568 + * the ChangeHost protocol. The rest is just done in a consistent manner.
580 + * Check for the hack localhost address ::1.
581 + * In this case, we are really FamilyLocal.
584 + struct sockaddr_in6 saddr;
585 + int len = sizeof(saddr.sin6_addr);
586 + char *cp = (char *) &saddr.sin6_addr;
588 + memcpy (&saddr, *addrp, sizeof (struct sockaddr_in6));
590 + if (memcmp(cp, (char *)&in6addr_loopback, len) == 0)
592 + *familyp=FamilyLocal;
596 + *familyp=FamilyInternet;
598 + memcpy(*addrp,&saddr.sin6_addr,len);
602 #endif /* defined(TCPCONN) || defined(STREAMSCONN) || MNX_TCPCONN */
604 #if defined(DNETCONN)
606 sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
612 + struct sockaddr_in6 *saddr = (struct sockaddr_in6 *) addr;
613 + char portnumbuf[10];
615 + sprintf (portnumbuf, "%d", ntohs (saddr->sin6_port));
616 + networkId = (char *) xalloc (3 + strlen (transName) +
617 + strlen (hostnamebuf) + strlen (portnumbuf));
618 + sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
621 #endif /* defined(TCPCONN) || defined(STREAMSCONN) || MNX_TCPCONN */
623 #if defined(DNETCONN)
625 addr = hostp->h_name;
627 addr = inet_ntoa (saddr->sin_addr);
633 + struct sockaddr_in6 *saddr = (struct sockaddr_in6 *) peer_addr;
634 + _Xgethostbynameparams hparams;
635 + struct hostent * hostp;
640 + * gethostbyaddr can take a LONG time if the host does not exist.
641 + * Assume that if it does not respond in NAMESERVER_TIMEOUT seconds
642 + * that something is wrong and do not make the user wait.
643 + * gethostbyaddr will continue after a signal, so we have to
647 + nameserver_timedout = 0;
648 + signal (SIGALRM, nameserver_lost);
650 + if (setjmp(env) == 0) {
652 + hostp = _XGethostbyaddr ((char *) &saddr->sin6_addr,
653 + sizeof (saddr->sin6_addr), AF_INET6, hparams);
659 + addr = hostp->h_name;
661 + inet_ntop (AF_INET6, &saddr->sin6_addr, v, sizeof (v));
667 --- XFree86-3.3.3.1/xc/programs/Xserver/os/access.c.ipv6 Thu Jun 24 12:39:34 1999
668 +++ XFree86-3.3.3.1/xc/programs/Xserver/os/access.c Thu Jun 24 12:39:47 1999
671 #if !defined(AMOEBA) && !defined(MINIX)
676 #include <server/ip/gen/netdb.h>
677 @@ -215,10 +216,12 @@
679 #define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
680 #define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len)
681 +#if !defined(TCPCONN)
682 #define addrEqual(fam, address, length, host) \
683 ((fam) == (host)->family &&\
684 (length) == (host)->len &&\
685 !acmp (address, (host)->addr, length))
688 static int ConvertAddr(
689 #if NeedFunctionPrototypes
691 static int LocalHostEnabled = FALSE;
692 static int UsingXdmcp = FALSE;
694 +#if defined(TCPCONN)
695 +#define MAPTOIPV4(a) ((char *)(a) + sizeof(struct in6_addr) - \
696 + sizeof(struct in_addr))
697 +#define MAPTOIPV6(d,a) { \
698 + bzero(&d.s6_addr[0], \
699 + sizeof(struct in6_addr)-2-sizeof(struct in_addr)); \
700 + d.s6_addr[10] = d.s6_addr[11] = 0xff; \
701 + acopy(a, MAPTOIPV4(&d.s6_addr[0]), sizeof(struct in_addr)); \
705 +addrEqual(fam, addr, len, host)
706 + unsigned char *addr;
707 + register HOST *host;
712 + if (fam != host->family)
714 + if (len == host->len)
715 + return !acmp (addr, host->addr, len);
716 + if (fam != FamilyInternet)
719 + /* compare IPv4 with special IPv6 : mapped, loopback */
720 + if (len == sizeof(struct in6_addr) &&
721 + host->len == sizeof(struct in_addr)) {
724 + } else if (len == sizeof(struct in_addr) &&
725 + host->len == sizeof(struct in6_addr)) {
730 + if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)a6))
731 + return !acmp(a4, MAPTOIPV4(a6), sizeof(*a4));
733 + return (a4[0] == 127 && a4[1] == 0 && a4[2] == 0 && a4[3] == 1 &&
734 + acmp(a6, &in6addr_loopback, sizeof(*a6)) == 0);
739 * called when authorization is not enabled to add the
743 register struct ifreq *ifr;
744 + struct in6_addr mapped;
747 struct dn_naddr *dnaddr = getnodeadd();
748 @@ -692,10 +739,32 @@
749 if (family == -1 || family == FamilyLocal)
751 #ifdef DEF_SELF_DEBUG
752 - if (family == FamilyInternet)
753 - ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %d.%d.%d.%d\n",
754 - ifr->ifr_name, addr[0], addr[1], addr[2], addr[3]);
755 + if (family == FamilyInternet) {
758 + ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %s\n",
760 + inet_ntop(len == 4 ? AF_INET : AF_INET6, addr, v, 64));
763 + if (family == FamilyInternet) {
765 + /* Mapped IPv4 to IPv6 with special case for loopback */
766 + if (addr[0] == 127 && addr[1] == 0 &&
767 + addr[2] == 0 && addr[3] == 1)
768 + addr = (unsigned char *)&in6addr_loopback;
770 + MAPTOIPV6(mapped, addr);
771 + addr = (unsigned char *) &mapped;
773 + len = sizeof(mapped);
776 + * Link local addresses are too weird
778 + if (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr))
781 for (host = selfhosts;
782 host && !addrEqual (family, addr, len, host);
784 @@ -724,13 +793,15 @@
786 * ignore 'localhost' entries as they're not useful
787 * on the other end of the wire
788 + * ignore 'link local' entries
791 - addr[0] == 127 && addr[1] == 0 &&
792 - addr[2] == 0 && addr[3] == 1)
793 + if (acmp(addr, &in6addr_loopback, len)==0)
796 XdmcpRegisterConnection (family, (char *)addr, len);
797 + /* what to do with INET6 ???? */
798 + if (ifr->ifr_addr.sa_family != AF_INET);
800 broad_addr = ifr->ifr_addr;
801 ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
802 htonl (INADDR_BROADCAST);
803 @@ -794,10 +865,22 @@
807 + struct in6_addr mapped;
809 family = ConvertAddr(from, &len, (pointer *)&addr);
810 if (family == -1 || family == FamilyLocal)
812 + if ((family == FamilyInternet) && (len == 4)) {
813 + /* Mapped IPv4 to IPv6 with special case for loopback */
814 + if (((char *)addr)[0] == 127 && ((char *)addr)[1] == 0 &&
815 + ((char *)addr)[2] == 0 && ((char *)addr)[3] == 1)
816 + addr = (pointer)&in6addr_loopback;
818 + MAPTOIPV6(mapped, addr);
819 + addr = (unsigned char *) &mapped;
821 + len = sizeof(mapped);
823 for (host = selfhosts; host; host = host->next)
825 if (addrEqual(family, addr, len, host))
829 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
830 - struct sockaddr_in in;
831 + struct sockaddr_in6 in;
832 #endif /* TCPCONN || STREAMSCONN */
834 struct sockaddr_dn dn;
835 @@ -978,12 +1061,16 @@
836 #endif /* SECURE_RPC */
837 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
839 + if ((_res.options & RES_INIT) == 0)
841 + _res.options |= RES_USE_INET6;
844 if (family == FamilyInternet && (hp = gethostbyname (hostname)) ||
845 (hp = gethostbyname (hostname)))
847 saddr.sa.sa_family = hp->h_addrtype;
848 - len = sizeof(saddr.sa);
849 + len = sizeof(saddr.in);
850 if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1)
852 #ifdef h_addr /* new 4.3bsd version of gethostent */
853 @@ -1072,6 +1159,7 @@
857 + struct in6_addr mapped;
859 if (!AuthorizedClient(client))
861 @@ -1092,6 +1180,11 @@
865 + if (length == sizeof (struct in_addr)) {
866 + MAPTOIPV6(mapped, pAddr);
867 + pAddr = (char *)& mapped;
868 + length = sizeof(mapped);
872 if ((len = CheckAddr (family, pAddr, length)) < 0)
873 @@ -1174,6 +1267,7 @@
876 register HOST *host, **prev;
877 + struct in6_addr mapped;
879 if (!AuthorizedClient(client))
881 @@ -1193,6 +1287,11 @@
885 + if (length == sizeof (struct in_addr)) {
886 + MAPTOIPV6(mapped, pAddr);
887 + pAddr = (char *)& mapped;
888 + length = sizeof(mapped);
892 if ((len = CheckAddr (family, pAddr, length)) < 0)
893 @@ -1236,7 +1335,12 @@
894 for (host = validhosts; host; host = host->next)
897 - n += (((host->len + 3) >> 2) << 2) + sizeof(xHostEntry);
899 + if (host->family == FamilyInternet &&
900 + len == sizeof (struct in6_addr) &&
901 + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)host->addr))
902 + len = sizeof (struct in_addr);
903 + n += (((len + 3) >> 2) << 2) + sizeof(xHostEntry);
907 @@ -1247,11 +1351,19 @@
909 for (host = validhosts; host; host = host->next)
911 + char *ad = host->addr;
914 ((xHostEntry *)ptr)->family = host->family;
915 + if (host->family == FamilyInternet &&
916 + len == sizeof (struct in6_addr) &&
917 + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)host->addr)) {
918 + len = sizeof (struct in_addr);
919 + ad = MAPTOIPV4(ad);
921 ((xHostEntry *)ptr)->length = len;
922 ptr += sizeof(xHostEntry);
923 - acopy (host->addr, ptr, len);
924 + acopy (ad, ptr, len);
925 ptr += ((len + 3) >> 2) << 2;
928 @@ -1277,11 +1389,7 @@
930 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN) || defined(MNX_TCPCONN)
932 -#if !defined(AMOEBA)
933 - if (length == sizeof (struct in_addr))
935 - if (length == sizeof(ipaddr_t))
937 + if (length == sizeof (struct in6_addr))
941 @@ -1312,11 +1420,7 @@
942 * Returns 1 if host is invalid, 0 if we've found it. */
944 InvalidHost (saddr, len)
946 register struct sockaddr *saddr;
948 - register ipaddr_t *saddr;
953 @@ -1359,11 +1463,7 @@
956 ConvertAddr (saddr, len, addr)
958 register struct sockaddr *saddr;
960 - register ipaddr_t *saddr;
965 @@ -1381,6 +1481,10 @@
967 *len = sizeof (struct in_addr);
968 *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
969 + return FamilyInternet;
971 + *len = sizeof (struct in6_addr);
972 + *addr = (pointer) &(((struct sockaddr_in6 *) saddr)->sin6_addr);
973 return FamilyInternet;
976 --- XFree86-3.3.3.1/xc/programs/Xserver/os/connection.c.ipv6 Thu Jun 24 12:39:34 1999
977 +++ XFree86-3.3.3.1/xc/programs/Xserver/os/connection.c Thu Jun 24 12:39:47 1999
985 if (!((OsCommPtr)client->osPrivate)->trans_conn) {
987 sprintf(out, "IP %s port %d",
988 inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr),
989 ntohs(((struct sockaddr_in *) saddr)->sin_port));
992 + sprintf(out, "IPv6 %s port %d",
993 + inet_ntop(AF_INET6,
994 + &((struct sockaddr_in6 *) saddr)->sin6_addr,
996 + ntohs(((struct sockaddr_in6 *) saddr)->sin6_port));
1000 --- XFree86-3.3.3.1/xc/programs/Xserver/os/k5auth.c.ipv6 Fri May 10 09:02:15 1996
1001 +++ XFree86-3.3.3.1/xc/programs/Xserver/os/k5auth.c Thu Jun 24 12:39:47 1999
1004 krb5_error_code retval, retval2;
1006 - struct sockaddr cli_net_addr;
1007 + struct sockaddr_in6 cli_net_addr;
1009 krb5_principal cprinc;
1011 @@ -299,15 +299,15 @@
1013 addrlen = sizeof (cli_net_addr);
1014 if (getpeername(((OsCommPtr)client->osPrivate)->fd,
1015 - &cli_net_addr, &addrlen) == -1)
1016 + (struct sockaddr *)&cli_net_addr, &addrlen) == -1)
1019 krb5_free_creds(creds);
1020 return(SendConnSetup(client, "Krb5 stage1: getpeername failed"));
1022 - if (cli_net_addr.sa_family == AF_UNSPEC
1023 + if (cli_net_addr.sin6_family == AF_UNSPEC
1024 #if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
1025 - || cli_net_addr.sa_family == AF_UNIX
1026 + || cli_net_addr.sin6_family == AF_UNIX
1028 ) /* assume local host */
1034 - cli_addr.addrtype = cli_net_addr.sa_family; /* the values
1035 + cli_addr.addrtype = cli_net_addr.sin6_family; /* the values
1037 - switch (cli_net_addr.sa_family)
1038 + switch (cli_net_addr.sin6_family)
1042 @@ -334,6 +334,11 @@
1044 (krb5_octet *)&((struct sockaddr_in *)&cli_net_addr)->sin_addr;
1047 + cli_addr.length = sizeof (struct in6_addr);
1048 + cli_addr.contents =
1049 + (krb5_octet *)&(&cli_net_addr)->sin6_addr;
1056 krb5_free_creds(creds);
1057 sprintf(kerror, "Krb5 stage1: unknown address family %d from getpeername",
1058 - cli_net_addr.sa_family);
1059 + cli_net_addr.sin6_family);
1060 return(SendConnSetup(client, kerror));
1063 --- XFree86-3.3.3.1/xc/programs/Xserver/os/utils.c.ipv6 Thu Jun 24 12:39:34 1999
1064 +++ XFree86-3.3.3.1/xc/programs/Xserver/os/utils.c Thu Jun 24 12:39:47 1999
1065 @@ -1112,7 +1112,9 @@
1067 #if defined(TCPCONN) || defined(STREAMSCONN)
1069 +#include <netinet/in.h>
1071 +#include <resolv.h>
1075 @@ -1134,6 +1136,10 @@
1076 char hname[1024], *hnameptr;
1077 struct hostent *host;
1080 + if ((_res.options & RES_INIT) == 0)
1082 + _res.options |= RES_USE_INET6;
1084 gethostname(hname, 1024);
1085 host = gethostbyname(hname);
1086 --- XFree86-3.3.3.1/xc/programs/Xserver/os/xdmcp.c.ipv6 Thu Jun 24 12:39:34 1999
1087 +++ XFree86-3.3.3.1/xc/programs/Xserver/os/xdmcp.c Thu Jun 24 12:39:47 1999
1090 #include <netinet/in.h>
1092 +#include <resolv.h>
1096 #include <net/hton.h>
1099 static int xdmcpSocket, sessionSocket;
1100 static xdmcp_states state;
1101 -static struct sockaddr_in req_sockaddr;
1102 +static struct sockaddr_in6 req_sockaddr;
1103 static int req_socklen;
1104 static CARD32 SessionID;
1105 static CARD32 timeOutTime;
1108 static XdmcpBuffer buffer;
1110 -static struct sockaddr_in ManagerAddress;
1111 +static struct sockaddr_in6 ManagerAddress;
1113 static void get_xdmcp_sock(
1114 #if NeedFunctionPrototypes
1117 static void recv_willing_msg(
1118 #if NeedFunctionPrototypes
1119 - struct sockaddr_in */*from*/,
1120 + struct sockaddr_in6 */*from*/,
1124 @@ -332,24 +334,27 @@
1126 #define MAX_BROADCAST 10
1128 -static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST];
1129 +static struct sockaddr_in6 BroadcastAddresses[MAX_BROADCAST];
1130 static int NumBroadcastAddresses;
1133 XdmcpRegisterBroadcastAddress (addr)
1134 struct sockaddr_in *addr;
1136 - struct sockaddr_in *bcast;
1137 + struct sockaddr_in6 *bcast;
1138 if (NumBroadcastAddresses >= MAX_BROADCAST)
1140 bcast = &BroadcastAddresses[NumBroadcastAddresses++];
1141 - bzero (bcast, sizeof (struct sockaddr_in));
1142 + bzero (bcast, sizeof (struct sockaddr_in6));
1143 + /* mapped the IPv4 broadcast address to IPv6 */
1145 - bcast->sin_len = addr->sin_len;
1146 + bcast->sin6_len = sizeof(struct sockaddr_in6);
1148 - bcast->sin_family = addr->sin_family;
1149 - bcast->sin_port = htons (xdm_udp_port);
1150 - bcast->sin_addr = addr->sin_addr;
1151 + bcast->sin6_family = AF_INET6;
1152 + bcast->sin6_port = htons (xdm_udp_port);
1153 + bcast->sin6_flowinfo = 0;
1154 + bcast->sin6_addr.s6_addr[10] = bcast->sin6_addr.s6_addr[11] = 0xff;
1155 + memmove(&bcast->sin6_addr.s6_addr[12], &addr->sin_addr, 4);
1159 @@ -464,6 +469,13 @@
1160 XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses);
1161 xdmcpGeneration = serverGeneration;
1163 + /* for INET6, try go back to INET, to help not INET6 managers !! */
1164 + if (type == FamilyInternet &&
1165 + addrlen == sizeof (struct in6_addr) &&
1166 + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)address)) {
1167 + addrlen = sizeof (struct in_addr);
1168 + address += sizeof (struct in6_addr) - sizeof (struct in_addr);
1170 newAddress = (CARD8 *) xalloc (addrlen * sizeof (CARD8));
1176 XdmcpAddHost(from, fromlen, AuthenticationName, hostname, status)
1177 - struct sockaddr_in *from;
1178 + struct sockaddr_in6 *from;
1179 ARRAY8Ptr AuthenticationName, hostname, status;
1181 XdmcpSelectHost(from, fromlen, AuthenticationName);
1186 - struct sockaddr_in from;
1187 - int fromlen = sizeof(struct sockaddr_in);
1188 + struct sockaddr_in6 from;
1189 + int fromlen = sizeof(struct sockaddr_in6);
1192 /* read message off socket */
1197 - if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
1198 + if ((xdmcpSocket = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
1202 @@ -1066,7 +1078,7 @@
1204 for (i = 0; i < NumBroadcastAddresses; i++)
1205 XdmcpFlush (xdmcpSocket, &buffer, &BroadcastAddresses[i],
1206 - sizeof (struct sockaddr_in));
1207 + sizeof (struct sockaddr_in6));
1211 @@ -1077,7 +1089,7 @@
1214 recv_willing_msg(from, fromlen, length)
1215 - struct sockaddr_in *from;
1216 + struct sockaddr_in6 *from;
1220 @@ -1380,23 +1392,29 @@
1221 ErrorF("Xserver: missing host name in command line\n");
1225 + if ((_res.options & RES_INIT) == 0)
1227 + _res.options |= RES_USE_INET6;
1229 if (!(hep = gethostbyname(argv[i])))
1231 ErrorF("Xserver: unknown host: %s\n", argv[i]);
1235 - if (hep->h_length == sizeof (struct in_addr))
1236 + if (hep->h_length == sizeof (struct in6_addr))
1238 if (hep->h_length == sizeof (ipaddr_t))
1241 - memmove(&ManagerAddress.sin_addr, hep->h_addr, hep->h_length);
1242 + memmove(&ManagerAddress.sin6_addr, hep->h_addr, hep->h_length);
1244 - ManagerAddress.sin_len = sizeof(ManagerAddress);
1245 + ManagerAddress.sin6_len = sizeof(ManagerAddress);
1247 - ManagerAddress.sin_family = AF_INET;
1248 - ManagerAddress.sin_port = htons (xdm_udp_port);
1249 + ManagerAddress.sin6_family = AF_INET6;
1250 + ManagerAddress.sin6_port = htons (xdm_udp_port);
1251 + ManagerAddress.sin6_flowinfo = 0;
1255 --- XFree86-3.3.3.1/xc/programs/lbxproxy/os/connection.c.ipv6 Thu Jun 24 12:39:42 1999
1256 +++ XFree86-3.3.3.1/xc/programs/lbxproxy/os/connection.c Thu Jun 24 12:39:47 1999
1258 int retry; /* boolean - retry if addr busy */
1261 - struct sockaddr_in insock;
1262 + struct sockaddr_in6 insock;
1265 #ifndef SO_DONTLINGER
1267 #endif /* SO_LINGER */
1268 #endif /* SO_DONTLINGER */
1270 - if ((request = socket (AF_INET, SOCK_STREAM, 0)) < 0)
1271 + if ((request = socket (AF_INET6, SOCK_STREAM, 0)) < 0)
1273 Error ("Creating TCP socket");
1275 @@ -255,11 +255,12 @@
1277 bzero ((char *)&insock, sizeof (insock));
1279 - insock.sin_len = sizeof(insock);
1280 + insock.sin6_len = sizeof(insock);
1282 - insock.sin_family = AF_INET;
1283 - insock.sin_port = htons ((unsigned short)(X_TCP_PORT + atoi (display)));
1284 - insock.sin_addr.s_addr = htonl(INADDR_ANY);
1285 + insock.sin6_family = AF_INET6;
1286 + insock.sin6_flowinfo = 0;
1287 + insock.sin6_port = htons ((unsigned short)(X_TCP_PORT + atoi (display)));
1288 + insock.sin6_addr = in6addr_any;
1290 retryCount = retry ? 19 : 0;
1292 @@ -1776,7 +1777,7 @@
1293 struct sockaddr_un un;
1294 #endif /* UNIXCONN */
1296 - struct sockaddr_in in;
1297 + struct sockaddr_in6 in;
1298 #endif /* TCPCONN */
1300 struct sockaddr_dn dn;
1301 @@ -1801,7 +1802,9 @@
1302 fromlen = sizeof (from);
1303 if (!getpeername (newconn, &from.sa, &fromlen))
1305 - if (fromlen && (from.sa.sa_family == AF_INET))
1307 + ((from.sa.sa_family == AF_INET) ||
1308 + (from.sa.sa_family == AF_INET6)))
1311 setsockopt (newconn, IPPROTO_TCP, TCP_NODELAY,
1312 --- XFree86-3.3.3.1/xc/programs/xauth/gethost.c.ipv6 Sun Sep 13 15:15:53 1998
1313 +++ XFree86-3.3.3.1/xc/programs/xauth/gethost.c Thu Jun 24 12:39:47 1999
1314 @@ -144,15 +144,21 @@
1316 if (setjmp(env) == 0) {
1318 - hp = gethostbyaddr (auth->address, auth->address_length, AF_INET);
1319 + hp = gethostbyaddr (auth->address, auth->address_length,
1320 + auth->address_length == 4 ? AF_INET : AF_INET6);
1326 return (hp->h_name);
1328 - return (inet_ntoa(*((struct in_addr *)(auth->address))));
1330 + static char v[64];
1332 + inet_ntop (auth->address_length == 4 ? AF_INET : AF_INET6,
1333 + auth->address, v, sizeof(v));
1339 @@ -172,38 +178,26 @@
1344 - * cribbed from lib/X/XConnDis.c
1346 static Bool get_inet_address (name, resultp)
1348 - unsigned int *resultp; /* return */
1349 + struct in6_addr *resultp; /* return */
1351 - unsigned int hostinetaddr = inet_addr (name);
1352 struct hostent *host_ptr;
1353 - struct sockaddr_in inaddr; /* dummy variable for size calcs */
1355 -#ifndef INADDR_NONE
1356 -#define INADDR_NONE -1
1359 - if (hostinetaddr == INADDR_NONE) {
1360 - if ((host_ptr = gethostbyname (name)) == NULL) {
1361 - /* No such host! */
1365 - /* Check the address type for an internet host. */
1366 - if (host_ptr->h_addrtype != AF_INET) {
1367 - /* Not an Internet host! */
1368 - errno = EPROTOTYPE;
1372 - memmove( (char *)&hostinetaddr, (char *)host_ptr->h_addr,
1373 - sizeof(inaddr.sin_addr));
1374 + if ((host_ptr = gethostbyname (name)) == NULL) {
1375 + /* No such host! */
1379 - *resultp = hostinetaddr;
1380 + /* Check the address type for an internet host. */
1381 + if (host_ptr->h_addrtype != AF_INET6) {
1382 + /* Not an Internet host! */
1383 + errno = EPROTOTYPE;
1387 + memmove( (char *)resultp, (char *)host_ptr->h_addr,
1388 + host_ptr->h_length);
1396 - unsigned int hostinetaddr;
1397 - struct sockaddr_in inaddr; /* dummy variable for size calcs */
1398 + struct in6_addr hostinetaddr;
1401 struct dn_naddr dnaddr;
1404 if (!get_inet_address (host, &hostinetaddr)) return NULL;
1405 src = (char *) &hostinetaddr;
1406 - len = 4; /* sizeof inaddr.sin_addr, would fail on Cray */
1407 + len = (sizeof hostinetaddr);
1411 --- XFree86-3.3.3.1/xc/programs/xauth/parsedpy.c.ipv6 Mon Feb 16 01:43:19 1998
1412 +++ XFree86-3.3.3.1/xc/programs/xauth/parsedpy.c Thu Jun 24 12:39:47 1999
1413 @@ -115,12 +115,18 @@
1414 if (!displayname || !displayname[0]) return False;
1416 /* must have at least :number */
1417 - ptr = strchr(displayname, ':');
1419 + * If a "host::" is found then assume DNET.
1420 + * For IPv6, pb with possible : in host --> use rightmost : and test
1421 + * x:y->inet, x::y->dnet, x:::y->inet(v6)
1423 + ptr = strrchr(displayname, ':');
1424 if (!ptr || !ptr[1]) return False;
1425 - if (ptr[1] == ':') {
1426 - if (ptr[2] == '\0') return False;
1429 + if (ptr > displayname && ptr[-1] == ':')
1430 + if (ptr-1 == displayname || ptr[-2] != ':') {
1437 --- XFree86-3.3.3.1/xc/programs/xauth/xauth.c.ipv6 Wed Apr 27 09:19:54 1994
1438 +++ XFree86-3.3.3.1/xc/programs/xauth/xauth.c Thu Jun 24 12:39:47 1999
1443 +#include <netinet/in.h>
1444 +#include <resolv.h>
1448 @@ -102,6 +104,10 @@
1451 ProgramName = argv[0];
1453 + if ((_res.options & RES_INIT) == 0)
1455 + _res.options |= RES_USE_INET6;
1457 for (i = 1; i < argc; i++) {
1458 char *arg = argv[i];
1459 --- XFree86-3.3.3.1/xc/programs/xdm/access.c.ipv6 Sat Jan 18 08:02:17 1997
1460 +++ XFree86-3.3.3.1/xc/programs/xdm/access.c Thu Jun 24 12:39:47 1999
1461 @@ -379,6 +379,11 @@
1462 display->connectionType = FamilyInternet;
1467 + display->connectionType = FamilyInternet;
1472 display->connectionType = FamilyDECnet;
1473 --- XFree86-3.3.3.1/xc/programs/xdm/auth.c.ipv6 Thu Jun 24 12:39:34 1999
1474 +++ XFree86-3.3.3.1/xc/programs/xdm/auth.c Thu Jun 24 12:39:47 1999
1483 # include <sys/sockio.h>
1485 @@ -988,6 +988,21 @@
1486 Debug ("Skipping localhost address\n");
1489 + if (len == sizeof (struct in6_addr)) {
1490 + if (bcmp(addr, &in6addr_loopback, len) == 0)
1492 + Debug ("Skipping localhost address\n");
1496 + * ignore Link local address, the semantic would be weird
1498 + if (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr))
1500 + Debug ("Skipping link-local address\n");
1504 family = FamilyInternet;
1506 Debug ("DefineSelf: write network address, length %d\n", len);
1507 @@ -1014,10 +1029,10 @@
1511 - struct sockaddr_in in;
1512 + struct sockaddr_in6 in;
1515 - struct sockaddr_in *inetaddr;
1516 + struct sockaddr_in6 *inetaddr;
1519 * Why not use gethostname()? Well, at least on my system, I've had to
1520 @@ -1029,12 +1044,12 @@
1521 hp = gethostbyname (name.nodename);
1523 saddr.sa.sa_family = hp->h_addrtype;
1524 - inetaddr = (struct sockaddr_in *) (&(saddr.sa));
1525 - memmove( (char *) &(inetaddr->sin_addr), (char *) hp->h_addr, (int) hp->h_length);
1526 + inetaddr = (struct sockaddr_in6 *) (&(saddr.sa));
1527 + memmove( (char *) &(inetaddr->sin6_addr), (char *) hp->h_addr, (int) hp->h_length);
1528 family = ConvertAddr ( &(saddr.sa), &len, &addr);
1530 - writeAddr (FamilyInternet, sizeof (inetaddr->sin_addr),
1531 - (char *) (&inetaddr->sin_addr), file, auth);
1532 + writeAddr (FamilyInternet, sizeof (inetaddr->sin6_addr),
1533 + (char *) (&inetaddr->sin6_addr), file, auth);
1537 @@ -1101,7 +1116,7 @@
1538 tcp_device= TCP_DEVICE;
1539 fd = open(tcp_device, O_RDWR);
1541 - fd = socket (AF_INET, SOCK_STREAM, 0);
1542 + fd = socket (AF_INET6, SOCK_STREAM, 0);
1544 DefineSelf (fd, file, auth);
1546 @@ -1133,6 +1148,35 @@
1547 setAuthNumber (auth, name);
1548 family = ConvertAddr (peer, &peerlen, &addr);
1549 Debug ("writeRemoteAuth: family %d\n", family);
1550 + /* if remote and name, set all the remote addresses */
1551 + if (family == FamilyInternet)
1553 + struct in6_addr tmp;
1554 + struct hostent *hp;
1555 + char **ad, *colon;
1558 + if (peerlen == sizeof (struct in6_addr) &&
1559 + !IN6_IS_ADDR_V4MAPPED((struct in6_addr *)addr))
1563 + colon = strrchr(name, ':');
1566 + if (inet_pton(af, name, &tmp) == 0 &&
1567 + (hp = gethostbyname2(name, af))) {
1568 + for(ad = hp->h_addr_list; *ad; ad++) {
1569 + Debug ("writeRemoteAuth: %d, %d, %x\n",
1570 + family, hp->h_length, *(int *)*ad);
1571 + writeAddr (family, hp->h_length, *ad, file, auth);
1579 if (family != FamilyLocal)
1581 Debug ("writeRemoteAuth: %d, %d, %x\n",
1582 --- XFree86-3.3.3.1/xc/programs/xdm/choose.c.ipv6 Sat Jan 18 08:02:19 1997
1583 +++ XFree86-3.3.3.1/xc/programs/xdm/choose.c Thu Jun 24 12:39:47 1999
1584 @@ -232,6 +232,22 @@
1592 + ARRAY8Ptr localAddress, getLocalAddress ();
1594 + port = NetaddrPort((XdmcpNetaddr)addr_buf, &portlen);
1595 + result_buf[0] = netfamily >> 8;
1596 + result_buf[1] = netfamily & 0xFF;
1597 + result_buf[2] = port[0];
1598 + result_buf[3] = port[1];
1599 + localAddress = getLocalAddress ();
1600 + memmove( (char *)result_buf+4, (char *)localAddress->data, 16);
1607 --- XFree86-3.3.3.1/xc/programs/xdm/chooser.c.ipv6 Thu Jun 24 12:39:34 1999
1608 +++ XFree86-3.3.3.1/xc/programs/xdm/chooser.c Thu Jun 24 12:39:47 1999
1611 #include <netinet/in.h>
1612 #include <arpa/inet.h>
1613 +#include <resolv.h>
1615 #include <net/hton.h>
1616 #include <net/netlib.h>
1617 @@ -347,6 +348,11 @@
1618 hostAddr.length = 4;
1619 connectionType = FamilyInternet;
1622 + hostAddr.data = (CARD8 *) &((struct sockaddr_in6 *) addr)->sin6_addr;
1623 + hostAddr.length = 16;
1624 + connectionType = FamilyInternet;
1627 hostAddr.data = (CARD8 *) "";
1628 hostAddr.length = 0;
1629 @@ -376,11 +382,12 @@
1630 switch (addr->sa_family)
1635 struct hostent *hostent;
1638 - hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, AF_INET);
1639 + hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, addr->sa_family);
1642 XdmcpDisposeARRAY8 (hostname);
1646 int saveHostname = 0;
1647 - struct sockaddr addr;
1648 + struct sockaddr_in6 addr;
1653 in_addr.sin_family = AF_INET;
1657 hostent = gethostbyname (name);
1661 ref.ref_int= socketFD;
1662 nbio_setcallback(socketFD, ASIO_READ, read_cb, ref);
1664 - if ((socketFD = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
1665 + if ((socketFD = socket (AF_INET6, SOCK_DGRAM, 0)) < 0)
1671 if (app_resources.xdmAddress)
1673 - struct sockaddr_in in_addr;
1674 + struct sockaddr_in6 in_addr;
1675 struct sockaddr *addr;
1678 @@ -970,13 +978,14 @@
1679 xdm = (char *) app_resources.xdmAddress->data;
1680 family = (xdm[0] << 8) + xdm[1];
1685 - in_addr.sin_len = sizeof(in_addr);
1686 + in_addr.sin6_len = sizeof(in_addr);
1688 - in_addr.sin_family = family;
1689 - memmove( &in_addr.sin_port, xdm + 2, 2);
1690 - memmove( &in_addr.sin_addr, xdm + 4, 4);
1691 + in_addr.sin6_family = family;
1692 + in_addr.sin6_flowinfo = 0;
1693 + memmove( &in_addr.sin6_port, xdm + 2, 2);
1694 + memmove( &in_addr.sin6_addr, xdm + 4, 16);
1695 addr = (struct sockaddr *) &in_addr;
1696 len = sizeof (in_addr);
1698 @@ -1172,6 +1181,10 @@
1700 Dimension width, height;
1703 + if ((_res.options & RES_INIT) == 0)
1705 + _res.options |= RES_USE_INET6;
1707 toplevel = XtInitialize (argv[0], "Chooser", options, XtNumber(options), &argc, argv);
1709 --- XFree86-3.3.3.1/xc/programs/xdm/dm.c.ipv6 Sat Oct 31 21:17:43 1998
1710 +++ XFree86-3.3.3.1/xc/programs/xdm/dm.c Thu Jun 24 12:39:47 1999
1715 +#include <netinet/in.h>
1716 +#include <resolv.h>
1718 #if defined(SVR4) && !defined(SCO)
1719 extern FILE *fdopen();
1720 @@ -118,6 +120,10 @@
1722 TitleLen = (argv[argc - 1] + strlen(argv[argc - 1])) - Title;
1725 + if ((_res.options & RES_INIT) == 0)
1727 + _res.options |= RES_USE_INET6;
1730 * Step 1 - load configuration parameters
1731 --- XFree86-3.3.3.1/xc/programs/xdm/netaddr.c.ipv6 Sat Jan 18 08:02:21 1997
1732 +++ XFree86-3.3.3.1/xc/programs/xdm/netaddr.c Thu Jun 24 12:39:47 1999
1736 /* given an XdmcpNetaddr, returns the socket protocol family used,
1738 + e.g., AF_INET[6] */
1740 int NetaddrFamily(netaddrp)
1741 XdmcpNetaddr netaddrp;
1745 return (char *)&(((struct sockaddr_in *)netaddrp)->sin_port);
1748 + return (char *)&(((struct sockaddr_in6 *)netaddrp)->sin6_port);
1754 *lenp = sizeof (struct in_addr);
1755 return (char *) &(((struct sockaddr_in *)netaddrp)->sin_addr);
1757 + *lenp = sizeof (struct in6_addr);
1758 + return (char *) &(((struct sockaddr_in6 *)netaddrp)->sin6_addr);
1767 retval = FamilyInternet;
1770 @@ -248,6 +255,20 @@
1772 Debug ("port %d, host %d.%d.%d.%d\n",
1773 (p[0] << 8) + p[1], t[0], t[1], t[2], t[3]);
1780 + p = (unsigned char *) &((struct sockaddr_in6 *) a)->sin6_port;
1781 + t = (unsigned char *) &((struct sockaddr_in6 *) a)->sin6_addr;
1783 + Debug ("port %d, host %2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x\n",
1784 + (p[0] << 8) + p[1],
1785 + t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7],
1786 + t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15]);
1791 --- XFree86-3.3.3.1/xc/programs/xdm/socket.c.ipv6 Sat Jan 18 08:02:24 1997
1792 +++ XFree86-3.3.3.1/xc/programs/xdm/socket.c Thu Jun 24 12:39:47 1999
1794 CreateWellKnownSockets ()
1797 - struct sockaddr_in sock_addr;
1798 + struct sockaddr_in6 sock_addr;
1800 char *tcp_device, *udp_device;
1801 nwio_udpopt_t udpopt;
1803 udp_device= UDP_DEVICE;
1804 xdmcpFd = open(udp_device, O_RDWR);
1806 - xdmcpFd = socket (AF_INET, SOCK_DGRAM, 0);
1807 + xdmcpFd = socket (AF_INET6, SOCK_DGRAM, 0);
1809 if (xdmcpFd == -1) {
1810 LogError ("XDMCP socket creation failed, errno %d\n", errno);
1811 @@ -145,11 +145,12 @@
1812 /* zero out the entire structure; this avoids 4.4 incompatibilities */
1813 bzero ((char *) &sock_addr, sizeof (sock_addr));
1815 - sock_addr.sin_len = sizeof(sock_addr);
1816 + sock_addr.sin6_len = sizeof(sock_addr);
1818 - sock_addr.sin_family = AF_INET;
1819 - sock_addr.sin_port = htons ((short) request_port);
1820 - sock_addr.sin_addr.s_addr = htonl (INADDR_ANY);
1821 + sock_addr.sin6_family = AF_INET6;
1822 + sock_addr.sin6_port = htons ((short) request_port);
1823 + sock_addr.sin6_flowinfo = 0;
1824 + sock_addr.sin6_addr = in6addr_any;
1825 if (bind (xdmcpFd, (struct sockaddr *)&sock_addr, sizeof (sock_addr)) == -1)
1827 LogError ("error %d binding socket address %d\n", errno, request_port);
1829 tcp_device= TCP_DEVICE;
1830 chooserFd = open(tcp_device, O_RDWR);
1832 - chooserFd = socket (AF_INET, SOCK_STREAM, 0);
1833 + chooserFd = socket (AF_INET6, SOCK_STREAM, 0);
1835 Debug ("Created chooser socket %d\n", chooserFd);
1836 if (chooserFd == -1)
1841 - struct sockaddr_in in_addr;
1842 + struct sockaddr_in6 in_addr;
1845 len = sizeof in_addr;
1846 --- XFree86-3.3.3.1/xc/programs/xdm/xdmcp.c.ipv6 Sun Feb 1 22:44:04 1998
1847 +++ XFree86-3.3.3.1/xc/programs/xdm/xdmcp.c Thu Jun 24 12:39:47 1999
1849 #include <net/gen/netdb.h>
1852 +# include <arpa/inet.h>
1854 #ifdef X_NOT_STDC_ENV
1856 extern Time_t time ();
1862 - struct sockaddr_in in_addr;
1864 + struct sockaddr_in6 in_addr;
1868 @@ -143,19 +145,20 @@
1870 switch (connectionType)
1874 case FamilyInternet:
1875 addr = (struct sockaddr *) &in_addr;
1876 bzero ((char *) &in_addr, sizeof (in_addr));
1878 - in_addr.sin_len = sizeof(in_addr);
1879 + in_addr.sin6_len = sizeof(in_addr);
1881 - in_addr.sin_family = AF_INET;
1882 - in_addr.sin_port = htons ((short) XDM_UDP_PORT);
1883 - if (address->length != 4)
1884 + in_addr.sin6_family = AF_INET6;
1885 + in_addr.sin6_flowinfo = 0;
1886 + in_addr.sin6_port = htons ((short) XDM_UDP_PORT);
1887 + if (address->length != 16)
1889 - memmove( (char *) &in_addr.sin_addr, address->data, address->length);
1890 - addrlen = sizeof (struct sockaddr_in);
1891 + memmove( (char *) &in_addr.sin6_addr, address->data, address->length);
1892 + addrlen = sizeof (struct sockaddr_in6);
1897 ProcessRequestSocket ()
1900 - struct sockaddr_in addr;
1901 + struct sockaddr_in6 addr;
1902 int addrlen = sizeof addr;
1907 data = connectionAddress->data;
1908 hostent = gethostbyaddr ((char *)data,
1909 - connectionAddress->length, AF_INET);
1910 + connectionAddress->length,
1911 + connectionAddress->length == 4 ? AF_INET : AF_INET6);
1912 if (sourceAddress && hostent) {
1913 #if defined(__SVR4) && defined(__sun)
1915 @@ -546,11 +550,34 @@
1920 + if (((struct sockaddr_in *)
1921 + originalAddress)->sin_family == AF_INET) {
1922 + data = (CARD8 *) &((struct sockaddr_in *)
1923 + originalAddress)->sin_addr.s_addr;
1926 + data = (CARD8 *) &((struct sockaddr_in6 *)
1927 + originalAddress)->sin6_addr;
1930 + if (connectionAddress->length == sizeof (struct in6_addr)) {
1932 + if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)data)) {
1933 + data += sizeof(struct in6_addr)-sizeof(struct in_addr);
1936 + if (!getString (name, INET6_ADDRSTRLEN+6))
1938 + (void) inet_ntop(AF_INET6, data, name, INET6_ADDRSTRLEN);
1939 + sprintf(name+strlen(name), ":%d", displayNumber);
1942 + if (connectionAddress->length != 4)
1945 if (!getString (name, 25))
1948 - data = (CARD8 *) &((struct sockaddr_in *)originalAddress)->
1950 sprintf(name, "%d.%d.%d.%d:%d",
1951 data[0], data[1], data[2], data[3], displayNumber);
1953 @@ -631,6 +658,29 @@
1960 + struct sockaddr_in6 in_addr;
1962 + if (clientAddress.length != 16 ||
1963 + clientPort.length != 2)
1967 + bzero ((char *) &in_addr, sizeof (in_addr));
1968 +#ifdef BSD44SOCKETS
1969 + in_addr.sin6_len = sizeof(in_addr);
1971 + in_addr.sin6_family = AF_INET6;
1972 + in_addr.sin6_flowinfo = 0;
1973 + memmove( &in_addr.sin6_addr, clientAddress.data, 16);
1974 + memmove( (char *) &in_addr.sin6_port, clientPort.data, 2);
1975 + client = (struct sockaddr *) &in_addr;
1976 + clientlen = sizeof (in_addr);
1983 @@ -1199,11 +1249,14 @@
1986 hostent = gethostbyaddr ((char *)connectionAddress->data,
1987 - connectionAddress->length, AF_INET);
1988 + connectionAddress->length,
1989 + connectionAddress->length == 4 ? AF_INET : AF_INET6);
1992 local_name = hostent->h_name;
1994 + if (connectionAddress->length != 4)
1996 /* can't get name, so use emergency fallback */
1997 sprintf(dotted, "%d.%d.%d.%d",
1998 connectionAddress->data[0],
1999 --- XFree86-3.3.3.1/xc/programs/xfs/difs/main.c.ipv6 Thu Jun 24 12:39:41 1999
2000 +++ XFree86-3.3.3.1/xc/programs/xfs/difs/main.c Thu Jun 24 12:39:47 1999
2005 +#include <sys/types.h>
2006 +#include <netinet/in.h>
2007 +#include <resolv.h>
2009 char *ConnectionInfo;
2017 + if ((_res.options & RES_INIT) == 0)
2019 + _res.options |= RES_USE_INET6;
2021 configfilename = DEFAULT_CONFIG_FILE;
2023 --- XFree86-3.3.3.1/xc/programs/xfs/os/access.c.ipv6 Sat Jan 18 08:02:45 1997
2024 +++ XFree86-3.3.3.1/xc/programs/xfs/os/access.c Thu Jun 24 12:39:47 1999
2029 - addr->addr_len = sizeof(struct in_addr);
2030 + addr->addr_len = sizeof(struct in6_addr);
2031 addr->address = (pointer) fsalloc(addr->addr_len);
2034 --- XFree86-3.3.3.1/xc/programs/xfwp/xfwp.c.ipv6 Fri Jan 23 00:53:25 1998
2035 +++ XFree86-3.3.3.1/xc/programs/xfwp/xfwp.c Thu Jun 24 14:22:13 1999
2038 #include <sys/wait.h>
2040 +#include <resolv.h>
2041 #if defined(_ANSI_SOURCE) && defined(__bsdi__)
2044 @@ -163,13 +164,13 @@
2045 main (int argc, char * argv[])
2047 struct clientDataStruct client_data;
2048 - struct sockaddr_in dest_server;
2049 + struct sockaddr_in6 dest_server;
2050 struct pm_policy policy;
2051 int pm_listen_array[MAX_TRANSPORTS];
2052 int pm_conn_counter;
2053 - struct sockaddr_in pm_sockaddr_in;
2054 + struct sockaddr_in6 pm_sockaddr_in6;
2055 int rem_listen_counter;
2056 - struct sockaddr_in rem_sockaddr_in;
2057 + struct sockaddr_in6 rem_sockaddr_in6;
2058 fd_set readable, writable, rinit, winit;
2061 @@ -196,6 +197,10 @@
2063 // now do the rest of the setup
2065 + if ((_res.options & RES_INIT) == 0)
2066 + (void) res_init();
2067 + _res.options |= RES_USE_INET6;
2069 doProcessInputArgs(config_info, argc, argv);
2070 if ((config_status = doHandleConfigFile(config_info)) == FAILURE)
2076 - struct sockaddr_in rem_sockaddr_in;
2077 + struct sockaddr_in6 rem_sockaddr_in6;
2084 if ((server_array[this_server]->client_listen_fd =
2085 - socket(AF_INET, SOCK_STREAM, 0)) < 0)
2086 + socket(AF_INET6, SOCK_STREAM, 0)) < 0)
2089 fprintf(stderr,"doRemClientSetup: socket() call failed!");
2090 @@ -599,8 +604,10 @@
2092 // set up the rest of the remote client listener
2094 - bzero((char * ) &rem_sockaddr_in, sizeof(rem_sockaddr_in));
2095 - rem_sockaddr_in.sin_family = AF_INET;
2096 + bzero((char * ) &rem_sockaddr_in6, sizeof(rem_sockaddr_in6));
2097 + rem_sockaddr_in6.sin6_family = AF_INET6;
2098 + rem_sockaddr_in6.sin6_flowinfo = 0;
2099 + rem_sockaddr_in6.sin6_addr = in6addr_any;
2100 if (setsockopt(server_array[this_server]->client_listen_fd,
2101 SOL_SOCKET, SO_REUSEADDR,
2102 &one, sizeof(one)) < 0)
2103 @@ -617,10 +624,10 @@
2107 - rem_sockaddr_in.sin_port = htons(listen_port);
2108 + rem_sockaddr_in6.sin6_port = htons(listen_port);
2109 if (bind(server_array[this_server]->client_listen_fd,
2110 - (struct sockaddr *)&rem_sockaddr_in,
2111 - sizeof(rem_sockaddr_in)) == 0)
2112 + (struct sockaddr *)&rem_sockaddr_in6,
2113 + sizeof(rem_sockaddr_in6)) == 0)
2115 if (errno != EADDRINUSE)
2117 @@ -1003,7 +1010,7 @@
2118 int server_reason_len;
2119 int conn_auth_namelen, conn_auth_datalen;
2120 char throw_away[RWBUFFER_SIZE];
2121 - struct sockaddr_in server_sockaddr_in;
2122 + struct sockaddr_in6 server_sockaddr_in6;
2123 enum CONFIG_CHECK server_status;
2124 xConnClientPrefix client;
2125 xConnSetupPrefix prefix;
2126 @@ -1039,10 +1046,10 @@
2128 struct timeval time_val;
2129 struct timezone time_zone;
2130 - struct sockaddr_in temp_sockaddr_in;
2131 + struct sockaddr_in6 temp_sockaddr_in6;
2134 - int addrlen = sizeof(temp_sockaddr_in);
2135 + int addrlen = sizeof(temp_sockaddr_in6);
2137 // start by accepting the connection if you can, use pm_listen_array
2138 // index to index into ICE listen_object list (this is because the
2139 @@ -1061,17 +1068,17 @@
2140 // connection; start by using getpeername() to get endpoint info
2142 retval = getpeername(temp_sock_fd,
2143 - (struct sockaddr*)&temp_sockaddr_in,
2144 + (struct sockaddr*)&temp_sockaddr_in6,
2147 - assert(temp_sockaddr_in.sin_family == AF_INET);
2148 + assert(temp_sockaddr_in6.sin6_family == AF_INET6);
2151 // then do the configuration check; NOTE: we're not doing anything
2152 - // with the server_sockaddr_in argument
2153 + // with the server_sockaddr_in6 argument
2155 - if ((config_check = doConfigCheck(&temp_sockaddr_in,
2156 - &server_sockaddr_in,
2157 + if ((config_check = doConfigCheck(&temp_sockaddr_in6,
2158 + &server_sockaddr_in6,
2161 &log_data)) == FAILURE)
2162 @@ -1302,17 +1309,18 @@
2163 // configuration, if connection allowed, allocate
2164 // the read/write buffer for this connection;
2166 - struct sockaddr_in temp_sockaddr_in;
2168 - int temp_sock_len;
2171 - struct timeval time_val;
2172 - struct timezone time_zone;
2173 + struct sockaddr_in6 temp_sockaddr_in6;
2175 + int temp_sock_len;
2178 + struct timeval time_val;
2179 + struct timezone time_zone;
2180 + char v1[64], v2[64];
2182 - temp_sock_len = sizeof(temp_sockaddr_in);
2183 + temp_sock_len = sizeof(temp_sockaddr_in6);
2184 if ((temp_sock_fd = accept(fd_counter,
2185 - (struct sockaddr *) &temp_sockaddr_in,
2186 + (struct sockaddr *) &temp_sockaddr_in6,
2187 &temp_sock_len)) < 0)
2190 @@ -1336,7 +1344,7 @@
2191 if ((server_status =
2192 doServerConnectSetup(server_array[listen_counter]->x_server_hostport,
2193 &server_array[listen_counter]->server_fd,
2194 - &server_sockaddr_in)) == FAILURE)
2195 + &server_sockaddr_in6)) == FAILURE)
2199 @@ -1346,7 +1354,7 @@
2201 if ((server_status =
2202 doServerConnect(&server_array[listen_counter]->server_fd,
2203 - &server_sockaddr_in)) == FAILURE)
2204 + &server_sockaddr_in6)) == FAILURE)
2208 @@ -1355,15 +1363,18 @@
2212 - // derive and save the client IP source and destination address strings
2213 - // for logging purposes (have to do it here while we have them; even if
2214 - // this client connection passes the config check, it might fail the
2215 - // server security checks later); also, init the config_rule_num field
2217 - log_data.source = Malloc(strlen(inet_ntoa(temp_sockaddr_in.sin_addr)));
2218 - log_data.destination = Malloc(strlen(inet_ntoa(server_sockaddr_in.sin_addr)));
2219 - strcpy(log_data.source, inet_ntoa(temp_sockaddr_in.sin_addr));
2220 - strcpy(log_data.destination, inet_ntoa(server_sockaddr_in.sin_addr));
2221 + // derive and save the client IPv6 source and destination
2222 + // address strings for logging purposes (have to do it here
2223 + // while we have them; even if this client connection passes
2224 + // the config check, it might fail the server security checks later);
2225 + // also, init the config_rule_num field
2227 + log_data.source = Malloc(strlen(inet_ntop(AF_INET6,
2228 + &temp_sockaddr_in6.sin6_addr, v1, sizeof(v1))));
2229 + log_data.destination = Malloc(strlen(inet_ntop(AF_INET6,
2230 + &server_sockaddr_in6.sin6_addr, v2, sizeof(v2))));
2231 + strcpy(log_data.source, v1);
2232 + strcpy(log_data.destination, v2);
2233 log_data.config_rule_num = -1;
2235 // do config check on client source and destination (must do
2236 @@ -1371,8 +1382,8 @@
2237 // to query and we may not be able to resolve server name
2238 // alone from xfindproxy()
2240 - if ((config_check = doConfigCheck(&temp_sockaddr_in,
2241 - &server_sockaddr_in,
2242 + if ((config_check = doConfigCheck(&temp_sockaddr_in6,
2243 + &server_sockaddr_in6,
2246 &log_data)) == FAILURE)
2247 @@ -1454,13 +1465,13 @@
2248 // server security extension or other loggable events)
2250 client_conn_array[temp_sock_fd]->source =
2251 - Malloc(strlen(inet_ntoa(temp_sockaddr_in.sin_addr)));
2252 + Malloc(strlen(inet_ntop(AF_INET6,
2253 + &temp_sockaddr_in6.sin6_addr, v1, sizeof(v1))));
2254 client_conn_array[temp_sock_fd]->destination =
2255 - Malloc(strlen(inet_ntoa(server_sockaddr_in.sin_addr)));
2256 - strcpy(client_conn_array[temp_sock_fd]->source,
2257 - inet_ntoa(temp_sockaddr_in.sin_addr));
2258 - strcpy(client_conn_array[temp_sock_fd]->destination,
2259 - inet_ntoa(server_sockaddr_in.sin_addr));
2260 + Malloc(strlen(inet_ntop(AF_INET6,
2261 + &server_sockaddr_in6.sin6_addr, v2, sizeof(v2))));
2262 + strcpy(client_conn_array[temp_sock_fd]->source, v1);
2263 + strcpy(client_conn_array[temp_sock_fd]->destination, v2);
2265 // allocate a buffer for the X server connection
2266 // and create the association between client and server
2267 @@ -1959,7 +1970,7 @@
2268 fprintf(stderr, "Server replied AUTHENTICATE!\n");
2271 - // retrieve the client IP source and destination address strings
2272 + // retrieve the client IPv6 source and destination address strings
2276 @@ -2030,13 +2041,22 @@
2277 }/* end if client_conn_array != NULL */
2280 -int doConfigCheck(struct sockaddr_in * source_sockaddr_in,
2281 - struct sockaddr_in * dest_sockaddr_in,
2282 +#define IN6ADDR_MATCH(x,m,y) \
2284 + for (i = 0; i < sizeof(struct in6_addr) && (m).s6_addr[i] != 0; i++) \
2285 + if (((x).s6_addr[i] & (m).s6_addr[i]) != (y).s6_addr[i]) { \
2290 +int doConfigCheck(struct sockaddr_in6 * source_sockaddr_in6,
2291 + struct sockaddr_in6 * dest_sockaddr_in6,
2292 struct config * config_info,
2294 struct log_struct * log_data)
2299 // look through the config file parse tree for a source IP address
2300 // that matches this request
2301 @@ -2045,12 +2065,13 @@
2303 if (config_info->config_file_data[line_counter] != NULL)
2305 - if ((source_sockaddr_in->sin_addr.s_addr &
2306 - (~(config_info->config_file_data[line_counter]->source_net))) ==
2307 - config_info->config_file_data[line_counter]->source_host)
2308 + IN6ADDR_MATCH(source_sockaddr_in6->sin6_addr,
2309 + config_info->config_file_data[line_counter]->source_net,
2310 + config_info->config_file_data[line_counter]->source_host);
2314 - // okay, the source host and netmask fields pass, see if the
2315 + // okay, the source host and prefix length fields pass, see if the
2316 // config file specifies "permit" or "deny" for this host
2318 if (!strcmp(config_info->config_file_data[line_counter]->permit_deny,
2319 @@ -2065,9 +2086,10 @@
2321 // compute destination info restrictions
2323 - if ((dest_sockaddr_in->sin_addr.s_addr &
2324 - (~(config_info->config_file_data[line_counter]->dest_net))) ==
2325 - config_info->config_file_data[line_counter]->dest_host)
2326 + IN6ADDR_MATCH(dest_sockaddr_in6->sin6_addr,
2327 + config_info->config_file_data[line_counter]->dest_net,
2328 + config_info->config_file_data[line_counter]->dest_host);
2332 // you got a match on the destination, so look at
2333 @@ -2171,9 +2193,10 @@
2335 // compute destination info restrictions
2337 - if ((dest_sockaddr_in->sin_addr.s_addr &
2338 - (~(config_info->config_file_data[line_counter]->dest_net))) ==
2339 - config_info->config_file_data[line_counter]->dest_host)
2340 + IN6ADDR_MATCH(dest_sockaddr_in6->sin6_addr,
2341 + config_info->config_file_data[line_counter]->dest_net,
2342 + config_info->config_file_data[line_counter]->dest_host);
2346 // you got a match on the destination, so look at
2347 @@ -2292,7 +2315,7 @@
2348 if (config_info->config_file_path == NULL)
2350 if (printConfigVerify)
2351 - fputs("matched default permit 0.0.0.0 255.255.255.255\n", stderr);
2352 + fputs("matched default permit :: 0\n", stderr);
2354 // there's no rule match to save
2356 @@ -2301,7 +2324,7 @@
2359 if (printConfigVerify)
2360 - fputs("matched default deny 0.0.0.0 255.255.255.255\n", stderr);
2361 + fputs("matched default deny :: 0\n", stderr);
2363 // not in this case either
2365 @@ -2395,8 +2418,8 @@
2366 pmGetProxyAddrReplyMsg * pReply;
2368 struct hostent * hostptr;
2369 - struct sockaddr_in server_sockaddr_in;
2370 - struct sockaddr_in dummy_sockaddr_in;
2371 + struct sockaddr_in6 server_sockaddr_in6;
2372 + struct sockaddr_in6 dummy_sockaddr_in6;
2373 char * server_name_base;
2375 char * config_failure = "unrecognized server or permission denied";
2376 @@ -2497,9 +2520,9 @@
2380 - memset(&server_sockaddr_in, 0, sizeof(server_sockaddr_in));
2381 - memset(&dummy_sockaddr_in, 0, sizeof(dummy_sockaddr_in));
2382 - memcpy((char *) &server_sockaddr_in.sin_addr,
2383 + memset(&server_sockaddr_in6, 0, sizeof(server_sockaddr_in6));
2384 + memset(&dummy_sockaddr_in6, 0, sizeof(dummy_sockaddr_in6));
2385 + memcpy((char *) &server_sockaddr_in6.sin6_addr,
2389 @@ -2509,11 +2532,11 @@
2390 // NOTE: source configuration will always match (see XFWP man
2391 // page) unless sysadmin explicitly chooses to deny
2393 - memcpy((char *) &dummy_sockaddr_in.sin_addr,
2394 + memcpy((char *) &dummy_sockaddr_in6.sin6_addr,
2397 - if ((config_check = doConfigCheck(&dummy_sockaddr_in,
2398 - &server_sockaddr_in,
2399 + if ((config_check = doConfigCheck(&dummy_sockaddr_in6,
2400 + &server_sockaddr_in6,
2401 global_data.config_info,
2403 &log_data)) == FAILURE)
2404 @@ -2759,7 +2782,7 @@
2406 int doServerConnectSetup(char * x_server_hostport,
2407 int * server_connect_fd,
2408 - struct sockaddr_in * server_sockaddr_in)
2409 + struct sockaddr_in6 * server_sockaddr_in6)
2411 struct hostent * hostptr;
2412 char * server_name_base;
2413 @@ -2796,7 +2819,7 @@
2417 - if ((*server_connect_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
2418 + if ((*server_connect_fd = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
2422 @@ -2805,20 +2828,20 @@
2426 - memset(server_sockaddr_in, 0, sizeof(*server_sockaddr_in));
2427 - server_sockaddr_in->sin_family = hostptr->h_addrtype;
2428 - memcpy((char *) &server_sockaddr_in->sin_addr,
2429 + memset(server_sockaddr_in6, 0, sizeof(*server_sockaddr_in6));
2430 + server_sockaddr_in6->sin6_family = hostptr->h_addrtype;
2431 + memcpy((char *) &server_sockaddr_in6->sin6_addr,
2434 - server_sockaddr_in->sin_port = htons(server_port);
2435 + server_sockaddr_in6->sin6_port = htons(server_port);
2439 int doServerConnect(int * server_connect_fd,
2440 - struct sockaddr_in * server_sockaddr_in)
2441 + struct sockaddr_in6 * server_sockaddr_in6)
2443 - if(connect(*server_connect_fd, (struct sockaddr * )server_sockaddr_in,
2444 - sizeof(*server_sockaddr_in)) < 0)
2445 + if(connect(*server_connect_fd, (struct sockaddr * )server_sockaddr_in6,
2446 + sizeof(*server_sockaddr_in6)) < 0)
2450 @@ -3122,13 +3145,13 @@
2452 config_lineP->permit_deny = NULL;
2453 config_lineP->source_hostname = NULL;
2454 - config_lineP->source_host = 0;
2455 - config_lineP->source_netmask = NULL;
2456 - config_lineP->source_net = 0;
2457 + bzero((char *)&config_lineP->source_host, sizeof(struct in6_addr));
2458 + config_lineP->source_preflen = NULL;
2459 + bzero((char *)&config_lineP->source_net, sizeof(struct in6_addr));
2460 config_lineP->dest_hostname = NULL;
2461 - config_lineP->dest_host = 0;
2462 - config_lineP->dest_netmask = NULL;
2463 - config_lineP->dest_net = 0;
2464 + bzero((char *)&config_lineP->dest_host, sizeof(struct in6_addr));
2465 + config_lineP->dest_preflen = NULL;
2466 + bzero((char *)&config_lineP->dest_net, sizeof(struct in6_addr));
2467 config_lineP->operator = NULL;
2468 config_lineP->service = NULL;
2470 @@ -3200,7 +3223,7 @@
2473 strcpy(token, result);
2474 - if (doVerifyHostMaskToken(token))
2475 + if (doVerifyHostToken(token))
2477 if ((config_file_data[line_number]->source_hostname =
2478 (char *) malloc (strlen(result) + 1)) == NULL)
2479 @@ -3219,22 +3242,24 @@
2481 // generate network address format
2483 - config_file_data[line_number]->source_host =
2484 - inet_addr(config_file_data[line_number]->source_hostname);
2485 + inet_pton(AF_INET6,
2486 + config_file_data[line_number]->source_hostname,
2487 + &config_file_data[line_number]->source_host);
2493 - // now the source netmask field
2494 + // now the source prefix length field
2496 if ((result = strtok(NULL, SEPARATOR1)) != NULL)
2500 strcpy(token, result);
2501 - if (doVerifyHostMaskToken(token))
2502 + if (doVerifyMaskToken(token))
2504 - if ((config_file_data[line_number]->source_netmask =
2505 + if ((config_file_data[line_number]->source_preflen =
2506 (char *) malloc (strlen(result) + 1)) == NULL)
2509 @@ -3242,14 +3267,18 @@
2513 - strcpy(config_file_data[line_number]->source_netmask, result);
2514 + strcpy(config_file_data[line_number]->source_preflen, result);
2517 "third token = %s\n",
2518 - config_file_data[line_number]->source_netmask);
2519 + config_file_data[line_number]->source_preflen);
2521 - config_file_data[line_number]->source_net =
2522 - inet_addr(config_file_data[line_number]->source_netmask);
2523 + plen = atoi(config_file_data[line_number]->source_preflen);
2524 + for (j = 0; plen >= 8; plen -= 8, j++)
2525 + config_file_data[line_number]->source_net.s6_addr[j] = 0xff;
2527 + config_file_data[line_number]->source_net.s6_addr[j] =
2528 + 0xff << (8 - plen);
2532 @@ -3260,7 +3289,7 @@
2535 strcpy(token, result);
2536 - if (doVerifyHostMaskToken(token))
2537 + if (doVerifyHostToken(token))
2539 if ((config_file_data[line_number]->dest_hostname =
2540 (char *) malloc (strlen(result) + 1)) == NULL)
2541 @@ -3276,21 +3305,23 @@
2542 "fourth token = %s\n",
2543 config_file_data[line_number]->dest_hostname);
2545 - config_file_data[line_number]->dest_host =
2546 - inet_addr(config_file_data[line_number]->dest_hostname);
2547 + inet_pton(AF_INET6,
2548 + config_file_data[line_number]->dest_hostname,
2549 + &config_file_data[line_number]->dest_host);
2554 - // now the destination netmask field
2555 + // now the destination prefix length field
2557 if ((result = strtok(NULL, SEPARATOR1)) != NULL)
2561 strcpy(token, result);
2562 - if (doVerifyHostMaskToken(token))
2563 + if (doVerifyMaskToken(token))
2565 - if ((config_file_data[line_number]->dest_netmask =
2566 + if ((config_file_data[line_number]->dest_preflen =
2567 (char *) malloc (strlen(result) + 1)) == NULL)
2570 @@ -3298,14 +3329,18 @@
2574 - strcpy(config_file_data[line_number]->dest_netmask, result);
2575 + strcpy(config_file_data[line_number]->dest_preflen, result);
2578 "fifth token = %s\n",
2579 - config_file_data[line_number]->dest_netmask);
2580 + config_file_data[line_number]->dest_preflen);
2582 - config_file_data[line_number]->dest_net =
2583 - inet_addr(config_file_data[line_number]->dest_netmask);
2584 + plen = atoi(config_file_data[line_number]->dest_preflen);
2585 + for (j = 0; plen >= 8; plen -= 8, j++)
2586 + config_file_data[line_number]->dest_net.s6_addr[j] = 0xff;
2588 + config_file_data[line_number]->dest_net.s6_addr[j] =
2589 + 0xff << (8 - plen);
2593 @@ -3377,9 +3412,9 @@
2594 ((config_file_data[line_number]->permit_deny != NULL) &&
2595 (config_file_data[line_number]->source_hostname == NULL)) ||
2596 ((config_file_data[line_number]->source_hostname != NULL) &&
2597 - (config_file_data[line_number]->source_netmask == NULL)) ||
2598 + (config_file_data[line_number]->source_preflen == NULL)) ||
2599 ((config_file_data[line_number]->dest_hostname != NULL) &&
2600 - (config_file_data[line_number]->dest_netmask == NULL)) ||
2601 + (config_file_data[line_number]->dest_preflen == NULL)) ||
2602 ((config_file_data[line_number]->operator != NULL) &&
2603 (config_file_data[line_number]->service == NULL)))
2605 @@ -3388,27 +3423,23 @@
2609 -int doVerifyHostMaskToken(char token[])
2610 +int doVerifyHostToken(char token[])
2613 - int delimiter_count = 0;
2614 + struct in6_addr addr;
2616 - // verify there are 3 "." delimiters in the token
2617 + // verify it is a real IPv6 address
2621 - if ((result = strchr(token, SEPARATOR2)) != NULL)
2624 - delimiter_count++;
2629 - if ((delimiter_count < 3) || (delimiter_count > 3))
2633 + return (inet_pton(AF_INET6, token, &addr) > 0);
2636 +int doVerifyMaskToken(char token[])
2640 + // verify it is a legal prefix length
2642 + plen = atoi(token);
2643 + return ((plen >= 0) && (plen <= 128));
2646 void BadSyntax(char *msg, int line)
2647 @@ -3483,8 +3514,8 @@
2648 struct config_line *ruleP = config_info->config_file_data[line_counter];
2649 fprintf(stderr,"matched: %s %s %s %s %s %s %s\n",
2651 - ruleP->source_hostname, ruleP->source_netmask,
2652 - ruleP->dest_hostname, ruleP->dest_netmask,
2653 + ruleP->source_hostname, ruleP->source_preflen,
2654 + ruleP->dest_hostname, ruleP->dest_preflen,
2658 --- XFree86-3.3.3.1/xc/programs/xfwp/xfwp.h.ipv6 Wed Jun 11 14:09:00 1997
2659 +++ XFree86-3.3.3.1/xc/programs/xfwp/xfwp.h Thu Jun 24 12:39:47 1999
2661 /* allocate ADD_LINES entries at a time when loading the configuration */
2662 #define ADD_LINES 20
2663 #define SEPARATOR1 " \t\n"
2664 -#define SEPARATOR2 '.'
2665 +#define SEPARATOR2 ':'
2667 #define min(a,b) ((a) < (b) ? (a) : (b))
2668 #define max(a,b) ((a) > (b) ? (a) : (b))
2669 @@ -194,13 +194,13 @@
2672 char * source_hostname;
2673 - unsigned int source_host;
2674 - char * source_netmask;
2675 - unsigned int source_net;
2676 + struct in6_addr source_host;
2677 + char * source_preflen;
2678 + struct in6_addr source_net;
2679 char * dest_hostname;
2680 - unsigned int dest_host;
2681 - char * dest_netmask;
2682 - unsigned int dest_net;
2683 + struct in6_addr dest_host;
2684 + char * dest_preflen;
2685 + struct in6_addr dest_net;
2690 struct client_conn_buf * client_conn_array[],
2691 struct ice_data * ice_data);
2693 -int doConfigCheck(struct sockaddr_in * temp_sockaddr_in,
2694 - struct sockaddr_in * server_sockaddr_in,
2695 +int doConfigCheck(struct sockaddr_in6 * temp_sockaddr_in6,
2696 + struct sockaddr_in6 * server_sockaddr_in6,
2697 struct config * config_info,
2699 struct log_struct * log_data);
2700 @@ -337,10 +337,10 @@
2702 int doServerConnectSetup(char * x_server_hostport,
2703 int * server_connect_fd,
2704 - struct sockaddr_in * server_addr_in);
2705 + struct sockaddr_in6 * server_addr_in6);
2707 int doServerConnect(int * server_connect_fd,
2708 - struct sockaddr_in * server_addr_in);
2709 + struct sockaddr_in6 * server_addr_in6);
2711 int doProcessLine(char *line,
2712 struct config * config_info,
2715 Bool doConfigRequireDisallow(int, char*);
2717 -int doVerifyHostMaskToken(char token[]);
2718 +int doVerifyHostToken(char token[]);
2720 +int doVerifyMaskToken(char token[]);
2722 void doInstallIOErrorHandler();
2724 --- XFree86-3.3.3.1/xc/programs/xfwp/xfwp.man.ipv6 Tue Dec 24 11:04:47 1996
2725 +++ XFree86-3.3.3.1/xc/programs/xfwp/xfwp.man Thu Jun 24 12:39:47 1999
2727 packet-filtering routers. It contains zero or more source-destination
2728 rules of the following form:
2730 -[#]{permit | deny} <src> <src mask> [<dest> <dest mask> [<operator> <service>]]
2731 +[#]{permit | deny} <src> <src len> [<dest> <dest len> [<operator> <service>]]
2734 comment delimiter; evaluator will skip these lines
2735 @@ -214,21 +214,21 @@
2736 the keywords ``permit'' or ``deny'' indicate whether the
2737 rule will enable or disable access, respectively
2739 -the IP address against the host who originated the
2740 -connection request will be matched, expressed in IP
2743 -a subnet mask, also in IP format, for further qualifying
2744 -the source mask. Bits set in the mask indicate bits of the
2745 +the IPv6 address against the host who originated the
2746 +connection request will be matched, expressed in IPv6
2747 +format (x:x:x:x:x:x:x:x)
2749 +a prefix length, a number between 0 and 128, for further qualifying
2750 +the source prefix. Bits after the prefix indicate bits of the
2751 incoming address to be \fIignored\fP when comparing to the specified src
2753 -the IP address against which the destination of the
2754 -incoming connection request (i.e. the host IP of the
2755 +the IPv6 address against which the destination of the
2756 +incoming connection request (i.e. the host IPv6 of the
2757 X server to which the incoming client is attempting to
2758 connect) will be matched
2760 -a subnet mask, also in IP format, for further qualifying
2761 -the destination mask. Bits set in the mask indicate bits of the
2763 +a prefix length, a number between 0 and 128, for further qualifying
2764 +the destination prefix. Bits after the prefix indicate bits of the
2765 destination address to be \fIignored\fP when comparing to the specified dest
2767 always ``eq'' (if the service field is not NULL)
2770 while (more entries to check)
2772 - if ((<originator IP> AND (NOT <src mask>)) == src)
2773 - [if ((<dest X server IP> AND (NOT <dest mask>)) == dest)]
2774 + if ((<originator IPv6> AND (<src prefix>)) == src)
2775 + [if ((<dest X server IPv6> AND (<dest prefix>)) == dest)]
2776 [if (service fields present and matching)]
2777 do either permit or deny connection depending on keyword
2779 @@ -312,22 +312,22 @@
2783 -# deny pm connections originating on 8.7.6.5 [NOTE: If pm service
2784 +# deny pm connections originating on 8:7:6:5:4:3:2:1 [NOTE: If pm service
2785 # is explicitly qualified, line must include destination fields as
2788 -deny 8.7.6.5 0.0.0.0 0.0.0.0 255.255.255.255 eq pm
2789 +deny 8:7:6:5:4:3:2:1 128 :: 0 eq pm
2791 # permit xfindproxy X server connects to anywhere [NOTE: If
2792 # fp service is explicitly qualified, line must include source fields
2795 -permit 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255 eq fp
2796 +permit :: 0 :: 0 eq fp
2798 -# permit all connection types originating from the 192.0.0.0
2800 +# permit all connection types originating from the fec0::/10
2803 -permit 192.0.0.0 0.255.255.255
2808 --- XFree86-3.3.3.1/xc/programs/xhost/xhost.c.ipv6 Sun Sep 13 15:15:59 1998
2809 +++ XFree86-3.3.3.1/xc/programs/xhost/xhost.c Thu Jun 24 12:39:47 1999
2813 #include <netinet/in.h>
2814 +#include <resolv.h>
2816 #include <server/ip/gen/socket.h>
2817 #include <server/ip/types.h>
2820 { AF_INET, FamilyInternet },
2823 + { AF_INET6, FamilyInternet },
2827 #define FAMILIES ((sizeof familyMap)/(sizeof familyMap[0]))
2828 @@ -184,6 +188,12 @@
2830 ProgramName = argv[0];
2833 + if ((_res.options & RES_INIT) == 0)
2835 + _res.options |= RES_USE_INET6;
2838 if ((dpy = XOpenDisplay(NULL)) == NULL) {
2839 fprintf(stderr, "%s: unable to open display \"%s\"\n",
2840 ProgramName, XDisplayName (NULL));
2845 - static struct in_addr addr; /* so we can point at it */
2846 + static struct in6_addr addr; /* so we can point at it */
2848 static ipaddr_t addr;
2850 @@ -484,41 +494,30 @@
2854 - * First see if inet_addr() can grok the name; if so, then use it.
2857 - if ((addr.s_addr = inet_addr(name)) != -1) {
2859 - if ((addr = inet_addr(name)) != -1) {
2861 - ha.family = FamilyInternet;
2862 - ha.length = 4; /* but for Cray would be sizeof(addr.s_addr) */
2863 - ha.address = (char *)&addr; /* but for Cray would be &addr.s_addr */
2865 - XAddHost (dpy, &ha);
2866 - printf ("%s %s\n", name, add_msg);
2868 - XRemoveHost (dpy, &ha);
2869 - printf ("%s %s\n", name, remove_msg);
2874 + * (gethostbyname knows how to handle litterals...)
2875 * Is it in the namespace?
2877 - else if (((hp = gethostbyname(name)) == (struct hostent *)NULL)
2878 - || hp->h_addrtype != AF_INET) {
2879 + if (((hp = gethostbyname(name)) == (struct hostent *)NULL)
2880 + || hp->h_addrtype != AF_INET6) {
2883 ha.family = XFamily(hp->h_addrtype);
2884 - ha.length = hp->h_length;
2885 #ifdef h_addr /* new 4.3bsd version of gethostent */
2889 /* iterate over the hosts */
2890 for (list = hp->h_addr_list; *list; list++) {
2891 + ha.length = hp->h_length;
2893 +#ifdef UNMAPPED_IPV4
2894 + if ((ha.family == FamilyInternet) &&
2895 + (ha.length == sizeof(struct in6_addr)) &&
2896 + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ha.address)) {
2897 + ha.length = sizeof(struct in_addr);
2898 + ha.address += sizeof(struct in6_addr) - sizeof(struct in_addr);
2902 XAddHost (dpy, &ha);
2904 @@ -527,7 +526,16 @@
2908 + ha.length = hp->h_length;
2909 ha.address = hp->h_addr;
2910 +#ifdef UNMAPPED_IPV4
2911 + if ((ha.family == FamilyInternet) &&
2912 + (ha.length == sizeof(struct in6_addr)) &&
2913 + IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ha.address)) {
2914 + ha.length = sizeof(struct in_addr);
2915 + ha.address += sizeof(struct in6_addr) - sizeof(struct in_addr);
2919 XAddHost (dpy, &ha);
2924 * get_hostname - Given an internet address, return a name (CHARON.MIT.EDU)
2925 - * or a string representing the address (18.58.0.13) if the name cannot
2926 + * or a string representing the address (::ffff:18.58.0.13) if the name cannot
2932 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
2933 struct hostent *hp = NULL;
2934 - char *inet_ntoa();
2935 + static char v[64];
2939 @@ -571,12 +579,6 @@
2941 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
2942 if (ha->family == FamilyInternet) {
2944 - struct in_addr t_addr;
2945 - bzero((char *)&t_addr, sizeof(t_addr));
2946 - bcopy(ha->address, (char *)&t_addr, 4);
2947 - ha->address = (char *)&t_addr;
2949 /* gethostbyaddr can take a LONG time if the host does not exist.
2950 Assume that if it does not respond in NAMESERVER_TIMEOUT seconds
2951 that something is wrong and do not make the user wait.
2952 @@ -586,16 +588,17 @@
2953 signal(SIGALRM, nameserver_lost);
2955 if (setjmp(env) == 0) {
2956 - hp = gethostbyaddr (ha->address, ha->length, AF_INET);
2957 + hp = gethostbyaddr (ha->address, ha->length,
2958 + ha->length == 4 ? AF_INET : AF_INET6);
2962 return (hp->h_name);
2964 - else return (inet_ntoa(*((struct in_addr *)(ha->address))));
2966 - else return (inet_ntoa(*((ipaddr_t *)(ha->address))));
2969 + inet_ntop(ha->length == 4 ? AF_INET : AF_INET6,
2970 + ha->address, v, sizeof(v));
2975 if (ha->family == FamilyNetname) {