/// <summary> /// Initialize this protocol with create control and data channels. /// </summary> /// <param name="rdpedycServer">RDPEDYC Server instance</param> /// <param name="transportType">selected transport type for created channels</param> /// <returns>true if client supports this protocol; otherwise, return false.</returns> public bool ProtocolInitialize(RdpedycServer rdpedycServer, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_UDP_Reliable) { if (!rdpedycServer.IsMultipleTransportCreated(transportType)) { rdpedycServer.CreateMultipleTransport(transportType); } this.rdpefsServer = new RdpefsServer(rdpedycServer); bool success = false; // Create RDPEFS channel try { uint channelId = DynamicVirtualChannel.NewChannelId(); Dictionary <TunnelType_Value, List <uint> > channelListDic = new Dictionary <TunnelType_Value, List <uint> >(); List <uint> list = new List <uint>(); list.Add(channelId); channelListDic.Add(TunnelType_Value.TUNNELTYPE_UDPFECR, list); rdpedycServer.SoftSyncNegotiate(waitTime, channelListDic); success = rdpefsServer.CreateRdpefsDvc(waitTime, channelId); } catch (Exception e) { Site.Log.Add(LogEntryKind.Comment, "Exception occurred when creating RDPEFS channels: {1}", e.Message); } return(success); }
/// <summary> /// Create graphic dynamic virtual channel over UDP transport. /// </summary> private bool InitializeForSoftSync(DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_UDP_Reliable) { uint?channelId = null; if (!rdpedycServer.IsMultipleTransportCreated(transportType)) { rdpedycServer.CreateMultipleTransport(transportType); this.TestSite.Log.Add(LogEntryKind.Comment, "Expect for Client Initiate Multitransport PDU to indicate that the client was able to successfully complete the multitransport initiation request."); rdpbcgrAdapter.WaitForPacket <Client_Initiate_Multitransport_Response_PDU>(waitTime); TestSite.Assert.IsTrue( rdpbcgrAdapter.SessionContext.ClientInitiateMultitransportResponsePDU.hrResponse == HrResponse_Value.S_OK, "hrResponse field should be {0}", HrResponse_Value.S_OK); channelId = DynamicVirtualChannel.NewChannelId(); List <uint> list = new List <uint>(); list.Add((uint)channelId); Dictionary <TunnelType_Value, List <uint> > channelListDic = new Dictionary <TunnelType_Value, List <uint> >(); TunnelType_Value tunnelType = TunnelType_Value.TUNNELTYPE_UDPFECR; if (transportType == DynamicVC_TransportType.RDP_UDP_Lossy) { tunnelType = TunnelType_Value.TUNNELTYPE_UDPFECL; } channelListDic.Add(tunnelType, list); rdpedycServer.SoftSyncNegotiate(waitTime, channelListDic); } return(this.rdpegfxAdapter.CreateEGFXDvc(rdpedycServer, transportType, channelId)); }
/// <summary> /// Receives the ADD_VIRTUAL_CHANNEL request from the client. /// </summary> /// <param name="channelId">The channel received in.</param> public void ExpectAddVirtualChannel(DynamicVirtualChannel channel) { Site.Log.Add(LogEntryKind.Debug, "Receiving ADD_VIRTUAL_CHANNEL: Channel ID {0}", channel.ChannelId); EusbAddVirtualChannelPdu responsePdu = this.rdpeusbServer.ExpectRdpeusbPdu <EusbAddVirtualChannelPdu>(channel.ChannelId, waitTime); #region Verify ADD_VIRTUAL_CHANNEL Site.Assert.IsNotNull( responsePdu, "Expect that the response from the client is EusbAddVirtualChannelPdu."); // Log this PDU if responsePdu is not null LogPdu(responsePdu); Site.Assert.AreEqual <uint>( 0x00000001, responsePdu.InterfaceId, "Expect that the InterfaceId in the response PDU equals 0x00000001. The actual value is 0x{0:x8}.", responsePdu.InterfaceId); Site.Assert.AreEqual <Mask_Values>( Mask_Values.STREAM_ID_PROXY, responsePdu.Mask, "Expect that the Mask in the response PDU is STREAM_ID_PROXY."); Site.Assert.AreEqual <FunctionId_Values>( FunctionId_Values.ADD_VIRTUAL_CHANNEL, (FunctionId_Values)responsePdu.FunctionId, "Expect that the FunctionId in the response PDU is ADD_VIRTUAL_CHANNEL. The actual value is 0x{0:x8}.", responsePdu.FunctionId); #endregion }
public void S1_EDYC_SendUncompressedData() { #region Test Code this.rdpedycAdapter.Initialize(this.Site); // Set up RDPBCGR connection with server this.rdpedycAdapter.ConnectToServer(transportProtocol, requestProtocol, new string[] { RdpConstValue.SVCNAME_RDPEDYC }, CompressionType.PACKET_COMPR_TYPE_NONE, false, true); // Capability exchange this.Site.Log.Add(LogEntryKind.Debug, "Expect the Exchange Capabilites PDU from SUT."); this.rdpedycAdapter.ExchangeCapabilities(timeout); // Expect the geometry channel create request from server this.Site.Log.Add(LogEntryKind.Debug, "Expect the DVC channel create PDU from SUT."); DynamicVirtualChannel channel = this.rdpedycAdapter.ExpectChannel(timeout, DynamicVC_TransportType.RDP_TCP); // Send data to server this.Site.Log.Add(LogEntryKind.Debug, "Send the DYNVC_Data PDU to SUT."); this.rdpedycAdapter.SendUncompressedPdu(channel.ChannelId, DynamicVC_TransportType.RDP_TCP); // Expect the geometry channel close request from server this.Site.Log.Add(LogEntryKind.Debug, "Expect the DVC channel close PDU from SUT."); this.rdpedycAdapter.CloseChannel(timeout, (ushort)channel.ChannelId); this.Site.Log.Add(LogEntryKind.Debug, "The DVC channel is closed successfully."); #endregion Test Code }
private void SendPdu(EusbPdu pdu, DynamicVirtualChannel channel) { Site.Assume.IsNotNull(channel, "DynamicVirtualChannel must be initialized."); channel.Send(PduMarshaler.Marshal(pdu)); Site.Log.Add(LogEntryKind.Debug, "Sending {0}: \r\n{1}\r\n", pdu.GetType().ToString(), pdu.ToString()); }
/// <summary> /// Negotiates the capability through the specified channel with the connected RDP client. /// </summary> /// <param name="channel">The channel which the negotiation is sent in.</param> /// <param name="messageId">A unique ID for the request or response pair.</param> /// <param name="capability">The server's capability.</param> public void NegotiateCapability(DynamicVirtualChannel channel, uint messageId, CapabilityValue_Values capability) { Site.Log.Add(LogEntryKind.Debug, "Sending RIM_EXCHANGE_CAPABILITY_REQUEST: Channel ID {0}, Message ID {1}, Capability {2}.", channel.ChannelId, messageId, capability.ToString()); EusbRimExchangeCapRequestPdu requestPdu = new EusbRimExchangeCapRequestPdu(); requestPdu.MessageId = messageId; SendPdu(requestPdu, channel); if (capability == CapabilityValue_Values.RIM_CAPABILITY_VERSION_01) { // Positive tests so expect a valid response. Site.Log.Add(LogEntryKind.Debug, "Receiving EusbRimExchangeCapResponsePdu."); EusbRimExchangeCapResponsePdu responsePdu = this.rdpeusbServer.ExpectRdpeusbPdu <EusbRimExchangeCapResponsePdu>(channel.ChannelId, waitTime); #region Verify RIM_EXCHANGE_CAPABILITY_RESPONSE Site.Assert.IsNotNull( responsePdu, "Expect that the response from the client is EusbRimExchangeCapResponsePdu."); Site.Assert.AreEqual <uint>( requestPdu.InterfaceId, responsePdu.InterfaceId, "Expect that the InterfaceId in the response PDU equals the InterfaceId in the request PDU. The actual value is 0x{0:x8}.", responsePdu.InterfaceId); Site.Assert.AreEqual <uint>( requestPdu.MessageId, responsePdu.MessageId, "Expect that the MessageId in the response PDU equals the MessageId in the request PDU. The actual value is 0x{0:x8}.", responsePdu.MessageId); Site.Assert.AreEqual <Mask_Values>( Mask_Values.STREAM_ID_NONE, responsePdu.Mask, "Expect that the Mask in the response PDU is STREAM_ID_NONE."); Site.Assert.AreEqual <uint>( (uint)CapabilityValue_Values.RIM_CAPABILITY_VERSION_01, responsePdu.CapabilityValue, "Expect that the CapabilityValue in the response PDU is 0x00000001."); Site.Assert.AreEqual <uint>( 0, responsePdu.Result, "Expect that the Result in the response PDU is 0x00000000. The actual value is 0x{0:x8}.", responsePdu.MessageId); #endregion } else { // Negative tests so expect the channel to be closed. bool channelClosed = IsChannelClosed(channel); Site.Assert.IsTrue(channelClosed, "Expect the channel {0} to be closed.", channel.ChannelId); } }
private void CheckSupportedProtocols() { // Notify the UI for detecting protocol supported finished DetectorUtil.WriteLog("Check specified protocols support..."); bool serverSupportUDPFECR = false; bool serverSupportUDPFECL = false; if (connectResponsePdu.mcsCrsp.gccPdu.serverMultitransportChannelData != null) { if (connectResponsePdu.mcsCrsp.gccPdu.serverMultitransportChannelData.flags.HasFlag(MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECR)) { serverSupportUDPFECR = true; } if (connectResponsePdu.mcsCrsp.gccPdu.serverMultitransportChannelData.flags.HasFlag(MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECL)) { serverSupportUDPFECL = true; } } detectInfo.IsSupportRDPEMT = serverSupportUDPFECR || serverSupportUDPFECL; if (detectInfo.IsSupportRDPEMT) { DetectorUtil.WriteLog("Detect RDPEMT supported"); } else { DetectorUtil.WriteLog("Detect RDPEMT unsupported"); } rdpedycClient = new RdpedycClient(rdpbcgrClient, rdpbcgrClient.Context, false); try { DynamicVirtualChannel channel = rdpedycClient.ExpectChannel(timeout, DYVNAME_RDPEDYC, DynamicVC_TransportType.RDP_TCP); if (channel != null) { detectInfo.IsSupportRDPEDYC = true; } rdpedycClient.CloseChannel((ushort)channel.ChannelId); } catch { detectInfo.IsSupportRDPEDYC = false; } if (detectInfo.IsSupportRDPEDYC) { DetectorUtil.WriteLog("Detect RDPEDYC supported"); } else { DetectorUtil.WriteLog("Detect RDPEDYC unsupported"); } DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); }
/// <summary> /// Expect create channel reqeust from SUT /// </summary> /// <param name="timeout">Time span for waiting</param> /// <param name="channelName">Channel name to be created </param> /// <param name="transportType">Transport type, Tcp by default</param> /// <returns></returns> public DynamicVirtualChannel ExpectChannel(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { if (rdpedycClientStack == null) { throw new InvalidOperationException("RDPEDYC Client is required to be created before create channel!"); } DynamicVirtualChannel channel = rdpedycClientStack.ExpectChannel(timeout, SVCNameForEGT, transportType); return(channel); }
/// <summary> /// Create dynamic virtual channel. /// </summary> /// <param name="transportType">selected transport type for created channels</param> /// <param name="timeout">Timeout</param> /// <returns>true if client supports this protocol; otherwise, return false.</returns> public bool CreateRdpegtDvc(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { const ushort priority = 0; rdpegtDVC = rdpedycServer.CreateChannel(timeout, priority, RdpegtChannelName, transportType, null); if (rdpegtDVC != null) { return(true); } return(false); }
/// <summary> /// Create dynamic virtual channel. /// </summary> /// <param name="transportType">selected transport type for created channels</param> /// <param name="timeout">Timeout</param> /// <returns>true if client supports this protocol; otherwise, return false.</returns> public bool CreateRdpevorDvc(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { const ushort priority = 0; rdpevorControlDVC = rdpedycServer.CreateChannel(timeout, priority, RdpevorControlChannelName, transportType, OnDataReceived); rdpevorDataDVC = rdpedycServer.CreateChannel(timeout, priority, RdpevorDataChannelName, transportType, OnDataReceived); if (rdpevorControlDVC != null && rdpevorDataDVC != null) { return(true); } return(false); }
private DynamicVirtualChannel CreateVirtualChannel() { // Creates the required dynamic virtual channel. DynamicVirtualChannel channel = rdpeusbAdapter.CreateVirtualChannel(); // Exchanges capabilities. rdpeusbAdapter.NegotiateCapability(channel, IdGenerator.NewId(), CapabilityValue_Values.RIM_CAPABILITY_VERSION_01); // Notifies the channel has been created. rdpeusbAdapter.ChannelCreated(channel, IdGenerator.NewId(), 1, 0, 0); return(channel); }
public void BVT_EUSB_CancelRequest_TransferInRequest() { LogComment("BVT_EUSB_CancelRequest_TransferInRequest"); LogComment("1. Creates the control virtual channel, exchanges capabilities then notifies that the channel is created."); context.ControlChannel = CreateVirtualChannel(); LogComment("2. Receives an add virtual channel request."); rdpeusbAdapter.ExpectAddVirtualChannel(context.ControlChannel); LogComment("3. Creates a new virtual channel for the device."); DynamicVirtualChannel channel = CreateVirtualChannel(); LogComment("4. Receives an add device request."); EusbDeviceContext device = rdpeusbAdapter.ExpectAddDevice(channel); LogComment("5. Register a callback to provide the Request Completion Interface to the client."); uint interfaceId = IdGenerator.NewId(); rdpeusbAdapter.RegisterCallback(device, 1, interfaceId); // TODO: Needs a long processing transfer in request so that the request cannot be completed before cancel is // received. LogComment("6. Sends TS_URB_CONTROL_DESCRIPTOR_REQUEST within a transfer in request."); uint requestId = IdGenerator.NewId(); TS_URB_CONTROL_DESCRIPTOR_REQUEST des = new UrbBuilder( URB_FUNCTIONID.URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE, requestId, 0).BuildDeviceDescriptorRequest(); rdpeusbAdapter.TransferInRequest(device, des, USB_DEVICE_DESCRIPTOR.DefaultSize); LogComment("7. Sends a cancel request with the request ID specified in the transfer in request."); rdpeusbAdapter.CancelRequest(device, requestId); LogComment("8. Expects not to receive a completion message."); EusbPdu pdu = rdpeusbAdapter.ExpectCompletion(device.VirtualChannel); if (null != pdu) { Site.Log.Add( LogEntryKind.Debug, "The Completion message is received. Callback interface ID: {0}, Completion Interface ID: {1}", interfaceId, pdu.InterfaceId ); } LogComment("9. Sends retract device request and the channel for the device is expected to be closed."); rdpeusbAdapter.RetractDevice(device, USB_RETRACT_REASON.UsbRetractReason_BlockedByPolicy); }
/// <summary> /// Wait for creation of dynamic virtual channel for RDPEGFX /// </summary> /// <param name="timeout"></param> /// <param name="transportType"></param> /// <returns></returns> public bool WaitForRdpegfxDvcCreation(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { try { RdpegfxDVC = rdpedycClient.ExpectChannel(timeout, RdpegfxGraphicChannelName, transportType); } catch { } if (RdpegfxDVC != null) { return(true); } return(false); }
/// <summary> /// Wait for creation of dynamic virtual channel for RDPEGFX /// </summary> /// <param name="timeout"></param> /// <param name="transportType"></param> /// <returns></returns> public bool WaitForRdpegfxDvcCreation(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { try { rdpeiDVC = rdpedycClient.ExpectChannel(timeout, rdpeiChannelName, transportType, OnDataReceived); } catch { } if (rdpeiDVC != null) { return(true); } return(false); }
public void BVT_EUSB_CancelRequest_InternalIoControl() { LogComment("BVT_EUSB_CancelRequest_InternalIoControl"); LogComment("1. Creates the control virtual channel, exchanges capabilities then notifies that the channel is created."); context.ControlChannel = CreateVirtualChannel(); LogComment("2. Receives an add virtual channel request."); rdpeusbAdapter.ExpectAddVirtualChannel(context.ControlChannel); LogComment("3. Creates a new virtual channel for the device."); DynamicVirtualChannel channel = CreateVirtualChannel(); LogComment("4. Receives an add device request."); EusbDeviceContext device = rdpeusbAdapter.ExpectAddDevice(channel); LogComment("5. Register a callback to provide the Request Completion Interface to the client."); uint interfaceId = IdGenerator.NewId(); rdpeusbAdapter.RegisterCallback(device, 1, interfaceId); // TODO: Needs a long processing internal IO request so that the request cannot be completed before cancel is // received. LogComment("6. Sends an internal IO request."); uint requestId = IdGenerator.NewId(); const uint outputSize = 4; rdpeusbAdapter.InternalIoControl(device, UsbInternalIoControlCode.IOCTL_TSUSBGD_IOCTL_USBDI_QUERY_BUS_TIME, null, outputSize, requestId); LogComment("7. Sends a cancel request with the request ID specified in the IO request."); rdpeusbAdapter.CancelRequest(device, requestId); LogComment("8. Expects not to receive a completion message."); EusbPdu pdu = rdpeusbAdapter.ExpectCompletion(device.VirtualChannel); if (null != pdu) { Site.Log.Add( LogEntryKind.Debug, "The Completion message is received. Callback interface ID: {0}, Completion Interface ID: {1}", interfaceId, pdu.InterfaceId ); } LogComment("9. Sends retract device request and the channel for the device is expected to be closed."); rdpeusbAdapter.RetractDevice(device, USB_RETRACT_REASON.UsbRetractReason_BlockedByPolicy); }
/// <summary> /// Wait for creation of dynamic virtual channel for RDPEVOR /// </summary> /// <param name="timeout"></param> /// <param name="transportType"></param> /// <returns></returns> public bool WaitForRdpevorDvcCreation(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { try { rdpevorControlDVC = rdpedycClient.ExpectChannel(timeout, RdpevorControlChannelName, transportType); rdpevorDataDVC = rdpedycClient.ExpectChannel(timeout, RdpevorDataChannelName, transportType); } catch { } if (rdpevorControlDVC != null && rdpevorDataDVC != null) { return(true); } return(false); }
/// <summary> /// Create dynamic virtual channel. /// </summary> /// <param name="transportType">selected transport type for created channels</param> /// <param name="timeout">Timeout</param> /// <returns>true if client supports this protocol; otherwise, return false.</returns> public bool CreateRdpegfxDvc(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { const ushort priority = 0; try { rdpegfxDVC = rdpedycServer.CreateChannel(timeout, priority, RdpegfxGraphicChannelName, transportType, OnDataReceived); } catch { } if (rdpegfxDVC != null) { return(true); } return(false); }
/// <summary> /// Wait for creation of dynamic virtual channel for RDPEUSB /// </summary> /// <param name="timeout"></param> /// <param name="transportType"></param> /// <returns></returns> public DynamicVirtualChannel WaitForRdpeusbDvcCreation(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { DynamicVirtualChannel channel = null; try { channel = rdpedycClient.ExpectChannel(timeout, RdpeusbChannelName, transportType, OnDataReceived); } catch { } if (channel != null) { rdpeusbChannelDicbyId.Add(channel.ChannelId, channel); return(channel); } return(null); }
/// <summary> /// Create dynamic virtual channel. /// </summary> /// <param name="transportType">selected transport type for created channels</param> /// <param name="timeout">Timeout</param> /// <returns>DVC created</returns> public DynamicVirtualChannel CreateRdpeusbDvc(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { const ushort priority = 0; DynamicVirtualChannel channel = null; try { channel = rdpedycServer.CreateChannel(timeout, priority, RdpeusbChannelName, transportType, OnDataReceived); } catch { } if (channel != null) { rdpeusbChannelDicbyId.Add(channel.ChannelId, channel); return(channel); } return(null); }
/// <summary> /// Creates a dynamic virtual channel with specified channel ID. /// </summary> /// <param name="transportType">selected transport type for created channels</param> /// <returns>Instance of the DVC created</returns> public DynamicVirtualChannel CreateVirtualChannel(DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { if (!this.rdpedycServer.IsMultipleTransportCreated(transportType)) { this.rdpedycServer.CreateMultipleTransport(transportType); } DynamicVirtualChannel rdpeusbDVC = null; try { rdpeusbDVC = this.rdpeusbServer.CreateRdpeusbDvc(waitTime, transportType); } catch (Exception e) { Site.Assert.Fail("Exception occurred when creating RDPEUSB channel: {0}.", e.Message); } return(rdpeusbDVC); }
/// <summary> /// Receives an IOCONTROL_COMPLETION, URB_COMPLETION or URB_COMPLETION_NO_DATA request from the client. /// </summary> /// <param name="channel">The channel to be received in.</param> /// <returns>The received completion PDU. Returns null, if timeout or required .</returns> public EusbPdu ExpectCompletion(DynamicVirtualChannel channel) { EusbPdu pdu = this.rdpeusbServer.ExpectRdpeusbPdu <EusbPdu>(channel.ChannelId, waitTime); if (null == pdu) { return(null); } bool isCompletionPdu = ( (pdu is EusbIoControlCompletionPdu) || (pdu is EusbUrbCompletionPdu) || (pdu is EusbUrbCompletionNoDataPdu) ); Site.Assert.IsTrue(isCompletionPdu, "Expect a completion PDU, current pdu is {0}.", pdu.ToString()); return(pdu); }
/// <summary> /// Create efs DVC /// </summary> /// <param name="timeout">Timeout</param> /// <param name="channelId">DVC channel ID</param> /// <returns>return create results.</returns> public bool CreateRdpefsDvc(TimeSpan timeout, uint?channelId = null) { const ushort priority = 0; try { if (channelId == null) { channelId = DynamicVirtualChannel.NewChannelId(); } rdpefsDVC = rdpedycServer.CreateChannel(timeout, priority, rdpefsChannelName, DynamicVC_TransportType.RDP_UDP_Reliable, OnDataReceived, channelId); } catch { throw new InvalidOperationException("DVC createed failed."); } return(rdpefsDVC == null); }
public void BVT_EUSB_OperateDeviceChannel() { LogComment("BVT_EUSB_OperateDeviceChannel"); LogComment("1. Creates the control virtual channel, exchanges capabilities then notifies that the channel is created."); context.ControlChannel = CreateVirtualChannel(); LogComment("2. Receives an add virtual channel request."); rdpeusbAdapter.ExpectAddVirtualChannel(context.ControlChannel); LogComment("3. Creates a new virtual channel for the device."); DynamicVirtualChannel channel = CreateVirtualChannel(); LogComment("4. Receives an add device request."); EusbDeviceContext device = rdpeusbAdapter.ExpectAddDevice(channel); LogComment("5. Sends retract device request and the channel for the device is expected to be closed."); rdpeusbAdapter.RetractDevice(device, USB_RETRACT_REASON.UsbRetractReason_BlockedByPolicy); }
private bool IsChannelClosed(DynamicVirtualChannel channel) { double timeout = Config.Timeout.TotalMilliseconds; const int wait = 100; Thread.Sleep(wait); timeout -= wait; while (timeout >= 0 && channel.IsActive) { Thread.Sleep(wait); timeout -= wait; } if (channel.IsActive) { Site.Log.Add(LogEntryKind.Debug, "The channel {0} is not closed within {1}", channel.ChannelId, Config.Timeout.ToString("c")); } return(true); }
public void S1_EDYC_SendCompressedDataSequence() { #region Test Code this.rdpedycAdapter.Initialize(this.Site); // Set up RDPBCGR connection with server this.rdpedycAdapter.ConnectToServer(transportProtocol, requestProtocol, new string[] { RdpConstValue.SVCNAME_RDPEDYC }, CompressionType.PACKET_COMPR_TYPE_NONE, false, true); // Capability exchange this.Site.Log.Add(LogEntryKind.Debug, "Expect the Exchange Capabilites PDU from SUT."); // This PDU MUST NOT be used unless both DVC managers support version 3 of the Remote Desktop Protocol: dynamic Virtual Channel Extension, and a reliable transport is being used (UDP-Random or TCP).) DYNVC_CAPS_Version capVersion = this.rdpedycAdapter.ExchangeCapabilities(timeout); if (capVersion != DYNVC_CAPS_Version.VERSION3) { this.Site.Assert.Inconclusive("Compressed data only be used when DVC managers support Version 3 of the EDYC channel."); } // Expect the geometry channel create request from server this.Site.Log.Add(LogEntryKind.Debug, "Expect the DVC channel create PDU from SUT."); DynamicVirtualChannel channel = this.rdpedycAdapter.ExpectChannel(timeout, DynamicVC_TransportType.RDP_TCP); // Send compressed data sequence to server this.Site.Log.Add(LogEntryKind.Debug, "Expect the DYNVC_Data PDU from SUT."); this.rdpedycAdapter.SendCompressedSequencePdu(channel.ChannelId, DynamicVC_TransportType.RDP_TCP); // Expect the geometry channel close request from server this.Site.Log.Add(LogEntryKind.Debug, "Expect the DVC channel close PDU from SUT."); this.rdpedycAdapter.CloseChannel(timeout, (ushort)channel.ChannelId); this.Site.Log.Add(LogEntryKind.Debug, "The DVC channel is closed successfully."); #endregion Test Code }
/// <summary> /// Reset the RdpeiServer instance. /// </summary> public void Reset() { rdpedycServer = null; rdpeiDVC = null; receivedList.Clear(); }
/// <summary> /// Sends CHANNEL_CREATED to notify the client the channel has been created. /// </summary> /// <param name="channel">The channel to be sent in.</param> /// <param name="messageId">A unique ID for the request or response pair.</param> /// <param name="majorVersion">The major version of RDP USB redirection supported.</param> /// <param name="minorVersion">The minor version of RDP USB redirection supported.</param> /// <param name="capability">The capabilities of RDP USB redirection supported.</param> public void ChannelCreated(DynamicVirtualChannel channel, uint messageId, uint majorVersion, uint minorVersion, uint capability) { Site.Log.Add( LogEntryKind.Debug, "Sending CHANNEL_CREATED: Channel ID {0}, Message ID {1}, Version major {2} minor {3}, Capability {4}.", channel.ChannelId, messageId, majorVersion, minorVersion, capability ); EusbChannelCreatedPdu requestPdu = new EusbChannelCreatedPdu(true); requestPdu.MessageId = messageId; requestPdu.MajorVersion = majorVersion; requestPdu.MinorVersion = minorVersion; requestPdu.Capabilities = capability; SendPdu(requestPdu, channel); if (majorVersion == 1 && minorVersion == 0 && capability == 0) { // Positive tests so expect a valid response. Site.Log.Add(LogEntryKind.Debug, "Receiving CHANNEL_CREATED."); EusbChannelCreatedPdu responsePdu = this.rdpeusbServer.ExpectRdpeusbPdu <EusbChannelCreatedPdu>(channel.ChannelId, waitTime); #region Verify CHANNEL_CREATED Response Site.Assert.IsNotNull( responsePdu, "Expect that the response from the client is EusbChannelCreatedPdu."); // Log this PDU if responsePdu is not null LogPdu(responsePdu); Site.Assert.AreEqual <uint>( 0x000000003, responsePdu.InterfaceId, "Expect that the InterfaceId in the response PDU equals 0x000000003. The actual value is 0x{0:x8}.", responsePdu.InterfaceId); Site.Assert.AreEqual <FunctionId_Values>( FunctionId_Values.CHANNEL_CREATED, (FunctionId_Values)responsePdu.FunctionId, "Expect that the FunctionId in the response PDU is CHANNEL_CREATED. The actual value is 0x{0:x8}.", responsePdu.FunctionId); Site.Assert.AreEqual <uint>(responsePdu.MajorVersion, 1, "Expect that the MajorVersion in the response PDU is 1. The actual value is {0}.", responsePdu.MajorVersion); Site.Assert.AreEqual <uint>(responsePdu.MinorVersion, 0, "Expect that the MinorVersion in the response PDU is 0. The actual value is {0}.", responsePdu.MinorVersion); Site.Assert.AreEqual <uint>(responsePdu.Capabilities, 0, "Expect that the Capabilities in the response PDU is 0. The actual value is {0}.", responsePdu.Capabilities); #endregion } else { // Negative tests so expect the channel to be closed. bool channelClosed = IsChannelClosed(channel); Site.Assert.IsTrue(channelClosed, "Expect the channel {0} to be closed.", channel.ChannelId); } }
/// <summary> /// Receives the ADD_DEVICE request from the client. /// </summary> /// <param name="channel">The channel to be received from.</param> /// <returns>The context of the device which is being added.</returns> public EusbDeviceContext ExpectAddDevice(DynamicVirtualChannel channel) { Site.Log.Add(LogEntryKind.Debug, "Receiving ADD_DEVICE, Channel ID {0}.", channel.ChannelId); EusbAddDevicePdu pdu = this.rdpeusbServer.ExpectRdpeusbPdu <EusbAddDevicePdu>(channel.ChannelId, waitTime); USB_DEVICE_CAPABILITIES cap = new USB_DEVICE_CAPABILITIES(); if (!PduMarshaler.Unmarshal(pdu.UsbDeviceCapabilities, cap)) { Site.Assert.Fail( "UsbDeviceCapabilities (size in bytes: {0}) in ADD_DEVICE cannot be decoded.", pdu.UsbDeviceCapabilities.Length ); } #region Verify ADD_DEVICE Site.Assert.IsNotNull( pdu, "Expect that the response from the client is EusbAddDevicePdu." ); Site.Assert.AreEqual <uint>( 0x00000001, pdu.InterfaceId, "Expect that the InterfaceId in the response PDU equals 0x00000001. The actual value is 0x{0:x8}.", pdu.InterfaceId); Site.Assert.AreEqual <Mask_Values>( Mask_Values.STREAM_ID_PROXY, pdu.Mask, "Expect that the Mask in the response PDU is STREAM_ID_PROXY."); Site.Assert.AreEqual <FunctionId_Values>( FunctionId_Values.ADD_DEVICE, (FunctionId_Values)pdu.FunctionId, "Expect that the FunctionId in the response PDU is ADD_DEVICE. The actual value is 0x{0:x8}.", pdu.FunctionId); Site.Assert.AreEqual <uint>( 0x00000001, pdu.NumUsbDevice, "Expect that the NumUsbDevice in the response PDU equals 0x00000001. The actual value is 0x{0:x8}.", pdu.NumUsbDevice); Site.Assert.AreNotEqual <uint>( 0x00000000, pdu.cchDeviceInstanceId, "Expect that the cchDeviceInstanceId in the response PDU is zero. The actual value is 0x{0:x8}.", pdu.cchDeviceInstanceId); if (Config.IsWindowsImplementation) { Site.Assert.AreNotEqual <uint>( 0x00000000, pdu.cchHwIds, "Expect that the cchHwIds in the response PDU is not zero in an implementation of Windows. The actual value is 0x{0:x8}.", pdu.cchHwIds); } #region Verify UsbDeviceCapabilities Site.Assert.AreEqual <uint>( (uint)USB_DEVICE_CAPABILITIES.USB_DEVICE_CAPABILITIES_SIZE, cap.CbSize, "Expect that the CbSize of the USB_DEVICE_CAPABILITIES in the response PDU equals 28. The actual value is {0}.", cap.CbSize); Site.Assert.IsTrue( cap.UsbBusInterfaceVersion == (uint)UsbBusInterfaceVersion_Values.USB_BUS_VERSION_0 || cap.UsbBusInterfaceVersion == (uint)UsbBusInterfaceVersion_Values.USB_BUS_VERSION_1 || cap.UsbBusInterfaceVersion == (uint)UsbBusInterfaceVersion_Values.USB_BUS_VERSION_2, "Expect that the UsbBusInterfaceVersion of the USB_DEVICE_CAPABILITIES in the response PDU equals 0x00000000 or 0x00000001 or 0x00000002. The actual value is {0}.", cap.UsbBusInterfaceVersion); Site.Assert.IsTrue( cap.USBDI_Version == (uint)USBDI_VER.USBDI_VERSION_5 || cap.USBDI_Version == (uint)USBDI_VER.USBDI_VERSION_6, "Expect that the USBDI_Version of the USB_DEVICE_CAPABILITIES in the response PDU equals 0x00000500 or 0x00000600. The actual value is {0}.", cap.USBDI_Version); Site.Assert.IsTrue( cap.Supported_USB_Version == (uint)Supported_USB_Version_Values.USB_1_0 || cap.Supported_USB_Version == (uint)Supported_USB_Version_Values.USB_1_1 || cap.Supported_USB_Version == (uint)Supported_USB_Version_Values.USB_2_0, "Expect that the Supported_USB_Version of the USB_DEVICE_CAPABILITIES in the response PDU equals 0x100 or 0x110 or 0x200. The actual value is {0}.", cap.Supported_USB_Version); Site.Assert.AreEqual <uint>( 0, cap.HcdCapabilities, "Expect that the HcdCapabilities of the USB_DEVICE_CAPABILITIES in the response PDU is zero. The actual value is {0}.", cap.HcdCapabilities); if (cap.UsbBusInterfaceVersion == (uint)UsbBusInterfaceVersion_Values.USB_BUS_VERSION_0) { Site.Assert.AreEqual <uint>( (uint)DeviceSpeed_Values.FULL_SPEED, cap.DeviceIsHighSpeed, "Expect that the DeviceIsHighSpeed of the USB_DEVICE_CAPABILITIES in the response PDU is zero when UsbBusInterfaceVersion is 0x00000000. The actual value is {0}.", cap.HcdCapabilities); } else { Site.Assert.IsTrue( cap.DeviceIsHighSpeed == (uint)DeviceSpeed_Values.FULL_SPEED || cap.DeviceIsHighSpeed == (uint)DeviceSpeed_Values.HIGH_SPEED, "Expect that the DeviceIsHighSpeed of the USB_DEVICE_CAPABILITIES in the response PDU equals 0x100 or 0x110 or 0x200. The actual value is {0}.", cap.DeviceIsHighSpeed); } if (cap.NoAckIsochWriteJitterBufferSizeInMs != 0) { Site.Assert.IsTrue( cap.NoAckIsochWriteJitterBufferSizeInMs >= 10 && cap.NoAckIsochWriteJitterBufferSizeInMs <= 512, "Expect that the NoAckIsochWriteJitterBufferSizeInMs of the USB_DEVICE_CAPABILITIES in the response PDU is greater than or equal to 10 and less than or equal to 512. The actual value is {0}.", cap.NoAckIsochWriteJitterBufferSizeInMs); } #endregion #endregion EusbDeviceContext device = new EusbDeviceContext(); device.VirtualChannel = channel; device.NoAckIsochWriteJitterBufferSizeInMs = (cap.NoAckIsochWriteJitterBufferSizeInMs != 0); device.UsbDeviceInterfaceId = pdu.UsbDevice; device.DeviceInstanceId = pdu.DeviceInstanceId; Site.Log.Add(LogEntryKind.Debug, "Received device request. Device: {0}", device); return(device); }