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 
16 #include "wifi_backup_config.h"
17 
18 namespace OHOS {
19 namespace Wifi {
ConvertBackupCfgToDeviceCfg(const WifiBackupConfig & backupCfg,WifiDeviceConfig & config)20 void ConvertBackupCfgToDeviceCfg(const WifiBackupConfig &backupCfg, WifiDeviceConfig &config)
21 {
22     config.instanceId = backupCfg.instanceId;
23     config.uid = backupCfg.uid;
24     config.status = backupCfg.status;
25     config.bssid = backupCfg.bssid;
26     config.userSelectBssid = backupCfg.userSelectBssid;
27     config.ssid = backupCfg.ssid;
28     config.priority = backupCfg.priority;
29     config.hiddenSSID = backupCfg.hiddenSSID;
30     config.keyMgmt = backupCfg.keyMgmt;
31     config.networkStatusHistory = backupCfg.networkStatusHistory;
32     config.isPortal = backupCfg.isPortal;
33     config.lastHasInternetTime = backupCfg.lastHasInternetTime;
34     config.noInternetAccess = backupCfg.noInternetAccess;
35     config.preSharedKey = backupCfg.preSharedKey;
36     config.wepTxKeyIndex = backupCfg.wepTxKeyIndex;
37     for (int i = 0; i < WEPKEYS_SIZE; i++) {
38         config.wepKeys[i] = backupCfg.wepKeys[i];
39     }
40     config.wifiIpConfig = backupCfg.wifiIpConfig;
41     config.wifiProxyconfig = backupCfg.wifiProxyconfig;
42     config.wifiPrivacySetting = backupCfg.wifiPrivacySetting;
43 }
44 
ConvertDeviceCfgToBackupCfg(const WifiDeviceConfig & config,WifiBackupConfig & backupCfg)45 void ConvertDeviceCfgToBackupCfg(const WifiDeviceConfig &config, WifiBackupConfig &backupCfg)
46 {
47     backupCfg.instanceId = config.instanceId;
48     backupCfg.uid = config.uid;
49     backupCfg.status = config.status;
50     backupCfg.bssid = config.bssid;
51     backupCfg.userSelectBssid = config.userSelectBssid;
52     backupCfg.ssid = config.ssid;
53     backupCfg.priority = config.priority;
54     backupCfg.hiddenSSID = config.hiddenSSID;
55     backupCfg.keyMgmt = config.keyMgmt;
56     backupCfg.networkStatusHistory = config.networkStatusHistory;
57     backupCfg.isPortal = config.isPortal;
58     backupCfg.lastHasInternetTime = config.lastHasInternetTime;
59     backupCfg.noInternetAccess = config.noInternetAccess;
60     backupCfg.preSharedKey = config.preSharedKey;
61     backupCfg.wepTxKeyIndex = config.wepTxKeyIndex;
62     for (int i = 0; i < WEPKEYS_SIZE; i++) {
63         backupCfg.wepKeys[i] = config.wepKeys[i];
64     }
65     backupCfg.wifiIpConfig = config.wifiIpConfig;
66     backupCfg.wifiProxyconfig = config.wifiProxyconfig;
67     backupCfg.wifiPrivacySetting = config.wifiPrivacySetting;
68 }
69 }  // namespace Wifi
70 }  // namespace OHOS