The RDP Negotiation Failure structure is used by a server to inform the client of a failure that has occurred while preparing security for the connection.
Inheritance: RdpbcgrServerPdu
        /// <summary>
        /// [TD Reference 3.2.5.3.2]
        /// Decode X.224 Connection Confirm PDU
        /// </summary>
        /// <param name="data">data to be parsed</param>
        /// <returns>decoded X.224 Connection Confirm PDU</returns>
        public StackPacket DecodeX224ConnectionConfirmPDU(byte[] data)
        {
            // initialize
            int currentIndex = 0;
            StackPacket pdu = null;

            // TpktHeader
            TpktHeader tpktHeader = ParseTpktHeader(data, ref currentIndex);

            // X224Crq
            X224Crq x224Ccf = ParseX224Crq(data, ref currentIndex);

            // RDP_NEG_RSP/RDP_NEG_FAILURE (optional field)
            if (currentIndex < data.Length)
            {
                // check type
                byte pduType = data[currentIndex];
                if (pduType == (byte)RDP_NEG_RSP_type_Values.V1)
                {
                    // X224 Connection Confirm PDU
                    Server_X_224_Connection_Confirm_Pdu confirmPdu = new Server_X_224_Connection_Confirm_Pdu();

                    // Server_X_224_Connection_Confirm_Pdu: tpktHeader & x224Ccf
                    confirmPdu.tpktHeader = tpktHeader;
                    confirmPdu.x224Ccf = x224Ccf;

                    // Server_X_224_Connection_Confirm_Pdu: rdpNegData
                    confirmPdu.rdpNegData = ParseRdpNegRsp(data, ref currentIndex);

                    pdu = confirmPdu;
                }
                else if (pduType == (byte)RDP_NEG_FAILURE_type_Values.V1)
                {
                    // X224 Negotiate Failure PDU
                    Server_X_224_Negotiate_Failure_Pdu failurePdu = new Server_X_224_Negotiate_Failure_Pdu();

                    // Server_X_224_Negotiate_Failure_Pdu: tpktHeader & x224Ccf
                    failurePdu.tpktHeader = tpktHeader;
                    failurePdu.x224Ccf = x224Ccf;

                    // Server_X_224_Negotiate_Failure_Pdu: rdpNegFailure
                    failurePdu.rdpNegFailure = ParseRdpNegFailure(data, ref currentIndex);

                    pdu = failurePdu;
                }
                else
                {
                    throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED);
                }
            }
            else
            {
                // X224 Connection Confirm PDU
                Server_X_224_Connection_Confirm_Pdu confirmPdu = new Server_X_224_Connection_Confirm_Pdu();

                // Server_X_224_Connection_Confirm_Pdu: tpktHeader
                confirmPdu.tpktHeader = tpktHeader;

                // Server_X_224_Connection_Confirm_Pdu: x224Ccf
                confirmPdu.x224Ccf = x224Ccf;

                // Server_X_224_Connection_Confirm_Pdu: rdpNegData (absent)
                confirmPdu.rdpNegData = null;

                pdu = confirmPdu;
            }

            // Check if data length exceeded expectation
            VerifyDataLength(data.Length, currentIndex, ConstValue.ERROR_MESSAGE_DATA_LENGTH_EXCEEDED);
            return pdu;
        }
Esempio n. 2
0
        /// <summary>
        /// Create an instance of the class that is identical to the current PDU. 
        /// </summary>
        /// <returns>The new instance.</returns>
        public override StackPacket Clone()
        {
            Server_X_224_Negotiate_Failure_Pdu cloneServerX224Failure = new Server_X_224_Negotiate_Failure_Pdu(serverSessionContext);

            cloneServerX224Failure.tpktHeader = tpktHeader;
            cloneServerX224Failure.x224Ccf = x224Ccf;
            if (rdpNegFailure != null)
            {
                cloneServerX224Failure.rdpNegFailure = new RDP_NEG_FAILURE();
                cloneServerX224Failure.rdpNegFailure.failureCode = rdpNegFailure.failureCode;
                cloneServerX224Failure.rdpNegFailure.flags = rdpNegFailure.flags;
                cloneServerX224Failure.rdpNegFailure.length = rdpNegFailure.length;
                cloneServerX224Failure.rdpNegFailure.type = rdpNegFailure.type;
            }

            return cloneServerX224Failure;
        }