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;
}