• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Driver interaction with hdf wifi
3  * Copyright (c) 2020 Huawei Device Co., Ltd.
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef _WPA_HAL_H_
10 #define _WPA_HAL_H_
11 
12 #include "wifi_driver_client.h"
13 
14 #ifdef __cplusplus
15 #if __cplusplus
16 extern "C" {
17 #endif
18 #endif
19 
20 #define SUCC 0
21 #define EFAIL 1
22 #define EINVAL 22
23 
24 #define WEP_KEY_NUM 4
25 #define DEFAULT_NUM_MODES 2
26 #define WPA_BANDWIDTH_20 20
27 #define WPA_BANDWIDTH_40 40
28 
29 #define SCAN_AP_LIMIT 64
30 #define SCAN_TIME_OUT 5
31 
32 #define NETDEV_UP 0x0001
33 #define NETDEV_DOWN 0x0002
34 
35 #define EAPOL_PKT_BUF_SIZE 800
36 #define CHECK_DHCP_TIME 30
37 
38 #define WPA_WEP40_KEY_LEN 5
39 #define WPA_WEP104_KEY_LEN 13
40 
41 #define WPA_FLAG_ON 1
42 #define WPA_FLAG_OFF 0
43 
44 typedef enum {
45     WPA_VERSION_1 = 1 << 0,
46     WPA_VERSION_2 = 1 << 1,
47 } WpaVersions;
48 
49 typedef enum {
50     WIFI_CHAN_WIDTH_20_NOHT,
51     WIFI_CHAN_WIDTH_20,
52     WIFI_CHAN_WIDTH_40,
53     WIFI_CHAN_WIDTH_BUTT
54 } WifiChannelWidth;
55 
56 typedef enum {
57     WIFI_DISCONNECT,
58     WIFI_CONNECT,
59 } WifiConnectStatus;
60 
61 typedef enum {
62     WIFI_KEYTYPE_GROUP,
63     WIFI_KEYTYPE_PAIRWISE,
64     WIFI_KEYTYPE_PEERKEY,
65     WIFI_KEYTYPE_BUTT
66 } WifiKeyType;
67 
68 typedef enum {
69     WIFI_KEY_DEFAULT_TYPE_INVALID,
70     WIFI_KEY_DEFAULT_TYPE_UNICAST,
71     WIFI_KEY_DEFAULT_TYPE_MULTICAST,
72     WIFI_KEY_DEFAULT_TYPES
73 } WifiKeyDefaultType;
74 
75 typedef enum {
76     WIFI_NO_SSID_HIDING,
77     WIFI_HIDDEN_SSID_ZERO_LEN,
78     WIFI_HIDDEN_SSID_ZERO_CONTENTS
79 } WifiHiddenSsid;
80 
81 typedef enum {
82     WIFI_MESH_ENABLE_AUTO_PEER,
83     WIFI_MESH_ENABLE_ACCEPT_PEER,
84     WIFI_MESH_ENABLE_ACCEPT_STA,
85     WIFI_MESH_ENABLE_FLAG_BUTT
86 } WifiMeshEnableFlagType;
87 
88 typedef enum {
89     WIFI_AUTHTYPE_OPEN_SYSTEM = 0,
90     WIFI_AUTHTYPE_SHARED_KEY,
91     WIFI_AUTHTYPE_FT,
92     WIFI_AUTHTYPE_EAP,
93     WIFI_AUTHTYPE_SAE,
94     WIFI_AUTHTYPE_AUTOMATIC,
95     WIFI_AUTHTYPE_BUTT
96 } WifiAuthType;
97 
98 typedef enum {
99     WIFI_SCAN_SUCCESS,
100     WIFI_SCAN_FAILED,
101     WIFI_SCAN_REFUSED,
102     WIFI_SCAN_TIMEOUT
103 } WifiScanStatus;
104 
105 typedef struct {
106     int32_t numRates;
107     int32_t mode;
108 } WifiModes;
109 
110 typedef struct {
111     uint8_t *addr;
112     uint8_t plinkState;
113     uint8_t set;
114     uint8_t meshBcnPriority;
115     uint8_t meshIsMbr;
116     uint8_t meshInitiativePeering;
117 } WifiMeshUsrParams;
118 
119 typedef struct {
120     uint8_t *addr;
121     uint8_t *gtk;
122     uint8_t gtkLen;
123     uint8_t resv[3];
124 } WifiSetMeshUsrGtk;
125 
126 typedef struct {
127     uint8_t *buf;
128     uint32_t len;
129 } WifiTxEapol;
130 
131 typedef struct {
132     void *callback;
133     void *contex;
134 } WifiEnableEapol;
135 
136 typedef struct {
137     int32_t start;
138     int32_t duration;
139     uint8_t count;
140     uint8_t resv[3];
141 } WifiP2pNoa;
142 
143 typedef struct {
144     int32_t legacyPs;
145     int8_t oppPs;
146     uint8_t ctWindow;
147     int8_t resv[2];
148 } WifiP2pPowerSave;
149 
150 typedef struct {
151     uint8_t type;
152     uint8_t macAddr[ETH_ADDR_LEN];
153     uint8_t resv;
154 } WifiGetP2pAddr;
155 
156 typedef struct {
157     enum WifiIfType iftype;
158     uint8_t *macAddr;
159 } WifiIftypeMacAddr;
160 
161 typedef struct {
162     int32_t freq;
163 } WifiChannelSwitch;
164 
165 typedef struct {
166     uint8_t macAddr[ETH_ADDR_LEN];
167     uint16_t reason;
168 } WifiMeshClosePeer;
169 
170 typedef struct {
171     uint8_t peerAddr[ETH_ADDR_LEN];
172     uint8_t meshBcnPriority;
173     uint8_t meshIsMbr;
174     int8_t rssi;
175     int8_t reserved[3];
176 } WifiMeshNewPeerCandidate;
177 
178 typedef struct {
179     struct hostapd_data *hapd;
180     char iface[IFNAMSIZ + 1];
181     int8_t resv[3];
182     uint64_t actionCookie;
183     void *ctx;
184     void *eventQueue;
185 
186     struct l2_packet_data *eapolSock;
187     uint8_t ownAddr[ETH_ADDR_LEN];
188 
189     uint32_t associated;
190     uint8_t bssid[ETH_ADDR_LEN];
191     uint8_t ssid[MAX_SSID_LEN];
192     int32_t ssidLen;
193 
194     struct wpa_scan_res *scanRes[SCAN_AP_LIMIT];
195     uint32_t scanNum;
196     uint32_t beaconSet;
197     uint8_t mode;
198 } WifiDriverData;
199 
200 typedef struct {
201     int32_t cmd;
202     const struct wpabuf *src;
203 } WifiCmd;
204 
205 typedef struct {
206     enum WifiIfType ifType;
207     WifiDriverData *priv;
208     int32_t networkId;
209     int32_t ifNameLen;
210     char ifName[IFNAMSIZ + 1];
211     char reserver[1];
212 } WifiDev;
213 
214 WifiDriverData *GetDrvData();
215 void WifiWpaScanTimeout(void *eloop, void *ctx);
216 int32_t WifiWpaGetDrvFlags(void *priv, uint64_t *drvFlags);
217 WifiDev *GetWifiDevByName(const char *ifName);
218 
219 void WifiWpaNewStaProcess(WifiDriverData *drv, WifiNewStaInfo *staInfo);
220 void WifiWpaDelStaProcess(WifiDriverData *drv, uint8_t *addr);
221 void WifiWpaRxMgmtProcess(WifiDriverData *drv, WifiRxMgmt *rxMgmt);
222 void WifiWpaTxStatusProcess(WifiDriverData *drv, WifiTxStatus *txStatus);
223 void WifiWpaScanDoneProcess(WifiDriverData *drv, uint32_t *status);
224 void WifiWpaScanResultProcess(WifiDriverData *drv, WifiScanResult *scanResult);
225 void WifiWpaConnectResultProcess(WifiDriverData *drv, WifiConnectResult *result);
226 void WifiWpaDisconnectProcess(WifiDriverData *drv, WifiDisconnect *result);
227 void WifiWpaDriverEapolRecvProcess(WifiDriverData *drv, void *data);
228 void WifiWpaRemainOnChannelProcess(WifiDriverData *drv, WifiOnChannel *result);
229 void WifiWpaCancelRemainOnChannelProcess(WifiDriverData *drv, WifiOnChannel *result);
230 
231 #ifdef __cplusplus
232 #if __cplusplus
233 }
234 #endif
235 #endif
236 
237 #endif /* end of wpa_hal.h */
238