blob: 0194dccd19b1f3b413e8ce5a42d996ac8d1b6b1f [file] [log] [blame]
From 66531c560a9d292b18cc2d3574427fbb0a32f8f4 Mon Sep 17 00:00:00 2001
From: MeiChia Chiu <meichia.chiu@mediatek.com>
Date: Tue, 31 May 2022 21:15:54 +0800
Subject: [PATCH 03/25] hostapd: mtk: add support for runtime set in-band
discovery
Usage:
hostapd_cli unsolic_probe_resp [tx_type] [interval]
0: disable all in-band discovery
1: enable unsolicited probe response
2: enable FILS discovery
Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com>
---
hostapd/ctrl_iface.c | 66 ++++++++++++++++++++++++++++++++++++
hostapd/hostapd_cli.c | 20 +++++++++++
src/ap/beacon.c | 5 ++-
src/drivers/driver_nl80211.c | 10 ++++--
src/drivers/nl80211_copy.h | 1 +
5 files changed, 98 insertions(+), 4 deletions(-)
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index bc690c5..bb8c74f 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -826,6 +826,69 @@ static int hostapd_ctrl_iface_send_qos_map_conf(struct hostapd_data *hapd,
#endif /* CONFIG_INTERWORKING */
+static int hostapd_ctrl_iface_inband_discovery(struct hostapd_data *hapd,
+ const char *cmd)
+{
+ struct hostapd_bss_config *conf = hapd->conf;
+ const char *pos = cmd;
+ int tx_type, interval, ret;
+
+ tx_type = atoi(pos);
+ if (tx_type < 0 || tx_type > 2) {
+ wpa_printf(MSG_ERROR, "Invalid tx type\n");
+ return -1;
+ }
+
+ pos = os_strchr(pos, ' ');
+ if(!pos)
+ return -1;
+ pos++;
+ interval = atoi(pos);
+ if (interval < 0 || interval > 20) {
+ wpa_printf(MSG_ERROR, "Invalid interval value\n");
+ return -1;
+ }
+
+ wpa_printf(MSG_ERROR, "Set inband discovery type:%d, interval:%d\n",
+ tx_type, interval);
+
+#define DISABLE_INBAND_DISC 0
+#define UNSOL_PROBE_RESP 1
+#define FILS_DISCOVERY 2
+
+#ifdef CONFIG_FILS
+ conf->fils_discovery_max_int = 0;
+ conf->fils_discovery_min_int = 0;
+#endif /* CONFIG_FILS */
+ conf->unsol_bcast_probe_resp_interval = 0;
+
+ switch (tx_type) {
+ case DISABLE_INBAND_DISC:
+ default:
+ /* Disable both Unsolicited probe response and FILS discovery*/
+ break;
+ case UNSOL_PROBE_RESP:
+ /* Enable Unsolicited probe response */
+ conf->unsol_bcast_probe_resp_interval = interval;
+ break;
+#ifdef CONFIG_FILS
+ case FILS_DISCOVERY:
+ /* Enable FILS discovery */
+ conf->fils_discovery_min_int = interval;
+ conf->fils_discovery_max_int = interval;
+ break;
+#endif /* CONFIG_FILS */
+ }
+
+ ret = ieee802_11_update_beacons(hapd->iface);
+ if(ret) {
+ wpa_printf(MSG_DEBUG,
+ "Failed to update with inband discovery parameters\n");
+ return -1;
+ }
+
+ return 0;
+}
#ifdef CONFIG_WNM_AP
@@ -3434,6 +3497,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
if (hostapd_ctrl_iface_coloc_intf_req(hapd, buf + 15))
reply_len = -1;
#endif /* CONFIG_WNM_AP */
+ } else if (os_strncmp(buf, "INBAND_DISCOVERY ", 17) == 0) {
+ if (hostapd_ctrl_iface_inband_discovery(hapd, buf + 17))
+ reply_len = -1;
} else if (os_strcmp(buf, "GET_CONFIG") == 0) {
reply_len = hostapd_ctrl_iface_get_config(hapd, reply,
reply_size);
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 85c41d0..db21258 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -642,6 +642,24 @@ static int hostapd_cli_cmd_wps_config(struct wpa_ctrl *ctrl, int argc,
return wpa_ctrl_command(ctrl, buf);
}
+static int hostapd_cli_cmd_inband_discovery(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ char buf[300];
+ int res;
+
+ if (argc < 2) {
+ printf("Invalid 'inband_discovery' command - two arguments"
+ "tx_type interval\n");
+ return -1;
+ }
+
+ res = os_snprintf(buf, sizeof(buf), "INBAND_DISCOVERY %s %s",
+ argv[0], argv[1]);
+ if (os_snprintf_error(sizeof(buf), res))
+ return -1;
+ return wpa_ctrl_command(ctrl, buf);
+}
static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc,
char *argv[])
@@ -1749,6 +1767,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
{ "driver", hostapd_cli_cmd_driver, NULL,
"<driver sub command> [<hex formatted data>] = send driver command data" },
#endif /* ANDROID */
+ { "inband_discovery", hostapd_cli_cmd_inband_discovery, NULL,
+ "<tx type(0/1/2)> <interval> = runtime set inband discovery" },
{ NULL, NULL, NULL, NULL }
};
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 814e86e..1a26f11 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -1497,6 +1497,8 @@ static u8 * hostapd_fils_discovery(struct hostapd_data *hapd,
struct wpa_driver_ap_params *params)
{
params->fd_max_int = hapd->conf->fils_discovery_max_int;
+ params->unsol_bcast_probe_resp_interval =
+ hapd->conf->unsol_bcast_probe_resp_interval;
if (is_6ghz_op_class(hapd->iconf->op_class) &&
params->fd_max_int > FD_MAX_INTERVAL_6GHZ)
params->fd_max_int = FD_MAX_INTERVAL_6GHZ;
@@ -1505,7 +1507,8 @@ static u8 * hostapd_fils_discovery(struct hostapd_data *hapd,
if (params->fd_min_int > params->fd_max_int)
params->fd_min_int = params->fd_max_int;
- if (params->fd_max_int)
+ if (params->fd_max_int || (is_6ghz_op_class(hapd->iconf->op_class) &&
+ !params->unsol_bcast_probe_resp_interval))
return hostapd_gen_fils_discovery(hapd,
&params->fd_frame_tmpl_len);
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 1fa7dd8..c695263 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4498,9 +4498,10 @@ static int nl80211_fils_discovery(struct i802_bss *bss, struct nl_msg *msg,
params->fd_max_int) ||
(params->fd_frame_tmpl &&
nla_put(msg, NL80211_FILS_DISCOVERY_ATTR_TMPL,
- params->fd_frame_tmpl_len, params->fd_frame_tmpl)))
+ params->fd_frame_tmpl_len, params->fd_frame_tmpl)) ||
+ nla_put_u32(msg, NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE,
+ params->unsol_bcast_probe_resp_interval))
return -1;
-
nla_nest_end(msg, attr);
return 0;
}
@@ -4844,7 +4845,10 @@ static int wpa_driver_nl80211_set_ap(void *priv,
#endif /* CONFIG_SAE */
#ifdef CONFIG_FILS
- if (params->fd_max_int && nl80211_fils_discovery(bss, msg, params) < 0)
+ if ((params->fd_max_int ||
+ ((params->freq->freq > 5950 && params->freq->freq <= 7115) &&
+ !(params->unsol_bcast_probe_resp_interval))) &&
+ nl80211_fils_discovery(bss, msg, params) < 0)
goto fail;
#endif /* CONFIG_FILS */
diff --git a/src/drivers/nl80211_copy.h b/src/drivers/nl80211_copy.h
index 0568a79..c4bf3ad 100644
--- a/src/drivers/nl80211_copy.h
+++ b/src/drivers/nl80211_copy.h
@@ -7379,6 +7379,7 @@ enum nl80211_fils_discovery_attributes {
NL80211_FILS_DISCOVERY_ATTR_INT_MIN,
NL80211_FILS_DISCOVERY_ATTR_INT_MAX,
NL80211_FILS_DISCOVERY_ATTR_TMPL,
+ NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE,
/* keep last */
__NL80211_FILS_DISCOVERY_ATTR_LAST,
--
2.18.0