/// <summary> /// [TD Reference 3.2.5.3.20] /// Decode Control PDU - Cooperate /// </summary> /// <param name="data">data to be parsed</param> /// <param name="decryptedUserData">decrypted user data to be parsed</param> /// <param name="type">security header type</param> /// <returns>decoded Control PDU</returns> 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; }