public Virtual_Channel_RAW_Server_Pdu_Ex(Virtual_Channel_RAW_Server_Pdu orgPdu, RdpbcgrServerSessionContext serverSessionContext) : base(serverSessionContext) { this.commonHeader = orgPdu.commonHeader; this.channelPduHeader = orgPdu.channelPduHeader; this.virtualChannelData = orgPdu.virtualChannelData; }
/// <summary> /// Reassemble chunk data /// </summary> /// <param name="pdu"></param> /// <returns></returns> internal Virtual_Channel_Complete_Server_Pdu ReassembleChunkData(Virtual_Channel_RAW_Server_Pdu pdu) { if (!channelDicById.ContainsKey(pdu.commonHeader.channelId)) { // drop the pdu if the channel id does not exist return(null); } ClientStaticVirtualChannel channel = (ClientStaticVirtualChannel)channelDicById[pdu.commonHeader.channelId]; return(channel.ReassembleChunkData(pdu)); }
/// <summary> /// Send static virtual channel data /// </summary> /// <param name="channelId">Channel ID</param> /// <param name="channelPduHeader">Channel PDU Header</param> /// <param name="SVCData"></param> public void SendPacket(UInt16 channelId, CHANNEL_PDU_HEADER channelPduHeader, byte[] SVCData) { Virtual_Channel_RAW_Server_Pdu rawPdu = new Virtual_Channel_RAW_Server_Pdu(context); rawPdu.channelPduHeader = channelPduHeader; rawPdu.virtualChannelData = SVCData; RdpbcgrUtility.FillCommonHeader(ref rawPdu.commonHeader, TS_SECURITY_HEADER_flags_Values.SEC_IGNORE_SEQNO | TS_SECURITY_HEADER_flags_Values.SEC_RESET_SEQNO, context, channelId); context.Server.SendPdu(context, rawPdu); }
/// <summary> /// Generate static virtual channel traffics /// </summary> /// <param name="invalidType">Invalid Type used for negative test case</param> public void GenerateStaticVirtualChannelTraffics(NegativeType invalidType) { if (rdpbcgrClientStack.Context.SVCManager == null) { Site.Assume.Fail("SVC Manager must be created before generate static virtual channel data."); } StaticVirtualChannel RDPEDYCChannel = rdpbcgrClientStack.Context.SVCManager.GetChannelByName(SVCNameForRDPEDYC); if (RDPEDYCChannel == null) { Site.Assume.Fail("Static virtual channel: {0} must be created.", SVCNameForRDPEDYC); } ushort channelId = RDPEDYCChannel.ChannelId; // Expect a RDPEDYC caps request PDU Virtual_Channel_RAW_Server_Pdu svcPdu = this.ExpectPacket <Virtual_Channel_RAW_Server_Pdu>(pduWaitTimeSpan); if (svcPdu == null) { Site.Assert.Fail("Timeout when receiving RDPEDYC static virtual channel data."); } ClientDecodingPduBuilder decoder = new ClientDecodingPduBuilder(); PduBuilder pduBuilder = new PduBuilder(); DynamicVCPDU pdu = decoder.ToPdu(svcPdu.virtualChannelData); if (pdu == null) { Site.Assert.Fail("Received static virtual channel data must be a DVC Capabilities Request PDU!"); } DYNVC_CAPS_Version version = DYNVC_CAPS_Version.VERSION3; if (pdu is CapsVer1ReqDvcPdu) { version = DYNVC_CAPS_Version.VERSION1; } else if (pdu is CapsVer2ReqDvcPdu) { version = DYNVC_CAPS_Version.VERSION2; } // Response a RDPEDYC caps response PDU CapsRespDvcPdu capResp = pduBuilder.CreateCapsRespPdu((ushort)version); SendVirtualChannelPDU(channelId, pduBuilder.ToRawData(capResp), invalidType); }
/// <summary> /// Reassemble static virtual channel PDU /// </summary> /// <param name="pdu"></param> /// <returns></returns> internal Virtual_Channel_Complete_Server_Pdu ReassembleChunkData(Virtual_Channel_RAW_Server_Pdu pdu) { if (pdu == null || pdu.virtualChannelData == null) { return(null); } // the first chunk if ((pdu.channelPduHeader.flags & CHANNEL_PDU_HEADER_flags_Values.CHANNEL_FLAG_FIRST) == CHANNEL_PDU_HEADER_flags_Values.CHANNEL_FLAG_FIRST) { completeServerPdu = new Virtual_Channel_Complete_Server_Pdu(); completeServerPdu.rawPdus = new System.Collections.ObjectModel.Collection <Virtual_Channel_RAW_Server_Pdu>(); completeServerPdu.channelId = channelId; decompressedBuffer.Clear(); } byte[] decompressedData = pdu.virtualChannelData; if (mppcDecompressor != null) // has compression { CompressMode flag = CompressMode.None; if ((pdu.channelPduHeader.flags & CHANNEL_PDU_HEADER_flags_Values.CHANNEL_PACKET_AT_FRONT) == CHANNEL_PDU_HEADER_flags_Values.CHANNEL_PACKET_AT_FRONT) { flag |= CompressMode.SetToFront; } if ((pdu.channelPduHeader.flags & CHANNEL_PDU_HEADER_flags_Values.CHANNEL_PACKET_COMPRESSED) == CHANNEL_PDU_HEADER_flags_Values.CHANNEL_PACKET_COMPRESSED) { flag |= CompressMode.Compressed; } if ((pdu.channelPduHeader.flags & CHANNEL_PDU_HEADER_flags_Values.CHANNEL_PACKET_FLUSHED) == CHANNEL_PDU_HEADER_flags_Values.CHANNEL_PACKET_FLUSHED) { flag |= CompressMode.Flush; } if (flag != CompressMode.None) { decompressedData = mppcDecompressor.Decompress(pdu.virtualChannelData, flag); } } if (completeServerPdu != null) { completeServerPdu.rawPdus.Add(pdu); decompressedBuffer.AddRange(decompressedData); } else { // not need to reassemble Virtual_Channel_Complete_Server_Pdu returnPDU = new Virtual_Channel_Complete_Server_Pdu(); returnPDU.rawPdus = new System.Collections.ObjectModel.Collection <Virtual_Channel_RAW_Server_Pdu>(); returnPDU.channelId = channelId; returnPDU.rawPdus.Add(pdu); returnPDU.virtualChannelData = decompressedData; return(returnPDU); } // the last chunk if ((pdu.channelPduHeader.flags & CHANNEL_PDU_HEADER_flags_Values.CHANNEL_FLAG_LAST) == CHANNEL_PDU_HEADER_flags_Values.CHANNEL_FLAG_LAST) { if (decompressedBuffer != null) { completeServerPdu.virtualChannelData = decompressedBuffer.ToArray(); } Virtual_Channel_Complete_Server_Pdu returnPDU = completeServerPdu; completeServerPdu = null; return(returnPDU); } return(null); }