Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 21392 Details for
Bug 24445
xfree with ipv6 SmsGenerateClientID fails, leading to "...severely misconfigured" warning when starting kde
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
fixed patch
2000_all_4.3.0-ipv6-server.patch (text/plain), 189.43 KB, created by
Andrew Bevitt
on 2003-11-27 16:28:57 UTC
(
hide
)
Description:
fixed patch
Filename:
MIME Type:
Creator:
Andrew Bevitt
Created:
2003-11-27 16:28:57 UTC
Size:
189.43 KB
patch
obsolete
>diff -ur 4.3.0/xc/LABEL 4.3.0+IPv6/xc/LABEL >--- 4.3.0/xc/LABEL Sun Sep 27 00:48:02 1998 >+++ 4.3.0+IPv6/xc/LABEL Sat Mar 1 23:38:37 2003 >@@ -1,5 +1,5 @@ > X Window System, Version 11 >- Release 6.4 >+ Release 6.6 > > Portions Copyright by: > >diff -ur 4.3.0/xc/config/cf/FreeBSD.cf 4.3.0+IPv6/xc/config/cf/FreeBSD.cf >--- 4.3.0/xc/config/cf/FreeBSD.cf Tue Jan 14 18:52:12 2003 >+++ 4.3.0+IPv6/xc/config/cf/FreeBSD.cf Sat Mar 1 23:34:36 2003 >@@ -489,6 +489,10 @@ > #endif > #endif > >+#if OSMajorVersion >= 4 >+#define HasIPv6 YES >+#endif >+ > #ifdef i386Architecture > # define OptimizedCDebugFlags DefaultGcc2i386Opt > #else >diff -ur 4.3.0/xc/config/cf/NetBSD.cf 4.3.0+IPv6/xc/config/cf/NetBSD.cf >--- 4.3.0/xc/config/cf/NetBSD.cf Sat Dec 14 14:36:03 2002 >+++ 4.3.0+IPv6/xc/config/cf/NetBSD.cf Sat Mar 1 23:34:36 2003 >@@ -648,3 +648,10 @@ > #ifndef UseSeparateConfDir > #define UseSeparateConfDir NO /* We don't want appdefs in "/etc/X11". */ > #endif >+ >+#if defined(NetBSDArchitecture) && \ >+ ((OSMajorVersion > 1) || \ >+ (OSMajorVersion == 1 && OSMinorVersion > 3)) >+#define HasDevRandom YES >+#define RandomDeviceFile /dev/urandom >+#endif >diff -ur 4.3.0/xc/config/cf/X11.tmpl 4.3.0+IPv6/xc/config/cf/X11.tmpl >--- 4.3.0/xc/config/cf/X11.tmpl Tue Feb 25 13:57:52 2003 >+++ 4.3.0+IPv6/xc/config/cf/X11.tmpl Mon Mar 3 19:00:25 2003 >@@ -1,6 +1,7 @@ > XCOMM ---------------------------------------------------------------------- > XCOMM X Window System Build Parameters and Rules > XCOMM $Xorg: X11.tmpl,v 1.6 2000/08/17 19:41:46 cpqbld Exp $ >+XCOMM Updated for IPv6 > XCOMM > XCOMM > XCOMM >@@ -761,16 +762,29 @@ > #ifndef FontCompilerFlags > #define FontCompilerFlags -t > #endif >-#ifndef ConnectionFlags >-#if HasStreams >-#define ConnectionFlags -DSTREAMSCONN >+#ifndef HasIPv6 >+#define HasIPv6 NO >+#endif >+#ifndef IPv6Flags >+#if HasIPv6 >+#define IPv6Flags -DIPv6 > #else >+#define IPv6Flags >+#endif >+#endif >+#ifndef DECnetFlags > #if HasDECnet >-#define ConnectionFlags -DTCPCONN -DUNIXCONN -DDNETCONN >+#define DECnetFlags -DDNETCONN > #else >-#define ConnectionFlags -DTCPCONN -DUNIXCONN >+#define DECnetFlags > #endif > #endif >+#ifndef ConnectionFlags >+#if HasStreams >+#define ConnectionFlags -DSTREAMSCONN >+#else >+#define ConnectionFlags -DTCPCONN -DUNIXCONN DECnetFlags >+#endif > #endif > #if HasStickyDirBit > STICKY_DEFINES = -DHAS_STICKY_DIR_BIT >@@ -779,7 +793,7 @@ > FCHOWN_DEFINES = -DHAS_FCHOWN > #endif > #ifndef ExtraConnectionDefs >-#define ExtraConnectionDefs $(STICKY_DEFINES) $(FCHOWN_DEFINES) >+#define ExtraConnectionDefs $(STICKY_DEFINES) $(FCHOWN_DEFINES) IPv6Flags > #endif > #ifndef ProjectThreadsDefines > #define ProjectThreadsDefines -DXTHREADS >@@ -1140,6 +1154,28 @@ > # define StrcasecmpDefines /**/ > # else > # define StrcasecmpDefines -DNEED_STRCASECMP >+# endif >+#endif >+ >+#ifndef HasDevRandom >+#define HasDevRandom NO >+#endif >+ >+#ifndef RandomDefines >+# if HasDevRandom >+# ifndef RandomDeviceFile >+# define RandomDeviceFile /dev/random >+# endif >+# ifndef ExtraRandomDefines >+# ifdef PollDevRandom /* Set if can poll() /dev/random to avoid blocking */ >+# define ExtraRandomDefines -DPOLL_DEV_RANDOM >+# else >+# define ExtraRandomDefines /**/ >+# endif >+# endif >+# define RandomDefines -DDEV_RANDOM=\"RandomDeviceFile\" ExtraRandomDefines >+# else >+# define RandomDefines /**/ > # endif > #endif > >diff -ur 4.3.0/xc/config/cf/sun.cf 4.3.0+IPv6/xc/config/cf/sun.cf >--- 4.3.0/xc/config/cf/sun.cf Fri Nov 22 14:55:56 2002 >+++ 4.3.0+IPv6/xc/config/cf/sun.cf Mon Mar 3 18:59:53 2003 >@@ -1,5 +1,5 @@ > XCOMM platform: $Xorg: sun.cf,v 1.4 2000/08/17 19:41:48 cpqbld Exp $ >- >+XCOMM Updated for IPv6 > > > >@@ -302,6 +302,11 @@ > #define HasSecureRPC YES > #define SetTtyGroup YES > #define HasPutenv YES >+#if (OSMajorVersion > 5) || ( (OSMajorVersion == 5) && (OSMinorVersion >= 8)) >+#define HasIPv6 YES /* IPv6 is in SunOS 5.8 (Solaris 8) & later */ >+#define HasDevRandom YES /* /dev/random is in Solaris 8 patches */ >+#define PollDevRandom YES /* /dev/random is poll()able on Solaris */ >+#endif > #if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 9)) > # define HasIssetugid YES > #endif >@@ -406,7 +411,7 @@ > # endif > # else /* OSMajorVersion >= 5*/ > # ifndef DefaultCCOptions >-# define DefaultCCOptions -Xa >+# define DefaultCCOptions -Xa -v > # endif > # endif > # endif >diff -ur 4.3.0/xc/config/makedepend/main.c 4.3.0+IPv6/xc/config/makedepend/main.c >--- 4.3.0/xc/config/makedepend/main.c Fri Jan 17 09:09:49 2003 >+++ 4.3.0+IPv6/xc/config/makedepend/main.c Mon Mar 3 18:02:17 2003 >@@ -57,9 +57,9 @@ > > /* #define DEBUG_DUMP */ > #ifdef DEBUG_DUMP >-#define DBG_PRINT(args...) fprintf(args) >+#define DBG_PRINT(a,b,c) fprintf(a,b,c) > #else >-#define DBG_PRINT(args...) /* empty */ >+#define DBG_PRINT(a,b,c) /* empty */ > #endif > > #define DASH_INC_PRE "#include \"" >diff -ur 4.3.0/xc/include/X.h 4.3.0+IPv6/xc/include/X.h >--- 4.3.0/xc/include/X.h Fri Dec 14 11:53:25 2001 >+++ 4.3.0+IPv6/xc/include/X.h Sat Mar 1 23:34:41 2003 >@@ -1,5 +1,6 @@ > /* > * $Xorg: X.h,v 1.4 2001/02/09 02:03:22 xorgcvs Exp $ >+ * Updated for IPv6 > */ > > /* Definitions for the X window system likely to be used by applications */ >@@ -299,9 +300,10 @@ > > /* protocol families */ > >-#define FamilyInternet 0 >+#define FamilyInternet 0 /* IPv4 */ > #define FamilyDECnet 1 > #define FamilyChaos 2 >+#define FamilyInternetV6 6 /* IPv6 */ > > /* Property notification */ > >diff -ur 4.3.0/xc/include/fonts/FS.h 4.3.0+IPv6/xc/include/fonts/FS.h >--- 4.3.0/xc/include/fonts/FS.h Fri Dec 14 11:53:31 2001 >+++ 4.3.0+IPv6/xc/include/fonts/FS.h Sat Mar 1 23:34:41 2003 >@@ -66,6 +66,7 @@ > #define FamilyInternet 0 > #define FamilyDECnet 1 > #define FamilyChaos 2 >+#define FamilyInternetV6 6 > > > typedef unsigned int FSDrawDirection; >diff -ur 4.3.0/xc/lib/SM/sm_genid.c 4.3.0+IPv6/xc/lib/SM/sm_genid.c >--- 4.3.0/xc/lib/SM/sm_genid.c Fri Dec 14 11:53:55 2001 >+++ 4.3.0+IPv6/xc/lib/SM/sm_genid.c Mon Mar 3 18:39:36 2003 >@@ -1,8 +1,9 @@ > /* $Xorg: sm_genid.c,v 1.4 2001/02/09 02:03:30 xorgcvs Exp $ */ >- >+/* Updated for IPv6 */ > /* > > Copyright 1993, 1998 The Open Group >+Copyright 2002 Sun Microsystems, Inc. > > Permission to use, copy, modify, distribute, and sell this software and its > documentation for any purpose is hereby granted without fee, provided that >@@ -120,7 +121,7 @@ > { > #if defined(TCPCONN) || defined(STREAMSCONN) > char hostname[256]; >- char address[14]; >+ char address[64]; > char temp[256]; > char *id; > static int sequence = 0; >@@ -133,15 +134,46 @@ > char temp[4], *ptr1, *ptr2; > unsigned char decimal[4]; > int i, len; >+ struct in_addr *haddr = NULL; >+#ifdef IPv6 >+ struct addrinfo *ai, *first_ai; >+ if (getaddrinfo(hostname,NULL,NULL,&ai) == 0) { >+ for (first_ai = ai; ai != NULL; ai = ai->ai_next) { >+ if ( (ai->ai_family == AF_INET) || (ai->ai_family == AF_INET6) ) >+ break; >+ } >+ if (ai == NULL) { >+ freeaddrinfo(first_ai); >+ return NULL; >+ } >+ } else >+ return NULL; >+ >+ if (ai->ai_family == AF_INET6) { >+ unsigned char *cp = (unsigned char *) &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr.s6_addr; >+ >+ address[0] = '6'; /* IPv6 address code */ >+ address[1] = '\0'; >+ >+ for (i = 0 ; i < 16 ; i++) { >+ strcat(address, hex_table[cp[i]]); >+ } >+ >+ } else { /* Fall through to IPv4 address handling */ >+ haddr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr; >+#else > #ifdef XTHREADS_NEEDS_BYNAMEPARAMS > _Xgethostbynameparams hparams; > #endif > struct hostent *hostp; > > if ((hostp = _XGethostbyname (hostname,hparams)) != NULL) >- inet_addr = inet_ntoa (*(struct in_addr *)(hostp->h_addr)); >+ haddr = (struct in_addr *)(hostp->h_addr); > else > return NULL; >+#endif >+ >+ inet_addr = inet_ntoa (*haddr); > for (i = 0, ptr1 = inet_addr; i < 3; i++) > { > ptr2 = strchr (ptr1, '.'); >@@ -160,6 +192,10 @@ > address[1] = '\0'; > for (i = 0; i < 4; i++) > strcat (address, hex_table[decimal[i]]); >+#ifdef IPv6 >+ } >+ freeaddrinfo(first_ai); >+#endif > } > > sprintf (temp, "1%s%.13ld%.10ld%.4d", address, time((Time_t*)0), >diff -ur 4.3.0/xc/lib/X11/ConnDis.c 4.3.0+IPv6/xc/lib/X11/ConnDis.c >--- 4.3.0/xc/lib/X11/ConnDis.c Fri Dec 14 11:53:58 2001 >+++ 4.3.0+IPv6/xc/lib/X11/ConnDis.c Sat Mar 1 23:34:42 2003 >@@ -692,7 +692,11 @@ > AUTH *a; > XDR xdr; > >+#if (defined(SVR4) && defined(sun)) >+ a = authdes_seccreate(servername, window, NULL, NULL); >+#else > a = (AUTH *)authdes_create(servername, window, NULL, NULL); >+#endif > if (a == (AUTH *)NULL) { > perror("auth_create"); > return 0; >diff -ur 4.3.0/xc/lib/X11/ICWrap.c 4.3.0+IPv6/xc/lib/X11/ICWrap.c >--- 4.3.0/xc/lib/X11/ICWrap.c Mon Nov 25 06:04:53 2002 >+++ 4.3.0+IPv6/xc/lib/X11/ICWrap.c Tue Mar 4 10:06:17 2003 >@@ -395,9 +395,9 @@ > XIC ic; > { > if (ic->core.im) { >- if (*ic->methods->utf8_reset) >+ if (ic->methods->utf8_reset) > return (*ic->methods->utf8_reset)(ic); >- else if (*ic->methods->mb_reset) >+ else if (ic->methods->mb_reset) > return (*ic->methods->mb_reset)(ic); > } > return (char *)NULL; >@@ -443,10 +443,10 @@ > Status *status; > { > if (ic->core.im) { >- if (*ic->methods->utf8_lookup_string) >+ if (ic->methods->utf8_lookup_string) > return (*ic->methods->utf8_lookup_string) (ic, ev, buffer, nbytes, > keysym, status); >- else if (*ic->methods->mb_lookup_string) >+ else if (ic->methods->mb_lookup_string) > return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes, > keysym, status); > } >diff -ur 4.3.0/xc/lib/Xdmcp/Xdmcp.h 4.3.0+IPv6/xc/lib/Xdmcp/Xdmcp.h >--- 4.3.0/xc/lib/Xdmcp/Xdmcp.h Wed Dec 19 13:37:31 2001 >+++ 4.3.0+IPv6/xc/lib/Xdmcp/Xdmcp.h Sun Mar 2 00:14:51 2003 >@@ -46,6 +46,9 @@ > XDM_START_CONNECTION, XDM_AWAIT_REQUEST_RESPONSE, > XDM_AWAIT_MANAGE_RESPONSE, XDM_MANAGE, XDM_RUN_SESSION, XDM_OFF, > XDM_AWAIT_USER_INPUT, XDM_KEEPALIVE, XDM_AWAIT_ALIVE_RESPONSE >+#ifdef IPv6 >+ , XDM_MULTICAST, XDM_COLLECT_MULTICAST_QUERY >+#endif > } xdmcp_states; > > #ifdef NOTDEF >diff -ur 4.3.0/xc/lib/xtrans/Xtrans.c 4.3.0+IPv6/xc/lib/xtrans/Xtrans.c >--- 4.3.0/xc/lib/xtrans/Xtrans.c Wed Nov 20 15:00:36 2002 >+++ 4.3.0+IPv6/xc/lib/xtrans/Xtrans.c Sun Mar 2 00:19:24 2003 >@@ -1,4 +1,5 @@ > /* $Xorg: Xtrans.c,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */ >+/* Updated for IPv6 */ > /* > > Copyright 1993, 1994, 1998 The Open Group >@@ -134,7 +135,7 @@ > TRANS(FreeConnInfo) (XtransConnInfo ciptr) > > { >- PRMSG (3,"FreeConnInfo(%x)\n", ciptr, 0, 0); >+ PRMSG (3,"FreeConnInfo(%p)\n", ciptr, 0, 0); > > if (ciptr->addr) > xfree (ciptr->addr); >@@ -166,6 +167,7 @@ > */ > > strncpy (protobuf, protocol, PROTOBUFSIZE - 1); >+ protobuf[PROTOBUFSIZE-1] = '\0'; > > for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++) > if (isupper (protobuf[i])) >@@ -198,7 +200,7 @@ > * Other than fontlib, the address is a string formatted > * as "protocol/host:port". > * >- * If the protocol part is missing, then assume INET. >+ * If the protocol part is missing, then assume TCP. > * If the protocol part and host part are missing, then assume local. > * If a "::" is found then assume DNET. > */ >@@ -220,9 +222,11 @@ > > _protocol = mybuf; > >- if ((mybuf = strpbrk (mybuf,"/:")) == NULL) >- { >- /* adress is in a bad format */ >+ >+ if ( ((mybuf = strchr (mybuf,'/')) == NULL) && >+ ((mybuf = strrchr (tmpptr,':')) == NULL) ) >+ { >+ /* address is in a bad format */ > *protocol = NULL; > *host = NULL; > *port = NULL; >@@ -233,7 +237,7 @@ > if (*mybuf == ':') > { > /* >- * If there is a hostname, then assume inet, otherwise >+ * If there is a hostname, then assume tcp, otherwise > * it must be local. > */ > if (mybuf == tmpptr) >@@ -243,8 +247,8 @@ > } > else > { >- /* Ther is a hostname specified */ >- _protocol = "inet"; >+ /* There is a hostname specified */ >+ _protocol = "tcp"; > mybuf = tmpptr; /* reset to the begining of the host ptr */ > } > } >@@ -257,11 +261,11 @@ > if (strlen(_protocol) == 0) > { > /* >- * If there is a hostname, then assume inet, otherwise >+ * If there is a hostname, then assume tcp, otherwise > * it must be local. > */ > if (*mybuf != ':') >- _protocol = "inet"; >+ _protocol = "tcp"; > else > _protocol = "local"; > } >@@ -271,7 +275,7 @@ > > _host = mybuf; > >- if ((mybuf = strchr (mybuf,':')) == NULL) >+ if ((mybuf = strrchr (mybuf,':')) == NULL) > { > *protocol = NULL; > *host = NULL; >@@ -280,20 +284,26 @@ > return 0; > } > >- *mybuf ++= '\0'; >+ /* Check for DECnet */ > >- if (strlen(_host) == 0) >+ if ((mybuf != _host) && (*(mybuf - 1) == ':') >+#ifdef IPv6 >+ /* An IPv6 address can end in :: so three : in a row is assumed to be >+ an IPv6 host and not a DECnet node with a : in it's name */ >+ && !( (mybuf > (_host + 2)) && (*(mybuf - 2) == ':') ) >+#endif >+ ) > { >- TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf)); >- _host = hostnamebuf; >+ _protocol = "dnet"; >+ *(mybuf - 1) = '\0'; > } > >- /* Check for DECnet */ >+ *mybuf ++= '\0'; > >- if (*mybuf == ':') >+ if (strlen(_host) == 0) > { >- _protocol = "dnet"; >- mybuf++; >+ TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf)); >+ _host = hostnamebuf; > } > > /* Get the port */ >@@ -997,7 +1007,7 @@ > XtransConnInfo ciptr, temp_ciptrs[NUMTRANS]; > int status, i, j; > >- PRMSG (2,"MakeAllCOTSServerListeners(%s,%x)\n", >+ PRMSG (2,"MakeAllCOTSServerListeners(%s,%p)\n", > port ? port : "NULL", ciptrs_ret, 0); > > *count_ret = 0; >@@ -1099,7 +1109,7 @@ > XtransConnInfo ciptr, temp_ciptrs[NUMTRANS]; > int status, i, j; > >- PRMSG (2,"MakeAllCLTSServerListeners(%s,%x)\n", >+ PRMSG (2,"MakeAllCLTSServerListeners(%s,%p)\n", > port ? port : "NULL", ciptrs_ret, 0); > > *count_ret = 0; >diff -ur 4.3.0/xc/lib/xtrans/Xtrans.h 4.3.0+IPv6/xc/lib/xtrans/Xtrans.h >--- 4.3.0/xc/lib/xtrans/Xtrans.h Fri Dec 14 11:57:04 2001 >+++ 4.3.0+IPv6/xc/lib/xtrans/Xtrans.h Sat Mar 1 23:34:42 2003 >@@ -1,4 +1,5 @@ > /* $Xorg: Xtrans.h,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */ >+/* Updated for IPv6 */ > /* > > Copyright 1993, 1994, 1998 The Open Group >@@ -83,7 +84,7 @@ > static char* __xtransname = "_XSERVTrans"; > #endif > #define X11_t >-#endif /* X11_t */ >+#endif /* XSERV_t */ > > #ifdef XIM_t > #if !defined(UNIXCPP) || defined(ANSICPP) >@@ -173,12 +174,16 @@ > * This structure needs to be independent of the socket/TLI interface used. > */ > >+#ifdef IPv6 >+#include <sys/socket.h> >+typedef struct socket_storage Xtransaddr; >+#else > #define XTRANS_MAX_ADDR_LEN 128 /* large enough to hold sun_path */ > > typedef struct { > unsigned char addr[XTRANS_MAX_ADDR_LEN]; > } Xtransaddr; >- >+#endif > > #ifdef LONG64 > typedef int BytesReadable_t; >@@ -450,6 +455,12 @@ > ); > > #endif /* X11_t */ >+ >+void TRANS(FreeConnInfo) ( >+#if NeedFunctionPrototypes >+ XtransConnInfo ciptr >+#endif >+); > > #ifdef ICE_t > >diff -ur 4.3.0/xc/lib/xtrans/Xtranssock.c 4.3.0+IPv6/xc/lib/xtrans/Xtranssock.c >--- 4.3.0/xc/lib/xtrans/Xtranssock.c Mon Nov 25 17:12:30 2002 >+++ 4.3.0+IPv6/xc/lib/xtrans/Xtranssock.c Sat Apr 12 15:11:33 2003 >@@ -1,7 +1,9 @@ > /* $Xorg: Xtranssock.c,v 1.11 2001/02/09 02:04:06 xorgcvs Exp $ */ >+/* Updated for IPv6 */ > /* > > Copyright 1993, 1994, 1998 The Open Group >+Copyright 2002 Sun Microsystems, Inc. All rights reserved. > > Permission to use, copy, modify, distribute, and sell this software and its > documentation for any purpose is hereby granted without fee, provided that >@@ -20,10 +22,10 @@ > ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > OTHER DEALINGS IN THE SOFTWARE. > >-Except as contained in this notice, the name of The Open Group shall >+Except as contained in this notice, the name of the copyright holders shall > not be used in advertising or otherwise to promote the sale, use or > other dealings in this Software without prior written authorization >-from The Open Group. >+from the copyright holders. > > */ > /* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.56 2002/11/26 01:12:30 dawes Exp $ */ >@@ -59,7 +61,9 @@ > #ifndef WIN32 > > #if defined(TCPCONN) || defined(UNIXCONN) >+#include <sys/socket.h> > #include <netinet/in.h> >+#include <arpa/inet.h> > #endif > > #if defined(TCPCONN) || defined(UNIXCONN) >@@ -88,6 +92,7 @@ > #include <sys/param.h> > #endif /* osf */ > #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) >+#include <sys/param.h> > #include <machine/endian.h> > #endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ */ > #include <netinet/tcp.h> >@@ -98,7 +103,7 @@ > #include <sys/filio.h> > #endif > >-#if (defined(i386) && defined(SYSV)) && !defined(sco) >+#if (defined(i386) && defined(SYSV)) && !defined(sco)&& !defined(sun) > #include <net/errno.h> > #endif > >@@ -184,7 +189,12 @@ > static Sockettrans2dev Sockettrans2devtab[] = { > #ifdef TCPCONN > {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, >+#ifndef IPv6 > {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, >+#else /* IPv6 */ >+ {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0}, >+ {"inetv6",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0}, >+#endif > #endif /* TCPCONN */ > #ifdef UNIXCONN > {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0}, >@@ -292,14 +302,18 @@ > TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) > > { >+#ifdef IPv6 >+ struct sockaddr_storage sockname; >+#else > struct sockaddr_in sockname; >+#endif > #if defined(SVR4) || defined(SCO325) > size_t namelen = sizeof sockname; > #else > int namelen = sizeof sockname; > #endif > >- PRMSG (3,"SocketINETGetAddr(%x)\n", ciptr, 0, 0); >+ PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0); > > if (getsockname (ciptr->fd,(struct sockaddr *) &sockname, > (void *)&namelen) < 0) >@@ -321,7 +335,11 @@ > return -1; > } > >+#ifdef IPv6 >+ ciptr->family = sockname.ss_family; >+#else > ciptr->family = sockname.sin_family; >+#endif > ciptr->addrlen = namelen; > memcpy (ciptr->addr, &sockname, ciptr->addrlen); > >@@ -338,14 +356,18 @@ > TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) > > { >+#ifdef IPv6 >+ struct sockaddr_storage sockname; >+#else > struct sockaddr_in sockname; >+#endif > #if defined(SVR4) || defined(SCO325) > size_t namelen = sizeof sockname; > #else > int namelen = sizeof sockname; > #endif > >- PRMSG (3,"SocketINETGetPeerAddr(%x)\n", ciptr, 0, 0); >+ PRMSG (3,"SocketINETGetPeerAddr(%p)\n", ciptr, 0, 0); > > if (getpeername (ciptr->fd, (struct sockaddr *) &sockname, > (void *)&namelen) < 0) >@@ -405,7 +427,11 @@ > } > > #ifdef TCP_NODELAY >- if (Sockettrans2devtab[i].family == AF_INET) >+ if (Sockettrans2devtab[i].family == AF_INET >+#ifdef IPv6 >+ || Sockettrans2devtab[i].family == AF_INET6 >+#endif >+ ) > { > /* > * turn off TCP coalescence for INET sockets >@@ -528,10 +554,14 @@ > #ifdef SO_REUSEADDR > > /* >- * SO_REUSEADDR only applied to AF_INET >+ * SO_REUSEADDR only applied to AF_INET && AF_INET6 > */ > >- if (Sockettrans2devtab[i].family == AF_INET) >+ if (Sockettrans2devtab[i].family == AF_INET >+#ifdef IPv6 >+ || Sockettrans2devtab[i].family == AF_INET6 >+#endif >+ ) > { > int one = 1; > setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR, >@@ -749,9 +779,13 @@ > int fd = ciptr->fd; > int retry; > >- PRMSG (3, "SocketCreateListener(%x,%d)\n", ciptr, fd, 0); >+ PRMSG (3, "SocketCreateListener(%x,%p)\n", ciptr, fd, 0); > >- if (Sockettrans2devtab[ciptr->index].family == AF_INET) >+ if (Sockettrans2devtab[ciptr->index].family == AF_INET >+#ifdef IPv6 >+ || Sockettrans2devtab[ciptr->index].family == AF_INET6 >+#endif >+ ) > retry = 20; > else > retry = 0; >@@ -774,7 +808,11 @@ > #endif /* SO_REUSEDADDR */ > } > >- if (Sockettrans2devtab[ciptr->index].family == AF_INET) { >+ if (Sockettrans2devtab[ciptr->index].family == AF_INET >+#ifdef IPv6 >+ || Sockettrans2devtab[ciptr->index].family == AF_INET6 >+#endif >+ ) { > #ifdef SO_DONTLINGER > setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0); > #else >@@ -807,7 +845,13 @@ > TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port) > > { >+#ifdef IPv6 >+ struct sockaddr_in6 sockname; >+ in_port_t sport; >+#else > struct sockaddr_in sockname; >+ unsigned short sport; >+#endif > int namelen = sizeof(sockname); > int status; > long tmpport; >@@ -855,7 +899,7 @@ > return TRANS_CREATE_LISTENER_FAILED; > } > /* we trust getservbyname to return a valid number */ >- sockname.sin_port = htons (servp->s_port); >+ sport = servp->s_port; > } > else > { >@@ -869,17 +913,28 @@ > if (tmpport < 1024 || tmpport > USHRT_MAX) > return TRANS_CREATE_LISTENER_FAILED; > >- sockname.sin_port = htons (((unsigned short) tmpport)); >+ sport = (unsigned short) tmpport; > } > } > else >- sockname.sin_port = htons (0); >+ sport = 0; > >+ bzero(&sockname, sizeof(sockname)); >+#ifdef IPv6 >+#ifdef SIN6_LEN >+ sockname.sin6_len = sizeof (sockname); >+#endif >+ sockname.sin6_family = AF_INET6; >+ sockname.sin6_port = htons (sport); >+ sockname.sin6_addr = in6addr_any; >+#else > #ifdef BSD44SOCKETS > sockname.sin_len = sizeof (sockname); > #endif > sockname.sin_family = AF_INET; >+ sockname.sin_port = htons (sport); > sockname.sin_addr.s_addr = htonl (INADDR_ANY); >+#endif > > if ((status = TRANS(SocketCreateListener) (ciptr, > (struct sockaddr *) &sockname, namelen)) < 0) >@@ -1008,7 +1063,7 @@ > int status = TRANS_RESET_NOOP; > unsigned int mode; > >- PRMSG (3, "SocketUNIXResetListener(%x,%d)\n", ciptr, ciptr->fd, 0); >+ PRMSG (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd, 0); > > if (stat (unsock->sun_path, &statb) == -1 || > ((statb.st_mode & S_IFMT) != >@@ -1080,7 +1135,7 @@ > struct sockaddr_in sockname; > int namelen = sizeof(sockname); > >- PRMSG (2, "SocketINETAccept(%x,%d)\n", ciptr, ciptr->fd, 0); >+ PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0); > > if ((newciptr = (XtransConnInfo) xcalloc ( > 1, sizeof(struct _XtransConnInfo))) == NULL) >@@ -1160,7 +1215,7 @@ > int namelen = sizeof sockname; > #endif > >- PRMSG (2, "SocketUNIXAccept(%x,%d)\n", ciptr, ciptr->fd, 0); >+ PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0); > > if ((newciptr = (XtransConnInfo) xcalloc ( > 1, sizeof(struct _XtransConnInfo))) == NULL) >@@ -1229,10 +1284,31 @@ > #ifdef TRANS_CLIENT > > #ifdef TCPCONN >+ >+#ifdef IPv6 >+struct addrlist { >+ struct addrinfo * addr; >+ struct addrinfo * firstaddr; >+ char port[PORTBUFSIZE]; >+ char host[MAXHOSTNAMELEN]; >+}; >+static struct addrlist *addrlist = NULL; >+#endif >+ >+ > static int > TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) > > { >+ struct sockaddr * socketaddr = NULL; >+ int socketaddrlen = 0; >+ int res; >+#ifdef IPv6 >+ struct addrinfo hints; >+ char ntopbuf[INET6_ADDRSTRLEN]; >+ struct sockaddr_in6 tmpsin6; >+ int resetonce = 0; >+#else > struct sockaddr_in sockname; > #if defined(SVR4) || defined(SCO325) > size_t namelen = sizeof sockname; >@@ -1245,13 +1321,15 @@ > #endif > struct hostent *hostp; > struct servent *servp; >- >+ unsigned long tmpaddr; >+#endif > #ifdef X11_t > char portbuf[PORTBUFSIZE]; > #endif > >+#if defined(X11_t) || !defined(IPv6) > long tmpport; >- unsigned long tmpaddr; >+#endif > char hostnamebuf[256]; /* tmp space */ > > PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port); >@@ -1281,6 +1359,116 @@ > } > #endif > >+#ifdef IPv6 >+ if (addrlist != NULL) { >+ if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) { >+ if (addrlist->firstaddr) >+ freeaddrinfo(addrlist->firstaddr); >+ addrlist->firstaddr = NULL; >+ } >+ } else { >+ addrlist = malloc(sizeof(struct addrlist)); >+ addrlist->firstaddr = NULL; >+ } >+ >+ if (addrlist->firstaddr == NULL) { >+ strncpy(addrlist->port, port, sizeof(addrlist->port)); >+ addrlist->port[sizeof(addrlist->port) - 1] = '\0'; >+ strncpy(addrlist->host, host, sizeof(addrlist->host)); >+ addrlist->host[sizeof(addrlist->host) - 1] = '\0'; >+ >+ bzero(&hints,sizeof(hints)); >+ hints.ai_socktype = Sockettrans2devtab[ciptr->index].devcotsname; >+ >+ res = getaddrinfo(host,port,&hints,&addrlist->firstaddr); >+ if (res != 0) { >+ PRMSG (1, >+ "TRANS(SocketINETConnect) () can't get address for %s:%s: %s\n", >+ host, port, gai_strerror(res)); >+ ESET(EINVAL); >+ return TRANS_CONNECT_FAILED; >+ } >+ for (res = 0, addrlist->addr = addrlist->firstaddr; addrlist->addr ; res++) { >+ addrlist->addr = addrlist->addr->ai_next; >+ } >+ PRMSG(4,"Got New Address list with %d addresses\n", res, 0, 0); >+ res = 0; >+ addrlist->addr = NULL; >+ } >+ >+ while ( socketaddr == NULL ) { >+ if (addrlist->addr == NULL) { >+ if (resetonce) { >+ /* Already checked entire list - no usable addresses */ >+ PRMSG (1, >+ "TRANS(SocketINETConnect) () no usable address for %s:%s\n", >+ host, port, 0); >+ return TRANS_CONNECT_FAILED; >+ } else { >+ /* Go back to beginning of list */ >+ resetonce = 1; >+ addrlist->addr = addrlist->firstaddr; >+ } >+ } >+ >+ >+ socketaddr = addrlist->addr->ai_addr; >+ socketaddrlen = addrlist->addr->ai_addrlen; >+ >+ if (addrlist->addr->ai_family == AF_INET) { >+ struct sockaddr_in *sin = (struct sockaddr_in *) socketaddr; >+ >+ PRMSG (4,"TRANS(SocketINETConnect) sockname.sin_addr = %s\n", >+ inet_ntop(addrlist->addr->ai_family,&sin->sin_addr, >+ ntopbuf,sizeof(ntopbuf)), 0, 0); >+ >+ PRMSG (4,"TRANS(SocketINETConnect) sockname.sin_port = %d\n", >+ ntohs(sin->sin_port), 0, 0); >+ >+ if (Sockettrans2devtab[ciptr->index].family == AF_INET6) { >+ /* We have IPv6 socket, need to map IPv4 address to IPv6 */ >+ char *v4addr = (char *) &sin->sin_addr.s_addr; >+ bzero(&tmpsin6, sizeof(tmpsin6)); >+#ifdef SIN6_LEN >+ tmpsin6.sin6_len = sizeof(tmpsin6); >+#endif >+ tmpsin6.sin6_family = AF_INET6; >+ tmpsin6.sin6_port = sin->sin_port; >+ tmpsin6.sin6_addr.s6_addr[10] = 0xff; >+ tmpsin6.sin6_addr.s6_addr[11] = 0xff; >+ tmpsin6.sin6_addr.s6_addr[12] = v4addr[0]; >+ tmpsin6.sin6_addr.s6_addr[13] = v4addr[1]; >+ tmpsin6.sin6_addr.s6_addr[14] = v4addr[2]; >+ tmpsin6.sin6_addr.s6_addr[15] = v4addr[3]; >+ >+ socketaddr = (struct sockaddr *) &tmpsin6; >+ socketaddrlen = sizeof(tmpsin6); >+ PRMSG (4,"TRANS(SocketINETConnect) sockname.sin6_addr = %s\n", >+ inet_ntop(AF_INET6, &tmpsin6.sin6_addr, ntopbuf, >+ sizeof(ntopbuf)), 0, 0); >+ } >+ } else if (addrlist->addr->ai_family == AF_INET6) { >+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) socketaddr; >+ >+ PRMSG (4,"TRANS(SocketINETConnect) sockname.sin6_addr = %s\n", >+ inet_ntop(addrlist->addr->ai_family, &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)), >+ 0, 0); >+ PRMSG (4,"TRANS(SocketINETConnect) sockname.sin6_port = %d\n", >+ ntohs(sin6->sin6_port), 0, 0); >+ >+ if (Sockettrans2devtab[ciptr->index].family == AF_INET) { >+ PRMSG (4,"TRANS(SocketINETConnect) Skipping IPv6 address\n", >+ 0,0,0); >+ socketaddr = NULL; >+ } >+ } else { >+ socketaddr = NULL; /* Unsupported address type */ >+ } >+ if (socketaddr == NULL) { >+ addrlist->addr = addrlist->addr->ai_next; >+ } >+ } >+#else > /* > * Build the socket name. > */ >@@ -1305,7 +1493,7 @@ > PRMSG (4,"SocketINETConnect: inet_addr(%s) = %x\n", > host, tmpaddr, 0); > >- if (tmpaddr == -1) >+ if ((long)tmpaddr == -1L) > { > if ((hostp = _XGethostbyname(host,hparams)) == NULL) > { >@@ -1371,6 +1559,9 @@ > > PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n", > ntohs(sockname.sin_port), 0, 0); >+ socketaddr = (struct sockaddr *) &sockname; >+ socketaddrlen = sizeof(sockname); >+#endif /* IPv6 */ > > /* > * Turn on socket keepalive so the client process will eventually >@@ -1393,7 +1584,7 @@ > * Do the connect() > */ > >- if (connect (ciptr->fd, (struct sockaddr *) &sockname, namelen) < 0) >+ if (connect (ciptr->fd, socketaddr, socketaddrlen ) < 0) > { > #ifdef WIN32 > int olderrno = WSAGetLastError(); >@@ -1410,43 +1601,65 @@ > * > * If the error was EINTR, the connect was interrupted and we > * should try again. >+ * >+ * If multiple addresses are found for a host then we should >+ * try to connect again with a different address for a larger >+ * number of errors that made us quit before, since those >+ * could be caused by trying to use an IPv6 address to contact >+ * a machine with an IPv4-only server or other reasons that >+ * only affect one of a set of addresses. > */ > >- if (olderrno == ECONNREFUSED || olderrno == EINTR) >- return TRANS_TRY_CONNECT_AGAIN; >+ if (olderrno == ECONNREFUSED || olderrno == EINTR >+#ifdef IPv6 >+ || ( ((addrlist->addr->ai_next != NULL) || >+ (addrlist->addr != addrlist->firstaddr)) && >+ (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT || >+ olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT)) >+#endif >+ ) >+ res = TRANS_TRY_CONNECT_AGAIN; > else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS) >- return TRANS_IN_PROGRESS; >+ res = TRANS_IN_PROGRESS; > else > { > PRMSG (2,"SocketINETConnect: Can't connect: errno = %d\n", > olderrno,0, 0); > >- return TRANS_CONNECT_FAILED; >+ res = TRANS_CONNECT_FAILED; > } >- } >+ } else { >+ res = 0; > > >- /* >- * Sync up the address fields of ciptr. >- */ >+ /* >+ * Sync up the address fields of ciptr. >+ */ > >- if (TRANS(SocketINETGetAddr) (ciptr) < 0) >- { >- PRMSG (1, >- "SocketINETConnect: ...SocketINETGetAddr() failed:\n", >- 0, 0, 0); >- return TRANS_CONNECT_FAILED; >- } >+ if (TRANS(SocketINETGetAddr) (ciptr) < 0) >+ { >+ PRMSG (1, >+ "SocketINETConnect: ...SocketINETGetAddr() failed:\n", >+ 0, 0, 0); >+ res = TRANS_CONNECT_FAILED; >+ } > >- if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0) >- { >- PRMSG (1, >- "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n", >+ else if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0) >+ { >+ PRMSG (1, >+ "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n", > 0, 0, 0); >- return TRANS_CONNECT_FAILED; >+ res = TRANS_CONNECT_FAILED; >+ } > } > >- return 0; >+#ifdef IPv6 >+ if (res != 0) { >+ addrlist->addr = addrlist->addr->ai_next; >+ } >+#endif >+ >+ return res; > } > > #endif /* TCPCONN */ >@@ -1473,6 +1686,53 @@ > } > else > { >+#ifdef IPv6 >+ struct addrinfo *localhostaddr; >+ struct addrinfo *otherhostaddr; >+ struct addrinfo *i, *j; >+ int equiv = 0; >+ >+ if (getaddrinfo(hostnamebuf, NULL, NULL, &localhostaddr) != 0) >+ return 0; >+ if (getaddrinfo(host, NULL, NULL, &otherhostaddr) != 0) { >+ freeaddrinfo(localhostaddr); >+ return 0; >+ } >+ >+ for (i = localhostaddr; i != NULL && equiv == 0; i = i->ai_next) { >+ for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) { >+ if (i->ai_family == j->ai_family) { >+ if (i->ai_family == AF_INET) { >+ struct sockaddr_in *sinA >+ = (struct sockaddr_in *) i->ai_addr; >+ struct sockaddr_in *sinB >+ = (struct sockaddr_in *) j->ai_addr; >+ struct in_addr *A = &sinA->sin_addr; >+ struct in_addr *B = &sinB->sin_addr; >+ >+ if (memcmp(A,B,sizeof(struct in_addr)) == 0) { >+ equiv = 1; >+ } >+ } else if (i->ai_family == AF_INET6) { >+ struct sockaddr_in6 *sinA >+ = (struct sockaddr_in6 *) i->ai_addr; >+ struct sockaddr_in6 *sinB >+ = (struct sockaddr_in6 *) j->ai_addr; >+ struct in6_addr *A = &sinA->sin6_addr; >+ struct in6_addr *B = &sinB->sin6_addr; >+ >+ if (memcmp(A,B,sizeof(struct in6_addr)) == 0) { >+ equiv = 1; >+ } >+ } >+ } >+ } >+ } >+ >+ freeaddrinfo(localhostaddr); >+ freeaddrinfo(otherhostaddr); >+ return equiv; >+#else > /* > * A host may have more than one network address. If any of the > * network addresses of 'host' (specified to the connect call) >@@ -1542,6 +1802,7 @@ > } > > return (equiv); >+#endif > } > } > >@@ -1703,7 +1964,7 @@ > TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend) > > { >- PRMSG (2,"SocketBytesReadable(%x,%d,%x)\n", >+ PRMSG (2,"SocketBytesReadable(%p,%d,%p)\n", > ciptr, ciptr->fd, pend); > #if defined(QNX4) > *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */ >@@ -1728,7 +1989,7 @@ > TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size) > > { >- PRMSG (2,"SocketRead(%d,%x,%d)\n", ciptr->fd, buf, size); >+ PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size); > > #if defined(WIN32) || defined(__UNIXOS2__) > return recv ((SOCKET)ciptr->fd, buf, size, 0); >@@ -1742,7 +2003,7 @@ > TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size) > > { >- PRMSG (2,"SocketWrite(%d,%x,%d)\n", ciptr->fd, buf, size); >+ PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size); > > #if defined(WIN32) || defined(__UNIXOS2__) > return send ((SOCKET)ciptr->fd, buf, size, 0); >@@ -1756,7 +2017,7 @@ > TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size) > > { >- PRMSG (2,"SocketReadv(%d,%x,%d)\n", ciptr->fd, buf, size); >+ PRMSG (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size); > > return READV (ciptr, buf, size); > } >@@ -1766,7 +2027,7 @@ > TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size) > > { >- PRMSG (2,"SocketWritev(%d,%x,%d)\n", ciptr->fd, buf, size); >+ PRMSG (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size); > > return WRITEV (ciptr, buf, size); > } >@@ -1776,7 +2037,7 @@ > TRANS(SocketDisconnect) (XtransConnInfo ciptr) > > { >- PRMSG (2,"SocketDisconnect(%x,%d)\n", ciptr, ciptr->fd, 0); >+ PRMSG (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd, 0); > > return shutdown (ciptr->fd, 2); /* disallow further sends and receives */ > } >@@ -1787,7 +2048,7 @@ > TRANS(SocketINETClose) (XtransConnInfo ciptr) > > { >- PRMSG (2,"SocketINETClose(%x,%d)\n", ciptr, ciptr->fd, 0); >+ PRMSG (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd, 0); > > return close (ciptr->fd); > } >@@ -1809,7 +2070,7 @@ > char path[200]; /* > sizeof sun_path +1 */ > int ret; > >- PRMSG (2,"SocketUNIXClose(%x,%d)\n", ciptr, ciptr->fd, 0); >+ PRMSG (2,"SocketUNIXClose(%p,%d)\n", ciptr, ciptr->fd, 0); > > ret = close(ciptr->fd); > >@@ -1837,7 +2098,7 @@ > > int ret; > >- PRMSG (2,"SocketUNIXCloseForCloning(%x,%d)\n", >+ PRMSG (2,"SocketUNIXCloseForCloning(%p,%d)\n", > ciptr, ciptr->fd, 0); > > ret = close(ciptr->fd); >diff -ur 4.3.0/xc/lib/xtrans/Xtransutil.c 4.3.0+IPv6/xc/lib/xtrans/Xtransutil.c >--- 4.3.0/xc/lib/xtrans/Xtransutil.c Wed Feb 12 07:01:38 2003 >+++ 4.3.0+IPv6/xc/lib/xtrans/Xtransutil.c Sat Apr 12 15:13:46 2003 >@@ -69,9 +69,10 @@ > * of these values are also defined by the ChangeHost protocol message. > */ > >-#define FamilyInternet 0 >+#define FamilyInternet 0 /* IPv4 */ > #define FamilyDECnet 1 > #define FamilyChaos 2 >+#define FamilyInternetV6 6 > #define FamilyAmoeba 33 > #define FamilyLocalHost 252 > #define FamilyKrb5Principal 253 >@@ -82,7 +83,7 @@ > /* > * TRANS(ConvertAddress) converts a sockaddr based address to an > * X authorization based address. Some of this is defined as part of >- * the ChangeHost protocol. The rest is just doen in a consistent manner. >+ * the ChangeHost protocol. The rest is just done in a consistent manner. > */ > > int >@@ -130,6 +131,42 @@ > } > break; > } >+ >+#ifdef IPv6 >+ case AF_INET6: >+ { >+ struct sockaddr_in6 saddr6; >+ >+ memcpy (&saddr6, *addrp, sizeof (struct sockaddr_in6)); >+ >+ if (IN6_IS_ADDR_LOOPBACK(&saddr6.sin6_addr)) >+ { >+ *familyp=FamilyLocal; >+ } >+ else if (IN6_IS_ADDR_V4MAPPED(&(saddr6.sin6_addr))) { >+ char *cp = (char *) &saddr6.sin6_addr.s6_addr[12]; >+ >+ if ((cp[0] == 127) && (cp[1] == 0) && >+ (cp[2] == 0) && (cp[3] == 1)) >+ { >+ *familyp=FamilyLocal; >+ } >+ else >+ { >+ *familyp=FamilyInternet; >+ *addrlenp = sizeof (struct in_addr); >+ memcpy(*addrp,cp,*addrlenp); >+ } >+ } >+ else >+ { >+ *familyp=FamilyInternetV6; >+ *addrlenp=sizeof(saddr6.sin6_addr); >+ memcpy(*addrp,&saddr6.sin6_addr,sizeof(saddr6.sin6_addr)); >+ } >+ break; >+ } >+#endif /* IPv6 */ > #endif /* defined(TCPCONN) || defined(STREAMSCONN) */ > > #if defined(DNETCONN) >@@ -237,11 +274,26 @@ > > #if defined(TCPCONN) || defined(STREAMSCONN) > case AF_INET: >+#ifdef IPv6 >+ case AF_INET6: >+#endif > { > struct sockaddr_in *saddr = (struct sockaddr_in *) addr; >+#ifdef IPv6 >+ struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) addr; >+#endif >+ int portnum; > char portnumbuf[10]; > >- sprintf (portnumbuf, "%d", ntohs (saddr->sin_port)); >+ >+#ifdef IPv6 >+ if (family == AF_INET6) >+ portnum = ntohs (saddr6->sin6_port); >+ else >+#endif >+ portnum = ntohs (saddr->sin_port); >+ >+ sprintf (portnumbuf, "%d", portnum); > networkId = (char *) xalloc (3 + strlen (transName) + > strlen (hostnamebuf) + strlen (portnumbuf)); > sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf); >@@ -273,7 +325,7 @@ > static jmp_buf env; > > #ifdef SIGALRM >-static int nameserver_timedout = 0; >+static volatile int nameserver_timedout = 0; > > static > #ifdef SIGNALRETURNSINT >@@ -301,7 +353,7 @@ > char *peer_addr = ciptr->peeraddr; > char *hostname; > char addrbuf[256]; >- char *addr = NULL; >+ const char *addr = NULL; > > switch (family) > { >@@ -317,13 +369,33 @@ > > #if defined(TCPCONN) || defined(STREAMSCONN) > case AF_INET: >+#ifdef IPv6 >+ case AF_INET6: >+#endif > { > struct sockaddr_in *saddr = (struct sockaddr_in *) peer_addr; >+#ifdef IPv6 >+ struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) peer_addr; >+#endif >+ char *address; >+ int addresslen; > #ifdef XTHREADS_NEEDS_BYNAMEPARAMS > _Xgethostbynameparams hparams; > #endif > struct hostent * volatile hostp = NULL; > >+#ifdef IPv6 >+ if (family == AF_INET6) { >+ address = (char *) &saddr6->sin6_addr; >+ addresslen = sizeof (saddr6->sin6_addr); >+ } >+ else >+#endif >+ { >+ address = (char *) &saddr->sin_addr; >+ addresslen = sizeof (saddr->sin_addr); >+ } >+ > #ifdef SIGALRM > /* > * gethostbyaddr can take a LONG time if the host does not exist. >@@ -338,8 +410,7 @@ > alarm (4); > if (setjmp(env) == 0) { > #endif >- hostp = _XGethostbyaddr ((char *) &saddr->sin_addr, >- sizeof (saddr->sin_addr), AF_INET, hparams); >+ hostp = _XGethostbyaddr (address, addresslen, family, hparams); > #ifdef SIGALRM > } > alarm (0); >@@ -347,7 +418,11 @@ > if (hostp != NULL) > addr = hostp->h_name; > else >+#ifdef IPv6 >+ addr = inet_ntop (family, address, addrbuf, sizeof (addrbuf)); >+#else > addr = inet_ntoa (saddr->sin_addr); >+#endif > break; > } > >diff -ur 4.3.0/xc/programs/Xserver/os/access.c 4.3.0+IPv6/xc/programs/Xserver/os/access.c >--- 4.3.0/xc/programs/Xserver/os/access.c Sun Jul 7 13:11:52 2002 >+++ 4.3.0+IPv6/xc/programs/Xserver/os/access.c Wed Apr 9 19:44:43 2003 >@@ -1,4 +1,5 @@ > /* $Xorg: access.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */ >+/* Updated for IPv6 */ > /*********************************************************** > > Copyright 1987, 1998 The Open Group >@@ -52,6 +53,7 @@ > #endif > > #include <stdio.h> >+#include <stdlib.h> > #include <X11/Xtrans.h> > #include <X11/Xauth.h> > #include <X.h> >@@ -142,6 +144,17 @@ > #include <ifaddrs.h> > #endif > >+/* Solaris provides an extended interface SIOCGLIFCONF. Other systems >+ * may have this as well, but the code has only been tested on Solaris >+ * so far, so we only enable it there. Other platforms may be added as >+ * needed. >+ */ >+#ifdef SIOCGLIFCONF >+#if defined(sun) >+#define USE_SIOCGLIFCONF >+#endif >+#endif >+ > #endif /* WIN32 */ > > #ifndef PATH_MAX >@@ -170,6 +183,14 @@ > #include "extensions/security.h" > #endif > >+#ifndef PATH_MAX >+#ifdef MAXPATHLEN >+#define PATH_MAX MAXPATHLEN >+#else >+#define PATH_MAX 1024 >+#endif >+#endif >+ > Bool defeatAccessControl = FALSE; > > #define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len) >@@ -191,21 +212,39 @@ > pointer /*addr*/, > int /*len*/); > >+#ifdef XDMCP >+extern void XdmcpRegisterConnection (int type, char *address, int addrlen); >+extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr); >+#endif >+ >+/* default hosts bug fix: To keep track of which hosts were explicitly >+ requested in /etc/X<display>.hosts, we've added a requested field >+ to the HOST struct, and a LocalHostRequested variable. These >+ default to FALSE, but are set to TRUE in ResetHosts when reading in >+ /etc/X<display>.hosts. They are checked in DisableLocalHost(), >+ which is called to disable the default local host entries when >+ stronger authentication is turned on. >+ */ >+ > typedef struct _host { > short family; > short len; > unsigned char *addr; > struct _host *next; >+ int requested; > } HOST; > > #define MakeHost(h,l) (h)=(HOST *) xalloc(sizeof *(h)+(l));\ >- if((h))\ >- (h)->addr=(unsigned char *) ((h) + 1); >+ if ((h)) {\ >+ (h)->addr=(unsigned char *) ((h) + 1);\ >+ (h)->requested = FALSE; \ >+ } > #define FreeHost(h) xfree(h) > static HOST *selfhosts = NULL; > static HOST *validhosts = NULL; > static int AccessEnabled = DEFAULT_ACCESS_CONTROL; > static int LocalHostEnabled = FALSE; >+static int LocalHostRequested = FALSE; > static int UsingXdmcp = FALSE; > > >@@ -232,9 +271,13 @@ > { > HOST *self; > >- LocalHostEnabled = FALSE; >+ if (!LocalHostRequested) >+ LocalHostEnabled = FALSE; > for (self = selfhosts; self; self = self->next) >+ { >+ if (!self->requested) > (void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr); >+ } > } > > /* >@@ -250,7 +293,7 @@ > } > > >-#if ((defined(SVR4) && !defined(DGUX) && !defined(SCO325) && !defined(sun) && !defined(NCR)) || defined(ISC)) && defined(SIOCGIFCONF) >+#if ((defined(SVR4) && !defined(DGUX) && !defined(SCO325) && !defined(sun) && !defined(NCR)) || defined(ISC)) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF) > > /* Deal with different SIOCGIFCONF ioctl semantics on these OSs */ > >@@ -465,9 +508,13 @@ > union { > struct sockaddr sa; > struct sockaddr_in in; >+#ifdef IPv6 >+ struct sockaddr_in6 in6; >+#endif > } saddr; > > struct sockaddr_in *inetaddr; >+ struct sockaddr_in6 *inet6addr; > struct sockaddr_in broad_addr; > #ifdef XTHREADS_NEEDS_BYNAMEPARAMS > _Xgethostbynameparams hparams; >@@ -492,9 +539,22 @@ > if (hp != NULL) > { > saddr.sa.sa_family = hp->h_addrtype; >- inetaddr = (struct sockaddr_in *) (&(saddr.sa)); >- acopy ( hp->h_addr, &(inetaddr->sin_addr), hp->h_length); >- len = sizeof(saddr.sa); >+ switch (hp->h_addrtype) { >+ case AF_INET: >+ inetaddr = (struct sockaddr_in *) (&(saddr.sa)); >+ acopy ( hp->h_addr, &(inetaddr->sin_addr), hp->h_length); >+ len = sizeof(saddr.sa); >+ break; >+#ifdef IPv6 >+ case AF_INET6: >+ inet6addr = (struct sockaddr_in6 *) (&(saddr.sa)); >+ acopy ( hp->h_addr, &(inet6addr->sin6_addr), hp->h_length); >+ len = sizeof(saddr.in6); >+ break; >+#endif >+ default: >+ goto DefineLocalHost; >+ } > family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr); > if ( family != -1 && family != FamilyLocal ) > { >@@ -530,6 +590,14 @@ > XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) > &broad_addr); > } >+#ifdef IPv6 >+ else if (family == FamilyInternetV6 && >+ !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))) >+ { >+ XdmcpRegisterConnection (family, (char *)addr, len); >+ } >+#endif >+ > #endif /* XDMCP */ > } > } >@@ -537,6 +605,7 @@ > /* > * now add a host of family FamilyLocalHost... > */ >+DefineLocalHost: > for (host = selfhosts; > host && !addrEqual(FamilyLocalHost, "", 0, host); > host = host->next); >@@ -557,6 +626,12 @@ > > #else > >+#ifdef USE_SIOCGLIFCONF >+#define ifr_type struct lifreq >+#else >+#define ifr_type struct ifreq >+#endif >+ > #ifdef VARIABLE_IFREQ > #define ifr_size(p) (sizeof (struct ifreq) + \ > (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \ >@@ -567,7 +642,7 @@ > #define ifr_size(p) (p->ifr_addr.sa_len + IFNAMSIZ) > #define ifraddr_size(a) (a.sa_len) > #else >-#define ifr_size(p) (sizeof (struct ifreq)) >+#define ifr_size(p) (sizeof (ifr_type)) > #define ifraddr_size(a) (sizeof (a)) > #endif > #endif >@@ -581,8 +656,17 @@ > { > #ifndef HAS_GETIFADDRS > char buf[2048], *cp, *cplim; >+ void * bufptr = buf; >+#ifdef USE_SIOCGLIFCONF >+ struct lifconf ifc; >+ register struct lifreq *ifr; >+#ifdef SIOCGLIFNUM >+ struct lifnum ifn; >+#endif >+#else > struct ifconf ifc; > register struct ifreq *ifr; >+#endif > #else > struct ifaddrs * ifap, *ifr; > #endif >@@ -621,37 +705,80 @@ > } > #endif /* DNETCONN */ > #ifndef HAS_GETIFADDRS >- ifc.ifc_len = sizeof (buf); >- ifc.ifc_buf = buf; >- if (ifioctl (fd, SIOCGIFCONF, (pointer) &ifc) < 0) >- Error ("Getting interface configuration (4)"); > >+ len = sizeof(buf); >+ >+#ifdef USE_SIOCGLIFCONF >+ >+#ifdef SIOCGLIFNUM >+ ifn.lifn_family = AF_UNSPEC; >+ ifn.lifn_flags = 0; >+ if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0) >+ Error ("Getting interface count"); >+ if (len < (ifn.lifn_count * sizeof(struct lifreq))) { >+ len = ifn.lifn_count * sizeof(struct lifreq); >+ bufptr = xalloc(len); >+ } >+#endif >+ >+ ifc.lifc_family = AF_UNSPEC; >+ ifc.lifc_flags = 0; >+ ifc.lifc_len = len; >+ ifc.lifc_buf = bufptr; >+ >+#define IFC_IOCTL_REQ SIOCGLIFCONF >+#define IFC_IFC_REQ ifc.lifc_req >+#define IFC_IFC_LEN ifc.lifc_len >+#define IFR_IFR_ADDR ifr->lifr_addr >+#define IFR_IFR_NAME ifr->lifr_name >+ >+#else /* Use SIOCGIFCONF */ >+ ifc.ifc_len = len; >+ ifc.ifc_buf = bufptr; >+ >+#define IFC_IOCTL_REQ SIOCGIFCONF > #ifdef ISC > #define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf > #else > #define IFC_IFC_REQ ifc.ifc_req > #endif /* ISC */ >+#define IFC_IFC_LEN ifc.ifc_len >+#define IFR_IFR_ADDR ifr->ifr_addr >+#define IFR_IFR_NAME ifr->ifr_name >+#endif >+ >+ if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0) >+ Error ("Getting interface configuration (4)"); > >- cplim = (char *) IFC_IFC_REQ + ifc.ifc_len; >+ cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN; > > for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr)) > { >- ifr = (struct ifreq *) cp; >- len = ifraddr_size (ifr->ifr_addr); >+ ifr = (ifr_type *) cp; >+ len = ifraddr_size (IFR_IFR_ADDR); >+ family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR, >+ &len, (pointer *)&addr); > #ifdef DNETCONN > /* > * DECnet was handled up above. > */ >- if (ifr->ifr_addr.sa_family == AF_DECnet) >+ if (family == AF_DECnet) > continue; > #endif /* DNETCONN */ >- family = ConvertAddr (&ifr->ifr_addr, &len, (pointer *)&addr); > if (family == -1 || family == FamilyLocal) > continue; > #ifdef DEF_SELF_DEBUG > if (family == FamilyInternet) > ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %d.%d.%d.%d\n", >- ifr->ifr_name, addr[0], addr[1], addr[2], addr[3]); >+ IFR_IFR_NAME, addr[0], addr[1], addr[2], addr[3]); >+#ifdef IPv6 >+ else if (family == FamilyInternetV6) { >+ char cp[INET6_ADDRSTRLEN] = ""; >+ inet_ntop(AF_INET6, addr, cp, sizeof(cp)); >+ ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %s\n", >+ IFR_IFR_NAME, cp); >+ } >+#endif > #endif /* DEF_SELF_DEBUG */ > for (host = selfhosts; > host && !addrEqual (family, addr, len, host); >@@ -670,28 +797,69 @@ > } > #ifdef XDMCP > { >+#ifdef USE_SIOCGLIFCONF >+ struct sockaddr_storage broad_addr; >+#else > struct sockaddr broad_addr; >+#endif > > /* > * If this isn't an Internet Address, don't register it. > */ >- if (family != FamilyInternet) >+ if (family != FamilyInternet >+#ifdef IPv6 >+ && family != FamilyInternetV6 >+#endif >+ ) > continue; > > /* > * ignore 'localhost' entries as they're not useful > * on the other end of the wire > */ >- if (len == 4 && >+ if (family == FamilyInternet && > addr[0] == 127 && addr[1] == 0 && > addr[2] == 0 && addr[3] == 1) > continue; >+#ifdef IPv6 >+ else if (family == FamilyInternetV6 && >+ IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)) >+ continue; >+#endif > > XdmcpRegisterConnection (family, (char *)addr, len); >- broad_addr = ifr->ifr_addr; >+ >+#ifdef IPv6 >+ /* IPv6 doesn't support broadcasting, so we drop out here */ >+ if (family == FamilyInternetV6) >+ continue; >+#endif >+ >+ broad_addr = IFR_IFR_ADDR; >+ > ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr = > htonl (INADDR_BROADCAST); >-#ifdef SIOCGIFBRDADDR >+#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR) >+ { >+ struct lifreq broad_req; >+ >+ broad_req = *ifr; >+ if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 && >+ (broad_req.lifr_flags & IFF_BROADCAST) && >+ (broad_req.lifr_flags & IFF_UP) >+ ) >+ { >+ broad_req = *ifr; >+ if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1) >+ broad_addr = broad_req.lifr_broadaddr; >+ else >+ continue; >+ } >+ else >+ continue; >+ } >+ >+#elif defined(SIOCGIFBRDADDR) > { > struct ifreq broad_req; > >@@ -713,13 +881,15 @@ > #endif /* SIOCGIFBRDADDR */ > #ifdef DEF_SELF_DEBUG > ErrorF("Xserver: DefineSelf(): ifname = %s, baddr = %s\n", >- ifr->ifr_name, >+ IFR_IFR_NAME, > inet_ntoa(((struct sockaddr_in *) &broad_addr)->sin_addr)); > #endif /* DEF_SELF_DEBUG */ > XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr); > } > #endif /* XDMCP */ > } >+ if (bufptr != buf) >+ free(bufptr); > #else /* HAS_GETIFADDRS */ > if (getifaddrs(&ifap) < 0) { > ErrorF("Warning: getifaddrs returns %s\n", strerror(errno)); >@@ -837,13 +1007,20 @@ > } > #endif > >+/* Default hosts bug fix: This variable is set to TRUE only when AddLocalHosts >+ is being run. This tells NewHost that we are adding the default local >+ host entries and not to flag the entries as being explicitly requested */ >+static int AddingLocalHosts = FALSE; >+ > void > AddLocalHosts (void) > { > HOST *self; > >+ AddingLocalHosts = TRUE; > for (self = selfhosts; self; self = self->next) > (void) NewHost (self->family, self->addr, self->len); >+ AddingLocalHosts = FALSE; > } > > /* Reset access control list to initial hosts */ >@@ -858,15 +1035,17 @@ > FILE *fd; > char *ptr; > int i, hostlen; >+#if ((defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)) && !defined(IPv6)) || defined (DNETCONN) > union { > struct sockaddr sa; > #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN) >- struct sockaddr_in in; >+ struct sockaddr_in in; > #endif /* TCPCONN || STREAMSCONN */ > #ifdef DNETCONN >- struct sockaddr_dn dn; >+ struct sockaddr_dn dn; >+#endif >+ } > #endif >- } saddr; > #ifdef DNETCONN > struct nodeent *np; > struct dn_naddr dnaddr, *dnaddrp, *dnet_addr(); >@@ -878,7 +1057,6 @@ > int family = 0; > pointer addr; > int len; >- register struct hostent *hp; > > AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL; > LocalHostEnabled = FALSE; >@@ -902,6 +1080,7 @@ > { > while (fgets (ohostname, sizeof (ohostname), fd)) > { >+ family = FamilyWild; > if (*ohostname == '#') > continue; > if ((ptr = strchr(ohostname, '\n')) != 0) >@@ -918,6 +1097,7 @@ > { > family = FamilyLocalHost; > NewHost(family, "", 0); >+ LocalHostRequested = TRUE; /* Default host bug fix */ > } > #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN) > else if (!strncmp("inet:", lhostname, 5)) >@@ -925,6 +1105,13 @@ > family = FamilyInternet; > hostname = ohostname + 5; > } >+#ifdef IPv6 >+ else if (!strncmp("inetv6:", lhostname, 7)) >+ { >+ family = FamilyInternetV6; >+ hostname = ohostname + 7; >+ } >+#endif > #endif > #ifdef DNETCONN > else if (!strncmp("dnet:", lhostname, 5)) >@@ -993,9 +1180,31 @@ > #endif /* SECURE_RPC */ > #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN) > { >+#ifdef IPv6 >+ if ( (family == FamilyInternet) || (family == FamilyInternetV6) >+ || (family == FamilyWild) ) >+ { >+ struct addrinfo *addresses; >+ struct addrinfo *a; >+ int f; >+ >+ if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) { >+ for (a = addresses ; a != NULL ; a = a->ai_next) { >+ len = a->ai_addrlen; >+ f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr); >+ if ( (family == f) || >+ ((family == FamilyWild) && (f != -1)) ) { >+ NewHost(f, addr, len); >+ } >+ } >+ freeaddrinfo(addresses); >+ } >+ } >+#else > #ifdef XTHREADS_NEEDS_BYNAMEPARAMS > _Xgethostbynameparams hparams; > #endif >+ register struct hostent *hp; > > /* host name */ > if ((family == FamilyInternet && >@@ -1017,6 +1226,7 @@ > #endif > } > } >+#endif /* IPv6 */ > } > #endif /* TCPCONN || STREAMSCONN */ > family = FamilyWild; >@@ -1158,6 +1368,9 @@ > break; > #endif > case FamilyInternet: >+#ifdef IPv6 >+ case FamilyInternetV6: >+#endif > case FamilyDECnet: > case FamilyChaos: > if ((len = CheckAddr (family, pAddr, length)) < 0) >@@ -1206,6 +1419,14 @@ > if (addrEqual (family, addr, len, host)) > return TRUE; > } >+ if (!AddingLocalHosts) { /* Default host bug fix */ >+ for (host = selfhosts; host; host = host->next) { >+ if (addrEqual (family, addr, len, host)) { >+ host->requested = TRUE; >+ break; >+ } >+ } >+ } > MakeHost(host,len) > if (!host) > return FALSE; >@@ -1247,6 +1468,9 @@ > break; > #endif > case FamilyInternet: >+#ifdef IPv6 >+ case FamilyInternetV6: >+#endif > case FamilyDECnet: > case FamilyChaos: > if ((len = CheckAddr (family, pAddr, length)) < 0) >@@ -1336,6 +1560,14 @@ > else > len = -1; > break; >+#ifdef IPv6 >+ case FamilyInternetV6: >+ if (length == sizeof (struct in6_addr)) >+ len = length; >+ else >+ len = -1; >+ break; >+#endif > #endif > #ifdef DNETCONN > case FamilyDECnet: >@@ -1424,6 +1656,21 @@ > *len = sizeof (struct in_addr); > *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr); > return FamilyInternet; >+#ifdef IPv6 >+ case AF_INET6: >+ { >+ struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr; >+ if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) { >+ *len = sizeof (struct in_addr); >+ *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]); >+ return FamilyInternet; >+ } else { >+ *len = sizeof (struct in6_addr); >+ *addr = (pointer) &(saddr6->sin6_addr); >+ return FamilyInternetV6; >+ } >+ } >+#endif > #endif > #ifdef DNETCONN > case AF_DECnet: >diff -ur 4.3.0/xc/programs/Xserver/os/connection.c 4.3.0+IPv6/xc/programs/Xserver/os/connection.c >--- 4.3.0/xc/programs/Xserver/os/connection.c Fri May 31 11:46:05 2002 >+++ 4.3.0+IPv6/xc/programs/Xserver/os/connection.c Sun Mar 2 13:54:11 2003 >@@ -1,4 +1,5 @@ > /* $Xorg: connection.c,v 1.6 2001/02/09 02:05:23 xorgcvs Exp $ */ >+/* Updated for IPv6 */ > /*********************************************************** > > Copyright 1987, 1989, 1998 The Open Group >@@ -72,6 +73,7 @@ > #include <errno.h> > #include <signal.h> > #include <stdio.h> >+#include <stdlib.h> > > #ifndef WIN32 > #if defined(Lynx) >@@ -123,6 +125,7 @@ > # endif > # endif > # endif >+# include <arpa/inet.h> > #endif > > #ifdef AMTCPCONN >@@ -510,6 +513,16 @@ > inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr), > ntohs(((struct sockaddr_in *) saddr)->sin_port)); > break; >+#ifdef IPv6 >+ case AF_INET6: { >+ char ipaddr[INET6_ADDRSTRLEN]; >+ inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr, >+ ipaddr, sizeof(ipaddr)); >+ sprintf(out, "IP %s port %d", ipaddr, >+ ((struct sockaddr_in6 *) saddr)->sin6_port); >+ } >+ break; >+#endif > #endif > #ifdef DNETCONN > case AF_DECnet: >diff -ur 4.3.0/xc/programs/Xserver/os/utils.c 4.3.0+IPv6/xc/programs/Xserver/os/utils.c >--- 4.3.0/xc/programs/Xserver/os/utils.c Tue Dec 24 09:43:00 2002 >+++ 4.3.0+IPv6/xc/programs/Xserver/os/utils.c Sun Mar 23 13:31:37 2003 >@@ -486,6 +486,10 @@ > > void UseMsg() > { >+#ifdef XDMCP >+ extern void XdmcpUseMsg(void); >+#endif >+ > #if !defined(AIXrt) && !defined(AIX386) > ErrorF("use: X [:<display>] [option]\n"); > ErrorF("-a # mouse acceleration (pixels)\n"); >@@ -1119,35 +1123,57 @@ > { > #define AUTHORIZATION_NAME "hp-hostname-1" > #if defined(TCPCONN) || defined(STREAMSCONN) >- static char result[1024]; >+ static char *result = NULL; > static char *p = NULL; > > if (p == NULL) > { > char hname[1024], *hnameptr; >+ unsigned int len; >+#ifdef IPv6 >+ struct addrinfo hints, *ai = NULL; >+#else > struct hostent *host; >- int len; > #ifdef XTHREADS_NEEDS_BYNAMEPARAMS > _Xgethostbynameparams hparams; > #endif >+#endif > > gethostname(hname, 1024); >+#ifdef IPv6 >+ bzero(&hints, sizeof(hints)); >+ hints.ai_flags = AI_CANONNAME; >+ if (getaddrinfo(hname, NULL, &hints, &ai) == 0) { >+ hnameptr = ai->ai_canonname; >+ } else { >+ hnameptr = hname; >+ } >+#else > host = _XGethostbyname(hname, hparams); > if (host == NULL) > hnameptr = hname; > else > hnameptr = host->h_name; >+#endif >+ >+ len = strlen(hnameptr) + 1; >+ result = xalloc(len + sizeof(AUTHORIZATION_NAME) + 4); > > p = result; > *p++ = sizeof(AUTHORIZATION_NAME) >> 8; > *p++ = sizeof(AUTHORIZATION_NAME) & 0xff; >- *p++ = (len = strlen(hnameptr) + 1) >> 8; >+ *p++ = (len) >> 8; > *p++ = (len & 0xff); > > memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME)); > p += sizeof(AUTHORIZATION_NAME); > memmove(p, hnameptr, len); > p += len; >+#ifdef IPv6 >+ if (hnameptr == ai->ai_canonname) { >+ freeaddrinfo(ai); >+ } >+#endif > } > *authlen = p - result; > *authorizations = result; >diff -ur 4.3.0/xc/programs/Xserver/os/xdmcp.c 4.3.0+IPv6/xc/programs/Xserver/os/xdmcp.c >--- 4.3.0/xc/programs/Xserver/os/xdmcp.c Mon Mar 11 08:22:28 2002 >+++ 4.3.0+IPv6/xc/programs/Xserver/os/xdmcp.c Sun Apr 13 23:26:55 2003 >@@ -1,4 +1,5 @@ > /* $Xorg: xdmcp.c,v 1.4 2001/01/31 13:37:19 pookie Exp $ */ >+/* Updated for IPv6 */ > /* > * Copyright 1989 Network Computing Devices, Inc., Mountain View, California. > * >@@ -43,6 +44,7 @@ > #endif > > #include <stdio.h> >+#include <stdlib.h> > #include "X.h" > #include "Xmd.h" > #include "misc.h" >@@ -74,7 +76,12 @@ > > static int xdmcpSocket, sessionSocket; > static xdmcp_states state; >+#ifdef IPv6 >+static int xdmcpSocket6; >+static struct sockaddr_storage req_sockaddr; >+#else > static struct sockaddr_in req_sockaddr; >+#endif > static int req_socklen; > static CARD32 SessionID; > static CARD32 timeOutTime; >@@ -89,18 +96,58 @@ > > static XdmcpBuffer buffer; > >-static struct sockaddr_in ManagerAddress; >-static struct sockaddr_in FromAddress; >+#ifdef IPv6 >+ >+static struct addrinfo *mgrAddr; >+static struct addrinfo *mgrAddrFirst; >+ >+#define SOCKADDR_TYPE struct sockaddr_storage >+#define SOCKLEN_TYPE socklen_t >+#define SOCKADDR_FAMILY ss_family >+ >+#ifdef BSD44SOCKETS >+#define SOCKLEN_FIELD ss_len >+#endif >+ >+#else >+ >+#define SOCKADDR_TYPE struct sockaddr_in >+#define SOCKLEN_TYPE size_t >+#define SOCKADDR_FAMILY sin_family >+ >+#ifdef BSD44SOCKETS >+#define SOCKLEN_FIELD sin_len >+#endif >+ >+#endif >+ >+static SOCKADDR_TYPE ManagerAddress; >+static SOCKADDR_TYPE FromAddress; >+ >+#ifdef SOCKLEN_FIELD >+#define ManagerAddressLen ManagerAddress.SOCKLEN_FIELD >+#define FromAddressLen FromAddress.SOCKLEN_FIELD >+#else >+static SOCKLEN_TYPE ManagerAddressLen, FromAddressLen; >+#endif >+ >+#ifdef IPv6 >+static struct multicastinfo { >+ struct multicastinfo *next; >+ struct addrinfo *ai; >+ int hops; >+} *mcastlist; >+#endif > > static void XdmcpAddHost( >- struct sockaddr_in *from, >+ struct sockaddr *from, > int fromlen, > ARRAY8Ptr AuthenticationName, > ARRAY8Ptr hostname, > ARRAY8Ptr status); > > static void XdmcpSelectHost( >- struct sockaddr_in *host_sockaddr, >+ struct sockaddr *host_sockaddr, > int host_len, > ARRAY8Ptr AuthenticationName); > >@@ -118,7 +165,7 @@ > > static void recv_willing_msg( > #if NeedFunctionPrototypes >- struct sockaddr_in */*from*/, >+ struct sockaddr */*from*/, > int /*fromlen*/, > unsigned /*length*/ > #endif >@@ -195,9 +242,19 @@ > > static void get_fromaddr_by_name(int /*argc*/, char **/*argv*/, int /*i*/); > >+#ifdef IPv6 >+static int get_mcast_options( >+#if NeedFunctionPrototypes >+ int /*argc*/, >+ char **/*argv*/, >+ int /*i*/ >+#endif >+); >+#endif >+ > static void receive_packet( > #if NeedFunctionPrototypes >- void >+ int socketfd > #endif > ); > >@@ -249,7 +306,7 @@ > ); > > >-static short xdm_udp_port = XDM_UDP_PORT; >+static unsigned short xdm_udp_port = XDM_UDP_PORT; > static Bool OneSession = FALSE; > static const char *xdm_from = NULL; > >@@ -258,6 +315,9 @@ > { > ErrorF("-query host-name contact named host for XDMCP\n"); > ErrorF("-broadcast broadcast for XDMCP\n"); >+#ifdef IPv6 >+ ErrorF("-multicast [addr [hops]] IPv6 multicast for XDMCP\n"); >+#endif > ErrorF("-indirect host-name contact named host for indirect XDMCP\n"); > ErrorF("-port port-num UDP port number to send messages to\n"); > ErrorF("-from local-address specify the local address to connect from\n"); >@@ -273,7 +333,7 @@ > XdmcpOptions(int argc, char **argv, int i) > { > if (strcmp(argv[i], "-query") == 0) { >- get_manager_by_name(argc, argv, ++i); >+ get_manager_by_name(argc, argv, i++); > XDM_INIT_STATE = XDM_QUERY; > AccessUsingXdmcp (); > return (i + 1); >@@ -283,8 +343,16 @@ > AccessUsingXdmcp (); > return (i + 1); > } >+#ifdef IPv6 >+ if (strcmp(argv[i], "-multicast") == 0) { >+ i = get_mcast_options(argc, argv, ++i); >+ XDM_INIT_STATE = XDM_MULTICAST; >+ AccessUsingXdmcp (); >+ return (i + 1); >+ } >+#endif > if (strcmp(argv[i], "-indirect") == 0) { >- get_manager_by_name(argc, argv, ++i); >+ get_manager_by_name(argc, argv, i++); > XDM_INIT_STATE = XDM_INDIRECT; > AccessUsingXdmcp (); > return (i + 1); >@@ -294,7 +362,7 @@ > ErrorF("Xserver: missing port number in command line\n"); > exit(1); > } >- xdm_udp_port = atoi(argv[i]); >+ xdm_udp_port = (unsigned short) atoi(argv[i]); > return (i + 1); > } > if (strcmp(argv[i], "-from") == 0) { >@@ -348,6 +416,7 @@ > > #define MAX_BROADCAST 10 > >+/* This stays sockaddr_in since IPv6 doesn't support broadcast */ > static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST]; > static int NumBroadcastAddresses; > >@@ -478,10 +547,36 @@ > XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses); > xdmcpGeneration = serverGeneration; > } >- if (addrlen == sizeof(struct in_addr) && xdm_from != NULL) >- { >- /* Only register the requested address */ >- if (memcmp(address, &FromAddress.sin_addr, addrlen) != 0) { >+ if (xdm_from != NULL) { /* Only register the requested address */ >+ const void *regAddr = address; >+ const void *fromAddr = NULL; >+ int regAddrlen = addrlen; >+ >+ if (addrlen == sizeof(struct in_addr)) { >+ if (FromAddress.SOCKADDR_FAMILY == AF_INET) { >+ fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr; >+ } >+#ifdef IPv6 >+ else if ((FromAddress.SOCKADDR_FAMILY == AF_INET6) && >+ IN6_IS_ADDR_V4MAPPED( >+ &((struct sockaddr_in6 *)&FromAddress)->sin6_addr)) { >+ fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr.s6_addr[12]; >+ } >+#endif >+ } >+#ifdef IPv6 >+ else if (addrlen == sizeof(struct in6_addr)) { >+ if (FromAddress.SOCKADDR_FAMILY == AF_INET6) { >+ fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr; >+ } else if ((FromAddress.SOCKADDR_FAMILY == AF_INET) && >+ IN6_IS_ADDR_V4MAPPED((struct in6_addr *) address)) { >+ fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr; >+ regAddr = &((struct sockaddr_in6 *)&address)->sin6_addr.s6_addr[12]; >+ regAddrlen = sizeof(struct in_addr); >+ } >+ } >+#endif >+ if (fromAddr && memcmp(regAddr, fromAddr, regAddrlen) != 0) { > return; > } > } >@@ -665,6 +760,9 @@ > if (state == XDM_OFF) > return; > FD_SET(xdmcpSocket, LastSelectMask); >+#ifdef IPv6 >+ FD_SET(xdmcpSocket6, LastSelectMask); >+#endif > if (timeOutTime == 0) > return; > millisToGo = timeOutTime - GetTimeInMillis(); >@@ -695,9 +793,16 @@ > { > if (FD_ISSET(xdmcpSocket, LastSelectMask)) > { >- receive_packet(); >+ receive_packet(xdmcpSocket); > FD_CLR(xdmcpSocket, LastSelectMask); > } >+#ifdef IPv6 >+ if (FD_ISSET(xdmcpSocket6, LastSelectMask)) >+ { >+ receive_packet(xdmcpSocket6); >+ FD_CLR(xdmcpSocket6, LastSelectMask); >+ } >+#endif > XFD_ANDSET(&devicesReadable, LastSelectMask, &EnabledDevices); > if (XFD_ANYSET(&devicesReadable)) > { >@@ -728,10 +833,18 @@ > > static void > XdmcpSelectHost( >- struct sockaddr_in *host_sockaddr, >+ struct sockaddr *host_sockaddr, > int host_len, > ARRAY8Ptr AuthenticationName) > { >+#ifdef IPv6 >+ /* Don't need list of addresses for host anymore */ >+ if (mgrAddrFirst != NULL) { >+ freeaddrinfo(mgrAddrFirst); >+ mgrAddrFirst = NULL; >+ mgrAddr = NULL; >+ } >+#endif > state = XDM_START_CONNECTION; > memmove(&req_sockaddr, host_sockaddr, host_len); > req_socklen = host_len; >@@ -748,7 +861,7 @@ > /*ARGSUSED*/ > static void > XdmcpAddHost( >- struct sockaddr_in *from, >+ struct sockaddr *from, > int fromlen, > ARRAY8Ptr AuthenticationName, > ARRAY8Ptr hostname, >@@ -765,14 +878,18 @@ > ARRAY8 UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" }; > > static void >-receive_packet(void) >+receive_packet(int socketfd) > { >+#ifdef IPv6 >+ struct sockaddr_storage from; >+#else > struct sockaddr_in from; >- int fromlen = sizeof(struct sockaddr_in); >+#endif >+ int fromlen = sizeof(from); > XdmcpHeader header; > > /* read message off socket */ >- if (!XdmcpFill (xdmcpSocket, &buffer, (XdmcpNetaddr) &from, &fromlen)) >+ if (!XdmcpFill (socketfd, &buffer, (XdmcpNetaddr) &from, &fromlen)) > return; > > /* reset retransmission backoff */ >@@ -786,7 +903,7 @@ > > switch (header.opcode) { > case WILLING: >- recv_willing_msg(&from, fromlen, header.length); >+ recv_willing_msg((struct sockaddr *) &from, fromlen, header.length); > break; > case UNWILLING: > XdmcpFatal("Manager unwilling", &UnwillingMessage); >@@ -821,6 +938,9 @@ > case XDM_QUERY: > case XDM_BROADCAST: > case XDM_INDIRECT: >+#ifdef IPv6 >+ case XDM_MULTICAST: >+#endif > send_query_msg(); > break; > case XDM_START_CONNECTION: >@@ -873,13 +993,34 @@ > } > else if (timeOutRtx >= XDM_RTX_LIMIT) > { >- ErrorF("XDM: too many retransmissions\n"); >- state = XDM_AWAIT_USER_INPUT; >- timeOutTime = 0; >- timeOutRtx = 0; >+ /* Quit if "-once" specified, otherwise reset and try again. */ >+ if (OneSession) { >+ dispatchException |= DE_TERMINATE; >+ ErrorF("XDM: too many retransmissions\n"); >+ } else { >+ XdmcpDeadSession("too many retransmissions"); >+ } > return; > } > >+#ifdef IPv6 >+ if (state == XDM_COLLECT_QUERY || state == XDM_COLLECT_INDIRECT_QUERY) { >+ /* Try next address */ >+ for (mgrAddr = mgrAddr->ai_next; ; mgrAddr = mgrAddr->ai_next) { >+ if (mgrAddr == NULL) { >+ mgrAddr = mgrAddrFirst; >+ } >+ if (mgrAddr->ai_family == AF_INET >+ || mgrAddr->ai_family == AF_INET6) >+ break; >+ } >+#ifndef SIN6_LEN >+ ManagerAddressLen = mgrAddr->ai_addrlen; >+#endif >+ memcpy(&ManagerAddress, mgrAddr->ai_addr, mgrAddr->ai_addrlen); >+ } >+#endif >+ > switch (state) { > case XDM_COLLECT_QUERY: > state = XDM_QUERY; >@@ -887,6 +1028,11 @@ > case XDM_COLLECT_BROADCAST_QUERY: > state = XDM_BROADCAST; > break; >+#ifdef IPv6 >+ case XDM_COLLECT_MULTICAST_QUERY: >+ state = XDM_MULTICAST; >+ break; >+#endif > case XDM_COLLECT_INDIRECT_QUERY: > state = XDM_INDIRECT; > break; >@@ -988,6 +1134,10 @@ > #else > int soopts = 1; > >+#ifdef IPv6 >+ if ((xdmcpSocket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) >+ XdmcpWarning("INET6 UDP socket creation failed"); >+#endif > if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) > XdmcpWarning("UDP socket creation failed"); > #ifdef SO_BROADCAST >@@ -996,8 +1146,8 @@ > XdmcpWarning("UDP set broadcast socket-option failed"); > #endif /* SO_BROADCAST */ > if (xdmcpSocket >= 0 && xdm_from != NULL) { >- if (bind(xdmcpSocket, (struct sockaddr *)&FromAddress, >- sizeof(FromAddress)) < 0) { >+ if (bind(xdmcpSocket, (struct sockaddr *)&FromAddress, >+ FromAddressLen) < 0) { > ErrorF("Xserver: failed to bind to -from address: %s\n", xdm_from); > exit(1); > } >@@ -1010,7 +1160,11 @@ > { > XdmcpHeader header; > Bool broadcast = FALSE; >+#ifdef IPv6 >+ Bool multicast = FALSE; >+#endif > int i; >+ int socketfd = xdmcpSocket; > > header.version = XDM_PROTOCOL_VERSION; > switch(state){ >@@ -1023,6 +1177,13 @@ > state = XDM_COLLECT_BROADCAST_QUERY; > broadcast = TRUE; > break; >+#ifdef IPv6 >+ case XDM_MULTICAST: >+ header.opcode = (CARD16) BROADCAST_QUERY; >+ state = XDM_COLLECT_MULTICAST_QUERY; >+ multicast = TRUE; >+ break; >+#endif > case XDM_INDIRECT: > header.opcode = (CARD16) INDIRECT_QUERY; > state = XDM_COLLECT_INDIRECT_QUERY; >@@ -1044,16 +1205,48 @@ > XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &BroadcastAddresses[i], > sizeof (struct sockaddr_in)); > } >+#ifdef IPv6 >+ else if (multicast) >+ { >+ struct multicastinfo *mcl; >+ struct addrinfo *ai; >+ >+ for (mcl = mcastlist; mcl != NULL; mcl = mcl->next) { >+ for (ai = mcl->ai ; ai != NULL; ai = ai->ai_next) { >+ if (ai->ai_family == AF_INET) { >+ unsigned char hopflag = (unsigned char) mcl->hops; >+ socketfd = xdmcpSocket; >+ setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL, >+ &hopflag, sizeof(hopflag)); >+ } else if (ai->ai_family == AF_INET6) { >+ int hopflag6 = mcl->hops; >+ socketfd = xdmcpSocket6; >+ setsockopt(socketfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, >+ &hopflag6, sizeof(hopflag6)); >+ } else { >+ continue; >+ } >+ XdmcpFlush (socketfd, &buffer, >+ (XdmcpNetaddr) ai->ai_addr, ai->ai_addrlen); >+ break; >+ } >+ } >+ } >+#endif > else > { >- XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &ManagerAddress, >+#ifdef IPv6 >+ if (ManagerAddress.ss_family == AF_INET6) >+ socketfd = xdmcpSocket6; >+#endif >+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &ManagerAddress, > sizeof (ManagerAddress)); > } > } > > static void > recv_willing_msg( >- struct sockaddr_in *from, >+ struct sockaddr *from, > int fromlen, > unsigned length) > { >@@ -1077,6 +1270,9 @@ > XdmcpSelectHost(from, fromlen, &authenticationName); > break; > case XDM_COLLECT_BROADCAST_QUERY: >+#ifdef IPv6 >+ case XDM_COLLECT_MULTICAST_QUERY: >+#endif > case XDM_COLLECT_INDIRECT_QUERY: > XdmcpAddHost(from, fromlen, &authenticationName, &hostname, &status); > break; >@@ -1097,6 +1293,7 @@ > int length; > int i; > ARRAY8 authenticationData; >+ int socketfd = xdmcpSocket; > > header.version = XDM_PROTOCOL_VERSION; > header.opcode = (CARD16) REQUEST; >@@ -1136,7 +1333,12 @@ > XdmcpDisposeARRAY8 (&authenticationData); > XdmcpWriteARRAYofARRAY8 (&buffer, &AuthorizationNames); > XdmcpWriteARRAY8 (&buffer, &ManufacturerDisplayID); >- if (XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen)) >+#ifdef IPv6 >+ if (req_sockaddr.ss_family == AF_INET6) >+ socketfd = xdmcpSocket6; >+#endif >+ if (XdmcpFlush (socketfd, &buffer, >+ (XdmcpNetaddr) &req_sockaddr, req_socklen)) > state = XDM_AWAIT_REQUEST_RESPONSE; > } > >@@ -1220,6 +1422,7 @@ > send_manage_msg(void) > { > XdmcpHeader header; >+ int socketfd = xdmcpSocket; > > header.version = XDM_PROTOCOL_VERSION; > header.opcode = (CARD16) MANAGE; >@@ -1231,7 +1434,11 @@ > XdmcpWriteCARD16 (&buffer, DisplayNumber); > XdmcpWriteARRAY8 (&buffer, &DisplayClass); > state = XDM_AWAIT_MANAGE_RESPONSE; >- XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen); >+#ifdef IPv6 >+ if (req_sockaddr.ss_family == AF_INET6) >+ socketfd = xdmcpSocket6; >+#endif >+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen); > } > > static void >@@ -1278,6 +1485,7 @@ > send_keepalive_msg(void) > { > XdmcpHeader header; >+ int socketfd = xdmcpSocket; > > header.version = XDM_PROTOCOL_VERSION; > header.opcode = (CARD16) KEEPALIVE; >@@ -1288,7 +1496,11 @@ > XdmcpWriteCARD32 (&buffer, SessionID); > > state = XDM_AWAIT_ALIVE_RESPONSE; >- XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen); >+#ifdef IPv6 >+ if (req_sockaddr.ss_family == AF_INET6) >+ socketfd = xdmcpSocket6; >+#endif >+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen); > } > > static void >@@ -1340,80 +1552,206 @@ > } > > static void >-get_manager_by_name( >- int argc, >- char **argv, >- int i) >-{ >+get_addr_by_name( >+ char * argtype, >+ char * namestr, >+ int port, >+ int socktype, >+ SOCKADDR_TYPE *addr, >+ SOCKLEN_TYPE *addrlen >+#ifdef IPv6 >+ , >+ struct addrinfo **aip, >+ struct addrinfo **aifirstp >+#endif >+ ) >+{ >+#ifdef IPv6 >+ struct addrinfo *ai; >+ struct addrinfo hints; >+ char portstr[6]; >+ char *pport = portstr; >+ int gaierr; >+ >+ bzero(&hints, sizeof(hints)); >+ hints.ai_socktype = socktype; >+ >+ if (port == 0) { >+ pport = NULL; >+ } else if (port > 0 && port < 65535) { >+ sprintf(portstr, "%d", port); >+ } else { >+ ErrorF("Xserver: port out of range: %d\n", port); >+ exit(1); >+ } >+ >+ if (*aifirstp != NULL) { >+ freeaddrinfo(*aifirstp); >+ *aifirstp = NULL; >+ } >+ >+ if ((gaierr = getaddrinfo(namestr, pport, &hints, aifirstp)) == 0) { >+ for (ai = *aifirstp; ai != NULL; ai = ai->ai_next) { >+ if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6) >+ break; >+ } >+ if ((ai == NULL) || (ai->ai_addrlen > sizeof(SOCKADDR_TYPE))) { >+ ErrorF ("Xserver: %s host %s not on supported network type\n", >+ argtype, namestr); >+ exit (1); >+ } else { >+ *aip = ai; >+ *addrlen = ai->ai_addrlen; >+ memcpy(addr, ai->ai_addr, ai->ai_addrlen); >+ } >+ } else { >+ ErrorF("Xserver: %s: %s %s\n", gai_strerror(gaierr), argtype, namestr); >+ exit(1); >+ } >+#else > struct hostent *hep; > #ifdef XTHREADS_NEEDS_BYNAMEPARAMS > _Xgethostbynameparams hparams; > #endif > >- if (i == argc) >+ if (!(hep = _XGethostbyname(namestr, hparams))) > { >- ErrorF("Xserver: missing host name in command line\n"); >- exit(1); >- } >- if (!(hep = _XGethostbyname(argv[i], hparams))) >- { >- ErrorF("Xserver: unknown host: %s\n", argv[i]); >+ ErrorF("Xserver: %s unknown host: %s\n", argtype, namestr); > exit(1); > } > if (hep->h_length == sizeof (struct in_addr)) > { >- memmove(&ManagerAddress.sin_addr, hep->h_addr, hep->h_length); >-#ifdef BSD44SOCKETS >- ManagerAddress.sin_len = sizeof(ManagerAddress); >-#endif >- ManagerAddress.sin_family = AF_INET; >- ManagerAddress.sin_port = htons (xdm_udp_port); >+ memmove(&addr->sin_addr, hep->h_addr, hep->h_length); >+ *addrlen = sizeof(struct sockaddr_in); >+ addr->sin_family = AF_INET; >+ addr->sin_port = htons (xdm_udp_port); > } > else > { >- ErrorF ("Xserver: host on strange network %s\n", argv[i]); >+ ErrorF ("Xserver: %s host on strange network %s\n", argtype, namestr); > exit (1); > } >+#endif > } > > static void >-get_fromaddr_by_name( >+get_manager_by_name( > int argc, > char **argv, > int i) > { >- struct hostent *hep; >-#ifdef XTHREADS_NEEDS_BYNAMEPARAMS >- _Xgethostbynameparams hparams; >-#endif > >- if (i == argc) >+ if ((i + 1) == argc) > { >- ErrorF("Xserver: missing -from host name in command line\n"); >+ ErrorF("Xserver: missing %s host name in command line\n", argv[i]); > exit(1); > } >- if (!(hep = _XGethostbyname(argv[i], hparams))) >+ >+ get_addr_by_name(argv[i], argv[i+1], xdm_udp_port, SOCK_DGRAM, >+ &ManagerAddress, &ManagerAddressLen >+#ifdef IPv6 >+ , &mgrAddr, &mgrAddrFirst >+#endif >+ ); >+} >+ >+ >+static void >+get_fromaddr_by_name( >+ int argc, >+ char **argv, >+ int i) >+{ >+#ifdef IPv6 >+ struct addrinfo *ai = NULL; >+ struct addrinfo *aifirst = NULL; >+#endif >+ if (i == argc) > { >- ErrorF("Xserver: unknown host: %s\n", argv[i]); >+ ErrorF("Xserver: missing -from host name in command line\n"); > exit(1); > } >- if (hep->h_length == sizeof (struct in_addr)) >- { >- memset(&FromAddress, 0, sizeof(FromAddress)); >- memmove(&FromAddress.sin_addr, hep->h_addr, hep->h_length); >-#ifdef BSD44SOCKETS >- FromAddress.sin_len = sizeof(FromAddress); >+ get_addr_by_name("-from", argv[i], 0, 0, &FromAddress, &FromAddressLen >+#ifdef IPv6 >+ , &ai, &aifirst > #endif >- FromAddress.sin_family = AF_INET; >- FromAddress.sin_port = 0; >+ ); >+ xdm_from = argv[i]; >+} >+ >+ >+#ifdef IPv6 >+static int >+get_mcast_options(argc, argv, i) >+ int argc, i; >+ char **argv; >+{ >+ char *address = "ff02::1"; /* Default address until IANA assigns one */ >+ int hopcount = 1; >+ struct addrinfo hints; >+ char portstr[6]; >+ int gaierr; >+ struct addrinfo *ai, *firstai; >+ >+ if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) { >+ address = argv[i++]; >+ if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) { >+ hopcount = strtol(argv[i++], NULL, 10); >+ if ((hopcount < 1) || (hopcount > 255)) { >+ ErrorF("Xserver: multicast hop count out of range: %d\n", >+ hopcount); >+ exit(1); >+ } >+ } > } >- else >- { >- ErrorF ("Xserver: -from host on strange network %s\n", argv[i]); >- exit (1); >+ >+ if (xdm_udp_port > 0 && xdm_udp_port < 65535) { >+ sprintf(portstr, "%d", xdm_udp_port); >+ } else { >+ ErrorF("Xserver: port out of range: %d\n", xdm_udp_port); >+ exit(1); > } >- xdm_from = argv[i]; >+ bzero(&hints, sizeof(hints)); >+ hints.ai_socktype = SOCK_DGRAM; >+ >+ if ((gaierr = getaddrinfo(address, portstr, &hints, &firstai)) == 0) { >+ for (ai = firstai; ai != NULL; ai = ai->ai_next) { >+ if (((ai->ai_family == AF_INET) && >+ IN_MULTICAST(((struct sockaddr_in *) ai->ai_addr) >+ ->sin_addr.s_addr)) >+ || ((ai->ai_family == AF_INET6) && >+ IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *) ai->ai_addr) >+ ->sin6_addr))) >+ break; >+ } >+ if (ai == NULL) { >+ ErrorF ("Xserver: address not supported multicast type %s\n", >+ address); >+ exit (1); >+ } else { >+ struct multicastinfo *mcastinfo, *mcl; >+ >+ mcastinfo = malloc(sizeof(struct multicastinfo)); >+ mcastinfo->next = NULL; >+ mcastinfo->ai = firstai; >+ mcastinfo->hops = hopcount; >+ >+ if (mcastlist == NULL) { >+ mcastlist = mcastinfo; >+ } else { >+ for (mcl = mcastlist; mcl->next != NULL; mcl = mcl->next) { >+ /* Do nothing - just find end of list */ >+ } >+ mcl->next = mcastinfo; >+ } >+ } >+ } else { >+ ErrorF("Xserver: %s: %s\n", gai_strerror(gaierr), address); >+ exit(1); >+ } >+ return i; > } >+#endif > > #else > static int xdmcp_non_empty; /* avoid complaint by ranlib */ >diff -ur 4.3.0/xc/programs/fslsfonts/fslsfonts.c 4.3.0+IPv6/xc/programs/fslsfonts/fslsfonts.c >--- 4.3.0/xc/programs/fslsfonts/fslsfonts.c Fri Dec 14 12:00:45 2001 >+++ 4.3.0+IPv6/xc/programs/fslsfonts/fslsfonts.c Sat Mar 1 23:34:42 2003 >@@ -1,4 +1,4 @@ >-/* $Xorg: fslsfonts.c,v 1.4 2001/02/09 02:05:30 xorgcvs Exp $ */ >+/* $Id$ */ > /* > > Copyright 1990, 1998 The Open Group >diff -ur 4.3.0/xc/programs/fstobdf/fstobdf.c 4.3.0+IPv6/xc/programs/fstobdf/fstobdf.c >--- 4.3.0/xc/programs/fstobdf/fstobdf.c Fri Dec 14 12:00:46 2001 >+++ 4.3.0+IPv6/xc/programs/fstobdf/fstobdf.c Sat Mar 1 23:34:42 2003 >@@ -1,4 +1,4 @@ >-/* $Xorg: fstobdf.c,v 1.4 2001/02/09 02:05:30 xorgcvs Exp $ */ >+/* $Id$ */ > /* > > Copyright 1990, 1998 The Open Group >@@ -104,8 +104,13 @@ > > fontServer = FSOpenServer(serverName); > if (!fontServer) { >- fprintf(stderr, "can't open font server \"%s\"\n", >- FSServerName(serverName)); >+ char *sn = FSServerName(serverName); >+ if (sn) >+ fprintf(stderr, "%s: can't open font server \"%s\"\n", >+ argv[0], sn); >+ else >+ fprintf(stderr, "%s: No font server specified.\n", >+ argv[0]); > exit(0); > } > bitmapFormat = 0; >diff -ur 4.3.0/xc/programs/lbxproxy/di/Imakefile 4.3.0+IPv6/xc/programs/lbxproxy/di/Imakefile >--- 4.3.0/xc/programs/lbxproxy/di/Imakefile Mon Apr 23 09:17:12 2001 >+++ 4.3.0+IPv6/xc/programs/lbxproxy/di/Imakefile Sat Mar 1 23:34:42 2003 >@@ -39,7 +39,12 @@ > LintLibraryTarget(dilbx,$(SRCS)) > NormalLintTarget($(SRCS)) > >+#ifdef IPv6Flags >+ IPv6_FLAGS = IPv6Flags >+#endif >+ > SpecialCObjectRule(dispatch,$(ICONFIGFILES),$(EXT_DEFINES)) > SpecialCObjectRule(utils,$(ICONFIGFILES),$(UTIL_DEFINES)) >+SpecialCObjectRule(pm,$(ICONFIGFILES),$(IPv6_FLAGS)) > > DependTarget() >diff -ur 4.3.0/xc/programs/lbxproxy/di/pm.c 4.3.0+IPv6/xc/programs/lbxproxy/di/pm.c >--- 4.3.0/xc/programs/lbxproxy/di/pm.c Mon Sep 16 11:06:20 2002 >+++ 4.3.0+IPv6/xc/programs/lbxproxy/di/pm.c Sat Mar 1 23:34:42 2003 >@@ -1,5 +1,5 @@ > /* $Xorg: pm.c,v 1.5 2001/02/09 02:05:31 xorgcvs Exp $ */ >- >+/* Updated for IPv6 */ > /* > Copyright 1996, 1998 The Open Group > >@@ -374,22 +374,54 @@ > * If gethostbyname fails, try to connect anyhow because > * the display name could be something like :0, local:0 > * or unix:0. >+ * >+ * Search for last colon to allow IPv6 numeric addresses. > */ >- colon = strchr (serverAddress, ':'); >+ colon = strrchr (serverAddress, ':'); > if (colon) > { >+#ifdef IPv6 >+ struct addrinfo *ai, hints; >+ int res; >+#else > struct hostent *hostent; >+#endif >+ char *canonhost = NULL; >+ char *hoststart = strchr(serverAddress, '/'); >+ >+ if (hoststart == NULL) >+ hoststart = serverAddress; >+ >+ /* DECnet :: addresses */ >+ if (*(colon - 1) == ':') { >+ colon--; >+ } > > *colon = '\0'; >- hostent = gethostbyname (serverAddress); >+#ifdef IPv6 >+ hints.ai_flags = AI_CANONNAME; >+ if (getaddrinfo(hoststart, NULL, &hints, &ai) == 0) >+ canonhost = ai->ai_canonname; >+ else >+ ai = NULL; >+#else >+ hostent = gethostbyname (hoststart); >+ if (hostent && hostent->h_name) >+ canonhost = hostent->h_name; >+#endif > *colon = ':'; > >- if (hostent && hostent->h_name) { >- tmpAddress = (char *) malloc (strlen (hostent->h_name) + >+ >+ if (canonhost) { >+ tmpAddress = (char *) malloc (strlen (canonhost) + > strlen (colon) + 1); >- (void) sprintf (tmpAddress, "%s%s", hostent->h_name, colon); >+ (void) sprintf (tmpAddress, "%s%s", canonhost, colon); > serverAddress = tmpAddress; > } >+#ifdef IPv6 >+ if (ai != NULL) >+ freeaddrinfo(ai); >+#endif > } > display_name = serverAddress; > >diff -ur 4.3.0/xc/programs/proxymngr/Imakefile 4.3.0+IPv6/xc/programs/proxymngr/Imakefile >--- 4.3.0/xc/programs/proxymngr/Imakefile Fri May 31 11:46:08 2002 >+++ 4.3.0+IPv6/xc/programs/proxymngr/Imakefile Sat Mar 1 23:34:42 2003 >@@ -10,10 +10,14 @@ > DEPLIBS = $(DEPXTOOLLIB) $(DEPXLIB) > LOCAL_LIBRARIES = $(XTOOLLIB) $(XLIB) > >+#ifdef IPv6Flags >+ IPv6_FLAGS = IPv6Flags >+#endif >+ > HEADERS = PM.h PMproto.h > > SRCS1 = main.c pmdb.c config.c >- >+ > OBJS1 = main.o pmdb.o config.o > > PROGRAMS = ProgramTargetName(proxymngr) >@@ -32,6 +36,6 @@ > InstallMultipleFlags($(HEADERS),$(INCDIR)/X11/PM,$(INSTINCFLAGS)) > > ComplexProgramTarget_1(proxymngr,$(LOCAL_LIBRARIES),NullParameter) >-SpecialCObjectRule(main,$(_NOOP_),'-DCONFIG_FILE="'$(PROXYMANAGERDIR)'/pmconfig"') >+SpecialCObjectRule(main,$(_NOOP_),'-DCONFIG_FILE="'$(PROXYMANAGERDIR)'/pmconfig"' $(IPv6_FLAGS)) > > InstallNonExecFile(pmconfig,$(PROXYMANAGERDIR)) >diff -ur 4.3.0/xc/programs/proxymngr/main.c 4.3.0+IPv6/xc/programs/proxymngr/main.c >--- 4.3.0/xc/programs/proxymngr/main.c Wed Dec 19 13:37:35 2001 >+++ 4.3.0+IPv6/xc/programs/proxymngr/main.c Sat Mar 1 23:34:42 2003 >@@ -483,17 +483,21 @@ > * different host than the client or the client host, > * proxy host and the server host may all be different, > * thus a serverAddress of :0 or :0.0 is not useful. >- * Therefore, change serverAddrees to use the client's >+ * Therefore, change serverAddress to use the client's > * hostname. > */ > char *tmpName; > >- tmpName = strchr (serverAddress, ':'); >+ tmpName = strrchr (serverAddress, ':'); > >- if (tmpName && ((serverAddress[0] == ':') || >+ if (tmpName && ((tmpName == serverAddress) || > (!strncmp (serverAddress, "unix:", 5)))) > { >+#ifdef IPv6 >+ struct sockaddr_storage serverSock; >+#else > struct sockaddr_in serverSock; >+#endif > int retVal; > int addrLen = sizeof(serverSock); > >@@ -502,20 +506,42 @@ > (void *) &addrLen); > if (!retVal) > { >+ char *canonname = NULL; >+#ifdef IPv6 >+ char hostname[NI_MAXHOST]; >+ struct addrinfo *ai = NULL, hints; >+ >+ if (getnameinfo((struct sockaddr *) &serverSock, >+ addrLen, hostname, sizeof(hostname), NULL, 0, 0) == 0) { >+ hints.ai_flags = AI_CANONNAME; >+ if (getaddrinfo(hostname, NULL, &hints, &ai) == 0) { >+ canonname = ai->ai_canonname; >+ } else { >+ ai = NULL; >+ } >+ } >+#else > struct hostent *hostent; > > hostent = gethostbyname (inet_ntoa(serverSock.sin_addr)); > > if (hostent && hostent->h_name) >+ canonname = hostent->h_name; >+#endif >+ if (canonname) > { > int len; > char * pch = strdup (tmpName); > >- len = strlen(hostent->h_name) + strlen(tmpName) + 1; >+ len = strlen(canonname) + strlen(tmpName) + 1; > serverAddress = (char *) realloc (serverAddress, len); >- sprintf (serverAddress, "%s%s", hostent->h_name, pch); >+ sprintf (serverAddress, "%s%s", canonname, pch); > free (pch); > } >+#ifdef IPv6 >+ if (ai != NULL) >+ freeaddrinfo(ai); >+#endif > } > } > } >diff -ur 4.3.0/xc/programs/xauth/Imakefile 4.3.0+IPv6/xc/programs/xauth/Imakefile >--- 4.3.0/xc/programs/xauth/Imakefile Thu Mar 29 18:15:23 2001 >+++ 4.3.0+IPv6/xc/programs/xauth/Imakefile Thu Apr 10 10:08:04 2003 >@@ -14,5 +14,5 @@ > ComplexProgramTarget(xauth) > > SpecialCObjectRule(gethost,$(ICONFIGFILES),$(CONN_DEFINES) $(SIGNAL_DEFINES)) >-SpecialCObjectRule(process,$(ICONFIGFILES),$(SIGNAL_DEFINES)) >+SpecialCObjectRule(process,$(ICONFIGFILES),$(CONN_DEFINES) $(SIGNAL_DEFINES)) > SpecialCObjectRule(parsedpy,$(ICONFIGFILES),$(CONN_DEFINES)) >diff -ur 4.3.0/xc/programs/xauth/gethost.c 4.3.0+IPv6/xc/programs/xauth/gethost.c >--- 4.3.0/xc/programs/xauth/gethost.c Fri Dec 14 12:01:14 2001 >+++ 4.3.0+IPv6/xc/programs/xauth/gethost.c Sat Apr 12 15:16:46 2003 >@@ -1,6 +1,6 @@ > /* > * $Xorg: gethost.c,v 1.5 2001/02/09 02:05:38 xorgcvs Exp $ >- * >+ * Updated for IPv6 > * > Copyright 1989, 1998 The Open Group > >@@ -59,9 +59,9 @@ > #include <arpa/inet.h> > #ifdef SYSV > #ifdef i386 >-#ifndef sco >+#if !defined(sco) && !defined(sun) > #include <net/errno.h> >-#endif /* !sco */ >+#endif /* !sco && !sun */ > #endif /* i386 */ > #endif /* SYSV */ > #endif /* !STREAMSCONN */ >@@ -74,8 +74,12 @@ > #include <netdnet/dnetdb.h> > #endif > >+#ifndef WIN32 >+#include <arpa/inet.h> >+#endif >+ > #ifdef SIGALRM >-Bool nameserver_timedout = False; >+volatile Bool nameserver_timedout = False; > > > /* >@@ -107,6 +111,10 @@ > Xauth *auth; > { > static struct hostent *hp = NULL; >+ int af; >+#ifdef IPv6 >+ static char addr[INET6_ADDRSTRLEN]; >+#endif /* IPv6 */ > #ifdef DNETCONN > struct nodeent *np; > static char nodeaddr[4 + 2 * DN_MAXADDL]; >@@ -115,7 +123,18 @@ > if (auth->address_length == 0) > return "Illegal Address"; > #ifdef TCPCONN >- if (auth->family == FamilyInternet) { >+ if (auth->family == FamilyInternet >+#ifdef IPv6 >+ || auth->family == FamilyInternetV6 >+#endif >+ ) >+ { >+#ifdef IPv6 >+ if (auth->family == FamilyInternetV6) >+ af = AF_INET6; >+ else >+#endif >+ af = AF_INET; > #ifdef SIGALRM > /* gethostbyaddr can take a LONG time if the host does not exist. > Assume that if it does not respond in NAMESERVER_TIMEOUT seconds >@@ -128,15 +147,21 @@ > alarm (4); > if (setjmp(env) == 0) { > #endif >- hp = gethostbyaddr (auth->address, auth->address_length, AF_INET); >+ hp = gethostbyaddr (auth->address, auth->address_length, af); > #ifdef SIGALRM > } > alarm (0); > #endif > if (hp) > return (hp->h_name); >- else >+ else { >+#ifdef IPv6 >+ inet_ntop(af, auth->address, addr, sizeof(addr)); >+ return addr; >+#else > return (inet_ntoa(*((struct in_addr *)(auth->address)))); >+#endif >+ } > } > #endif > #ifdef DNETCONN >@@ -155,7 +180,7 @@ > return (NULL); > } > >-#ifdef TCPCONN >+#if defined(TCPCONN) && !defined(IPv6) > /* > * cribbed from lib/X/XConnDis.c > */ >@@ -212,7 +237,7 @@ > #endif > > char *get_address_info (family, fulldpyname, prefix, host, lenp) >- int family; >+ int *family; > char *fulldpyname; > int prefix; > char *host; >@@ -220,10 +245,15 @@ > { > char *retval = NULL; > int len = 0; >- char *src = NULL; >+ void *src = NULL; > #ifdef TCPCONN >+#ifdef IPv6 >+ struct addrinfo *firstai = NULL; >+ struct addrinfo *ai = NULL; >+#else > unsigned int hostinetaddr; > #endif >+#endif > #ifdef DNETCONN > struct dn_naddr dnaddr; > #endif >@@ -233,7 +263,7 @@ > * based on the family, set the pointer src to the start of the address > * information to be copied and set len to the number of bytes. > */ >- switch (family) { >+ switch (*family) { > case FamilyLocal: /* hostname/unix:0 */ > /* handle unix:0 and :0 specially */ > if (prefix == 0 && (strncmp (fulldpyname, "unix:", 5) == 0 || >@@ -252,9 +282,27 @@ > break; > case FamilyInternet: /* host:0 */ > #ifdef TCPCONN >+#ifdef IPv6 >+ case FamilyInternetV6: >+ if (getaddrinfo(host,NULL,NULL,&firstai) !=0) return NULL; >+ for (ai = firstai; ai != NULL && src == NULL ; ai = ai->ai_next) { >+ if (ai->ai_family == AF_INET) { >+ struct sockaddr_in *sin = (struct sockaddr_in *)ai->ai_addr; >+ src = &(sin->sin_addr); >+ len = sizeof(sin->sin_addr); >+ *family = FamilyInternet; >+ } else if (ai->ai_family == AF_INET6) { >+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ai->ai_addr; >+ src = &(sin6->sin6_addr); >+ len = sizeof(sin6->sin6_addr); >+ *family = FamilyInternetV6; >+ } >+ } >+#else > if (!get_inet_address (host, &hostinetaddr)) return NULL; > src = (char *) &hostinetaddr; > len = 4; /* sizeof inaddr.sin_addr, would fail on Cray */ >+#endif /* IPv6 */ > break; > #else > return NULL; >@@ -283,5 +331,9 @@ > memmove( retval, src, len); > *lenp = len; > } >+#ifdef IPv6 >+ if (firstai != NULL) >+ freeaddrinfo(firstai); >+#endif > return retval; > } >diff -ur 4.3.0/xc/programs/xauth/parsedpy.c 4.3.0+IPv6/xc/programs/xauth/parsedpy.c >--- 4.3.0/xc/programs/xauth/parsedpy.c Fri Dec 14 12:01:15 2001 >+++ 4.3.0+IPv6/xc/programs/xauth/parsedpy.c Sat Mar 1 23:34:42 2003 >@@ -1,5 +1,6 @@ > /* > * $Xorg: parsedpy.c,v 1.4 2001/02/09 02:05:38 xorgcvs Exp $ >+ * Updated for IPv6 > * > * parse_displayname - utility routine for splitting up display name strings > * >@@ -111,10 +112,10 @@ > if (!displayname || !displayname[0]) return False; > > /* must have at least :number */ >- ptr = strchr(displayname, ':'); >+ ptr = strrchr(displayname, ':'); > if (!ptr || !ptr[1]) return False; >- if (ptr[1] == ':') { >- if (ptr[2] == '\0') return False; >+ if ((ptr != displayname) && (*(ptr - 1) == ':')) { >+ ptr--; > dnet = True; > } > >diff -ur 4.3.0/xc/programs/xauth/process.c 4.3.0+IPv6/xc/programs/xauth/process.c >--- 4.3.0/xc/programs/xauth/process.c Wed Feb 12 18:50:22 2003 >+++ 4.3.0+IPv6/xc/programs/xauth/process.c Sat Mar 1 23:34:42 2003 >@@ -1,4 +1,5 @@ > /* $Xorg: process.c,v 1.6 2001/02/09 02:05:38 xorgcvs Exp $ */ >+/* Updated for IPv6 */ > /* > > Copyright 1989, 1998 The Open Group >@@ -485,8 +486,8 @@ > return False; > } > >+ proto.address = get_address_info(&family, displayname, prelen, host, &len); > proto.family = family; >- proto.address = get_address_info (family, displayname, prelen, host, &len); > if (proto.address) { > char buf[40]; /* want to hold largest display num */ > >@@ -606,7 +607,7 @@ > static Bool xauth_allowed = True; /* if allowed to write auth file */ > static Bool xauth_locked = False; /* if has been locked */ > static char *xauth_filename = NULL; >-static Bool dieing = False; >+static volatile Bool dieing = False; > > #ifdef SIGNALRETURNSINT > #define _signal_t int >@@ -975,6 +976,9 @@ > fprintf (fp, "/unix"); > break; > case FamilyInternet: >+#ifdef IPv6 >+ case FamilyInternetV6: >+#endif > case FamilyDECnet: > dpyname = get_hostname (auth); > if (dpyname) { >diff -ur 4.3.0/xc/programs/xauth/xauth.h 4.3.0+IPv6/xc/programs/xauth/xauth.h >--- 4.3.0/xc/programs/xauth/xauth.h Fri Dec 14 12:01:15 2001 >+++ 4.3.0+IPv6/xc/programs/xauth/xauth.h Mon Mar 3 18:43:12 2003 >@@ -44,7 +44,7 @@ > #include <stdlib.h> > > extern char *get_hostname ( Xauth *auth ); >-extern char *get_address_info ( int family, char *fulldpyname, int prefix, char *host, int *lenp ); >+extern char *get_address_info ( int *family, char *fulldpyname, int prefix, char *host, int *lenp ); > extern char *copystring ( char *src, int len ); > extern char *get_local_hostname ( char *buf, int maxlen ); > extern Bool parse_displayname ( char *displayname, int *familyp, char **hostp, int *dpynump, int *scrnump, char **restp ); >diff -ur 4.3.0/xc/programs/xdm/Imakefile 4.3.0+IPv6/xc/programs/xdm/Imakefile >--- 4.3.0/xc/programs/xdm/Imakefile Sat Dec 7 12:31:04 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/Imakefile Sat Mar 8 09:34:52 2003 >@@ -1,9 +1,9 @@ > XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:54:14 cpqbld Exp $ >+XCOMM Updated for IPv6 > > > >- >-XCOMM $XFree86: xc/programs/xdm/Imakefile,v 3.52 2002/12/07 20:31:04 herrb Exp $ >+XCOMM $Id$ > > #define IHaveSubdirs > #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' >@@ -43,6 +43,12 @@ > KRBIVLIB = KrbIVLibraries > #endif > >+#if HasKrbIV >+KRBIV_DEFINES = KrbIVDefines >+KRBIV_INCLUDES = KrbIVIncludes >+KRBIVLIB = KrbIVLibraries >+#endif >+ > #if HasKrb5 > KRB5_DEFINES = Krb5Defines > KRB5_INCLUDE = Krb5Includes >@@ -131,14 +137,20 @@ > FRAGILE_DEFINES = -DFRAGILE_DEV_MEM > #endif > >-#if defined(NetBSDArchitecture) && \ >- ((OSMajorVersion > 1) || \ >- (OSMajorVersion == 1 && OSMinorVersion > 3)) >-RANDOM_DEFINES = -DDEV_RANDOM=\"/dev/urandom\" >-#endif >- >+#ifdef RandomDefines >+RANDOM_DEFINES = RandomDefines >+#else > #ifdef OpenBSDArchitecture > RANDOM_DEFINES = -DARC4_RANDOM >+#else >+/* Replaced with equivalent RandomDefines in NetBSD.cf >+ * #if defined(NetBSDArchitecture) && \ >+ * ((OSMajorVersion > 1) || \ >+ * (OSMajorVersion == 1 && OSMinorVersion > 3)) >+ * RANDOM_DEFINES = -DDEV_RANDOM=\"/dev/urandom\" >+ * #endif >+ */ >+#endif > #endif > > #if HasVFork >@@ -164,6 +176,15 @@ > SNPRINTFOBJS = snprintf.o > #endif > >+#ifdef HasSunC >+#if HasSunC >+XCOMM auth.c & chooser.c must be compiled with -Xa (ANSI compatible) instead >+XCOMM of -Xc (strict ANSI compliance) in order to access the definition for >+XCOMM struct lifreq, which uses "long long" type variables. >+LIFREQ_FLAGS = -Xa >+#endif >+#endif >+ > SYS_LIBRARIES = $(SYS_LIBRARIES1) $(SYS_LIBRARIES2) $(SYS_LIBRARIES3) > > XDMCONFIGDIR = XdmConfigurationSubdirectory >@@ -235,6 +256,7 @@ > -DOSMINORVERSION=$(OSMINORVERSION) \ > $(XKB_CLIENT_DEFINES) $(USER_CONTEXT_DEFINES) \ > $(XPM_DEFINES) $(XINERAMA_DEFINES) $(PROCTITLE_DEFINES) >+ EXTRAMANDEFS = $(RANDOM_DEFINES) > > XCOMM > XCOMM Special definitions for compiling default resources; these parameters >@@ -261,10 +283,16 @@ > '-DDEF_GREETER_LIB="$(XDMDIR)/libXdmGreet.so"' > > ComplexProgramTarget_1(xdm,$(LOCAL_LIBRARIES),NullParameter) >+#ifdef LinkConfDirectory > LinkConfDirectory(xdm,.,xdm,.) > #ifdef VarDbDirectory > LinkConfDirectoryLong(xdm,xdm,authdir,authdir,$(CONFDIR),$(VARDBDIR)) > #endif >+#else >+#ifdef VarDirectory >+LinkVarDirectory(xdm,.,xdm,.) >+#endif >+#endif > NormalProgramTarget(xdmshell,$(OBJS2),NullParameter,NullParameter,NullParameter) > NormalProgramTarget(sessreg,$(OBJS4),NullParameter,NullParameter,NullParameter) > InstallProgram(sessreg,$(BINDIR)) >@@ -275,7 +303,7 @@ > #endif > > #if BuildChooser >-SpecialCObjectRule(chooser, $(ICONFIGFILES), $(SOCK_DEFINES)) >+SpecialCObjectRule(chooser, $(ICONFIGFILES), $(SOCK_DEFINES) $(LIFREQ_FLAGS)) > NormalProgramTarget(chooser,$(OBJS3),$(DEPLIBS3),$(LIBS3),NullParameter) > InstallProgram(chooser,$(XDMDIR)) > InstallAppDefaults(Chooser) >@@ -285,7 +313,7 @@ > InstallProgram(xdm-shadow,$(BINDIR)) > #endif > >-SpecialCObjectRule(auth,$(ICONFIGFILES),$(SOCK_DEFINES)) >+SpecialCObjectRule(auth,$(ICONFIGFILES),$(SOCK_DEFINES) $(LIFREQ_FLAGS)) > SpecialCObjectRule(policy,$(ICONFIGFILES),$(_NOOP_)) > SpecialCObjectRule(resource,$(ICONFIGFILES),$(RES_DEFINES)) > SpecialCObjectRule(socket,$(ICONFIGFILES),$(SOCK_DEFINES)) >diff -ur 4.3.0/xc/programs/xdm/access.c 4.3.0+IPv6/xc/programs/xdm/access.c >--- 4.3.0/xc/programs/xdm/access.c Tue Dec 10 15:36:43 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/access.c Sat Apr 12 15:21:03 2003 >@@ -2,6 +2,7 @@ > * $Xorg: access.c,v 1.5 2001/02/09 02:05:40 xorgcvs Exp $ > * > Copyright 1990, 1998 The Open Group >+Copyright 2002 Sun Microsystems, Inc. All rights reserved. > > Permission to use, copy, modify, distribute, and sell this software and its > documentation for any purpose is hereby granted without fee, provided that >@@ -19,9 +20,9 @@ > AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN > CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. > >-Except as contained in this notice, the name of The Open Group shall not be >+Except as contained in this notice, the name of a copyright holder shall not be > used in advertising or otherwise to promote the sale, use or other dealings >-in this Software without prior written authorization from The Open Group. >+in this Software without prior written authorization from the copyright holder. > * > * Author: Keith Packard, MIT X Consortium > */ >@@ -53,12 +54,15 @@ > #define CHOOSER_STRING "CHOOSER" > #define BROADCAST_STRING "BROADCAST" > #define NOBROADCAST_STRING "NOBROADCAST" >+#define LISTEN_STRING "LISTEN" >+#define WILDCARD_STRING "*" > > #define HOST_ALIAS 0 > #define HOST_ADDRESS 1 > #define HOST_BROADCAST 2 > #define HOST_CHOOSER 3 > #define HOST_NOBROADCAST 4 >+#define HOST_ANYADDR 5 > > typedef struct _hostEntry { > struct _hostEntry *next; >@@ -67,11 +71,13 @@ > char *aliasName; > ARRAY8 hostAddress; > } entry; >+ int hopCount; > } HostEntry; > > #define DISPLAY_ALIAS 0 > #define DISPLAY_PATTERN 1 > #define DISPLAY_ADDRESS 2 >+#define DISPLAY_LISTEN 3 > > typedef struct _displayEntry { > struct _displayEntry *next; >@@ -101,11 +107,38 @@ > > if (!haveLocalAddress) > { >+#ifdef IPv6 >+ struct addrinfo *ai; >+ >+ if (getaddrinfo(localHostname(), NULL, NULL, &ai) != 0) { >+ XdmcpAllocARRAY8 (&localAddress, 4); >+ localAddress.data[0] = 127; >+ localAddress.data[1] = 0; >+ localAddress.data[2] = 0; >+ localAddress.data[3] = 1; >+ } else { >+ XdmcpAllocARRAY8 (&localAddress, 4); >+ if (ai->ai_addr->sa_family == AF_INET) { >+ XdmcpAllocARRAY8 (&localAddress, sizeof(struct in_addr)); >+ memcpy(localAddress.data, >+ &((struct sockaddr_in *)ai->ai_addr)->sin_addr, >+ sizeof(struct in_addr)); >+ } else if (ai->ai_addr->sa_family == AF_INET6) { >+ XdmcpAllocARRAY8 (&localAddress, sizeof(struct in6_addr)); >+ memcpy(localAddress.data, >+ &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr, >+ sizeof(struct in6_addr)); >+ } >+ freeaddrinfo(ai); >+ } >+#else > struct hostent *hostent; > > hostent = gethostbyname (localHostname()); > XdmcpAllocARRAY8 (&localAddress, hostent->h_length); > memmove( localAddress.data, hostent->h_addr, hostent->h_length); >+#endif >+ > } > return &localAddress; > } >@@ -140,6 +173,9 @@ > case DISPLAY_ADDRESS: > XdmcpDisposeARRAY8 (&d->entry.displayAddress.clientAddress); > break; >+ case DISPLAY_LISTEN: >+ /* do nothing - this case doesn't use the d->entry union */ >+ break; > } > for (h = d->hosts; h; h = next) { > next = h->next; >@@ -217,7 +253,8 @@ > continue; > } > default: >- *wordp++ = c; >+ if (wordp < &(wordBuffer[WORD_LEN])) >+ *wordp++ = c; > break; > } > quoted = FALSE; >@@ -230,13 +267,13 @@ > { > char *hostOrAlias; > HostEntry *h; >- struct hostent *hostent; > > tryagain: > hostOrAlias = ReadWord (file, TRUE); > if (!hostOrAlias) > return NULL; > h = (HostEntry *) malloc (sizeof (DisplayEntry)); >+ h->hopCount = 1; > if (*hostOrAlias == ALIAS_CHARACTER) > { > h->type = HOST_ALIAS; >@@ -259,24 +296,64 @@ > { > h->type = HOST_NOBROADCAST; > } >+ else if (!strcmp (hostOrAlias, WILDCARD_STRING)) >+ { >+ h->type = HOST_ANYADDR; >+ h->entry.hostAddress.length = 0; >+ } > else > { >+ void *addr=NULL; >+ size_t addr_length=0; >+#ifdef IPv6 >+ struct addrinfo *ai; >+#else >+ struct hostent *hostent = gethostbyname (hostOrAlias); >+#endif >+ char *hops = strrchr(hostOrAlias, '/'); >+ >+ if (hops) { >+ *(hops++) = '\0'; >+ h->hopCount = strtol(hops, NULL, 10); >+ if (h->hopCount < 1) >+ h->hopCount = 1; >+ } >+ >+#ifdef IPv6 >+ if (getaddrinfo(hostOrAlias, NULL, NULL, &ai) == 0) { >+ if (ai->ai_addr->sa_family == AF_INET) { >+ addr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr; >+ addr_length = sizeof(struct in_addr); >+ } else if (ai->ai_addr->sa_family == AF_INET6) { >+ addr = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr; >+ addr_length = sizeof(struct in6_addr); >+ } >+ } >+#else >+ if (hostent) { >+ addr = &(hostent->h_addr); >+ addr_length = hostent->h_length; >+ } >+#endif > h->type = HOST_ADDRESS; >- hostent = gethostbyname (hostOrAlias); >- if (!hostent) >+ >+ if (!addr) > { > Debug ("No such host %s\n", hostOrAlias); > LogError ("Access file \"%s\", host \"%s\" not found\n", accessFile, hostOrAlias); > free ((char *) h); > goto tryagain; > } >- if (!XdmcpAllocARRAY8 (&h->entry.hostAddress, hostent->h_length)) >+ if (!XdmcpAllocARRAY8 (&h->entry.hostAddress, addr_length)) > { > LogOutOfMem ("ReadHostEntry\n"); > free ((char *) h); > return NULL; > } >- memmove( h->entry.hostAddress.data, hostent->h_addr, hostent->h_length); >+ memmove( h->entry.hostAddress.data, addr, addr_length); >+#ifdef IPv6 >+ freeaddrinfo(ai); >+#endif > } > return h; > } >@@ -301,7 +378,6 @@ > DisplayEntry *d; > struct _display *display; > HostEntry *h, **prev; >- struct hostent *hostent; > > displayOrAlias = ReadWord (file, FALSE); > if (!displayOrAlias) >@@ -321,6 +397,10 @@ > } > strcpy (d->entry.aliasName, displayOrAlias); > } >+ else if (!strcmp(displayOrAlias, LISTEN_STRING)) >+ { >+ d->type = DISPLAY_LISTEN; >+ } > else > { > if (*displayOrAlias == NEGATE_CHARACTER) >@@ -341,21 +421,48 @@ > } > else > { >+ void *addr = NULL; >+ size_t addr_length = 0; >+ int addrtype = 0; >+ >+#ifdef IPv6 >+ struct addrinfo *ai; >+ >+ if (getaddrinfo(displayOrAlias, NULL, NULL, &ai) == 0) { >+ addrtype = ai->ai_addr->sa_family; >+ if (addrtype == AF_INET) { >+ addr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr; >+ addr_length = sizeof(struct in_addr); >+ } else if (addrtype == AF_INET6) { >+ addr = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr; >+ addr_length = sizeof(struct in6_addr); >+ } >+ } >+#else >+ struct hostent *hostent; >+ > if ((hostent = gethostbyname (displayOrAlias)) == NULL) > { >+ addr = &(hostent->h_addr); >+ addrtype = hostent->h_addrtype; >+ addr_length = hostent->h_length; >+ } >+#endif >+ if (addr == NULL) >+ { > LogError ("Access file %s, display %s unknown\n", accessFile, displayOrAlias); > free ((char *) d); > return NULL; > } > d->type = DISPLAY_ADDRESS; > display = &d->entry.displayAddress; >- if (!XdmcpAllocARRAY8 (&display->clientAddress, hostent->h_length)) >+ if (!XdmcpAllocARRAY8 (&display->clientAddress, addr_length)) > { > free ((char *) d); > return NULL; > } >- memmove( display->clientAddress.data, hostent->h_addr, hostent->h_length); >- switch (hostent->h_addrtype) >+ memmove( display->clientAddress.data, addr, addr_length); >+ switch (addrtype) > { > #ifdef AF_UNIX > case AF_UNIX: >@@ -367,6 +474,11 @@ > display->connectionType = FamilyInternet; > break; > #endif >+#ifdef IPv6 >+ case AF_INET6: >+ display->connectionType = FamilyInternetV6; >+ break; >+#endif > #ifdef AF_DECnet > case AF_DECnet: > display->connectionType = FamilyDECnet; >@@ -388,6 +500,14 @@ > } else if (h->type == HOST_NOBROADCAST) { > FreeHostEntry (h); > d->notBroadcast = 1; >+ } else if (h->type == HOST_ANYADDR) { >+ if (d->type == DISPLAY_LISTEN) { >+ *prev = h; >+ prev = &h->next; >+ } else { >+ Debug("Wildcard host specified in Xaccess for type other than LISTEN -- ignoring\n"); >+ FreeHostEntry (h); >+ } > } else { > *prev = h; > prev = &h->next; >@@ -574,6 +694,7 @@ > { > switch (d->type) { > case DISPLAY_ALIAS: >+ case DISPLAY_LISTEN: > continue; > case DISPLAY_PATTERN: > if (!clientName) >@@ -628,6 +749,7 @@ > { > switch (d->type) { > case DISPLAY_ALIAS: >+ case DISPLAY_LISTEN: > continue; > case DISPLAY_PATTERN: > if (!clientName) >@@ -675,6 +797,7 @@ > { > switch (d->type) { > case DISPLAY_ALIAS: >+ case DISPLAY_LISTEN: > continue; > case DISPLAY_PATTERN: > if (!clientName) >@@ -734,6 +857,7 @@ > continue; > switch (d->type) { > case DISPLAY_ALIAS: >+ case DISPLAY_LISTEN: > continue; > case DISPLAY_PATTERN: > if (!clientName) >@@ -758,5 +882,33 @@ > return (d != 0) && (d->notAllowed == 0) > && (type == BROADCAST_QUERY ? d->notBroadcast == 0 : 1); > } >+ >+void ForEachListenAddr ( >+ ListenFunc listenfunction, >+ ListenFunc mcastfunction, >+ void **closure) >+{ >+ DisplayEntry *d; >+ HostEntry *h; >+ int listenFound = 0; >+ >+ for (d = database; d != NULL ; d = d->next) >+ { >+ if (d->type == DISPLAY_LISTEN) { >+ listenFound = 1; >+ h = d->hosts; >+ if (h != NULL) { >+ (*listenfunction) (&h->entry.hostAddress, closure); >+ } >+ for (h = h->next; h != NULL; h = h->next) { >+ (*mcastfunction) (&h->entry.hostAddress, closure); >+ } >+ } >+ } >+ if (!listenFound) { >+ (*listenfunction) (NULL, closure); >+ } >+} >+ > > #endif /* XDMCP */ >diff -ur 4.3.0/xc/programs/xdm/auth.c 4.3.0+IPv6/xc/programs/xdm/auth.c >--- 4.3.0/xc/programs/xdm/auth.c Tue Dec 10 14:37:17 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/auth.c Sun Mar 23 16:01:39 2003 >@@ -88,7 +88,18 @@ > #include <net/if.h> > #endif /* __GNU__ */ > >-#if ((defined(SVR4) && !defined(sun)) || defined(ISC)) && defined(SIOCGIFCONF) >+/* Solaris provides an extended interface SIOCGLIFCONF. Other systems >+ * may have this as well, but the code has only been tested on Solaris >+ * so far, so we only enable it there. Other platforms may be added as >+ * needed. >+ */ >+#ifdef SIOCGLIFCONF >+#if defined(sun) >+#define USE_SIOCGLIFCONF >+#endif >+#endif >+ >+#if ((defined(SVR4) && !defined(sun)) || defined(ISC)) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF) > #define SYSV_SIOCGIFCONF > #endif > >@@ -270,7 +281,7 @@ > MakeServerAuthFile (struct display *d) > { > int len; >-#ifdef SYSV >+#if defined(SYSV) && !defined(SVR4) > #define NAMELEN 14 > #else > #define NAMELEN 255 >@@ -851,7 +862,13 @@ > > #else /* WINTCP */ > >-#ifdef SIOCGIFCONF >+#if defined(SIOCGIFCONF) || defined (USE_SIOCGLIFCONF) >+ >+#ifdef USE_SIOCGLIFCONF >+#define ifr_type struct lifreq >+#else >+#define ifr_type struct ifreq >+#endif > > /* Handle variable length ifreq in BNR2 and later */ > #ifdef VARIABLE_IFREQ >@@ -859,7 +876,7 @@ > (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \ > p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0)) > #else >-#define ifr_size(p) (sizeof (struct ifreq)) >+#define ifr_size(p) (sizeof (ifr_type)) > #endif > > /* Define this host for access control. Find all the hosts the OS knows about >@@ -869,42 +886,94 @@ > DefineSelf (int fd, FILE *file, Xauth *auth) > { > char buf[2048], *cp, *cplim; >- struct ifconf ifc; > int len; > char *addr; > int family; >- register struct ifreq *ifr; >+ register ifr_type *ifr; >+#ifdef USE_SIOCGLIFCONF >+ int n; >+ void * bufptr = buf; >+ size_t buflen = sizeof(buf); >+ struct lifconf ifc; >+#ifdef SIOCGLIFNUM >+ struct lifnum ifn; >+#endif >+#else >+ struct ifconf ifc; >+#endif > >+#if defined(SIOCGLIFNUM) && defined(SIOCGLIFCONF) >+ ifn.lifn_family = AF_UNSPEC; >+ ifn.lifn_flags = 0; >+ if (ioctl (fd, (int) SIOCGLIFNUM, (char *) &ifn) < 0) >+ LogError ("Failed getting interface count"); >+ if (buflen < (ifn.lifn_count * sizeof(struct lifreq))) { >+ buflen = ifn.lifn_count * sizeof(struct lifreq); >+ bufptr = malloc(buflen); >+ } >+#endif >+ >+#ifdef USE_SIOCGLIFCONF >+ ifc.lifc_family = AF_UNSPEC; >+ ifc.lifc_flags = 0; >+ ifc.lifc_len = buflen; >+ ifc.lifc_buf = bufptr; >+ >+#define IFC_IOCTL_REQ SIOCGLIFCONF >+#define IFC_IFC_REQ ifc.lifc_req >+#define IFC_IFC_LEN ifc.lifc_len >+#define IFR_IFR_ADDR ifr->lifr_addr >+#define IFR_IFR_NAME ifr->lifr_name >+ >+#else > ifc.ifc_len = sizeof (buf); > ifc.ifc_buf = buf; >- if (ifioctl (fd, SIOCGIFCONF, (char *) &ifc) < 0) >- LogError ("Trouble getting network interface configuration"); > >+#define IFC_IOCTL_REQ SIOCGIFCONF > #ifdef ISC > #define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf > #else > #define IFC_IFC_REQ ifc.ifc_req > #endif >+#define IFC_IFC_LEN ifc.ifc_len >+#define IFR_IFR_ADDR ifr->ifr_addr >+#define IFR_IFR_NAME ifr->ifr_name >+#endif >+ >+ if (ifioctl (fd, IFC_IOCTL_REQ, (char *) &ifc) < 0) >+ LogError ("Trouble getting network interface configuration"); >+ >+ if (ifioctl (fd, IFC_IOCTL_REQ, (char *) &ifc) < 0) { >+ LogError ("Trouble getting network interface configuration"); >+#ifdef USE_SIOCGLIFCONF >+ if (bufptr != buf) { >+ free(bufptr); >+ } >+#endif >+ return; >+ } > >- cplim = (char *) IFC_IFC_REQ + ifc.ifc_len; >+ cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN; > > for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr)) > { >- ifr = (struct ifreq *) cp; >+ ifr = (ifr_type *) cp; > #ifdef DNETCONN > /* > * this is ugly but SIOCGIFCONF returns decnet addresses in > * a different form from other decnet calls > */ >- if (ifr->ifr_addr.sa_family == AF_DECnet) { >+ if (IFR_IFR_ADDR.sa_family == AF_DECnet) { > len = sizeof (struct dn_naddr); > addr = (char *)ifr->ifr_addr.sa_data; > family = FamilyDECnet; > } else > #endif > { >- if (ConvertAddr ((XdmcpNetaddr) &ifr->ifr_addr, &len, &addr) < 0) >+ family = ConvertAddr ((XdmcpNetaddr) &IFR_IFR_ADDR, &len, &addr); >+ if (family < 0) > continue; >+ > if (len == 0) > { > Debug ("Skipping zero length address\n"); >@@ -917,14 +986,21 @@ > * the local entry anyway, so this one can > * be tossed. > */ >- if (len == 4 && >+ if (family == FamilyInternet && len == 4 && > addr[0] == 127 && addr[1] == 0 && > addr[2] == 0 && addr[3] == 1) > { > Debug ("Skipping localhost address\n"); > continue; > } >- family = FamilyInternet; >+#ifdef IPv6 >+ if(family == FamilyInternetV6) { >+ if (IN6_IS_ADDR_LOOPBACK(((struct in6_addr *)addr))) { >+ Debug ("Skipping IPv6 localhost address\n"); >+ continue; >+ } >+ } >+#endif > } > Debug ("DefineSelf: write network address, length %d\n", len); > writeAddr (family, len, addr, file, auth); >@@ -1022,7 +1098,11 @@ > t_close (fd); > #endif > #ifdef TCPCONN >+#ifdef IPv6 >+ fd = socket (AF_INET6, SOCK_STREAM, 0); >+#else > fd = socket (AF_INET, SOCK_STREAM, 0); >+#endif > DefineSelf (fd, file, auth); > close (fd); > #endif >diff -ur 4.3.0/xc/programs/xdm/choose.c 4.3.0+IPv6/xc/programs/xdm/choose.c >--- 4.3.0/xc/programs/xdm/choose.c Fri Dec 14 12:01:20 2001 >+++ 4.3.0+IPv6/xc/programs/xdm/choose.c Sat Mar 8 20:26:56 2003 >@@ -43,6 +43,7 @@ > #include <sys/types.h> > > #include "dm_socket.h" >+#include <arpa/inet.h> > > #ifndef X_NO_SYS_UN > #ifndef Lynx >@@ -197,19 +198,29 @@ > netfamily = NetaddrFamily((XdmcpNetaddr)addr_buf); > switch (netfamily) { > case AF_INET: >+#ifdef IPv6 >+ case AF_INET6: >+#endif > { > char *port; > int portlen; >- ARRAY8Ptr localAddress; >+ ARRAY8Ptr localAddress = getLocalAddress (); >+ >+#ifdef IPv6 >+ if (localAddress->length == 16) >+ netfamily = AF_INET6; >+ else >+ netfamily = AF_INET; >+#endif > > port = NetaddrPort((XdmcpNetaddr)addr_buf, &portlen); > result_buf[0] = netfamily >> 8; > result_buf[1] = netfamily & 0xFF; > result_buf[2] = port[0]; > result_buf[3] = port[1]; >- localAddress = getLocalAddress (); >- memmove( (char *)result_buf+4, (char *)localAddress->data, 4); >- result_len = 8; >+ memmove( (char *)result_buf+4, (char *)localAddress->data, >+ localAddress->length); >+ result_len = 4 + localAddress->length; > } > break; > #ifdef AF_DECnet >@@ -372,6 +383,13 @@ > { > *argp = parseArgs (*argp, "BROADCAST"); > } >+#ifdef IPv6 >+ else if ( (addr->length == 16) && >+ (inet_ntop(AF_INET6, addr->data, hostbuf, sizeof(hostbuf)))) >+ { >+ *argp = parseArgs (*argp, hostbuf); >+ } >+#endif > else if (ARRAY8ToDottedDecimal (addr, hostbuf, sizeof (hostbuf))) > { > *argp = parseArgs (*argp, hostbuf); >diff -ur 4.3.0/xc/programs/xdm/chooser.c 4.3.0+IPv6/xc/programs/xdm/chooser.c >--- 4.3.0/xc/programs/xdm/chooser.c Fri Dec 14 12:01:20 2001 >+++ 4.3.0+IPv6/xc/programs/xdm/chooser.c Fri Apr 11 17:56:58 2003 >@@ -194,6 +194,9 @@ > static HostName *hostNamedb; > > static int socketFD; >+#ifdef IPv6 >+static int socket6FD; >+#endif > > static int pingTry; > >@@ -262,13 +265,22 @@ > PingHosts (XtPointer closure, XtIntervalId *id) > { > HostAddr *hosts; >+ int sfd = socketFD; > > for (hosts = hostAddrdb; hosts; hosts = hosts->next) > { >+#ifdef IPv6 >+ if ( ((struct sockaddr *) hosts->addr)->sa_family == AF_INET6 ) >+ sfd = socket6FD; >+ else >+ sfd = socketFD; >+#endif > if (hosts->type == QUERY) >- XdmcpFlush (socketFD, &directBuffer, (XdmcpNetaddr) hosts->addr, hosts->addrlen); >+ XdmcpFlush (sfd, &directBuffer, >+ (XdmcpNetaddr) hosts->addr, hosts->addrlen); > else >- XdmcpFlush (socketFD, &broadcastBuffer, (XdmcpNetaddr) hosts->addr, hosts->addrlen); >+ XdmcpFlush (sfd, &broadcastBuffer, >+ (XdmcpNetaddr) hosts->addr, hosts->addrlen); > } > if (++pingTry < TRIES) > XtAddTimeOut (PING_INTERVAL, PingHosts, (XtPointer) 0); >@@ -321,6 +333,13 @@ > hostAddr.length = 4; > connectionType = FamilyInternet; > break; >+#ifdef IPv6 >+ case AF_INET6: >+ hostAddr.data = (CARD8 *) &((struct sockaddr_in6 *) addr)->sin6_addr; >+ hostAddr.length = 16; >+ connectionType = FamilyInternetV6; >+ break; >+#endif > default: > hostAddr.data = (CARD8 *) ""; > hostAddr.length = 0; >@@ -350,11 +369,14 @@ > switch (addr->sa_family) > { > case AF_INET: >+#ifdef IPv6 >+ case AF_INET6: >+#endif > { > struct hostent *hostent; > char *host; > >- hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, AF_INET); >+ hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, addr->sa_family); > if (hostent) > { > XdmcpDisposeARRAY8 (hostname); >@@ -464,11 +486,16 @@ > ARRAY8 hostname; > ARRAY8 status; > int saveHostname = 0; >+#ifdef IPv6 >+ struct sockaddr_storage addr; >+#else > struct sockaddr addr; >+#endif > int addrlen; >+ int sfd = * (int *) closure; > > addrlen = sizeof (addr); >- if (!XdmcpFill (socketFD, &buffer, (XdmcpNetaddr) &addr, &addrlen)) >+ if (!XdmcpFill (sfd, &buffer, (XdmcpNetaddr) &addr, &addrlen)) > return; > if (!XdmcpReadHeader (&buffer, &header)) > return; >@@ -486,7 +513,8 @@ > if (header.length == 6 + authenticationName.length + > hostname.length + status.length) > { >- if (AddHostname (&hostname, &status, &addr, header.opcode == (int) WILLING)) >+ if (AddHostname (&hostname, &status, (struct sockaddr *) &addr, >+ header.opcode == (int) WILLING)) > saveHostname = 1; > } > } >@@ -498,7 +526,8 @@ > { > if (header.length == 4 + hostname.length + status.length) > { >- if (AddHostname (&hostname, &status, &addr, header.opcode == (int) WILLING)) >+ if (AddHostname (&hostname, &status, (struct sockaddr *) &addr, >+ header.opcode == (int) WILLING)) > saveHostname = 1; > > } >@@ -558,7 +587,9 @@ > static void > RegisterHostname (char *name) > { >+#ifndef IPv6 > struct hostent *hostent; >+#endif > struct sockaddr_in in_addr; > struct ifconf ifc; > register struct ifreq *ifr; >@@ -673,13 +704,48 @@ > } > else > { >- > /* address as hex string, e.g., "12180022" (depreciated) */ > if (strlen(name) == 8 && > FromHex(name, (char *)&in_addr.sin_addr, strlen(name)) == 0) > { > in_addr.sin_family = AF_INET; >+ in_addr.sin_port = htons (XDM_UDP_PORT); >+#ifdef BSD44SOCKETS >+ in_addr.sin_len = sizeof(in_addr); >+#endif >+ RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr), >+ QUERY); > } >+ else { >+ >+#ifdef IPv6 >+ char sport[8]; >+ struct addrinfo *ai, *nai, hints; >+ bzero(&hints,sizeof(hints)); >+ hints.ai_socktype = SOCK_DGRAM; >+ sprintf(sport, "%d", XDM_UDP_PORT); >+ if (getaddrinfo(name, sport, &hints, &ai) == 0) { >+ for (nai = ai ; nai != NULL ; nai = nai->ai_next) { >+ if ((nai->ai_family == AF_INET) || >+ (nai->ai_family == AF_INET6)) { >+ if (((nai->ai_family == AF_INET) && >+ IN_MULTICAST(((struct sockaddr_in *) nai->ai_addr) >+ ->sin_addr.s_addr)) >+ || ((nai->ai_family == AF_INET6) && >+ IN6_IS_ADDR_MULTICAST( >+ &((struct sockaddr_in6 *) nai->ai_addr) >+ ->sin6_addr))) >+ { >+ RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, >+ BROADCAST_QUERY); >+ } else { >+ RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, >+ QUERY); >+ } >+ } >+ } >+ } >+#else > /* Per RFC 1123, check first for IP address in dotted-decimal form */ > else if ((in_addr.sin_addr.s_addr = inet_addr(name)) != -1) > in_addr.sin_family = AF_INET; >@@ -699,6 +765,10 @@ > #endif > RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr), > QUERY); >+#endif /* IPv6 */ >+ } >+ >+ > } > } > #else /* __GNU__ */ >@@ -723,7 +793,25 @@ > FromHex(name, (char *)&in_addr.sin_addr, strlen(name)) == 0) > { > in_addr.sin_family = AF_INET; >- } >+ in_addr.sin_port = htons (XDM_UDP_PORT); >+ RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr), >+ QUERY); >+ } else { >+#ifdef IPv6 >+ char sport[8]; >+ struct addrinfo *ai, *nai, hints; >+ bzero(&hints,sizeof(hints)); >+ hints.ai_socktype = SOCK_DGRAM; >+ sprintf(sport, "%d", XDM_UDP_PORT); >+ if (getaddrinfo(name, sport, &hints, &ai) == 0) { >+ for (nai = ai ; nai != NULL ; nai = nai->ai_next) { >+ if ((nai->ai_family == AF_INET) || >+ (nai->ai_family == AF_INET6)) { >+ RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, QUERY); >+ } >+ } >+ } >+#else > /* Per RFC 1123, check first for IP address in dotted-decimal form */ > else if ((in_addr.sin_addr.s_addr = inet_addr(name)) != -1) > in_addr.sin_family = AF_INET; >@@ -740,6 +828,9 @@ > in_addr.sin_port = htons (XDM_UDP_PORT); > RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr), > QUERY); >+#endif >+ } >+ > } > } > #endif /* __GNU__ */ >@@ -820,6 +911,9 @@ > #else > if ((socketFD = socket (AF_INET, SOCK_DGRAM, 0)) < 0) > return 0; >+#ifdef IPv6 >+ socket6FD = socket (AF_INET6, SOCK_DGRAM, 0); >+#endif > #endif > #ifndef STREAMSCONN > #ifdef SO_BROADCAST >@@ -830,7 +924,11 @@ > #endif > > XtAddInput (socketFD, (XtPointer) XtInputReadMask, ReceivePacket, >- (XtPointer) 0); >+ (XtPointer) &socketFD); >+#ifdef IPv6 >+ XtAddInput (socket6FD, (XtPointer) XtInputReadMask, ReceivePacket, >+ (XtPointer) &socket6FD); >+#endif > while (*argv) > { > RegisterHostname (*argv); >@@ -847,6 +945,9 @@ > if (app_resources.xdmAddress) > { > struct sockaddr_in in_addr; >+#ifdef IPv6 >+ struct sockaddr_in6 in6_addr; >+#endif > struct sockaddr *addr = NULL; > int family; > int len = 0; >@@ -871,6 +972,19 @@ > addr = (struct sockaddr *) &in_addr; > len = sizeof (in_addr); > break; >+#ifdef IPv6 >+ case AF_INET6: >+ bzero(&in6_addr, sizeof(in6_addr)); >+#ifdef SIN6_LEN >+ in6_addr.sin6_len = sizeof(in6_addr); >+#endif >+ in6_addr.sin6_family = family; >+ memmove( &in6_addr.sin6_port, xdm + 2, 2); >+ memmove( &in6_addr.sin6_addr, xdm + 4, 16); >+ addr = (struct sockaddr *) &in6_addr; >+ len = sizeof (in6_addr); >+ break; >+#endif > } > #if defined(STREAMSCONN) > if ((fd = t_open ("/dev/tcp", O_RDWR, NULL)) == -1) >diff -ur 4.3.0/xc/programs/xdm/config/Xaccess 4.3.0+IPv6/xc/programs/xdm/config/Xaccess >--- 4.3.0/xc/programs/xdm/config/Xaccess Wed Jan 17 15:45:24 2001 >+++ 4.3.0+IPv6/xc/programs/xdm/config/Xaccess Sat Mar 8 20:57:33 2003 >@@ -1,5 +1,5 @@ > # $Xorg: Xaccess,v 1.3 2000/08/17 19:54:17 cpqbld Exp $ >-# >+# Updated for IPv6 > # $XFree86: xc/programs/xdm/config/Xaccess,v 1.3 2001/01/17 23:45:24 dawes Exp $ > # > # Access control file for XDMCP connections >@@ -24,6 +24,10 @@ > # > # %name list of hosts ... > # >+# To control which addresses xdm listens for requests on: >+# >+# LISTEN address [list of multicast groups ... ] >+# > # The first form tells xdm which displays to respond to itself. > # The second form tells xdm to forward indirect queries from hosts matching > # the specified pattern to the indicated list of hosts. >@@ -32,6 +36,9 @@ > # address and display the results on the terminal. > # The fourth form is similar to the third, except instead of using the > # broadcast address, it sends DirectQuerys to each of the hosts in the list >+# The fifth form tells xdm which addresses to listen for incoming connections >+# on. If present, xdm will only listen for connections on the specified >+# interfaces and/or multicast groups. > # > # In all cases, xdm uses the first entry which matches the terminal; > # for IndirectQuery messages only entries with right hand sides can >@@ -68,3 +75,17 @@ > #%hostlist host-a host-b > > #* CHOOSER %hostlist # >+ >+# >+# If you have a machine with multiple network interfaces or IP addresses >+# you can control which interfaces accept XDMCP packets by listing a LISTEN >+# line for each interface you want to listen on. You can additionally list >+# one or more multicast groups after each address to listen on those groups >+# on that address. >+# >+# If no LISTEN is specified, the default is the same as "LISTEN *" - listen on >+# all unicast interfaces, but not for multicast packets. If any LISTEN lines >+# are specified, then only the listed interfaces will be listened on. >+# >+ >+#LISTEN * ff02::1 >diff -ur 4.3.0/xc/programs/xdm/dm.c 4.3.0+IPv6/xc/programs/xdm/dm.c >--- 4.3.0/xc/programs/xdm/dm.c Sat Dec 7 12:31:04 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/dm.c Sat Mar 8 18:11:25 2003 >@@ -73,7 +73,7 @@ > #endif > > >-#if defined(SVR4) && !defined(SCO) >+#if defined(SVR4) && !defined(SCO) && !defined(sun) > extern FILE *fdopen(); > #endif > >@@ -86,7 +86,7 @@ > static void StartDisplays (void); > static void TerminateProcess (int pid, int signal); > >-int Rescan; >+volatile int Rescan; > static long ServersModTime, ConfigModTime, AccessFileModTime; > > int nofork_session = 0; >@@ -177,6 +177,7 @@ > SetAccessFileTime (); > #ifdef XDMCP > ScanAccessDatabase (); >+ UpdateListenSockets (); > #endif > ScanServers (); > StartDisplays (); >@@ -281,6 +282,7 @@ > SetAccessFileTime (); > #ifdef XDMCP > ScanAccessDatabase (); >+ UpdateListenSockets (); > #endif > StartDisplays (); > } >@@ -339,6 +341,7 @@ > LogInfo ("Rereading access file %s\n", accessFile); > AccessFileModTime = statb.st_mtime; > ScanAccessDatabase (); >+ UpdateListenSockets(); > } > } > #endif >diff -ur 4.3.0/xc/programs/xdm/dm.h 4.3.0+IPv6/xc/programs/xdm/dm.h >--- 4.3.0/xc/programs/xdm/dm.h Fri May 31 11:46:10 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/dm.h Sat Mar 8 10:04:33 2003 >@@ -116,6 +116,21 @@ > #endif > #endif > >+#ifdef USE_PAM >+#include <security/pam_appl.h> >+#endif >+ >+#ifdef CSRG_BASED >+#include <sys/param.h> >+#ifdef HAS_SETUSERCONTEXT >+#include <login_cap.h> >+#include <pwd.h> >+#ifdef USE_BSDAUTH >+#include <bsd_auth.h> >+#endif >+#endif >+#endif >+ > # define waitCompose(sig,core,code) ((sig) * 256 + (core) * 128 + (code)) > # define waitVal(w) waitCompose(waitSig(w), waitCore(w), waitCode(w)) > >@@ -186,6 +201,7 @@ > int useChooser; /* Run the chooser for this display */ > ARRAY8 clientAddr; /* for chooser picking */ > CARD16 connectionType; /* ... */ >+ int xdmcpFd; > #endif > /* server management resources */ > int serverAttempts; /* number of attempts at running X */ >@@ -279,6 +295,7 @@ > #endif > > typedef void (*ChooserFunc)(CARD16 connectionType, ARRAY8Ptr addr, char *closure); >+typedef void (*ListenFunc)(ARRAY8Ptr addr, void **closure); > > struct verify_info { > int uid; /* user id */ >@@ -352,6 +369,8 @@ > extern int ScanAccessDatabase (void); > extern int UseChooser (ARRAY8Ptr clientAddress, CARD16 connectionType); > extern void ForEachChooserHost (ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure); >+extern void ForEachListenAddr(ListenFunc listenfunction, >+ ListenFunc mcastfcuntion, void **closure); > > /* in choose.c */ > extern ARRAY8Ptr IndirectChoice (ARRAY8Ptr clientAddress, CARD16 connectionType); >@@ -439,9 +458,12 @@ > extern int WaitForServer (struct display *d); > extern void ResetServer (struct display *d); > >-/* socket.c */ >+/* socket.c or streams.c */ > extern int GetChooserAddr (char *addr, int *lenp); > extern void CreateWellKnownSockets (void); >+extern void UpdateListenSockets (void); >+extern void CloseListenSockets (void); >+extern void ProcessListenSockets (fd_set *readmask); > > /* in util.c */ > extern char *localHostname (void); >@@ -467,6 +489,7 @@ > extern void WaitForSomething (void); > extern void init_session_id(void); > extern void registerHostname(char *name, int namelen); >+extern void ProcessRequestSocket(int fd); > > /* > * CloseOnFork flags >diff -ur 4.3.0/xc/programs/xdm/dpylist.c 4.3.0+IPv6/xc/programs/xdm/dpylist.c >--- 4.3.0/xc/programs/xdm/dpylist.c Fri Dec 14 12:01:21 2001 >+++ 4.3.0+IPv6/xc/programs/xdm/dpylist.c Sat Mar 8 18:37:33 2003 >@@ -258,6 +258,7 @@ > d->clientAddr.data = NULL; > d->clientAddr.length = 0; > d->connectionType = 0; >+ d->xdmcpFd = -1; > #endif > d->version = 1; /* registered with The Open Group */ > displays = d; >diff -ur 4.3.0/xc/programs/xdm/genauth.c 4.3.0+IPv6/xc/programs/xdm/genauth.c >--- 4.3.0/xc/programs/xdm/genauth.c Sun Oct 6 11:12:29 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/genauth.c Sat Mar 8 18:27:01 2003 >@@ -47,6 +47,10 @@ > > static unsigned char key[8]; > >+#ifdef DEV_RANDOM >+extern char *randomDevice; >+#endif >+ > #ifdef HASXDMAUTH > > typedef unsigned char auth_cblock[8]; /* block size */ >@@ -66,9 +70,25 @@ > > #endif > >+#ifdef POLL_DEV_RANDOM >+#include <poll.h> >+static int >+pollRandomDevice (int fd) >+{ >+ struct pollfd fds; >+ >+ fds.fd = fd; >+ fds.events = POLLIN | POLLRDNORM; >+ /* Wait up to 5 seconds for entropy to accumulate */ >+ return poll(&fds, 1, 5000); >+} >+#else >+#define pollRandomDevice 1 >+#endif >+ > # define FILE_LIMIT 1024 /* no more than this many buffers */ > >-#if !defined(ARC4_RANDOM) && !defined(DEV_RANDOM) >+#if !defined(ARC4_RANDOM) > static int > sumFile (char *name, long sum[2]) > { >@@ -120,12 +140,15 @@ > > _XdmcpWrapperToOddParity(sum, key); > >-#elif defined(DEV_RANDOM) >- int fd; >+#else > unsigned char tmpkey[8]; >+ long sum[2]; >+ >+#ifdef DEV_RANDOM >+ int fd; > >- if ((fd = open(DEV_RANDOM, O_RDONLY)) >= 0) { >- if (read(fd, tmpkey, 8) == 8) { >+ if ((fd = open(randomDevice, O_RDONLY)) >= 0) { >+ if (pollRandomDevice(fd) && read(fd, tmpkey, 8) == 8) { > tmpkey[0] = 0; > _XdmcpWrapperToOddParity(tmpkey, key); > close(fd); >@@ -133,11 +156,11 @@ > } else { > close(fd); > } >+ } else { >+ LogError("Cannot open randomDevice \"%s\", errno = %d\n", >+ randomDevice, errno); > } >-#else >- long sum[2]; >- unsigned char tmpkey[8]; >- >+#endif > if (!sumFile (randomFile, sum)) { > sum[0] = time ((Time_t *) 0); > sum[1] = time ((Time_t *) 0); >@@ -231,18 +254,23 @@ > #ifdef ARC4_RANDOM > localkey[0] = arc4random(); > localkey[1] = arc4random(); >-#elif defined(DEV_RANDOM) >+#else >+#ifdef DEV_RANDOM > int fd; > >- if ((fd = open(DEV_RANDOM, O_RDONLY)) >= 0) { >- if (read(fd, (char *)localkey, 8) != 8) { >- localkey[0] = 1; >+ if ((fd = open(randomDevice, O_RDONLY)) >= 0) { >+ if (pollRandomDevice(fd) && >+ read(fd, (char *)localkey, 8) != 8) { >+ localkey[0] = 0; localkey[1] = 0; > } > close(fd); > } else { >- localkey[0] = 1; >+ LogError("Cannot open randomDevice \"%s\", errno = %d\n", >+ randomDevice, errno); > } >-#else >+ /* Fallback if not able to get from /dev/random */ >+ if ( (localkey[0] == 0) && (localkey[1] == 0) ) >+#endif > if (!sumFile (randomFile, localkey)) { > localkey[0] = 1; /* To keep from continually calling sumFile() */ > } >diff -ur 4.3.0/xc/programs/xdm/greet.h 4.3.0+IPv6/xc/programs/xdm/greet.h >--- 4.3.0/xc/programs/xdm/greet.h Fri Dec 14 12:01:22 2001 >+++ 4.3.0+IPv6/xc/programs/xdm/greet.h Sat Mar 8 10:07:30 2003 >@@ -37,7 +37,7 @@ > /* > * Do this rather than break a build over a const-mismatch > */ >-#if defined(__linux__) || defined(CSRG_BASED) >+#if defined(__linux__) || defined(CSRG_BASED) || (defined(sun) && defined(SVR4)) > #define CRYPT_ARGS const char *s1, const char *s2 > #define GETSPNAM_ARGS const char *name > #define GETPWNAM_ARGS const char *name >diff -ur 4.3.0/xc/programs/xdm/greeter/Login.c 4.3.0+IPv6/xc/programs/xdm/greeter/Login.c >--- 4.3.0/xc/programs/xdm/greeter/Login.c Sun Oct 6 13:42:16 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/greeter/Login.c Sat Mar 8 21:21:17 2003 >@@ -137,7 +137,12 @@ > {XtNpasswdPrompt, XtCPasswdPrompt, XtRString, sizeof (char *), > offset(passwdPrompt), XtRString, "Password: "}, > {XtNfail, XtCFail, XtRString, sizeof (char *), >- offset(fail), XtRString, "Login incorrect"}, >+ offset(fail), XtRString, >+#if defined(sun) && defined(SVR4) >+ "Login incorrect or not on system console if root"}, >+#else >+ "Login incorrect"}, >+#endif > {XtNfailTimeout, XtCFailTimeout, XtRInt, sizeof (int), > offset(failTimeout), XtRImmediate, (XtPointer) 10}, > {XtNnotifyDone, XtCCallback, XtRFunction, sizeof (XtPointer), >diff -ur 4.3.0/xc/programs/xdm/greeter/greet.c 4.3.0+IPv6/xc/programs/xdm/greeter/greet.c >--- 4.3.0/xc/programs/xdm/greeter/greet.c Sun Oct 6 13:42:16 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/greeter/greet.c Sat Mar 8 21:11:13 2003 >@@ -145,8 +145,10 @@ > data->name, strlen (data->passwd)); > switch (status) { > case NOTIFY_OK: >- strcpy (name, data->name); >- strcpy (password, data->passwd); >+ strncpy (name, data->name, sizeof(name)); >+ name[sizeof(name)-1] = '\0'; >+ strncpy (password, data->passwd, sizeof(password)); >+ password[sizeof(password)-1] = '\0'; > bzero (data->passwd, PASSWORD_LEN); > code = 0; > done = 1; >@@ -280,6 +282,9 @@ > Debug ("Greet connection closed\n"); > } > >+#define WHITESPACE 0 >+#define ARGUMENT 1 >+ > static int > Greet (struct display *d, struct greet_info *greet) > { >@@ -306,7 +311,29 @@ > Debug ("Done dispatch %s\n", d->name); > if (code == 0) > { >- greet->name = name; >+ char *ptr; >+ unsigned int c,state = WHITESPACE; >+ >+ /* >+ * process the name string to get rid of >+ * white spaces. >+ */ >+ >+ for (ptr = name; state == WHITESPACE; ptr++) >+ { >+ c = (unsigned int)(*ptr); >+ if ( c == ' ') >+ { >+ continue; >+ } >+ else >+ { >+ state = ARGUMENT; >+ break; >+ } >+ } >+ >+ greet->name = ptr; > greet->password = password; > XtSetArg (arglist[0], XtNsessionArgument, (char *) &(greet->string)); > XtSetArg (arglist[1], XtNallowNullPasswd, (char *) &(greet->allow_null_passwd)); >diff -ur 4.3.0/xc/programs/xdm/greeter/verify.c 4.3.0+IPv6/xc/programs/xdm/greeter/verify.c >--- 4.3.0/xc/programs/xdm/greeter/verify.c Mon Nov 25 17:16:09 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/greeter/verify.c Sat Mar 8 21:14:27 2003 >@@ -304,6 +304,47 @@ > char **argv; > > Debug ("Verify %s ...\n", greet->name); >+ >+#if defined(sun) && defined(SVR4) >+ /* Solaris: If CONSOLE is set to /dev/console in /etc/default/login, >+ then root can only login on system console */ >+ >+# define SOLARIS_LOGIN_DEFAULTS "/etc/default/login" >+ >+ if (strcmp(greet->name, "root") == 0) { >+ char *console = NULL, *tmp = NULL; >+ FILE *fs; >+ >+ if ((fs= fopen(SOLARIS_LOGIN_DEFAULTS, "r")) != NULL) >+ { >+ char str[120]; >+ while (!feof(fs)) >+ { >+ fgets(str, 120, fs); >+ if(str[0] == '#' || strlen(str) < 8) >+ continue; >+ if((tmp = strstr(str, "CONSOLE=")) != NULL) >+ console = strdup((tmp+8)); >+ } >+ fclose(fs); >+ if ( console != NULL && >+ (strncmp(console, "/dev/console", 12) == 0) && >+ (strncmp(d->name,":0",2) != 0) ) >+ { >+ Debug("Not on system console\n"); >+ bzero(greet->password, strlen(greet->password)); >+ XFree(console); >+ return 0; >+ } >+ Xfree(console); >+ } >+ else >+ { >+ Debug("Could not open %s\n", SOLARIS_LOGIN_DEFAULTS); >+ } >+ } >+#endif >+ > #ifndef USE_PAM > p = getpwnam (greet->name); > endpwent(); >diff -ur 4.3.0/xc/programs/xdm/netaddr.c 4.3.0+IPv6/xc/programs/xdm/netaddr.c >--- 4.3.0/xc/programs/xdm/netaddr.c Fri Dec 14 12:01:22 2001 >+++ 4.3.0+IPv6/xc/programs/xdm/netaddr.c Sat Mar 8 18:28:52 2003 >@@ -85,6 +85,11 @@ > case AF_INET: > *lenp = 2; > return (char *)&(((struct sockaddr_in *)netaddrp)->sin_port); >+#ifdef IPv6 >+ case AF_INET6: >+ *lenp = 2; >+ return (char *)&(((struct sockaddr_in6 *)netaddrp)->sin6_port); >+#endif > default: > *lenp = 0; > return NULL; >@@ -112,6 +117,19 @@ > case AF_INET: > *lenp = sizeof (struct in_addr); > return (char *) &(((struct sockaddr_in *)netaddrp)->sin_addr); >+#ifdef IPv6 >+ case AF_INET6: >+ { >+ struct in6_addr *a = &(((struct sockaddr_in6 *)netaddrp)->sin6_addr); >+ if (IN6_IS_ADDR_V4MAPPED(a)) { >+ *lenp = sizeof (struct in_addr); >+ return ((char *) &(a->s6_addr))+12; >+ } else { >+ *lenp = sizeof (struct in6_addr); >+ return (char *) &(a->s6_addr); >+ } >+ } >+#endif > #endif > #ifdef DNETCONN > case AF_DECnet: >@@ -163,6 +181,14 @@ > case AF_INET: > retval = FamilyInternet; > break; >+#ifdef IPv6 >+ case AF_INET6: >+ if (*len == sizeof(struct in_addr)) >+ retval = FamilyInternet; >+ else >+ retval = FamilyInternetV6; >+ break; >+#endif > #endif > #ifdef DNETCONN > case AF_DECnet: >@@ -231,8 +257,21 @@ > Debug ("port %d, host %d.%d.%d.%d\n", > (p[0] << 8) + p[1], t[0], t[1], t[2], t[3]); > break; >+#endif >+#ifdef IPv6 >+ case AF_INET6: >+ { >+ char astr[INET6_ADDRSTRLEN] = ""; >+ >+ inet_ntop(a->sa_family, &((struct sockaddr_in6 *) a)->sin6_addr, >+ astr, sizeof(astr)); >+ p = (unsigned char *) &((struct sockaddr_in6 *) a)->sin6_port; >+ >+ Debug ("port %d, host %s\n", (p[0] << 8) + p[1], astr); >+ break; > } > #endif >+ } > } > #endif > >diff -ur 4.3.0/xc/programs/xdm/resource.c 4.3.0+IPv6/xc/programs/xdm/resource.c >--- 4.3.0/xc/programs/xdm/resource.c Sat Dec 7 12:31:04 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/resource.c Sat Mar 8 18:35:09 2003 >@@ -58,6 +58,9 @@ > char *accessFile; > char **exportList; > char *randomFile; >+#ifdef DEV_RANDOM >+char *randomDevice; >+#endif > char *greeterLib; > char *willing; > int choiceTimeout; /* chooser choice timeout */ >@@ -72,6 +75,7 @@ > * parameters set util/imake.includes/site.def (or *.macros in that directory > * if it is server-specific). DO NOT CHANGE THESE DEFINITIONS! > */ >+#ifndef __EMX__ > #ifndef DEF_SERVER_LINE > #define DEF_SERVER_LINE ":0 local /usr/bin/X11/X :0" > #endif >@@ -119,15 +123,68 @@ > #define DEF_ACCESS_FILE "" > #endif > #ifndef DEF_RANDOM_FILE >-# ifdef linux >-# define DEF_RANDOM_FILE "/dev/urandom" >-# else >-# define DEF_RANDOM_FILE "/dev/mem" >-# endif >+#define DEF_RANDOM_FILE "/dev/mem" > #endif > #ifndef DEF_GREETER_LIB > #define DEF_GREETER_LIB "/usr/lib/X11/xdm/libXdmGreet.so" > #endif >+#else >+/* unfortunately I have to declare all of them, because there is a limit >+ * in argument size in OS/2 >+ * but everything needs to be fixed again >+ */ >+#define DEF_SERVER_LINE ":0 local /XFree86/bin/X :0" >+#ifndef XRDB_PROGRAM >+#define XRDB_PROGRAM "/XFree86/bin/xrdb" >+#endif >+#ifndef DEF_SESSION >+#define DEF_SESSION "/XFree86/bin/xterm -ls" >+#endif >+#ifndef DEF_USER_PATH >+#define DEF_USER_PATH "c:\\os2;c:\\os2\apps;\\XFree86\\bin" >+#endif >+#ifndef DEF_SYSTEM_PATH >+#define DEF_SYSTEM_PATH "c:\\os2;c:\\os2\apps;\\XFree86\\bin" >+#endif >+#ifndef DEF_SYSTEM_SHELL >+#define DEF_SYSTEM_SHELL "sh" >+#endif >+#ifndef DEF_FAILSAFE_CLIENT >+#define DEF_FAILSAFE_CLIENT "/XFree86/bin/xterm" >+#endif >+#ifndef DEF_XDM_CONFIG >+#define DEF_XDM_CONFIG "/XFree86/lib/X11/xdm/xdm-config" >+#endif >+#ifndef DEF_CHOOSER >+#define DEF_CHOOSER "/XFree86/lib/X11/xdm/chooser" >+#endif >+#ifndef DEF_AUTH_NAME >+#ifdef HASXDMAUTH >+#define DEF_AUTH_NAME "XDM-AUTHORIZATION-1 MIT-MAGIC-COOKIE-1" >+#else >+#define DEF_AUTH_NAME "MIT-MAGIC-COOKIE-1" >+#endif >+#endif >+#ifndef DEF_AUTH_DIR >+#define DEF_AUTH_DIR "/XFree86/lib/X11/xdm" >+#endif >+#ifndef DEF_USER_AUTH_DIR >+#define DEF_USER_AUTH_DIR "/tmp" >+#endif >+#ifndef DEF_KEY_FILE >+#define DEF_KEY_FILE "" >+#endif >+#ifndef DEF_ACCESS_FILE >+#define DEF_ACCESS_FILE "" >+#endif >+#ifndef DEF_RANDOM_FILE >+#define DEF_RANDOM_FILE "" >+#endif >+#ifndef DEF_GREETER_LIB >+#define DEF_GREETER_LIB "/XFree86/lib/X11/xdm/libXdmGreet.so" >+#endif >+ >+#endif /* __EMX__ */ > > #define DEF_UDP_PORT "177" /* registered XDMCP port, dont change */ > >@@ -165,6 +222,10 @@ > ""} , > { "randomFile", "RandomFile", DM_STRING, &randomFile, > DEF_RANDOM_FILE} , >+#ifdef DEV_RANDOM >+{ "randomDevice", "RandomDevice", DM_STRING, &randomDevice, >+ DEV_RANDOM} , >+#endif > { "greeterLib", "GreeterLib", DM_STRING, &greeterLib, > DEF_GREETER_LIB} , > { "choiceTimeout","ChoiceTimeout",DM_INT, (char **) &choiceTimeout, >diff -ur 4.3.0/xc/programs/xdm/session.c 4.3.0+IPv6/xc/programs/xdm/session.c >--- 4.3.0/xc/programs/xdm/session.c Fri Dec 14 12:01:23 2001 >+++ 4.3.0+IPv6/xc/programs/xdm/session.c Sat Mar 8 18:40:22 2003 >@@ -54,6 +54,7 @@ > #ifdef SECURE_RPC > # include <rpc/rpc.h> > # include <rpc/key_prot.h> >+extern int key_setnet(struct key_netstarg *arg); > #endif > #ifdef K5AUTH > # include <krb5/krb5.h> >@@ -68,7 +69,7 @@ > > static int runAndWait (char **args, char **environ); > >-#if defined(CSRG_BASED) || defined(__osf__) || defined(__DARWIN__) || defined(__QNXNTO__) >+#if defined(CSRG_BASED) || defined(__osf__) || defined(__DARWIN__) || defined(__QNXNTO__) || defined(sun) > #include <sys/types.h> > #include <grp.h> > #else >@@ -79,9 +80,13 @@ > #endif > > #ifdef USESHADOW >+#if defined(SVR4) >+#include <shadow.h> >+#else > extern struct spwd *getspnam(GETSPNAM_ARGS); > extern void endspent(void); > #endif >+#endif > #if defined(CSRG_BASED) > #include <pwd.h> > #include <unistd.h> >@@ -652,6 +657,7 @@ > char netname[MAXNETNAMELEN+1], secretkey[HEXKEYBYTES+1]; > int nameret, keyret; > int len; >+ struct key_netstarg netst; > int key_set_ok = 0; > > nameret = getnetname (netname); >@@ -662,6 +668,13 @@ > keyret = getsecretkey(netname,secretkey,passwd); > Debug ("getsecretkey returns %d, key length %d\n", > keyret, strlen (secretkey)); >+ memcpy(&(netst.st_priv_key), secretkey, HEXKEYBYTES); >+ netst.st_netname = strdup(netname); >+ memset(netst.st_pub_key, 0, HEXKEYBYTES); >+ if (key_setnet(&netst) < 0) { >+ Debug("Could not set secret key.\n"); >+ } >+ free(netst.st_netname); > /* is there a key, and do we have the right password? */ > if (keyret == 1) > { >diff -ur 4.3.0/xc/programs/xdm/socket.c 4.3.0+IPv6/xc/programs/xdm/socket.c >--- 4.3.0/xc/programs/xdm/socket.c Fri Dec 14 12:01:24 2001 >+++ 4.3.0+IPv6/xc/programs/xdm/socket.c Sat Apr 12 15:18:32 2003 >@@ -2,6 +2,7 @@ > /* > > Copyright 1988, 1998 The Open Group >+Copyright 2002 Sun Microsystems, Inc. All rights reserved. > > Permission to use, copy, modify, distribute, and sell this software and its > documentation for any purpose is hereby granted without fee, provided that >@@ -15,15 +16,15 @@ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS > OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. >-IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR >+IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR > OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > OTHER DEALINGS IN THE SOFTWARE. > >-Except as contained in this notice, the name of The Open Group shall >+Except as contained in this notice, the name of a copyright holder shall > not be used in advertising or otherwise to promote the sale, use or > other dealings in this Software without prior written authorization >-from The Open Group. >+from the copyright holder. > > */ > /* $XFree86: xc/programs/xdm/socket.c,v 3.10 2001/12/14 20:01:24 dawes Exp $ */ >@@ -52,9 +53,8 @@ > #endif > #endif > #include <netdb.h> >+#include <arpa/inet.h> > >- >-extern int xdmcpFd; > extern int chooserFd; > > extern FD_TYPE WellKnownSocketsMask; >@@ -63,39 +63,14 @@ > void > CreateWellKnownSockets (void) > { >- struct sockaddr_in sock_addr; >- char *name; >- >- if (request_port == 0) >- return; >- Debug ("creating socket %d\n", request_port); >- xdmcpFd = socket (AF_INET, SOCK_DGRAM, 0); >- if (xdmcpFd == -1) { >- LogError ("XDMCP socket creation failed, errno %d\n", errno); >- return; >- } >- name = localHostname (); >+ char *name = localHostname (); > registerHostname (name, strlen (name)); >- RegisterCloseOnFork (xdmcpFd); >- /* zero out the entire structure; this avoids 4.4 incompatibilities */ >- bzero ((char *) &sock_addr, sizeof (sock_addr)); >-#ifdef BSD44SOCKETS >- sock_addr.sin_len = sizeof(sock_addr); >-#endif >- sock_addr.sin_family = AF_INET; >- sock_addr.sin_port = htons ((short) request_port); >- sock_addr.sin_addr.s_addr = htonl (INADDR_ANY); >- if (bind (xdmcpFd, (struct sockaddr *)&sock_addr, sizeof (sock_addr)) == -1) >- { >- LogError ("error %d binding socket address %d\n", errno, request_port); >- close (xdmcpFd); >- xdmcpFd = -1; >- return; >- } >- WellKnownSocketsMax = xdmcpFd; >- FD_SET (xdmcpFd, &WellKnownSocketsMask); > >+#ifdef IPv6 >+ chooserFd = socket (AF_INET6, SOCK_STREAM, 0); >+#else > chooserFd = socket (AF_INET, SOCK_STREAM, 0); >+#endif > Debug ("Created chooser socket %d\n", chooserFd); > if (chooserFd == -1) > { >@@ -113,17 +88,419 @@ > char *addr, > int *lenp) > { >+#ifdef IPv6 >+ struct sockaddr_storage in_addr; >+#else > struct sockaddr_in in_addr; >+#endif > int len; >+ int retval = 0; > > len = sizeof in_addr; >+ if (chooserFd < 0) >+ return -1; /* TODO check other listening sockets */ > if (getsockname (chooserFd, (struct sockaddr *)&in_addr, (void *)&len) < 0) > return -1; >- Debug ("Chooser socket port: %d\n", ntohs(in_addr.sin_port)); >- memmove( addr, (char *) &in_addr, len); >+#ifdef IPv6 >+ if (in_addr.ss_family == AF_INET6) >+ Debug ("Chooser socket port: %d (IPv6)\n", >+ ntohs(((struct sockaddr_in6 *) &in_addr)->sin6_port)); >+ else >+#endif >+ Debug ("Chooser socket port: %d\n", >+ ntohs(((struct sockaddr_in *) &in_addr)->sin_port)); >+ if (*lenp < len) >+ retval = -2; >+ else >+ memmove( addr, (char *) &in_addr, len); > *lenp = len; > >- return 0; >+ return retval; >+} >+ >+static int >+CreateListeningSocket (struct sockaddr *sock_addr, int salen) >+{ >+ int fd; >+ const char *addrstring = "unknown"; >+#ifdef IPv6 >+ char addrbuf[INET6_ADDRSTRLEN]; >+#endif >+ >+ if (request_port == 0) >+ return -1; >+ >+ if (debugLevel > 0) { >+#ifdef IPv6 >+ void *ipaddr; >+ if (sock_addr->sa_family == AF_INET6) { >+ ipaddr = & ((struct sockaddr_in6 *) sock_addr)->sin6_addr; >+ } else { >+ ipaddr = & ((struct sockaddr_in *) sock_addr)->sin_addr; >+ } >+ addrstring = >+ inet_ntop(sock_addr->sa_family, ipaddr, addrbuf, sizeof(addrbuf)); >+ >+#else >+ addrstring = inet_ntoa(((struct sockaddr_in *) sock_addr)->sin_addr); >+#endif >+ >+ Debug ("creating socket to listen on port %d of address %s\n", >+ request_port,addrstring); >+ } >+ >+ fd = socket (sock_addr->sa_family, SOCK_DGRAM, 0); >+ >+ if (fd == -1) { >+ LogError ("XDMCP socket creation failed, errno %d\n", errno); >+ return fd; >+ } >+ RegisterCloseOnFork (fd); >+ >+ if (bind (fd, sock_addr, salen) == -1) >+ { >+ LogError ("error %d binding socket address %d\n", errno, request_port); >+ close (fd); >+ fd = -1; >+ return fd; >+ } >+ if (fd > WellKnownSocketsMax) >+ WellKnownSocketsMax = fd; >+ FD_SET (fd, &WellKnownSocketsMask); >+ return fd; >+} >+ >+struct socklist { >+ struct socklist * next; >+ struct socklist * mcastgroups; >+ struct sockaddr * addr; >+ int salen; >+ int addrlen; >+ int fd; >+ int ref; /* referenced bit - see UpdateListenSockets */ >+}; >+ >+static struct socklist *listensocks; >+ >+static void >+DestroyListeningSocket (struct socklist *s) >+{ >+ if (s->fd >= 0) { >+ FD_CLR (s->fd, &WellKnownSocketsMask); >+ close(s->fd); >+ s->fd = -1; >+ } >+ if (s->addr) { >+ free(s->addr); >+ s->addr = NULL; >+ } >+ if (s->mcastgroups) { >+ struct socklist *g, *n; >+ >+ for (g = s->mcastgroups; g != NULL; g = n) { >+ n = g->next; >+ if (g->addr) >+ free(g->addr); >+ free(g); >+ } >+ s->mcastgroups = NULL; >+ } >+} >+ >+static struct socklist* >+FindInList(struct socklist *list, ARRAY8Ptr addr) >+{ >+ struct socklist *s; >+ >+ for (s = list; s != NULL; s = s->next) { >+ if (s->addrlen == addr->length) { >+ char *addrdata; >+ >+ switch (s->addr->sa_family) { >+ case AF_INET: >+ addrdata = (char *) >+ &(((struct sockaddr_in *)s->addr)->sin_addr.s_addr); >+ break; >+#ifdef IPv6 >+ case AF_INET6: >+ addrdata = (char *) >+ &(((struct sockaddr_in6 *)s->addr)->sin6_addr.s6_addr); >+ break; >+#endif >+ default: >+ /* Unrecognized address family */ >+ continue; >+ } >+ if (memcmp(addrdata, addr->data, addr->length) == 0) { >+ return s; >+ } >+ } >+ } >+ return NULL; >+} >+ >+static struct socklist * >+CreateSocklistEntry(ARRAY8Ptr addr) >+{ >+ struct socklist *s = malloc (sizeof(struct socklist)); >+ if (s == NULL) >+ LogOutOfMem("CreateSocklistEntry"); >+ >+ bzero(s, sizeof(struct socklist)); >+ >+ if (addr->length == 4) /* IPv4 */ >+ { >+ struct sockaddr_in *sin; >+ sin = malloc (sizeof(struct sockaddr_in)); >+ if (sin == NULL) >+ LogOutOfMem("CreateSocklistEntry"); >+ s->addr = (struct sockaddr *) sin; >+ >+ bzero (sin, sizeof (struct sockaddr_in)); >+#ifdef BSD44SOCKETS >+ sin->sin_len = sizeof(struct sockaddr_in); >+#endif >+ s->salen = sizeof(struct sockaddr_in); >+ s->addrlen = sizeof(struct in_addr); >+ sin->sin_family = AF_INET; >+ sin->sin_port = htons ((short) request_port); >+ memcpy(&sin->sin_addr, addr->data, addr->length); >+ } >+#ifdef IPv6 >+ else if (addr->length == 16) /* IPv6 */ >+ { >+ struct sockaddr_in6 *sin6; >+ sin6 = malloc (sizeof(struct sockaddr_in6)); >+ if (sin6 == NULL) >+ LogOutOfMem("CreateSocklistEntry"); >+ s->addr = (struct sockaddr *) sin6; >+ >+ bzero (sin6, sizeof (struct sockaddr_in6)); >+#ifdef SIN6_LEN >+ sin6->sin6_len = sizeof(struct sockaddr_in6); >+#endif >+ s->salen = sizeof(struct sockaddr_in6); >+ s->addrlen = sizeof(struct in6_addr); >+ sin6->sin6_family = AF_INET6; >+ sin6->sin6_port = htons ((short) request_port); >+ memcpy(&sin6->sin6_addr, addr->data, addr->length); >+ } >+#endif >+ else { >+ /* Unknown address type */ >+ free(s); >+ s = NULL; >+ } >+ return s; >+} >+ >+static void >+UpdateListener(ARRAY8Ptr addr, void **closure) >+{ >+ struct socklist *s; >+ ARRAY8 tmpaddr; >+ >+ *closure = NULL; >+ >+ if (addr == NULL || addr->length == 0) { >+#ifdef IPv6 >+ struct in6_addr in6 = in6addr_any; >+ tmpaddr.length = sizeof(in6); >+ tmpaddr.data = (CARD8Ptr) &in6; >+#else >+ struct in_addr in; >+ in.s_addr = htonl (INADDR_ANY); >+ tmpaddr.length = sizeof(in); >+ tmpaddr.data = (CARD8Ptr) ∈ >+#endif >+ addr = &tmpaddr; >+ } >+ >+ s = FindInList(listensocks, addr); >+ >+ if (s) { >+ *closure = (void *) s; >+ s->ref = 1; >+ return; >+ } >+ >+ s = CreateSocklistEntry(addr); >+ >+ if (s == NULL) >+ return; >+ >+ s->fd = CreateListeningSocket(s->addr, s->salen); >+ if (s->fd < 0) { >+ free(s->addr); >+ free(s); >+ return; >+ } >+ s->ref = 1; >+ s->next = listensocks; >+ listensocks = s; >+ *closure = (void *) s; >+} >+ >+#define JOIN_MCAST_GROUP 0 >+#define LEAVE_MCAST_GROUP 1 >+ >+static void >+ChangeMcastMembership(struct socklist *s, struct socklist *g, int op) >+{ >+ int sockopt; >+ >+ switch (s->addr->sa_family) >+ { >+ case AF_INET: >+ { >+ struct ip_mreq mreq; >+ memcpy(&mreq.imr_multiaddr, >+ &((struct sockaddr_in *) g->addr)->sin_addr, >+ sizeof(struct in_addr)); >+ memcpy(&mreq.imr_interface, >+ &((struct sockaddr_in *) s->addr)->sin_addr, >+ sizeof(struct in_addr)); >+ if (op == JOIN_MCAST_GROUP) { >+ sockopt = IP_ADD_MEMBERSHIP; >+ } else { >+ sockopt = IP_DROP_MEMBERSHIP; >+ } >+ if (setsockopt(s->fd, IPPROTO_IP, sockopt, >+ &mreq, sizeof(mreq)) < 0) { >+ LogError ("XDMCP socket multicast %s to %s failed, errno %d\n", >+ (op == JOIN_MCAST_GROUP) ? "join" : "drop", >+ inet_ntoa(((struct sockaddr_in *) g->addr)->sin_addr), >+ errno); >+ return; >+ } else if (debugLevel > 0) { >+ Debug ("XDMCP socket multicast %s to %s succeeded\n", >+ (op == JOIN_MCAST_GROUP) ? "join" : "drop", >+ inet_ntoa(((struct sockaddr_in *) g->addr)->sin_addr)); >+ } >+ } >+#ifdef IPv6 >+ case AF_INET6: >+ { >+ struct ipv6_mreq mreq6; >+ memcpy(&mreq6.ipv6mr_multiaddr, >+ &((struct sockaddr_in6 *) g->addr)->sin6_addr, >+ sizeof(struct in6_addr)); >+ mreq6.ipv6mr_interface = 0; /* TODO: fix this */ >+ if (op == JOIN_MCAST_GROUP) { >+ sockopt = IPV6_ADD_MEMBERSHIP; >+ } else { >+ sockopt = IPV6_DROP_MEMBERSHIP; >+ } >+ if (setsockopt(s->fd, IPPROTO_IPV6, sockopt, >+ &mreq6, sizeof(mreq6)) < 0) { >+ int saveerr = errno; >+ char addrbuf[INET6_ADDRSTRLEN]; >+ >+ inet_ntop(s->addr->sa_family, >+ &((struct sockaddr_in6 *) g->addr)->sin6_addr, >+ addrbuf, sizeof(addrbuf)); >+ >+ LogError ("XDMCP socket multicast %s to %s failed, errno %d\n", >+ (op == JOIN_MCAST_GROUP) ? "join" : "drop", addrbuf, >+ saveerr); >+ return; >+ } else if (debugLevel > 0) { >+ char addrbuf[INET6_ADDRSTRLEN]; >+ >+ inet_ntop(s->addr->sa_family, >+ &((struct sockaddr_in6 *) g->addr)->sin6_addr, >+ addrbuf, sizeof(addrbuf)); >+ >+ Debug ("XDMCP socket multicast %s to %s succeeded\n", >+ (op == JOIN_MCAST_GROUP) ? "join" : "drop", addrbuf); >+ } >+ } >+#endif >+ } >+} >+ >+static void >+UpdateMcastGroup(ARRAY8Ptr addr, void **closure) >+{ >+ struct socklist *s = (struct socklist *) *closure; >+ struct socklist *g; >+ >+ g = FindInList(s->mcastgroups, addr); >+ >+ if (g) { /* Already in the group, mark & continue */ >+ g->ref = 1; >+ return; >+ } >+ >+ /* Need to join the group */ >+ g = CreateSocklistEntry(addr); >+ if (g == NULL) >+ return; >+ >+ ChangeMcastMembership(s, g, JOIN_MCAST_GROUP); >+} >+ >+/* Open or close listening sockets to match the current settings read in >+ from the access database. */ >+void UpdateListenSockets (void) >+{ >+ struct socklist *s, *g, **ls, **lg, *ns, *ng; >+ void *tmpPtr = NULL; >+ >+ /* Clear Ref bits - any not marked by UpdateCallback will be closed */ >+ for (s = listensocks; s != NULL; s = s->next) { >+ s->ref = 0; >+ for (g = s->mcastgroups; g != NULL ; g = g->next) { >+ g->ref = 0; >+ } >+ } >+ ForEachListenAddr(UpdateListener, UpdateMcastGroup, &tmpPtr); >+ for (s = listensocks, ls = &listensocks; s != NULL; s = ns) { >+ ns = s->next; >+ if (s->ref == 0) { >+ DestroyListeningSocket(s); >+ *ls = s->next; >+ free(s); >+ } else { >+ ls = &(s->next); >+ for (lg = &s->mcastgroups, g = *lg; g != NULL ; g = ng) { >+ ng = g->next; >+ if (g->ref == 0) { >+ ChangeMcastMembership(s,g,LEAVE_MCAST_GROUP); >+ *lg = g->next; >+ free(g); >+ } else { >+ lg = &(g->next); >+ } >+ } >+ } >+ } >+} >+ >+/* Close all additional listening sockets beyond the basic chooserFd and >+ remove them from the WellKnownSocketsMask. */ >+void CloseListenSockets (void) >+{ >+ struct socklist *s, *n; >+ >+ for (s = listensocks; s != NULL; s = n) { >+ n = s->next; >+ DestroyListeningSocket(s); >+ free(s); >+ } >+ listensocks = NULL; >+} >+ >+/* For each listening socket identified in readmask, process the incoming >+ XDMCP request */ >+void ProcessListenSockets (fd_set *readmask) >+{ >+ struct socklist *s; >+ >+ for (s = listensocks; s != NULL; s = s->next) { >+ if (FD_ISSET(s->fd, readmask)) >+ ProcessRequestSocket(s->fd); >+ } > } > > #endif /* !STREAMSCONN */ >diff -ur 4.3.0/xc/programs/xdm/streams.c 4.3.0+IPv6/xc/programs/xdm/streams.c >--- 4.3.0/xc/programs/xdm/streams.c Fri Dec 14 12:01:24 2001 >+++ 4.3.0+IPv6/xc/programs/xdm/streams.c Sat Mar 8 19:33:30 2003 >@@ -146,5 +146,24 @@ > return retval; > } > >+/* TODO: Implement support for controlling which interfaces are listened on >+ and for listening to multicast addresses. See the sockets equivalent in >+ sockets.c for details. */ >+ >+void UpdateListenSockets (void) >+{ >+ return; >+} >+ >+void CloseListenSockets (void) >+{ >+ return; >+} >+ >+void ProcessListenSockets (fd_set *readmask) >+{ >+ return; >+} >+ > #endif /* STREAMSCONN */ > #endif /* XDMCP */ >diff -ur 4.3.0/xc/programs/xdm/xdm.man 4.3.0+IPv6/xc/programs/xdm/xdm.man >--- 4.3.0/xc/programs/xdm/xdm.man Sat Oct 12 09:06:47 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/xdm.man Sat Mar 8 09:54:47 2003 >@@ -92,6 +92,13 @@ > .I chooser > or X terminals themselves. > .PP >+.I Xdm >+can be configured to ignore BroadcastQuery messages from selected hosts. >+This is useful when you don't want the host to appear in menus produced >+by >+.I chooser >+or X terminals themselves. >+.PP > Because > .I xdm > provides the first interface that users will see, it is designed to be >@@ -144,7 +151,7 @@ > At the end of the session, the \fIXreset\fP script is run to clean up, > the X server is reset, and the cycle starts over. > .PP >-The file \fI__projectroot__/lib/X11/xdm/xdm-errors\fP will contain error >+The file \fI __projectroot__/lib/X11/xdm/xdm-errors\fP will contain error > messages from > .I xdm > and anything output to stderr by \fIXsetup, Xstartup, Xsession\fP >@@ -349,6 +356,13 @@ > A file to checksum to generate the seed of authorization keys. > This should be a file that changes frequently. > The default is \fI/dev/mem\fP. >+#ifdef DEV_RANDOM >+.IP \fBDisplayManager.randomDevice\fP >+A file to read 8 bytes from to generate the seed of authorization keys. >+The default is \fI DEV_RANDOM \fP. If this file cannot be read, or if a >+read blocks for more than 5 seconds, xdm falls back to using a checksum >+of \fBDisplayManager.randomFile\fP to generate the seed. >+#endif > .IP \fBDisplayManager.greeterLib\fP > On systems that support a dynamically-loadable greeter library, the > name of the library. The default is >@@ -632,6 +646,11 @@ > This can be used to prevent an xdm server from appearing on > menus based on Broadcast queries. > .PP >+To only respond to Direct queries for a host or pattern, >+it can be followed by the optional ``NOBROADCAST'' keyword. >+This can be used to prevent an xdm server from appearing on >+menus based on Broadcast queries. >+.PP > An Indirect entry also contains a host name or pattern, > but follows it with a list of > host names or macros to which indirect queries should be sent. >@@ -686,6 +705,23 @@ > !xtra.lcs.mit.edu dummy #disallow indirect access > *.lcs.mit.edu %HOSTS #all others get to choose > .fi >+.PP >+If compiled with IPv6 support, multicast address groups may also be included >+in the list of addresses indirect queries are set to. Multicast addresses >+may be followed by an optional / character and hop count. If no hop count is >+specified, the multicast hop count defaults to 1, keeping the packet on the >+local network. For IPv4 multicasting, the hop count is used as the TTL. >+.PP >+Examples: >+.LP >+.ta 2.1i 4.5i >+.nf >+rincewind.sample.net ff02::1 #IPv6 Multicast to ff02::1 >+ #with a hop count of 1 >+ponder.sample.net CHOOSER 239.192.1.1/16 #Offer a menu of hosts >+ #who respond to IPv4 Multicast >+ # to 239.192.1.1 with a TTL of 16 >+.fi > .SH CHOOSER > .PP > For X terminals that do not offer a host menu for use with Broadcast >@@ -725,6 +761,37 @@ > \fBDisplayManager.choiceTimeout\fP seconds) and forwards the request > to the chosen host, which starts a session on that display. > .\" >+.SH LISTEN >+The following configuration directive is also defined for the Xaccess >+configuration file: >+.IP "\fBLISTEN\fP \fIinterface\fP \fI[list of multicast group addresses]\fP" >+\fIinterface\fP may be a hostname or IP addresss representing a >+network interface on this machine, or the wildcard * to represent all >+available network interfaces. >+.PP >+If one or more LISTEN lines are specified, xdm only listens for XDMCP >+connections on the specified interfaces. If multicast group addresses >+are listed on a listen line, xdm joins the multicast groups on the >+given interface. >+.PP >+If no LISTEN lines are given, the original behavior of listening on >+all interfaces is preserved for backwards compatibility. >+Additionally, if no LISTEN is specified, xdm joins the default XDMCP >+IPv6 multicast group, when compiled with IPv6 support. >+.PP >+To disable listening for XDMCP connections altogther, a line of LISTEN >+with no addresses may be specified, or the previously supported method >+of setting DisplayManager.requestPort to 0 may be used. >+.PP >+Examples: >+.ta 2i 4i >+.nf >+LISTEN * ff02::1 # Listen on all interfaces and to the >+ # ff02::1 IPv6 multicast group. >+LISTEN 10.11.12.13 # Listen only on this interface, as long >+ # as no other listen directives appear in >+ # file. >+.fi > .SH "LOCAL SERVER SPECIFICATION" > .PP > The resource \fBDisplayManager.servers\fP gives a server specification >@@ -830,6 +897,15 @@ > SHELL the value of \fBDisplayManager.\fP\fIDISPLAY\fP\fB.systemShell\fP > XAUTHORITY may be set to an authority file > .fi >+.IP "\fBxlogin.Login.allowRootLogin\fP" >+If set to ``false'', don't allow root (and any other user with uid = 0) to >+log in directly. >+The default is ``true''. >+.IP "\fBxlogin.Login.allowNullPasswd\fP" >+If set to ``true'', allow an otherwise failing password match to succeed >+if the account does not require a password at all. >+The default is ``false'', so only users that have passwords assigned can >+log in. > .PP > Note that since \fIxdm\fP grabs the keyboard, any other windows will not be > able to receive keyboard input. They will be able to interact with >diff -ur 4.3.0/xc/programs/xdm/xdmcp.c 4.3.0+IPv6/xc/programs/xdm/xdmcp.c >--- 4.3.0/xc/programs/xdm/xdmcp.c Tue Dec 10 14:37:17 2002 >+++ 4.3.0+IPv6/xc/programs/xdm/xdmcp.c Fri Apr 11 17:55:45 2003 >@@ -26,7 +26,7 @@ > from The Open Group. > > */ >-/* $XFree86: xc/programs/xdm/xdmcp.c,v 3.21 2002/12/10 22:37:17 tsi Exp $ */ >+/* $Id: xc/programs/xdm/xdmcp.c,v 3.21 2002/12/10 22:37:17 tsi Exp $ */ > > /* > * xdm - display manager daemon >@@ -55,14 +55,10 @@ > #include <un.h> > #endif > #endif >-#if defined(__SVR4) && defined(__sun) >- /* >- * make sure we get the resolver's version of gethostbyname >- * otherwise we may not get all the addresses! >- */ >-#define gethostbyname res_gethostbyname >-#endif > #include <netdb.h> >+#ifdef IPv6 >+#include <arpa/inet.h> >+#endif > > #include <time.h> > #define Time_t time_t >@@ -72,27 +68,28 @@ > /* > * misc externs > */ >-extern int Rescan, ChildReady; >-extern int sourceAddress; >+extern volatile int Rescan; >+extern int sourceAddress, ChildReady; > > /* > * Forward reference > */ >-static void broadcast_respond (struct sockaddr *from, int fromlen, int length); >-static void forward_respond (struct sockaddr *from, int fromlen, int length); >-static void manage (struct sockaddr *from, int fromlen, int length); >-static void query_respond (struct sockaddr *from, int fromlen, int length); >-static void request_respond (struct sockaddr *from, int fromlen, int length); >-static void send_accept (struct sockaddr *to, int tolen, CARD32 sessionID, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr authorizationName, ARRAY8Ptr authorizationData); >-static void send_alive (struct sockaddr *from, int fromlen, int length); >-static void send_decline (struct sockaddr *to, int tolen, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr status); >-static void send_failed (struct sockaddr *from, int fromlen, char *name, CARD32 sessionID, char *reason); >-static void send_refuse (struct sockaddr *from, int fromlen, CARD32 sessionID); >-static void send_unwilling (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status); >-static void send_willing (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status); >- >+static void broadcast_respond (struct sockaddr *from, int fromlen, int length, int fd); >+static void forward_respond (struct sockaddr *from, int fromlen, int length, int fd); >+static void manage (struct sockaddr *from, int fromlen, int length, int fd); >+static void query_respond (struct sockaddr *from, int fromlen, int length, int fd); >+static void request_respond (struct sockaddr *from, int fromlen, int length, int fd); >+static void send_accept (struct sockaddr *to, int tolen, CARD32 sessionID, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr authorizationName, ARRAY8Ptr authorizationData, int fd); >+static void send_alive (struct sockaddr *from, int fromlen, int length, int fd); >+static void send_decline (struct sockaddr *to, int tolen, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr status, int fd); >+static void send_failed (struct sockaddr *from, int fromlen, char *name, CARD32 sessionID, char *reason, int fd); >+static void send_refuse (struct sockaddr *from, int fromlen, CARD32 sessionID, int fd); >+static void send_unwilling (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status, int fd); >+static void send_willing (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status, int fd); > >+#ifdef STREAMSCONN > int xdmcpFd = -1; >+#endif > int chooserFd = -1; > > FD_TYPE WellKnownSocketsMask; >@@ -103,22 +100,44 @@ > void > DestroyWellKnownSockets (void) > { >+#ifdef STREAMSCONN > if (xdmcpFd != -1) > { > close (xdmcpFd); >+ FD_CLR(xdmcpFd, &WellKnownSocketsMask); > xdmcpFd = -1; > } >+#endif > if (chooserFd != -1) > { > close (chooserFd); >+ FD_CLR(chooserFd, &WellKnownSocketsMask); > chooserFd = -1; > } >+ CloseListenSockets(); >+} >+ >+static int >+FD_ANYSET(fd_set *fds) >+{ >+ int i; >+ char *mask = (char *) fds; >+ >+ for (i = 0 ; i < sizeof(fds); i++) { >+ if (mask[i]) >+ return TRUE; >+ } >+ return FALSE; > } > > int > AnyWellKnownSockets (void) > { >- return xdmcpFd != -1 || chooserFd != -1; >+ return >+#ifdef STREAMS_CONN >+ xdmcpFd != -1 || >+#endif >+ chooserFd != -1 || FD_ANYSET(&WellKnownSocketsMask); > } > > static XdmcpBuffer buffer; >@@ -133,6 +152,9 @@ > #ifdef AF_INET > struct sockaddr_in in_addr; > #endif >+#ifdef IPv6 >+ struct sockaddr_in6 in6_addr; >+#endif > #ifdef AF_DECnet > #endif > struct sockaddr *addr; >@@ -155,13 +177,28 @@ > addrlen = sizeof (struct sockaddr_in); > break; > #endif >+#ifdef IPv6 >+ case FamilyInternetV6: >+ addr = (struct sockaddr *) &in6_addr; >+ bzero ((char *) &in6_addr, sizeof (in6_addr)); >+#ifdef SIN6_LEN >+ in6_addr.sin6_len = sizeof(in6_addr); >+#endif >+ in6_addr.sin6_family = AF_INET6; >+ in6_addr.sin6_port = htons ((short) XDM_UDP_PORT); >+ if (address->length != 16) >+ return; >+ memmove( (char *) &in6_addr.sin6_addr, address->data, address->length); >+ addrlen = sizeof (struct sockaddr_in6); >+ break; >+#endif > #ifdef AF_DECnet > case FamilyDECnet: > #endif > default: > return; > } >- XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) addr, addrlen); >+ XdmcpFlush (*((int *) closure), &buffer, (XdmcpNetaddr) addr, addrlen); > return; > } > >@@ -193,7 +230,8 @@ > struct sockaddr *from, > int fromlen, > ARRAYofARRAY8Ptr authenticationNames, >- xdmOpCode type) >+ xdmOpCode type, >+ int fd) > { > ARRAY8Ptr authenticationName; > ARRAY8 status; >@@ -217,10 +255,10 @@ > > authenticationName = ChooseAuthentication (authenticationNames); > if (Willing (&addr, connectionType, authenticationName, &status, type)) >- send_willing (from, fromlen, authenticationName, &status); >+ send_willing (from, fromlen, authenticationName, &status, fd); > else > if (type == QUERY) >- send_unwilling (from, fromlen, authenticationName, &status); >+ send_unwilling (from, fromlen, authenticationName, &status, fd); > XdmcpDisposeARRAY8 (&status); > } > >@@ -228,7 +266,8 @@ > indirect_respond ( > struct sockaddr *from, > int fromlen, >- int length) >+ int length, >+ int fd) > { > ARRAYofARRAY8 queryAuthenticationNames; > ARRAY8 clientAddress; >@@ -264,13 +303,13 @@ > XdmcpWriteARRAY8 (&buffer, &clientPort); > XdmcpWriteARRAYofARRAY8 (&buffer, &queryAuthenticationNames); > >- localHostAsWell = ForEachMatchingIndirectHost (&clientAddress, connectionType, sendForward, (char *) 0); >+ localHostAsWell = ForEachMatchingIndirectHost (&clientAddress, connectionType, sendForward, (char *) &fd); > > XdmcpDisposeARRAY8 (&clientAddress); > XdmcpDisposeARRAY8 (&clientPort); > if (localHostAsWell) > all_query_respond (from, fromlen, &queryAuthenticationNames, >- INDIRECT_QUERY); >+ INDIRECT_QUERY, fd); > } > else > { >@@ -279,16 +318,20 @@ > XdmcpDisposeARRAYofARRAY8 (&queryAuthenticationNames); > } > >-static void >-ProcessRequestSocket (void) >+void >+ProcessRequestSocket (int fd) > { > XdmcpHeader header; >+#ifdef IPv6 >+ struct sockaddr_storage addr; >+#else > struct sockaddr addr; >+#endif > int addrlen = sizeof addr; > > Debug ("ProcessRequestSocket\n"); > bzero ((char *) &addr, sizeof (addr)); >- if (!XdmcpFill (xdmcpFd, &buffer, (XdmcpNetaddr) &addr, &addrlen)) { >+ if (!XdmcpFill (fd, &buffer, (XdmcpNetaddr) &addr, &addrlen)) { > Debug ("XdmcpFill failed\n"); > return; > } >@@ -305,25 +348,25 @@ > switch (header.opcode) > { > case BROADCAST_QUERY: >- broadcast_respond (&addr, addrlen, header.length); >+ broadcast_respond ((struct sockaddr *) &addr, addrlen, header.length, fd); > break; > case QUERY: >- query_respond (&addr, addrlen, header.length); >+ query_respond ((struct sockaddr *) &addr, addrlen, header.length, fd); > break; > case INDIRECT_QUERY: >- indirect_respond (&addr, addrlen, header.length); >+ indirect_respond ((struct sockaddr *) &addr, addrlen, header.length, fd); > break; > case FORWARD_QUERY: >- forward_respond (&addr, addrlen, header.length); >+ forward_respond ((struct sockaddr *) &addr, addrlen, header.length, fd); > break; > case REQUEST: >- request_respond (&addr, addrlen, header.length); >+ request_respond ((struct sockaddr *) &addr, addrlen, header.length, fd); > break; > case MANAGE: >- manage (&addr, addrlen, header.length); >+ manage ((struct sockaddr *) &addr, addrlen, header.length, fd); > break; > case KEEPALIVE: >- send_alive (&addr, addrlen, header.length); >+ send_alive ((struct sockaddr *) &addr, addrlen, header.length, fd); > break; > } > } >@@ -342,15 +385,21 @@ > nready, Rescan, ChildReady); > if (nready > 0) > { >+#ifdef STREAMSCONN > if (xdmcpFd >= 0 && FD_ISSET (xdmcpFd, &reads)) > ProcessRequestSocket (); >+#endif > if (chooserFd >= 0 && FD_ISSET (chooserFd, &reads)) >+ { > #ifdef ISC > if (!ChildReady) { > WaitForSomething (); > } else > #endif > ProcessChooserSocket (chooserFd); >+ FD_CLR(chooserFd, &reads); >+ } >+ ProcessListenSockets(&reads); > } > if (ChildReady) > { >@@ -384,7 +433,8 @@ > struct sockaddr *from, > int fromlen, > int length, >- xdmOpCode type) >+ xdmOpCode type, >+ int fd) > { > ARRAYofARRAY8 queryAuthenticationNames; > int expectedLen; >@@ -396,7 +446,7 @@ > for (i = 0; i < (int)queryAuthenticationNames.length; i++) > expectedLen += 2 + queryAuthenticationNames.data[i].length; > if (length == expectedLen) >- all_query_respond (from, fromlen, &queryAuthenticationNames, type); >+ all_query_respond (from, fromlen, &queryAuthenticationNames, type, fd); > XdmcpDisposeARRAYofARRAY8 (&queryAuthenticationNames); > } > >@@ -404,19 +454,21 @@ > query_respond ( > struct sockaddr *from, > int fromlen, >- int length) >+ int length, >+ int fd) > { > Debug ("Query respond %d\n", length); >- direct_query_respond (from, fromlen, length, QUERY); >+ direct_query_respond (from, fromlen, length, QUERY, fd); > } > > static void > broadcast_respond ( > struct sockaddr *from, > int fromlen, >- int length) >+ int length, >+ int fd) > { >- direct_query_respond (from, fromlen, length, BROADCAST_QUERY); >+ direct_query_respond (from, fromlen, length, BROADCAST_QUERY, fd); > } > > /* computes an X display name */ >@@ -431,6 +483,113 @@ > switch (connectionType) > { > case FamilyInternet: >+#ifdef IPv6 >+ case FamilyInternetV6: >+ { >+ CARD8 *data; >+ struct hostent *hostent; >+ char *hostname = NULL; >+ char *name; >+ char *localhost; >+ int multiHomed = 0; >+ struct addrinfo hints, *ai = NULL, *nai; >+ int type; >+ >+ if (connectionType == FamilyInternetV6) >+ type = AF_INET6; >+ else >+ type = AF_INET; >+ >+ data = connectionAddress->data; >+ hostent = gethostbyaddr ((char *)data, >+ connectionAddress->length, type); >+ if (hostent) { >+ if (sourceAddress) { >+ bzero(&hints, sizeof(hints)); >+ hints.ai_flags = AI_CANONNAME; >+ if (getaddrinfo(hostent->h_name, NULL, &hints, &ai) == 0) { >+ hostname = ai->ai_canonname; >+ while ((nai = ai->ai_next) != NULL) { >+ if ((ai->ai_protocol == nai->ai_protocol) && >+ (ai->ai_addrlen == nai->ai_addrlen) && >+ (memcmp(ai->ai_addr,nai->ai_addr, >+ ai->ai_addrlen) != 0) ) { >+ multiHomed = 1; >+ } >+ } >+ } >+ } else { >+ hostname = hostent->h_name; >+ } >+ } >+ >+ localhost = localHostname (); >+ >+ /* >+ * protect against bogus host names >+ */ >+ if (hostname && hostname[0] && (hostname[0] != '.') >+ && !multiHomed) >+ { >+ if (!strcmp (localhost, hostname)) >+ { >+ if (!getString (name, 10)) >+ return 0; >+ sprintf (name, ":%d", displayNumber); >+ } >+ else >+ { >+ if (removeDomainname) >+ { >+ char *localDot, *remoteDot; >+ >+ /* check for a common domain name. This >+ * could reduce names by recognising common >+ * super-domain names as well, but I don't think >+ * this is as useful, and will confuse more >+ * people >+ */ >+ if ((localDot = strchr(localhost, '.')) && >+ (remoteDot = strchr(hostname, '.'))) >+ { >+ /* smash the name in place; it won't >+ * be needed later. >+ */ >+ if (!strcmp (localDot+1, remoteDot+1)) >+ *remoteDot = '\0'; >+ } >+ } >+ >+ if (!getString (name, strlen (hostname) + 10)) >+ return 0; >+ sprintf (name, "%s:%d", hostname, displayNumber); >+ } >+ } >+ else >+ { >+ if (!getString (name, INET6_ADDRSTRLEN + 10)) >+ return 0; >+ if (multiHomed) { >+ if (connectionType == FamilyInternet) { >+ data = (CARD8 *) >+ &((struct sockaddr_in *)originalAddress)-> >+ sin_addr; >+ } else { >+ data = (CARD8 *) >+ &((struct sockaddr_in6 *)originalAddress)->sin6_addr; >+ } >+ } >+ if (inet_ntop(type, data, name, INET6_ADDRSTRLEN) == NULL) { >+ free(name); >+ return 0; >+ } >+ sprintf(name + strlen(name), ":%d", displayNumber); >+ } >+ if (ai) >+ freeaddrinfo(ai); >+ return name; >+ } >+#else /* IPv6 */ > { > CARD8 *data; > struct hostent *hostent; >@@ -502,6 +661,7 @@ > } > return name; > } >+#endif /* IPv6 */ > #ifdef DNET > case FamilyDECnet: > return NULL; >@@ -516,7 +676,8 @@ > forward_respond ( > struct sockaddr *from, > int fromlen, >- int length) >+ int length, >+ int fd) > { > ARRAY8 clientAddress; > ARRAY8 clientPort; >@@ -576,7 +737,31 @@ > client = (struct sockaddr *) &in_addr; > clientlen = sizeof (in_addr); > all_query_respond (client, clientlen, &authenticationNames, >- FORWARD_QUERY); >+ FORWARD_QUERY, fd); >+ } >+ break; >+#endif >+#ifdef IPv6 >+ case AF_INET6: >+ { >+ struct sockaddr_in6 in6_addr; >+ >+ if (clientAddress.length != 16 || >+ clientPort.length != 2) >+ { >+ goto badAddress; >+ } >+ bzero ((char *) &in6_addr, sizeof (in6_addr)); >+#ifdef SIN6_LEN >+ in6_addr.sin6_len = sizeof(in6_addr); >+#endif >+ in6_addr.sin6_family = AF_INET6; >+ memmove(&in6_addr,clientAddress.data,clientAddress.length); >+ memmove((char *) &in6_addr.sin6_port, clientPort.data, 2); >+ client = (struct sockaddr *) &in6_addr; >+ clientlen = sizeof (in6_addr); >+ all_query_respond (client, clientlen, &authenticationNames, >+ FORWARD_QUERY, fd); > } > break; > #endif >@@ -599,7 +784,7 @@ > clientlen = sizeof (un_addr); > #endif > all_query_respond (client, clientlen, &authenticationNames, >- FORWARD_QUERY); >+ FORWARD_QUERY, fd); > } > break; > #endif >@@ -629,7 +814,8 @@ > struct sockaddr *from, > int fromlen, > ARRAY8Ptr authenticationName, >- ARRAY8Ptr status) >+ ARRAY8Ptr status, >+ int fd) > { > XdmcpHeader header; > >@@ -647,7 +833,7 @@ > XdmcpWriteARRAY8 (&buffer, authenticationName); > XdmcpWriteARRAY8 (&buffer, &Hostname); > XdmcpWriteARRAY8 (&buffer, status); >- XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen); >+ XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen); > } > > static void >@@ -655,7 +841,8 @@ > struct sockaddr *from, > int fromlen, > ARRAY8Ptr authenticationName, >- ARRAY8Ptr status) >+ ARRAY8Ptr status, >+ int fd) > { > XdmcpHeader header; > >@@ -671,7 +858,7 @@ > XdmcpWriteHeader (&buffer, &header); > XdmcpWriteARRAY8 (&buffer, &Hostname); > XdmcpWriteARRAY8 (&buffer, status); >- XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen); >+ XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen); > } > > static unsigned long globalSessionID; >@@ -696,7 +883,8 @@ > request_respond ( > struct sockaddr *from, > int fromlen, >- int length) >+ int length, >+ int fd) > { > CARD16 displayNumber; > ARRAY16 connectionTypes; >@@ -821,14 +1009,14 @@ > &authenticationName, > &authenticationData, > &authorizationName, >- &authorizationData); >+ &authorizationData, fd); > } > else > { > decline: ; > send_decline (from, fromlen, &authenticationName, > &authenticationData, >- reason); >+ reason, fd); > if (pdpy) > DisposeProtoDisplay (pdpy); > } >@@ -850,7 +1038,8 @@ > ARRAY8Ptr authenticationName, > ARRAY8Ptr authenticationData, > ARRAY8Ptr authorizationName, >- ARRAY8Ptr authorizationData) >+ ARRAY8Ptr authorizationData, >+ int fd) > { > XdmcpHeader header; > >@@ -868,7 +1057,7 @@ > XdmcpWriteARRAY8 (&buffer, authenticationData); > XdmcpWriteARRAY8 (&buffer, authorizationName); > XdmcpWriteARRAY8 (&buffer, authorizationData); >- XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) to, tolen); >+ XdmcpFlush (fd, &buffer, (XdmcpNetaddr) to, tolen); > } > > static void >@@ -877,7 +1066,8 @@ > int tolen, > ARRAY8Ptr authenticationName, > ARRAY8Ptr authenticationData, >- ARRAY8Ptr status) >+ ARRAY8Ptr status, >+ int fd) > { > XdmcpHeader header; > >@@ -892,14 +1082,15 @@ > XdmcpWriteARRAY8 (&buffer, status); > XdmcpWriteARRAY8 (&buffer, authenticationName); > XdmcpWriteARRAY8 (&buffer, authenticationData); >- XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) to, tolen); >+ XdmcpFlush (fd, &buffer, (XdmcpNetaddr) to, tolen); > } > > static void > manage ( > struct sockaddr *from, > int fromlen, >- int length) >+ int length, >+ int fd) > { > CARD32 sessionID; > CARD16 displayNumber; >@@ -949,7 +1140,7 @@ > Debug ("Session ID %ld refused\n", (long) sessionID); > if (pdpy) > Debug ("Existing Session ID %ld\n", (long) pdpy->sessionID); >- send_refuse (from, fromlen, sessionID); >+ send_refuse (from, fromlen, sessionID, fd); > } > else > { >@@ -960,7 +1151,8 @@ > Debug ("Computed display name: %s\n", name); > if (!name) > { >- send_failed (from, fromlen, "(no name)", sessionID, "out of memory"); >+ send_failed (from, fromlen, "(no name)", sessionID, >+ "out of memory", fd); > goto abort; > } > d = FindDisplayByName (name); >@@ -972,7 +1164,8 @@ > class = malloc (displayClass.length + 1); > if (!class) > { >- send_failed (from, fromlen, name, sessionID, "out of memory"); >+ send_failed (from, fromlen, name, sessionID, >+ "out of memory", fd); > goto abort; > } > if (displayClass.length) >@@ -988,7 +1181,8 @@ > from_save = (XdmcpNetaddr) malloc (fromlen); > if (!from_save) > { >- send_failed (from, fromlen, name, sessionID, "out of memory"); >+ send_failed (from, fromlen, name, sessionID, >+ "out of memory", fd); > goto abort; > } > memmove( from_save, from, fromlen); >@@ -996,7 +1190,8 @@ > if (!d) > { > free ((char *) from_save); >- send_failed (from, fromlen, name, sessionID, "out of memory"); >+ send_failed (from, fromlen, name, sessionID, >+ "out of memory", fd); > goto abort; > } > d->displayType.location = Foreign; >@@ -1008,6 +1203,7 @@ > d->displayNumber = pdpy->displayNumber; > ClientAddress (from, &clientAddress, &clientPort, &connectionType); > d->useChooser = 0; >+ d->xdmcpFd = fd; > if (IsIndirectClient (&clientAddress, connectionType)) > { > Debug ("IsIndirectClient\n"); >@@ -1028,7 +1224,8 @@ > { > free ((char *) from_save); > free ((char *) d); >- send_failed (from, fromlen, name, sessionID, "out of memory"); >+ send_failed (from, fromlen, name, sessionID, >+ "out of memory", fd); > goto abort; > } > d->authorizations[0] = pdpy->fileAuthorization; >@@ -1052,7 +1249,8 @@ > char *reason) > { > Debug ("Display start failed, sending Failed\n"); >- send_failed ((struct sockaddr *)(d->from), d->fromlen, d->name, d->sessionID, reason); >+ send_failed ((struct sockaddr *)(d->from), d->fromlen, d->name, >+ d->sessionID, reason, d->xdmcpFd); > } > > static void >@@ -1061,7 +1259,8 @@ > int fromlen, > char *name, > CARD32 sessionID, >- char *reason) >+ char *reason, >+ int fd) > { > static char buf[256]; > XdmcpHeader header; >@@ -1078,14 +1277,15 @@ > XdmcpWriteHeader (&buffer, &header); > XdmcpWriteCARD32 (&buffer, sessionID); > XdmcpWriteARRAY8 (&buffer, &status); >- XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen); >+ XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen); > } > > static void > send_refuse ( > struct sockaddr *from, > int fromlen, >- CARD32 sessionID) >+ CARD32 sessionID, >+ int fd) > { > XdmcpHeader header; > >@@ -1095,14 +1295,15 @@ > header.length = 4; > XdmcpWriteHeader (&buffer, &header); > XdmcpWriteCARD32 (&buffer, sessionID); >- XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen); >+ XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen); > } > > static void > send_alive ( > struct sockaddr *from, > int fromlen, >- int length) >+ int length, >+ int fd) > { > CARD32 sessionID; > CARD16 displayNumber; >@@ -1136,7 +1337,7 @@ > XdmcpWriteHeader (&buffer, &header); > XdmcpWriteCARD8 (&buffer, sendRunning); > XdmcpWriteCARD32 (&buffer, sendSessionID); >- XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen); >+ XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen); > } > } > } >@@ -1151,16 +1352,55 @@ > switch (connectionType) > { > case FamilyInternet: >+#ifdef IPv6 >+ case FamilyInternetV6: >+#endif > { > struct hostent *hostent = NULL; >+#ifdef IPv6 >+ char dotted[INET6_ADDRSTRLEN]; >+#else > char dotted[20]; >+#endif > char *local_name = ""; >+ int af_type; >+ >+#ifdef IPv6 >+ if (connectionType == FamilyInternetV6) >+ af_type = AF_INET6; >+ else >+#endif >+ af_type = AF_INET; > > hostent = gethostbyaddr ((char *)connectionAddress->data, >- connectionAddress->length, AF_INET); >+ connectionAddress->length, af_type); > > if (hostent) { > /* check for DNS spoofing */ >+#ifdef IPv6 >+ struct addrinfo *ai = NULL, *nai; >+ if (getaddrinfo(hostent->h_name, NULL, NULL, &ai) == 0) { >+ while ((nai = ai->ai_next) != NULL) { >+ if ((af_type == nai->ai_family) && >+ (connectionAddress->length == nai->ai_addrlen) && >+ (memcmp(connectionAddress->data,nai->ai_addr, >+ nai->ai_addrlen) != 0) ) { >+ break; >+ } >+ } >+ if (nai == NULL) { >+ inet_ntop(af_type, connectionAddress->data, >+ dotted, sizeof(dotted)); >+ >+ LogError("Possible DNS spoof attempt %s->%s.", dotted, >+ hostent->h_name); >+ hostent = NULL; >+ } >+ freeaddrinfo(ai); >+ } else { >+ hostent = NULL; >+ } >+#else > char *s = strdup(hostent->h_name); /* fscking non-reentrancy of getXXX() */ > if ((hostent = gethostbyname(s))) { > if (memcmp((char*)connectionAddress->data, hostent->h_addr, >@@ -1172,15 +1412,21 @@ > } > } > free(s); >+#endif > } > > if (!hostent) { > /* can't get name, so use emergency fallback */ >+#ifdef IPv6 >+ inet_ntop(af_type, connectionAddress->data, >+ dotted, sizeof(dotted)); >+#else > sprintf(dotted, "%d.%d.%d.%d", > connectionAddress->data[0], > connectionAddress->data[1], > connectionAddress->data[2], > connectionAddress->data[3]); >+#endif > local_name = dotted; > LogError ("Cannot convert Internet address %s to host name\n", > dotted); >@@ -1198,7 +1444,7 @@ > break; > } > return name; >- } >+} > > #if 0 > static int >diff -ur 4.3.0/xc/programs/xfs/os/access.c 4.3.0+IPv6/xc/programs/xfs/os/access.c >--- 4.3.0/xc/programs/xfs/os/access.c Fri Dec 14 12:01:40 2001 >+++ 4.3.0+IPv6/xc/programs/xfs/os/access.c Sun Mar 23 11:10:09 2003 >@@ -76,10 +76,12 @@ > MaxClients = num; > } > >+#ifdef NOTDEF > /* > * XXX > * > * needs massive amounts of OS-dependent work (big surprise) >+ * needs IPv6 support as well > */ > int > GetHostAddress(HostAddress *addr) >@@ -102,6 +104,7 @@ > } > return FSSuccess; > } >+#endif > > /* ARGSUSED */ > int >diff -ur 4.3.0/xc/programs/xfs/os/connection.c 4.3.0+IPv6/xc/programs/xfs/os/connection.c >--- 4.3.0/xc/programs/xfs/os/connection.c Mon Oct 14 18:45:03 2002 >+++ 4.3.0+IPv6/xc/programs/xfs/os/connection.c Sat Mar 1 23:34:42 2003 >@@ -69,6 +69,7 @@ > */ > /* $XFree86: xc/programs/xfs/os/connection.c,v 3.25 2002/10/15 01:45:03 dawes Exp $ */ > >+#include <stdlib.h> > #include <X11/Xtrans.h> > #include <stdlib.h> > #include "misc.h" >diff -ur 4.3.0/xc/programs/xhost/xhost.c 4.3.0+IPv6/xc/programs/xhost/xhost.c >--- 4.3.0/xc/programs/xhost/xhost.c Fri Dec 14 12:01:45 2001 >+++ 4.3.0+IPv6/xc/programs/xhost/xhost.c Sat Apr 12 15:28:44 2003 >@@ -1,4 +1,5 @@ > /* $Xorg: xhost.c,v 1.4 2001/02/09 02:05:46 xorgcvs Exp $ */ >+/* Updated for IPv6 */ > /* > > Copyright 1985, 1986, 1987, 1998 The Open Group >@@ -43,6 +44,7 @@ > #include <X11/Xproto.h> > #include <X11/Xfuncs.h> > #include <stdio.h> >+#include <stdlib.h> > #include <signal.h> > #ifdef X_NOT_POSIX > #include <setjmp.h> >@@ -123,7 +125,7 @@ > > #define NAMESERVER_TIMEOUT 5 /* time to wait for nameserver */ > >-int nameserver_timedout; >+volatile int nameserver_timedout; > > char *ProgramName; > >@@ -143,6 +145,9 @@ > #endif > #ifdef AF_INET > { AF_INET, FamilyInternet }, >+#ifdef IPv6 >+ { AF_INET6, FamilyInternetV6 }, >+#endif > #endif > }; > >@@ -202,6 +207,9 @@ > case FamilyInternet: > printf("INET:"); > break; >+ case FamilyInternetV6: >+ printf("INETV6:"); >+ break; > case FamilyDECnet: > printf("DNET:"); > break; >@@ -286,7 +294,6 @@ > static int > change_host(Display *dpy, char *name, Bool add) > { >- struct hostent *hp; > XHostAddress ha; > char *lname; > int namelen, i, family = FamilyWild; >@@ -297,6 +304,11 @@ > #ifdef NEEDSOCKETS > #ifndef AMTCPCONN > static struct in_addr addr; /* so we can point at it */ >+#ifdef IPv6 >+ static struct in6_addr addr6; /* so we can point at it */ >+#else >+ struct hostent *hp; >+#endif > #else > static ipaddr_t addr; > #endif >@@ -328,6 +340,15 @@ > return 0; > #endif > } >+ if (!strncmp("inetv6:", lname, 7)) { >+#if (defined(TCPCONN) || defined(STREAMSCONN)) && defined(IPv6) >+ family = FamilyInternetV6; >+ name += 7; >+#else >+ fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName); >+ return 0; >+#endif >+ } > if (!strncmp("dnet:", lname, 5)) { > #ifdef DNETCONN > family = FamilyDECnet; >@@ -491,6 +512,67 @@ > } > return 1; > } >+#ifdef IPv6 >+ /* >+ * Check to see if inet_pton() can grok it as an IPv6 address >+ */ >+ else if (inet_pton(AF_INET6, name, &addr6.s6_addr) == 1) { >+ ha.family = FamilyInternetV6; >+ ha.length = sizeof(addr6.s6_addr); >+ ha.address = (char *) &addr6.s6_addr; >+ if (add) { >+ XAddHost (dpy, &ha); >+ printf ("%s %s\n", name, add_msg); >+ } else { >+ XRemoveHost (dpy, &ha); >+ printf ("%s %s\n", name, remove_msg); >+ } >+ return 1; >+ } else { >+ /* >+ * Is it in the namespace? >+ * >+ * If no family was specified, use both Internet v4 & v6 addresses. >+ * Otherwise, use only addresses matching specified family. >+ */ >+ struct addrinfo *addresses; >+ struct addrinfo *a; >+ >+ if (getaddrinfo(name, NULL, NULL, &addresses) != 0) >+ return 0; >+ >+ for (a = addresses; a != NULL; a = a->ai_next) { >+ if ( ((a->ai_family == AF_INET) && (family != FamilyInternetV6)) >+ || ((a->ai_family == AF_INET6) && (family != FamilyInternet)) ) { >+ char ad[INET6_ADDRSTRLEN]; >+ ha.family = XFamily(a->ai_family); >+ if (a->ai_family == AF_INET6) { >+ ha.address = (char *) >+ &((struct sockaddr_in6 *) a->ai_addr)->sin6_addr; >+ ha.length = >+ sizeof (((struct sockaddr_in6 *) a->ai_addr)->sin6_addr); >+ } else { >+ ha.address = (char *) >+ &((struct sockaddr_in *) a->ai_addr)->sin_addr; >+ ha.length = >+ sizeof (((struct sockaddr_in *) a->ai_addr)->sin_addr); >+ } >+ inet_ntop(a->ai_family, ha.address, ad, sizeof(ad)); >+ /* printf("Family: %d\nLength: %d\n", a->ai_family, ha.length); */ >+ /* printf("Address: %s\n", ad); */ >+ >+ if (add) { >+ XAddHost (dpy, &ha); >+ } else { >+ XRemoveHost (dpy, &ha); >+ } >+ } >+ } >+ printf ("%s %s\n", name, add ? add_msg : remove_msg); >+ freeaddrinfo(addresses); >+ return 1; >+ } >+#else /* !IPv6 */ > /* > * Is it in the namespace? > */ >@@ -525,6 +607,7 @@ > printf ("%s %s\n", name, add ? add_msg : remove_msg); > return 1; > } >+#endif /* IPv6 */ > #else /* NEEDSOCKETS */ > return 0; > #endif /* NEEDSOCKETS */ >@@ -544,7 +627,7 @@ > static char * > get_hostname(XHostAddress *ha) > { >-#if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN) >+#if (defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)) && !defined(IPv6) > static struct hostent *hp = NULL; > #endif > #ifdef DNETCONN >@@ -562,6 +645,61 @@ > #endif > > #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN) >+#ifdef IPv6 >+ if ((ha->family == FamilyInternet) || (ha->family == FamilyInternetV6)) { >+ struct sockaddr_storage saddr; >+ static char inetname[NI_MAXHOST]; >+ int saddrlen; >+ >+ inetname[0] = '\0'; >+ if (ha->family == FamilyInternet) { >+ struct sockaddr_in *sin = (struct sockaddr_in *) &saddr; >+#ifdef BSD44SOCKETS >+ sin->sin_len = sizeof(sin); >+#endif >+ sin->sin_family = AF_INET; >+ sin->sin_port = 0; >+ memcpy(&sin->sin_addr, ha->address, sizeof(sin->sin_addr)); >+ saddrlen = sizeof(struct sockaddr_in); >+ } else { >+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) &saddr; >+#ifdef SIN6_LEN >+ sin6->sin6_len = sizeof(sin6); >+#endif >+ sin6->sin6_family = AF_INET6; >+ sin6->sin6_port = 0; >+ memcpy(&sin6->sin6_addr, ha->address, sizeof(sin6->sin6_addr)); >+ saddrlen = sizeof(struct sockaddr_in6); >+ } >+ >+ /* gethostbyaddr can take a LONG time if the host does not exist. >+ Assume that if it does not respond in NAMESERVER_TIMEOUT seconds >+ that something is wrong and do not make the user wait. >+ gethostbyaddr will continue after a signal, so we have to >+ jump out of it. >+ */ >+#ifndef X_NOT_POSIX >+ memset(&sa, 0, sizeof sa); >+ sa.sa_handler = nameserver_lost; >+ sa.sa_flags = 0; /* don't restart syscalls */ >+ sigaction(SIGALRM, &sa, NULL); >+#else >+ signal(SIGALRM, nameserver_lost); >+#endif >+ alarm(NAMESERVER_TIMEOUT); >+#ifdef X_NOT_POSIX >+ if (setjmp(env) == 0) >+#endif >+ { >+ getnameinfo((struct sockaddr *) &saddr, saddrlen, inetname, >+ sizeof(inetname), NULL, 0, 0); >+ } >+ alarm(0); >+ if (nameserver_timedout || inetname[0] == '\0') >+ inet_ntop(saddr.ss_family, ha->address, inetname, sizeof(inetname)); >+ return inetname; >+ } >+#else > if (ha->family == FamilyInternet) { > #ifdef CRAY > struct in_addr t_addr; >@@ -600,6 +738,7 @@ > else return (inet_ntoa(*((ipaddr_t *)(ha->address)))); > #endif > } >+#endif /* IPv6 */ > #endif > if (ha->family == FamilyNetname) { > static char netname[512]; >diff -ur 4.3.0/xc/programs/xhost/xhost.man 4.3.0+IPv6/xc/programs/xhost/xhost.man >--- 4.3.0/xc/programs/xhost/xhost.man Fri Dec 14 12:01:45 2001 >+++ 4.3.0+IPv6/xc/programs/xhost/xhost.man Sun Mar 2 18:37:29 2003 >@@ -85,7 +85,8 @@ > .PP > .nf > .ta 1i >-inet Internet host >+inet Internet host (IPv4) >+inetv6 Internet host (IPv6) > dnet DECnet host > nis Secure RPC network name > krb Kerberos V5 principal >@@ -102,7 +103,9 @@ > .PP > For backward compatibility with pre-R6 \fIxhost\fP, > names that contain an at-sign (@) are assumed to be in the nis family. >-Otherwise the inet family is assumed. >+Otherwise they are assumed to be Internet addresses. If compiled to support >+IPv6, then all IPv4 and IPv6 addresses returned by getaddrinfo(3) are added to >+the access list in the appropriate inet or inetv6 family. > .SH DIAGNOSTICS > For each name added to the access control list, > a line of the form "\fIname\fP being added to access control list" >@@ -113,7 +116,7 @@ > .SH FILES > /etc/X*.hosts > .SH "SEE ALSO" >-X(__miscmansuffix__), Xsecurity(__miscmansuffix__), Xserver(1), xdm(1) >+X(__miscmansuffix__), Xsecurity(__miscmansuffix__), Xserver(1), xdm(1), getaddrinfo(3) > .SH ENVIRONMENT > .TP 8 > .B DISPLAY >diff -ur 4.3.0/xc/programs/xlogo/RenderLogo.c 4.3.0+IPv6/xc/programs/xlogo/RenderLogo.c >--- 4.3.0/xc/programs/xlogo/RenderLogo.c Sat Oct 19 12:15:32 2002 >+++ 4.3.0+IPv6/xc/programs/xlogo/RenderLogo.c Tue Mar 4 10:25:00 2003 >@@ -156,7 +156,7 @@ > #ifdef __GNUC__ > fprintf(stderr, "%s: intersection is off by: %f\n", __FUNCTION__, fabs(check - intersection->x)); > #else >- fprintf(stderr, "intersect: intersection is off by %f\n", fabs(check - instersection->x)); >+ fprintf(stderr, "intersect: intersection is off by %f\n", fabs(check - intersection->x)); > #endif > } > } >diff -ur 4.3.0/xc/programs/xrx/helper/Imakefile 4.3.0+IPv6/xc/programs/xrx/helper/Imakefile >--- 4.3.0/xc/programs/xrx/helper/Imakefile Mon Apr 23 09:17:13 2001 >+++ 4.3.0+IPv6/xc/programs/xrx/helper/Imakefile Sun Mar 2 18:39:50 2003 >@@ -22,12 +22,15 @@ > > CONN_DEFINES = -DTCPCONN > TRANS_DEFINES = -DTRANS_CLIENT >+# ifdef IPv6Flags >+ IPv6_DEFINES = IPv6Flags >+# endif > # if HasBSD44Sockets > SOCK_DEFINES = -DBSD44SOCKETS > # endif >- DEPEND_DEFINES = $(TRANS_DEFINES) $(CONN_DEFINES) DependDefines >+ DEPEND_DEFINES = $(TRANS_DEFINES) $(CONN_DEFINES) $(IPv6_DEFINES) DependDefines > >- DEFINES = StrcasecmpDefines \ >+ DEFINES = StrcasecmpDefines $(IPv6_DEFINES) \ > $(CONN_DEFINES) $(SOCK_DEFINES) $(TRANS_DEFINES) $(POLL_DEFINES) > INCLUDES = $(TRANS_INCLUDES) $(RX_INCLUDES) > >diff -ur 4.3.0/xc/registry 4.3.0+IPv6/xc/registry >--- 4.3.0/xc/registry Sun Jun 30 19:25:51 2002 >+++ 4.3.0+IPv6/xc/registry Sat Mar 1 23:34:35 2003 >@@ -448,6 +448,8 @@ > 0 Internet [23] > 1 DECnet [23] > 2 Chaos [23] >+6 InternetV6 [23] >+33 Amoeba [8] > 252 LocalHost [105] > 253 Kerberos5Principal [94] > 254 Netname [57] >--- 4.3.0/xc/programs/Xserver/Xserver.man Tue Nov 19 15:18:09 2002 >+++ 4.3.0+IPv6/xc/programs/Xserver/Xserver.man Mon Apr 14 00:49:32 2003 >@@ -273,6 +273,15 @@ > .B \-broadcast > enable XDMCP and broadcasts BroadcastQuery packets to the network. The > first responding display manager will be chosen for the session. >+.B \-multicast [\fIaddress\fP [\fIhop count\fP]] >+Enable XDMCP and multicast BroadcastQuery packets to the network. >+The first responding display manager is chosen for the session. If an >+address is specified, the multicast is sent to that address. If no >+address is specified, the multicast is sent to the default XDMCP IPv6 >+multicast group. If a hop count is specified, it is used as the maximum >+hop count for the multicast. If no hop count is specified, the multicast >+is set to a maximum of 1 hop, to prevent the multicast from being routed >+beyond the local network. > .TP 8 > .B \-indirect \fIhostname\fP > enables XDMCP and send IndirectQuery packets to the specified
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 24445
: 21392