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