LCOV - code coverage report
Current view: top level - zephyr/net - wifi.h Coverage Total Hit
Test: new.info Lines: 93.7 % 79 74
Test Date: 2025-09-05 22:20:39

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

Generated by: LCOV version 2.0-1