/// <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; }
/// <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_Connection_Confirm_Pdu cloneServerX224Confirm = new Server_X_224_Connection_Confirm_Pdu(serverSessionContext); cloneServerX224Confirm.tpktHeader = tpktHeader; cloneServerX224Confirm.x224Ccf = x224Ccf; if (rdpNegData != null) { cloneServerX224Confirm.rdpNegData = new RDP_NEG_RSP(); cloneServerX224Confirm.rdpNegData.flags = rdpNegData.flags; cloneServerX224Confirm.rdpNegData.length = rdpNegData.length; cloneServerX224Confirm.rdpNegData.selectedProtocol = rdpNegData.selectedProtocol; cloneServerX224Confirm.rdpNegData.type = rdpNegData.type; } return cloneServerX224Confirm; }