public Virtual_Channel_RAW_Pdu_Ex(Virtual_Channel_RAW_Pdu originalPacket, RdpbcgrClientContext clientContext) : base(clientContext) { this.commonHeader = originalPacket.commonHeader; this.channelPduHeader = originalPacket.channelPduHeader; this.virtualChannelData = originalPacket.virtualChannelData; }
/// <summary> /// Reasemble Chunk Data /// </summary> /// <param name="pdu"></param> /// <returns></returns> internal Virtual_Channel_Complete_Pdu ReassembleChunkData(Virtual_Channel_RAW_Pdu pdu) { if (!channelDicById.ContainsKey(pdu.commonHeader.channelId)) { // drop the pdu if the channel id does not exist //return null; throw new ArgumentException("The channel id of the pdu does not exist!"); } ServerStaticVirtualChannel channel = (ServerStaticVirtualChannel)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_Pdu channelPdu = new Virtual_Channel_RAW_Pdu(context); RdpbcgrUtility.FillCommonHeader(ref channelPdu.commonHeader, TS_SECURITY_HEADER_flags_Values.SEC_IGNORE_SEQNO | TS_SECURITY_HEADER_flags_Values.SEC_RESET_SEQNO, context, channelId); channelPdu.virtualChannelData = SVCData; channelPdu.channelPduHeader = channelPduHeader; context.Client.SendPdu(channelPdu); }
/// <summary> /// Decompress the virtual channel data into decompressedBuffer buffer. /// After decompressing the last pdu, the member decompressedBuffer contains /// the complete virtual data. /// </summary> /// <param name="pdu">The virtual channel pdu includes header and data.</param> /// <returns>If the reassemble is complete, then return the completePdu. Else return null.</returns> internal Virtual_Channel_Complete_Pdu ReassembleChunkData(Virtual_Channel_RAW_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) { completePdu = new Virtual_Channel_Complete_Pdu(); completePdu.rawPdus = new System.Collections.ObjectModel.Collection <Virtual_Channel_RAW_Pdu>(); completePdu.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 (completePdu != null) { completePdu.rawPdus.Add(pdu); decompressedBuffer.AddRange(decompressedData); } else { // not need to reassemble Virtual_Channel_Complete_Pdu returnPDU = new Virtual_Channel_Complete_Pdu(); returnPDU.rawPdus = new System.Collections.ObjectModel.Collection <Virtual_Channel_RAW_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) { completePdu.virtualChannelData = decompressedBuffer.ToArray(); } Virtual_Channel_Complete_Pdu returnPDU = completePdu; completePdu = null; return(returnPDU); } return(null); }