• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HDF_WIFI_CMD_H
10 #define HDF_WIFI_CMD_H
11 
12 #include "hdf_base.h"
13 #include <stddef.h>
14 #include "net_device.h"
15 #include "hdf_device_desc.h"
16 #include "hdf_sbuf.h"
17 
18 #ifdef __cplusplus
19 #if __cplusplus
20 extern "C" {
21 #endif
22 #endif
23 
24 #define SUCC 0
25 #define EFAIL 1
26 #define EINVAL 22
27 
28 #define ETH_ADDR_LEN 6
29 #define MAX_SSID_LEN 32
30 #define MAX_NR_CIPHER_SUITES 5
31 #define MAX_NR_AKM_SUITES 2
32 #define WPAS_MAX_SCAN_SSIDS 16
33 #define DRIVER_MAX_SCAN_SSIDS 2
34 
35 #define SCAN_AP_LIMIT 64
36 #define SCAN_TIME_OUT 5
37 
38 #define NETDEV_UP 0x0001
39 #define NETDEV_DOWN 0x0002
40 
41 #define EAPOL_PKT_BUF_SIZE 800
42 #define CHECK_DHCP_TIME 30
43 
44 #define WPA_WEP40_KEY_LEN 5
45 #define WPA_WEP104_KEY_LEN 13
46 
47 typedef enum {
48     WPA_VERSION_1 = 1 << 0,
49     WPA_VERSION_2 = 1 << 1,
50 } WpaVersions;
51 
52 typedef enum {
53     WIFI_CHAN_WIDTH_20_NOHT,
54     WIFI_CHAN_WIDTH_20,
55     WIFI_CHAN_WIDTH_40,
56     WIFI_CHAN_WIDTH_BUTT
57 } WifiChannelWidth;
58 
59 typedef enum {
60     WIFI_DISCONNECT,
61     WIFI_CONNECT,
62 } WifiConnectStatus;
63 
64 typedef enum {
65     WIFI_KEYTYPE_GROUP,
66     WIFI_KEYTYPE_PAIRWISE,
67     WIFI_KEYTYPE_PEERKEY,
68     WIFI_KEYTYPE_BUTT
69 } WifiKeyType;
70 
71 typedef enum {
72     WIFI_KEY_DEFAULT_TYPE_INVALID,
73     WIFI_KEY_DEFAULT_TYPE_UNICAST,
74     WIFI_KEY_DEFAULT_TYPE_MULTICAST,
75     WIFI_KEY_DEFAULT_TYPES
76 } WifiKeyDefaultType;
77 
78 typedef enum {
79     WIFI_NO_SSID_HIDING,
80     WIFI_HIDDEN_SSID_ZERO_LEN,
81     WIFI_HIDDEN_SSID_ZERO_CONTENTS
82 } WifiHiddenSsid;
83 
84 typedef enum {
85     WIFI_WPA_EVENT_NEW_STA = 0,
86     WIFI_WPA_EVENT_DEL_STA,
87     WIFI_WPA_EVENT_RX_MGMT,
88     WIFI_WPA_EVENT_TX_STATUS,
89     WIFI_WPA_EVENT_SCAN_DONE,
90     WIFI_WPA_EVENT_SCAN_RESULT = 5,
91     WIFI_WPA_EVENT_CONNECT_RESULT,
92     WIFI_WPA_EVENT_DISCONNECT,
93     WIFI_WPA_EVENT_MESH_CLOSE,
94     WIFI_WPA_EVENT_NEW_PEER_CANDIDATE,
95     WIFI_WPA_EVENT_REMAIN_ON_CHANNEL = 10,
96     WIFI_WPA_EVENT_CANCEL_REMAIN_ON_CHANNEL,
97     WIFI_WPA_EVENT_CHANNEL_SWITCH,
98     WIFI_WPA_EVENT_EAPOL_RECV,
99     WIFI_WPA_EVENT_TIMEOUT_DISCONN,
100     WIFI_WPA_EVENT_RESET_DRIVER = 15,
101     WIFI_WPA_EVENT_BUTT
102 } WifiWpaEventType;
103 
104 typedef enum {
105     WIFI_AUTHTYPE_OPEN_SYSTEM = 0,
106     WIFI_AUTHTYPE_SHARED_KEY,
107     WIFI_AUTHTYPE_FT,
108     WIFI_AUTHTYPE_EAP,
109     WIFI_AUTHTYPE_SAE,
110     WIFI_AUTHTYPE_AUTOMATIC,
111     WIFI_AUTHTYPE_BUTT
112 } WifiAuthType;
113 
114 typedef enum {
115     WIFI_SCAN_SUCCESS,
116     WIFI_SCAN_FAILED,
117     WIFI_SCAN_REFUSED,
118     WIFI_SCAN_TIMEOUT
119 } WifiScanStatus;
120 
121 typedef enum {
122     WIFI_MFP_NO,
123     WIFI_MFP_OPTIONAL,
124     WIFI_MFP_REQUIRED,
125 } WifiMfp;
126 
127 typedef enum {
128     WIFI_IFTYPE_UNSPECIFIED,
129     WIFI_IFTYPE_ADHOC,
130     WIFI_IFTYPE_STATION,
131     WIFI_IFTYPE_AP,
132     WIFI_IFTYPE_AP_VLAN,
133     WIFI_IFTYPE_WDS,
134     WIFI_IFTYPE_MONITOR,
135     WIFI_IFTYPE_MESH_POINT,
136     WIFI_IFTYPE_P2P_CLIENT,
137     WIFI_IFTYPE_P2P_GO,
138     WIFI_IFTYPE_P2P_DEVICE,
139     WIFI_IFTYPE_MAX,
140 } WifiIfType;
141 
142 typedef enum {
143     WIFI_PHY_MODE_11N = 0,
144     WIFI_PHY_MODE_11G = 1,
145     WIFI_PHY_MODE_11B = 2,
146     WIFI_PHY_MODE_BUTT
147 } WifiPhyMode;
148 
149 typedef struct {
150     uint8_t status;
151     WifiIfType ifType;
152     WifiPhyMode mode;
153 } WifiSetNewDev;
154 
155 typedef struct {
156     uint8_t mac[ETH_ADDR_LEN];
157 } WifiStaInfo;
158 
159 typedef struct {
160     int32_t numRates;
161     int32_t mode;
162 } WifiModes;
163 
164 typedef struct {
165     int32_t reassoc;
166     size_t ieLen;
167     uint8_t *ie;
168     uint8_t macAddr[ETH_ADDR_LEN];
169     uint8_t resv[2];
170 } WifiNewStaInfo;
171 
172 typedef struct {
173     uint8_t *buf;
174     uint32_t len;
175     int32_t sigMbm;
176     int32_t freq;
177 } WifiRxMgmt;
178 
179 typedef struct {
180     uint8_t *buf;
181     uint32_t len;
182     uint8_t ack;
183     uint8_t resv[3];
184 } WifiTxStatus;
185 
186 typedef struct {
187     uint32_t freq;
188     size_t dataLen;
189     uint8_t *data;
190     uint64_t *cookie;
191 } WifiMlmeData;
192 
193 typedef struct {
194     size_t headLen;
195     size_t tailLen;
196     uint8_t *head;
197     uint8_t *tail;
198 } WifiBeaconData;
199 
200 typedef struct {
201     uint8_t *dst;
202     uint8_t *src;
203     uint8_t *bssid;
204     uint8_t *data;
205     size_t dataLen;
206 } WifiActionData;
207 
208 typedef struct {
209     uint32_t freq;
210     uint32_t duration;
211 } WifiOnChannel;
212 
213 typedef struct {
214     uint8_t type;
215 } WifiIfAdd;
216 
217 typedef struct {
218     uint8_t ifname[IFNAMSIZ];
219 } WifiIfRemove;
220 
221 typedef struct {
222     uint32_t ieLen;
223     uint8_t appIeType;
224     uint8_t rsv[3];
225     uint8_t *ie;
226 } WifiAppIe;
227 
228 typedef struct {
229     uint64_t drvFlags;
230 } WifiGetDrvFlags;
231 
232 typedef struct {
233     int32_t mode;
234     int32_t freq;
235     int32_t channel;
236 
237     /* for HT */
238     int32_t htEnabled;
239 
240     /*
241      * 0 = HT40 disabled, -1 = HT40 enabled,
242      * secondary channel below primary, 1 = HT40
243      * enabled, secondary channel above primary
244      */
245     int32_t secChannelOffset;
246 
247     /* for VHT */
248     int32_t vhtEnabled;
249 
250     /*
251      * valid for both HT and VHT, center_freq2 is non-zero
252      * only for bandwidth 80 and an 80+80 channel
253      */
254     int32_t centerFreq1;
255     int32_t centerFreq2;
256     int32_t bandwidth;
257 } WifiFreqParams;
258 
259 typedef struct {
260     int32_t type;
261     uint32_t keyIdx;
262     uint32_t keyLen;
263     uint32_t seqLen;
264     uint32_t cipher;
265     uint8_t *addr;
266     uint8_t *key;
267     uint8_t *seq;
268     uint8_t def;
269     uint8_t defMgmt;
270     uint8_t defaultTypes;
271     uint8_t resv;
272 } WifiKeyExt;
273 
274 typedef struct {
275     WifiFreqParams freqParams;
276     WifiBeaconData beaconData;
277     size_t ssidLen;
278     int32_t beaconInterval;
279     int32_t dtimPeriod;
280     uint8_t *ssid;
281     uint8_t hiddenSsid;
282     uint8_t authType;
283     size_t meshSsidLen;
284     uint8_t *meshSsid;
285 } WifiApSetting;
286 
287 typedef struct {
288     uint8_t bssid[ETH_ADDR_LEN];
289     uint8_t iftype;
290     uint8_t resv;
291 } WifiSetMode;
292 
293 typedef struct {
294     uint8_t *buf;
295     uint32_t len;
296 } WifiTxEapol;
297 
298 typedef struct {
299     uint8_t *buf;
300     uint32_t len;
301 } WifiRxEapol;
302 
303 typedef struct {
304     void *callback;
305     void *context;
306 } WifiEnableEapol;
307 
308 typedef struct {
309     uint16_t channel;
310     uint32_t freq;
311     uint32_t flags;
312 } WifiIeee80211Channel;
313 
314 #define MAX_SUPPORTED_RATE 12
315 
316 typedef struct {
317     int32_t channelNum;
318     uint16_t bitrate[MAX_SUPPORTED_RATE];
319     uint16_t htCapab;
320     uint8_t resv[2];
321     WifiIeee80211Channel iee80211Channel[14];
322 } WifiHwFeatureData;
323 
324 typedef struct {
325     uint8_t ssid[MAX_SSID_LEN];
326     size_t ssidLen;
327 } WifiDriverScanSsid;
328 
329 typedef struct {
330     WifiDriverScanSsid *ssids;
331     int32_t *freqs;
332     uint8_t *extraIes;
333     uint8_t *bssid;
334     uint8_t numSsids;
335     uint8_t numFreqs;
336     uint8_t prefixSsidScanFlag;
337     uint8_t fastConnectFlag;
338     int32_t extraIesLen;
339 } WifiScan;
340 
341 typedef struct {
342     uint8_t type;
343     uint8_t macAddr[ETH_ADDR_LEN];
344     uint8_t resv;
345 } WifiGetP2pAddr;
346 
347 typedef struct {
348     WifiIfType iftype;
349     uint8_t *macAddr;
350 } WifiIftypeMacAddr;
351 
352 typedef struct {
353     int32_t freq;
354 } WifiChannelSwitch;
355 
356 typedef struct {
357     uint32_t wpaVersions;
358     uint32_t cipherGroup;
359     int32_t nCiphersPairwise;
360     uint32_t ciphersPairwise[MAX_NR_CIPHER_SUITES];
361     int32_t nAkmSuites;
362     uint32_t akmSuites[MAX_NR_AKM_SUITES];
363 } WifiCryptoSetting;
364 
365 typedef struct {
366     uint8_t *bssid;
367     uint8_t *ssid;
368     uint8_t *ie;
369     uint8_t *key;
370     uint8_t authType;
371     uint8_t privacy;
372     uint8_t keyLen;
373     uint8_t keyIdx;
374     uint8_t mfp;
375     uint8_t rsv[3];
376     uint32_t freq;
377     uint32_t ssidLen;
378     uint32_t ieLen;
379     WifiCryptoSetting *crypto;
380 } WifiAssociateParams;
381 
382 typedef struct {
383     uint8_t *reqIe;
384     size_t reqIeLen;
385     uint8_t *respIe;
386     size_t respIeLen;
387     uint8_t bssid[ETH_ADDR_LEN];
388     uint8_t rsv[2];
389     uint16_t status;
390     uint16_t freq;
391 } WifiConnectResult;
392 
393 typedef struct {
394     int32_t flags;
395     uint8_t bssid[ETH_ADDR_LEN];
396     int16_t caps;
397     int32_t freq;
398     int16_t beaconInt;
399     int32_t qual;
400     uint32_t beaconIeLen;
401     int32_t level;
402     uint32_t age;
403     uint32_t ieLen;
404     uint8_t *variable;
405 } WifiScanResult;
406 
407 typedef struct {
408     uint8_t *ie;
409     uint16_t reason;
410     uint8_t rsv[2];
411     uint32_t ieLen;
412 } WifiDisconnect;
413 
414 typedef enum {
415     WIFI_CHAN_DISABLED      = 1 << 0,
416     WIFI_CHAN_PASSIVE_SCAN  = 1 << 1,
417     WIFI_CHAN_NO_IBSS       = 1 << 2,
418     WIFI_CHAN_RADAR         = 1 << 3,
419     WIFI_CHAN_NO_HT40PLUS   = 1 << 4,
420     WIFI_CHAN_NO_HT40MINUS  = 1 << 5,
421     WIFI_CHAN_NO_OFDM       = 1 << 6,
422     WIFI_CHAN_NO_80MHZ      = 1 << 7,
423     WIFI_CHAN_NO_160MHZ     = 1 << 8,
424 } WifiChannelFlags;
425 
426 #ifdef __cplusplus
427 #if __cplusplus
428 }
429 #endif
430 #endif
431 
432 
433 #endif /* end of hdf_wifi_cmd.h */
434