Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
wifi.h
Go to the documentation of this file.
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
20#ifndef ZEPHYR_INCLUDE_NET_WIFI_H_
21#define ZEPHYR_INCLUDE_NET_WIFI_H_
22
23#include <zephyr/sys/util.h> /* for ARRAY_SIZE */
24
26#define WIFI_COUNTRY_CODE_LEN 2
27
30#define WIFI_LISTEN_INTERVAL_MIN 0
31#define WIFI_LISTEN_INTERVAL_MAX 65535
32
35#ifdef __cplusplus
36extern "C" {
37#endif
38
66
68const char *wifi_security_txt(enum wifi_security_type security);
69
78
80 __WIFI_MFP_AFTER_LAST,
81 WIFI_MFP_MAX = __WIFI_MFP_AFTER_LAST - 1,
82 WIFI_MFP_UNKNOWN
84};
85
87const char *wifi_mfp_txt(enum wifi_mfp_options mfp);
88
99
101 __WIFI_FREQ_BAND_AFTER_LAST,
103 WIFI_FREQ_BAND_MAX = __WIFI_FREQ_BAND_AFTER_LAST - 1,
107
109const char *wifi_band_txt(enum wifi_frequency_bands band);
110
112#define WIFI_SSID_MAX_LEN 32
114#define WIFI_PSK_MIN_LEN 8
116#define WIFI_PSK_MAX_LEN 64
118#define WIFI_SAE_PSWD_MAX_LEN 128
120#define WIFI_MAC_ADDR_LEN 6
121
123#define WIFI_CHANNEL_MIN 1
125#define WIFI_CHANNEL_MAX 233
127#define WIFI_CHANNEL_ANY 255
128
161
162/* We rely on the strict order of the enum values, so, let's check it */
172
173
176
194
196 __WIFI_MODE_AFTER_LAST,
197 WIFI_MODE_MAX = __WIFI_MODE_AFTER_LAST - 1,
198 WIFI_MODE_UNKNOWN
200};
201
203const char *wifi_mode_txt(enum wifi_iface_mode mode);
204
228
230 __WIFI_LINK_MODE_AFTER_LAST,
231 WIFI_LINK_MODE_MAX = __WIFI_LINK_MODE_AFTER_LAST - 1,
232 WIFI_LINK_MODE_UNKNOWN
234};
235
237const char *wifi_link_mode_txt(enum wifi_link_mode link_mode);
238
246
254
256const char *wifi_ps_txt(enum wifi_ps ps_name);
257
262 /* This has to be configured before connecting to the AP,
263 * as support for ADDTS action frames is not available.
264 */
267};
268
270const char *wifi_ps_mode_txt(enum wifi_ps_mode ps_mode);
271
273#define WIFI_INTERFACE_INDEX_MIN 1
275#define WIFI_INTERFACE_INDEX_MAX 255
276
292
304
312
314const char *wifi_twt_operation_txt(enum wifi_twt_operation twt_operation);
315
325
328
348
350const char *wifi_twt_setup_cmd_txt(enum wifi_twt_setup_cmd twt_setup);
351
359
385
393
395static const char * const wifi_twt_err_code_tbl[] = {
396 [WIFI_TWT_FAIL_UNSPECIFIED] = "Unspecified",
397 [WIFI_TWT_FAIL_CMD_EXEC_FAIL] = "Command Execution failed",
399 "Operation not supported",
401 "Unable to get iface status",
403 "Device not connected",
404 [WIFI_TWT_FAIL_PEER_NOT_HE_CAPAB] = "Peer not HE capable",
405 [WIFI_TWT_FAIL_PEER_NOT_TWT_CAPAB] = "Peer not TWT capable",
407 "Operation already in progress",
409 "Invalid negotiated flow id",
411 "IP address not assigned",
413 "Flow already exists",
414};
418static inline const char *wifi_twt_get_err_code_str(int16_t err_no)
419{
420 if ((err_no) < (int16_t)ARRAY_SIZE(wifi_twt_err_code_tbl)) {
421 return wifi_twt_err_code_tbl[err_no];
422 }
423
424 return "<unknown>";
425}
426
440
448
450const char *wifi_ps_wakeup_mode_txt(enum wifi_ps_wakeup_mode ps_wakeup_mode);
451
469
471static const char * const wifi_ps_param_config_err_code_tbl[] = {
472 [WIFI_PS_PARAM_FAIL_UNSPECIFIED] = "Unspecified",
473 [WIFI_PS_PARAM_FAIL_CMD_EXEC_FAIL] = "Command Execution failed",
475 "Operation not supported",
477 "Unable to get iface status",
479 "Cannot set parameters while device not connected",
481 "Cannot set parameters while device connected",
483 "Parameter out of range",
484};
488static inline const char *wifi_ps_get_config_err_code_str(int16_t err_no)
489{
490 if ((err_no) < (int16_t)ARRAY_SIZE(wifi_ps_param_config_err_code_tbl)) {
491 return wifi_ps_param_config_err_code_tbl[err_no];
492 }
493
494 return "<unknown>";
495}
496
504
505#ifdef __cplusplus
506}
507#endif
508
512#endif /* ZEPHYR_INCLUDE_NET_WIFI_H_ */
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define ARRAY_SIZE(array)
Number of elements in the given array.
Definition util.h:127
const char * wifi_state_txt(enum wifi_iface_state state)
Helper function to get user-friendly interface state name.
const char * wifi_link_mode_txt(enum wifi_link_mode link_mode)
Helper function to get user-friendly link mode name.
wifi_ps
Wi-Fi power save states.
Definition wifi.h:248
wifi_frequency_bands
IEEE 802.11 operational frequency bands (not exhaustive).
Definition wifi.h:92
wifi_mfp_options
IEEE 802.11w - Management frame protection.
Definition wifi.h:71
const char * wifi_mfp_txt(enum wifi_mfp_options mfp)
Helper function to get user-friendly MFP name.
wifi_twt_setup_cmd
Wi-Fi Target Wake Time (TWT) setup commands.
Definition wifi.h:330
const char * wifi_band_txt(enum wifi_frequency_bands band)
Helper function to get user-friendly frequency band name.
wifi_operational_modes
Wifi operational mode.
Definition wifi.h:278
wifi_twt_setup_resp_status
Wi-Fi Target Wake Time (TWT) negotiation status.
Definition wifi.h:353
wifi_iface_mode
Wi-Fi interface modes.
Definition wifi.h:181
wifi_twt_negotiation_type
Wi-Fi Target Wake Time (TWT) negotiation types.
Definition wifi.h:317
const char * wifi_twt_negotiation_type_txt(enum wifi_twt_negotiation_type twt_negotiation)
Helper function to get user-friendly twt negotiation type name.
const char * wifi_ps_wakeup_mode_txt(enum wifi_ps_wakeup_mode ps_wakeup_mode)
Helper function to get user-friendly ps wakeup mode name.
wifi_ap_config_param
Wi-Fi AP mode configuration parameter.
Definition wifi.h:498
static const char * wifi_ps_get_config_err_code_str(int16_t err_no)
Helper function to get user-friendly power save error code name.
Definition wifi.h:488
wifi_twt_fail_reason
Target Wake Time (TWT) error codes.
Definition wifi.h:361
wifi_iface_state
Wi-Fi interface states.
Definition wifi.h:133
const char * wifi_security_txt(enum wifi_security_type security)
Helper function to get user-friendly security type name.
wifi_filter
Mode filter settings.
Definition wifi.h:294
static const char * wifi_twt_get_err_code_str(int16_t err_no)
Helper function to get user-friendly TWT error code name.
Definition wifi.h:418
wifi_link_mode
Wi-Fi link operating modes.
Definition wifi.h:209
wifi_ps_param_type
Wi-Fi power save parameters.
Definition wifi.h:428
wifi_ps_wakeup_mode
Wi-Fi power save modes.
Definition wifi.h:442
wifi_twt_operation
Wi-Fi Target Wake Time (TWT) operations.
Definition wifi.h:306
wifi_scan_type
Wi-Fi scanning types.
Definition wifi.h:240
wifi_twt_teardown_status
Wi-Fi Target Wake Time (TWT) teradown status.
Definition wifi.h:387
const char * wifi_mode_txt(enum wifi_iface_mode mode)
Helper function to get user-friendly interface mode name.
wifi_config_ps_param_fail_reason
Wi-Fi power save error codes.
Definition wifi.h:453
const char * wifi_twt_operation_txt(enum wifi_twt_operation twt_operation)
Helper function to get user-friendly twt operation name.
const char * wifi_ps_mode_txt(enum wifi_ps_mode ps_mode)
Helper function to get user-friendly ps mode name.
wifi_security_type
IEEE 802.11 security types.
Definition wifi.h:40
const char * wifi_twt_setup_cmd_txt(enum wifi_twt_setup_cmd twt_setup)
Helper function to get user-friendly twt setup cmd name.
const char * wifi_ps_txt(enum wifi_ps ps_name)
Helper function to get user-friendly ps name.
wifi_ps_mode
Wi-Fi power save modes.
Definition wifi.h:259
@ WIFI_PS_ENABLED
Power save enabled.
Definition wifi.h:252
@ WIFI_PS_DISABLED
Power save disabled.
Definition wifi.h:250
@ WIFI_FREQ_BAND_6_GHZ
6 GHz band (Wi-Fi 6E, also extends to 7GHz).
Definition wifi.h:98
@ WIFI_FREQ_BAND_2_4_GHZ
2.4 GHz band.
Definition wifi.h:94
@ WIFI_FREQ_BAND_UNKNOWN
Invalid frequency band.
Definition wifi.h:105
@ WIFI_FREQ_BAND_5_GHZ
5 GHz band.
Definition wifi.h:96
@ WIFI_FREQ_BAND_MAX
Highest frequency band available.
Definition wifi.h:103
@ WIFI_MFP_DISABLE
MFP disabled.
Definition wifi.h:73
@ WIFI_MFP_OPTIONAL
MFP optional.
Definition wifi.h:75
@ WIFI_MFP_REQUIRED
MFP required.
Definition wifi.h:77
@ WIFI_TWT_SETUP_CMD_DEMAND
TWT setup demand (parameters can not be changed by AP)
Definition wifi.h:336
@ WIFI_TWT_SETUP_CMD_REQUEST
TWT setup request.
Definition wifi.h:332
@ WIFI_TWT_SETUP_CMD_ALTERNATE
TWT setup alternate (alternate parameters suggested by AP)
Definition wifi.h:342
@ WIFI_TWT_SETUP_CMD_GROUPING
TWT setup grouping (grouping of TWT flows)
Definition wifi.h:338
@ WIFI_TWT_SETUP_CMD_DICTATE
TWT setup dictate (parameters dictated by AP)
Definition wifi.h:344
@ WIFI_TWT_SETUP_CMD_SUGGEST
TWT setup suggest (parameters can be changed by AP)
Definition wifi.h:334
@ WIFI_TWT_SETUP_CMD_REJECT
TWT setup reject (parameters rejected by AP)
Definition wifi.h:346
@ WIFI_TWT_SETUP_CMD_ACCEPT
TWT setup accept (parameters accepted by AP)
Definition wifi.h:340
@ WIFI_TX_INJECTION_MODE
TX injection mode setting enable.
Definition wifi.h:284
@ WIFI_STA_MODE
STA mode setting enable.
Definition wifi.h:280
@ WIFI_AP_MODE
AP mode setting enable.
Definition wifi.h:288
@ WIFI_SOFTAP_MODE
Softap mode setting enable.
Definition wifi.h:290
@ WIFI_MONITOR_MODE
Monitor mode setting enable.
Definition wifi.h:282
@ WIFI_PROMISCUOUS_MODE
Promiscuous mode setting enable.
Definition wifi.h:286
@ WIFI_TWT_RESP_RECEIVED
TWT response received for TWT request.
Definition wifi.h:355
@ WIFI_TWT_RESP_NOT_RECEIVED
TWT response not received for TWT request.
Definition wifi.h:357
@ WIFI_MODE_AP
AP mode.
Definition wifi.h:187
@ WIFI_MODE_IBSS
IBSS (ad-hoc) station mode.
Definition wifi.h:185
@ WIFI_MODE_P2P_GO
P2P group owner mode.
Definition wifi.h:189
@ WIFI_MODE_P2P_GROUP_FORMATION
P2P group formation mode.
Definition wifi.h:191
@ WIFI_MODE_INFRA
Infrastructure station mode.
Definition wifi.h:183
@ WIFI_MODE_MESH
802.11s Mesh mode.
Definition wifi.h:193
@ WIFI_TWT_BROADCAST
TWT broadcast negotiation.
Definition wifi.h:321
@ WIFI_TWT_WAKE_TBTT
TWT wake TBTT negotiation.
Definition wifi.h:323
@ WIFI_TWT_INDIVIDUAL
TWT individual negotiation.
Definition wifi.h:319
@ WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY
Used for AP mode configuration parameter ap_max_inactivity.
Definition wifi.h:500
@ WIFI_AP_CONFIG_PARAM_MAX_NUM_STA
Used for AP mode configuration parameter max_num_sta.
Definition wifi.h:502
@ WIFI_TWT_FAIL_IP_NOT_ASSIGNED
IP address not assigned or configured.
Definition wifi.h:381
@ WIFI_TWT_FAIL_INVALID_FLOW_ID
Invalid negotiated flow id.
Definition wifi.h:379
@ WIFI_TWT_FAIL_CMD_EXEC_FAIL
Command execution failed.
Definition wifi.h:365
@ WIFI_TWT_FAIL_OPERATION_NOT_SUPPORTED
Operation not supported.
Definition wifi.h:367
@ WIFI_TWT_FAIL_UNABLE_TO_GET_IFACE_STATUS
Unable to get interface status.
Definition wifi.h:369
@ WIFI_TWT_FAIL_PEER_NOT_HE_CAPAB
Peer not HE (802.11ax/Wi-Fi 6) capable.
Definition wifi.h:373
@ WIFI_TWT_FAIL_DEVICE_NOT_CONNECTED
Device not connected to AP.
Definition wifi.h:371
@ WIFI_TWT_FAIL_OPERATION_IN_PROGRESS
A TWT flow is already in progress.
Definition wifi.h:377
@ WIFI_TWT_FAIL_PEER_NOT_TWT_CAPAB
Peer not TWT capable.
Definition wifi.h:375
@ WIFI_TWT_FAIL_UNSPECIFIED
Unspecified error.
Definition wifi.h:363
@ WIFI_TWT_FAIL_FLOW_ALREADY_EXISTS
Flow already exists.
Definition wifi.h:383
@ WIFI_STATE_DISCONNECTED
Interface is disconnected.
Definition wifi.h:135
@ WIFI_STATE_GROUP_HANDSHAKE
Group Key exchange with a network is in progress.
Definition wifi.h:151
@ WIFI_STATE_INTERFACE_DISABLED
Interface is disabled (administratively).
Definition wifi.h:137
@ WIFI_STATE_4WAY_HANDSHAKE
4-way handshake with a network is in progress.
Definition wifi.h:149
@ WIFI_STATE_ASSOCIATED
Association with a network completed.
Definition wifi.h:147
@ WIFI_STATE_SCANNING
Interface is scanning for networks.
Definition wifi.h:141
@ WIFI_STATE_AUTHENTICATING
Authentication with a network is in progress.
Definition wifi.h:143
@ WIFI_STATE_COMPLETED
All authentication completed, ready to pass data.
Definition wifi.h:153
@ WIFI_STATE_ASSOCIATING
Association with a network is in progress.
Definition wifi.h:145
@ WIFI_STATE_INACTIVE
No enabled networks in the configuration.
Definition wifi.h:139
@ WIFI_PACKET_FILTER_MGMT
Support only sniffing of management packets.
Definition wifi.h:298
@ WIFI_PACKET_FILTER_ALL
Support management, data and control packet sniffing.
Definition wifi.h:296
@ WIFI_PACKET_FILTER_DATA
Support only sniffing of data packets.
Definition wifi.h:300
@ WIFI_PACKET_FILTER_CTRL
Support only sniffing of control packets.
Definition wifi.h:302
@ WIFI_6E
802.11ax 6GHz.
Definition wifi.h:225
@ WIFI_5
802.11ac.
Definition wifi.h:221
@ WIFI_0
802.11 (legacy).
Definition wifi.h:211
@ WIFI_7
802.11be.
Definition wifi.h:227
@ WIFI_4
802.11n.
Definition wifi.h:219
@ WIFI_2
802.11a.
Definition wifi.h:215
@ WIFI_6
802.11ax.
Definition wifi.h:223
@ WIFI_1
802.11b.
Definition wifi.h:213
@ WIFI_3
802.11g.
Definition wifi.h:217
@ WIFI_PS_PARAM_LISTEN_INTERVAL
Power save listen interval.
Definition wifi.h:432
@ WIFI_PS_PARAM_STATE
Power save state.
Definition wifi.h:430
@ WIFI_PS_PARAM_WAKEUP_MODE
Power save wakeup mode.
Definition wifi.h:434
@ WIFI_PS_PARAM_MODE
Power save mode.
Definition wifi.h:436
@ WIFI_PS_PARAM_TIMEOUT
Power save timeout.
Definition wifi.h:438
@ WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL
Listen interval based wakeup.
Definition wifi.h:446
@ WIFI_PS_WAKEUP_MODE_DTIM
DTIM based wakeup.
Definition wifi.h:444
@ WIFI_TWT_SETUP
TWT setup operation.
Definition wifi.h:308
@ WIFI_TWT_TEARDOWN
TWT teardown operation.
Definition wifi.h:310
@ WIFI_SCAN_TYPE_ACTIVE
Active scanning (default).
Definition wifi.h:242
@ WIFI_SCAN_TYPE_PASSIVE
Passive scanning.
Definition wifi.h:244
@ WIFI_TWT_TEARDOWN_SUCCESS
TWT teardown success.
Definition wifi.h:389
@ WIFI_TWT_TEARDOWN_FAILED
TWT teardown failure.
Definition wifi.h:391
@ WIFI_PS_PARAM_FAIL_UNABLE_TO_GET_IFACE_STATUS
Unable to get interface status.
Definition wifi.h:461
@ WIFI_PS_PARAM_FAIL_UNSPECIFIED
Unspecified error.
Definition wifi.h:455
@ WIFI_PS_PARAM_FAIL_CMD_EXEC_FAIL
Command execution failed.
Definition wifi.h:457
@ WIFI_PS_PARAM_FAIL_DEVICE_NOT_CONNECTED
Device not connected to AP.
Definition wifi.h:463
@ WIFI_PS_PARAM_LISTEN_INTERVAL_RANGE_INVALID
Listen interval out of range.
Definition wifi.h:467
@ WIFI_PS_PARAM_FAIL_OPERATION_NOT_SUPPORTED
Parameter not supported.
Definition wifi.h:459
@ WIFI_PS_PARAM_FAIL_DEVICE_CONNECTED
Device already connected to AP.
Definition wifi.h:465
@ WIFI_SECURITY_TYPE_SAE
WPA3-SAE security.
Definition wifi.h:48
@ WIFI_SECURITY_TYPE_PSK_SHA256
WPA2-PSK-SHA256 security.
Definition wifi.h:46
@ WIFI_SECURITY_TYPE_PSK
WPA2-PSK security.
Definition wifi.h:44
@ WIFI_SECURITY_TYPE_WPA_AUTO_PERSONAL
WPA/WPA2/WPA3 PSK security.
Definition wifi.h:58
@ WIFI_SECURITY_TYPE_WAPI
GB 15629.11-2003 WAPI security.
Definition wifi.h:50
@ WIFI_SECURITY_TYPE_WEP
WEP security.
Definition wifi.h:54
@ WIFI_SECURITY_TYPE_NONE
No security.
Definition wifi.h:42
@ WIFI_SECURITY_TYPE_WPA_PSK
WPA-PSK security.
Definition wifi.h:56
@ WIFI_SECURITY_TYPE_EAP
EAP security - Enterprise.
Definition wifi.h:52
@ WIFI_PS_MODE_WMM
WMM power save mode.
Definition wifi.h:266
@ WIFI_PS_MODE_LEGACY
Legacy power save mode.
Definition wifi.h:261
state
Definition parser_state.h:29
__INT16_TYPE__ int16_t
Definition stdint.h:73
Misc utilities.