1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_DHCP_RESULT_STORE_MANAGER_H 16 #define OHOS_DHCP_RESULT_STORE_MANAGER_H 17 18 #include <string> 19 #include <mutex> 20 #include <unistd.h> 21 #include "dhcp_client_def.h" 22 23 namespace OHOS { 24 namespace DHCP { 25 class DhcpResultStoreManager { 26 public: 27 DhcpResultStoreManager(); 28 ~DhcpResultStoreManager(); 29 static DhcpResultStoreManager &GetInstance(); 30 int32_t SaveIpInfoInLocalFile(const IpInfoCached ipInfo); 31 int32_t GetCachedIp(const std::string targetBssid, IpInfoCached &outIpResult); 32 int32_t RemoveCachedIp(const IpInfoCached &cacheInfo); 33 int32_t AddCachedIp(const IpInfoCached &cacheInfo); 34 35 private: 36 void SetConfigFilePath(const std::string &fileName); 37 int32_t LoadAllIpCached(const std::string &fileName); 38 int32_t SaveConfig(); 39 40 private: 41 std::mutex m_ipResultMutex; 42 std::vector<IpInfoCached> m_allIpCached; 43 std::string m_fileName; 44 }; 45 } // namespace DHCP 46 } // namespace OHOS 47 #endif 48