1 /*
2  * Copyright (C) 2021-2023 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 OHOS_WIFI_INTER_SCAN_INFO_H
17 #define OHOS_WIFI_INTER_SCAN_INFO_H
18 
19 #include "wifi_scan_msg.h"
20 namespace OHOS {
21 namespace Wifi {
22 constexpr int WIFI_MODE_UNDEFINED = 0;
23 constexpr int WIFI_802_11A = 1;
24 constexpr int WIFI_802_11B = 2;
25 constexpr int WIFI_802_11G = 3;
26 constexpr int WIFI_802_11N = 4;
27 constexpr int WIFI_802_11AC = 5;
28 constexpr int WIFI_802_11AX = 6;
29 
30 enum class Ant {
31     NETWORK_PRIVATE = 0,
32     NETWORK_PRIVATEWITHGUEST = 1,
33     NETWORK_CHARGEABLEPUBLIC = 2,
34     NETWORK_FREEPUBLIC = 3,
35     NETWORK_PERSONAL = 4,
36     NETWORK_EMERGENCYONLY = 5,
37     NETWORK_RESVD6 = 6,
38     NETWORK_RESVD7 = 7,
39     NETWORK_RESVD8 = 8,
40     NETWORK_RESVD9 = 9,
41     NETWORK_RESVD10 = 10,
42     NETWORK_RESVD11 = 11,
43     NETWORK_RESVD12 = 12,
44     NETWORK_RESVD13 = 13,
45     NETWORK_TESTOREXPERIMENTAL = 14,
46     NETWORK_WILDCARD = 15,
47     NETWORK_ANT_INVALID = 16
48 };
49 
50 struct InterScanInfo {
51     std::string bssid;
52     std::string ssid;
53     // Original SSID, used to store the original SSID of different charts like GBK, UTF-8, etc.
54     std::string oriSsid;
55     /**
56      * Network performance, including authentication,
57      * key management, and encryption mechanisms
58      * supported by the access point
59      */
60     std::string capabilities;
61     int frequency;
62     int band;  /* ap band, 1: 2.4G, 2: 5G */
63     WifiChannelWidth channelWidth;
64     int centerFrequency0;
65     int centerFrequency1;
66     int rssi; /* signal level */
67     WifiSecurity securityType;
68     std::vector<WifiInfoElem> infoElems;
69     int64_t features;
70     int64_t timestamp;
71     Ant ant;
72     int wifiMode;
73     bool isVhtInfoExist;
74     bool isHtInfoExist;
75     bool isHeInfoExist;
76     bool isErpExist;
77     int maxRates;
78     bool isHiLinkNetwork;
79     WifiCategory supportedWifiCategory;
80 
InterScanInfoInterScanInfo81     InterScanInfo()
82         : frequency(0),
83           band(0),
84           channelWidth(WifiChannelWidth::WIDTH_INVALID),
85           centerFrequency0(0),
86           centerFrequency1(0),
87           rssi(0),
88           securityType(WifiSecurity::INVALID),
89           features(0),
90           timestamp(0),
91           ant(Ant::NETWORK_ANT_INVALID),
92           wifiMode(WIFI_MODE_UNDEFINED),
93           isVhtInfoExist(false),
94           isHtInfoExist(false),
95           isHeInfoExist(false),
96           isErpExist(false),
97           maxRates(0),
98           isHiLinkNetwork(false),
99           supportedWifiCategory(WifiCategory::DEFAULT) {}
100 
~InterScanInfoInterScanInfo101     ~InterScanInfo() {}
102 
GetDeviceMgmtInterScanInfo103     void GetDeviceMgmt(std::string &mgmt) const
104     {
105         switch (securityType) {
106             case WifiSecurity::PSK:
107                 mgmt = "WPA-PSK";
108                 break;
109             case WifiSecurity::EAP:
110                 mgmt = "WPA-EAP";
111                 break;
112             case WifiSecurity::SAE:
113                 mgmt = "SAE";
114                 break;
115             case WifiSecurity::OWE:
116                 mgmt = "OWE";
117                 break;
118             case WifiSecurity::WEP:
119                 mgmt = "WEP";
120                 break;
121             case WifiSecurity::EAP_SUITE_B:
122                 mgmt = "WPA-EAP-SUITE-B-192";
123                 break;
124             case WifiSecurity::WAPI_CERT:
125                 mgmt = "WAPI-CERT";
126                 break;
127             case WifiSecurity::WAPI_PSK:
128                 mgmt = "WAPI-PSK";
129                 break;
130             case WifiSecurity::PSK_SAE:
131                 mgmt = "WPA-PSK+SAE";
132                 break;
133             default:
134                 mgmt = "NONE";
135                 break;
136         }
137     }
138 
GetWifiStandardInterScanInfo139     void GetWifiStandard(int &standard) const
140     {
141         standard = wifiMode;
142     }
143 
IsWifi11bModeInterScanInfo144     bool IsWifi11bMode() const
145     {
146         return wifiMode == WIFI_802_11B;
147     }
148 };
149 }
150 }
151 #endif
152