${DAEMON_PATH}/src/TAInstance.cpp
${DAEMON_PATH}/src/TEEConnectionHandler.cpp
${DAEMON_PATH}/src/TEEContext.cpp
+ ${DAEMON_PATH}/src/UUIDConfig.cpp
+ ${DAEMON_PATH}/src/UUIDConfigManager.cpp
+ ${DAEMON_PATH}/src/UUIDComparator.cpp
${DAEMON_PATH}/src/ClientCommands/CommandCloseSession.cpp
${DAEMON_PATH}/src/ClientCommands/CommandCloseTASession.cpp
${DAEMON_PATH}/src/ClientCommands/CommandFinContext.cpp
--- /dev/null
+
+/**
+ * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @author Igor Kotrasinski (i.kotrasinsk@partner.samsung.com)
+ * @brief Class for storing UUID-specific user configuration.
+ */
+
+#ifndef UUIDCONFIG_H_
+#define UUIDCONFIG_H_
+
+#include <mutex>
+#include <boost/optional.hpp>
+#include <boost/none.hpp>
+
+class UUIDConfig {
+public:
+ boost::optional<uint32_t> getDebugPort();
+ void setDebugPort(uint32_t port);
+ void clearDebugPort();
+private:
+ boost::optional<uint32_t> m_debugPort = boost::none;
+ std::mutex m_lock{};
+};
+
+#endif /* UUIDCONFIG_H_ */
--- /dev/null
+/**
+ * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @author Igor Kotrasinski (i.kotrasinsk@partner.samsung.com)
+ * @brief Class for storing UUID-specific user configuration.
+ */
+
+#ifndef UUIDCONFIGMANAGER_H_
+#define UUIDCONFIGMANAGER_H_
+
+#include <map>
+#include <memory>
+#include <mutex>
+
+#include "tee_client_api.h"
+#include "UUIDUtils.h"
+#include "UUIDConfig.h"
+
+class UUIDConfigManager {
+private:
+ static std::shared_ptr<UUIDConfigManager> instance;
+ std::map<TEEC_UUID, std::shared_ptr<UUIDConfig>, UUIDComparator> m_TAMap{};
+ std::mutex m_mapLock{};
+public:
+ static std::shared_ptr<UUIDConfigManager> getInstance();
+ std::shared_ptr<UUIDConfig> at(const TEEC_UUID &uuid);
+ std::shared_ptr<UUIDConfig> operator[](const TEEC_UUID &uuid);
+ void erase(const TEEC_UUID &uuid);
+};
+
+#endif /* UUIDCONFIGMANAGER_H_ */
--- /dev/null
+/**
+ * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @author Igor Kotrasinski (i.kotrasinsk@partner.samsung.com)
+ * @brief UUID handling utilities.
+ */
+
+#ifndef UUIDUTILS_H_
+#define UUIDUTILS_H_
+
+class UUIDComparator {
+public:
+ bool operator() (const TEEC_UUID &u1, const TEEC_UUID &u2);
+private:
+ bool compareSeq (const TEEC_UUID &u1, const TEEC_UUID &u2);
+};
+
+#endif /* UUIDUTILS_H_ */
--- /dev/null
+/**
+ * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @author Igor Kotrasinski (i.kotrasinsk@partner.samsung.com)
+ * @brief Class for storing UUID-specific user configuration.
+ */
+
+#include "tee_client_api.h"
+#include "UUIDUtils.h"
+
+bool UUIDComparator::operator() (const TEEC_UUID &u1, const TEEC_UUID &u2) {
+ if (u1.timeLow != u2.timeLow)
+ return u1.timeLow < u2.timeLow;
+ if (u1.timeMid != u2.timeMid)
+ return u1.timeMid < u2.timeMid;
+ if (u1.timeHiAndVersion != u2.timeHiAndVersion)
+ return u1.timeHiAndVersion < u2.timeHiAndVersion;
+ return compareSeq(u1, u2);
+}
+
+bool UUIDComparator::compareSeq(const TEEC_UUID &u1, const TEEC_UUID &u2) {
+ for (int i = 0; i < 8; i++) {
+ if (u1.clockSeqAndNode[i] !=
+ u2.clockSeqAndNode[i])
+ return (u1.clockSeqAndNode[i] <
+ u2.clockSeqAndNode[i]);
+ }
+ return false;
+}
--- /dev/null
+/**
+ * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @author Igor Kotrasinski (i.kotrasinsk@partner.samsung.com)
+ * @brief Class for storing UUID-specific user configuration.
+ */
+
+#include <cstdint>
+#include <mutex>
+#include <boost/optional.hpp>
+#include <boost/none.hpp>
+#include "UUIDConfig.h"
+
+void UUIDConfig::setDebugPort(uint32_t port)
+{
+ std::lock_guard<std::mutex> guard(m_lock);
+ m_debugPort = port;
+}
+
+boost::optional<uint32_t> UUIDConfig::getDebugPort()
+{
+ std::lock_guard<std::mutex> guard(m_lock);
+ return m_debugPort;
+}
+
+void UUIDConfig::clearDebugPort()
+{
+ std::lock_guard<std::mutex> guard(m_lock);
+ m_debugPort = boost::none;
+}
--- /dev/null
+/**
+ * Copyright (c) 2015-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @author Igor Kotrasinski (i.kotrasinsk@partner.samsung.com)
+ * @brief Class for storing UUID-specific user configuration.
+ */
+
+#include <map>
+#include <memory>
+#include <mutex>
+
+#include "tee_client_api.h"
+#include "UUIDUtils.h"
+#include "UUIDConfig.h"
+#include "UUIDConfigManager.h"
+
+
+std::shared_ptr<UUIDConfigManager> UUIDConfigManager::instance{};
+
+std::shared_ptr<UUIDConfigManager> UUIDConfigManager::getInstance()
+{
+ if (!instance) {
+ instance = std::shared_ptr<UUIDConfigManager>(
+ new UUIDConfigManager);
+ }
+ return instance;
+}
+
+std::shared_ptr<UUIDConfig> UUIDConfigManager::at(const TEEC_UUID &uuid)
+{
+ std::lock_guard<std::mutex> guard(m_mapLock);
+ return m_TAMap.at(uuid);
+};
+
+std::shared_ptr<UUIDConfig> UUIDConfigManager::operator[](const TEEC_UUID &uuid)
+{
+ std::lock_guard<std::mutex> guard(m_mapLock);
+ try {
+ return m_TAMap.at(uuid);
+ } catch (std::out_of_range) {
+ std::shared_ptr<UUIDConfig> newUUIDConf =
+ std::shared_ptr<UUIDConfig>(new UUIDConfig());
+ m_TAMap[uuid] = newUUIDConf;
+ return newUUIDConf;
+ }
+}
+
+void UUIDConfigManager::erase(const TEEC_UUID &uuid)
+{
+ std::lock_guard<std::mutex> guard(m_mapLock);
+ m_TAMap.erase(uuid);
+}