]> git.pld-linux.org Git - packages/XFree86.git/blame - XFree86-IPv6.patch
- added IPv6 patch (work ok)
[packages/XFree86.git] / XFree86-IPv6.patch
CommitLineData
047d95d5
AF
1diff -ruN xc.old/IPv6-README xc/IPv6-README
2--- xc.old/IPv6-README Thu Jan 1 01:00:00 1970
3+++ xc/IPv6-README Wed Feb 24 14:33:54 1999
4@@ -0,0 +1,88 @@
5+This patch is fot the INRIA Net/FreeBSD IPv6 code
6+It can also work on KAME IPv6 code. For support see at the end
7+
8+1/ This patch is based on the distribution XFree86 Release 3.3.3 patch 1
9+ It also works on the xsrc distribution provided with NetBSD 1.3.3
10+
11+2/ This patch contains a xc/config/cf/host.def file which sets the compile
12+ option -pipe and suppress the build of the fonts.
13+
14+3/ For FreeBSD3.0, if you use elf format (the default), you should add the
15+ generation of the shared libraries in aout format (legacy format)
16+ To do this, add in the file xc/config/cf/host.def the line:
17+#define BuildAoutLibraries YES
18+
19+4/ In the NetBSD 1.3.3 case some -orig files do not match with the distribution,
20+ but the IPv6 patch compiles and works.
21+
22+==== INSTALL ===
23+To apply the patch on FreeBSD:
24+- Install XFree86 from binary distribution
25+- Get the distributed source archive source/X333src-1.tgz on a XFree86-3.3.3
26+ or XFree86-3.3.3.1 ftp repository
27+ BEWARE: the source distribution is at level 3.3.3, NOT 3.3.3.1
28+- Get the upgrade patch(es) 3.3.3->3.3.3.1 on a XFree86-3.3.3.1 repository
29+ (It should be the file fixes/3.3.3-3.3.3.1.diff.gz) and apply it
30+ (in the source directory containing the xc dir, using:
31+ cd ..../xc/..
32+ patch -p -E < 3.3.3-3.3.3.1.diff
33+ )
34+- Go in the source directory containing the xc dir, expand the IPv6 patch, and
35+ install it by renaming the XX-new files, replacing the original XX file.
36+ cd ..../xc/..
37+ tar zxf X11-990111.tgz
38+ find . -type f -name '*-new' -exec csh -c \
39+ 'set f={}; set f=$f:s/-new//; cp -p ${f}-new $f' \;
40+- Update the xc/config/cf/host.def for aout libraries if needed
41+- make the X11 world and install it
42+ BEWARE : the installation will overrides the installed X server.
43+ Before the install, note the name of the installed X server
44+ (ls -l /usr/X11R6/bin/X) and restore the correct link after the
45+ installation.
46+
47+To apply the patch on NetBSD:
48+- Install X11 from binary distribution
49+- Get the distributed source/sets/xsrc.tgz on a ftp NetBSD repository
50+- Go in the source directory containing the xc dir, expand the IPv6 patch, and
51+ install it by renaming the XX-new files, replacing the original XX file.
52+ cd ..../xc/..
53+ tar zxf X11-990111.tgz
54+ find . -type f -name '*-new' -exec csh -c \
55+ 'set f={}; set f=$f:s/-new//; cp -p ${f}-new $f' \;
56+- Update the xc/config/cf/host.def if needed (e.g. for building fonts)
57+- make the X11 world and install it
58+ BEWARE : the installation may overrides the installed X server.
59+ Before the install, note the name of the installed X server
60+ (ls -l /usr/X11R6/bin/X) and restore the correct link after the
61+ installation.
62+
63+=========
64+KAME support : You need to add -linet6 to library list; For example, add
65+the following lines at the end of the xc/config/cf/host.def file:
66+
67+*** ../src.Free//xc/config/cf/host.def Wed Feb 24 14:29:40 1999
68+--- xc/config/cf/host.def Wed Feb 24 14:28:07 1999
69+***************
70+*** 44,46 ****
71+--- 44,64 ----
72+ # endif
73+ # endif
74+ #endif
75++
76++ /*
77++ * Set KAME library - copied form *BSD.cf, and modified
78++ */
79++ #ifdef AfterVendorCF
80++ # ifdef FreeBSDArchitecture
81++ /* support for multi-byte locales is in libxpg4 rather than libc */
82++ #if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 2)
83++ #undef ExtraLibraries
84++ #define ExtraLibraries -lxpg4 -L/usr/local/v6/lib -linet6
85++ #else
86++ #define ExtraLibraries -L/usr/local/v6/lib -linet6
87++ #endif
88++ # endif
89++ # ifdef NetBSDArchitecture
90++ #define ExtraLibraries -L/usr/local/v6/lib -linet6
91++ # endif
92++ #endif
93diff -ruN xc.old/config/cf/host.def xc/config/cf/host.def
94--- xc.old/config/cf/host.def Thu Jan 1 01:00:00 1970
95+++ xc/config/cf/host.def Tue Apr 14 15:50:10 1998
96@@ -0,0 +1,28 @@
97+/*
98+ * Do not build fonts: use the binary distrib
99+ */
100+#define BuildFonts NO
101+
102+/*
103+ * Don't build PC98 servers
104+ */
105+#define BuildPC98Servers NO
106+
107+/*
108+ * Set -pipe for XFree86 for NetBSD 1.3 on i386
109+ */
110+#ifdef i386Architecture
111+# define DefaultGcc2i386Opt -O2 -fno-strength-reduce -pipe
112+#endif
113+
114+/*
115+ * Set -pipe for NetBSD 1.3 on sparc
116+ */
117+#ifdef NetBSDArchitecture
118+# ifdef SparcArchitecture
119+# ifdef AfterVendorCF
120+# undef OptimizedCDebugFlags
121+# define OptimizedCDebugFlags -O2 -pipe
122+# endif
123+# endif
124+#endif
125diff -ruN xc.old/lib/SM/sm_genid.c xc/lib/SM/sm_genid.c
126--- xc.old/lib/SM/sm_genid.c Sun Oct 4 16:36:38 1998
127+++ xc/lib/SM/sm_genid.c Fri Jan 8 19:37:33 1999
128@@ -64,6 +64,7 @@
129 #define XOS_USE_NO_LOCKING
130 #define X_INCLUDE_NETDB_H
131 #include <X11/Xos_r.h>
132+#include <resolv.h>
133 #endif
134
135 #else /* WIN32 */
136@@ -137,6 +138,7 @@
137
138 #if defined(TCPCONN) || defined(STREAMSCONN)
139 {
140+ u_long options;
141 char* inet_addr;
142 char temp[4], *ptr1, *ptr2;
143 unsigned char decimal[4];
144@@ -144,7 +146,13 @@
145 _Xgethostbynameparams hparams;
146 struct hostent *hostp;
147
148- if ((hostp = _XGethostbyname (hostname,hparams)) != NULL)
149+ if ((_res.options & RES_INIT) == 0)
150+ (void) res_init ();
151+ options = _res.options;
152+ _res.options &= ~RES_USE_INET6;
153+ hostp = _XGethostbyname (hostname,hparams);
154+ _res.options = options;
155+ if (hostp != NULL)
156 inet_addr = inet_ntoa (*(struct in_addr *)(hostp->h_addr));
157 else
158 return NULL;
159diff -ruN xc.old/lib/X11/ConnDis.c xc/lib/X11/ConnDis.c
160--- xc.old/lib/X11/ConnDis.c Sat Jan 18 07:51:49 1997
161+++ xc/lib/X11/ConnDis.c Tue Mar 17 15:52:29 1998
162@@ -163,7 +163,9 @@
163
164 if (!lastc) return NULL; /* must have a colon */
165
166- if ((lastp != lastc) && (*(lastc - 1) == ':')) {
167+ /* :: is DECnet, : and ::: are IPv6 */
168+ if ((lastp != lastc) && (*(lastc - 1) == ':') &&
169+ (lastp == lastc-1 || *(lastc - 2) != ':') ) {
170 /* DECnet display specified */
171
172 #ifndef DNETCONN
173@@ -334,7 +336,7 @@
174 _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr);
175
176 /*
177- * The family is given in a socket format (ie AF_INET). This
178+ * The family is given in a socket format (ie AF_INET[6]). This
179 * will convert it to the format used by the authorization and
180 * X protocol (ie FamilyInternet).
181 */
182@@ -1026,6 +1028,21 @@
183 for(i=4; i<8; i++) /* do sin_addr */
184 xdmcp_data[j++] = ((char *)addr)[i];
185 for(i=2; i<4; i++) /* do sin_port */
186+ xdmcp_data[j++] = ((char *)addr)[i];
187+ break;
188+ }
189+#endif /* AF_INET */
190+#ifdef AF_INET6
191+ case AF_INET6:
192+ {
193+ /*
194+ * addr will contain a sockaddr_in6 with all
195+ * of the members already in network byte order.
196+ */
197+
198+ for(i=20; i<24; i++) /* do sin6_addr last 4 bytes */
199+ xdmcp_data[j++] = ((char *)addr)[i];
200+ for(i=2; i<4; i++) /* do sin6_port */
201 xdmcp_data[j++] = ((char *)addr)[i];
202 break;
203 }
204diff -ruN xc.old/lib/X11/Imakefile xc/lib/X11/Imakefile
205--- xc.old/lib/X11/Imakefile Fri Nov 6 17:32:30 1998
206+++ xc/lib/X11/Imakefile Fri Jan 8 19:46:58 1999
207@@ -947,6 +947,7 @@
208 InstallLintLibrary(X11,$(LINTLIBDIR))
209
210
211+SpecialCLibObjectRule(AuGetBest,$(ICONFIGFILES),$(CONN_DEFINES))
212 LinkSourceFile(AuDispose.c,$(XAUTHSRC))
213 LinkSourceFile(AuGetBest.c,$(XAUTHSRC))
214 LinkSourceFile(AuFileName.c,$(XAUTHSRC))
215diff -ruN xc.old/lib/Xau/AuGetBest.c xc/lib/Xau/AuGetBest.c
216--- xc.old/lib/Xau/AuGetBest.c Sun Dec 22 04:20:12 1996
217+++ xc/lib/Xau/AuGetBest.c Fri Mar 27 16:12:54 1998
218@@ -49,6 +49,32 @@
219 return 1;
220 }
221
222+#if defined(TCPCONN)
223+#include <netinet/in.h>
224+#include <X11/X.h>
225+#define MAPTOIPV4(a) ((char *)(a) + sizeof(struct in6_addr) - \
226+ sizeof(struct in_addr))
227+#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
228+static int
229+inetMapEqual (a4, l4, a6, l6)
230+ char *a4, *a6;
231+ int l4, l6;
232+{
233+ /* compare IPv4 with special IPv6 : mapped, loopback */
234+ if (l4 == sizeof(struct in6_addr) && l6 == sizeof(struct in_addr)) {
235+ char *a = a4;
236+ a4 = a6;
237+ a6 = a;
238+ } else if (l6 != sizeof(struct in6_addr) || l4 != sizeof(struct in_addr))
239+ return 0;
240+ if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)a6))
241+ return !acmp(a4, MAPTOIPV4(a6), sizeof(*a4));
242+ else
243+ return (a4[0] == 127 && a4[1] == 0 && a4[2] == 0 && a4[3] == 1 &&
244+ acmp(a6, &in6addr_loopback, sizeof(*a6)) == 0);
245+}
246+#endif
247+
248 #if NeedFunctionPrototypes
249 Xauth *
250 XauGetBestAuthByAddr (
251@@ -147,6 +173,13 @@
252 (entry->family == family &&
253 ((address_length == entry->address_length &&
254 binaryEqual (entry->address, address, (int)address_length))
255+#if defined(TCPCONN)
256+ || (family == FamilyInternet &&
257+ address_length != entry->address_length &&
258+ inetMapEqual ((char *)entry->address,
259+ (int)entry->address_length,
260+ (char *)address, (int)address_length))
261+#endif
262 #ifdef hpux
263 || (family == FamilyLocal &&
264 fully_qual_address_length == entry->address_length &&
265diff -ruN xc.old/lib/Xau/Imakefile xc/lib/Xau/Imakefile
266--- xc.old/lib/Xau/Imakefile Fri Nov 6 17:32:44 1998
267+++ xc/lib/Xau/Imakefile Fri Jan 8 19:44:33 1999
268@@ -23,6 +23,9 @@
269 INCLUDES =
270 #endif
271
272+ CONN_DEFINES = ConnectionFlags
273+ DEPEND_DEFINES = $(CONN_DEFINES)
274+
275 HEADERS = \
276 Xauth.h
277
278@@ -33,6 +36,8 @@
279 AuRead.o AuUnlock.o AuWrite.o $(K5ENCOBJ)
280
281 #include <Library.tmpl>
282+
283+SpecialCLibObjectRule(AuGetBest,$(ICONFIGFILES),$(CONN_DEFINES))
284
285 InstallLinkKitLibrary(Xau,$(LINKKITDIR)/lib)
286
287diff -ruN xc.old/lib/Xmu/CvtStdSel.c xc/lib/Xmu/CvtStdSel.c
288--- xc.old/lib/Xmu/CvtStdSel.c Sat Jan 18 07:52:13 1997
289+++ xc/lib/Xmu/CvtStdSel.c Mon Jul 7 22:19:34 1997
290@@ -225,7 +225,9 @@
291 if ((hostp = _XGethostbyname (hostname,hparams)) == NULL)
292 return False;
293
294- if (hostp->h_addrtype != AF_INET) return False;
295+ if ((hostp->h_addrtype != AF_INET) &&
296+ (hostp->h_addrtype != AF_INET6))
297+ return False;
298 *length = hostp->h_length;
299 *value = XtMalloc(*length);
300 (void) memmove (*value, hostp->h_addr, *length);
301diff -ruN xc.old/lib/xtrans/Xtrans.c xc/lib/xtrans/Xtrans.c
302--- xc.old/lib/xtrans/Xtrans.c Sun Dec 13 18:12:01 1998
303+++ xc/lib/xtrans/Xtrans.c Fri Jan 8 21:05:29 1999
304@@ -218,7 +218,9 @@
305 *
306 * If the protocol part is missing, then assume INET.
307 * If the protocol part and host part are missing, then assume local.
308- * If a "::" is found then assume DNET.
309+ * If a "host::" is found then assume DNET.
310+ * For IPv6, pb with possible : in host --> use rightmost : and test
311+ * x:y->inet, x::y->dnet, x:::y->inet(v6)
312 */
313
314 char *mybuf, *tmpptr;
315@@ -289,7 +291,23 @@
316
317 _host = mybuf;
318
319- if ((mybuf = strchr (mybuf,':')) == NULL)
320+ /* For IPv6, we need the rightmost : in the non-catalog part */
321+ {
322+ char *p;
323+#if defined(FONT_t) || defined(FS_t)
324+ char *f = strchr (mybuf, '/');
325+ if (f) *f = 0;
326+#endif
327+ p = strrchr (mybuf,':');
328+ if (p && p > mybuf && p[-1] == ':')
329+ if (p-1 == mybuf || p[-2] != ':')
330+ p--;
331+ mybuf = p;
332+#if defined(FONT_t) || defined(FS_t)
333+ if (f) *f = '/';
334+#endif
335+ }
336+ if (mybuf == NULL)
337 {
338 *protocol = NULL;
339 *host = NULL;
340diff -ruN xc.old/lib/xtrans/Xtranssock.c xc/lib/xtrans/Xtranssock.c
341--- xc.old/lib/xtrans/Xtranssock.c Fri Dec 18 15:56:11 1998
342+++ xc/lib/xtrans/Xtranssock.c Fri Jan 8 21:06:42 1999
343@@ -70,6 +70,7 @@
344 #define X_INCLUDE_NETDB_H
345 #define XOS_USE_NO_LOCKING
346 #include <X11/Xos_r.h>
347+#include <resolv.h>
348 #endif
349
350 #ifdef UNIXCONN
351@@ -190,8 +191,8 @@
352
353 static Sockettrans2dev Sockettrans2devtab[] = {
354 #ifdef TCPCONN
355- {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
356- {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
357+ {"inet",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
358+ {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
359 #endif /* TCPCONN */
360 #ifdef UNIXCONN
361 {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
362@@ -294,7 +295,7 @@
363 XtransConnInfo ciptr;
364
365 {
366- struct sockaddr_in sockname;
367+ struct sockaddr_in6 sockname;
368 #if defined(SVR4) || defined(SCO325)
369 size_t namelen = sizeof sockname;
370 #else
371@@ -322,7 +323,7 @@
372 return -1;
373 }
374
375- ciptr->family = sockname.sin_family;
376+ ciptr->family = sockname.sin6_family;
377 ciptr->addrlen = namelen;
378 memcpy (ciptr->addr, &sockname, ciptr->addrlen);
379
380@@ -341,7 +342,7 @@
381 XtransConnInfo ciptr;
382
383 {
384- struct sockaddr_in sockname;
385+ struct sockaddr_in6 sockname;
386 #if defined(SVR4) || defined(SCO325)
387 size_t namelen = sizeof sockname;
388 #else
389@@ -410,10 +411,11 @@
390 }
391
392 #ifdef TCP_NODELAY
393- if (Sockettrans2devtab[i].family == AF_INET)
394+ if ((Sockettrans2devtab[i].family == AF_INET) ||
395+ (Sockettrans2devtab[i].family == AF_INET6))
396 {
397 /*
398- * turn off TCP coalescence for INET sockets
399+ * turn off TCP coalescence for INET[6] sockets
400 */
401
402 int tmp = 1;
403@@ -546,10 +548,11 @@
404 #ifdef SO_REUSEADDR
405
406 /*
407- * SO_REUSEADDR only applied to AF_INET
408+ * SO_REUSEADDR only applied to AF_INET6
409 */
410
411- if (Sockettrans2devtab[i].family == AF_INET)
412+ if ((Sockettrans2devtab[i].family == AF_INET) ||
413+ (Sockettrans2devtab[i].family == AF_INET6))
414 {
415 int one = 1;
416 setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR,
417@@ -770,7 +773,8 @@
418
419 PRMSG (3, "SocketCreateListener(%x,%d)\n", ciptr, fd, 0);
420
421- if (Sockettrans2devtab[ciptr->index].family == AF_INET)
422+ if ((Sockettrans2devtab[ciptr->index].family == AF_INET) ||
423+ (Sockettrans2devtab[ciptr->index].family == AF_INET6))
424 retry = 20;
425 else
426 retry = 0;
427@@ -793,7 +797,8 @@
428 #endif /* SO_REUSEDADDR */
429 }
430
431- if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
432+ if ((Sockettrans2devtab[ciptr->index].family == AF_INET) ||
433+ (Sockettrans2devtab[ciptr->index].family == AF_INET)) {
434 #ifdef SO_DONTLINGER
435 setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
436 #else
437@@ -830,7 +835,7 @@
438 char *port;
439
440 {
441- struct sockaddr_in sockname;
442+ struct sockaddr_in6 sockname;
443 int namelen = sizeof(sockname);
444 int status;
445 short tmpport;
446@@ -878,22 +883,23 @@
447 port, 0, 0);
448 return TRANS_CREATE_LISTENER_FAILED;
449 }
450- sockname.sin_port = servp->s_port;
451+ sockname.sin6_port = servp->s_port;
452 }
453 else
454 {
455 tmpport = (short) atoi (port);
456- sockname.sin_port = htons (tmpport);
457+ sockname.sin6_port = htons (tmpport);
458 }
459 }
460 else
461- sockname.sin_port = htons (0);
462+ sockname.sin6_port = htons (0);
463
464 #ifdef BSD44SOCKETS
465- sockname.sin_len = sizeof (sockname);
466+ sockname.sin6_len = sizeof (sockname);
467 #endif
468- sockname.sin_family = AF_INET;
469- sockname.sin_addr.s_addr = htonl (INADDR_ANY);
470+ sockname.sin6_family = AF_INET6;
471+ sockname.sin6_flowinfo = 0;
472+ sockname.sin6_addr = in6addr_any;
473
474 if ((status = TRANS(SocketCreateListener) (ciptr,
475 (struct sockaddr *) &sockname, namelen)) < 0)
476@@ -1089,7 +1095,7 @@
477
478 {
479 XtransConnInfo newciptr;
480- struct sockaddr_in sockname;
481+ struct sockaddr_in6 sockname;
482 int namelen = sizeof(sockname);
483
484 PRMSG (2, "SocketINETAccept(%x,%d)\n", ciptr, ciptr->fd, 0);
485@@ -1252,7 +1258,7 @@
486 char *port;
487
488 {
489- struct sockaddr_in sockname;
490+ struct sockaddr_in6 sockname;
491 #if defined(SVR4) || defined(SCO325)
492 size_t namelen = sizeof sockname;
493 #else
494@@ -1262,14 +1268,15 @@
495 _Xgetservbynameparams sparams;
496 struct hostent *hostp;
497 struct servent *servp;
498+ u_long options;
499
500 #define PORTBUFSIZE 64 /* what is a real size for this? */
501 char portbuf[PORTBUFSIZE];
502
503 int ret;
504 short tmpport;
505- unsigned long tmpaddr;
506 char hostnamebuf[256]; /* tmp space */
507+ char v[64]; /* Vixie's tmp space */
508
509 PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port);
510
511@@ -1305,67 +1312,44 @@
512 */
513
514 #ifdef BSD44SOCKETS
515- sockname.sin_len = sizeof (struct sockaddr_in);
516+ sockname.sin6_len = sizeof (struct sockaddr_in6);
517 #endif
518- sockname.sin_family = AF_INET;
519+ sockname.sin6_family = AF_INET6;
520+ sockname.sin6_flowinfo = 0;
521
522 /*
523- * fill in sin_addr
524+ * fill in sin6_addr
525 */
526
527- /* check for ww.xx.yy.zz host string */
528-
529- if (isascii (host[0]) && isdigit (host[0])) {
530- tmpaddr = inet_addr (host); /* returns network byte order */
531- } else {
532- tmpaddr = -1;
533- }
534-
535- PRMSG (4,"SocketINETConnect: inet_addr(%s) = %x\n",
536- host, tmpaddr, 0);
537+ /* ww.xx.yy.zz host string done by _XGethostbyname() */
538
539- if (tmpaddr == -1)
540- {
541- if ((hostp = _XGethostbyname(host,hparams)) == NULL)
542- {
543- PRMSG (1,"SocketINETConnect: Can't get address for %s\n",
544- host, 0, 0);
545- ESET(EINVAL);
546- return TRANS_CONNECT_FAILED;
547- }
548- if (hostp->h_addrtype != AF_INET) /* is IP host? */
549- {
550- PRMSG (1,"SocketINETConnect: not INET host%s\n",
551- host, 0, 0);
552- ESET(EPROTOTYPE);
553- return TRANS_CONNECT_FAILED;
554- }
555-
556-#if defined(CRAY) && defined(OLDTCP)
557- /* Only Cray UNICOS3 and UNICOS4 will define this */
558- {
559- long t;
560- memcpy ((char *)&t, (char *) hostp->h_addr, sizeof (t));
561- sockname.sin_addr = t;
562- }
563-#else
564- memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr,
565- sizeof (sockname.sin_addr));
566-#endif /* CRAY and OLDTCP */
567-
568+ if ((_res.options & RES_INIT) == 0)
569+ (void)res_init();
570+ options = _res.options;
571+ _res.options |= RES_USE_INET6;
572+
573+ hostp = _XGethostbyname(host,hparams);
574+ _res.options = options;
575+ if (hostp == NULL)
576+ {
577+ PRMSG (1,"SocketINETConnect: Can't get address for %s\n",
578+ host, 0, 0);
579+ ESET(EINVAL);
580+ return TRANS_CONNECT_FAILED;
581 }
582-else
583+ if (hostp->h_addrtype != AF_INET6) /* is IPv6 host? */
584 {
585-#if defined(CRAY) && defined(OLDTCP)
586- /* Only Cray UNICOS3 and UNICOS4 will define this */
587- sockname.sin_addr = tmpaddr;
588-#else
589- sockname.sin_addr.s_addr = tmpaddr;
590-#endif /* CRAY and OLDTCP */
591+ PRMSG (1,"SocketINETConnect: not INET host%s\n",
592+ host, 0, 0);
593+ ESET(EPROTOTYPE);
594+ return TRANS_CONNECT_FAILED;
595 }
596+
597+ memcpy ((char *) &sockname.sin6_addr, (char *) hostp->h_addr,
598+ sizeof (sockname.sin6_addr));
599
600 /*
601- * fill in sin_port
602+ * fill in sin6_port
603 */
604
605 /* Check for number in the port string */
606@@ -1378,16 +1362,16 @@
607 portbuf, 0, 0);
608 return TRANS_CONNECT_FAILED;
609 }
610- sockname.sin_port = servp->s_port;
611+ sockname.sin6_port = servp->s_port;
612 }
613 else
614 {
615 tmpport = (short) atoi (portbuf);
616- sockname.sin_port = htons (tmpport);
617+ sockname.sin6_port = htons (tmpport);
618 }
619
620- PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n",
621- ntohs(sockname.sin_port), 0, 0);
622+ PRMSG (4,"SocketINETConnect: sockname.sin6_port = %d\n",
623+ ntohs(sockname.sin6_port), 0, 0);
624
625 /*
626 * Do the connect()
627@@ -1475,13 +1459,21 @@
628 * by TRANS(GetHostname)), then the two hostnames are equivalent,
629 * and we know that 'host' is really a local host.
630 */
631- char specified_local_addr_list[10][4];
632+ char specified_local_addr_list[10][16];
633 int scount, equiv, i, j;
634 _Xgethostbynameparams hparams;
635 struct hostent *hostp;
636+ u_long options;
637
638- if ((hostp = _XGethostbyname (host,hparams)) == NULL)
639+ if ((_res.options & RES_INIT) == 0)
640+ (void)res_init();
641+ options = _res.options;
642+ _res.options |= RES_USE_INET6;
643+
644+ if ((hostp = _XGethostbyname (host,hparams)) == NULL) {
645+ _res.options = options;
646 return (0);
647+ }
648
649 scount = 0;
650 while (hostp->h_addr_list[scount] && scount <= 8)
651@@ -1491,17 +1483,14 @@
652 * from the 1st call, so we must save the address list.
653 */
654
655- specified_local_addr_list[scount][0] =
656- hostp->h_addr_list[scount][0];
657- specified_local_addr_list[scount][1] =
658- hostp->h_addr_list[scount][1];
659- specified_local_addr_list[scount][2] =
660- hostp->h_addr_list[scount][2];
661- specified_local_addr_list[scount][3] =
662- hostp->h_addr_list[scount][3];
663+ memcpy(specified_local_addr_list[scount],
664+ hostp->h_addr_list[scount],
665+ hostp->h_length);
666 scount++;
667 }
668- if ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL)
669+ hostp = _XGethostbyname (hostnamebuf,hparams);
670+ _res.options = options;
671+ if (hostp == NULL)
672 return (0);
673
674 equiv = 0;
675@@ -1513,14 +1502,9 @@
676
677 while (hostp->h_addr_list[j])
678 {
679- if ((specified_local_addr_list[i][0] ==
680- hostp->h_addr_list[j][0]) &&
681- (specified_local_addr_list[i][1] ==
682- hostp->h_addr_list[j][1]) &&
683- (specified_local_addr_list[i][2] ==
684- hostp->h_addr_list[j][2]) &&
685- (specified_local_addr_list[i][3] ==
686- hostp->h_addr_list[j][3]))
687+ if (memcmp(specified_local_addr_list[i],
688+ hostp->h_addr_list[j],
689+ hostp->h_length) == 0)
690 {
691 /* They're equal, so we're done */
692
693diff -ruN xc.old/lib/xtrans/Xtransutil.c xc/lib/xtrans/Xtransutil.c
694--- xc.old/lib/xtrans/Xtransutil.c Mon Dec 23 07:04:18 1996
695+++ xc/lib/xtrans/Xtransutil.c Tue Jul 8 02:11:26 1997
696@@ -84,7 +84,7 @@
697 /*
698 * TRANS(ConvertAddress) converts a sockaddr based address to an
699 * X authorization based address. Some of this is defined as part of
700- * the ChangeHost protocol. The rest is just doen in a consistent manner.
701+ * the ChangeHost protocol. The rest is just done in a consistent manner.
702 */
703
704 int
705@@ -134,6 +134,32 @@
706 }
707 break;
708 }
709+
710+ case AF_INET6:
711+ {
712+ /*
713+ * Check for the hack localhost address ::1.
714+ * In this case, we are really FamilyLocal.
715+ */
716+
717+ struct sockaddr_in6 saddr;
718+ int len = sizeof(saddr.sin6_addr);
719+ char *cp = (char *) &saddr.sin6_addr;
720+
721+ memcpy (&saddr, *addrp, sizeof (struct sockaddr_in6));
722+
723+ if (memcmp(cp, (char *)&in6addr_loopback, len) == 0)
724+ {
725+ *familyp=FamilyLocal;
726+ }
727+ else
728+ {
729+ *familyp=FamilyInternet;
730+ *addrlenp=len;
731+ memcpy(*addrp,&saddr.sin6_addr,len);
732+ }
733+ break;
734+ }
735 #endif /* defined(TCPCONN) || defined(STREAMSCONN) || MNX_TCPCONN */
736
737 #if defined(DNETCONN)
738@@ -269,6 +295,18 @@
739 sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
740 break;
741 }
742+
743+ case AF_INET6:
744+ {
745+ struct sockaddr_in6 *saddr = (struct sockaddr_in6 *) addr;
746+ char portnumbuf[10];
747+
748+ sprintf (portnumbuf, "%d", ntohs (saddr->sin6_port));
749+ networkId = (char *) xalloc (3 + strlen (transName) +
750+ strlen (hostnamebuf) + strlen (portnumbuf));
751+ sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
752+ break;
753+ }
754 #endif /* defined(TCPCONN) || defined(STREAMSCONN) || MNX_TCPCONN */
755
756 #if defined(DNETCONN)
757@@ -377,6 +415,42 @@
758 addr = hostp->h_name;
759 else
760 addr = inet_ntoa (saddr->sin_addr);
761+ break;
762+ }
763+
764+ case AF_INET6:
765+ {
766+ struct sockaddr_in6 *saddr = (struct sockaddr_in6 *) peer_addr;
767+ _Xgethostbynameparams hparams;
768+ struct hostent * hostp;
769+ static char v[64];
770+
771+#ifdef SIGALRM
772+ /*
773+ * gethostbyaddr can take a LONG time if the host does not exist.
774+ * Assume that if it does not respond in NAMESERVER_TIMEOUT seconds
775+ * that something is wrong and do not make the user wait.
776+ * gethostbyaddr will continue after a signal, so we have to
777+ * jump out of it.
778+ */
779+
780+ nameserver_timedout = 0;
781+ signal (SIGALRM, nameserver_lost);
782+ alarm (4);
783+ if (setjmp(env) == 0) {
784+#endif
785+ hostp = _XGethostbyaddr ((char *) &saddr->sin6_addr,
786+ sizeof (saddr->sin6_addr), AF_INET6, hparams);
787+#ifdef SIGALRM
788+ }
789+ alarm (0);
790+#endif
791+ if (hostp != NULL)
792+ addr = hostp->h_name;
793+ else {
794+ inet_ntop (AF_INET6, &saddr->sin6_addr, v, sizeof (v));
795+ addr = addrbuf;
796+ }
797 break;
798 }
799
800diff -ruN xc.old/programs/Xserver/os/access.c xc/programs/Xserver/os/access.c
801--- xc.old/programs/Xserver/os/access.c Tue Dec 22 15:23:30 1998
802+++ xc/programs/Xserver/os/access.c Fri Jan 8 21:08:44 1999
803@@ -163,6 +163,7 @@
804 #else
805 #if !defined(AMOEBA) && !defined(MINIX)
806 #include <netdb.h>
807+#include <resolv.h>
808 #else
809 #ifdef AMOEBA
810 #include <server/ip/gen/netdb.h>
811@@ -215,10 +216,12 @@
812
813 #define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
814 #define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len)
815+#if !defined(TCPCONN)
816 #define addrEqual(fam, address, length, host) \
817 ((fam) == (host)->family &&\
818 (length) == (host)->len &&\
819 !acmp (address, (host)->addr, length))
820+#endif
821
822 static int ConvertAddr(
823 #if NeedFunctionPrototypes
824@@ -260,6 +263,49 @@
825 static int LocalHostEnabled = FALSE;
826 static int UsingXdmcp = FALSE;
827
828+#if defined(TCPCONN)
829+#define MAPTOIPV4(a) ((char *)(a) + sizeof(struct in6_addr) - \
830+ sizeof(struct in_addr))
831+#define MAPTOIPV6(d,a) { \
832+ bzero(&d.s6_addr[0], \
833+ sizeof(struct in6_addr)-2-sizeof(struct in_addr)); \
834+ d.s6_addr[10] = d.s6_addr[11] = 0xff; \
835+ acopy(a, MAPTOIPV4(&d.s6_addr[0]), sizeof(struct in_addr)); \
836+ }
837+
838+static int
839+addrEqual(fam, addr, len, host)
840+ unsigned char *addr;
841+ register HOST *host;
842+ int fam, len;
843+{
844+ char *a4, *a6;
845+
846+ if (fam != host->family)
847+ return FALSE;
848+ if (len == host->len)
849+ return !acmp (addr, host->addr, len);
850+ if (fam != FamilyInternet)
851+ return FALSE;
852+
853+ /* compare IPv4 with special IPv6 : mapped, loopback */
854+ if (len == sizeof(struct in6_addr) &&
855+ host->len == sizeof(struct in_addr)) {
856+ a4 = host->addr;
857+ a6 = addr;
858+ } else if (len == sizeof(struct in_addr) &&
859+ host->len == sizeof(struct in6_addr)) {
860+ a4 = addr;
861+ a6 = host->addr;
862+ } else
863+ return FALSE;
864+ if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)a6))
865+ return !acmp(a4, MAPTOIPV4(a6), sizeof(*a4));
866+ else
867+ return (a4[0] == 127 && a4[1] == 0 && a4[2] == 0 && a4[3] == 1 &&
868+ acmp(a6, &in6addr_loopback, sizeof(*a6)) == 0);
869+}
870+#endif
871
872 /*
873 * called when authorization is not enabled to add the
874@@ -634,6 +680,7 @@
875 int family;
876 register HOST *host;
877 register struct ifreq *ifr;
878+ struct in6_addr mapped;
879
880 #ifdef DNETCONN
881 struct dn_naddr *dnaddr = getnodeadd();
882@@ -692,10 +739,32 @@
883 if (family == -1 || family == FamilyLocal)
884 continue;
885 #ifdef DEF_SELF_DEBUG
886- if (family == FamilyInternet)
887- ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %d.%d.%d.%d\n",
888- ifr->ifr_name, addr[0], addr[1], addr[2], addr[3]);
889+ if (family == FamilyInternet) {
890+ char v[64];
891+
892+ ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %s\n",
893+ ifr->ifr_name,
894+ inet_ntop(len == 4 ? AF_INET : AF_INET6, addr, v, 64));
895+ }
896 #endif
897+ if (family == FamilyInternet) {
898+ if (len == 4) {
899+ /* Mapped IPv4 to IPv6 with special case for loopback */
900+ if (addr[0] == 127 && addr[1] == 0 &&
901+ addr[2] == 0 && addr[3] == 1)
902+ addr = (unsigned char *)&in6addr_loopback;
903+ else {
904+ MAPTOIPV6(mapped, addr);
905+ addr = (unsigned char *) &mapped;
906+ }
907+ len = sizeof(mapped);
908+ }
909+ /*
910+ * Link local addresses are too weird
911+ */
912+ if (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr))
913+ continue;
914+ }
915 for (host = selfhosts;
916 host && !addrEqual (family, addr, len, host);
917 host = host->next)
918@@ -724,13 +793,15 @@
919 /*
920 * ignore 'localhost' entries as they're not useful
921 * on the other end of the wire
922+ * ignore 'link local' entries
923 */
924- if (len == 4 &&
925- addr[0] == 127 && addr[1] == 0 &&
926- addr[2] == 0 && addr[3] == 1)
927+ if (acmp(addr, &in6addr_loopback, len)==0)
928 continue;
929
930 XdmcpRegisterConnection (family, (char *)addr, len);
931+ /* what to do with INET6 ???? */
932+ if (ifr->ifr_addr.sa_family != AF_INET);
933+ continue;
934 broad_addr = ifr->ifr_addr;
935 ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
936 htonl (INADDR_BROADCAST);
937@@ -794,10 +865,22 @@
938 int family;
939 pointer addr;
940 register HOST *host;
941+ struct in6_addr mapped;
942
943 family = ConvertAddr(from, &len, (pointer *)&addr);
944 if (family == -1 || family == FamilyLocal)
945 return;
946+ if ((family == FamilyInternet) && (len == 4)) {
947+ /* Mapped IPv4 to IPv6 with special case for loopback */
948+ if (((char *)addr)[0] == 127 && ((char *)addr)[1] == 0 &&
949+ ((char *)addr)[2] == 0 && ((char *)addr)[3] == 1)
950+ addr = (pointer)&in6addr_loopback;
951+ else {
952+ MAPTOIPV6(mapped, addr);
953+ addr = (unsigned char *) &mapped;
954+ }
955+ len = sizeof(mapped);
956+ }
957 for (host = selfhosts; host; host = host->next)
958 {
959 if (addrEqual(family, addr, len, host))
960@@ -840,7 +923,7 @@
961 union {
962 struct sockaddr sa;
963 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
964- struct sockaddr_in in;
965+ struct sockaddr_in6 in;
966 #endif /* TCPCONN || STREAMSCONN */
967 #ifdef DNETCONN
968 struct sockaddr_dn dn;
969@@ -978,12 +1061,16 @@
970 #endif /* SECURE_RPC */
971 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
972 {
973+ if ((_res.options & RES_INIT) == 0)
974+ (void)res_init();
975+ _res.options |= RES_USE_INET6;
976+
977 /* host name */
978 if (family == FamilyInternet && (hp = gethostbyname (hostname)) ||
979 (hp = gethostbyname (hostname)))
980 {
981 saddr.sa.sa_family = hp->h_addrtype;
982- len = sizeof(saddr.sa);
983+ len = sizeof(saddr.in);
984 if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1)
985 {
986 #ifdef h_addr /* new 4.3bsd version of gethostent */
987@@ -1072,6 +1159,7 @@
988 pointer pAddr;
989 {
990 int len;
991+ struct in6_addr mapped;
992
993 if (!AuthorizedClient(client))
994 return(BadAccess);
995@@ -1092,6 +1180,11 @@
996 break;
997 #endif
998 case FamilyInternet:
999+ if (length == sizeof (struct in_addr)) {
1000+ MAPTOIPV6(mapped, pAddr);
1001+ pAddr = (char *)& mapped;
1002+ length = sizeof(mapped);
1003+ }
1004 case FamilyDECnet:
1005 case FamilyChaos:
1006 if ((len = CheckAddr (family, pAddr, length)) < 0)
1007@@ -1174,6 +1267,7 @@
1008 {
1009 int len;
1010 register HOST *host, **prev;
1011+ struct in6_addr mapped;
1012
1013 if (!AuthorizedClient(client))
1014 return(BadAccess);
1015@@ -1193,6 +1287,11 @@
1016 break;
1017 #endif
1018 case FamilyInternet:
1019+ if (length == sizeof (struct in_addr)) {
1020+ MAPTOIPV6(mapped, pAddr);
1021+ pAddr = (char *)& mapped;
1022+ length = sizeof(mapped);
1023+ }
1024 case FamilyDECnet:
1025 case FamilyChaos:
1026 if ((len = CheckAddr (family, pAddr, length)) < 0)
1027@@ -1236,7 +1335,12 @@
1028 for (host = validhosts; host; host = host->next)
1029 {
1030 nHosts++;
1031- n += (((host->len + 3) >> 2) << 2) + sizeof(xHostEntry);
1032+ len = host->len;
1033+ if (host->family == FamilyInternet &&
1034+ len == sizeof (struct in6_addr) &&
1035+ IN6_IS_ADDR_V4MAPPED((struct in6_addr *)host->addr))
1036+ len = sizeof (struct in_addr);
1037+ n += (((len + 3) >> 2) << 2) + sizeof(xHostEntry);
1038 }
1039 if (n)
1040 {
1041@@ -1247,11 +1351,19 @@
1042 }
1043 for (host = validhosts; host; host = host->next)
1044 {
1045+ char *ad = host->addr;
1046+
1047 len = host->len;
1048 ((xHostEntry *)ptr)->family = host->family;
1049+ if (host->family == FamilyInternet &&
1050+ len == sizeof (struct in6_addr) &&
1051+ IN6_IS_ADDR_V4MAPPED((struct in6_addr *)host->addr)) {
1052+ len = sizeof (struct in_addr);
1053+ ad = MAPTOIPV4(ad);
1054+ }
1055 ((xHostEntry *)ptr)->length = len;
1056 ptr += sizeof(xHostEntry);
1057- acopy (host->addr, ptr, len);
1058+ acopy (ad, ptr, len);
1059 ptr += ((len + 3) >> 2) << 2;
1060 }
1061 } else {
1062@@ -1277,11 +1389,7 @@
1063 {
1064 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN) || defined(MNX_TCPCONN)
1065 case FamilyInternet:
1066-#if !defined(AMOEBA)
1067- if (length == sizeof (struct in_addr))
1068-#else
1069- if (length == sizeof(ipaddr_t))
1070-#endif
1071+ if (length == sizeof (struct in6_addr))
1072 len = length;
1073 else
1074 len = -1;
1075@@ -1312,11 +1420,7 @@
1076 * Returns 1 if host is invalid, 0 if we've found it. */
1077
1078 InvalidHost (saddr, len)
1079-#ifndef AMOEBA_ORIG
1080 register struct sockaddr *saddr;
1081-#else
1082- register ipaddr_t *saddr;
1083-#endif
1084 int len;
1085 {
1086 int family;
1087@@ -1359,11 +1463,7 @@
1088
1089 static int
1090 ConvertAddr (saddr, len, addr)
1091-#ifndef AMOEBA_ORIG
1092 register struct sockaddr *saddr;
1093-#else
1094- register ipaddr_t *saddr;
1095-#endif
1096 int *len;
1097 pointer *addr;
1098 {
1099@@ -1381,6 +1481,10 @@
1100 case AF_INET:
1101 *len = sizeof (struct in_addr);
1102 *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
1103+ return FamilyInternet;
1104+ case AF_INET6:
1105+ *len = sizeof (struct in6_addr);
1106+ *addr = (pointer) &(((struct sockaddr_in6 *) saddr)->sin6_addr);
1107 return FamilyInternet;
1108 #endif
1109 #ifdef DNETCONN
1110diff -ruN xc.old/programs/Xserver/os/connection.c xc/programs/Xserver/os/connection.c
1111--- xc.old/programs/Xserver/os/connection.c Fri Dec 18 15:56:32 1998
1112+++ xc/programs/Xserver/os/connection.c Fri Jan 8 21:09:37 1999
1113@@ -477,6 +477,7 @@
1114 int auth_id;
1115 {
1116 char addr[128];
1117+ char v[64];
1118 char *out = addr;
1119
1120 if (!((OsCommPtr)client->osPrivate)->trans_conn) {
1121@@ -499,6 +500,13 @@
1122 sprintf(out, "IP %s port %d",
1123 inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr),
1124 ntohs(((struct sockaddr_in *) saddr)->sin_port));
1125+ break;
1126+ case AF_INET6:
1127+ sprintf(out, "IPv6 %s port %d",
1128+ inet_ntop(AF_INET6,
1129+ &((struct sockaddr_in6 *) saddr)->sin6_addr,
1130+ v, sizeof (v)),
1131+ ntohs(((struct sockaddr_in6 *) saddr)->sin6_port));
1132 break;
1133 #endif
1134 #ifdef DNETCONN
1135diff -ruN xc.old/programs/Xserver/os/k5auth.c xc/programs/Xserver/os/k5auth.c
1136--- xc.old/programs/Xserver/os/k5auth.c Fri May 10 09:02:15 1996
1137+++ xc/programs/Xserver/os/k5auth.c Mon Jul 7 23:00:58 1997
1138@@ -277,7 +277,7 @@
1139 long addrlen;
1140 krb5_error_code retval, retval2;
1141 register char n;
1142- struct sockaddr cli_net_addr;
1143+ struct sockaddr_in6 cli_net_addr;
1144 xReq prefix;
1145 krb5_principal cprinc;
1146 krb5_data buf;
1147@@ -299,15 +299,15 @@
1148 }
1149 addrlen = sizeof (cli_net_addr);
1150 if (getpeername(((OsCommPtr)client->osPrivate)->fd,
1151- &cli_net_addr, &addrlen) == -1)
1152+ (struct sockaddr *)&cli_net_addr, &addrlen) == -1)
1153 {
1154 if (creds)
1155 krb5_free_creds(creds);
1156 return(SendConnSetup(client, "Krb5 stage1: getpeername failed"));
1157 }
1158- if (cli_net_addr.sa_family == AF_UNSPEC
1159+ if (cli_net_addr.sin6_family == AF_UNSPEC
1160 #if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
1161- || cli_net_addr.sa_family == AF_UNIX
1162+ || cli_net_addr.sin6_family == AF_UNIX
1163 #endif
1164 ) /* assume local host */
1165 {
1166@@ -324,9 +324,9 @@
1167 }
1168 else
1169 {
1170- cli_addr.addrtype = cli_net_addr.sa_family; /* the values
1171+ cli_addr.addrtype = cli_net_addr.sin6_family; /* the values
1172 are compatible */
1173- switch (cli_net_addr.sa_family)
1174+ switch (cli_net_addr.sin6_family)
1175 {
1176 #ifdef TCPCONN
1177 case AF_INET:
1178@@ -334,6 +334,11 @@
1179 cli_addr.contents =
1180 (krb5_octet *)&((struct sockaddr_in *)&cli_net_addr)->sin_addr;
1181 break;
1182+ case AF_INET6:
1183+ cli_addr.length = sizeof (struct in6_addr);
1184+ cli_addr.contents =
1185+ (krb5_octet *)&(&cli_net_addr)->sin6_addr;
1186+ break;
1187 #endif
1188 #ifdef DNETCONN
1189 case AF_DECnet:
1190@@ -348,7 +353,7 @@
1191 if (creds)
1192 krb5_free_creds(creds);
1193 sprintf(kerror, "Krb5 stage1: unknown address family %d from getpeername",
1194- cli_net_addr.sa_family);
1195+ cli_net_addr.sin6_family);
1196 return(SendConnSetup(client, kerror));
1197 }
1198 }
1199diff -ruN xc.old/programs/Xserver/os/utils.c xc/programs/Xserver/os/utils.c
1200--- xc.old/programs/Xserver/os/utils.c Sun Dec 27 06:01:20 1998
1201+++ xc/programs/Xserver/os/utils.c Fri Jan 8 21:10:38 1999
1202@@ -1112,7 +1112,9 @@
1203
1204 #if defined(TCPCONN) || defined(STREAMSCONN)
1205 #ifndef WIN32
1206+#include <netinet/in.h>
1207 #include <netdb.h>
1208+#include <resolv.h>
1209 #endif
1210 #endif
1211
1212@@ -1134,6 +1136,10 @@
1213 char hname[1024], *hnameptr;
1214 struct hostent *host;
1215 int len;
1216+
1217+ if ((_res.options & RES_INIT) == 0)
1218+ (void)res_init();
1219+ _res.options |= RES_USE_INET6;
1220
1221 gethostname(hname, 1024);
1222 host = gethostbyname(hname);
1223diff -ruN xc.old/programs/Xserver/os/xdmcp.c xc/programs/Xserver/os/xdmcp.c
1224--- xc.old/programs/Xserver/os/xdmcp.c Fri Dec 18 15:56:34 1998
1225+++ xc/programs/Xserver/os/xdmcp.c Fri Jan 8 21:11:28 1999
1226@@ -38,6 +38,8 @@
1227 #endif
1228 #include <netinet/in.h>
1229 #include <netdb.h>
1230+#include <resolv.h>
1231+#undef QUERY
1232 #else
1233 #if defined(MINIX)
1234 #include <net/hton.h>
1235@@ -81,7 +83,7 @@
1236
1237 static int xdmcpSocket, sessionSocket;
1238 static xdmcp_states state;
1239-static struct sockaddr_in req_sockaddr;
1240+static struct sockaddr_in6 req_sockaddr;
1241 static int req_socklen;
1242 static CARD32 SessionID;
1243 static CARD32 timeOutTime;
1244@@ -96,7 +98,7 @@
1245
1246 static XdmcpBuffer buffer;
1247
1248-static struct sockaddr_in ManagerAddress;
1249+static struct sockaddr_in6 ManagerAddress;
1250
1251 static void get_xdmcp_sock(
1252 #if NeedFunctionPrototypes
1253@@ -112,7 +114,7 @@
1254
1255 static void recv_willing_msg(
1256 #if NeedFunctionPrototypes
1257- struct sockaddr_in */*from*/,
1258+ struct sockaddr_in6 */*from*/,
1259 int /*fromlen*/,
1260 unsigned /*length*/
1261 #endif
1262@@ -332,24 +334,27 @@
1263
1264 #define MAX_BROADCAST 10
1265
1266-static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST];
1267+static struct sockaddr_in6 BroadcastAddresses[MAX_BROADCAST];
1268 static int NumBroadcastAddresses;
1269
1270 void
1271 XdmcpRegisterBroadcastAddress (addr)
1272 struct sockaddr_in *addr;
1273 {
1274- struct sockaddr_in *bcast;
1275+ struct sockaddr_in6 *bcast;
1276 if (NumBroadcastAddresses >= MAX_BROADCAST)
1277 return;
1278 bcast = &BroadcastAddresses[NumBroadcastAddresses++];
1279- bzero (bcast, sizeof (struct sockaddr_in));
1280+ bzero (bcast, sizeof (struct sockaddr_in6));
1281+ /* mapped the IPv4 broadcast address to IPv6 */
1282 #ifdef BSD44SOCKETS
1283- bcast->sin_len = addr->sin_len;
1284+ bcast->sin6_len = sizeof(struct sockaddr_in6);
1285 #endif
1286- bcast->sin_family = addr->sin_family;
1287- bcast->sin_port = htons (xdm_udp_port);
1288- bcast->sin_addr = addr->sin_addr;
1289+ bcast->sin6_family = AF_INET6;
1290+ bcast->sin6_port = htons (xdm_udp_port);
1291+ bcast->sin6_flowinfo = 0;
1292+ bcast->sin6_addr.s6_addr[10] = bcast->sin6_addr.s6_addr[11] = 0xff;
1293+ memmove(&bcast->sin6_addr.s6_addr[12], &addr->sin_addr, 4);
1294 }
1295
1296 /*
1297@@ -464,6 +469,13 @@
1298 XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses);
1299 xdmcpGeneration = serverGeneration;
1300 }
1301+ /* for INET6, try go back to INET, to help not INET6 managers !! */
1302+ if (type == FamilyInternet &&
1303+ addrlen == sizeof (struct in6_addr) &&
1304+ IN6_IS_ADDR_V4MAPPED((struct in6_addr *)address)) {
1305+ addrlen = sizeof (struct in_addr);
1306+ address += sizeof (struct in6_addr) - sizeof (struct in_addr);
1307+ }
1308 newAddress = (CARD8 *) xalloc (addrlen * sizeof (CARD8));
1309 if (!newAddress)
1310 return;
1311@@ -750,7 +762,7 @@
1312
1313 /*ARGSUSED*/
1314 XdmcpAddHost(from, fromlen, AuthenticationName, hostname, status)
1315- struct sockaddr_in *from;
1316+ struct sockaddr_in6 *from;
1317 ARRAY8Ptr AuthenticationName, hostname, status;
1318 {
1319 XdmcpSelectHost(from, fromlen, AuthenticationName);
1320@@ -766,8 +778,8 @@
1321 static void
1322 receive_packet()
1323 {
1324- struct sockaddr_in from;
1325- int fromlen = sizeof(struct sockaddr_in);
1326+ struct sockaddr_in6 from;
1327+ int fromlen = sizeof(struct sockaddr_in6);
1328 XdmcpHeader header;
1329
1330 /* read message off socket */
1331@@ -980,7 +992,7 @@
1332 #ifndef _MINIX
1333 int soopts = 1;
1334
1335- if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
1336+ if ((xdmcpSocket = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
1337 #else /* MINIX */
1338 char *udp_device;
1339 int r, s_errno;
1340@@ -1066,7 +1078,7 @@
1341
1342 for (i = 0; i < NumBroadcastAddresses; i++)
1343 XdmcpFlush (xdmcpSocket, &buffer, &BroadcastAddresses[i],
1344- sizeof (struct sockaddr_in));
1345+ sizeof (struct sockaddr_in6));
1346 }
1347 else
1348 {
1349@@ -1077,7 +1089,7 @@
1350
1351 static void
1352 recv_willing_msg(from, fromlen, length)
1353- struct sockaddr_in *from;
1354+ struct sockaddr_in6 *from;
1355 int fromlen;
1356 unsigned length;
1357 {
1358@@ -1380,23 +1392,29 @@
1359 ErrorF("Xserver: missing host name in command line\n");
1360 exit(1);
1361 }
1362+
1363+ if ((_res.options & RES_INIT) == 0)
1364+ (void)res_init();
1365+ _res.options |= RES_USE_INET6;
1366+
1367 if (!(hep = gethostbyname(argv[i])))
1368 {
1369 ErrorF("Xserver: unknown host: %s\n", argv[i]);
1370 exit(1);
1371 }
1372 #ifndef _MINIX
1373- if (hep->h_length == sizeof (struct in_addr))
1374+ if (hep->h_length == sizeof (struct in6_addr))
1375 #else
1376 if (hep->h_length == sizeof (ipaddr_t))
1377 #endif
1378 {
1379- memmove(&ManagerAddress.sin_addr, hep->h_addr, hep->h_length);
1380+ memmove(&ManagerAddress.sin6_addr, hep->h_addr, hep->h_length);
1381 #ifdef BSD44SOCKETS
1382- ManagerAddress.sin_len = sizeof(ManagerAddress);
1383+ ManagerAddress.sin6_len = sizeof(ManagerAddress);
1384 #endif
1385- ManagerAddress.sin_family = AF_INET;
1386- ManagerAddress.sin_port = htons (xdm_udp_port);
1387+ ManagerAddress.sin6_family = AF_INET6;
1388+ ManagerAddress.sin6_port = htons (xdm_udp_port);
1389+ ManagerAddress.sin6_flowinfo = 0;
1390 }
1391 else
1392 {
1393diff -ruN xc.old/programs/lbxproxy/os/connection.c xc/programs/lbxproxy/os/connection.c
1394--- xc.old/programs/lbxproxy/os/connection.c Thu Nov 5 20:27:57 1998
1395+++ xc/programs/lbxproxy/os/connection.c Fri Jan 8 19:56:54 1999
1396@@ -231,7 +231,7 @@
1397 int retry; /* boolean - retry if addr busy */
1398
1399 {
1400- struct sockaddr_in insock;
1401+ struct sockaddr_in6 insock;
1402 int request;
1403 int retryCount;
1404 #ifndef SO_DONTLINGER
1405@@ -240,7 +240,7 @@
1406 #endif /* SO_LINGER */
1407 #endif /* SO_DONTLINGER */
1408
1409- if ((request = socket (AF_INET, SOCK_STREAM, 0)) < 0)
1410+ if ((request = socket (AF_INET6, SOCK_STREAM, 0)) < 0)
1411 {
1412 Error ("Creating TCP socket");
1413 return -1;
1414@@ -255,11 +255,12 @@
1415 {
1416 bzero ((char *)&insock, sizeof (insock));
1417 #ifdef BSD44SOCKETS
1418- insock.sin_len = sizeof(insock);
1419+ insock.sin6_len = sizeof(insock);
1420 #endif
1421- insock.sin_family = AF_INET;
1422- insock.sin_port = htons ((unsigned short)(X_TCP_PORT + atoi (display)));
1423- insock.sin_addr.s_addr = htonl(INADDR_ANY);
1424+ insock.sin6_family = AF_INET6;
1425+ insock.sin6_flowinfo = 0;
1426+ insock.sin6_port = htons ((unsigned short)(X_TCP_PORT + atoi (display)));
1427+ insock.sin6_addr = in6addr_any;
1428
1429 retryCount = retry ? 19 : 0;
1430
1431@@ -1730,7 +1731,7 @@
1432 struct sockaddr_un un;
1433 #endif /* UNIXCONN */
1434 #ifdef TCPCONN
1435- struct sockaddr_in in;
1436+ struct sockaddr_in6 in;
1437 #endif /* TCPCONN */
1438 #ifdef DNETCONN
1439 struct sockaddr_dn dn;
1440@@ -1755,7 +1756,9 @@
1441 fromlen = sizeof (from);
1442 if (!getpeername (newconn, &from.sa, &fromlen))
1443 {
1444- if (fromlen && (from.sa.sa_family == AF_INET))
1445+ if (fromlen &&
1446+ ((from.sa.sa_family == AF_INET) ||
1447+ (from.sa.sa_family == AF_INET6)))
1448 {
1449 int mi = 1;
1450 setsockopt (newconn, IPPROTO_TCP, TCP_NODELAY,
1451diff -ruN xc.old/programs/xauth/gethost.c xc/programs/xauth/gethost.c
1452--- xc.old/programs/xauth/gethost.c Sun Sep 13 15:15:53 1998
1453+++ xc/programs/xauth/gethost.c Fri Jan 8 19:58:51 1999
1454@@ -144,15 +144,21 @@
1455 alarm (4);
1456 if (setjmp(env) == 0) {
1457 #endif
1458- hp = gethostbyaddr (auth->address, auth->address_length, AF_INET);
1459+ hp = gethostbyaddr (auth->address, auth->address_length,
1460+ auth->address_length == 4 ? AF_INET : AF_INET6);
1461 #ifdef SIGALRM
1462 }
1463 alarm (0);
1464 #endif
1465 if (hp)
1466 return (hp->h_name);
1467- else
1468- return (inet_ntoa(*((struct in_addr *)(auth->address))));
1469+ else {
1470+ static char v[64];
1471+
1472+ inet_ntop (auth->address_length == 4 ? AF_INET : AF_INET6,
1473+ auth->address, v, sizeof(v));
1474+ return (v);
1475+ }
1476 }
1477 #endif
1478 #ifdef DNETCONN
1479@@ -172,38 +178,26 @@
1480 }
1481
1482 #ifdef TCPCONN
1483-/*
1484- * cribbed from lib/X/XConnDis.c
1485- */
1486 static Bool get_inet_address (name, resultp)
1487 char *name;
1488- unsigned int *resultp; /* return */
1489+ struct in6_addr *resultp; /* return */
1490 {
1491- unsigned int hostinetaddr = inet_addr (name);
1492 struct hostent *host_ptr;
1493- struct sockaddr_in inaddr; /* dummy variable for size calcs */
1494
1495-#ifndef INADDR_NONE
1496-#define INADDR_NONE -1
1497-#endif
1498-
1499- if (hostinetaddr == INADDR_NONE) {
1500- if ((host_ptr = gethostbyname (name)) == NULL) {
1501- /* No such host! */
1502- errno = EINVAL;
1503- return False;
1504- }
1505- /* Check the address type for an internet host. */
1506- if (host_ptr->h_addrtype != AF_INET) {
1507- /* Not an Internet host! */
1508- errno = EPROTOTYPE;
1509- return False;
1510- }
1511-
1512- memmove( (char *)&hostinetaddr, (char *)host_ptr->h_addr,
1513- sizeof(inaddr.sin_addr));
1514+ if ((host_ptr = gethostbyname (name)) == NULL) {
1515+ /* No such host! */
1516+ errno = EINVAL;
1517+ return False;
1518 }
1519- *resultp = hostinetaddr;
1520+ /* Check the address type for an internet host. */
1521+ if (host_ptr->h_addrtype != AF_INET6) {
1522+ /* Not an Internet host! */
1523+ errno = EPROTOTYPE;
1524+ return False;
1525+ }
1526+
1527+ memmove( (char *)resultp, (char *)host_ptr->h_addr,
1528+ host_ptr->h_length);
1529 return True;
1530 }
1531 #endif
1532@@ -239,8 +233,7 @@
1533 int len = 0;
1534 char *src = NULL;
1535 #ifdef TCPCONN
1536- unsigned int hostinetaddr;
1537- struct sockaddr_in inaddr; /* dummy variable for size calcs */
1538+ struct in6_addr hostinetaddr;
1539 #endif
1540 #ifdef DNETCONN
1541 struct dn_naddr dnaddr;
1542@@ -273,7 +266,7 @@
1543 #ifdef TCPCONN
1544 if (!get_inet_address (host, &hostinetaddr)) return NULL;
1545 src = (char *) &hostinetaddr;
1546- len = 4; /* sizeof inaddr.sin_addr, would fail on Cray */
1547+ len = (sizeof hostinetaddr);
1548 break;
1549 #else
1550 return NULL;
1551diff -ruN xc.old/programs/xauth/parsedpy.c xc/programs/xauth/parsedpy.c
1552--- xc.old/programs/xauth/parsedpy.c Mon Feb 16 01:43:19 1998
1553+++ xc/programs/xauth/parsedpy.c Thu Apr 2 17:24:14 1998
1554@@ -115,12 +115,18 @@
1555 if (!displayname || !displayname[0]) return False;
1556
1557 /* must have at least :number */
1558- ptr = strchr(displayname, ':');
1559+ /*
1560+ * If a "host::" is found then assume DNET.
1561+ * For IPv6, pb with possible : in host --> use rightmost : and test
1562+ * x:y->inet, x::y->dnet, x:::y->inet(v6)
1563+ */
1564+ ptr = strrchr(displayname, ':');
1565 if (!ptr || !ptr[1]) return False;
1566- if (ptr[1] == ':') {
1567- if (ptr[2] == '\0') return False;
1568- dnet = True;
1569- }
1570+ if (ptr > displayname && ptr[-1] == ':')
1571+ if (ptr-1 == displayname || ptr[-2] != ':') {
1572+ ptr--;
1573+ dnet = True;
1574+ }
1575
1576
1577 /*
1578diff -ruN xc.old/programs/xauth/xauth.c xc/programs/xauth/xauth.c
1579--- xc.old/programs/xauth/xauth.c Wed Apr 27 09:19:54 1994
1580+++ xc/programs/xauth/xauth.c Mon Jul 7 23:10:46 1997
1581@@ -32,6 +32,8 @@
1582
1583 #include "xauth.h"
1584
1585+#include <netinet/in.h>
1586+#include <resolv.h>
1587
1588 /*
1589 * global data
1590@@ -102,6 +104,10 @@
1591 int status;
1592
1593 ProgramName = argv[0];
1594+
1595+ if ((_res.options & RES_INIT) == 0)
1596+ (void)res_init();
1597+ _res.options |= RES_USE_INET6;
1598
1599 for (i = 1; i < argc; i++) {
1600 char *arg = argv[i];
1601diff -ruN xc.old/programs/xdm/access.c xc/programs/xdm/access.c
1602--- xc.old/programs/xdm/access.c Sat Jan 18 08:02:17 1997
1603+++ xc/programs/xdm/access.c Mon Jul 7 23:12:04 1997
1604@@ -379,6 +379,11 @@
1605 display->connectionType = FamilyInternet;
1606 break;
1607 #endif
1608+#ifdef AF_INET6
1609+ case AF_INET6:
1610+ display->connectionType = FamilyInternet;
1611+ break;
1612+#endif
1613 #ifdef AF_DECnet
1614 case AF_DECnet:
1615 display->connectionType = FamilyDECnet;
1616diff -ruN xc.old/programs/xdm/auth.c xc/programs/xdm/auth.c
1617--- xc.old/programs/xdm/auth.c Tue Dec 22 15:23:31 1998
1618+++ xc/programs/xdm/auth.c Fri Jan 8 21:12:32 1999
1619@@ -86,8 +86,8 @@
1620 # endif /* ESIX */
1621 #endif /* i386 */
1622
1623-#ifdef SVR4
1624 # include <netdb.h>
1625+#ifdef SVR4
1626 # ifndef SCO325
1627 # include <sys/sockio.h>
1628 # endif
1629@@ -988,6 +988,21 @@
1630 Debug ("Skipping localhost address\n");
1631 continue;
1632 }
1633+ if (len == sizeof (struct in6_addr)) {
1634+ if (bcmp(addr, &in6addr_loopback, len) == 0)
1635+ {
1636+ Debug ("Skipping localhost address\n");
1637+ continue;
1638+ }
1639+ /*
1640+ * ignore Link local address, the semantic would be weird
1641+ */
1642+ if (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr))
1643+ {
1644+ Debug ("Skipping link-local address\n");
1645+ continue;
1646+ }
1647+ }
1648 family = FamilyInternet;
1649 }
1650 Debug ("DefineSelf: write network address, length %d\n", len);
1651@@ -1014,10 +1029,10 @@
1652
1653 union {
1654 struct sockaddr sa;
1655- struct sockaddr_in in;
1656+ struct sockaddr_in6 in;
1657 } saddr;
1658
1659- struct sockaddr_in *inetaddr;
1660+ struct sockaddr_in6 *inetaddr;
1661
1662 /* hpux:
1663 * Why not use gethostname()? Well, at least on my system, I've had to
1664@@ -1029,12 +1044,12 @@
1665 hp = gethostbyname (name.nodename);
1666 if (hp != NULL) {
1667 saddr.sa.sa_family = hp->h_addrtype;
1668- inetaddr = (struct sockaddr_in *) (&(saddr.sa));
1669- memmove( (char *) &(inetaddr->sin_addr), (char *) hp->h_addr, (int) hp->h_length);
1670+ inetaddr = (struct sockaddr_in6 *) (&(saddr.sa));
1671+ memmove( (char *) &(inetaddr->sin6_addr), (char *) hp->h_addr, (int) hp->h_length);
1672 family = ConvertAddr ( &(saddr.sa), &len, &addr);
1673 if ( family >= 0) {
1674- writeAddr (FamilyInternet, sizeof (inetaddr->sin_addr),
1675- (char *) (&inetaddr->sin_addr), file, auth);
1676+ writeAddr (FamilyInternet, sizeof (inetaddr->sin6_addr),
1677+ (char *) (&inetaddr->sin6_addr), file, auth);
1678 }
1679 }
1680 }
1681@@ -1101,7 +1116,7 @@
1682 tcp_device= TCP_DEVICE;
1683 fd = open(tcp_device, O_RDWR);
1684 #else
1685- fd = socket (AF_INET, SOCK_STREAM, 0);
1686+ fd = socket (AF_INET6, SOCK_STREAM, 0);
1687 #endif
1688 DefineSelf (fd, file, auth);
1689 close (fd);
1690@@ -1133,6 +1148,35 @@
1691 setAuthNumber (auth, name);
1692 family = ConvertAddr (peer, &peerlen, &addr);
1693 Debug ("writeRemoteAuth: family %d\n", family);
1694+ /* if remote and name, set all the remote addresses */
1695+ if (family == FamilyInternet)
1696+ {
1697+ struct in6_addr tmp;
1698+ struct hostent *hp;
1699+ char **ad, *colon;
1700+ int af;
1701+
1702+ if (peerlen == sizeof (struct in6_addr) &&
1703+ !IN6_IS_ADDR_V4MAPPED((struct in6_addr *)addr))
1704+ af = AF_INET6;
1705+ else
1706+ af = AF_INET;
1707+ colon = strrchr(name, ':');
1708+ if (colon) {
1709+ *colon = 0;
1710+ if (inet_pton(af, name, &tmp) == 0 &&
1711+ (hp = gethostbyname2(name, af))) {
1712+ for(ad = hp->h_addr_list; *ad; ad++) {
1713+ Debug ("writeRemoteAuth: %d, %d, %x\n",
1714+ family, hp->h_length, *(int *)*ad);
1715+ writeAddr (family, hp->h_length, *ad, file, auth);
1716+ }
1717+ *colon = ':';
1718+ return;
1719+ }
1720+ *colon = ':';
1721+ }
1722+ }
1723 if (family != FamilyLocal)
1724 {
1725 Debug ("writeRemoteAuth: %d, %d, %x\n",
1726diff -ruN xc.old/programs/xdm/choose.c xc/programs/xdm/choose.c
1727--- xc.old/programs/xdm/choose.c Sat Jan 18 08:02:19 1997
1728+++ xc/programs/xdm/choose.c Mon Jul 7 23:13:47 1997
1729@@ -232,6 +232,22 @@
1730 result_len = 8;
1731 }
1732 break;
1733+ case AF_INET6:
1734+ {
1735+ char *port;
1736+ int portlen;
1737+ ARRAY8Ptr localAddress, getLocalAddress ();
1738+
1739+ port = NetaddrPort((XdmcpNetaddr)addr_buf, &portlen);
1740+ result_buf[0] = netfamily >> 8;
1741+ result_buf[1] = netfamily & 0xFF;
1742+ result_buf[2] = port[0];
1743+ result_buf[3] = port[1];
1744+ localAddress = getLocalAddress ();
1745+ memmove( (char *)result_buf+4, (char *)localAddress->data, 16);
1746+ result_len = 20;
1747+ }
1748+ break;
1749 #ifdef AF_DECnet
1750 case AF_DECnet:
1751 break;
1752diff -ruN xc.old/programs/xdm/chooser.c xc/programs/xdm/chooser.c
1753--- xc.old/programs/xdm/chooser.c Tue Dec 22 15:23:31 1998
1754+++ xc/programs/xdm/chooser.c Fri Jan 8 21:13:28 1999
1755@@ -88,6 +88,7 @@
1756 #endif
1757 #include <netinet/in.h>
1758 #include <arpa/inet.h>
1759+#include <resolv.h>
1760 #else /* MINIX */
1761 #include <net/hton.h>
1762 #include <net/netlib.h>
1763@@ -347,6 +348,11 @@
1764 hostAddr.length = 4;
1765 connectionType = FamilyInternet;
1766 break;
1767+ case AF_INET6:
1768+ hostAddr.data = (CARD8 *) &((struct sockaddr_in6 *) addr)->sin6_addr;
1769+ hostAddr.length = 16;
1770+ connectionType = FamilyInternet;
1771+ break;
1772 default:
1773 hostAddr.data = (CARD8 *) "";
1774 hostAddr.length = 0;
1775@@ -376,11 +382,12 @@
1776 switch (addr->sa_family)
1777 {
1778 case AF_INET:
1779+ case AF_INET6:
1780 {
1781 struct hostent *hostent;
1782 char *host;
1783
1784- hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, AF_INET);
1785+ hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, addr->sa_family);
1786 if (hostent)
1787 {
1788 XdmcpDisposeARRAY8 (hostname);
1789@@ -493,7 +500,7 @@
1790 ARRAY8 hostname;
1791 ARRAY8 status;
1792 int saveHostname = 0;
1793- struct sockaddr addr;
1794+ struct sockaddr_in6 addr;
1795 int addrlen;
1796 #ifdef MINIX
1797 int r;
1798@@ -750,6 +757,7 @@
1799 in_addr.sin_family = AF_INET;
1800 else
1801 {
1802+ /* TODO */
1803 hostent = gethostbyname (name);
1804 if (!hostent)
1805 return;
1806@@ -920,7 +928,7 @@
1807 ref.ref_int= socketFD;
1808 nbio_setcallback(socketFD, ASIO_READ, read_cb, ref);
1809 #else /* !MINIX */
1810- if ((socketFD = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
1811+ if ((socketFD = socket (AF_INET6, SOCK_DGRAM, 0)) < 0)
1812 return 0;
1813 #endif /* MINIX */
1814 #endif
1815@@ -950,7 +958,7 @@
1816 {
1817 if (app_resources.xdmAddress)
1818 {
1819- struct sockaddr_in in_addr;
1820+ struct sockaddr_in6 in_addr;
1821 struct sockaddr *addr;
1822 int family;
1823 int len;
1824@@ -970,13 +978,14 @@
1825 xdm = (char *) app_resources.xdmAddress->data;
1826 family = (xdm[0] << 8) + xdm[1];
1827 switch (family) {
1828- case AF_INET:
1829+ case AF_INET6:
1830 #ifdef BSD44SOCKETS
1831- in_addr.sin_len = sizeof(in_addr);
1832+ in_addr.sin6_len = sizeof(in_addr);
1833 #endif
1834- in_addr.sin_family = family;
1835- memmove( &in_addr.sin_port, xdm + 2, 2);
1836- memmove( &in_addr.sin_addr, xdm + 4, 4);
1837+ in_addr.sin6_family = family;
1838+ in_addr.sin6_flowinfo = 0;
1839+ memmove( &in_addr.sin6_port, xdm + 2, 2);
1840+ memmove( &in_addr.sin6_addr, xdm + 4, 16);
1841 addr = (struct sockaddr *) &in_addr;
1842 len = sizeof (in_addr);
1843 break;
1844@@ -1172,6 +1181,10 @@
1845 Arg position[3];
1846 Dimension width, height;
1847 Position x, y;
1848+
1849+ if ((_res.options & RES_INIT) == 0)
1850+ (void)res_init();
1851+ _res.options |= RES_USE_INET6;
1852
1853 toplevel = XtInitialize (argv[0], "Chooser", options, XtNumber(options), &argc, argv);
1854
1855diff -ruN xc.old/programs/xdm/dm.c xc/programs/xdm/dm.c
1856--- xc.old/programs/xdm/dm.c Sat Oct 31 21:17:43 1998
1857+++ xc/programs/xdm/dm.c Fri Jan 8 20:04:21 1999
1858@@ -79,6 +79,8 @@
1859 extern int errno;
1860 #endif
1861
1862+#include <netinet/in.h>
1863+#include <resolv.h>
1864
1865 #if defined(SVR4) && !defined(SCO)
1866 extern FILE *fdopen();
1867@@ -118,6 +120,10 @@
1868 Title = argv[0];
1869 TitleLen = (argv[argc - 1] + strlen(argv[argc - 1])) - Title;
1870 #endif
1871+
1872+ if ((_res.options & RES_INIT) == 0)
1873+ (void)res_init();
1874+ _res.options |= RES_USE_INET6;
1875
1876 /*
1877 * Step 1 - load configuration parameters
1878diff -ruN xc.old/programs/xdm/netaddr.c xc/programs/xdm/netaddr.c
1879--- xc.old/programs/xdm/netaddr.c Sat Jan 18 08:02:21 1997
1880+++ xc/programs/xdm/netaddr.c Mon Jul 7 23:15:59 1997
1881@@ -65,7 +65,7 @@
1882 #endif
1883
1884 /* given an XdmcpNetaddr, returns the socket protocol family used,
1885- e.g., AF_INET */
1886+ e.g., AF_INET[6] */
1887
1888 int NetaddrFamily(netaddrp)
1889 XdmcpNetaddr netaddrp;
1890@@ -96,6 +96,9 @@
1891 case AF_INET:
1892 *lenp = 2;
1893 return (char *)&(((struct sockaddr_in *)netaddrp)->sin_port);
1894+ case AF_INET6:
1895+ *lenp = 2;
1896+ return (char *)&(((struct sockaddr_in6 *)netaddrp)->sin6_port);
1897 default:
1898 *lenp = 0;
1899 return NULL;
1900@@ -125,6 +128,9 @@
1901 case AF_INET:
1902 *lenp = sizeof (struct in_addr);
1903 return (char *) &(((struct sockaddr_in *)netaddrp)->sin_addr);
1904+ case AF_INET6:
1905+ *lenp = sizeof (struct in6_addr);
1906+ return (char *) &(((struct sockaddr_in6 *)netaddrp)->sin6_addr);
1907 #endif
1908 #ifdef DNETCONN
1909 case AF_DECnet:
1910@@ -177,6 +183,7 @@
1911 #endif
1912 #ifdef TCPCONN
1913 case AF_INET:
1914+ case AF_INET6:
1915 retval = FamilyInternet;
1916 break;
1917 #endif
1918@@ -248,6 +255,20 @@
1919
1920 Debug ("port %d, host %d.%d.%d.%d\n",
1921 (p[0] << 8) + p[1], t[0], t[1], t[2], t[3]);
1922+ break;
1923+ }
1924+#endif
1925+#ifdef AF_INET6
1926+ case AF_INET6:
1927+
1928+ p = (unsigned char *) &((struct sockaddr_in6 *) a)->sin6_port;
1929+ t = (unsigned char *) &((struct sockaddr_in6 *) a)->sin6_addr;
1930+
1931+ Debug ("port %d, host %2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x:%2x%02x\n",
1932+ (p[0] << 8) + p[1],
1933+ t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7],
1934+ t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15]);
1935+
1936 break;
1937 }
1938 #endif
1939diff -ruN xc.old/programs/xdm/socket.c xc/programs/xdm/socket.c
1940--- xc.old/programs/xdm/socket.c Sat Jan 18 08:02:24 1997
1941+++ xc/programs/xdm/socket.c Mon Jul 7 23:16:50 1997
1942@@ -84,7 +84,7 @@
1943 CreateWellKnownSockets ()
1944 {
1945 #ifndef MINIX
1946- struct sockaddr_in sock_addr;
1947+ struct sockaddr_in6 sock_addr;
1948 #else /* MINIX */
1949 char *tcp_device, *udp_device;
1950 nwio_udpopt_t udpopt;
1951@@ -103,7 +103,7 @@
1952 udp_device= UDP_DEVICE;
1953 xdmcpFd = open(udp_device, O_RDWR);
1954 #else
1955- xdmcpFd = socket (AF_INET, SOCK_DGRAM, 0);
1956+ xdmcpFd = socket (AF_INET6, SOCK_DGRAM, 0);
1957 #endif
1958 if (xdmcpFd == -1) {
1959 LogError ("XDMCP socket creation failed, errno %d\n", errno);
1960@@ -145,11 +145,12 @@
1961 /* zero out the entire structure; this avoids 4.4 incompatibilities */
1962 bzero ((char *) &sock_addr, sizeof (sock_addr));
1963 #ifdef BSD44SOCKETS
1964- sock_addr.sin_len = sizeof(sock_addr);
1965+ sock_addr.sin6_len = sizeof(sock_addr);
1966 #endif
1967- sock_addr.sin_family = AF_INET;
1968- sock_addr.sin_port = htons ((short) request_port);
1969- sock_addr.sin_addr.s_addr = htonl (INADDR_ANY);
1970+ sock_addr.sin6_family = AF_INET6;
1971+ sock_addr.sin6_port = htons ((short) request_port);
1972+ sock_addr.sin6_flowinfo = 0;
1973+ sock_addr.sin6_addr = in6addr_any;
1974 if (bind (xdmcpFd, (struct sockaddr *)&sock_addr, sizeof (sock_addr)) == -1)
1975 {
1976 LogError ("error %d binding socket address %d\n", errno, request_port);
1977@@ -167,7 +168,7 @@
1978 tcp_device= TCP_DEVICE;
1979 chooserFd = open(tcp_device, O_RDWR);
1980 #else
1981- chooserFd = socket (AF_INET, SOCK_STREAM, 0);
1982+ chooserFd = socket (AF_INET6, SOCK_STREAM, 0);
1983 #endif
1984 Debug ("Created chooser socket %d\n", chooserFd);
1985 if (chooserFd == -1)
1986@@ -216,7 +217,7 @@
1987 char *addr;
1988 int *lenp;
1989 {
1990- struct sockaddr_in in_addr;
1991+ struct sockaddr_in6 in_addr;
1992 int len;
1993
1994 len = sizeof in_addr;
1995diff -ruN xc.old/programs/xdm/xdmcp.c xc/programs/xdm/xdmcp.c
1996--- xc.old/programs/xdm/xdmcp.c Sun Feb 1 22:44:04 1998
1997+++ xc/programs/xdm/xdmcp.c Thu Apr 2 17:10:26 1998
1998@@ -66,6 +66,8 @@
1999 #include <net/gen/netdb.h>
2000 #endif /* !MINIX */
2001
2002+# include <arpa/inet.h>
2003+
2004 #ifdef X_NOT_STDC_ENV
2005 #define Time_t long
2006 extern Time_t time ();
2007@@ -133,8 +135,8 @@
2008 ARRAY8Ptr address;
2009 char *closure;
2010 {
2011-#ifdef AF_INET
2012- struct sockaddr_in in_addr;
2013+#ifdef AF_INET6
2014+ struct sockaddr_in6 in_addr;
2015 #endif
2016 #ifdef AF_DECnet
2017 #endif
2018@@ -143,19 +145,20 @@
2019
2020 switch (connectionType)
2021 {
2022-#ifdef AF_INET
2023+#ifdef AF_INET6
2024 case FamilyInternet:
2025 addr = (struct sockaddr *) &in_addr;
2026 bzero ((char *) &in_addr, sizeof (in_addr));
2027 #ifdef BSD44SOCKETS
2028- in_addr.sin_len = sizeof(in_addr);
2029+ in_addr.sin6_len = sizeof(in_addr);
2030 #endif
2031- in_addr.sin_family = AF_INET;
2032- in_addr.sin_port = htons ((short) XDM_UDP_PORT);
2033- if (address->length != 4)
2034+ in_addr.sin6_family = AF_INET6;
2035+ in_addr.sin6_flowinfo = 0;
2036+ in_addr.sin6_port = htons ((short) XDM_UDP_PORT);
2037+ if (address->length != 16)
2038 return;
2039- memmove( (char *) &in_addr.sin_addr, address->data, address->length);
2040- addrlen = sizeof (struct sockaddr_in);
2041+ memmove( (char *) &in_addr.sin6_addr, address->data, address->length);
2042+ addrlen = sizeof (struct sockaddr_in6);
2043 break;
2044 #endif
2045 #ifdef AF_DECnet
2046@@ -287,7 +290,7 @@
2047 ProcessRequestSocket ()
2048 {
2049 XdmcpHeader header;
2050- struct sockaddr_in addr;
2051+ struct sockaddr_in6 addr;
2052 int addrlen = sizeof addr;
2053 #ifdef MINIX
2054 int r;
2055@@ -486,7 +489,8 @@
2056
2057 data = connectionAddress->data;
2058 hostent = gethostbyaddr ((char *)data,
2059- connectionAddress->length, AF_INET);
2060+ connectionAddress->length,
2061+ connectionAddress->length == 4 ? AF_INET : AF_INET6);
2062 if (sourceAddress && hostent) {
2063 #if defined(__SVR4) && defined(__sun)
2064 /*
2065@@ -546,11 +550,34 @@
2066 }
2067 else
2068 {
2069+ if (multiHomed) {
2070+ if (((struct sockaddr_in *)
2071+ originalAddress)->sin_family == AF_INET) {
2072+ data = (CARD8 *) &((struct sockaddr_in *)
2073+ originalAddress)->sin_addr.s_addr;
2074+ goto v4;
2075+ }
2076+ data = (CARD8 *) &((struct sockaddr_in6 *)
2077+ originalAddress)->sin6_addr;
2078+ goto v6;
2079+ }
2080+ if (connectionAddress->length == sizeof (struct in6_addr)) {
2081+ v6:
2082+ if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)data)) {
2083+ data += sizeof(struct in6_addr)-sizeof(struct in_addr);
2084+ goto v4;
2085+ }
2086+ if (!getString (name, INET6_ADDRSTRLEN+6))
2087+ return 0;
2088+ (void) inet_ntop(AF_INET6, data, name, INET6_ADDRSTRLEN);
2089+ sprintf(name+strlen(name), ":%d", displayNumber);
2090+ return name;
2091+ }
2092+ if (connectionAddress->length != 4)
2093+ return 0;
2094+ v4:
2095 if (!getString (name, 25))
2096 return 0;
2097- if (multiHomed)
2098- data = (CARD8 *) &((struct sockaddr_in *)originalAddress)->
2099- sin_addr.s_addr;
2100 sprintf(name, "%d.%d.%d.%d:%d",
2101 data[0], data[1], data[2], data[3], displayNumber);
2102 }
2103@@ -631,6 +658,29 @@
2104 }
2105 break;
2106 #endif
2107+#ifdef AF_INET6
2108+ case AF_INET6:
2109+ {
2110+ struct sockaddr_in6 in_addr;
2111+
2112+ if (clientAddress.length != 16 ||
2113+ clientPort.length != 2)
2114+ {
2115+ goto badAddress;
2116+ }
2117+ bzero ((char *) &in_addr, sizeof (in_addr));
2118+#ifdef BSD44SOCKETS
2119+ in_addr.sin6_len = sizeof(in_addr);
2120+#endif
2121+ in_addr.sin6_family = AF_INET6;
2122+ in_addr.sin6_flowinfo = 0;
2123+ memmove( &in_addr.sin6_addr, clientAddress.data, 16);
2124+ memmove( (char *) &in_addr.sin6_port, clientPort.data, 2);
2125+ client = (struct sockaddr *) &in_addr;
2126+ clientlen = sizeof (in_addr);
2127+ }
2128+ break;
2129+#endif
2130 #ifdef AF_UNIX
2131 case AF_UNIX:
2132 {
2133@@ -1199,11 +1249,14 @@
2134 char *local_name;
2135
2136 hostent = gethostbyaddr ((char *)connectionAddress->data,
2137- connectionAddress->length, AF_INET);
2138+ connectionAddress->length,
2139+ connectionAddress->length == 4 ? AF_INET : AF_INET6);
2140
2141 if (hostent)
2142 local_name = hostent->h_name;
2143 else {
2144+ if (connectionAddress->length != 4)
2145+ break;
2146 /* can't get name, so use emergency fallback */
2147 sprintf(dotted, "%d.%d.%d.%d",
2148 connectionAddress->data[0],
2149diff -ruN xc.old/programs/xfs/difs/main.c xc/programs/xfs/difs/main.c
2150--- xc.old/programs/xfs/difs/main.c Thu Nov 5 20:28:29 1998
2151+++ xc/programs/xfs/difs/main.c Fri Jan 8 20:08:42 1999
2152@@ -59,6 +59,10 @@
2153 #include "cache.h"
2154 #include "site.h"
2155
2156+#include <sys/types.h>
2157+#include <netinet/in.h>
2158+#include <resolv.h>
2159+
2160 char *ConnectionInfo;
2161 int ConnInfoLen;
2162
2163@@ -93,6 +97,10 @@
2164
2165 argcGlobal = argc;
2166 argvGlobal = argv;
2167+
2168+ if ((_res.options & RES_INIT) == 0)
2169+ (void)res_init();
2170+ _res.options |= RES_USE_INET6;
2171
2172 configfilename = DEFAULT_CONFIG_FILE;
2173
2174diff -ruN xc.old/programs/xfs/os/access.c xc/programs/xfs/os/access.c
2175--- xc.old/programs/xfs/os/access.c Sat Jan 18 08:02:45 1997
2176+++ xc/programs/xfs/os/access.c Mon Jul 7 23:26:42 1997
2177@@ -93,7 +93,7 @@
2178 char hname[64];
2179 struct hostent *hp;
2180
2181- addr->addr_len = sizeof(struct in_addr);
2182+ addr->addr_len = sizeof(struct in6_addr);
2183 addr->address = (pointer) fsalloc(addr->addr_len);
2184 if (!addr->address)
2185 return FSBadAlloc;
2186diff -ruN xc.old/programs/xfwp/xfwp.c xc/programs/xfwp/xfwp.c
2187--- xc.old/programs/xfwp/xfwp.c Fri Jan 23 00:53:25 1998
2188+++ xc/programs/xfwp/xfwp.c Thu Apr 2 17:17:41 1998
2189@@ -57,6 +57,7 @@
2190 #endif
2191 #include <sys/wait.h>
2192 #include <netdb.h>
2193+#include <resolv.h>
2194 #if defined(_ANSI_SOURCE) && defined(__bsdi__)
2195 #undef _ANSI_SOURCE
2196 #include <signal.h>
2197@@ -163,13 +164,13 @@
2198 main (int argc, char * argv[])
2199 {
2200 struct clientDataStruct client_data;
2201- struct sockaddr_in dest_server;
2202+ struct sockaddr_in6 dest_server;
2203 struct pm_policy policy;
2204 int pm_listen_array[MAX_TRANSPORTS];
2205 int pm_conn_counter;
2206- struct sockaddr_in pm_sockaddr_in;
2207+ struct sockaddr_in6 pm_sockaddr_in6;
2208 int rem_listen_counter;
2209- struct sockaddr_in rem_sockaddr_in;
2210+ struct sockaddr_in6 rem_sockaddr_in6;
2211 fd_set readable, writable, rinit, winit;
2212 int nfds = 0;
2213 int nready = 0;
2214@@ -196,6 +197,10 @@
2215 /*
2216 // now do the rest of the setup
2217 */
2218+ if ((_res.options & RES_INIT) == 0)
2219+ (void) res_init();
2220+ _res.options |= RES_USE_INET6;
2221+
2222 doProcessInputArgs(config_info, argc, argv);
2223 if ((config_status = doHandleConfigFile(config_info)) == FAILURE)
2224 exit(1);
2225@@ -515,7 +520,7 @@
2226 {
2227 int this_server;
2228 int one = 1;
2229- struct sockaddr_in rem_sockaddr_in;
2230+ struct sockaddr_in6 rem_sockaddr_in6;
2231 int port_counter;
2232 int listen_port;
2233 char port_buff[10];
2234@@ -578,7 +583,7 @@
2235 return FAILURE;
2236 }
2237 if ((server_array[this_server]->client_listen_fd =
2238- socket(AF_INET, SOCK_STREAM, 0)) < 0)
2239+ socket(AF_INET6, SOCK_STREAM, 0)) < 0)
2240 {
2241 #ifdef DEBUG
2242 fprintf(stderr,"doRemClientSetup: socket() call failed!");
2243@@ -599,8 +604,11 @@
2244 /*
2245 // set up the rest of the remote client listener
2246 */
2247- bzero((char * ) &rem_sockaddr_in, sizeof(rem_sockaddr_in));
2248- rem_sockaddr_in.sin_family = AF_INET;
2249+ bzero((char * ) &rem_sockaddr_in6, sizeof(rem_sockaddr_in6));
2250+ rem_sockaddr_in6.sin6_family = AF_INET6;
2251+ rem_sockaddr_in6.sin6_len = sizeof(rem_sockaddr_in6);
2252+ rem_sockaddr_in6.sin6_flowinfo = 0;
2253+ rem_sockaddr_in6.sin6_addr = in6addr_any;
2254 if (setsockopt(server_array[this_server]->client_listen_fd,
2255 SOL_SOCKET, SO_REUSEADDR,
2256 &one, sizeof(one)) < 0)
2257@@ -617,10 +625,10 @@
2258 }
2259
2260 while (True) {
2261- rem_sockaddr_in.sin_port = htons(listen_port);
2262+ rem_sockaddr_in6.sin6_port = htons(listen_port);
2263 if (bind(server_array[this_server]->client_listen_fd,
2264- (struct sockaddr *)&rem_sockaddr_in,
2265- sizeof(rem_sockaddr_in)) == 0)
2266+ (struct sockaddr *)&rem_sockaddr_in6,
2267+ sizeof(rem_sockaddr_in6)) == 0)
2268 break;
2269 if (errno != EADDRINUSE)
2270 {
2271@@ -1003,7 +1011,7 @@
2272 int server_reason_len;
2273 int conn_auth_namelen, conn_auth_datalen;
2274 char throw_away[RWBUFFER_SIZE];
2275- struct sockaddr_in server_sockaddr_in;
2276+ struct sockaddr_in6 server_sockaddr_in6;
2277 enum CONFIG_CHECK server_status;
2278 xConnClientPrefix client;
2279 xConnSetupPrefix prefix;
2280@@ -1039,10 +1047,10 @@
2281 int check_sock_fd;
2282 struct timeval time_val;
2283 struct timezone time_zone;
2284- struct sockaddr_in temp_sockaddr_in;
2285+ struct sockaddr_in6 temp_sockaddr_in6;
2286 int retval;
2287 int config_check;
2288- int addrlen = sizeof(temp_sockaddr_in);
2289+ int addrlen = sizeof(temp_sockaddr_in6);
2290 /*
2291 // start by accepting the connection if you can, use pm_listen_array
2292 // index to index into ICE listen_object list (this is because the
2293@@ -1061,17 +1069,17 @@
2294 // connection; start by using getpeername() to get endpoint info
2295 */
2296 retval = getpeername(temp_sock_fd,
2297- (struct sockaddr*)&temp_sockaddr_in,
2298+ (struct sockaddr*)&temp_sockaddr_in6,
2299 &addrlen);
2300
2301- assert(temp_sockaddr_in.sin_family == AF_INET);
2302+ assert(temp_sockaddr_in6.sin6_family == AF_INET6);
2303
2304 /*
2305 // then do the configuration check; NOTE: we're not doing anything
2306- // with the server_sockaddr_in argument
2307+ // with the server_sockaddr_in6 argument
2308 */
2309- if ((config_check = doConfigCheck(&temp_sockaddr_in,
2310- &server_sockaddr_in,
2311+ if ((config_check = doConfigCheck(&temp_sockaddr_in6,
2312+ &server_sockaddr_in6,
2313 config_info,
2314 PMGR,
2315 &log_data)) == FAILURE)
2316@@ -1302,17 +1310,18 @@
2317 // configuration, if connection allowed, allocate
2318 // the read/write buffer for this connection;
2319 */
2320- struct sockaddr_in temp_sockaddr_in;
2321- int temp_sock_fd;
2322- int temp_sock_len;
2323- int host_count;
2324- int config_check;
2325- struct timeval time_val;
2326- struct timezone time_zone;
2327+ struct sockaddr_in6 temp_sockaddr_in6;
2328+ int temp_sock_fd;
2329+ int temp_sock_len;
2330+ int host_count;
2331+ int config_check;
2332+ struct timeval time_val;
2333+ struct timezone time_zone;
2334+ char v1[64], v2[64];
2335
2336- temp_sock_len = sizeof(temp_sockaddr_in);
2337+ temp_sock_len = sizeof(temp_sockaddr_in6);
2338 if ((temp_sock_fd = accept(fd_counter,
2339- (struct sockaddr *) &temp_sockaddr_in,
2340+ (struct sockaddr *) &temp_sockaddr_in6,
2341 &temp_sock_len)) < 0)
2342 {
2343 /*
2344@@ -1336,7 +1345,7 @@
2345 if ((server_status =
2346 doServerConnectSetup(server_array[listen_counter]->x_server_hostport,
2347 &server_array[listen_counter]->server_fd,
2348- &server_sockaddr_in)) == FAILURE)
2349+ &server_sockaddr_in6)) == FAILURE)
2350 {
2351 #ifdef DEBUG
2352 fprintf(stderr,
2353@@ -1346,7 +1355,7 @@
2354 }
2355 if ((server_status =
2356 doServerConnect(&server_array[listen_counter]->server_fd,
2357- &server_sockaddr_in)) == FAILURE)
2358+ &server_sockaddr_in6)) == FAILURE)
2359 {
2360 #ifdef DEBUG
2361 fprintf(stderr,
2362@@ -1355,15 +1364,18 @@
2363 return;
2364 }
2365 /*
2366- // derive and save the client IP source and destination address strings
2367- // for logging purposes (have to do it here while we have them; even if
2368- // this client connection passes the config check, it might fail the
2369- // server security checks later); also, init the config_rule_num field
2370- */
2371- log_data.source = Malloc(strlen(inet_ntoa(temp_sockaddr_in.sin_addr)));
2372- log_data.destination = Malloc(strlen(inet_ntoa(server_sockaddr_in.sin_addr)));
2373- strcpy(log_data.source, inet_ntoa(temp_sockaddr_in.sin_addr));
2374- strcpy(log_data.destination, inet_ntoa(server_sockaddr_in.sin_addr));
2375+ // derive and save the client IPv6 source and destination
2376+ // address strings for logging purposes (have to do it here
2377+ // while we have them; even if this client connection passes
2378+ // the config check, it might fail the server security checks later);
2379+ // also, init the config_rule_num field
2380+ */
2381+ log_data.source = Malloc(strlen(inet_ntop(AF_INET6,
2382+ &temp_sockaddr_in6.sin6_addr, v1, sizeof(v1))));
2383+ log_data.destination = Malloc(strlen(inet_ntop(AF_INET6,
2384+ &server_sockaddr_in6.sin6_addr, v2, sizeof(v2))));
2385+ strcpy(log_data.source, v1);
2386+ strcpy(log_data.destination, v2);
2387 log_data.config_rule_num = -1;
2388 /*
2389 // do config check on client source and destination (must do
2390@@ -1371,8 +1383,8 @@
2391 // to query and we may not be able to resolve server name
2392 // alone from xfindproxy()
2393 */
2394- if ((config_check = doConfigCheck(&temp_sockaddr_in,
2395- &server_sockaddr_in,
2396+ if ((config_check = doConfigCheck(&temp_sockaddr_in6,
2397+ &server_sockaddr_in6,
2398 config_info,
2399 CLIENT,
2400 &log_data)) == FAILURE)
2401@@ -1454,13 +1466,13 @@
2402 // server security extension or other loggable events)
2403 */
2404 client_conn_array[temp_sock_fd]->source =
2405- Malloc(strlen(inet_ntoa(temp_sockaddr_in.sin_addr)));
2406+ Malloc(strlen(inet_ntop(AF_INET6,
2407+ &temp_sockaddr_in6.sin6_addr, v1, sizeof(v1))));
2408 client_conn_array[temp_sock_fd]->destination =
2409- Malloc(strlen(inet_ntoa(server_sockaddr_in.sin_addr)));
2410- strcpy(client_conn_array[temp_sock_fd]->source,
2411- inet_ntoa(temp_sockaddr_in.sin_addr));
2412- strcpy(client_conn_array[temp_sock_fd]->destination,
2413- inet_ntoa(server_sockaddr_in.sin_addr));
2414+ Malloc(strlen(inet_ntop(AF_INET6,
2415+ &server_sockaddr_in6.sin6_addr, v2, sizeof(v2))));
2416+ strcpy(client_conn_array[temp_sock_fd]->source, v1);
2417+ strcpy(client_conn_array[temp_sock_fd]->destination, v2);
2418 /*
2419 // allocate a buffer for the X server connection
2420 // and create the association between client and server
2421@@ -1959,7 +1971,7 @@
2422 fprintf(stderr, "Server replied AUTHENTICATE!\n");
2423 #endif
2424 /*
2425- // retrieve the client IP source and destination address strings
2426+ // retrieve the client IPv6 source and destination address strings
2427 */
2428 log_data.source =
2429 Malloc(strlen
2430@@ -2030,13 +2042,22 @@
2431 }/* end if client_conn_array != NULL */
2432 }
2433
2434-int doConfigCheck(struct sockaddr_in * source_sockaddr_in,
2435- struct sockaddr_in * dest_sockaddr_in,
2436+#define IN6ADDR_MATCH(x,m,y) \
2437+ match = 1; \
2438+ for (i = 0; i < sizeof(struct in6_addr) && (m).s6_addr[i] != 0; i++) \
2439+ if (((x).s6_addr[i] & (m).s6_addr[i]) != (y).s6_addr[i]) { \
2440+ match = 0; \
2441+ break; \
2442+ }
2443+
2444+int doConfigCheck(struct sockaddr_in6 * source_sockaddr_in6,
2445+ struct sockaddr_in6 * dest_sockaddr_in6,
2446 struct config * config_info,
2447 int context,
2448 struct log_struct * log_data)
2449 {
2450 int line_counter;
2451+ int i, match;
2452 /*
2453 // look through the config file parse tree for a source IP address
2454 // that matches this request
2455@@ -2045,12 +2066,13 @@
2456 {
2457 if (config_info->config_file_data[line_counter] != NULL)
2458 {
2459- if ((source_sockaddr_in->sin_addr.s_addr &
2460- (~(config_info->config_file_data[line_counter]->source_net))) ==
2461- config_info->config_file_data[line_counter]->source_host)
2462+ IN6ADDR_MATCH(source_sockaddr_in6->sin6_addr,
2463+ config_info->config_file_data[line_counter]->source_net,
2464+ config_info->config_file_data[line_counter]->source_host);
2465+ if (match)
2466 {
2467 /*
2468- // okay, the source host and netmask fields pass, see if the
2469+ // okay, the source host and prefix length fields pass, see if the
2470 // config file specifies "permit" or "deny" for this host
2471 */
2472 if (!strcmp(config_info->config_file_data[line_counter]->permit_deny,
2473@@ -2065,9 +2087,10 @@
2474 /*
2475 // compute destination info restrictions
2476 */
2477- if ((dest_sockaddr_in->sin_addr.s_addr &
2478- (~(config_info->config_file_data[line_counter]->dest_net))) ==
2479- config_info->config_file_data[line_counter]->dest_host)
2480+ IN6ADDR_MATCH(dest_sockaddr_in6->sin6_addr,
2481+ config_info->config_file_data[line_counter]->dest_net,
2482+ config_info->config_file_data[line_counter]->dest_host);
2483+ if (match)
2484 {
2485 /*
2486 // you got a match on the destination, so look at
2487@@ -2171,9 +2194,10 @@
2488 /*
2489 // compute destination info restrictions
2490 */
2491- if ((dest_sockaddr_in->sin_addr.s_addr &
2492- (~(config_info->config_file_data[line_counter]->dest_net))) ==
2493- config_info->config_file_data[line_counter]->dest_host)
2494+ IN6ADDR_MATCH(dest_sockaddr_in6->sin6_addr,
2495+ config_info->config_file_data[line_counter]->dest_net,
2496+ config_info->config_file_data[line_counter]->dest_host);
2497+ if (match)
2498 {
2499 /*
2500 // you got a match on the destination, so look at
2501@@ -2292,7 +2316,7 @@
2502 if (config_info->config_file_path == NULL)
2503 {
2504 if (printConfigVerify)
2505- fputs("matched default permit 0.0.0.0 255.255.255.255\n", stderr);
2506+ fputs("matched default permit :: 0\n", stderr);
2507 /*
2508 // there's no rule match to save
2509 */
2510@@ -2301,7 +2325,7 @@
2511 }
2512
2513 if (printConfigVerify)
2514- fputs("matched default deny 0.0.0.0 255.255.255.255\n", stderr);
2515+ fputs("matched default deny :: 0\n", stderr);
2516 /*
2517 // not in this case either
2518 */
2519@@ -2395,8 +2419,8 @@
2520 pmGetProxyAddrReplyMsg * pReply;
2521 char * pReplyData;
2522 struct hostent * hostptr;
2523- struct sockaddr_in server_sockaddr_in;
2524- struct sockaddr_in dummy_sockaddr_in;
2525+ struct sockaddr_in6 server_sockaddr_in6;
2526+ struct sockaddr_in6 dummy_sockaddr_in6;
2527 char * server_name_base;
2528 int config_check;
2529 char * config_failure = "unrecognized server or permission denied";
2530@@ -2497,9 +2521,9 @@
2531 #endif
2532 goto sendFailure;
2533 }
2534- memset(&server_sockaddr_in, 0, sizeof(server_sockaddr_in));
2535- memset(&dummy_sockaddr_in, 0, sizeof(dummy_sockaddr_in));
2536- memcpy((char *) &server_sockaddr_in.sin_addr,
2537+ memset(&server_sockaddr_in6, 0, sizeof(server_sockaddr_in6));
2538+ memset(&dummy_sockaddr_in6, 0, sizeof(dummy_sockaddr_in6));
2539+ memcpy((char *) &server_sockaddr_in6.sin6_addr,
2540 hostptr->h_addr,
2541 hostptr->h_length);
2542
2543@@ -2509,11 +2533,11 @@
2544 // NOTE: source configuration will always match (see XFWP man
2545 // page) unless sysadmin explicitly chooses to deny
2546 */
2547- memcpy((char *) &dummy_sockaddr_in.sin_addr,
2548+ memcpy((char *) &dummy_sockaddr_in6.sin6_addr,
2549 hostptr->h_addr,
2550 hostptr->h_length);
2551- if ((config_check = doConfigCheck(&dummy_sockaddr_in,
2552- &server_sockaddr_in,
2553+ if ((config_check = doConfigCheck(&dummy_sockaddr_in6,
2554+ &server_sockaddr_in6,
2555 global_data.config_info,
2556 FINDPROXY,
2557 &log_data)) == FAILURE)
2558@@ -2759,7 +2783,7 @@
2559
2560 int doServerConnectSetup(char * x_server_hostport,
2561 int * server_connect_fd,
2562- struct sockaddr_in * server_sockaddr_in)
2563+ struct sockaddr_in6 * server_sockaddr_in6)
2564 {
2565 struct hostent * hostptr;
2566 char * server_name_base;
2567@@ -2796,7 +2820,7 @@
2568 #endif
2569 return;
2570 }
2571- if ((*server_connect_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
2572+ if ((*server_connect_fd = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
2573 {
2574 #ifdef DEBUG
2575 fprintf(stderr,
2576@@ -2805,20 +2829,21 @@
2577 #endif
2578 return FAILURE;
2579 }
2580- memset(server_sockaddr_in, 0, sizeof(*server_sockaddr_in));
2581- server_sockaddr_in->sin_family = hostptr->h_addrtype;
2582- memcpy((char *) &server_sockaddr_in->sin_addr,
2583+ memset(server_sockaddr_in6, 0, sizeof(*server_sockaddr_in6));
2584+ server_sockaddr_in6->sin6_family = hostptr->h_addrtype;
2585+ server_sockaddr_in6->sin6_len = sizeof(*server_sockaddr_in6);
2586+ memcpy((char *) &server_sockaddr_in6->sin6_addr,
2587 hostptr->h_addr,
2588 hostptr->h_length);
2589- server_sockaddr_in->sin_port = htons(server_port);
2590+ server_sockaddr_in6->sin6_port = htons(server_port);
2591 return SUCCESS;
2592 }
2593
2594 int doServerConnect(int * server_connect_fd,
2595- struct sockaddr_in * server_sockaddr_in)
2596+ struct sockaddr_in6 * server_sockaddr_in6)
2597 {
2598- if(connect(*server_connect_fd, (struct sockaddr * )server_sockaddr_in,
2599- sizeof(*server_sockaddr_in)) < 0)
2600+ if(connect(*server_connect_fd, (struct sockaddr * )server_sockaddr_in6,
2601+ sizeof(*server_sockaddr_in6)) < 0)
2602 {
2603 #ifdef DEBUG
2604 fprintf(stderr,
2605@@ -3122,13 +3147,13 @@
2606
2607 config_lineP->permit_deny = NULL;
2608 config_lineP->source_hostname = NULL;
2609- config_lineP->source_host = 0;
2610- config_lineP->source_netmask = NULL;
2611- config_lineP->source_net = 0;
2612+ bzero((char *)&config_lineP->source_host, sizeof(struct in6_addr));
2613+ config_lineP->source_preflen = NULL;
2614+ bzero((char *)&config_lineP->source_net, sizeof(struct in6_addr));
2615 config_lineP->dest_hostname = NULL;
2616- config_lineP->dest_host = 0;
2617- config_lineP->dest_netmask = NULL;
2618- config_lineP->dest_net = 0;
2619+ bzero((char *)&config_lineP->dest_host, sizeof(struct in6_addr));
2620+ config_lineP->dest_preflen = NULL;
2621+ bzero((char *)&config_lineP->dest_net, sizeof(struct in6_addr));
2622 config_lineP->operator = NULL;
2623 config_lineP->service = NULL;
2624
2625@@ -3200,7 +3225,7 @@
2626 {
2627 char token[64];
2628 strcpy(token, result);
2629- if (doVerifyHostMaskToken(token))
2630+ if (doVerifyHostToken(token))
2631 {
2632 if ((config_file_data[line_number]->source_hostname =
2633 (char *) malloc (strlen(result) + 1)) == NULL)
2634@@ -3219,22 +3244,24 @@
2635 /*
2636 // generate network address format
2637 */
2638- config_file_data[line_number]->source_host =
2639- inet_addr(config_file_data[line_number]->source_hostname);
2640+ inet_pton(AF_INET6,
2641+ config_file_data[line_number]->source_hostname,
2642+ &config_file_data[line_number]->source_host);
2643 } else
2644 bad_token = 1;
2645 }
2646
2647 /*
2648- // now the source netmask field
2649+ // now the source prefix length field
2650 */
2651 if ((result = strtok(NULL, SEPARATOR1)) != NULL)
2652 {
2653 char token[64];
2654+ int plen, j;
2655 strcpy(token, result);
2656- if (doVerifyHostMaskToken(token))
2657+ if (doVerifyMaskToken(token))
2658 {
2659- if ((config_file_data[line_number]->source_netmask =
2660+ if ((config_file_data[line_number]->source_preflen =
2661 (char *) malloc (strlen(result) + 1)) == NULL)
2662 {
2663 #ifdef DEBUG
2664@@ -3242,14 +3269,18 @@
2665 #endif
2666 return 0;
2667 }
2668- strcpy(config_file_data[line_number]->source_netmask, result);
2669+ strcpy(config_file_data[line_number]->source_preflen, result);
2670 #ifdef DEBUG
2671 fprintf(stderr,
2672 "third token = %s\n",
2673- config_file_data[line_number]->source_netmask);
2674+ config_file_data[line_number]->source_preflen);
2675 #endif
2676- config_file_data[line_number]->source_net =
2677- inet_addr(config_file_data[line_number]->source_netmask);
2678+ plen = atoi(config_file_data[line_number]->source_preflen);
2679+ for (j = 0; plen >= 8; plen -= 8, j++)
2680+ config_file_data[line_number]->source_net.s6_addr[j] = 0xff;
2681+ if (plen != 0)
2682+ config_file_data[line_number]->source_net.s6_addr[j] =
2683+ 0xff << (8 - plen);
2684 } else
2685 bad_token = 1;
2686 }
2687@@ -3260,7 +3291,7 @@
2688 {
2689 char token[64];
2690 strcpy(token, result);
2691- if (doVerifyHostMaskToken(token))
2692+ if (doVerifyHostToken(token))
2693 {
2694 if ((config_file_data[line_number]->dest_hostname =
2695 (char *) malloc (strlen(result) + 1)) == NULL)
2696@@ -3276,21 +3307,23 @@
2697 "fourth token = %s\n",
2698 config_file_data[line_number]->dest_hostname);
2699 #endif
2700- config_file_data[line_number]->dest_host =
2701- inet_addr(config_file_data[line_number]->dest_hostname);
2702+ inet_pton(AF_INET6,
2703+ config_file_data[line_number]->dest_hostname,
2704+ &config_file_data[line_number]->dest_host);
2705 } else
2706 bad_token = 1;
2707 }
2708 /*
2709- // now the destination netmask field
2710+ // now the destination prefix length field
2711 */
2712 if ((result = strtok(NULL, SEPARATOR1)) != NULL)
2713 {
2714 char token[64];
2715+ int plen, j;
2716 strcpy(token, result);
2717- if (doVerifyHostMaskToken(token))
2718+ if (doVerifyMaskToken(token))
2719 {
2720- if ((config_file_data[line_number]->dest_netmask =
2721+ if ((config_file_data[line_number]->dest_preflen =
2722 (char *) malloc (strlen(result) + 1)) == NULL)
2723 {
2724 #ifdef DEBUG
2725@@ -3298,14 +3331,18 @@
2726 #endif
2727 return 0;
2728 }
2729- strcpy(config_file_data[line_number]->dest_netmask, result);
2730+ strcpy(config_file_data[line_number]->dest_preflen, result);
2731 #ifdef DEBUG
2732 fprintf(stderr,
2733 "fifth token = %s\n",
2734- config_file_data[line_number]->dest_netmask);
2735+ config_file_data[line_number]->dest_preflen);
2736 #endif
2737- config_file_data[line_number]->dest_net =
2738- inet_addr(config_file_data[line_number]->dest_netmask);
2739+ plen = atoi(config_file_data[line_number]->dest_preflen);
2740+ for (j = 0; plen >= 8; plen -= 8, j++)
2741+ config_file_data[line_number]->dest_net.s6_addr[j] = 0xff;
2742+ if (plen != 0)
2743+ config_file_data[line_number]->dest_net.s6_addr[j] =
2744+ 0xff << (8 - plen);
2745 } else
2746 bad_token = 1;
2747 }
2748@@ -3377,9 +3414,9 @@
2749 ((config_file_data[line_number]->permit_deny != NULL) &&
2750 (config_file_data[line_number]->source_hostname == NULL)) ||
2751 ((config_file_data[line_number]->source_hostname != NULL) &&
2752- (config_file_data[line_number]->source_netmask == NULL)) ||
2753+ (config_file_data[line_number]->source_preflen == NULL)) ||
2754 ((config_file_data[line_number]->dest_hostname != NULL) &&
2755- (config_file_data[line_number]->dest_netmask == NULL)) ||
2756+ (config_file_data[line_number]->dest_preflen == NULL)) ||
2757 ((config_file_data[line_number]->operator != NULL) &&
2758 (config_file_data[line_number]->service == NULL)))
2759 return 1;
2760@@ -3388,27 +3425,23 @@
2761 return 0;
2762 }
2763
2764-int doVerifyHostMaskToken(char token[])
2765+int doVerifyHostToken(char token[])
2766 {
2767- char * result;
2768- int delimiter_count = 0;
2769+ struct in6_addr addr;
2770 /*
2771- // verify there are 3 "." delimiters in the token
2772+ // verify it is a real IPv6 address
2773 */
2774- while (token)
2775- {
2776- if ((result = strchr(token, SEPARATOR2)) != NULL)
2777- {
2778- token = result;
2779- delimiter_count++;
2780- token ++;
2781- } else
2782- token = result;
2783- }
2784- if ((delimiter_count < 3) || (delimiter_count > 3))
2785- return 0;
2786- else
2787- return 1;
2788+ return (inet_pton(AF_INET6, token, &addr) > 0);
2789+}
2790+
2791+int doVerifyMaskToken(char token[])
2792+{
2793+ int plen;
2794+ /*
2795+ // verify it is a legal prefix length
2796+ */
2797+ plen = atoi(token);
2798+ return ((plen >= 0) && (plen <= 128));
2799 }
2800
2801 void BadSyntax(char *msg, int line)
2802@@ -3483,8 +3516,8 @@
2803 struct config_line *ruleP = config_info->config_file_data[line_counter];
2804 fprintf(stderr,"matched: %s %s %s %s %s %s %s\n",
2805 ruleP->permit_deny,
2806- ruleP->source_hostname, ruleP->source_netmask,
2807- ruleP->dest_hostname, ruleP->dest_netmask,
2808+ ruleP->source_hostname, ruleP->source_preflen,
2809+ ruleP->dest_hostname, ruleP->dest_preflen,
2810 ruleP->operator,
2811 ruleP->service);
2812 }
2813diff -ruN xc.old/programs/xfwp/xfwp.h xc/programs/xfwp/xfwp.h
2814--- xc.old/programs/xfwp/xfwp.h Wed Jun 11 14:09:00 1997
2815+++ xc/programs/xfwp/xfwp.h Wed Sep 3 22:53:27 1997
2816@@ -61,7 +61,7 @@
2817 /* allocate ADD_LINES entries at a time when loading the configuration */
2818 #define ADD_LINES 20
2819 #define SEPARATOR1 " \t\n"
2820-#define SEPARATOR2 '.'
2821+#define SEPARATOR2 ':'
2822
2823 #define min(a,b) ((a) < (b) ? (a) : (b))
2824 #define max(a,b) ((a) > (b) ? (a) : (b))
2825@@ -194,13 +194,13 @@
2826 {
2827 char * permit_deny;
2828 char * source_hostname;
2829- unsigned int source_host;
2830- char * source_netmask;
2831- unsigned int source_net;
2832+ struct in6_addr source_host;
2833+ char * source_preflen;
2834+ struct in6_addr source_net;
2835 char * dest_hostname;
2836- unsigned int dest_host;
2837- char * dest_netmask;
2838- unsigned int dest_net;
2839+ struct in6_addr dest_host;
2840+ char * dest_preflen;
2841+ struct in6_addr dest_net;
2842 char * operator;
2843 char * service;
2844 int service_id;
2845@@ -303,8 +303,8 @@
2846 struct client_conn_buf * client_conn_array[],
2847 struct ice_data * ice_data);
2848
2849-int doConfigCheck(struct sockaddr_in * temp_sockaddr_in,
2850- struct sockaddr_in * server_sockaddr_in,
2851+int doConfigCheck(struct sockaddr_in6 * temp_sockaddr_in6,
2852+ struct sockaddr_in6 * server_sockaddr_in6,
2853 struct config * config_info,
2854 int context,
2855 struct log_struct * log_data);
2856@@ -337,10 +337,10 @@
2857
2858 int doServerConnectSetup(char * x_server_hostport,
2859 int * server_connect_fd,
2860- struct sockaddr_in * server_addr_in);
2861+ struct sockaddr_in6 * server_addr_in6);
2862
2863 int doServerConnect(int * server_connect_fd,
2864- struct sockaddr_in * server_addr_in);
2865+ struct sockaddr_in6 * server_addr_in6);
2866
2867 int doProcessLine(char *line,
2868 struct config * config_info,
2869@@ -352,7 +352,9 @@
2870
2871 Bool doConfigRequireDisallow(int, char*);
2872
2873-int doVerifyHostMaskToken(char token[]);
2874+int doVerifyHostToken(char token[]);
2875+
2876+int doVerifyMaskToken(char token[]);
2877
2878 void doInstallIOErrorHandler();
2879
2880diff -ruN xc.old/programs/xfwp/xfwp.man xc/programs/xfwp/xfwp.man
2881--- xc.old/programs/xfwp/xfwp.man Tue Dec 24 11:04:47 1996
2882+++ xc/programs/xfwp/xfwp.man Tue Jul 8 00:05:40 1997
2883@@ -206,7 +206,7 @@
2884 packet-filtering routers. It contains zero or more source-destination
2885 rules of the following form:
2886 .PP
2887-[#]{permit | deny} <src> <src mask> [<dest> <dest mask> [<operator> <service>]]
2888+[#]{permit | deny} <src> <src len> [<dest> <dest len> [<operator> <service>]]
2889 .sp
2890 .IP # 12
2891 comment delimiter; evaluator will skip these lines
2892@@ -214,21 +214,21 @@
2893 the keywords ``permit'' or ``deny'' indicate whether the
2894 rule will enable or disable access, respectively
2895 .IP src 12
2896-the IP address against the host who originated the
2897-connection request will be matched, expressed in IP
2898-format (x.x.x.x)
2899-.IP "src mask" 12
2900-a subnet mask, also in IP format, for further qualifying
2901-the source mask. Bits set in the mask indicate bits of the
2902+the IPv6 address against the host who originated the
2903+connection request will be matched, expressed in IPv6
2904+format (x:x:x:x:x:x:x:x)
2905+.IP "src len" 12
2906+a prefix length, a number between 0 and 128, for further qualifying
2907+the source prefix. Bits after the prefix indicate bits of the
2908 incoming address to be \fIignored\fP when comparing to the specified src
2909 .IP dest 12
2910-the IP address against which the destination of the
2911-incoming connection request (i.e. the host IP of the
2912+the IPv6 address against which the destination of the
2913+incoming connection request (i.e. the host IPv6 of the
2914 X server to which the incoming client is attempting to
2915 connect) will be matched
2916-.IP "dest mask" 12
2917-a subnet mask, also in IP format, for further qualifying
2918-the destination mask. Bits set in the mask indicate bits of the
2919+.IP "dest len" 12
2920+a prefix length, a number between 0 and 128, for further qualifying
2921+the destination prefix. Bits after the prefix indicate bits of the
2922 destination address to be \fIignored\fP when comparing to the specified dest
2923 .IP operator 12
2924 always ``eq'' (if the service field is not NULL)
2925@@ -267,8 +267,8 @@
2926 .RS 3
2927 while (more entries to check)
2928 {
2929- if ((<originator IP> AND (NOT <src mask>)) == src)
2930- [if ((<dest X server IP> AND (NOT <dest mask>)) == dest)]
2931+ if ((<originator IPv6> AND (<src prefix>)) == src)
2932+ [if ((<dest X server IPv6> AND (<dest prefix>)) == dest)]
2933 [if (service fields present and matching)]
2934 do either permit or deny connection depending on keyword
2935 else
2936@@ -312,22 +312,22 @@
2937 require policy1
2938 require policy2
2939 #
2940-# deny pm connections originating on 8.7.6.5 [NOTE: If pm service
2941+# deny pm connections originating on 8:7:6:5:4:3:2:1 [NOTE: If pm service
2942 # is explicitly qualified, line must include destination fields as
2943 # shown.]
2944 #
2945-deny 8.7.6.5 0.0.0.0 0.0.0.0 255.255.255.255 eq pm
2946+deny 8:7:6:5:4:3:2:1 128 :: 0 eq pm
2947 #
2948 # permit xfindproxy X server connects to anywhere [NOTE: If
2949 # fp service is explicitly qualified, line must include source fields
2950 # as shown.]
2951 #
2952-permit 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255 eq fp
2953+permit :: 0 :: 0 eq fp
2954 #
2955-# permit all connection types originating from the 192.0.0.0
2956-# IP domain only
2957+# permit all connection types originating from the fec0::/10
2958+# IPv6 domain only
2959 #
2960-permit 192.0.0.0 0.255.255.255
2961+permit fec0:: 10
2962 .fi
2963 \fP
2964 .PP
2965diff -ruN xc.old/programs/xhost/xhost.c xc/programs/xhost/xhost.c
2966--- xc.old/programs/xhost/xhost.c Sun Sep 13 15:15:59 1998
2967+++ xc/programs/xhost/xhost.c Fri Jan 8 20:06:40 1999
2968@@ -75,6 +75,7 @@
2969 #endif
2970 #include <netdb.h>
2971 #include <netinet/in.h>
2972+#include <resolv.h>
2973 #else
2974 #include <server/ip/gen/socket.h>
2975 #include <server/ip/types.h>
2976@@ -153,6 +154,9 @@
2977 #ifdef AF_INET
2978 { AF_INET, FamilyInternet },
2979 #endif
2980+#ifdef AF_INET6
2981+ { AF_INET6, FamilyInternet },
2982+#endif
2983 };
2984
2985 #define FAMILIES ((sizeof familyMap)/(sizeof familyMap[0]))
2986@@ -184,6 +188,12 @@
2987
2988 ProgramName = argv[0];
2989
2990+#ifdef NEEDSOCKETS
2991+ if ((_res.options & RES_INIT) == 0)
2992+ (void)res_init();
2993+ _res.options |= RES_USE_INET6;
2994+#endif
2995+
2996 if ((dpy = XOpenDisplay(NULL)) == NULL) {
2997 fprintf(stderr, "%s: unable to open display \"%s\"\n",
2998 ProgramName, XDisplayName (NULL));
2999@@ -308,7 +318,7 @@
3000 #endif
3001 #ifdef NEEDSOCKETS
3002 #ifndef AMTCPCONN
3003- static struct in_addr addr; /* so we can point at it */
3004+ static struct in6_addr addr; /* so we can point at it */
3005 #else
3006 static ipaddr_t addr;
3007 #endif
3008@@ -484,41 +494,30 @@
3009 }
3010 #ifdef NEEDSOCKETS
3011 /*
3012- * First see if inet_addr() can grok the name; if so, then use it.
3013- */
3014-#ifndef AMTCPCONN
3015- if ((addr.s_addr = inet_addr(name)) != -1) {
3016-#else
3017- if ((addr = inet_addr(name)) != -1) {
3018-#endif
3019- ha.family = FamilyInternet;
3020- ha.length = 4; /* but for Cray would be sizeof(addr.s_addr) */
3021- ha.address = (char *)&addr; /* but for Cray would be &addr.s_addr */
3022- if (add) {
3023- XAddHost (dpy, &ha);
3024- printf ("%s %s\n", name, add_msg);
3025- } else {
3026- XRemoveHost (dpy, &ha);
3027- printf ("%s %s\n", name, remove_msg);
3028- }
3029- return 1;
3030- }
3031- /*
3032+ * (gethostbyname knows how to handle litterals...)
3033 * Is it in the namespace?
3034 */
3035- else if (((hp = gethostbyname(name)) == (struct hostent *)NULL)
3036- || hp->h_addrtype != AF_INET) {
3037+ if (((hp = gethostbyname(name)) == (struct hostent *)NULL)
3038+ || hp->h_addrtype != AF_INET6) {
3039 return 0;
3040 } else {
3041 ha.family = XFamily(hp->h_addrtype);
3042- ha.length = hp->h_length;
3043 #ifdef h_addr /* new 4.3bsd version of gethostent */
3044 {
3045 char **list;
3046
3047 /* iterate over the hosts */
3048 for (list = hp->h_addr_list; *list; list++) {
3049+ ha.length = hp->h_length;
3050 ha.address = *list;
3051+#ifdef UNMAPPED_IPV4
3052+ if ((ha.family == FamilyInternet) &&
3053+ (ha.length == sizeof(struct in6_addr)) &&
3054+ IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ha.address)) {
3055+ ha.length = sizeof(struct in_addr);
3056+ ha.address += sizeof(struct in6_addr) - sizeof(struct in_addr);
3057+ }
3058+#endif
3059 if (add) {
3060 XAddHost (dpy, &ha);
3061 } else {
3062@@ -527,7 +526,16 @@
3063 }
3064 }
3065 #else
3066+ ha.length = hp->h_length;
3067 ha.address = hp->h_addr;
3068+#ifdef UNMAPPED_IPV4
3069+ if ((ha.family == FamilyInternet) &&
3070+ (ha.length == sizeof(struct in6_addr)) &&
3071+ IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ha.address)) {
3072+ ha.length = sizeof(struct in_addr);
3073+ ha.address += sizeof(struct in6_addr) - sizeof(struct in_addr);
3074+ }
3075+#endif
3076 if (add) {
3077 XAddHost (dpy, &ha);
3078 } else {
3079@@ -545,7 +553,7 @@
3080
3081 /*
3082 * get_hostname - Given an internet address, return a name (CHARON.MIT.EDU)
3083- * or a string representing the address (18.58.0.13) if the name cannot
3084+ * or a string representing the address (::ffff:18.58.0.13) if the name cannot
3085 * be found.
3086 */
3087
3088@@ -556,7 +564,7 @@
3089 {
3090 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
3091 struct hostent *hp = NULL;
3092- char *inet_ntoa();
3093+ static char v[64];
3094 #endif
3095 #ifdef DNETCONN
3096 struct nodeent *np;
3097@@ -571,12 +579,6 @@
3098
3099 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
3100 if (ha->family == FamilyInternet) {
3101-#ifdef CRAY
3102- struct in_addr t_addr;
3103- bzero((char *)&t_addr, sizeof(t_addr));
3104- bcopy(ha->address, (char *)&t_addr, 4);
3105- ha->address = (char *)&t_addr;
3106-#endif
3107 /* gethostbyaddr can take a LONG time if the host does not exist.
3108 Assume that if it does not respond in NAMESERVER_TIMEOUT seconds
3109 that something is wrong and do not make the user wait.
3110@@ -586,16 +588,17 @@
3111 signal(SIGALRM, nameserver_lost);
3112 alarm(4);
3113 if (setjmp(env) == 0) {
3114- hp = gethostbyaddr (ha->address, ha->length, AF_INET);
3115+ hp = gethostbyaddr (ha->address, ha->length,
3116+ ha->length == 4 ? AF_INET : AF_INET6);
3117 }
3118 alarm(0);
3119 if (hp)
3120 return (hp->h_name);
3121-#ifndef AMTCPCONN
3122- else return (inet_ntoa(*((struct in_addr *)(ha->address))));
3123-#else
3124- else return (inet_ntoa(*((ipaddr_t *)(ha->address))));
3125-#endif
3126+ else {
3127+ inet_ntop(ha->length == 4 ? AF_INET : AF_INET6,
3128+ ha->address, v, sizeof(v));
3129+ return (v);
3130+ }
3131 }
3132 #endif
3133 if (ha->family == FamilyNetname) {
This page took 0.553032 seconds and 4 git commands to generate.