1 /* 2 * Copyright (c) 2023 Nordic Semiconductor ASA 3 * Copyright 2024 NXP 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #ifndef ZEPHYR_SUPP_MGMT_H 9 #define ZEPHYR_SUPP_MGMT_H 10 11 #include <defs.h> 12 #include <zephyr/net/wifi_mgmt.h> 13 14 #ifndef MAX_SSID_LEN 15 #define MAX_SSID_LEN 32 16 #endif 17 #ifndef MAC_ADDR_LEN 18 #define MAC_ADDR_LEN 6 19 #endif 20 21 #define MAC_STR_LEN 18 /* for ':' or '-' separated MAC address string */ 22 #define CHAN_NUM_LEN 6 /* for space-separated channel numbers string */ 23 24 enum wifi_frequency_bands wpas_band_to_zephyr(enum wpa_radio_work_band band); 25 26 enum wifi_wpa3_enterprise_type wpas_key_mgmt_to_zephyr_wpa3_ent(int key_mgmt); 27 28 enum wifi_security_type wpas_key_mgmt_to_zephyr(bool is_hapd, void *config, 29 int key_mgmt, int proto, int pwe); 30 31 const struct wifi_mgmt_ops *const get_wifi_mgmt_api(const struct device *dev); 32 33 enum wifi_mfp_options get_mfp(enum mfp_options supp_mfp_option); 34 35 /** 36 * @brief Get version 37 * 38 * @param dev: Wi-Fi interface name to use 39 * @param params: version to fill 40 * 41 * @return: 0 for OK; <0 for ERROR 42 */ 43 int supplicant_get_version(const struct device *dev, struct wifi_version *params); 44 45 /** 46 * @brief Request a connection 47 * 48 * @param dev: Wi-Fi interface name to use 49 * @param params: Connection details 50 * 51 * @return: 0 for OK; -1 for ERROR 52 */ 53 int supplicant_connect(const struct device *dev, struct wifi_connect_req_params *params); 54 55 /** 56 * @brief Forces station to disconnect and stops any subsequent scan 57 * or connection attempts 58 * 59 * @param dev: Wi-Fi interface name to use 60 * 61 * @return: 0 for OK; -1 for ERROR 62 */ 63 int supplicant_disconnect(const struct device *dev); 64 65 /** 66 * @brief 67 * 68 * @param dev: Wi-Fi interface name to use 69 * @param status: Status structure to fill 70 * 71 * @return: 0 for OK; -1 for ERROR 72 */ 73 int supplicant_status(const struct device *dev, struct wifi_iface_status *status); 74 75 /** 76 * @brief Request a scan 77 * 78 * @param dev Wi-Fi interface name to use 79 * @param params Scan parameters 80 * @param cb Callback to be called for each scan result 81 * 82 * @return 0 for OK; -1 for ERROR 83 */ 84 int supplicant_scan(const struct device *dev, struct wifi_scan_params *params, 85 scan_result_cb_t cb); 86 87 #if defined(CONFIG_NET_STATISTICS_WIFI) || defined(__DOXYGEN__) 88 /** 89 * @brief Get Wi-Fi statistics 90 * 91 * @param dev Wi-Fi interface name to use 92 * @param stats Pointer to stats structure to fill 93 * 94 * @return 0 for OK; -1 for ERROR 95 */ 96 int supplicant_get_stats(const struct device *dev, struct net_stats_wifi *stats); 97 /** 98 * @brief Reset Wi-Fi statistics 99 * 100 * @param dev Wi-Fi interface name to use 101 * 102 * @return 0 for OK; -1 for ERROR 103 */ 104 int supplicant_reset_stats(const struct device *dev); 105 #endif /* CONFIG_NET_STATISTICS_WIFI || __DOXYGEN__ */ 106 107 /** Flush PMKSA cache entries 108 * 109 * @param dev Pointer to the device structure for the driver instance. 110 * 111 * @return 0 if ok, < 0 if error 112 */ 113 int supplicant_pmksa_flush(const struct device *dev); 114 115 /** Set or get 11K status 116 * 117 * @param dev Pointer to the device structure for the driver instance. 118 * @param params 11k parameters 119 * 120 * @return 0 if ok, < 0 if error 121 */ 122 int supplicant_11k_cfg(const struct device *dev, struct wifi_11k_params *params); 123 124 /** Send 11k neighbor request 125 * 126 * @param dev Pointer to the device structure for the driver instance. 127 * @param params 11k parameters 128 * 129 * @return 0 if ok, < 0 if error 130 */ 131 int supplicant_11k_neighbor_request(const struct device *dev, struct wifi_11k_params *params); 132 133 #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_ROAMING 134 /** Send candidate scan request 135 * 136 * @param dev Pointer to the device structure for the driver instance. 137 * @param params Scan parameters 138 * 139 * @return 0 if ok, < 0 if error 140 */ 141 int supplicant_candidate_scan(const struct device *dev, struct wifi_scan_params *params); 142 143 /** Send 11r roaming request 144 * 145 * @param dev Pointer to the device structure for the driver instance. 146 * 147 * @return 0 if ok, < 0 if error 148 */ 149 int supplicant_11r_roaming(const struct device *dev); 150 #endif 151 152 /** 153 * @brief Set Wi-Fi power save configuration 154 * 155 * @param dev Wi-Fi interface name to use 156 * @param params Power save parameters to set 157 * 158 * @return 0 for OK; -1 for ERROR 159 */ 160 int supplicant_set_power_save(const struct device *dev, struct wifi_ps_params *params); 161 162 /** 163 * @brief Set Wi-Fi TWT parameters 164 * 165 * @param dev Wi-Fi interface name to use 166 * @param params TWT parameters to set 167 * @return 0 for OK; -1 for ERROR 168 */ 169 int supplicant_set_twt(const struct device *dev, struct wifi_twt_params *params); 170 171 /** 172 * @brief Set Wi-Fi BTWT parameters 173 * 174 * @param dev Wi-Fi interface name to use 175 * @param params BTWT parameters to set 176 * @return 0 for OK; -1 for ERROR 177 */ 178 int supplicant_set_btwt(const struct device *dev, struct wifi_twt_params *params); 179 180 /** 181 * @brief Get Wi-Fi power save configuration 182 * 183 * @param dev Wi-Fi interface name to use 184 * @param config Address of power save configuration to fill 185 * @return 0 for OK; -1 for ERROR 186 */ 187 int supplicant_get_power_save_config(const struct device *dev, struct wifi_ps_config *config); 188 189 /** 190 * @brief Set Wi-Fi Regulatory domain 191 * 192 * @param dev Wi-Fi interface name to use 193 * @param reg_domain Regulatory domain to set 194 * @return 0 for OK; -1 for ERROR 195 */ 196 int supplicant_reg_domain(const struct device *dev, struct wifi_reg_domain *reg_domain); 197 198 /** 199 * @brief Set Wi-Fi mode of operation 200 * 201 * @param dev Wi-Fi interface name to use 202 * @param mode Mode setting to set 203 * @return 0 for OK; -1 for ERROR 204 */ 205 int supplicant_mode(const struct device *dev, struct wifi_mode_info *mode); 206 207 #if defined CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE || \ 208 defined CONFIG_WIFI_NM_HOSTAPD_CRYPTO_ENTERPRISE 209 int is_eap_valid_security(int security); 210 211 int process_cipher_config(struct wifi_connect_req_params *params, 212 struct wifi_eap_cipher_config *cipher_config); 213 214 /** Set Wi-Fi enterprise mode CA/client Cert and key 215 * 216 * @param dev Pointer to the device structure for the driver instance 217 * @param file Pointer to the CA/client Cert and key. 218 * 219 * @return 0 if ok, < 0 if error 220 */ 221 int supplicant_add_enterprise_creds(const struct device *dev, 222 struct wifi_enterprise_creds_params *creds); 223 #endif 224 225 /** 226 * @brief Set Wi-Fi packet filter for sniffing operation 227 * 228 * @param dev Wi-Fi interface name to use 229 * @param filter Filter settings to set 230 * @return 0 for OK; -1 for ERROR 231 */ 232 int supplicant_filter(const struct device *dev, struct wifi_filter_info *filter); 233 234 /** 235 * @brief Set Wi-Fi channel for monitor or TX injection mode 236 * 237 * @param dev Wi-Fi interface name to use 238 * @param channel Channel settings to set 239 * @return 0 for OK; -1 for ERROR 240 */ 241 int supplicant_channel(const struct device *dev, struct wifi_channel_info *channel); 242 243 /** 244 * @brief Set Wi-Fi RTS threshold 245 * 246 * @param dev Wi-Fi interface handle to use 247 * @param rts_threshold RTS threshold to set 248 * @return 0 for OK; -1 for ERROR 249 */ 250 int supplicant_set_rts_threshold(const struct device *dev, unsigned int rts_threshold); 251 252 /** 253 * @brief Get Wi-Fi RTS threshold 254 * 255 * @param dev Wi-Fi interface handle to use 256 * @param rts_threshold Pointer to the RTS threshold value. 257 * @return 0 for OK; -1 for ERROR 258 */ 259 int supplicant_get_rts_threshold(const struct device *dev, unsigned int *rts_threshold); 260 261 #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_WNM 262 /** Send bss transition query 263 * 264 * @param dev Pointer to the device structure for the driver instance. 265 * @param reason query reason 266 * 267 * @return 0 if ok, < 0 if error 268 */ 269 int supplicant_btm_query(const struct device *dev, uint8_t reason); 270 #endif 271 272 /** Send legacy roam 273 * 274 * @param dev Pointer to the device structure for the driver instance. 275 * 276 * @return 0 if ok, < 0 if error 277 */ 278 int supplicant_legacy_roam(const struct device *dev); 279 280 /** Check if ap supports Neighbor report or not. 281 * 282 * @param dev Pointer to the device structure for the driver instance. 283 * 284 * @return true if support, false if not support 285 */ 286 bool supplicant_bss_support_neighbor_rep(const struct device *dev); 287 288 /** Judge ap whether support the capability 289 * 290 * @param dev Pointer to the device structure for the driver instance. 291 * @param capab is the capability to judge 292 * 293 * @return 1 if support, 0 if not support 294 */ 295 int supplicant_bss_ext_capab(const struct device *dev, int capab); 296 297 /** Get Wi-Fi connection parameters recently used 298 * 299 * @param dev Pointer to the device structure for the driver instance 300 * @param params the Wi-Fi connection parameters recently used 301 * 302 * @return 0 if ok, < 0 if error 303 */ 304 int supplicant_get_wifi_conn_params(const struct device *dev, 305 struct wifi_connect_req_params *params); 306 307 /** Start a WPS PBC/PIN connection 308 * 309 * @param dev Pointer to the device structure for the driver instance 310 * @param params wps operarion parameters 311 * 312 * @return 0 if ok, < 0 if error 313 */ 314 int supplicant_wps_config(const struct device *dev, struct wifi_wps_config_params *params); 315 316 /** @ Set Wi-Fi max idle period 317 * 318 * @param dev Wi-Fi interface handle to use 319 * @param bss_max_idle_period Maximum idle period to set 320 * @return 0 for OK; -1 for ERROR 321 */ 322 int supplicant_set_bss_max_idle_period(const struct device *dev, 323 unsigned short bss_max_idle_period); 324 #ifdef CONFIG_AP 325 int set_ap_bandwidth(const struct device *dev, enum wifi_frequency_bandwidths bandwidth); 326 327 /** 328 * @brief Set Wi-Fi AP configuration 329 * 330 * @param dev Wi-Fi interface name to use 331 * @param params AP configuration parameters to set 332 * @return 0 for OK; -1 for ERROR 333 */ 334 int supplicant_ap_enable(const struct device *dev, 335 struct wifi_connect_req_params *params); 336 337 /** 338 * @brief Disable Wi-Fi AP 339 * @param dev Wi-Fi interface name to use 340 * @return 0 for OK; -1 for ERROR 341 */ 342 int supplicant_ap_disable(const struct device *dev); 343 344 /** 345 * @brief Set Wi-Fi AP STA disconnect 346 * @param dev Wi-Fi interface name to use 347 * @param mac_addr MAC address of the station to disconnect 348 * @return 0 for OK; -1 for ERROR 349 */ 350 int supplicant_ap_sta_disconnect(const struct device *dev, 351 const uint8_t *mac_addr); 352 353 #endif /* CONFIG_AP */ 354 355 #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP 356 #define SUPPLICANT_DPP_CMD_BUF_SIZE 384 357 358 int dpp_params_to_cmd(struct wifi_dpp_params *params, char *cmd, size_t max_len); 359 360 /** 361 * @brief Dispatch DPP operations for STA 362 * 363 * @param dev Wi-Fi interface name to use 364 * @param dpp_params DPP action enum and params in string 365 * @return 0 for OK; -1 for ERROR 366 */ 367 int supplicant_dpp_dispatch(const struct device *dev, struct wifi_dpp_params *params); 368 #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP */ 369 370 /** 371 * @brief Wi-Fi STA configuration parameter. 372 * 373 * @param dev Wi-Fi interface handle to use 374 * @param params STA parameters 375 * @return 0 for OK; -1 for ERROR 376 */ 377 int supplicant_config_params(const struct device *dev, struct wifi_config_params *params); 378 #endif /* ZEPHYR_SUPP_MGMT_H */ 379