• 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_DEFAULT 6
26 #define AP_CHANNEL_5G_DEFAULT 149
27 #define WIFI_BSSID_LENGTH 18
28 enum class ApState {
29     AP_STATE_NONE = 0,
30     AP_STATE_IDLE,
31     AP_STATE_STARTING,
32     AP_STATE_STARTED,
33     AP_STATE_CLOSING,
34     AP_STATE_CLOSED,
35 };
36 
37 /* Encryption Mode */
38 enum class KeyMgmt {
39     NONE = 0,
40     WPA_PSK = 1,
41     WPA_EAP = 2,
42     IEEE8021X = 3,
43     WPA2_PSK = 4,
44     OSEN = 5,
45     FT_PSK = 6,
46     FT_EAP = 7
47 };
48 
49 enum class BandType {
50     BAND_NONE = 0, /* unknown */
51     BAND_2GHZ = 1, /* 2.4GHz */
52     BAND_5GHZ = 2, /* 5GHz */
53     BAND_6GHZ = 3, /* 6GHz */
54     BAND_60GHZ = 4, /* 60GHz */
55     BAND_ANY = 5, /* Dual-mode frequency band */
56 };
57 
58 enum class PowerModel {
59     SLEEPING = 0, /* Sleeping model. */
60     GENERAL = 1, /* General model. */
61     THROUGH_WALL = 2, /* Through wall model. */
62 };
63 
64 struct HotspotConfig {
HotspotConfigHotspotConfig65     HotspotConfig()
66     {
67         securityType = KeyMgmt::WPA2_PSK;
68         band = BandType::BAND_2GHZ;
69         channel = AP_CHANNEL_DEFAULT;
70         maxConn = -1;
71     }
72 
SetSsidHotspotConfig73     inline void SetSsid(const std::string &newSsid)
74     {
75         ssid = newSsid;
76     }
GetSsidHotspotConfig77     inline const std::string &GetSsid() const
78     {
79         return ssid;
80     }
81 
SetPreSharedKeyHotspotConfig82     inline void SetPreSharedKey(const std::string &newKey)
83     {
84         preSharedKey = newKey;
85     }
GetPreSharedKeyHotspotConfig86     inline const std::string &GetPreSharedKey() const
87     {
88         return preSharedKey;
89     }
90 
SetSecurityTypeHotspotConfig91     inline void SetSecurityType(KeyMgmt type)
92     {
93         securityType = type;
94     }
GetSecurityTypeHotspotConfig95     inline KeyMgmt GetSecurityType() const
96     {
97         return securityType;
98     }
99 
SetBandHotspotConfig100     inline void SetBand(BandType newBand)
101     {
102         band = newBand;
103     }
GetBandHotspotConfig104     inline BandType GetBand() const
105     {
106         return band;
107     }
108 
SetChannelHotspotConfig109     inline void SetChannel(int32_t newchannel)
110     {
111         channel = newchannel;
112     }
GetChannelHotspotConfig113     inline int32_t GetChannel() const
114     {
115         return channel;
116     }
117 
SetMaxConnHotspotConfig118     inline void SetMaxConn(int32_t newMaxConn)
119     {
120         maxConn = newMaxConn;
121     }
GetMaxConnHotspotConfig122     inline int32_t GetMaxConn() const
123     {
124         return maxConn;
125     }
126 
SetIpAddressHotspotConfig127     inline void SetIpAddress(const std::string &newIpAddress)
128     {
129         ipAddress = newIpAddress;
130     }
131 
GetIpAddressHotspotConfig132     inline const std::string &GetIpAddress() const
133     {
134         return ipAddress;
135     }
136 
137 private:
138     std::string ssid;         /* Hotspot name, The string length range is 1~32 */
139     std::string preSharedKey; /* Hotspot password ,The string length range is 8~63 */
140     KeyMgmt securityType;     /* Hotspot Encryption type, Optional NONE/WPA_PSK/WPA2_PSK */
141     BandType band;
142     int32_t channel;
143     int32_t maxConn;
144     std::string ipAddress;    /* Hotspot IP address of the dhcp server */
145 };
146 
147 struct StationInfo {
148     std::string deviceName; /* Device name */
149     std::string bssid;      /* Device Mac */
150     int bssidType; /* bssid type */
151     std::string ipAddr;     /* Device IP address */
152 };
153 }  // namespace Wifi
154 }  // namespace OHOS
155 #endif