developer | 2fd555a | 2023-07-25 05:48:15 +0800 | [diff] [blame] | 1 | From 33afb892c534b88aea9206740c53a3da0966861f Mon Sep 17 00:00:00 2001 |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 2 | From: MeiChia Chiu <meichia.chiu@mediatek.com> |
developer | 9fe3113 | 2022-05-31 21:21:20 +0800 | [diff] [blame] | 3 | Date: Tue, 31 May 2022 21:15:54 +0800 |
developer | 2fd555a | 2023-07-25 05:48:15 +0800 | [diff] [blame] | 4 | Subject: [PATCH 03/35] hostapd: mtk: add support for runtime set in-band |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 5 | discovery |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 6 | |
| 7 | Usage: |
| 8 | hostapd_cli unsolic_probe_resp [tx_type] [interval] |
| 9 | |
| 10 | 0: disable all in-band discovery |
| 11 | 1: enable unsolicited probe response |
| 12 | 2: enable FILS discovery |
| 13 | |
| 14 | Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com> |
| 15 | --- |
developer | 9fe3113 | 2022-05-31 21:21:20 +0800 | [diff] [blame] | 16 | hostapd/ctrl_iface.c | 66 ++++++++++++++++++++++++++++++++++++ |
| 17 | hostapd/hostapd_cli.c | 20 +++++++++++ |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 18 | src/ap/beacon.c | 5 ++- |
developer | 34178a8 | 2022-06-23 17:44:15 +0800 | [diff] [blame] | 19 | src/drivers/driver_nl80211.c | 10 ++++-- |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 20 | src/drivers/nl80211_copy.h | 1 + |
developer | 34178a8 | 2022-06-23 17:44:15 +0800 | [diff] [blame] | 21 | 5 files changed, 98 insertions(+), 4 deletions(-) |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 22 | |
| 23 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | 81939a5 | 2023-03-25 15:31:11 +0800 | [diff] [blame] | 24 | index bc690c5..bb8c74f 100644 |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 25 | --- a/hostapd/ctrl_iface.c |
| 26 | +++ b/hostapd/ctrl_iface.c |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 27 | @@ -826,6 +826,69 @@ static int hostapd_ctrl_iface_send_qos_map_conf(struct hostapd_data *hapd, |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 28 | |
| 29 | #endif /* CONFIG_INTERWORKING */ |
| 30 | |
| 31 | +static int hostapd_ctrl_iface_inband_discovery(struct hostapd_data *hapd, |
| 32 | + const char *cmd) |
| 33 | +{ |
| 34 | + struct hostapd_bss_config *conf = hapd->conf; |
| 35 | + const char *pos = cmd; |
| 36 | + int tx_type, interval, ret; |
| 37 | + |
| 38 | + tx_type = atoi(pos); |
| 39 | + if (tx_type < 0 || tx_type > 2) { |
| 40 | + wpa_printf(MSG_ERROR, "Invalid tx type\n"); |
| 41 | + return -1; |
| 42 | + } |
| 43 | + |
| 44 | + pos = os_strchr(pos, ' '); |
| 45 | + if(!pos) |
| 46 | + return -1; |
| 47 | + pos++; |
| 48 | + interval = atoi(pos); |
| 49 | + if (interval < 0 || interval > 20) { |
| 50 | + wpa_printf(MSG_ERROR, "Invalid interval value\n"); |
| 51 | + return -1; |
| 52 | + } |
| 53 | + |
| 54 | + wpa_printf(MSG_ERROR, "Set inband discovery type:%d, interval:%d\n", |
| 55 | + tx_type, interval); |
| 56 | + |
| 57 | +#define DISABLE_INBAND_DISC 0 |
| 58 | +#define UNSOL_PROBE_RESP 1 |
| 59 | +#define FILS_DISCOVERY 2 |
| 60 | + |
developer | 9fe3113 | 2022-05-31 21:21:20 +0800 | [diff] [blame] | 61 | +#ifdef CONFIG_FILS |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 62 | + conf->fils_discovery_max_int = 0; |
| 63 | + conf->fils_discovery_min_int = 0; |
developer | 9fe3113 | 2022-05-31 21:21:20 +0800 | [diff] [blame] | 64 | +#endif /* CONFIG_FILS */ |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 65 | + conf->unsol_bcast_probe_resp_interval = 0; |
| 66 | + |
| 67 | + switch (tx_type) { |
| 68 | + case DISABLE_INBAND_DISC: |
| 69 | + default: |
| 70 | + /* Disable both Unsolicited probe response and FILS discovery*/ |
| 71 | + break; |
| 72 | + case UNSOL_PROBE_RESP: |
| 73 | + /* Enable Unsolicited probe response */ |
| 74 | + conf->unsol_bcast_probe_resp_interval = interval; |
| 75 | + break; |
developer | 9fe3113 | 2022-05-31 21:21:20 +0800 | [diff] [blame] | 76 | +#ifdef CONFIG_FILS |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 77 | + case FILS_DISCOVERY: |
| 78 | + /* Enable FILS discovery */ |
| 79 | + conf->fils_discovery_min_int = interval; |
| 80 | + conf->fils_discovery_max_int = interval; |
| 81 | + break; |
developer | 9fe3113 | 2022-05-31 21:21:20 +0800 | [diff] [blame] | 82 | +#endif /* CONFIG_FILS */ |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 83 | + } |
| 84 | + |
| 85 | + ret = ieee802_11_update_beacons(hapd->iface); |
| 86 | + if(ret) { |
| 87 | + wpa_printf(MSG_DEBUG, |
| 88 | + "Failed to update with inband discovery parameters\n"); |
| 89 | + return -1; |
| 90 | + } |
| 91 | + |
| 92 | + return 0; |
| 93 | +} |
| 94 | |
| 95 | #ifdef CONFIG_WNM_AP |
| 96 | |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 97 | @@ -3434,6 +3497,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 98 | if (hostapd_ctrl_iface_coloc_intf_req(hapd, buf + 15)) |
| 99 | reply_len = -1; |
| 100 | #endif /* CONFIG_WNM_AP */ |
| 101 | + } else if (os_strncmp(buf, "INBAND_DISCOVERY ", 17) == 0) { |
| 102 | + if (hostapd_ctrl_iface_inband_discovery(hapd, buf + 17)) |
| 103 | + reply_len = -1; |
| 104 | } else if (os_strcmp(buf, "GET_CONFIG") == 0) { |
| 105 | reply_len = hostapd_ctrl_iface_get_config(hapd, reply, |
| 106 | reply_size); |
| 107 | diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c |
developer | 81939a5 | 2023-03-25 15:31:11 +0800 | [diff] [blame] | 108 | index 85c41d0..db21258 100644 |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 109 | --- a/hostapd/hostapd_cli.c |
| 110 | +++ b/hostapd/hostapd_cli.c |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 111 | @@ -642,6 +642,24 @@ static int hostapd_cli_cmd_wps_config(struct wpa_ctrl *ctrl, int argc, |
| 112 | return wpa_ctrl_command(ctrl, buf); |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 113 | } |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 114 | |
| 115 | +static int hostapd_cli_cmd_inband_discovery(struct wpa_ctrl *ctrl, int argc, |
| 116 | + char *argv[]) |
| 117 | +{ |
| 118 | + char buf[300]; |
| 119 | + int res; |
| 120 | + |
| 121 | + if (argc < 2) { |
| 122 | + printf("Invalid 'inband_discovery' command - two arguments" |
| 123 | + "tx_type interval\n"); |
| 124 | + return -1; |
| 125 | + } |
| 126 | + |
| 127 | + res = os_snprintf(buf, sizeof(buf), "INBAND_DISCOVERY %s %s", |
| 128 | + argv[0], argv[1]); |
| 129 | + if (os_snprintf_error(sizeof(buf), res)) |
| 130 | + return -1; |
| 131 | + return wpa_ctrl_command(ctrl, buf); |
| 132 | +} |
| 133 | |
| 134 | static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc, |
| 135 | char *argv[]) |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 136 | @@ -1749,6 +1767,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = { |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 137 | { "driver", hostapd_cli_cmd_driver, NULL, |
| 138 | "<driver sub command> [<hex formatted data>] = send driver command data" }, |
| 139 | #endif /* ANDROID */ |
| 140 | + { "inband_discovery", hostapd_cli_cmd_inband_discovery, NULL, |
| 141 | + "<tx type(0/1/2)> <interval> = runtime set inband discovery" }, |
| 142 | { NULL, NULL, NULL, NULL } |
| 143 | }; |
| 144 | |
| 145 | diff --git a/src/ap/beacon.c b/src/ap/beacon.c |
developer | 81939a5 | 2023-03-25 15:31:11 +0800 | [diff] [blame] | 146 | index 814e86e..1a26f11 100644 |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 147 | --- a/src/ap/beacon.c |
| 148 | +++ b/src/ap/beacon.c |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 149 | @@ -1497,6 +1497,8 @@ static u8 * hostapd_fils_discovery(struct hostapd_data *hapd, |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 150 | struct wpa_driver_ap_params *params) |
| 151 | { |
| 152 | params->fd_max_int = hapd->conf->fils_discovery_max_int; |
| 153 | + params->unsol_bcast_probe_resp_interval = |
| 154 | + hapd->conf->unsol_bcast_probe_resp_interval; |
| 155 | if (is_6ghz_op_class(hapd->iconf->op_class) && |
| 156 | params->fd_max_int > FD_MAX_INTERVAL_6GHZ) |
| 157 | params->fd_max_int = FD_MAX_INTERVAL_6GHZ; |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 158 | @@ -1505,7 +1507,8 @@ static u8 * hostapd_fils_discovery(struct hostapd_data *hapd, |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 159 | if (params->fd_min_int > params->fd_max_int) |
| 160 | params->fd_min_int = params->fd_max_int; |
| 161 | |
| 162 | - if (params->fd_max_int) |
developer | 34178a8 | 2022-06-23 17:44:15 +0800 | [diff] [blame] | 163 | + if (params->fd_max_int || (is_6ghz_op_class(hapd->iconf->op_class) && |
| 164 | + !params->unsol_bcast_probe_resp_interval)) |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 165 | return hostapd_gen_fils_discovery(hapd, |
| 166 | ¶ms->fd_frame_tmpl_len); |
| 167 | |
| 168 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
developer | 81939a5 | 2023-03-25 15:31:11 +0800 | [diff] [blame] | 169 | index 1fa7dd8..c695263 100644 |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 170 | --- a/src/drivers/driver_nl80211.c |
| 171 | +++ b/src/drivers/driver_nl80211.c |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 172 | @@ -4498,9 +4498,10 @@ static int nl80211_fils_discovery(struct i802_bss *bss, struct nl_msg *msg, |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 173 | params->fd_max_int) || |
| 174 | (params->fd_frame_tmpl && |
| 175 | nla_put(msg, NL80211_FILS_DISCOVERY_ATTR_TMPL, |
| 176 | - params->fd_frame_tmpl_len, params->fd_frame_tmpl))) |
| 177 | + params->fd_frame_tmpl_len, params->fd_frame_tmpl)) || |
| 178 | + nla_put_u32(msg, NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE, |
| 179 | + params->unsol_bcast_probe_resp_interval)) |
| 180 | return -1; |
| 181 | - |
| 182 | nla_nest_end(msg, attr); |
| 183 | return 0; |
| 184 | } |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 185 | @@ -4844,7 +4845,10 @@ static int wpa_driver_nl80211_set_ap(void *priv, |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 186 | #endif /* CONFIG_SAE */ |
| 187 | |
| 188 | #ifdef CONFIG_FILS |
| 189 | - if (params->fd_max_int && nl80211_fils_discovery(bss, msg, params) < 0) |
developer | 34178a8 | 2022-06-23 17:44:15 +0800 | [diff] [blame] | 190 | + if ((params->fd_max_int || |
| 191 | + ((params->freq->freq > 5950 && params->freq->freq <= 7115) && |
| 192 | + !(params->unsol_bcast_probe_resp_interval))) && |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 193 | + nl80211_fils_discovery(bss, msg, params) < 0) |
| 194 | goto fail; |
| 195 | #endif /* CONFIG_FILS */ |
| 196 | |
| 197 | diff --git a/src/drivers/nl80211_copy.h b/src/drivers/nl80211_copy.h |
developer | 81939a5 | 2023-03-25 15:31:11 +0800 | [diff] [blame] | 198 | index 0568a79..c4bf3ad 100644 |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 199 | --- a/src/drivers/nl80211_copy.h |
| 200 | +++ b/src/drivers/nl80211_copy.h |
developer | 34178a8 | 2022-06-23 17:44:15 +0800 | [diff] [blame] | 201 | @@ -7379,6 +7379,7 @@ enum nl80211_fils_discovery_attributes { |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 202 | NL80211_FILS_DISCOVERY_ATTR_INT_MIN, |
| 203 | NL80211_FILS_DISCOVERY_ATTR_INT_MAX, |
| 204 | NL80211_FILS_DISCOVERY_ATTR_TMPL, |
| 205 | + NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE, |
| 206 | |
| 207 | /* keep last */ |
| 208 | __NL80211_FILS_DISCOVERY_ATTR_LAST, |
| 209 | -- |
developer | 81939a5 | 2023-03-25 15:31:11 +0800 | [diff] [blame] | 210 | 2.18.0 |
developer | 2c9b8e9 | 2022-05-13 17:50:31 +0800 | [diff] [blame] | 211 | |