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 } WifiActionData; 206 207 typedef struct { 208 uint32_t freq; 209 uint32_t duration; 210 } WifiOnChannel; 211 212 typedef struct { 213 uint8_t type; 214 } WifiIfAdd; 215 216 typedef struct { 217 uint8_t ifname[IFNAMSIZ]; 218 } WifiIfRemove; 219 220 typedef struct { 221 uint32_t ieLen; 222 uint8_t appIeType; 223 uint8_t rsv[3]; 224 uint8_t *ie; 225 } WifiAppIe; 226 227 typedef struct { 228 uint64_t drvFlags; 229 } WifiGetDrvFlags; 230 231 typedef struct { 232 int32_t mode; 233 int32_t freq; 234 int32_t channel; 235 236 /* for HT */ 237 int32_t htEnabled; 238 239 /* 240 * 0 = HT40 disabled, -1 = HT40 enabled, 241 * secondary channel below primary, 1 = HT40 242 * enabled, secondary channel above primary 243 */ 244 int32_t secChannelOffset; 245 246 /* for VHT */ 247 int32_t vhtEnabled; 248 249 /* 250 * valid for both HT and VHT, center_freq2 is non-zero 251 * only for bandwidth 80 and an 80+80 channel 252 */ 253 int32_t centerFreq1; 254 int32_t centerFreq2; 255 int32_t bandwidth; 256 uint8_t band; 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 uint32_t ssidLen; 278 int32_t beaconInterval; 279 int32_t dtimPeriod; 280 uint8_t *ssid; 281 uint8_t hiddenSsid; 282 uint8_t authType; 283 uint32_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 #define WIFI_MAX_CHANNEL_NUM 24 316 #define SUPPORTED_NUM_BANDS 2 317 318 typedef struct { 319 int32_t channelNum; /**< Number of channels */ 320 WifiIeee80211Channel iee80211Channel[WIFI_MAX_CHANNEL_NUM]; /**< WLAN channel structures */ 321 }WlanBands; 322 323 typedef struct { 324 int32_t channelNum; 325 uint16_t bitrate[MAX_SUPPORTED_RATE]; 326 uint16_t htCapab; 327 uint8_t resv[2]; 328 WlanBands bands[SUPPORTED_NUM_BANDS]; 329 } WifiHwFeatureData; 330 331 typedef struct { 332 uint8_t ssid[MAX_SSID_LEN]; 333 uint32_t ssidLen; 334 } WifiDriverScanSsid; 335 336 typedef struct { 337 WifiDriverScanSsid *ssids; 338 int32_t *freqs; 339 uint8_t *extraIes; 340 uint8_t *bssid; 341 uint8_t numSsids; 342 uint8_t numFreqs; 343 uint8_t prefixSsidScanFlag; 344 uint8_t fastConnectFlag; 345 int32_t extraIesLen; 346 } WifiScan; 347 348 typedef struct { 349 uint8_t type; 350 uint8_t macAddr[ETH_ADDR_LEN]; 351 uint8_t resv; 352 } WifiGetP2pAddr; 353 354 typedef struct { 355 WifiIfType iftype; 356 uint8_t *macAddr; 357 } WifiIftypeMacAddr; 358 359 typedef struct { 360 int32_t freq; 361 } WifiChannelSwitch; 362 363 typedef struct { 364 uint32_t wpaVersions; 365 uint32_t cipherGroup; 366 int32_t nCiphersPairwise; 367 uint32_t ciphersPairwise[MAX_NR_CIPHER_SUITES]; 368 int32_t nAkmSuites; 369 uint32_t akmSuites[MAX_NR_AKM_SUITES]; 370 } WifiCryptoSetting; 371 372 typedef struct { 373 uint8_t *bssid; 374 uint8_t *ssid; 375 uint8_t *ie; 376 uint8_t *key; 377 uint8_t authType; 378 uint8_t privacy; 379 uint8_t keyLen; 380 uint8_t keyIdx; 381 uint8_t mfp; 382 uint8_t rsv[3]; 383 uint32_t freq; 384 uint32_t ssidLen; 385 uint32_t ieLen; 386 WifiCryptoSetting *crypto; 387 } WifiAssociateParams; 388 389 typedef struct { 390 uint8_t *reqIe; 391 uint32_t reqIeLen; 392 uint8_t *respIe; 393 uint32_t respIeLen; 394 uint8_t bssid[ETH_ADDR_LEN]; 395 uint8_t rsv[2]; 396 uint16_t status; 397 uint16_t freq; 398 } WifiConnectResult; 399 400 typedef struct { 401 int32_t flags; 402 uint8_t bssid[ETH_ADDR_LEN]; 403 int16_t caps; 404 int32_t freq; 405 int16_t beaconInt; 406 int32_t qual; 407 uint32_t beaconIeLen; 408 int32_t level; 409 uint32_t age; 410 uint32_t ieLen; 411 uint8_t *variable; 412 } WifiScanResult; 413 414 typedef struct { 415 uint8_t *ie; 416 uint16_t reason; 417 uint8_t rsv[2]; 418 uint32_t ieLen; 419 } WifiDisconnect; 420 421 typedef enum { 422 WIFI_CHAN_DISABLED = 1 << 0, 423 WIFI_CHAN_PASSIVE_SCAN = 1 << 1, 424 WIFI_CHAN_NO_IBSS = 1 << 2, 425 WIFI_CHAN_RADAR = 1 << 3, 426 WIFI_CHAN_NO_HT40PLUS = 1 << 4, 427 WIFI_CHAN_NO_HT40MINUS = 1 << 5, 428 WIFI_CHAN_NO_OFDM = 1 << 6, 429 WIFI_CHAN_NO_80MHZ = 1 << 7, 430 WIFI_CHAN_NO_160MHZ = 1 << 8, 431 } WifiChannelFlags; 432 433 #ifdef __cplusplus 434 #if __cplusplus 435 } 436 #endif 437 #endif 438 439 440 #endif /* end of hdf_wifi_cmd.h */ 441