• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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_AP_MSG_H
17 #define OHOS_WIFI_AP_MSG_H
18 #include <cstdint>
19 #include <set>
20 #include <string>
21 #include "wifi_common_msg.h"
22 
23 namespace OHOS {
24 namespace Wifi {
25 #define AP_CHANNEL_INVALID (-1)
26 #define AP_CHANNEL_DEFAULT 6
27 #define AP_CHANNEL_5G_DEFAULT 149
28 #define AP_CHANNEL_5G_NOT_RECOMMEND (165)  // cannot group bandwidth of 40M or above
29 #define WIFI_BSSID_LENGTH 18
30 #define DHCP_LEASE_TIME_MIN 60
31 #define DHCP_LEASE_TIME 21600
32 #define WIFI_SSID_MAX_LEN 32
33 #define WIFI_IP_MAX_LEN 15
34 #define AP_BANDWIDTH_DEFAULT 0
35 #define AP_BANDWIDTH_160 8
36 #define AP_CHANNEL_5G_160M_DEFAULT 36
37 #define AP_CHANNEL_5G_160M_SET_BEGIN 36
38 #define AP_CHANNEL_5G_160M_SET_END 48
39 
40 enum class ApState {
41     AP_STATE_NONE = 0,
42     AP_STATE_IDLE,
43     AP_STATE_STARTING,
44     AP_STATE_STARTED,
45     AP_STATE_CLOSING,
46     AP_STATE_CLOSED,
47 };
48 
49 /* Encryption Mode */
50 enum class KeyMgmt {
51     NONE = 0,
52     WPA_PSK = 1,
53     WPA_EAP = 2,
54     IEEE8021X = 3,
55     WPA2_PSK = 4,
56     OSEN = 5,
57     FT_PSK = 6,
58     FT_EAP = 7
59 };
60 
61 enum class BandType {
62     BAND_NONE = 0, /* unknown */
63     BAND_2GHZ = 1, /* 2.4GHz */
64     BAND_5GHZ = 2, /* 5GHz */
65     BAND_6GHZ = 3, /* 6GHz */
66     BAND_60GHZ = 4, /* 60GHz */
67     BAND_ANY = 5, /* Dual-mode frequency band */
68 };
69 
70 enum class PowerModel {
71     SLEEPING = 0, /* Sleeping model. */
72     GENERAL = 1, /* General model. */
73     THROUGH_WALL = 2, /* Through wall model. */
74 };
75 
76 struct HotspotConfig {
HotspotConfigHotspotConfig77     HotspotConfig()
78     {
79         securityType = KeyMgmt::WPA2_PSK;
80         band = BandType::BAND_2GHZ;
81         channel = AP_CHANNEL_DEFAULT;
82         maxConn = -1;
83         leaseTime = DHCP_LEASE_TIME;
84         apBandWidth = AP_BANDWIDTH_DEFAULT;
85     }
86 
SetSsidHotspotConfig87     inline void SetSsid(const std::string &newSsid)
88     {
89         ssid = newSsid;
90     }
GetSsidHotspotConfig91     inline const std::string &GetSsid() const
92     {
93         return ssid;
94     }
95 
SetPreSharedKeyHotspotConfig96     inline void SetPreSharedKey(const std::string &newKey)
97     {
98         preSharedKey = newKey;
99     }
GetPreSharedKeyHotspotConfig100     inline const std::string &GetPreSharedKey() const
101     {
102         return preSharedKey;
103     }
104 
SetSecurityTypeHotspotConfig105     inline void SetSecurityType(KeyMgmt type)
106     {
107         securityType = type;
108     }
GetSecurityTypeHotspotConfig109     inline KeyMgmt GetSecurityType() const
110     {
111         return securityType;
112     }
113 
SetBandHotspotConfig114     inline void SetBand(BandType newBand)
115     {
116         band = newBand;
117     }
GetBandHotspotConfig118     inline BandType GetBand() const
119     {
120         return band;
121     }
122 
SetBandWidthHotspotConfig123     inline void SetBandWidth(int32_t BandWidth)
124     {
125         apBandWidth = BandWidth;
126     }
GetBandWidthHotspotConfig127     inline int32_t GetBandWidth() const
128     {
129         return apBandWidth;
130     }
131 
SetChannelHotspotConfig132     inline void SetChannel(int32_t newchannel)
133     {
134         channel = newchannel;
135     }
GetChannelHotspotConfig136     inline int32_t GetChannel() const
137     {
138         return channel;
139     }
140 
SetMaxConnHotspotConfig141     inline void SetMaxConn(int32_t newMaxConn)
142     {
143         maxConn = newMaxConn;
144     }
GetMaxConnHotspotConfig145     inline int32_t GetMaxConn() const
146     {
147         return maxConn;
148     }
149 
SetIpAddressHotspotConfig150     inline void SetIpAddress(const std::string &newIpAddress)
151     {
152         ipAddress = newIpAddress;
153     }
154 
GetIpAddressHotspotConfig155     inline const std::string &GetIpAddress() const
156     {
157         return ipAddress;
158     }
159 
SetLeaseTimeHotspotConfig160     inline void SetLeaseTime(int32_t newLeaseTime)
161     {
162         leaseTime = newLeaseTime;
163     }
164 
GetLeaseTimeHotspotConfig165     inline int32_t GetLeaseTime() const
166     {
167         return leaseTime;
168     }
169 private:
170     std::string ssid;         /* Hotspot name, The string length range is 1~32 */
171     std::string preSharedKey; /* Hotspot password ,The string length range is 8~63 */
172     KeyMgmt securityType;     /* Hotspot Encryption type, Optional NONE/WPA_PSK/WPA2_PSK */
173     BandType band;
174     int32_t channel;
175     int32_t maxConn;
176     std::string ipAddress;    /* Hotspot IP address of the dhcp server */
177     int32_t leaseTime;
178     int32_t apBandWidth;
179 };
180 
181 struct StationInfo {
182     std::string deviceName; /* Device name */
183     std::string bssid;      /* Device Mac */
184     int bssidType; /* bssid type */
185     std::string ipAddr;     /* Device IP address */
186 };
187 }  // namespace Wifi
188 }  // namespace OHOS
189 #endif