diff --git a/modules/hostap/CMakeLists.txt b/modules/hostap/CMakeLists.txt index 8a89329b10c839..e1bd8c6c232bcd 100644 --- a/modules/hostap/CMakeLists.txt +++ b/modules/hostap/CMakeLists.txt @@ -206,6 +206,7 @@ zephyr_library_sources_ifdef(CONFIG_WIFI_NM_WPA_SUPPLICANT_AP ${HOSTAP_SRC_BASE}/ap/mbo_ap.c ${HOSTAP_SRC_BASE}/ap/ctrl_iface_ap.c ${HOSTAP_SRC_BASE}/utils/crc32.c + ${HOSTAP_SRC_BASE}/utils/ip_addr.c ) zephyr_library_compile_definitions_ifdef(CONFIG_WIFI_NM_WPA_SUPPLICANT_AP @@ -226,7 +227,6 @@ zephyr_include_directories_ifdef(CONFIG_WIFI_NM_HOSTAPD_AP zephyr_library_sources_ifdef(CONFIG_WIFI_NM_HOSTAPD_AP ${HOSTAP_SRC_BASE}/ap/acs.c - ${HOSTAP_SRC_BASE}/utils/ip_addr.c ${WIFI_NM_HOSTAPD_BASE}/config_file.c ${WIFI_NM_HOSTAPD_BASE}/ctrl_iface.c ${WIFI_NM_HOSTAPD_BASE}/ctrl_iface_zephyr.c @@ -243,6 +243,27 @@ zephyr_library_compile_definitions_ifdef(CONFIG_WIFI_NM_HOSTAPD_AP zephyr_library_sources_ifdef(CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_NONE ${HOSTAP_SRC_BASE}/crypto/crypto_none.c ${HOSTAP_SRC_BASE}/crypto/tls_none.c + + # FIXME: why do we need these when crypto is not selected? + ${HOSTAP_SRC_BASE}/crypto/aes-wrap.c + ${HOSTAP_SRC_BASE}/crypto/aes-internal.c + ${HOSTAP_SRC_BASE}/crypto/aes-internal-enc.c + ${HOSTAP_SRC_BASE}/crypto/aes-omac1.c + ${HOSTAP_SRC_BASE}/crypto/md5.c + ${HOSTAP_SRC_BASE}/crypto/md5-internal.c + ${HOSTAP_SRC_BASE}/crypto/sha1.c + ${HOSTAP_SRC_BASE}/crypto/sha1-internal.c + ${HOSTAP_SRC_BASE}/crypto/sha1-pbkdf2.c + ${HOSTAP_SRC_BASE}/crypto/sha1-prf.c + ${HOSTAP_SRC_BASE}/crypto/sha256.c + ${HOSTAP_SRC_BASE}/crypto/sha256-internal.c + ${HOSTAP_SRC_BASE}/crypto/sha256-prf.c + ${HOSTAP_SRC_BASE}/crypto/sha384.c + ${HOSTAP_SRC_BASE}/crypto/sha384-internal.c + ${HOSTAP_SRC_BASE}/crypto/sha384-prf.c + ${HOSTAP_SRC_BASE}/crypto/sha512.c + ${HOSTAP_SRC_BASE}/crypto/sha512-internal.c + ${HOSTAP_SRC_BASE}/crypto/rc4.c ) zephyr_library_compile_definitions_ifdef(CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_NONE @@ -609,6 +630,7 @@ zephyr_library_sources_ifdef(CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE ${HOSTAP_SRC_BASE}/crypto/ms_funcs.c ${HOSTAP_SRC_BASE}/crypto/aes-eax.c ${HOSTAP_SRC_BASE}/crypto/md4-internal.c + ${HOSTAP_SRC_BASE}/crypto/sha1-internal.c ${HOSTAP_SRC_BASE}/crypto/fips_prf_internal.c ${HOSTAP_SRC_BASE}/crypto/milenage.c ) diff --git a/modules/hostap/Kconfig b/modules/hostap/Kconfig index 09a43d7d07e33a..e22059f00f067d 100644 --- a/modules/hostap/Kconfig +++ b/modules/hostap/Kconfig @@ -247,6 +247,7 @@ config WIFI_NM_WPA_SUPPLICANT_P2P bool "P2P mode support" select WIFI_NM_WPA_SUPPLICANT_AP select WIFI_NM_WPA_SUPPLICANT_WPS + select WIFI_NM_WPA_SUPPLICANT_EAPOL config WIFI_NM_WPA_SUPPLICANT_EAPOL bool "EAPoL supplicant" @@ -439,9 +440,6 @@ config EAP_EKE config EAP_IKEv2 bool -config IEEE8021X_EAPOL - bool - config CRYPTO_INTERNAL bool @@ -545,4 +543,11 @@ config WIFI_NM_WPA_SUPPLICANT_CRYPTO_TEST bool depends on WIFI_NM_WPA_SUPPLICANT_CRYPTO_MBEDTLS_PSA +config WIFI_NM_WPA_CTRL_RESP_TIMEOUT_S + int "WPA supplicant control interface response timeout in seconds" + default 15 + help + Timeout for the control interface commands to get a response from the + supplicant. + endif # WIFI_NM_WPA_SUPPLICANT diff --git a/modules/hostap/src/supp_api.c b/modules/hostap/src/supp_api.c index 24561086f384f4..52772b4becfc64 100644 --- a/modules/hostap/src/supp_api.c +++ b/modules/hostap/src/supp_api.c @@ -1116,6 +1116,45 @@ int supplicant_disconnect(const struct device *dev) return wpas_disconnect_network(dev, WPAS_MODE_INFRA); } +static enum wifi_mfp_options get_mfp(enum mfp_options supp_mfp_option) +{ + switch (supp_mfp_option) { + case NO_MGMT_FRAME_PROTECTION: + return WIFI_MFP_DISABLE; + case MGMT_FRAME_PROTECTION_OPTIONAL: + return WIFI_MFP_OPTIONAL; + case MGMT_FRAME_PROTECTION_REQUIRED: + return WIFI_MFP_REQUIRED; + default: + wpa_printf(MSG_ERROR, "Invalid mfp mapping %d", supp_mfp_option); + break; + } + + return WIFI_MFP_DISABLE; +} + +static enum wifi_iface_mode get_iface_mode(enum wpas_mode supp_mode) +{ + switch (supp_mode) { + case WPAS_MODE_INFRA: + return WIFI_MODE_INFRA; + case WPAS_MODE_IBSS: + return WIFI_MODE_IBSS; + case WPAS_MODE_AP: + return WIFI_MODE_AP; + case WPAS_MODE_P2P_GO: + return WIFI_MODE_P2P_GO; + case WPAS_MODE_P2P_GROUP_FORMATION: + return WIFI_MODE_P2P_GROUP_FORMATION; + case WPAS_MODE_MESH: + return WIFI_MODE_MESH; + default: + break; + } + + return WIFI_MODE_UNKNOWN; +} + int supplicant_status(const struct device *dev, struct wifi_iface_status *status) { struct net_if *iface = net_if_lookup_by_dev(dev); @@ -1169,7 +1208,7 @@ int supplicant_status(const struct device *dev, struct wifi_iface_status *status os_memcpy(status->bssid, wpa_s->bssid, WIFI_MAC_ADDR_LEN); status->band = wpas_band_to_zephyr(wpas_freq_to_band(wpa_s->assoc_freq)); status->security = wpas_key_mgmt_to_zephyr(key_mgmt, proto); - status->mfp = ssid->ieee80211w; /* Same mapping */ + status->mfp = get_mfp(ssid->ieee80211w); ieee80211_freq_to_chan(wpa_s->assoc_freq, &channel); status->channel = channel; @@ -1187,7 +1226,7 @@ int supplicant_status(const struct device *dev, struct wifi_iface_status *status os_memcpy(status->ssid, _ssid, ssid_len); status->ssid_len = ssid_len; - status->iface_mode = ssid->mode; + status->iface_mode = get_iface_mode(ssid->mode); if (wpa_s->connection_set == 1) { status->link_mode = wpa_s->connection_he ? WIFI_6 : @@ -1847,7 +1886,6 @@ int supplicant_ap_config_params(const struct device *dev, struct wifi_ap_config_ return ret; } -#endif int supplicant_ap_status(const struct device *dev, struct wifi_iface_status *status) { @@ -1895,12 +1933,12 @@ int supplicant_ap_status(const struct device *dev, struct wifi_iface_status *sta ssid = &bss->ssid; os_memcpy(status->bssid, hapd->own_addr, WIFI_MAC_ADDR_LEN); - status->iface_mode = WPAS_MODE_AP; + status->iface_mode = WIFI_MODE_AP; status->band = wpas_band_to_zephyr(wpas_freq_to_band(iface->freq)); key_mgmt = bss->wpa_key_mgmt; proto = bss->wpa; status->security = wpas_key_mgmt_to_zephyr(key_mgmt, proto); - status->mfp = bss->ieee80211w; + status->mfp = get_mfp(bss->ieee80211w); status->channel = conf->channel; os_memcpy(status->ssid, ssid->ssid, ssid->ssid_len); @@ -1922,6 +1960,7 @@ int supplicant_ap_status(const struct device *dev, struct wifi_iface_status *sta k_mutex_unlock(&wpa_supplicant_mutex); return ret; } +#endif /* CONFIG_WIFI_NM_HOSTAPD_AP */ int supplicant_ap_enable(const struct device *dev, struct wifi_connect_req_params *params) diff --git a/modules/hostap/src/supp_main.c b/modules/hostap/src/supp_main.c index b47b322e2aa3ad..826e15e9d8d3de 100644 --- a/modules/hostap/src/supp_main.c +++ b/modules/hostap/src/supp_main.c @@ -94,11 +94,9 @@ DEFINE_WIFI_NM_INSTANCE(wifi_supplicant, &mgmt_ops); #ifdef CONFIG_WIFI_NM_HOSTAPD_AP static const struct wifi_mgmt_ops mgmt_ap_ops = { - .set_btwt = supplicant_set_btwt, .ap_enable = supplicant_ap_enable, .ap_disable = supplicant_ap_disable, .ap_sta_disconnect = supplicant_ap_sta_disconnect, - .ap_bandwidth = supplicant_ap_bandwidth, .iface_status = supplicant_ap_status, #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP .dpp_dispatch = hapd_dpp_dispatch, diff --git a/modules/hostap/src/supp_main.h b/modules/hostap/src/supp_main.h index e80ced0343184c..981bdf66958514 100644 --- a/modules/hostap/src/supp_main.h +++ b/modules/hostap/src/supp_main.h @@ -15,7 +15,7 @@ !defined(CONFIG_EAP_PSK) && !defined(CONFIG_EAP_PAX) && \ !defined(CONFIG_EAP_SAKE) && !defined(CONFIG_EAP_GPSK) && \ !defined(CONFIG_EAP_PWD) && !defined(CONFIG_EAP_EKE) && \ - !defined(CONFIG_EAP_IKEV2 && !defined(CONFIG_EAP_GTC) + !defined(CONFIG_EAP_IKEV2) && !defined(CONFIG_EAP_GTC) #error "At least one of the following EAP methods need to be defined \ CONFIG_EAP_TLS \ CONFIG_EAP_TTLS \ @@ -52,12 +52,17 @@ static inline void net_dhcpv4_stop(struct net_if *iface) struct wpa_global *zephyr_get_default_supplicant_context(void); struct wpa_supplicant *zephyr_get_handle_by_ifname(const char *ifname); + #ifdef CONFIG_WIFI_NM_HOSTAPD_AP +#include "common.h" +#include "wpa_debug_zephyr.h" + struct hostapd_iface *zephyr_get_hapd_handle_by_ifname(const char *ifname); void wpa_supplicant_msg_send(void *ctx, int level, enum wpa_msg_type type, const char *txt, size_t len); void hostapd_msg_send(void *ctx, int level, enum wpa_msg_type type, const char *buf, size_t len); #endif + struct wpa_supplicant_event_msg { #ifdef CONFIG_WIFI_NM_HOSTAPD_AP int hostapd; diff --git a/tests/net/wifi/configs/CMakeLists.txt b/tests/net/wifi/configs/CMakeLists.txt new file mode 100644 index 00000000000000..518596a02f7800 --- /dev/null +++ b/tests/net/wifi/configs/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(build_all) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/net/wifi/configs/prj.conf b/tests/net/wifi/configs/prj.conf new file mode 100644 index 00000000000000..2a2f4d2cf6b853 --- /dev/null +++ b/tests/net/wifi/configs/prj.conf @@ -0,0 +1,33 @@ +CONFIG_TEST=y +CONFIG_TEST_USERSPACE=y +CONFIG_NET_TEST=y + +CONFIG_NETWORKING=y +CONFIG_NET_IPV4=y +CONFIG_NET_IPV6=y +CONFIG_NET_CONFIG_SETTINGS=n + +CONFIG_WIFI=y +CONFIG_WIFI_NM=y + +CONFIG_SHELL=y +CONFIG_NET_SHELL=y +CONFIG_NET_L2_WIFI_SHELL=y +CONFIG_NET_L2_WIFI_MGMT=y + +CONFIG_WIFI_SHELL_MAX_AP_STA=2 +CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS=y +CONFIG_WIFI_MGMT_FORCED_PASSIVE_SCAN=y +CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX=3 +CONFIG_WIFI_MGMT_SCAN_CHAN_MAX_MANUAL=10 +CONFIG_WIFI_NM_MAX_MANAGED_INTERFACES=2 +CONFIG_WIFI_MGMT_AP_STA_SKIP_INACTIVITY_POLL=y +CONFIG_WIFI_MGMT_AP_MAX_NUM_STA=10 + +CONFIG_WIFI_NM_WPA_SUPPLICANT=y +CONFIG_WIFI_NM_WPA_SUPPLICANT_DEBUG_LEVEL=0 +CONFIG_WIFI_NM_WPA_SUPPLICANT_WEP=y +CONFIG_WIFI_NM_WPA_SUPPLICANT_ADVANCED_FEATURES=y +CONFIG_WIFI_NM_WPA_SUPPLICANT_AP=y +CONFIG_WIFI_NM_WPA_SUPPLICANT_CLI=y +CONFIG_WPA_CLI=y diff --git a/tests/net/wifi/configs/src/main.c b/tests/net/wifi/configs/src/main.c new file mode 100644 index 00000000000000..a05ee59143061f --- /dev/null +++ b/tests/net/wifi/configs/src/main.c @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +int main(void) +{ + return 0; +} diff --git a/tests/net/wifi/configs/testcase.yaml b/tests/net/wifi/configs/testcase.yaml new file mode 100644 index 00000000000000..017407bc8467c2 --- /dev/null +++ b/tests/net/wifi/configs/testcase.yaml @@ -0,0 +1,66 @@ +common: + build_only: true + tags: + - drivers + - wifi + - net + platform_allow: + - native_sim + - native_sim/native/64 +tests: + wifi.build.crypto_default: + extra_configs: + - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO=y + wifi.build.crypto_alt: + extra_configs: + - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ALT=y + wifi.build.crypto_none: + extra_configs: + - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_NONE=y + # FIXME: The psa crypto does not work atm so commented out + # the build test temporarily. + # wifi.build.crypto_psa: + # extra_configs: + # - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_MBEDTLS_PSA=y + wifi.build.crypto_enterprise: + extra_configs: + - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ALT=y + - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE=y + - CONFIG_MBEDTLS_TLS_VERSION_1_2=y + - CONFIG_EAP_TLS=y + - CONFIG_EAP_TTLS=y + - CONFIG_EAP_PEAP=y + - CONFIG_EAP_MD5=y + - CONFIG_EAP_MSCHAPV2=y + - CONFIG_EAP_LEAP=y + - CONFIG_EAP_PSK=y + - CONFIG_EAP_PAX=y + - CONFIG_EAP_SAKE=y + - CONFIG_EAP_GPSK=y + - CONFIG_EAP_PWD=y + - CONFIG_EAP_EKE=y + - CONFIG_EAP_IKEV2=y + - CONFIG_EAP_SIM=y + - CONFIG_EAP_AKA=y + wifi.build.wpa3: + extra_configs: + - CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3=y + - CONFIG_MBEDTLS_TLS_VERSION_1_2=y + wifi.build.wps: + extra_configs: + - CONFIG_WIFI_NM_WPA_SUPPLICANT_WPS=y + - CONFIG_WIFI_NM_WPA_SUPPLICANT_EAPOL=y + - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO=y + wifi.build.p2p: + extra_configs: + - CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P=y + - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO=y + wifi.build.hostapd_ap: + extra_configs: + - CONFIG_WIFI_NM_HOSTAPD_AP=y + - CONFIG_WIFI_NM_WPA_SUPPLICANT_INF_MON=n + wifi.build.dpp: + extra_configs: + - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ALT=y + - CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE=y + - CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP=y diff --git a/west.yml b/west.yml index 924ea20615cc33..18967c457865ee 100644 --- a/west.yml +++ b/west.yml @@ -259,7 +259,7 @@ manifest: - hal - name: hostap path: modules/lib/hostap - revision: ac59d28778b20cd68702f55dad2a27d648e3d571 + revision: e481fe559e17052ec8ea04388a934f3d30816737 - name: libmetal revision: a6851ba6dba8c9e87d00c42f171a822f7a29639b path: modules/hal/libmetal