aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os/xdmcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/os/xdmcp.c')
-rw-r--r--xorg-server/os/xdmcp.c142
1 files changed, 120 insertions, 22 deletions
diff --git a/xorg-server/os/xdmcp.c b/xorg-server/os/xdmcp.c
index 11f11333d..c18e90248 100644
--- a/xorg-server/os/xdmcp.c
+++ b/xorg-server/os/xdmcp.c
@@ -62,6 +62,8 @@
static const char *defaultDisplayClass = COMPILEDDISPLAYCLASS;
+extern void match_interface(u_long u_lQuery);
+
static int xdmcpSocket, sessionSocket;
static xdmcp_states state;
@@ -197,6 +199,11 @@ static void XdmcpWakeupHandler(pointer /*data */ ,
int /*i */ ,
pointer /*LastSelectMask */ );
+#define XSERV_t
+#define TRANS_SERVER
+#define TRANS_REOPEN
+#include <X11/Xtrans/Xtrans.h>
+
/*
* Register the Manufacturer display ID
*/
@@ -581,6 +588,32 @@ XdmcpInit(void)
(pointer) 0);
timeOutRtx = 0;
DisplayNumber = (CARD16) atoi(display);
+ if (ConnectionTypes.length>1 && xdm_from==NULL)
+ {
+ unsigned i=0;
+ char ErrorMessage[1024];
+ sprintf(ErrorMessage,"Multiple ip-addresses detected:\n");
+ for (i=0; i<ConnectionTypes.length; i++)
+ {
+ int AddrLen=ConnectionAddresses.data[i].length;
+ if (AddrLen==4)
+ sprintf(ErrorMessage+strlen(ErrorMessage)," %d.%d.%d.%d\n",
+ ConnectionAddresses.data[i].data[0],
+ ConnectionAddresses.data[i].data[1],
+ ConnectionAddresses.data[i].data[2],
+ ConnectionAddresses.data[i].data[3]);
+ else
+ {
+ int j;
+ sprintf(ErrorMessage+strlen(ErrorMessage)," ");
+ for (j=0; j<AddrLen; j++)
+ sprintf(ErrorMessage+strlen(ErrorMessage),"%02x",ConnectionAddresses.data[i].data[j]);
+ sprintf(ErrorMessage+strlen(ErrorMessage),"\n");
+ }
+ }
+ sprintf(ErrorMessage+strlen(ErrorMessage),"Please specify the ip-address you want to use with -from\n");
+ FatalError(ErrorMessage);
+ }
get_xdmcp_sock();
send_packet();
}
@@ -651,8 +684,8 @@ XdmcpBlockHandler(pointer data, /* unused */
if (timeOutTime == 0)
return;
millisToGo = timeOutTime - GetTimeInMillis();
- if ((int) millisToGo < 0)
- millisToGo = 0;
+ if ((int) millisToGo <= 0)
+ millisToGo = 1;
AdjustWaitForDelay(wt, millisToGo);
}
@@ -689,16 +722,6 @@ XdmcpWakeupHandler(pointer data, /* unused */
else if (state == XDM_RUN_SESSION)
keepaliveDormancy = defaultKeepaliveDormancy;
}
- if (XFD_ANYSET(&AllClients) && state == XDM_RUN_SESSION)
- timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
- }
- else if (timeOutTime && (int) (GetTimeInMillis() - timeOutTime) >= 0) {
- if (state == XDM_RUN_SESSION) {
- state = XDM_KEEPALIVE;
- send_packet();
- }
- else
- timeout();
}
}
@@ -724,12 +747,71 @@ XdmcpSelectHost(const struct sockaddr *host_sockaddr,
* selects the first host to respond with willing message.
*/
+#ifdef _MSC_VER
+void DisplayXdmcpHostsDialog(void);
+int XdmcpHostAddName(const char *HostName, int HostIndex);
+
+struct hostinfo
+{
+ struct sockaddr *from;
+ int fromlen;
+ ARRAY8 AuthenticationName;
+};
+static int g_NrHosts;
+static struct hostinfo *g_Hosts;
+
+void XdmcpHostSelected(int HostIdx)
+{
+ int i;
+
+ /* Connect to the selected host */
+ XdmcpSelectHost(g_Hosts[HostIdx].from, g_Hosts[HostIdx].fromlen, &g_Hosts[HostIdx].AuthenticationName);
+
+ for (i=0; i<g_NrHosts; i++)
+ {
+ free(g_Hosts[i].from);
+ free(g_Hosts[i].AuthenticationName.data);
+ }
+ free(g_Hosts);
+ g_Hosts=NULL;
+ g_NrHosts=0;
+}
+#endif
+
/*ARGSUSED*/ static void
XdmcpAddHost(const struct sockaddr *from,
int fromlen,
ARRAY8Ptr AuthenticationName, ARRAY8Ptr hostname, ARRAY8Ptr status)
{
- XdmcpSelectHost(from, fromlen, AuthenticationName);
+#ifdef _MSC_VER
+ char szHostName[100];
+ int HostIdx;
+
+ memcpy(szHostName,hostname->data,hostname->length);
+ szHostName[hostname->length]=0;
+
+ DisplayXdmcpHostsDialog(); /* Display the dialog if not already displayed */
+
+ HostIdx=XdmcpHostAddName(szHostName, g_NrHosts);
+ if (HostIdx==-1)
+ {
+ HostIdx=g_NrHosts;
+ g_NrHosts++;
+ g_Hosts=realloc(g_Hosts,g_NrHosts*sizeof(*g_Hosts));
+ g_Hosts[HostIdx].AuthenticationName.data=NULL;
+ g_Hosts[HostIdx].from=NULL;
+ }
+
+ g_Hosts[HostIdx].fromlen=fromlen;
+ g_Hosts[HostIdx].from=realloc(g_Hosts[HostIdx].from,g_Hosts[HostIdx].fromlen);
+ memcpy(g_Hosts[HostIdx].from,from,fromlen);
+
+ g_Hosts[HostIdx].AuthenticationName.length=AuthenticationName->length;
+ g_Hosts[HostIdx].AuthenticationName.data=realloc(g_Hosts[HostIdx].AuthenticationName.data,AuthenticationName->length);
+ memcpy(g_Hosts[HostIdx].AuthenticationName.data,AuthenticationName->data,AuthenticationName->length);
+#else
+ XdmcpSelectHost(from, fromlen, AuthenticationName);
+#endif
}
/*
@@ -1001,12 +1083,20 @@ get_xdmcp_sock(void)
sizeof(soopts)) < 0)
XdmcpWarning("UDP set broadcast socket-option failed");
#endif /* SO_BROADCAST */
- if (xdmcpSocket >= 0 && xdm_from != NULL) {
+ if (xdm_from)
+ {
+ if (xdmcpSocket >= 0 && SOCKADDR_FAMILY(FromAddress)==AF_INET) {
if (bind(xdmcpSocket, (struct sockaddr *) &FromAddress,
FromAddressLen) < 0) {
- FatalError("Xserver: failed to bind to -from address: %s\n",
- xdm_from);
+ FatalError("Xserver: failed to bind to -from address: %s error %d\n", xdm_from, WSAGetLastError());
+ }
+ }
+ else if (xdmcpSocket6 >= 0 && SOCKADDR_FAMILY(FromAddress)==AF_INET6) {
+ if (bind(xdmcpSocket6, (struct sockaddr *)&FromAddress,
+ FromAddressLen) < 0) {
+ FatalError("Xserver: failed to bind to -from address: %s error %d\n", xdm_from, WSAGetLastError());
}
+ }
}
#endif /* STREAMSCONN */
}
@@ -1070,18 +1160,18 @@ send_query_msg(void)
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;
+ int hopflag = mcl->hops;
socketfd = xdmcpSocket;
setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL,
- &hopflag, sizeof(hopflag));
+ (char*)&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));
+ (char*)&hopflag6, sizeof(hopflag6));
}
else {
continue;
@@ -1435,6 +1525,10 @@ get_addr_by_name(const char *argtype,
char *pport = portstr;
int gaierr;
+#if defined(WIN32) && defined(TCPCONN)
+ _XSERVTransWSAStartup();
+#endif
+
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = socktype;
@@ -1478,9 +1572,6 @@ get_addr_by_name(const char *argtype,
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
_Xgethostbynameparams hparams;
#endif
-#if defined(WIN32) && defined(TCPCONN)
- _XSERVTransWSAStartup();
-#endif
if (!(hep = _XGethostbyname(namestr, hparams))) {
FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);
}
@@ -1501,7 +1592,11 @@ static void
get_manager_by_name(int argc, char **argv, int i)
{
+ PSOCKADDR_IN queryAddr = NULL;
+ u_long u_lqueryAddr = 0;
+
if ((i + 1) == argc) {
+
FatalError("Xserver: missing %s host name in command line\n", argv[i]);
}
@@ -1511,6 +1606,9 @@ get_manager_by_name(int argc, char **argv, int i)
, &mgrAddr, &mgrAddrFirst
#endif
);
+ queryAddr = (PSOCKADDR_IN)&ManagerAddress;
+ u_lqueryAddr = queryAddr->sin_addr.S_un.S_addr;
+ match_interface(u_lqueryAddr);
}
static void