break;
GetAuthorization(    XtransConnInfo trans_conn,    int family,    char *saddr,    int saddrlen,    int idisplay,    char **auth_namep,			/* RETURN */    int *auth_namelenp,			/* RETURN */    char **auth_datap,			/* RETURN */    int *auth_datalenp)			/* RETURN */{#ifdef SECURE_RPC    char rpc_cred[MAX_AUTH_BYTES];#endif#ifdef HASXDMAUTH    char xdmcp_data[192/8];#endif    char *auth_name;    int auth_namelen;    char *auth_data;    int auth_datalen;    Xauth *authptr = NULL;/* * Look up the authorization protocol name and data if necessary. */    if (xauth_name && xauth_data) {	auth_namelen = xauth_namelen;	auth_name = xauth_name;	auth_datalen = xauth_datalen;	auth_data = xauth_data;    } else {	char dpynumbuf[40];		/* big enough to hold 2^64 and more */	(void) sprintf (dpynumbuf, "%d", idisplay);	authptr = XauGetBestAuthByAddr ((unsigned short) family,				    (unsigned short) saddrlen,				    saddr,				    (unsigned short) strlen (dpynumbuf),				    dpynumbuf,				    xauth_names_length,				    xauth_names,				    xauth_lengths);	if (authptr) {	    auth_namelen = authptr->name_length;	    auth_name = (char *)authptr->name;	    auth_datalen = authptr->data_length;	    auth_data = (char *)authptr->data;	} else {	    auth_namelen = 0;	    auth_name = NULL;	    auth_datalen = 0;	    auth_data = NULL;	}    }#ifdef HASXDMAUTH    /*     * build XDM-AUTHORIZATION-1 data     */    if (auth_namelen == 19 && !strncmp (auth_name, "XDM-AUTHORIZATION-1", 19))    {	int i, j;	Time_t  now;	int family, addrlen;	Xtransaddr *addr = NULL;	for (j = 0; j < 8; j++)	    xdmcp_data[j] = auth_data[j];	_X11TransGetMyAddr(trans_conn, &family, &addrlen, &addr);	switch( family )	{#ifdef AF_INET	case AF_INET:	{	    /*	     * addr will contain a sockaddr_in with all	     * of the members already in network byte order.	     */	    for(i=4; i<8; i++)	/* do sin_addr */		xdmcp_data[j++] = ((char *)addr)[i];	    for(i=2; i<4; i++)	/* do sin_port */		xdmcp_data[j++] = ((char *)addr)[i];	    break;	}#endif /* AF_INET */#if defined(IPv6) && defined(AF_INET6)	case AF_INET6:	  /* XXX This should probably never happen */	{	    unsigned char ipv4mappedprefix[] = {		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };	    	    /* In the case of v4 mapped addresses send the v4 	       part of the address - addr is already in network byte order */	    if (memcmp(addr+8, ipv4mappedprefix, 12) == 0) {		for (i = 20 ; i < 24; i++)		    xdmcp_data[j++] = ((char *)addr)[i];	    		/* Port number */		for (i=2; i<4; i++)		    xdmcp_data[j++] = ((char *)addr)[i];		break;	    } else {		/* Fake data to keep the data aligned. Otherwise the 		   the server will bail about incorrect timing data */		for (i = 0; i < 8; i++) {		    xdmcp_data[j++] = 0;		}	    }	}#endif /* AF_INET6 */#ifdef AF_UNIX	case AF_UNIX:	{	    /*	     * We don't use the sockaddr_un for this encoding.	     * Instead, we create a sockaddr_in filled with	     * a decreasing counter for the address, and the	     * pid for the port.	     */	    static unsigned long    unix_addr = 0xFFFFFFFF;	    unsigned long	the_addr;	    unsigned short	the_port;	    	    _XLockMutex(_Xglobal_lock);	    the_addr = unix_addr--;	    _XUnlockMutex(_Xglobal_lock);	    the_port = getpid ();	    xdmcp_data[j++] = (the_addr >> 24) & 0xFF;	    xdmcp_data[j++] = (the_addr >> 16) & 0xFF;	    xdmcp_data[j++] = (the_addr >>  8) & 0xFF;	    xdmcp_data[j++] = (the_addr >>  0) & 0xFF;	    xdmcp_data[j++] = (the_port >>  8) & 0xFF;	    xdmcp_data[j++] = (the_port >>  0) & 0xFF;	    break;	}#endif /* AF_UNIX */#ifdef AF_DECnet	case AF_DECnet:	    /*	     * What is the defined encoding for this?	     */	    break;#endif /* AF_DECnet */	default:	    /*	     * Need to return some kind of errro status here.	     * maybe a NULL auth??	     */	    break;	} /* switch */	if (addr)	    free ((char *) addr);	time (&now);	xdmcp_data[j++] = (now >> 24) & 0xFF;	xdmcp_data[j++] = (now >> 16) & 0xFF;	xdmcp_data[j++] = (now >>  8) & 0xFF;	xdmcp_data[j++] = (now >>  0) & 0xFF;	while (j < 192 / 8)	    xdmcp_data[j++] = 0;	_XLockMutex(_Xglobal_lock);	/* this function might use static data, hence the lock around it */	XdmcpWrap (xdmcp_data, auth_data + 8,		      xdmcp_data, j);	_XUnlockMutex(_Xglobal_lock);	auth_data = xdmcp_data;	auth_datalen = j;    }#endif /* HASXDMAUTH */#ifdef SECURE_RPC    /*     * The SUN-DES-1 authorization protocol uses the     * "secure RPC" mechanism in SunOS 4.0+.     */    if (auth_namelen == 9 && !strncmp(auth_name, "SUN-DES-1", 9)) {	char servernetname[MAXNETNAMELEN + 1];	/*	 * Copy over the server's netname from the authorization	 * data field filled in by XauGetAuthByAddr().	 */	if (auth_datalen > MAXNETNAMELEN) {	    auth_datalen = 0;	    auth_data = NULL;	} else {	    memcpy(servernetname, auth_data, auth_datalen);	    servernetname[auth_datalen] = '\0';	    auth_datalen = sizeof (rpc_cred);	    if (auth_ezencode(servernetname, 100, rpc_cred,			      &auth_datalen))		auth_data = rpc_cred;	    else {		auth_datalen = 0;		auth_data = NULL;	    }	}    }#endif    if (saddr) free ((char *) saddr);    if ((*auth_namelenp = auth_namelen))    {	if ((*auth_namep = Xmalloc(auth_namelen)))	    memcpy(*auth_namep, auth_name, auth_namelen);	else	    *auth_namelenp = 0;    }    else	*auth_namep = NULL;    if ((*auth_datalenp = auth_datalen))    {	if ((*auth_datap = Xmalloc(auth_datalen)))	    memcpy(*auth_datap, auth_data, auth_datalen);	else	    *auth_datalenp = 0;    }    else	*auth_datap = NULL;    if (authptr) XauDisposeAuth (authptr);}