1 /* 2 * Copyright (c) 2018 Texas Instruments, Incorporated 3 * Copyright (c) 2023 Nordic Semiconductor ASA 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 /** 9 * @file 10 * @brief IEEE 802.11 protocol and general Wi-Fi definitions. 11 */ 12 13 /** 14 * @brief Wi-Fi Management API. 15 * @defgroup wifi_mgmt Wi-Fi Management 16 * @since 1.12 17 * @version 0.8.0 18 * @ingroup networking 19 * @{ 20 */ 21 22 #ifndef ZEPHYR_INCLUDE_NET_WIFI_H_ 23 #define ZEPHYR_INCLUDE_NET_WIFI_H_ 24 25 #include <zephyr/sys/util.h> /* for ARRAY_SIZE */ 26 27 /** Length of the country code string */ 28 #define WIFI_COUNTRY_CODE_LEN 2 29 30 /** @cond INTERNAL_HIDDEN */ 31 32 #define WIFI_LISTEN_INTERVAL_MIN 0 33 #define WIFI_LISTEN_INTERVAL_MAX 65535 34 35 /** @endcond */ 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /** @brief IEEE 802.11 security types. */ 42 enum wifi_security_type { 43 /** No security. */ 44 WIFI_SECURITY_TYPE_NONE = 0, 45 /** WPA2-PSK security. */ 46 WIFI_SECURITY_TYPE_PSK, 47 /** WPA2-PSK-SHA256 security. */ 48 WIFI_SECURITY_TYPE_PSK_SHA256, 49 /** WPA3-SAE security. */ 50 WIFI_SECURITY_TYPE_SAE, 51 /** WPA3-SAE security with hunting-and-pecking loop. */ 52 WIFI_SECURITY_TYPE_SAE_HNP = WIFI_SECURITY_TYPE_SAE, 53 /** WPA3-SAE security with hash-to-element. */ 54 WIFI_SECURITY_TYPE_SAE_H2E, 55 /** WPA3-SAE security with both hunting-and-pecking loop and hash-to-element enabled. */ 56 WIFI_SECURITY_TYPE_SAE_AUTO, 57 /** GB 15629.11-2003 WAPI security. */ 58 WIFI_SECURITY_TYPE_WAPI, 59 /** EAP security - Enterprise. */ 60 WIFI_SECURITY_TYPE_EAP, 61 /** EAP TLS security - Enterprise. */ 62 WIFI_SECURITY_TYPE_EAP_TLS = WIFI_SECURITY_TYPE_EAP, 63 /** WEP security. */ 64 WIFI_SECURITY_TYPE_WEP, 65 /** WPA-PSK security. */ 66 WIFI_SECURITY_TYPE_WPA_PSK, 67 /** WPA/WPA2/WPA3 PSK security. */ 68 WIFI_SECURITY_TYPE_WPA_AUTO_PERSONAL, 69 /** DPP security */ 70 WIFI_SECURITY_TYPE_DPP, 71 /** EAP PEAP MSCHAPV2 security - Enterprise. */ 72 WIFI_SECURITY_TYPE_EAP_PEAP_MSCHAPV2, 73 /** EAP PEAP GTC security - Enterprise. */ 74 WIFI_SECURITY_TYPE_EAP_PEAP_GTC, 75 /** EAP TTLS MSCHAPV2 security - Enterprise. */ 76 WIFI_SECURITY_TYPE_EAP_TTLS_MSCHAPV2, 77 /** EAP PEAP security - Enterprise. */ 78 WIFI_SECURITY_TYPE_EAP_PEAP_TLS, 79 /** FT-PSK security */ 80 WIFI_SECURITY_TYPE_FT_PSK, 81 /** FT-SAE security */ 82 WIFI_SECURITY_TYPE_FT_SAE, 83 /** FT-EAP security */ 84 WIFI_SECURITY_TYPE_FT_EAP, 85 /** FT-EAP-SHA384 security */ 86 WIFI_SECURITY_TYPE_FT_EAP_SHA384, 87 /** SAE Extended key (uses group-dependent hashing) */ 88 WIFI_SECURITY_TYPE_SAE_EXT_KEY, 89 90 /** @cond INTERNAL_HIDDEN */ 91 __WIFI_SECURITY_TYPE_AFTER_LAST, 92 WIFI_SECURITY_TYPE_MAX = __WIFI_SECURITY_TYPE_AFTER_LAST - 1, 93 WIFI_SECURITY_TYPE_UNKNOWN 94 /** @endcond */ 95 }; 96 97 /** @brief EPA method Types. */ 98 enum wifi_eap_type { 99 /** No EPA security. */ 100 WIFI_EAP_TYPE_NONE = 0, 101 /** EPA GTC security, refer to rfc3748 chapter 5. */ 102 WIFI_EAP_TYPE_GTC = 6, 103 /** EPA TLS security, refer to rfc5216. */ 104 WIFI_EAP_TYPE_TLS = 13, 105 /** EPA TTLS security, refer to rfc5281. */ 106 WIFI_EAP_TYPE_TTLS = 21, 107 /** EPA PEAP security, refer to draft-josefsson-pppext-eap-tls-eap-06.txt. */ 108 WIFI_EAP_TYPE_PEAP = 25, 109 /** EPA MSCHAPV2 security, refer to draft-kamath-pppext-eap-mschapv2-00.txt. */ 110 WIFI_EAP_TYPE_MSCHAPV2 = 26, 111 }; 112 113 /** @brief WPA3 Enterprise security types. 114 * 115 * See Section#3 in WFA WPA3 specification v3.4: 116 * https://www.wi-fi.org/file/wpa3-specification for details. 117 */ 118 enum wifi_wpa3_enterprise_type { 119 /** No WPA3 enterprise, either WPA2 Enterprise or personal mode */ 120 WIFI_WPA3_ENTERPRISE_NA = 0, 121 /** WPA3 enterprise Suite-B (PMFR + WPA3-Suite-B). */ 122 WIFI_WPA3_ENTERPRISE_SUITEB = 1, 123 /** WPA3 enterprise Suite-B-192 (PMFR + WPA3-Suite-B-192). */ 124 WIFI_WPA3_ENTERPRISE_SUITEB_192, 125 /** WPA3 enterprise only (PMFR + WPA2-ENT disabled). */ 126 WIFI_WPA3_ENTERPRISE_ONLY, 127 128 /** @cond INTERNAL_HIDDEN */ 129 __WIFI_WPA3_ENTERPRISE_AFTER_LAST, 130 WIFI_WPA3_ENTERPRISE_MAX = __WIFI_WPA3_ENTERPRISE_AFTER_LAST - 1, 131 WIFI_WPA3_ENTERPRISE_UNKNOWN 132 /** @endcond */ 133 }; 134 135 enum wifi_eap_tls_cipher_type { 136 /** EAP TLS with NONE */ 137 WIFI_EAP_TLS_NONE, 138 /** EAP TLS with ECDH & ECDSA with p384 */ 139 WIFI_EAP_TLS_ECC_P384, 140 /** EAP TLS with ECDH & RSA with > 3K */ 141 WIFI_EAP_TLS_RSA_3K, 142 }; 143 144 /** @brief Group cipher and pairwise cipher types. */ 145 enum wifi_cipher_type { 146 /** AES in counter mode with CBC-MAC (CCMP-128). */ 147 WPA_CAPA_ENC_CCMP, 148 /** 128-bit Galois/Counter Mode Protocol. */ 149 WPA_CAPA_ENC_GCMP, 150 /** 256-bit Galois/Counter Mode Protocol. */ 151 WPA_CAPA_ENC_GCMP_256, 152 }; 153 154 /** @brief group mgmt cipher types. */ 155 enum wifi_group_mgmt_cipher_type { 156 /** 128-bit Broadcast/Multicast Integrity Protocol 157 * Cipher-based Message Authentication Code . 158 */ 159 WPA_CAPA_ENC_BIP, 160 /** 128-bit Broadcast/Multicast Integrity Protocol 161 * Galois Message Authentication Code . 162 */ 163 WPA_CAPA_ENC_BIP_GMAC_128, 164 /** 256-bit Broadcast/Multicast Integrity Protocol 165 * Galois Message Authentication Code . 166 */ 167 WPA_CAPA_ENC_BIP_GMAC_256, 168 }; 169 170 struct wifi_cipher_desc { 171 /** Cipher capability. */ 172 unsigned int capa; 173 /** Cipher name string. */ 174 char *name; 175 }; 176 177 struct wifi_eap_cipher_config { 178 /** Key management type string. */ 179 char *key_mgmt; 180 /** OpenSSL cipher string. */ 181 char *openssl_ciphers; 182 /** Group cipher cipher string. */ 183 char *group_cipher; 184 /** Pairwise_cipher cipher string. */ 185 char *pairwise_cipher; 186 /** Group management cipher string. */ 187 char *group_mgmt_cipher; 188 /** Used to confiure TLS features. */ 189 char *tls_flags; 190 }; 191 192 struct wifi_eap_config { 193 /** Security type. */ 194 enum wifi_security_type type; 195 /** EAP method type of phase1. */ 196 enum wifi_eap_type eap_type_phase1; 197 /** EAP method type of phase2. */ 198 enum wifi_eap_type eap_type_phase2; 199 /** EAP method string. */ 200 char *method; 201 /** Phase2 setting string. */ 202 char *phase2; 203 }; 204 205 /** Helper function to get user-friendly security type name. */ 206 const char *wifi_security_txt(enum wifi_security_type security); 207 208 /** Helper function to get user-friendly wpa3 enterprise security type name. */ 209 const char *wifi_wpa3_enterprise_txt(enum wifi_wpa3_enterprise_type wpa3_ent); 210 211 /** @brief IEEE 802.11w - Management frame protection. */ 212 enum wifi_mfp_options { 213 /** MFP disabled. */ 214 WIFI_MFP_DISABLE = 0, 215 /** MFP optional. */ 216 WIFI_MFP_OPTIONAL, 217 /** MFP required. */ 218 WIFI_MFP_REQUIRED, 219 220 /** @cond INTERNAL_HIDDEN */ 221 __WIFI_MFP_AFTER_LAST, 222 WIFI_MFP_MAX = __WIFI_MFP_AFTER_LAST - 1, 223 WIFI_MFP_UNKNOWN 224 /** @endcond */ 225 }; 226 227 /** Helper function to get user-friendly MFP name.*/ 228 const char *wifi_mfp_txt(enum wifi_mfp_options mfp); 229 230 /** 231 * @brief IEEE 802.11 operational frequency bands (not exhaustive). 232 */ 233 enum wifi_frequency_bands { 234 /** 2.4 GHz band. */ 235 WIFI_FREQ_BAND_2_4_GHZ = 0, 236 /** 5 GHz band. */ 237 WIFI_FREQ_BAND_5_GHZ, 238 /** 6 GHz band (Wi-Fi 6E, also extends to 7GHz). */ 239 WIFI_FREQ_BAND_6_GHZ, 240 241 /** Number of frequency bands available. */ 242 __WIFI_FREQ_BAND_AFTER_LAST, 243 /** Highest frequency band available. */ 244 WIFI_FREQ_BAND_MAX = __WIFI_FREQ_BAND_AFTER_LAST - 1, 245 /** Invalid frequency band */ 246 WIFI_FREQ_BAND_UNKNOWN 247 }; 248 249 /** Helper function to get user-friendly frequency band name. */ 250 const char *wifi_band_txt(enum wifi_frequency_bands band); 251 252 /** 253 * @brief IEEE 802.11 operational frequency bandwidths (not exhaustive). 254 */ 255 enum wifi_frequency_bandwidths { 256 /** 20 MHz. */ 257 WIFI_FREQ_BANDWIDTH_20MHZ = 1, 258 /** 40 MHz. */ 259 WIFI_FREQ_BANDWIDTH_40MHZ, 260 /** 80 MHz. */ 261 WIFI_FREQ_BANDWIDTH_80MHZ, 262 263 /** Number of frequency bandwidths available. */ 264 __WIFI_FREQ_BANDWIDTH_AFTER_LAST, 265 /** Highest frequency bandwidth available. */ 266 WIFI_FREQ_BANDWIDTH_MAX = __WIFI_FREQ_BANDWIDTH_AFTER_LAST - 1, 267 /** Invalid frequency bandwidth */ 268 WIFI_FREQ_BANDWIDTH_UNKNOWN 269 }; 270 271 const char *const wifi_bandwidth_txt(enum wifi_frequency_bandwidths bandwidth); 272 273 /** Max SSID length */ 274 #define WIFI_SSID_MAX_LEN 32 275 /** Minimum PSK length */ 276 #define WIFI_PSK_MIN_LEN 8 277 /** Maximum PSK length */ 278 #define WIFI_PSK_MAX_LEN 64 279 /** Max SAW password length */ 280 #define WIFI_SAE_PSWD_MAX_LEN 128 281 /** MAC address length */ 282 #define WIFI_MAC_ADDR_LEN 6 283 /** Max enterprise identity length */ 284 #define WIFI_ENT_IDENTITY_MAX_LEN 64 285 /** Max enterprise password length */ 286 #define WIFI_ENT_PSWD_MAX_LEN 128 287 288 /** Minimum channel number */ 289 #define WIFI_CHANNEL_MIN 1 290 /** Maximum channel number */ 291 #define WIFI_CHANNEL_MAX 233 292 /** Any channel number */ 293 #define WIFI_CHANNEL_ANY 255 294 295 /** @brief Wi-Fi interface states. 296 * 297 * Based on https://w1.fi/wpa_supplicant/devel/defs_8h.html#a4aeb27c1e4abd046df3064ea9756f0bc 298 */ 299 enum wifi_iface_state { 300 /** Interface is disconnected. */ 301 WIFI_STATE_DISCONNECTED = 0, 302 /** Interface is disabled (administratively). */ 303 WIFI_STATE_INTERFACE_DISABLED, 304 /** No enabled networks in the configuration. */ 305 WIFI_STATE_INACTIVE, 306 /** Interface is scanning for networks. */ 307 WIFI_STATE_SCANNING, 308 /** Authentication with a network is in progress. */ 309 WIFI_STATE_AUTHENTICATING, 310 /** Association with a network is in progress. */ 311 WIFI_STATE_ASSOCIATING, 312 /** Association with a network completed. */ 313 WIFI_STATE_ASSOCIATED, 314 /** 4-way handshake with a network is in progress. */ 315 WIFI_STATE_4WAY_HANDSHAKE, 316 /** Group Key exchange with a network is in progress. */ 317 WIFI_STATE_GROUP_HANDSHAKE, 318 /** All authentication completed, ready to pass data. */ 319 WIFI_STATE_COMPLETED, 320 321 /** @cond INTERNAL_HIDDEN */ 322 __WIFI_STATE_AFTER_LAST, 323 WIFI_STATE_MAX = __WIFI_STATE_AFTER_LAST - 1, 324 WIFI_STATE_UNKNOWN 325 /** @endcond */ 326 }; 327 328 /* We rely on the strict order of the enum values, so, let's check it */ 329 BUILD_ASSERT(WIFI_STATE_DISCONNECTED < WIFI_STATE_INTERFACE_DISABLED && 330 WIFI_STATE_INTERFACE_DISABLED < WIFI_STATE_INACTIVE && 331 WIFI_STATE_INACTIVE < WIFI_STATE_SCANNING && 332 WIFI_STATE_SCANNING < WIFI_STATE_AUTHENTICATING && 333 WIFI_STATE_AUTHENTICATING < WIFI_STATE_ASSOCIATING && 334 WIFI_STATE_ASSOCIATING < WIFI_STATE_ASSOCIATED && 335 WIFI_STATE_ASSOCIATED < WIFI_STATE_4WAY_HANDSHAKE && 336 WIFI_STATE_4WAY_HANDSHAKE < WIFI_STATE_GROUP_HANDSHAKE && 337 WIFI_STATE_GROUP_HANDSHAKE < WIFI_STATE_COMPLETED); 338 339 340 /** Helper function to get user-friendly interface state name. */ 341 const char *wifi_state_txt(enum wifi_iface_state state); 342 343 /** @brief Wi-Fi interface modes. 344 * 345 * Based on https://w1.fi/wpa_supplicant/devel/defs_8h.html#a4aeb27c1e4abd046df3064ea9756f0bc 346 */ 347 enum wifi_iface_mode { 348 /** Infrastructure station mode. */ 349 WIFI_MODE_INFRA = 0, 350 /** IBSS (ad-hoc) station mode. */ 351 WIFI_MODE_IBSS = 1, 352 /** AP mode. */ 353 WIFI_MODE_AP = 2, 354 /** P2P group owner mode. */ 355 WIFI_MODE_P2P_GO = 3, 356 /** P2P group formation mode. */ 357 WIFI_MODE_P2P_GROUP_FORMATION = 4, 358 /** 802.11s Mesh mode. */ 359 WIFI_MODE_MESH = 5, 360 361 /** @cond INTERNAL_HIDDEN */ 362 __WIFI_MODE_AFTER_LAST, 363 WIFI_MODE_MAX = __WIFI_MODE_AFTER_LAST - 1, 364 WIFI_MODE_UNKNOWN 365 /** @endcond */ 366 }; 367 368 /** Helper function to get user-friendly interface mode name. */ 369 const char *wifi_mode_txt(enum wifi_iface_mode mode); 370 371 /** @brief Wi-Fi link operating modes 372 * 373 * As per https://en.wikipedia.org/wiki/Wi-Fi#Versions_and_generations. 374 */ 375 enum wifi_link_mode { 376 /** 802.11 (legacy). */ 377 WIFI_0 = 0, 378 /** 802.11b. */ 379 WIFI_1, 380 /** 802.11a. */ 381 WIFI_2, 382 /** 802.11g. */ 383 WIFI_3, 384 /** 802.11n. */ 385 WIFI_4, 386 /** 802.11ac. */ 387 WIFI_5, 388 /** 802.11ax. */ 389 WIFI_6, 390 /** 802.11ax 6GHz. */ 391 WIFI_6E, 392 /** 802.11be. */ 393 WIFI_7, 394 395 /** @cond INTERNAL_HIDDEN */ 396 __WIFI_LINK_MODE_AFTER_LAST, 397 WIFI_LINK_MODE_MAX = __WIFI_LINK_MODE_AFTER_LAST - 1, 398 WIFI_LINK_MODE_UNKNOWN 399 /** @endcond */ 400 }; 401 402 /** Helper function to get user-friendly link mode name. */ 403 const char *wifi_link_mode_txt(enum wifi_link_mode link_mode); 404 405 /** @brief Wi-Fi scanning types. */ 406 enum wifi_scan_type { 407 /** Active scanning (default). */ 408 WIFI_SCAN_TYPE_ACTIVE = 0, 409 /** Passive scanning. */ 410 WIFI_SCAN_TYPE_PASSIVE, 411 }; 412 413 /** @brief Wi-Fi power save states. */ 414 enum wifi_ps { 415 /** Power save disabled. */ 416 WIFI_PS_DISABLED = 0, 417 /** Power save enabled. */ 418 WIFI_PS_ENABLED, 419 }; 420 421 /** Helper function to get user-friendly ps name. */ 422 const char *wifi_ps_txt(enum wifi_ps ps_name); 423 424 /** @brief Wi-Fi power save modes. */ 425 enum wifi_ps_mode { 426 /** Legacy power save mode. */ 427 WIFI_PS_MODE_LEGACY = 0, 428 /* This has to be configured before connecting to the AP, 429 * as support for ADDTS action frames is not available. 430 */ 431 /** WMM power save mode. */ 432 WIFI_PS_MODE_WMM, 433 }; 434 435 /** Helper function to get user-friendly ps mode name. */ 436 const char *wifi_ps_mode_txt(enum wifi_ps_mode ps_mode); 437 438 /** Network interface index min value */ 439 #define WIFI_INTERFACE_INDEX_MIN 1 440 /** Network interface index max value */ 441 #define WIFI_INTERFACE_INDEX_MAX 255 442 443 /** @brief Wifi operational mode */ 444 enum wifi_operational_modes { 445 /** STA mode setting enable */ 446 WIFI_STA_MODE = BIT(0), 447 /** Monitor mode setting enable */ 448 WIFI_MONITOR_MODE = BIT(1), 449 /** TX injection mode setting enable */ 450 WIFI_TX_INJECTION_MODE = BIT(2), 451 /** Promiscuous mode setting enable */ 452 WIFI_PROMISCUOUS_MODE = BIT(3), 453 /** AP mode setting enable */ 454 WIFI_AP_MODE = BIT(4), 455 /** Softap mode setting enable */ 456 WIFI_SOFTAP_MODE = BIT(5), 457 }; 458 459 /** @brief Mode filter settings */ 460 enum wifi_filter { 461 /** Support management, data and control packet sniffing */ 462 WIFI_PACKET_FILTER_ALL = BIT(0), 463 /** Support only sniffing of management packets */ 464 WIFI_PACKET_FILTER_MGMT = BIT(1), 465 /** Support only sniffing of data packets */ 466 WIFI_PACKET_FILTER_DATA = BIT(2), 467 /** Support only sniffing of control packets */ 468 WIFI_PACKET_FILTER_CTRL = BIT(3), 469 }; 470 471 /** @brief Wi-Fi Target Wake Time (TWT) operations. */ 472 enum wifi_twt_operation { 473 /** TWT setup operation */ 474 WIFI_TWT_SETUP = 0, 475 /** TWT teardown operation */ 476 WIFI_TWT_TEARDOWN, 477 }; 478 479 /** Helper function to get user-friendly twt operation name. */ 480 const char *wifi_twt_operation_txt(enum wifi_twt_operation twt_operation); 481 482 /** @brief Wi-Fi Target Wake Time (TWT) negotiation types. */ 483 enum wifi_twt_negotiation_type { 484 /** TWT individual negotiation */ 485 WIFI_TWT_INDIVIDUAL = 0, 486 /** TWT broadcast negotiation */ 487 WIFI_TWT_BROADCAST, 488 /** TWT wake TBTT negotiation */ 489 WIFI_TWT_WAKE_TBTT 490 }; 491 492 /** Helper function to get user-friendly twt negotiation type name. */ 493 const char *wifi_twt_negotiation_type_txt(enum wifi_twt_negotiation_type twt_negotiation); 494 495 /** @brief Wi-Fi Target Wake Time (TWT) setup commands. */ 496 enum wifi_twt_setup_cmd { 497 /** TWT setup request */ 498 WIFI_TWT_SETUP_CMD_REQUEST = 0, 499 /** TWT setup suggest (parameters can be changed by AP) */ 500 WIFI_TWT_SETUP_CMD_SUGGEST, 501 /** TWT setup demand (parameters can not be changed by AP) */ 502 WIFI_TWT_SETUP_CMD_DEMAND, 503 /** TWT setup grouping (grouping of TWT flows) */ 504 WIFI_TWT_SETUP_CMD_GROUPING, 505 /** TWT setup accept (parameters accepted by AP) */ 506 WIFI_TWT_SETUP_CMD_ACCEPT, 507 /** TWT setup alternate (alternate parameters suggested by AP) */ 508 WIFI_TWT_SETUP_CMD_ALTERNATE, 509 /** TWT setup dictate (parameters dictated by AP) */ 510 WIFI_TWT_SETUP_CMD_DICTATE, 511 /** TWT setup reject (parameters rejected by AP) */ 512 WIFI_TWT_SETUP_CMD_REJECT, 513 }; 514 515 /** Helper function to get user-friendly twt setup cmd name. */ 516 const char *wifi_twt_setup_cmd_txt(enum wifi_twt_setup_cmd twt_setup); 517 518 /** @brief Wi-Fi Target Wake Time (TWT) negotiation status. */ 519 enum wifi_twt_setup_resp_status { 520 /** TWT response received for TWT request */ 521 WIFI_TWT_RESP_RECEIVED = 0, 522 /** TWT response not received for TWT request */ 523 WIFI_TWT_RESP_NOT_RECEIVED, 524 }; 525 526 /** @brief Target Wake Time (TWT) error codes. */ 527 enum wifi_twt_fail_reason { 528 /** Unspecified error */ 529 WIFI_TWT_FAIL_UNSPECIFIED, 530 /** Command execution failed */ 531 WIFI_TWT_FAIL_CMD_EXEC_FAIL, 532 /** Operation not supported */ 533 WIFI_TWT_FAIL_OPERATION_NOT_SUPPORTED, 534 /** Unable to get interface status */ 535 WIFI_TWT_FAIL_UNABLE_TO_GET_IFACE_STATUS, 536 /** Device not connected to AP */ 537 WIFI_TWT_FAIL_DEVICE_NOT_CONNECTED, 538 /** Peer not HE (802.11ax/Wi-Fi 6) capable */ 539 WIFI_TWT_FAIL_PEER_NOT_HE_CAPAB, 540 /** Peer not TWT capable */ 541 WIFI_TWT_FAIL_PEER_NOT_TWT_CAPAB, 542 /** A TWT flow is already in progress */ 543 WIFI_TWT_FAIL_OPERATION_IN_PROGRESS, 544 /** Invalid negotiated flow id */ 545 WIFI_TWT_FAIL_INVALID_FLOW_ID, 546 /** IP address not assigned or configured */ 547 WIFI_TWT_FAIL_IP_NOT_ASSIGNED, 548 /** Flow already exists */ 549 WIFI_TWT_FAIL_FLOW_ALREADY_EXISTS, 550 }; 551 552 /** @brief Wi-Fi Target Wake Time (TWT) teradown status. */ 553 enum wifi_twt_teardown_status { 554 /** TWT teardown success */ 555 WIFI_TWT_TEARDOWN_SUCCESS = 0, 556 /** TWT teardown failure */ 557 WIFI_TWT_TEARDOWN_FAILED, 558 }; 559 560 /** @cond INTERNAL_HIDDEN */ 561 static const char * const wifi_twt_err_code_tbl[] = { 562 [WIFI_TWT_FAIL_UNSPECIFIED] = "Unspecified", 563 [WIFI_TWT_FAIL_CMD_EXEC_FAIL] = "Command Execution failed", 564 [WIFI_TWT_FAIL_OPERATION_NOT_SUPPORTED] = 565 "Operation not supported", 566 [WIFI_TWT_FAIL_UNABLE_TO_GET_IFACE_STATUS] = 567 "Unable to get iface status", 568 [WIFI_TWT_FAIL_DEVICE_NOT_CONNECTED] = 569 "Device not connected", 570 [WIFI_TWT_FAIL_PEER_NOT_HE_CAPAB] = "Peer not HE capable", 571 [WIFI_TWT_FAIL_PEER_NOT_TWT_CAPAB] = "Peer not TWT capable", 572 [WIFI_TWT_FAIL_OPERATION_IN_PROGRESS] = 573 "Operation already in progress", 574 [WIFI_TWT_FAIL_INVALID_FLOW_ID] = 575 "Invalid negotiated flow id", 576 [WIFI_TWT_FAIL_IP_NOT_ASSIGNED] = 577 "IP address not assigned", 578 [WIFI_TWT_FAIL_FLOW_ALREADY_EXISTS] = 579 "Flow already exists", 580 }; 581 /** @endcond */ 582 583 /** Helper function to get user-friendly TWT error code name. */ wifi_twt_get_err_code_str(int16_t err_no)584 static inline const char *wifi_twt_get_err_code_str(int16_t err_no) 585 { 586 if ((err_no) < (int16_t)ARRAY_SIZE(wifi_twt_err_code_tbl)) { 587 return wifi_twt_err_code_tbl[err_no]; 588 } 589 590 return "<unknown>"; 591 } 592 593 /** @brief Wi-Fi power save parameters. */ 594 enum wifi_ps_param_type { 595 /** Power save state. */ 596 WIFI_PS_PARAM_STATE, 597 /** Power save listen interval (units: (short) beacon intervals). */ 598 WIFI_PS_PARAM_LISTEN_INTERVAL, 599 /** Power save wakeup mode. */ 600 WIFI_PS_PARAM_WAKEUP_MODE, 601 /** Power save mode. */ 602 WIFI_PS_PARAM_MODE, 603 /** Power save exit strategy. */ 604 WIFI_PS_PARAM_EXIT_STRATEGY, 605 /** Power save timeout. */ 606 WIFI_PS_PARAM_TIMEOUT, 607 }; 608 609 /** @brief Wi-Fi power save modes. */ 610 enum wifi_ps_wakeup_mode { 611 /** DTIM based wakeup. */ 612 WIFI_PS_WAKEUP_MODE_DTIM = 0, 613 /** Listen interval based wakeup. */ 614 WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL, 615 }; 616 617 /** Helper function to get user-friendly ps wakeup mode name. */ 618 const char *wifi_ps_wakeup_mode_txt(enum wifi_ps_wakeup_mode ps_wakeup_mode); 619 620 /** 621 * @brief Wi-Fi power save exit strategy 622 */ 623 enum wifi_ps_exit_strategy { 624 /** PS-Poll frame based */ 625 WIFI_PS_EXIT_CUSTOM_ALGO = 0, 626 /** QoS NULL frame based */ 627 WIFI_PS_EXIT_EVERY_TIM, 628 629 /** @cond INTERNAL_HIDDEN */ 630 WIFI_PS_EXIT_LAST, 631 WIFI_PS_EXIT_MAX = WIFI_PS_EXIT_LAST - 1, 632 /** @endcond */ 633 }; 634 635 /** Helper function to get user-friendly ps exit strategy name. */ 636 const char *wifi_ps_exit_strategy_txt(enum wifi_ps_exit_strategy ps_exit_strategy); 637 638 /** @brief Wi-Fi power save error codes. */ 639 enum wifi_config_ps_param_fail_reason { 640 /** Unspecified error */ 641 WIFI_PS_PARAM_FAIL_UNSPECIFIED, 642 /** Command execution failed */ 643 WIFI_PS_PARAM_FAIL_CMD_EXEC_FAIL, 644 /** Parameter not supported */ 645 WIFI_PS_PARAM_FAIL_OPERATION_NOT_SUPPORTED, 646 /** Unable to get interface status */ 647 WIFI_PS_PARAM_FAIL_UNABLE_TO_GET_IFACE_STATUS, 648 /** Device not connected to AP */ 649 WIFI_PS_PARAM_FAIL_DEVICE_NOT_CONNECTED, 650 /** Device already connected to AP */ 651 WIFI_PS_PARAM_FAIL_DEVICE_CONNECTED, 652 /** Listen interval out of range */ 653 WIFI_PS_PARAM_LISTEN_INTERVAL_RANGE_INVALID, 654 /** Invalid exit strategy */ 655 WIFI_PS_PARAM_FAIL_INVALID_EXIT_STRATEGY, 656 }; 657 658 /** @cond INTERNAL_HIDDEN */ 659 static const char * const wifi_ps_param_config_err_code_tbl[] = { 660 [WIFI_PS_PARAM_FAIL_UNSPECIFIED] = "Unspecified", 661 [WIFI_PS_PARAM_FAIL_CMD_EXEC_FAIL] = "Command Execution failed", 662 [WIFI_PS_PARAM_FAIL_OPERATION_NOT_SUPPORTED] = 663 "Operation not supported", 664 [WIFI_PS_PARAM_FAIL_UNABLE_TO_GET_IFACE_STATUS] = 665 "Unable to get iface status", 666 [WIFI_PS_PARAM_FAIL_DEVICE_NOT_CONNECTED] = 667 "Cannot set parameters while device not connected", 668 [WIFI_PS_PARAM_FAIL_DEVICE_CONNECTED] = 669 "Cannot set parameters while device connected", 670 [WIFI_PS_PARAM_LISTEN_INTERVAL_RANGE_INVALID] = 671 "Parameter out of range", 672 }; 673 /** @endcond */ 674 675 /** IEEE 802.11v BTM (BSS transition management) Query reasons. 676 * Refer to IEEE Std 802.11v-2011 - Table 7-43x-Transition and Transition Query reasons table. 677 */ 678 enum wifi_btm_query_reason { 679 /** Unspecified. */ 680 WIFI_BTM_QUERY_REASON_UNSPECIFIED = 0, 681 /** Low RSSI. */ 682 WIFI_BTM_QUERY_REASON_LOW_RSSI = 16, 683 /** Leaving ESS. */ 684 WIFI_BTM_QUERY_REASON_LEAVING_ESS = 20, 685 }; 686 687 /** Helper function to get user-friendly power save error code name. */ wifi_ps_get_config_err_code_str(int16_t err_no)688 static inline const char *wifi_ps_get_config_err_code_str(int16_t err_no) 689 { 690 if ((err_no) < (int16_t)ARRAY_SIZE(wifi_ps_param_config_err_code_tbl)) { 691 return wifi_ps_param_config_err_code_tbl[err_no]; 692 } 693 694 return "<unknown>"; 695 } 696 697 /** @brief Wi-Fi AP mode configuration parameter */ 698 enum wifi_ap_config_param { 699 /** Used for AP mode configuration parameter ap_max_inactivity */ 700 WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY = BIT(0), 701 /** Used for AP mode configuration parameter max_num_sta */ 702 WIFI_AP_CONFIG_PARAM_MAX_NUM_STA = BIT(1), 703 /** Used for AP mode configuration parameter bandwidth */ 704 WIFI_AP_CONFIG_PARAM_BANDWIDTH = BIT(2), 705 /** Used for AP mode configuration parameter ht_capab */ 706 WIFI_AP_CONFIG_PARAM_HT_CAPAB = BIT(3), 707 /** Used for AP mode configuration parameter vht_capab */ 708 WIFI_AP_CONFIG_PARAM_VHT_CAPAB = BIT(4), 709 }; 710 711 #ifdef __cplusplus 712 } 713 #endif 714 715 /** 716 * @} 717 */ 718 #endif /* ZEPHYR_INCLUDE_NET_WIFI_H_ */ 719