The RDP_SEGMENTED_DATA structure is used to wrap one or more RDP_DATA_SEGMENT (section 2.2.5.2) structures. Each segment contains data that has been encoded using RDP 8.0 Bulk Compression techniques (section 3.1.9.1).
Inheritance: BasePDU
Ejemplo n.º 1
0
        /// <summary>
        /// Create a DataCompressedDvcPdu
        /// </summary>
        /// <param name="channelId"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public DataCompressedDvcPdu[] CreateCompressedDataPdu(uint channelId, byte[] data)
        {
            MemoryStream ms = new MemoryStream(data);
            List <DataCompressedDvcPdu> pdus = new List <DataCompressedDvcPdu>();

            byte[] compressed = CompressDataToRdp8BulkEncodedData(data, PACKET_COMPR_FLAG.PACKET_COMPR_TYPE_LITE | PACKET_COMPR_FLAG.PACKET_COMPRESSED);

            DataCompressedDvcPdu pdu = new DataCompressedDvcPdu();

            pdu.HeaderBits.Cmd         = Cmd_Values.DataCompressed;
            pdu.HeaderBits.Sp          = 0x0;
            pdu.HeaderBits.CbChannelId = cbChId_Values.OneByte;
            pdu.ChannelId = channelId;

            RDP_SEGMENTED_DATA rdpSegmentedData = new RDP_SEGMENTED_DATA();

            rdpSegmentedData.descriptor = DescriptorTypes.SINGLE;

            RDP8_BULK_ENCODED_DATA rdp8BulkEncodedData = new RDP8_BULK_ENCODED_DATA();

            rdp8BulkEncodedData.header = (byte)(PACKET_COMPR_FLAG.PACKET_COMPR_TYPE_LITE | PACKET_COMPR_FLAG.PACKET_COMPRESSED);
            rdp8BulkEncodedData.data   = compressed;

            pdu.Data = PduMarshaler.Marshal(rdpSegmentedData);
            pdus.Add(pdu);
            return(pdus.ToArray());
        }
Ejemplo n.º 2
0
        public uint segmentPartSize;                  // The pure data size in a single RDP8_BULK_ENCODED_DATA structure
        #endregion variables

        /// <summary>
        /// Contructor.
        /// </summary>
        /// <param name="descType"> Indicates if a single or multipart segment PDU.</param>
        /// <param name="compFlag">Indicates the data is compressed and the compress type.</param>
        public RdpSegmentedPdu(byte compFlag, uint segSize)
        {
            compressFlag    = compFlag;
            segmentPartSize = segSize;

            segHeadList = new List <RDP_SEGMENTED_DATA>();
            segPduList  = new List <byte[]>();

            segHeader = new RDP_SEGMENTED_DATA();
        }
        public List<byte[]> segPduList; // List of segment PDU, include segment header.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Contructor. 
        /// </summary>
        /// <param name="descType"> Indicates if a single or multipart segment PDU.</param>
        /// <param name="compFlag">Indicates the data is compressed and the compress type.</param>
        public RdpSegmentedPdu(byte compFlag, uint segSize)
        {
            compressFlag = compFlag;
            segmentPartSize = segSize;

            segHeadList = new List<RDP_SEGMENTED_DATA>();
            segPduList = new List<byte[]>();

            segHeader = new RDP_SEGMENTED_DATA();
        }
        /// <summary>
        /// Process DVC Data
        /// </summary>
        /// <param name="pdu"></param>
        private void ProcessDataPdu(DataDvcBasePdu pdu)
        {
            if (pdu is DataFirstDvcPdu)
            {
                dataFragmentManager = new DataFragmentManager();
                DataFirstDvcPdu first = (DataFirstDvcPdu)pdu;
                dataFragmentManager.AddFirstData(first.Length, first.Data);
            }
            else if (pdu is DataDvcPdu)
            {
                if (dataFragmentManager == null)
                {
                    // Single data PDU which is not fragmented.
                    if (this.Received != null)
                    {
                        this.Received(pdu.Data, this.ChannelId);
                    }
                    return;
                }
                else
                {
                    // Received a fragment.
                    dataFragmentManager.AppendData(pdu.Data);
                }
            }
            else if (pdu is DataCompressedDvcPdu)
            {
                CompressFactory Compressor = new CompressFactory();
                if (dataFragmentManager == null)
                {
                    RDP_SEGMENTED_DATA segData = new RDP_SEGMENTED_DATA();
                    bool fResult = PduMarshaler.Unmarshal(pdu.Data, segData);
                    if (fResult)
                    {
                        if (segData.descriptor == DescriptorTypes.SINGLE)
                        {
                            byte[] rawData = Compressor.Decompress(segData.bulkData.data, segData.bulkData.header);
                            // Single data PDU which is not fragmented.
                            if (this.Received != null)
                            {
                                this.Received(rawData, this.ChannelId);
                            }
                            return;
                        }
                    }
                }
                else
                {
                    // Received a fragment.
                    dataFragmentManager.AppendData(pdu.Data);
                }
            }

            if (dataFragmentManager.Completed)
            {
                if (this.Received != null)
                {
                    this.Received(dataFragmentManager.Data, this.ChannelId);
                }
                dataFragmentManager = null;
            }
        }