• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 <string>
20 
21 namespace OHOS {
22 namespace Wifi {
23 #define AP_CHANNEL_DEFAULT 6
24 #define AP_CHANNEL_5G_DEFAULT 149
25 enum class ApState {
26     AP_STATE_NONE = 0,
27     AP_STATE_IDLE,
28     AP_STATE_STARTING,
29     AP_STATE_STARTED,
30     AP_STATE_CLOSING,
31     AP_STATE_CLOSED,
32 };
33 
34 /* Encryption Mode */
35 enum class KeyMgmt {
36     NONE = 0,
37     WPA_PSK = 1,
38     WPA_EAP = 2,
39     IEEE8021X = 3,
40     WPA2_PSK = 4,
41     OSEN = 5,
42     FT_PSK = 6,
43     FT_EAP = 7
44 };
45 
46 enum class BandType {
47     BAND_NONE = 0, /* unknown */
48     BAND_2GHZ = 1, /* 2.4GHz */
49     BAND_5GHZ = 2, /* 5GHz */
50     BAND_ANY = 3   /* Dual-mode frequency band */
51 };
52 
53 struct HotspotConfig {
HotspotConfigHotspotConfig54     HotspotConfig()
55     {
56         securityType = KeyMgmt::WPA2_PSK;
57         band = BandType::BAND_2GHZ;
58         channel = AP_CHANNEL_DEFAULT;
59         maxConn = -1;
60     }
61 
SetSsidHotspotConfig62     inline void SetSsid(const std::string &newSsid)
63     {
64         ssid = newSsid;
65     }
GetSsidHotspotConfig66     inline const std::string &GetSsid() const
67     {
68         return ssid;
69     }
70 
SetPreSharedKeyHotspotConfig71     inline void SetPreSharedKey(const std::string &newKey)
72     {
73         preSharedKey = newKey;
74     }
GetPreSharedKeyHotspotConfig75     inline const std::string &GetPreSharedKey() const
76     {
77         return preSharedKey;
78     }
79 
SetSecurityTypeHotspotConfig80     inline void SetSecurityType(KeyMgmt type)
81     {
82         securityType = type;
83     }
GetSecurityTypeHotspotConfig84     inline KeyMgmt GetSecurityType() const
85     {
86         return securityType;
87     }
88 
SetBandHotspotConfig89     inline void SetBand(BandType newBand)
90     {
91         band = newBand;
92     }
GetBandHotspotConfig93     inline BandType GetBand() const
94     {
95         return band;
96     }
97 
SetChannelHotspotConfig98     inline void SetChannel(int32_t newchannel)
99     {
100         channel = newchannel;
101     }
GetChannelHotspotConfig102     inline int32_t GetChannel() const
103     {
104         return channel;
105     }
106 
SetMaxConnHotspotConfig107     inline void SetMaxConn(int32_t newMaxConn)
108     {
109         maxConn = newMaxConn;
110     }
GetMaxConnHotspotConfig111     inline int32_t GetMaxConn() const
112     {
113         return maxConn;
114     }
115 
116 private:
117     std::string ssid;         /* Hotspot name, The string length range is 1~32 */
118     std::string preSharedKey; /* Hotspot password ,The string length range is 8~63 */
119     KeyMgmt securityType;     /* Hotspot Encryption type, Optional NONE/WPA_PSK/WPA2_PSK */
120     BandType band;
121     int32_t channel;
122     int32_t maxConn;
123 };
124 
125 struct StationInfo {
126     std::string deviceName; /* Device name */
127     std::string bssid;      /* Device Mac */
128     std::string ipAddr;     /* Device IP address */
129 };
130 }  // namespace Wifi
131 }  // namespace OHOS
132 #endif
133