Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpbcgr.RdpbcgrDecoder.DecodeControlPDU C# (CSharp) Method

DecodeControlPDU() public method

[TD Reference 3.2.5.3.20] Decode Control PDU - Cooperate
public DecodeControlPDU ( byte data, byte decryptedUserData, SecurityHeaderType type ) : Microsoft.Protocols.TestTools.StackSdk.StackPacket
data byte data to be parsed
decryptedUserData byte decrypted user data to be parsed
type SecurityHeaderType security header type
return Microsoft.Protocols.TestTools.StackSdk.StackPacket
        public StackPacket DecodeControlPDU(
            byte[] data,
            byte[] decryptedUserData,
            SecurityHeaderType type)
        {
            // data index
            int dataIndex = 0;

            // ControlPDU: commonHeader
            SlowPathPduCommonHeader commonHeader = ParseMcsCommonHeader(data, ref dataIndex, type);

            // user data index
            int userDataIndex = 0;

            // ControlPDU: controlPduData
            TS_CONTROL_PDU controlPduData = ParseTsControlPdu(decryptedUserData, ref userDataIndex);

            // Get pdu by action type
            StackPacket pdu;
            if (controlPduData.action == action_Values.CTRLACTION_COOPERATE)
            {
                // Control PDU - cooperate
                Server_Control_Pdu_Cooperate cooperatePdu = new Server_Control_Pdu_Cooperate();
                cooperatePdu.commonHeader = commonHeader;
                cooperatePdu.controlPduData = controlPduData;
                pdu = cooperatePdu;
            }
            else if (controlPduData.action == action_Values.CTRLACTION_GRANTED_CONTROL)
            {
                // Control PDU - granted control
                Server_Control_Pdu_Granted_Control grantedPdu = new Server_Control_Pdu_Granted_Control();
                grantedPdu.commonHeader = commonHeader;
                grantedPdu.controlPduData = controlPduData;
                pdu = grantedPdu;
            }
            else
            {
                throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED);
            }

            // Check if data length exceeded expectation
            VerifyDataLength(decryptedUserData.Length, userDataIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED);
            return pdu;
        }
RdpbcgrDecoder