Revert "Revert "[wpa_supplicant] cumilative patch from commit 3a..."
Revert submission 28102966-revert-26533062-Supplicant_merge_June24-CUATTSRBBR
Reason for revert: Fixed the regression issue (ag/28389573)
Reverted changes: /q/submissionid:28102966-revert-26533062-Supplicant_merge_June24-CUATTSRBBR
Bug: 329004037
Test: Turn ON/OFF SoftAp multiple times
Change-Id: Ibfff2a847be5678f1a6d77e28506a05936812a91
diff --git a/hostapd/Android.mk b/hostapd/Android.mk
index ca81b61..d916488 100644
--- a/hostapd/Android.mk
+++ b/hostapd/Android.mk
@@ -253,6 +253,8 @@
OBJS += src/common/ocv.c
endif
+NEED_AES_UNWRAP=y
+
ifdef CONFIG_IEEE80211R
L_CFLAGS += -DCONFIG_IEEE80211R -DCONFIG_IEEE80211R_AP
OBJS += src/ap/wpa_auth_ft.c
@@ -599,6 +601,12 @@
endif
endif
+ifdef CONFIG_NAN_USD
+OBJS += src/common/nan_de.c
+OBJS += src/ap/nan_usd_ap.c
+L_CFLAGS += -DCONFIG_NAN_USD
+endif
+
ifdef CONFIG_PASN
L_CFLAGS += -DCONFIG_PASN
L_CFLAGS += -DCONFIG_PTKSA_CACHE
diff --git a/hostapd/Makefile b/hostapd/Makefile
index a2adc85..274a82d 100644
--- a/hostapd/Makefile
+++ b/hostapd/Makefile
@@ -167,7 +167,7 @@
ifdef CONFIG_CODE_COVERAGE
-CFLAGS += -O0 -fprofile-arcs -ftest-coverage
+CFLAGS += -O0 -fprofile-arcs -ftest-coverage -U_FORTIFY_SOURCE
LIBS += -lgcov
LIBS_c += -lgcov
LIBS_h += -lgcov
@@ -276,6 +276,8 @@
OBJS += ../src/common/ocv.o
endif
+NEED_AES_UNWRAP=y
+
ifdef CONFIG_IEEE80211R
CFLAGS += -DCONFIG_IEEE80211R -DCONFIG_IEEE80211R_AP
OBJS += ../src/ap/wpa_auth_ft.o
@@ -609,6 +611,12 @@
endif
endif
+ifdef CONFIG_NAN_USD
+OBJS += ../src/common/nan_de.o
+OBJS += ../src/ap/nan_usd_ap.o
+CFLAGS += -DCONFIG_NAN_USD
+endif
+
ifdef CONFIG_PASN
CFLAGS += -DCONFIG_PASN
CFLAGS += -DCONFIG_PTKSA_CACHE
diff --git a/hostapd/android.config b/hostapd/android.config
index 1c4dab2..9d20c8d 100644
--- a/hostapd/android.config
+++ b/hostapd/android.config
@@ -264,3 +264,6 @@
# certain percentage of probe requests or auth/(re)assoc frames.
# Each test case requires a flag set in hostapd.conf or through hostapd_cli
#CONFIG_TESTING_OPTIONS=y
+
+# Wi-Fi Aware unsynchronized service discovery (NAN USD)
+#CONFIG_NAN_USD=y
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index bfb152e..79cc1c2 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -1,6 +1,6 @@
/*
* hostapd / Configuration file parser
- * Copyright (c) 2003-2018, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2003-2024, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -1020,6 +1020,78 @@
return 0;
}
+
+
+int hostapd_config_read_rxkh_file(struct hostapd_bss_config *conf,
+ const char *fname)
+{
+ FILE *f;
+ char buf[256], *pos;
+ int line = 0, errors = 0;
+
+ if (!fname)
+ return 0;
+
+ f = fopen(fname, "r");
+ if (!f) {
+ wpa_printf(MSG_ERROR, "rxkh file '%s' not found.", fname);
+ return -1;
+ }
+
+ while (fgets(buf, sizeof(buf), f)) {
+ line++;
+
+ if (buf[0] == '#')
+ continue;
+ pos = buf;
+ while (*pos != '\0') {
+ if (*pos == '\n') {
+ *pos = '\0';
+ break;
+ }
+ pos++;
+ }
+ if (buf[0] == '\0')
+ continue;
+
+ pos = os_strchr(buf, '=');
+ if (!pos) {
+ wpa_printf(MSG_ERROR, "Line %d: Invalid line '%s'",
+ line, buf);
+ errors++;
+ continue;
+ }
+ *pos = '\0';
+ pos++;
+
+ if (os_strcmp(buf, "r0kh") == 0) {
+ if (add_r0kh(conf, pos) < 0) {
+ wpa_printf(MSG_ERROR,
+ "Line %d: Invalid r0kh '%s'",
+ line, pos);
+ errors++;
+ }
+ } else if (os_strcmp(buf, "r1kh") == 0) {
+ if (add_r1kh(conf, pos) < 0) {
+ wpa_printf(MSG_ERROR,
+ "Line %d: Invalid r1kh '%s'",
+ line, pos);
+ errors++;
+ }
+ }
+ }
+
+ fclose(f);
+
+ if (errors) {
+ wpa_printf(MSG_ERROR,
+ "%d errors in configuring RxKHs from '%s'",
+ errors, fname);
+ return -1;
+ }
+ return 0;
+}
+
#endif /* CONFIG_IEEE80211R_AP */
@@ -2159,6 +2231,7 @@
#ifdef CONFIG_SAE
+
static int parse_sae_password(struct hostapd_bss_config *bss, const char *val)
{
struct sae_password_entry *pw;
@@ -2262,6 +2335,40 @@
os_free(pw);
return -1;
}
+
+
+static int parse_sae_password_file(struct hostapd_bss_config *bss,
+ const char *fname)
+{
+ FILE *f;
+ char buf[500], *pos;
+ unsigned int line = 0;
+
+ f = fopen(fname, "r");
+ if (!f) {
+ wpa_printf(MSG_ERROR, "sae_password_file '%s' not found.",
+ fname);
+ return -1;
+ }
+
+ while (fgets(buf, sizeof(buf), f)) {
+ pos = os_strchr(buf, '\n');
+ if (pos)
+ *pos = '\0';
+ line++;
+ if (parse_sae_password(bss, buf)) {
+ wpa_printf(MSG_ERROR,
+ "Invalid SAE password at line %d in '%s'",
+ line, fname);
+ fclose(f);
+ return -1;
+ }
+ }
+
+ fclose(f);
+ return 0;
+}
+
#endif /* CONFIG_SAE */
@@ -2311,6 +2418,24 @@
}
+#ifdef CONFIG_IEEE80211BE
+static int get_u16(const char *pos, int line, u16 *ret_val)
+{
+ char *end;
+ long int val = strtol(pos, &end, 0);
+
+ if (*end || val < 0 || val > 0xffff) {
+ wpa_printf(MSG_ERROR, "Line %d: Invalid value '%s'",
+ line, pos);
+ return -1;
+ }
+
+ *ret_val = val;
+ return 0;
+}
+#endif /* CONFIG_IEEE80211BE */
+
+
static int hostapd_config_fill(struct hostapd_config *conf,
struct hostapd_bss_config *bss,
const char *buf, char *pos, int line)
@@ -3047,6 +3172,21 @@
line, pos);
return 1;
}
+ } else if (os_strcmp(buf, "rxkh_file") == 0) {
+ os_free(bss->rxkh_file);
+ bss->rxkh_file = os_strdup(pos);
+ if (!bss->rxkh_file) {
+ wpa_printf(MSG_ERROR, "Line %d: allocation failed",
+ line);
+ return 1;
+ }
+ if (hostapd_config_read_rxkh_file(bss, pos)) {
+ wpa_printf(MSG_DEBUG,
+ "Line %d: failed to read rxkh_file '%s'",
+ line, pos);
+ /* Allow the file to be created later and read into
+ * already operating AP context. */
+ }
} else if (os_strcmp(buf, "pmk_r1_push") == 0) {
bss->pmk_r1_push = atoi(pos);
} else if (os_strcmp(buf, "ft_over_ds") == 0) {
@@ -3624,6 +3764,18 @@
}
} else if (os_strcmp(buf, "he_6ghz_reg_pwr_type") == 0) {
conf->he_6ghz_reg_pwr_type = atoi(pos);
+ if (conf->he_6ghz_reg_pwr_type > HE_REG_INFO_6GHZ_AP_TYPE_MAX) {
+ wpa_printf(MSG_ERROR,
+ "Line %d: invalid he_6ghz_reg_pwr_type value",
+ line);
+ return 1;
+ }
+ } else if (os_strcmp(buf, "reg_def_cli_eirp_psd") == 0) {
+ conf->reg_def_cli_eirp_psd = atoi(pos);
+ } else if (os_strcmp(buf, "reg_sub_cli_eirp_psd") == 0) {
+ conf->reg_sub_cli_eirp_psd = atoi(pos);
+ } else if (os_strcmp(buf, "reg_def_cli_eirp") == 0) {
+ conf->reg_def_cli_eirp = atoi(pos);
} else if (os_strcmp(buf, "he_oper_chwidth") == 0) {
conf->he_oper_chwidth = atoi(pos);
} else if (os_strcmp(buf, "he_oper_centr_freq_seg0_idx") == 0) {
@@ -4296,6 +4448,16 @@
bss->eap_skip_prot_success = atoi(pos);
} else if (os_strcmp(buf, "delay_eapol_tx") == 0) {
conf->delay_eapol_tx = atoi(pos);
+ } else if (os_strcmp(buf, "eapol_m1_elements") == 0) {
+ if (parse_wpabuf_hex(line, buf, &bss->eapol_m1_elements, pos))
+ return 1;
+ } else if (os_strcmp(buf, "eapol_m3_elements") == 0) {
+ if (parse_wpabuf_hex(line, buf, &bss->eapol_m3_elements, pos))
+ return 1;
+ } else if (os_strcmp(buf, "eapol_m3_no_encrypt") == 0) {
+ bss->eapol_m3_no_encrypt = atoi(pos);
+ } else if (os_strcmp(buf, "test_assoc_comeback_type") == 0) {
+ bss->test_assoc_comeback_type = atoi(pos);
#endif /* CONFIG_TESTING_OPTIONS */
#ifdef CONFIG_SAE
} else if (os_strcmp(buf, "sae_password") == 0) {
@@ -4304,6 +4466,13 @@
line);
return 1;
}
+ } else if (os_strcmp(buf, "sae_password_file") == 0) {
+ if (parse_sae_password_file(bss, pos) < 0) {
+ wpa_printf(MSG_ERROR,
+ "Line %d: Invalid sae_password in file",
+ line);
+ return 1;
+ }
#endif /* CONFIG_SAE */
} else if (os_strcmp(buf, "vendor_elements") == 0) {
if (parse_wpabuf_hex(line, buf, &bss->vendor_elements, pos))
@@ -4770,8 +4939,11 @@
conf->eht_phy_capab.su_beamformee = atoi(pos);
} else if (os_strcmp(buf, "eht_mu_beamformer") == 0) {
conf->eht_phy_capab.mu_beamformer = atoi(pos);
+ } else if (os_strcmp(buf, "eht_default_pe_duration") == 0) {
+ conf->eht_default_pe_duration = atoi(pos);
} else if (os_strcmp(buf, "punct_bitmap") == 0) {
- conf->punct_bitmap = atoi(pos);
+ if (get_u16(pos, line, &conf->punct_bitmap))
+ return 1;
} else if (os_strcmp(buf, "punct_acs_threshold") == 0) {
int val = atoi(pos);
@@ -4792,6 +4964,15 @@
line);
return 1;
}
+ } else if (os_strcmp(buf, "eht_bw320_offset") == 0) {
+ conf->eht_bw320_offset = atoi(pos);
+#ifdef CONFIG_TESTING_OPTIONS
+ } else if (os_strcmp(buf, "eht_oper_puncturing_override") == 0) {
+ if (get_u16(pos, line, &bss->eht_oper_puncturing_override))
+ return 1;
+ } else if (os_strcmp(buf, "mld_indicate_disabled") == 0) {
+ bss->mld_indicate_disabled = atoi(pos);
+#endif /* CONFIG_TESTING_OPTIONS */
#endif /* CONFIG_IEEE80211BE */
} else {
wpa_printf(MSG_ERROR,
diff --git a/hostapd/config_file.h b/hostapd/config_file.h
index c98bdb6..9ef6ac8 100644
--- a/hostapd/config_file.h
+++ b/hostapd/config_file.h
@@ -10,6 +10,8 @@
#define CONFIG_FILE_H
struct hostapd_config * hostapd_config_read(const char *fname);
+int hostapd_config_read_rxkh_file(struct hostapd_bss_config *conf,
+ const char *fname);
int hostapd_set_iface(struct hostapd_config *conf,
struct hostapd_bss_config *bss, const char *field,
char *value);
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 57c9997..a6b16c2 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -39,6 +39,7 @@
#include "common/wpa_ctrl.h"
#include "common/ptksa_cache.h"
#include "common/hw_features_common.h"
+#include "common/nan_de.h"
#include "crypto/tls.h"
#include "drivers/driver.h"
#include "eapol_auth/eapol_auth_sm.h"
@@ -63,6 +64,7 @@
#include "ap/rrm.h"
#include "ap/dpp_hostapd.h"
#include "ap/dfs.h"
+#include "ap/nan_usd_ap.h"
#include "wps/wps_defs.h"
#include "wps/wps.h"
#include "fst/fst_ctrl_iface.h"
@@ -1435,7 +1437,7 @@
pmk_match = PMK_LEN == pmk_len &&
os_memcmp(psk->psk, pmk, pmk_len) == 0;
sta_match = psk->group == 0 &&
- os_memcmp(sta->addr, psk->addr, ETH_ALEN) == 0;
+ ether_addr_equal(sta->addr, psk->addr);
bss_match = psk->group == 1;
if (pmk_match && (sta_match || bss_match))
@@ -1474,6 +1476,79 @@
}
+#ifdef CONFIG_IEEE80211R_AP
+
+static int hostapd_ctrl_iface_get_rxkhs(struct hostapd_data *hapd,
+ char *buf, size_t buflen)
+{
+ int ret, start_pos;
+ char *pos, *end;
+ struct ft_remote_r0kh *r0kh;
+ struct ft_remote_r1kh *r1kh;
+ struct hostapd_bss_config *conf = hapd->conf;
+
+ pos = buf;
+ end = buf + buflen;
+
+ for (r0kh = conf->r0kh_list; r0kh; r0kh=r0kh->next) {
+ start_pos = pos - buf;
+ ret = os_snprintf(pos, end - pos, "r0kh=" MACSTR " ",
+ MAC2STR(r0kh->addr));
+ if (os_snprintf_error(end - pos, ret))
+ return start_pos;
+ pos += ret;
+ if (r0kh->id_len + 1 >= (size_t) (end - pos))
+ return start_pos;
+ os_memcpy(pos, r0kh->id, r0kh->id_len);
+ pos += r0kh->id_len;
+ *pos++ = ' ';
+ pos += wpa_snprintf_hex(pos, end - pos, r0kh->key,
+ sizeof(r0kh->key));
+ ret = os_snprintf(pos, end - pos, "\n");
+ if (os_snprintf_error(end - pos, ret))
+ return start_pos;
+ pos += ret;
+ }
+
+ for (r1kh = conf->r1kh_list; r1kh; r1kh=r1kh->next) {
+ start_pos = pos - buf;
+ ret = os_snprintf(pos, end - pos, "r1kh=" MACSTR " " MACSTR " ",
+ MAC2STR(r1kh->addr), MAC2STR(r1kh->id));
+ if (os_snprintf_error(end - pos, ret))
+ return start_pos;
+ pos += ret;
+ pos += wpa_snprintf_hex(pos, end - pos, r1kh->key,
+ sizeof(r1kh->key));
+ ret = os_snprintf(pos, end - pos, "\n");
+ if (os_snprintf_error(end - pos, ret))
+ return start_pos;
+ pos += ret;
+ }
+
+ return pos - buf;
+}
+
+
+static int hostapd_ctrl_iface_reload_rxkhs(struct hostapd_data *hapd)
+{
+ struct hostapd_bss_config *conf = hapd->conf;
+ int err;
+
+ hostapd_config_clear_rxkhs(conf);
+
+ err = hostapd_config_read_rxkh_file(conf, conf->rxkh_file);
+ if (err < 0) {
+ wpa_printf(MSG_ERROR, "Reloading RxKHs failed: %d",
+ err);
+ return -1;
+ }
+
+ return 0;
+}
+
+#endif /* CONFIG_IEEE80211R_AP */
+
+
#ifdef CONFIG_TESTING_OPTIONS
static int hostapd_ctrl_iface_radar(struct hostapd_data *hapd, char *cmd)
@@ -2010,74 +2085,6 @@
}
-static int hostapd_ctrl_test_alloc_fail(struct hostapd_data *hapd, char *cmd)
-{
-#ifdef WPA_TRACE_BFD
- char *pos;
-
- wpa_trace_fail_after = atoi(cmd);
- pos = os_strchr(cmd, ':');
- if (pos) {
- pos++;
- os_strlcpy(wpa_trace_fail_func, pos,
- sizeof(wpa_trace_fail_func));
- } else {
- wpa_trace_fail_after = 0;
- }
-
- return 0;
-#else /* WPA_TRACE_BFD */
- return -1;
-#endif /* WPA_TRACE_BFD */
-}
-
-
-static int hostapd_ctrl_get_alloc_fail(struct hostapd_data *hapd,
- char *buf, size_t buflen)
-{
-#ifdef WPA_TRACE_BFD
- return os_snprintf(buf, buflen, "%u:%s", wpa_trace_fail_after,
- wpa_trace_fail_func);
-#else /* WPA_TRACE_BFD */
- return -1;
-#endif /* WPA_TRACE_BFD */
-}
-
-
-static int hostapd_ctrl_test_fail(struct hostapd_data *hapd, char *cmd)
-{
-#ifdef WPA_TRACE_BFD
- char *pos;
-
- wpa_trace_test_fail_after = atoi(cmd);
- pos = os_strchr(cmd, ':');
- if (pos) {
- pos++;
- os_strlcpy(wpa_trace_test_fail_func, pos,
- sizeof(wpa_trace_test_fail_func));
- } else {
- wpa_trace_test_fail_after = 0;
- }
-
- return 0;
-#else /* WPA_TRACE_BFD */
- return -1;
-#endif /* WPA_TRACE_BFD */
-}
-
-
-static int hostapd_ctrl_get_fail(struct hostapd_data *hapd,
- char *buf, size_t buflen)
-{
-#ifdef WPA_TRACE_BFD
- return os_snprintf(buf, buflen, "%u:%s", wpa_trace_test_fail_after,
- wpa_trace_test_fail_func);
-#else /* WPA_TRACE_BFD */
- return -1;
-#endif /* WPA_TRACE_BFD */
-}
-
-
static int hostapd_ctrl_reset_pn(struct hostapd_data *hapd, const char *cmd)
{
struct sta_info *sta;
@@ -2640,6 +2647,12 @@
if (ret)
return ret;
+ settings.link_id = -1;
+#ifdef CONFIG_IEEE80211BE
+ if (iface->num_bss && iface->bss[0]->conf->mld_ap)
+ settings.link_id = iface->bss[0]->mld_link_id;
+#endif /* CONFIG_IEEE80211BE */
+
ret = hostapd_ctrl_check_freq_params(&settings.freq_params,
settings.punct_bitmap);
if (ret) {
@@ -3449,6 +3462,416 @@
#endif /* ANDROID */
+#ifdef CONFIG_IEEE80211BE
+
+static int hostapd_ctrl_iface_enable_mld(struct hostapd_iface *iface)
+{
+ unsigned int i;
+
+ if (!iface || !iface->bss[0]->conf->mld_ap) {
+ wpa_printf(MSG_ERROR,
+ "Trying to enable AP MLD on an interface that is not affiliated with an AP MLD");
+ return -1;
+ }
+
+ for (i = 0; i < iface->interfaces->count; ++i) {
+ struct hostapd_iface *h_iface = iface->interfaces->iface[i];
+ struct hostapd_data *h_hapd = h_iface->bss[0];
+ struct hostapd_bss_config *h_conf = h_hapd->conf;
+
+ if (!h_conf->mld_ap ||
+ h_conf->mld_id != iface->bss[0]->conf->mld_id)
+ continue;
+
+ if (hostapd_enable_iface(h_iface)) {
+ wpa_printf(MSG_ERROR, "Enabling of AP MLD failed");
+ return -1;
+ }
+ }
+ return 0;
+}
+
+
+static void hostapd_disable_iface_bss(struct hostapd_iface *iface)
+{
+ unsigned int i;
+
+ for (i = 0; i < iface->num_bss; i++)
+ hostapd_bss_deinit_no_free(iface->bss[i]);
+}
+
+
+static int hostapd_ctrl_iface_disable_mld(struct hostapd_iface *iface)
+{
+ unsigned int i;
+ struct hostapd_iface *first_iface = NULL;
+
+ if (!iface || !iface->bss[0]->conf->mld_ap) {
+ wpa_printf(MSG_ERROR,
+ "Trying to disable AP MLD on an interface that is not affiliated with an AP MLD.");
+ return -1;
+ }
+
+ /* First, disable BSSs before stopping beaconing and doing driver
+ * deinit so that the broadcast Deauthentication frames go out. */
+
+ for (i = 0; i < iface->interfaces->count; ++i) {
+ struct hostapd_iface *h_iface = iface->interfaces->iface[i];
+ struct hostapd_data *h_hapd = h_iface->bss[0];
+ struct hostapd_bss_config *h_conf = h_hapd->conf;
+
+ if (!h_conf->mld_ap ||
+ h_conf->mld_id != iface->bss[0]->conf->mld_id)
+ continue;
+
+ if (!h_hapd->mld_first_bss) {
+ first_iface = h_iface;
+ continue;
+ }
+ hostapd_disable_iface_bss(iface);
+ }
+
+ if (first_iface)
+ hostapd_disable_iface_bss(first_iface);
+
+ /* Then, fully disable interfaces */
+
+ for (i = 0; i < iface->interfaces->count; ++i) {
+ struct hostapd_iface *h_iface = iface->interfaces->iface[i];
+ struct hostapd_data *h_hapd = h_iface->bss[0];
+ struct hostapd_bss_config *h_conf = h_hapd->conf;
+
+ if (!h_conf->mld_ap ||
+ h_conf->mld_id != iface->bss[0]->conf->mld_id ||
+ !h_hapd->mld_first_bss)
+ continue;
+
+ if (hostapd_disable_iface(h_iface)) {
+ wpa_printf(MSG_ERROR, "Disabling AP MLD failed");
+ return -1;
+ }
+ }
+
+ if (first_iface && hostapd_disable_iface(first_iface)) {
+ wpa_printf(MSG_ERROR, "Disabling AP MLD failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+#ifdef CONFIG_TESTING_OPTIONS
+static int hostapd_ctrl_iface_link_remove(struct hostapd_data *hapd, char *cmd,
+ char *buf, size_t buflen)
+{
+ int ret;
+ u32 count = atoi(cmd);
+
+ if (!count)
+ count = 1;
+
+ ret = hostapd_link_remove(hapd, count);
+ if (ret == 0) {
+ ret = os_snprintf(buf, buflen, "%s\n", "OK");
+ if (os_snprintf_error(buflen, ret))
+ ret = -1;
+ else
+ ret = 0;
+ }
+
+ return ret;
+}
+#endif /* CONFIG_TESTING_OPTIONS */
+#endif /* CONFIG_IEEE80211BE */
+
+
+#ifdef CONFIG_NAN_USD
+
+static int hostapd_ctrl_nan_publish(struct hostapd_data *hapd, char *cmd,
+ char *buf, size_t buflen)
+{
+ char *token, *context = NULL;
+ int publish_id;
+ struct nan_publish_params params;
+ const char *service_name = NULL;
+ struct wpabuf *ssi = NULL;
+ int ret = -1;
+ enum nan_service_protocol_type srv_proto_type = 0;
+
+ os_memset(¶ms, 0, sizeof(params));
+ /* USD shall use both solicited and unsolicited transmissions */
+ params.unsolicited = true;
+ params.solicited = true;
+ /* USD shall require FSD without GAS */
+ params.fsd = true;
+
+ while ((token = str_token(cmd, " ", &context))) {
+ if (os_strncmp(token, "service_name=", 13) == 0) {
+ service_name = token + 13;
+ continue;
+ }
+
+ if (os_strncmp(token, "ttl=", 4) == 0) {
+ params.ttl = atoi(token + 4);
+ continue;
+ }
+
+ if (os_strncmp(token, "srv_proto_type=", 15) == 0) {
+ srv_proto_type = atoi(token + 15);
+ continue;
+ }
+
+ if (os_strncmp(token, "ssi=", 4) == 0) {
+ if (ssi)
+ goto fail;
+ ssi = wpabuf_parse_bin(token + 4);
+ if (!ssi)
+ goto fail;
+ continue;
+ }
+
+ if (os_strcmp(token, "solicited=0") == 0) {
+ params.solicited = false;
+ continue;
+ }
+
+ if (os_strcmp(token, "unsolicited=0") == 0) {
+ params.unsolicited = false;
+ continue;
+ }
+
+ if (os_strcmp(token, "fsd=0") == 0) {
+ params.fsd = false;
+ continue;
+ }
+
+ wpa_printf(MSG_INFO, "CTRL: Invalid NAN_PUBLISH parameter: %s",
+ token);
+ goto fail;
+ }
+
+ publish_id = hostapd_nan_usd_publish(hapd, service_name, srv_proto_type,
+ ssi, ¶ms);
+ if (publish_id > 0)
+ ret = os_snprintf(buf, buflen, "%d", publish_id);
+fail:
+ wpabuf_free(ssi);
+ return ret;
+}
+
+
+static int hostapd_ctrl_nan_cancel_publish(struct hostapd_data *hapd,
+ char *cmd)
+{
+ char *token, *context = NULL;
+ int publish_id = 0;
+
+ while ((token = str_token(cmd, " ", &context))) {
+ if (sscanf(token, "publish_id=%i", &publish_id) == 1)
+ continue;
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid NAN_CANCEL_PUBLISH parameter: %s",
+ token);
+ return -1;
+ }
+
+ if (publish_id <= 0) {
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid or missing NAN_CANCEL_PUBLISH publish_id");
+ return -1;
+ }
+
+ hostapd_nan_usd_cancel_publish(hapd, publish_id);
+ return 0;
+}
+
+
+static int hostapd_ctrl_nan_update_publish(struct hostapd_data *hapd,
+ char *cmd)
+{
+ char *token, *context = NULL;
+ int publish_id = 0;
+ struct wpabuf *ssi = NULL;
+ int ret = -1;
+
+ while ((token = str_token(cmd, " ", &context))) {
+ if (sscanf(token, "publish_id=%i", &publish_id) == 1)
+ continue;
+ if (os_strncmp(token, "ssi=", 4) == 0) {
+ if (ssi)
+ goto fail;
+ ssi = wpabuf_parse_bin(token + 4);
+ if (!ssi)
+ goto fail;
+ continue;
+ }
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid NAN_UPDATE_PUBLISH parameter: %s",
+ token);
+ goto fail;
+ }
+
+ if (publish_id <= 0) {
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid or missing NAN_UPDATE_PUBLISH publish_id");
+ goto fail;
+ }
+
+ ret = hostapd_nan_usd_update_publish(hapd, publish_id, ssi);
+fail:
+ wpabuf_free(ssi);
+ return ret;
+}
+
+
+static int hostapd_ctrl_nan_subscribe(struct hostapd_data *hapd, char *cmd,
+ char *buf, size_t buflen)
+{
+ char *token, *context = NULL;
+ int subscribe_id;
+ struct nan_subscribe_params params;
+ const char *service_name = NULL;
+ struct wpabuf *ssi = NULL;
+ int ret = -1;
+ enum nan_service_protocol_type srv_proto_type = 0;
+
+ os_memset(¶ms, 0, sizeof(params));
+
+ while ((token = str_token(cmd, " ", &context))) {
+ if (os_strncmp(token, "service_name=", 13) == 0) {
+ service_name = token + 13;
+ continue;
+ }
+
+ if (os_strcmp(token, "active=1") == 0) {
+ params.active = true;
+ continue;
+ }
+
+ if (os_strncmp(token, "ttl=", 4) == 0) {
+ params.ttl = atoi(token + 4);
+ continue;
+ }
+
+ if (os_strncmp(token, "srv_proto_type=", 15) == 0) {
+ srv_proto_type = atoi(token + 15);
+ continue;
+ }
+
+ if (os_strncmp(token, "ssi=", 4) == 0) {
+ if (ssi)
+ goto fail;
+ ssi = wpabuf_parse_bin(token + 4);
+ if (!ssi)
+ goto fail;
+ continue;
+ }
+
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid NAN_SUBSCRIBE parameter: %s",
+ token);
+ goto fail;
+ }
+
+ subscribe_id = hostapd_nan_usd_subscribe(hapd, service_name,
+ srv_proto_type, ssi,
+ ¶ms);
+ if (subscribe_id > 0)
+ ret = os_snprintf(buf, buflen, "%d", subscribe_id);
+fail:
+ wpabuf_free(ssi);
+ return ret;
+}
+
+
+static int hostapd_ctrl_nan_cancel_subscribe(struct hostapd_data *hapd,
+ char *cmd)
+{
+ char *token, *context = NULL;
+ int subscribe_id = 0;
+
+ while ((token = str_token(cmd, " ", &context))) {
+ if (sscanf(token, "subscribe_id=%i", &subscribe_id) == 1)
+ continue;
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid NAN_CANCEL_SUBSCRIBE parameter: %s",
+ token);
+ return -1;
+ }
+
+ if (subscribe_id <= 0) {
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid or missing NAN_CANCEL_SUBSCRIBE subscribe_id");
+ return -1;
+ }
+
+ hostapd_nan_usd_cancel_subscribe(hapd, subscribe_id);
+ return 0;
+}
+
+
+static int hostapd_ctrl_nan_transmit(struct hostapd_data *hapd, char *cmd)
+{
+ char *token, *context = NULL;
+ int handle = 0;
+ int req_instance_id = 0;
+ struct wpabuf *ssi = NULL;
+ u8 peer_addr[ETH_ALEN];
+ int ret = -1;
+
+ os_memset(peer_addr, 0, ETH_ALEN);
+
+ while ((token = str_token(cmd, " ", &context))) {
+ if (sscanf(token, "handle=%i", &handle) == 1)
+ continue;
+
+ if (sscanf(token, "req_instance_id=%i", &req_instance_id) == 1)
+ continue;
+
+ if (os_strncmp(token, "address=", 8) == 0) {
+ if (hwaddr_aton(token + 8, peer_addr) < 0)
+ return -1;
+ continue;
+ }
+
+ if (os_strncmp(token, "ssi=", 4) == 0) {
+ if (ssi)
+ goto fail;
+ ssi = wpabuf_parse_bin(token + 4);
+ if (!ssi)
+ goto fail;
+ continue;
+ }
+
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid NAN_TRANSMIT parameter: %s",
+ token);
+ goto fail;
+ }
+
+ if (handle <= 0) {
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid or missing NAN_TRANSMIT handle");
+ goto fail;
+ }
+
+ if (is_zero_ether_addr(peer_addr)) {
+ wpa_printf(MSG_INFO,
+ "CTRL: Invalid or missing NAN_TRANSMIT address");
+ goto fail;
+ }
+
+ ret = hostapd_nan_usd_transmit(hapd, handle, ssi, NULL, peer_addr,
+ req_instance_id);
+fail:
+ wpabuf_free(ssi);
+ return ret;
+}
+
+#endif /* CONFIG_NAN_USD */
+
+
static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
char *buf, char *reply,
int reply_size,
@@ -3633,19 +4056,30 @@
} else if (os_strncmp(buf, "GET ", 4) == 0) {
reply_len = hostapd_ctrl_iface_get(hapd, buf + 4, reply,
reply_size);
- } else if (os_strncmp(buf, "ENABLE", 6) == 0) {
+ } else if (os_strcmp(buf, "ENABLE") == 0) {
if (hostapd_ctrl_iface_enable(hapd->iface))
reply_len = -1;
} else if (os_strcmp(buf, "RELOAD_WPA_PSK") == 0) {
if (hostapd_ctrl_iface_reload_wpa_psk(hapd))
reply_len = -1;
+#ifdef CONFIG_IEEE80211R_AP
+ } else if (os_strcmp(buf, "GET_RXKHS") == 0) {
+ reply_len = hostapd_ctrl_iface_get_rxkhs(hapd, reply,
+ reply_size);
+ } else if (os_strcmp(buf, "RELOAD_RXKHS") == 0) {
+ if (hostapd_ctrl_iface_reload_rxkhs(hapd))
+ reply_len = -1;
+#endif /* CONFIG_IEEE80211R_AP */
} else if (os_strcmp(buf, "RELOAD_BSS") == 0) {
if (hostapd_ctrl_iface_reload_bss(hapd))
reply_len = -1;
- } else if (os_strncmp(buf, "RELOAD", 6) == 0) {
+ } else if (os_strcmp(buf, "RELOAD_CONFIG") == 0) {
+ if (hostapd_reload_config(hapd->iface))
+ reply_len = -1;
+ } else if (os_strcmp(buf, "RELOAD") == 0) {
if (hostapd_ctrl_iface_reload(hapd->iface))
reply_len = -1;
- } else if (os_strncmp(buf, "DISABLE", 7) == 0) {
+ } else if (os_strcmp(buf, "DISABLE") == 0) {
if (hostapd_ctrl_iface_disable(hapd->iface))
reply_len = -1;
} else if (os_strcmp(buf, "UPDATE_BEACON") == 0) {
@@ -3681,16 +4115,15 @@
if (hostapd_ctrl_iface_data_test_frame(hapd, buf + 16) < 0)
reply_len = -1;
} else if (os_strncmp(buf, "TEST_ALLOC_FAIL ", 16) == 0) {
- if (hostapd_ctrl_test_alloc_fail(hapd, buf + 16) < 0)
+ if (testing_set_fail_pattern(true, buf + 16) < 0)
reply_len = -1;
} else if (os_strcmp(buf, "GET_ALLOC_FAIL") == 0) {
- reply_len = hostapd_ctrl_get_alloc_fail(hapd, reply,
- reply_size);
+ reply_len = testing_get_fail_pattern(true, reply, reply_size);
} else if (os_strncmp(buf, "TEST_FAIL ", 10) == 0) {
- if (hostapd_ctrl_test_fail(hapd, buf + 10) < 0)
+ if (testing_set_fail_pattern(false, buf + 10) < 0)
reply_len = -1;
} else if (os_strcmp(buf, "GET_FAIL") == 0) {
- reply_len = hostapd_ctrl_get_fail(hapd, reply, reply_size);
+ reply_len = testing_get_fail_pattern(false, reply, reply_size);
} else if (os_strncmp(buf, "RESET_PN ", 9) == 0) {
if (hostapd_ctrl_reset_pn(hapd, buf + 9) < 0)
reply_len = -1;
@@ -3983,6 +4416,26 @@
reply_len = -1;
#endif /* CONFIG_DPP3 */
#endif /* CONFIG_DPP */
+#ifdef CONFIG_NAN_USD
+ } else if (os_strncmp(buf, "NAN_PUBLISH ", 12) == 0) {
+ reply_len = hostapd_ctrl_nan_publish(hapd, buf + 12, reply,
+ reply_size);
+ } else if (os_strncmp(buf, "NAN_CANCEL_PUBLISH ", 19) == 0) {
+ if (hostapd_ctrl_nan_cancel_publish(hapd, buf + 19) < 0)
+ reply_len = -1;
+ } else if (os_strncmp(buf, "NAN_UPDATE_PUBLISH ", 19) == 0) {
+ if (hostapd_ctrl_nan_update_publish(hapd, buf + 19) < 0)
+ reply_len = -1;
+ } else if (os_strncmp(buf, "NAN_SUBSCRIBE ", 14) == 0) {
+ reply_len = hostapd_ctrl_nan_subscribe(hapd, buf + 14, reply,
+ reply_size);
+ } else if (os_strncmp(buf, "NAN_CANCEL_SUBSCRIBE ", 21) == 0) {
+ if (hostapd_ctrl_nan_cancel_subscribe(hapd, buf + 21) < 0)
+ reply_len = -1;
+ } else if (os_strncmp(buf, "NAN_TRANSMIT ", 13) == 0) {
+ if (hostapd_ctrl_nan_transmit(hapd, buf + 13) < 0)
+ reply_len = -1;
+#endif /* CONFIG_NAN_USD */
#ifdef RADIUS_SERVER
} else if (os_strncmp(buf, "DAC_REQUEST ", 12) == 0) {
if (radius_server_dac_request(hapd->radius_srv, buf + 12) < 0)
@@ -4000,6 +4453,20 @@
reply_len = hostapd_ctrl_iface_driver_cmd(hapd, buf + 7, reply,
reply_size);
#endif /* ANDROID */
+#ifdef CONFIG_IEEE80211BE
+ } else if (os_strcmp(buf, "ENABLE_MLD") == 0) {
+ if (hostapd_ctrl_iface_enable_mld(hapd->iface))
+ reply_len = -1;
+ } else if (os_strcmp(buf, "DISABLE_MLD") == 0) {
+ if (hostapd_ctrl_iface_disable_mld(hapd->iface))
+ reply_len = -1;
+#ifdef CONFIG_TESTING_OPTIONS
+ } else if (os_strncmp(buf, "LINK_REMOVE ", 12) == 0) {
+ if (hostapd_ctrl_iface_link_remove(hapd, buf + 12,
+ reply, reply_size))
+ reply_len = -1;
+#endif /* CONFIG_TESTING_OPTIONS */
+#endif /* CONFIG_IEEE80211BE */
} else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
reply_len = 16;
@@ -4491,6 +4958,7 @@
#ifdef CONFIG_DPP
dpp_global_clear(interfaces->dpp);
#ifdef CONFIG_DPP3
+ interfaces->dpp_pb_bi = NULL;
{
int i;
diff --git a/hostapd/defconfig b/hostapd/defconfig
index 0a5ceee..5d769e9 100644
--- a/hostapd/defconfig
+++ b/hostapd/defconfig
@@ -424,3 +424,6 @@
# DPP version 3 support (experimental and still changing; do not enable for
# production use)
#CONFIG_DPP3=y
+
+# Wi-Fi Aware unsynchronized service discovery (NAN USD)
+#CONFIG_NAN_USD=y
diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
index f02cd92..1357649 100644
--- a/hostapd/hostapd.conf
+++ b/hostapd/hostapd.conf
@@ -980,10 +980,22 @@
# 6 GHz Access Point type
# This config is to set the 6 GHz Access Point type. Possible options are:
-# 0 = Indoor AP (default)
-# 1 = Standard Power AP
+# 0 = Indoor AP
+# 1 = Standard power AP
+# 2 = Very low power AP (default)
+# 3 = Indoor enabled AP
+# 4 = Indoor standard power AP
# This has no impact for operation on other bands.
+# See IEEE P802.11-REVme/D4.0, Table E-12 (Regulatory Info subfield encoding)
+# for more details.
#he_6ghz_reg_pwr_type=0
+#
+# 6 GHz Maximum Tx Power used in Transmit Power Envelope elements, where the
+# "Transmit Power Interpretation" is set to "Regulatory client EIRP PSD".
+# For Maximum Transmit Power Category subfield encoding set to default (0):
+#reg_def_cli_eirp_psd=-1
+# For Maximum Transmit Power Category subfield encoding set to subordinate (1):
+#reg_sub_cli_eirp_psd=-1
# Unsolicited broadcast Probe Response transmission settings
# This is for the 6 GHz band only. If the interval is set to a non-zero value,
@@ -1027,6 +1039,20 @@
#eht_oper_chwidth (see vht_oper_chwidth)
#eht_oper_centr_freq_seg0_idx
+#eht_default_pe_duration: The duration of PE field in EHT TB PPDU
+# 0 = PE field duration is the same as he_default_pe_duration (default)
+# 1 = PE field duration is 20 us
+#eht_default_pe_duration=0
+
+#eht_bw320_offset: For automatic channel selection (ACS) to indicate a preferred
+# 320 MHz channelization in EHT mode.
+# If the channel is decided or the bandwidth is not 320 MHz, this option is
+# meaningless.
+# 0 = auto-detect by hostapd
+# 1 = 320 MHz-1 (channel center frequency 31, 95, 159)
+# 2 = 320 MHz-2 (channel center frequency 63, 127, 191)
+#eht_bw320_offset=0
+
# Disabled subchannel bitmap (16 bits) as per IEEE P802.11be/3.0,
# Figure 9-1002c (EHT Operation Information field format). Each bit corresponds
# to a 20 MHz channel, the lowest bit corresponds to the lowest frequency. A
@@ -1775,6 +1801,10 @@
# Tunnel-Password
# 3 = ask RADIUS server during 4-way handshake if there is no locally
# configured PSK/passphrase for the STA
+#
+# The Tunnel-Password attribute in Access-Accept can contain either the
+# 8..63 character ASCII passphrase or a 64 hex character encoding of the PSK.
+#
#wpa_psk_radius=0
# Set of accepted key management algorithms (WPA-PSK, WPA-EAP, or both). The
@@ -2032,6 +2062,10 @@
#sae_password=really secret|mac=ff:ff:ff:ff:ff:ff
#sae_password=example secret|mac=02:03:04:05:06:07|id=pw identifier
#sae_password=example secret|vlanid=3|id=pw identifier
+#
+# SAE passwords can also be read from a separate file in which each line
+# contains and entry in the same format as sae_password uses.
+#sae_password_file=/tc/hostapd.sae_passwords
# SAE threshold for anti-clogging mechanism (dot11RSNASAEAntiCloggingThreshold)
# This parameter defines how many open SAE instances can be in progress at the
@@ -2261,6 +2295,12 @@
# list and thus will receive push notifications.
#r1kh=00:00:00:00:00:00 00:00:00:00:00:00 00112233445566778899aabbccddeeff
+# Optionally, the list of RxKHs can be read from a text file. Format is the same
+# as specified above. File shall contain both r0kh and r1kh. Once this variable
+# is set, RxKHs can be reloaded at runtime without bringing down an interface
+# using the RELOAD_RXKHS command.
+#rxkh_file=<path>
+
# Timeout (seconds) for newly discovered R0KH/R1KH (see wildcard entries above)
# Special values: 0 -> do not expire
# Warning: do not cache implies no sequence number validation with wildcards
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 45497cd..8fb6119 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -1235,6 +1235,13 @@
}
+static int hostapd_cli_cmd_reload_config(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ return wpa_ctrl_command(ctrl, "RELOAD_CONFIG");
+}
+
+
static int hostapd_cli_cmd_disable(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
@@ -1242,6 +1249,20 @@
}
+static int hostapd_cli_cmd_enable_mld(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ return wpa_ctrl_command(ctrl, "ENABLE_MLD");
+}
+
+
+static int hostapd_cli_cmd_disable_mld(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ return wpa_ctrl_command(ctrl, "DISABLE_MLD");
+}
+
+
static int hostapd_cli_cmd_update_beacon(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
@@ -1584,6 +1605,24 @@
}
+#ifdef CONFIG_IEEE80211R_AP
+
+static int hostapd_cli_cmd_get_rxkhs(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ return wpa_ctrl_command(ctrl, "GET_RXKHS");
+}
+
+
+static int hostapd_cli_cmd_reload_rxkhs(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ return wpa_ctrl_command(ctrl, "RELOAD_RXKHS");
+}
+
+#endif /* CONFIG_IEEE80211R_AP */
+
+
#ifdef ANDROID
static int hostapd_cli_cmd_driver(struct wpa_ctrl *ctrl, int argc, char *argv[])
{
@@ -1710,8 +1749,14 @@
"= reload configuration for current interface" },
{ "reload_bss", hostapd_cli_cmd_reload_bss, NULL,
"= reload configuration for current BSS" },
+ { "reload_config", hostapd_cli_cmd_reload_config, NULL,
+ "= reload configuration for current interface" },
{ "disable", hostapd_cli_cmd_disable, NULL,
"= disable hostapd on current interface" },
+ { "enable_mld", hostapd_cli_cmd_enable_mld, NULL,
+ "= enable AP MLD to which the interface is affiliated" },
+ { "disable_mld", hostapd_cli_cmd_disable_mld, NULL,
+ "= disable AP MLD to which the interface is affiliated" },
{ "update_beacon", hostapd_cli_cmd_update_beacon, NULL,
"= update Beacon frame contents\n"},
{ "erp_flush", hostapd_cli_cmd_erp_flush, NULL,
@@ -1795,6 +1840,12 @@
"<addr> [req_mode=] <measurement request hexdump> = send a Beacon report request to a station" },
{ "reload_wpa_psk", hostapd_cli_cmd_reload_wpa_psk, NULL,
"= reload wpa_psk_file only" },
+#ifdef CONFIG_IEEE80211R_AP
+ { "reload_rxkhs", hostapd_cli_cmd_reload_rxkhs, NULL,
+ "= reload R0KHs and R1KHs" },
+ { "get_rxkhs", hostapd_cli_cmd_get_rxkhs, NULL,
+ "= get R0KHs and R1KHs" },
+#endif /* CONFIG_IEEE80211R_AP */
#ifdef ANDROID
{ "driver", hostapd_cli_cmd_driver, NULL,
"<driver sub command> [<hex formatted data>] = send driver command data" },
diff --git a/hostapd/main.c b/hostapd/main.c
index 615dc2f..0fe2d74 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -249,8 +249,12 @@
* Use the configured MLD MAC address as the interface hardware address
* if this AP is a part of an AP MLD.
*/
- if (!is_zero_ether_addr(hapd->conf->mld_addr) && hapd->conf->mld_ap)
- params.bssid = hapd->conf->mld_addr;
+ if (hapd->conf->mld_ap) {
+ if (!is_zero_ether_addr(hapd->conf->mld_addr))
+ params.bssid = hapd->conf->mld_addr;
+ else
+ params.bssid = NULL;
+ }
#endif /* CONFIG_IEEE80211BE */
params.ifname = hapd->conf->iface;
@@ -340,6 +344,9 @@
return -1;
}
+ /* Initialize the BSS parameter change to 1 */
+ hapd->eht_mld_bss_param_change = 1;
+
wpa_printf(MSG_DEBUG,
"MLD: Set link_id=%u, mld_addr=" MACSTR
", own_addr=" MACSTR,