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 #ifndef WIFI_CONFIG_INFO_H
17 #define WIFI_CONFIG_INFO_H
18 
19 #include "interface_info.h"
20 
21 namespace OHOS::SoftBus {
22 enum class WifiConfigInfoKey {
23     INVALID = 0,
24     VERSION = 1,
25     IS_P2P_CHANNEL_OPTIMIZE_ENABLE = 2,
26     IS_DBDC_SUPPORTED = 3,
27     IS_CSA_SUPPORTED = 4,
28     IS_RADAR_DETECTION_SUPPORTED = 5,
29     IS_DFS_P2P_SUPPORTED = 6,
30     IS_INDOOR_P2P_SUPPORTED = 7,
31     STA_CHANNEL = 8,
32     STA_PORTAL_STATE = 9,
33     STA_SSID = 10,
34     STA_BSSID = 11,
35     STA_INTERNET_STATE = 12,
36     P2P_CHANNEL_LIST = 13,
37     STA_PWD = 14,
38     STA_ENCRYPT_MODE = 15,
39     IS_CONNECTED_TO_HW_ROUTER = 16,
40     DEVICE_TYPE = 17,
41     IGNORE = 18,
42     DEVICE_ID = 19,
43     INTERFACE_INFO_ARRAY = 20,
44     WC_KEY_MAX,
45 };
46 
47 class WifiConfigInfo : public Serializable, public InfoContainer<WifiConfigInfoKey> {
48 public:
49     WifiConfigInfo() = default;
50     explicit WifiConfigInfo(std::vector<uint8_t> &config);
51     ~WifiConfigInfo() override = default;
52 
53     int Marshalling(WifiDirectProtocol &protocol, std::vector<uint8_t> &output) const override;
54     int Unmarshalling(WifiDirectProtocol &protocol, const std::vector<uint8_t> &input) override;
55 
56     void SetInterfaceInfoArray(const std::vector<InterfaceInfo> &value);
57     std::vector<InterfaceInfo> GetInterfaceInfoArray() const;
58     InterfaceInfo GetInterfaceInfo(const std::string &name) const;
59 
60     void SetDeviceId(const std::string &value);
61     std::string GetDeviceId() const;
62 
63 private:
64     static constexpr int HEADER_LEN = 2;
65     void MarshallingInterfaceArray(WifiDirectProtocol &protocol) const;
66     void UnmarshallingInterfaceArray(WifiDirectProtocol &protocol, uint8_t *data, size_t size);
67 };
68 } // namespace OHOS::SoftBus
69 #endif // WIFI_CONFIG_INFO_H