Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hostap configuration build tests #79973

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion modules/hostap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
)
Expand Down
11 changes: 8 additions & 3 deletions modules/hostap/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -439,9 +440,6 @@ config EAP_EKE
config EAP_IKEv2
bool

config IEEE8021X_EAPOL
bool

config CRYPTO_INTERNAL
bool

Expand Down Expand Up @@ -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
49 changes: 44 additions & 5 deletions modules/hostap/src/supp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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 :
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions modules/hostap/src/supp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion modules/hostap/src/supp_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
!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 \

Check notice on line 19 in modules/hostap/src/supp_main.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

modules/hostap/src/supp_main.h:19 -#if !defined(CONFIG_EAP_TLS) && !defined(CONFIG_EAP_TTLS) && \ - !defined(CONFIG_EAP_PEAP) && !defined(CONFIG_EAP_FAST) && \ - !defined(CONFIG_EAP_SIM) && !defined(CONFIG_EAP_AKA) && \ - !defined(CONFIG_EAP_MD5) && !defined(CONFIG_EAP_MSCHAPV2) && \ - !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) +#if !defined(CONFIG_EAP_TLS) && !defined(CONFIG_EAP_TTLS) && !defined(CONFIG_EAP_PEAP) && \ + !defined(CONFIG_EAP_FAST) && !defined(CONFIG_EAP_SIM) && !defined(CONFIG_EAP_AKA) && \ + !defined(CONFIG_EAP_MD5) && !defined(CONFIG_EAP_MSCHAPV2) && !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)
CONFIG_EAP_TLS \
CONFIG_EAP_TTLS \
CONFIG_EAP_PEAP \
Expand Down Expand Up @@ -52,12 +52,17 @@

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;
Expand Down
8 changes: 8 additions & 0 deletions tests/net/wifi/configs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
33 changes: 33 additions & 0 deletions tests/net/wifi/configs/prj.conf
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tests/net/wifi/configs/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

int main(void)
{
return 0;
}
66 changes: 66 additions & 0 deletions tests/net/wifi/configs/testcase.yaml
Original file line number Diff line number Diff line change
@@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jukkar is the guidance to continue to add the extra configuration items to this test case as they get added to Zephyr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might not be practical to add new config options here. I think we should have these set differently by having a Kconfig option that sets needed values like these, and then just select that one option here.

- 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
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ manifest:
- hal
- name: hostap
path: modules/lib/hostap
revision: ac59d28778b20cd68702f55dad2a27d648e3d571
revision: e481fe559e17052ec8ea04388a934f3d30816737
- name: libmetal
revision: a6851ba6dba8c9e87d00c42f171a822f7a29639b
path: modules/hal/libmetal
Expand Down
Loading