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