/// <summary>
        /// Used to establish a RDPEMT connection.
        /// </summary>
        /// <param name="udpTransportMode">Transport Mode: Reliable or Lossy.</param>
        /// <param name="timeout">Wait time.</param>
        /// <returns>true,false.</returns>
        private bool EstablishRdpemtConnection(TransportMode udpTransportMode, TimeSpan timeout)
        {
            bool pass = true;
            RdpeudpServerSocket rdpeudpSocket = rdpeudpSocketR;

            if (udpTransportMode == TransportMode.Lossy)
            {
                rdpeudpSocket = rdpeudpSocketL;
            }

            if (!rdpeudpSocket.AutoHandle)
            {
                rdpeudpSocket.AutoHandle = true;
            }

            String           certFile = this.Site.Properties["CertificatePath"];
            String           certPwd  = this.Site.Properties["CertificatePassword"];
            X509Certificate2 cert     = new X509Certificate2(certFile, certPwd);


            RdpemtServer rdpemtServer = new RdpemtServer(rdpeudpSocket, cert);

            uint receivedRequestId;

            byte[] receivedSecurityCookie;
            if (!rdpemtServer.ExpectConnect(waitTime, out receivedRequestId, out receivedSecurityCookie))
            {
                pass = false;
            }

            rdpeudpSocket.AutoHandle = false;

            if (udpTransportMode == TransportMode.Reliable)
            {
                rdpemtServerR = rdpemtServer;
            }
            else
            {
                rdpemtServerL = rdpemtServer;
            }

            if (!pass)
            {
                this.TestSite.Log.Add(LogEntryKind.Comment, "Create a {0} RDPEMT connection failed, stop rdpeudpServer and close socket connection and retry.", udpTransportMode);
                rdpeudpServer.Stop();
                rdpeudpServer = null;
                if (udpTransportMode == TransportMode.Reliable)
                {
                    rdpeudpSocketR.Close();
                    rdpeudpSocketR = null;
                }
                else
                {
                    rdpeudpSocketL.Close();
                    rdpeudpSocketL = null;
                }
            }

            return(pass);
        }
Пример #2
0
        /// <summary>
        /// Establish a MultiTransport Connection
        /// </summary>
        private void EstablishTransportConnection()
        {
            // Send the Server Initial multitransport
            byte[] securityCookie = new byte[16];
            Random rnd            = new Random();

            rnd.NextBytes(securityCookie);

            Server_Initiate_Multitransport_Request_PDU requestPDU = rdpbcgrServer.CreateServerInitiateMultitransportRequestPDU(serverSessionContext, ++multitransportId, transportProtocol, securityCookie);

            rdpbcgrServer.SendPdu(serverSessionContext, requestPDU);

            //Create RDP-UDP Connection
            CreateRdpeudpServer(this.serverSessionContext);
            TransportMode transMode = TransportMode.Reliable;

            if (transportProtocol == Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL)
            {
                transMode = TransportMode.Lossy;
            }

            rdpeudpSocket = rdpeudpServer.Accept(((IPEndPoint)serverSessionContext.Identity).Address, transMode, timeout);
            if (rdpeudpSocket == null)
            {
                if (rdpeudpServer != null && rdpeudpServer.Running)
                {
                    rdpeudpServer.Dispose();
                }

                throw new NotSupportedException("RDPEMT Server create rdpedupSocket failed.");
            }
            rdpemtServer           = new RdpemtServer(rdpeudpSocket, rdpbcgrServer.AuthCertificate, true);
            rdpemtServer.Received += ReceivedBytes;

            uint receivedRequestId;

            byte[] receivedCookie;
            if (!rdpemtServer.ExpectConnect(timeout, out receivedRequestId, out receivedCookie))
            {
                throw new ProtocolViolationException("RDPEMT Server Expect Connection failed");
            }
            if (receivedRequestId != multitransportId || receivedCookie == null || receivedCookie.Length != 16)
            {
                throw new ProtocolViolationException("RDPEMT Server received a connection with un-expected request id or Cookie is null (or cookie's length is not 16)!");
            }

            for (int i = 0; i < receivedCookie.Length; i++)
            {
                if (receivedCookie[i] != securityCookie[i])
                {
                    throw new ProtocolViolationException("RDPEMT Server received a connection with un-correct cookie!");
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Used to establish a RDPEMT connection
        /// </summary>
        /// <param name="udpTransportMode">Transport Mode: Reliable or Lossy</param>
        /// <param name="timeout">wait time</param>
        private void EstablishRdpemtConnection(TransportMode udpTransportMode, TimeSpan timeout, bool verifyPacket = false)
        {
            RdpeudpSocket rdpeudpSocket = rdpeudpSocketR;

            if (udpTransportMode == TransportMode.Lossy)
            {
                rdpeudpSocket = rdpeudpSocketL;
            }

            String certFile;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePath", out certFile);

            String certPwd;

            PtfPropUtility.GetPtfPropertyValue(Site, "CertificatePassword", out certPwd);

            X509Certificate2 cert         = new X509Certificate2(certFile, certPwd);
            RdpemtServer     rdpemtServer = new RdpemtServer(rdpeudpSocket, cert, false);

            uint receivedRequestId;

            byte[] receivedSecurityCookie;
            if (!rdpemtServer.ExpectConnect(waitTime, out receivedRequestId, out receivedSecurityCookie))
            {
                Site.Assert.Fail("RDPEMT tunnel creation failed");
            }

            if (verifyPacket)
            {
                VerifyTunnelCreateRequestPacket(receivedRequestId, receivedSecurityCookie);
            }

            if (udpTransportMode == TransportMode.Reliable)
            {
                rdpemtServerR = rdpemtServer;
            }
            else
            {
                rdpemtServerL = rdpemtServer;
            }
        }
        /// <summary>
        /// Used to establish a RDPEMT connection.
        /// </summary>
        /// <param name="udpTransportMode">Transport Mode: Reliable or Lossy.</param>
        /// <param name="timeout">Wait time.</param>
        private void EstablishRdpemtConnection(TransportMode udpTransportMode, TimeSpan timeout)
        {
            RdpeudpServerSocket rdpeudpSocket = rdpeudpSocketR;
            if (udpTransportMode == TransportMode.Lossy)
            {
                rdpeudpSocket = rdpeudpSocketL;
            }

            if (!rdpeudpSocket.AutoHandle)
            {
                rdpeudpSocket.AutoHandle = true;
            }

            String certFile = this.Site.Properties["CertificatePath"];
            String certPwd = this.Site.Properties["CertificatePassword"];
            X509Certificate2 cert = new X509Certificate2(certFile, certPwd);


            RdpemtServer rdpemtServer = new RdpemtServer(rdpeudpSocket, cert);

            uint receivedRequestId;
            byte[] receivedSecurityCookie;
            if (!rdpemtServer.ExpectConnect(waitTime, out receivedRequestId, out receivedSecurityCookie))
            {
                Site.Assert.Fail("RDPEMT tunnel creation failed");
            }

            rdpeudpSocket.AutoHandle = false;

            if (udpTransportMode == TransportMode.Reliable)
            {
                rdpemtServerR = rdpemtServer;
            }
            else
            {
                rdpemtServerL = rdpemtServer;
            }


        }