developer | 150de74 | 2021-12-09 14:51:42 +0800 | [diff] [blame] | 1 | From 44c75ac86f456f7c10367a11303426903fa27e58 Mon Sep 17 00:00:00 2001 |
| 2 | From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 3 | Date: Thu, 9 Dec 2021 14:45:19 +0800 |
| 4 | Subject: [PATCH] Add hostapd patches for WiFi certification MBO test plan |
| 5 | |
| 6 | --- |
| 7 | ...hbor_count-and-hostapd_neighbor_inse.patch | 77 +++++++++++++++ |
| 8 | ...g-neighbor-report-elements-in-ANQP-r.patch | 94 +++++++++++++++++++ |
| 9 | ...g-neignbor-report-elements-in-BTM-re.patch | 68 ++++++++++++++ |
| 10 | ...onfigure-BSS-Termination-TSF-by-usin.patch | 66 +++++++++++++ |
| 11 | ...erface-if-BSS-Termination-TSF-is-set.patch | 47 ++++++++++ |
| 12 | ...assoc_frame_timer-to-send-disassocia.patch | 63 +++++++++++++ |
| 13 | ...g-neighbor-report-elements-in-BTM-re.patch | 31 ++++++ |
| 14 | ...hostapd_neighbor_set_own_report_pref.patch | 89 ++++++++++++++++++ |
| 15 | 8 files changed, 535 insertions(+) |
| 16 | create mode 100644 package/network/services/hostapd/patches/902-2102-Add-hostapd_neighbor_count-and-hostapd_neighbor_inse.patch |
| 17 | create mode 100644 package/network/services/hostapd/patches/903-2102-Support-including-neighbor-report-elements-in-ANQP-r.patch |
| 18 | create mode 100644 package/network/services/hostapd/patches/904-2102-Support-including-neignbor-report-elements-in-BTM-re.patch |
| 19 | create mode 100644 package/network/services/hostapd/patches/905-2102-Add-support-to-configure-BSS-Termination-TSF-by-usin.patch |
| 20 | create mode 100644 package/network/services/hostapd/patches/906-2102-Disable-interface-if-BSS-Termination-TSF-is-set.patch |
| 21 | create mode 100644 package/network/services/hostapd/patches/907-2102-Add-set_send_disassoc_frame_timer-to-send-disassocia.patch |
| 22 | create mode 100644 package/network/services/hostapd/patches/908-2102-Support-including-neighbor-report-elements-in-BTM-re.patch |
| 23 | create mode 100644 package/network/services/hostapd/patches/909-2102-Add-hostapd_neighbor_set_own_report_pref.patch |
| 24 | |
| 25 | diff --git a/package/network/services/hostapd/patches/902-2102-Add-hostapd_neighbor_count-and-hostapd_neighbor_inse.patch b/package/network/services/hostapd/patches/902-2102-Add-hostapd_neighbor_count-and-hostapd_neighbor_inse.patch |
| 26 | new file mode 100644 |
| 27 | index 0000000..038d71d |
| 28 | --- /dev/null |
| 29 | +++ b/package/network/services/hostapd/patches/902-2102-Add-hostapd_neighbor_count-and-hostapd_neighbor_inse.patch |
| 30 | @@ -0,0 +1,77 @@ |
| 31 | +From e42eb49238eec538262e465599bf417a1a8f228f Mon Sep 17 00:00:00 2001 |
| 32 | +From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 33 | +Date: Mon, 25 Oct 2021 10:54:35 +0800 |
| 34 | +Subject: [PATCH] Add hostapd_neighbor_count() and |
| 35 | + hostapd_neighbor_insert_buffer () |
| 36 | + |
| 37 | +The first function can count the number of neighbor report in neighbore report |
| 38 | +database. The second can iterate neighbor report database to build up neighbor |
| 39 | +report data. |
| 40 | +--- |
| 41 | + src/ap/neighbor_db.c | 37 +++++++++++++++++++++++++++++++++++++ |
| 42 | + src/ap/neighbor_db.h | 3 +++ |
| 43 | + 2 files changed, 40 insertions(+) |
| 44 | + |
| 45 | +diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c |
| 46 | +index 2bbe318..10143a0 100644 |
| 47 | +--- a/src/ap/neighbor_db.c |
| 48 | ++++ b/src/ap/neighbor_db.c |
| 49 | +@@ -88,6 +88,43 @@ int hostapd_neighbor_show(struct hostapd_data *hapd, char *buf, size_t buflen) |
| 50 | + } |
| 51 | + |
| 52 | + |
| 53 | ++int hostapd_neighbor_count(struct hostapd_data *hapd) |
| 54 | ++{ |
| 55 | ++ struct hostapd_neighbor_entry *nr; |
| 56 | ++ int count = 0; |
| 57 | ++ |
| 58 | ++ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry, |
| 59 | ++ list) { |
| 60 | ++ count++; |
| 61 | ++ } |
| 62 | ++ return count; |
| 63 | ++} |
| 64 | ++ |
| 65 | ++ |
| 66 | ++int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf, |
| 67 | ++ size_t buflen) |
| 68 | ++{ |
| 69 | ++ struct hostapd_neighbor_entry *nr; |
| 70 | ++ char *pos, *end; |
| 71 | ++ |
| 72 | ++ pos = buf; |
| 73 | ++ end = buf + buflen; |
| 74 | ++ |
| 75 | ++ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry, |
| 76 | ++ list) { |
| 77 | ++ /* For neighbor report IE, we only need bssid and nr*/ |
| 78 | ++ int ret; |
| 79 | ++ char nrie[2 * 255 + 1]; |
| 80 | ++ *pos++ = WLAN_EID_NEIGHBOR_REPORT; |
| 81 | ++ *pos++ = wpabuf_len(nr->nr); |
| 82 | ++ os_memcpy (pos, wpabuf_head(nr->nr), wpabuf_len(nr->nr)); |
| 83 | ++ pos += wpabuf_len(nr->nr); |
| 84 | ++ } |
| 85 | ++ |
| 86 | ++ return pos - buf; |
| 87 | ++} |
| 88 | ++ |
| 89 | ++ |
| 90 | + static void hostapd_neighbor_clear_entry(struct hostapd_neighbor_entry *nr) |
| 91 | + { |
| 92 | + wpabuf_free(nr->nr); |
| 93 | +diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h |
| 94 | +index bed0a2f..e93d1d5 100644 |
| 95 | +--- a/src/ap/neighbor_db.h |
| 96 | ++++ b/src/ap/neighbor_db.h |
| 97 | +@@ -23,4 +23,7 @@ int hostapd_neighbor_remove(struct hostapd_data *hapd, const u8 *bssid, |
| 98 | + const struct wpa_ssid_value *ssid); |
| 99 | + void hostapd_free_neighbor_db(struct hostapd_data *hapd); |
| 100 | + |
| 101 | ++int hostapd_neighbor_count(struct hostapd_data *hapd); |
| 102 | ++int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf, |
| 103 | ++ size_t buflen); |
| 104 | + #endif /* NEIGHBOR_DB_H */ |
| 105 | +-- |
| 106 | +2.18.0 |
| 107 | + |
| 108 | diff --git a/package/network/services/hostapd/patches/903-2102-Support-including-neighbor-report-elements-in-ANQP-r.patch b/package/network/services/hostapd/patches/903-2102-Support-including-neighbor-report-elements-in-ANQP-r.patch |
| 109 | new file mode 100644 |
| 110 | index 0000000..e3f07a5 |
| 111 | --- /dev/null |
| 112 | +++ b/package/network/services/hostapd/patches/903-2102-Support-including-neighbor-report-elements-in-ANQP-r.patch |
| 113 | @@ -0,0 +1,94 @@ |
| 114 | +From 38d9a0b2008ec6555d8b776d64040a0166633c6e Mon Sep 17 00:00:00 2001 |
| 115 | +From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 116 | +Date: Mon, 25 Oct 2021 11:03:15 +0800 |
| 117 | +Subject: [PATCH] Support including neighbor report elements in ANQP response |
| 118 | + |
| 119 | +--- |
| 120 | + src/ap/gas_serv.c | 29 +++++++++++++++++++++++++++++ |
| 121 | + src/ap/gas_serv.h | 2 ++ |
| 122 | + 2 files changed, 31 insertions(+) |
| 123 | + |
| 124 | +diff --git a/src/ap/gas_serv.c b/src/ap/gas_serv.c |
| 125 | +index 9567e20..43bd658 100644 |
| 126 | +--- a/src/ap/gas_serv.c |
| 127 | ++++ b/src/ap/gas_serv.c |
| 128 | +@@ -19,6 +19,7 @@ |
| 129 | + #include "dpp_hostapd.h" |
| 130 | + #include "sta_info.h" |
| 131 | + #include "gas_serv.h" |
| 132 | ++#include "neighbor_db.h" |
| 133 | + |
| 134 | + |
| 135 | + #ifdef CONFIG_DPP |
| 136 | +@@ -369,6 +370,24 @@ static void anqp_add_network_auth_type(struct hostapd_data *hapd, |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | ++static void anqp_add_neighbor_report(struct hostapd_data *hapd, |
| 141 | ++ struct wpabuf *buf) |
| 142 | ++{ |
| 143 | ++ struct hostapd_neighbor_entry *nr; |
| 144 | ++ u8 *len_pos = gas_anqp_add_element(buf, ANQP_NEIGHBOR_REPORT); |
| 145 | ++ if (dl_list_empty(&hapd->nr_db)) { |
| 146 | ++ wpabuf_put_le16(buf, 0); |
| 147 | ++ } |
| 148 | ++ else { |
| 149 | ++ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry, list ) { |
| 150 | ++ wpabuf_put_u8(buf, WLAN_EID_NEIGHBOR_REPORT); |
| 151 | ++ wpabuf_put_u8(buf, wpabuf_len(nr->nr)); |
| 152 | ++ wpabuf_put_buf(buf, nr->nr); |
| 153 | ++ } |
| 154 | ++ } |
| 155 | ++ gas_anqp_set_element_len(buf, len_pos); |
| 156 | ++} |
| 157 | ++ |
| 158 | + |
| 159 | + static void anqp_add_roaming_consortium(struct hostapd_data *hapd, |
| 160 | + struct wpabuf *buf) |
| 161 | +@@ -986,6 +1005,9 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd, |
| 162 | + len += 1000; |
| 163 | + if (request & ANQP_REQ_ICON_REQUEST) |
| 164 | + len += 65536; |
| 165 | ++ if (request & ANQP_REQ_NEIGHBOR_REPORT) { |
| 166 | ++ len += (40 * hostapd_neighbor_count(hapd)); |
| 167 | ++ } |
| 168 | + #ifdef CONFIG_FILS |
| 169 | + if (request & ANQP_FILS_REALM_INFO) |
| 170 | + len += 2 * dl_list_len(&hapd->conf->fils_realms); |
| 171 | +@@ -1028,6 +1050,8 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd, |
| 172 | + anqp_add_elem(hapd, buf, ANQP_TDLS_CAPABILITY); |
| 173 | + if (request & ANQP_REQ_EMERGENCY_NAI) |
| 174 | + anqp_add_elem(hapd, buf, ANQP_EMERGENCY_NAI); |
| 175 | ++ if (request & ANQP_REQ_NEIGHBOR_REPORT) |
| 176 | ++ anqp_add_neighbor_report(hapd, buf); |
| 177 | + |
| 178 | + for (i = 0; i < num_extra_req; i++) { |
| 179 | + #ifdef CONFIG_FILS |
| 180 | +@@ -1172,6 +1196,11 @@ static void rx_anqp_query_list_id(struct hostapd_data *hapd, u16 info_id, |
| 181 | + "Emergency NAI", |
| 182 | + get_anqp_elem(hapd, info_id) != NULL, qi); |
| 183 | + break; |
| 184 | ++ case ANQP_NEIGHBOR_REPORT: |
| 185 | ++ set_anqp_req(ANQP_REQ_NEIGHBOR_REPORT, |
| 186 | ++ "Neighbor Report", |
| 187 | ++ get_anqp_elem(hapd, info_id) != NULL, qi); |
| 188 | ++ break; |
| 189 | + default: |
| 190 | + #ifdef CONFIG_FILS |
| 191 | + if (info_id == ANQP_FILS_REALM_INFO && |
| 192 | +diff --git a/src/ap/gas_serv.h b/src/ap/gas_serv.h |
| 193 | +index 1528af4..d0241f2 100644 |
| 194 | +--- a/src/ap/gas_serv.h |
| 195 | ++++ b/src/ap/gas_serv.h |
| 196 | +@@ -40,6 +40,8 @@ |
| 197 | + (1 << (ANQP_TDLS_CAPABILITY - ANQP_QUERY_LIST)) |
| 198 | + #define ANQP_REQ_EMERGENCY_NAI \ |
| 199 | + (1 << (ANQP_EMERGENCY_NAI - ANQP_QUERY_LIST)) |
| 200 | ++#define ANQP_REQ_NEIGHBOR_REPORT \ |
| 201 | ++ (1 << (ANQP_NEIGHBOR_REPORT - ANQP_QUERY_LIST)) |
| 202 | + /* |
| 203 | + * First 15 Hotspot 2.0 vendor specific ANQP-elements can be included in the |
| 204 | + * optimized bitmap. |
| 205 | +-- |
| 206 | +2.18.0 |
| 207 | + |
| 208 | diff --git a/package/network/services/hostapd/patches/904-2102-Support-including-neignbor-report-elements-in-BTM-re.patch b/package/network/services/hostapd/patches/904-2102-Support-including-neignbor-report-elements-in-BTM-re.patch |
| 209 | new file mode 100644 |
| 210 | index 0000000..3a6c82e |
| 211 | --- /dev/null |
| 212 | +++ b/package/network/services/hostapd/patches/904-2102-Support-including-neignbor-report-elements-in-BTM-re.patch |
| 213 | @@ -0,0 +1,68 @@ |
| 214 | +From 2b36d2c5f227a0f2aeb7bb443e79a5282309614b Mon Sep 17 00:00:00 2001 |
| 215 | +From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 216 | +Date: Mon, 25 Oct 2021 12:17:24 +0800 |
| 217 | +Subject: [PATCH] Support including neignbor report elements in BTM response |
| 218 | + |
| 219 | +--- |
| 220 | + src/ap/wnm_ap.c | 26 ++++++++++++++++++++++++-- |
| 221 | + 1 file changed, 24 insertions(+), 2 deletions(-) |
| 222 | + |
| 223 | +diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c |
| 224 | +index 248f5a1..f3a7c92 100644 |
| 225 | +--- a/src/ap/wnm_ap.c |
| 226 | ++++ b/src/ap/wnm_ap.c |
| 227 | +@@ -20,6 +20,7 @@ |
| 228 | + #include "ap/wpa_auth.h" |
| 229 | + #include "mbo_ap.h" |
| 230 | + #include "wnm_ap.h" |
| 231 | ++#include "ap/neighbor_db.h" |
| 232 | + |
| 233 | + #define MAX_TFS_IE_LEN 1024 |
| 234 | + |
| 235 | +@@ -368,9 +369,21 @@ static int ieee802_11_send_bss_trans_mgmt_request(struct hostapd_data *hapd, |
| 236 | + u8 *pos; |
| 237 | + int res; |
| 238 | + |
| 239 | +- mgmt = os_zalloc(sizeof(*mgmt)); |
| 240 | +- if (mgmt == NULL) |
| 241 | ++ int nr_num = hostapd_neighbor_count(hapd); |
| 242 | ++ int nr_size = ETH_ALEN + 4 + 1 + 1 + 1 + 5; |
| 243 | ++ int total_nr_size = nr_num * nr_size; |
| 244 | ++ u8 *nr_data = os_malloc(total_nr_size); |
| 245 | ++ int nr_data_len = 0; |
| 246 | ++ if (nr_data == NULL) { |
| 247 | ++ wpa_printf (MSG_ERROR, "Failed to allocate memory"); |
| 248 | ++ } else { |
| 249 | ++ nr_data_len = hostapd_neighbor_insert_buffer(hapd, nr_data, total_nr_size); |
| 250 | ++ } |
| 251 | ++ mgmt = os_zalloc(sizeof(*mgmt) + nr_data_len); |
| 252 | ++ if (mgmt == NULL) { |
| 253 | ++ wpa_printf (MSG_ERROR, "Failed to allocate memory for mgmt frame"); |
| 254 | + return -1; |
| 255 | ++ } |
| 256 | + os_memcpy(mgmt->da, addr, ETH_ALEN); |
| 257 | + os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN); |
| 258 | + os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN); |
| 259 | +@@ -380,10 +393,19 @@ static int ieee802_11_send_bss_trans_mgmt_request(struct hostapd_data *hapd, |
| 260 | + mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ; |
| 261 | + mgmt->u.action.u.bss_tm_req.dialog_token = dialog_token; |
| 262 | + mgmt->u.action.u.bss_tm_req.req_mode = 0; |
| 263 | ++ if (nr_num) { |
| 264 | ++ mgmt->u.action.u.bss_tm_req.req_mode |= WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED; |
| 265 | ++ } |
| 266 | + mgmt->u.action.u.bss_tm_req.disassoc_timer = host_to_le16(0); |
| 267 | + mgmt->u.action.u.bss_tm_req.validity_interval = 1; |
| 268 | + pos = mgmt->u.action.u.bss_tm_req.variable; |
| 269 | + |
| 270 | ++ |
| 271 | ++ if (nr_num) { |
| 272 | ++ os_memcpy(pos, nr_data, nr_data_len); |
| 273 | ++ pos += nr_data_len; |
| 274 | ++ } |
| 275 | ++ |
| 276 | + wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request to " |
| 277 | + MACSTR " dialog_token=%u req_mode=0x%x disassoc_timer=%u " |
| 278 | + "validity_interval=%u", |
| 279 | +-- |
| 280 | +2.18.0 |
| 281 | + |
| 282 | diff --git a/package/network/services/hostapd/patches/905-2102-Add-support-to-configure-BSS-Termination-TSF-by-usin.patch b/package/network/services/hostapd/patches/905-2102-Add-support-to-configure-BSS-Termination-TSF-by-usin.patch |
| 283 | new file mode 100644 |
| 284 | index 0000000..ec90f9e |
| 285 | --- /dev/null |
| 286 | +++ b/package/network/services/hostapd/patches/905-2102-Add-support-to-configure-BSS-Termination-TSF-by-usin.patch |
| 287 | @@ -0,0 +1,66 @@ |
| 288 | +From c4f5049289bf5ce13ca0f10fedb6c0255c95d183 Mon Sep 17 00:00:00 2001 |
| 289 | +From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 290 | +Date: Mon, 25 Oct 2021 11:27:23 +0800 |
| 291 | +Subject: [PATCH] Add support to configure BSS Termination TSF by using |
| 292 | + hostapd_cli cmd |
| 293 | + |
| 294 | +--- |
| 295 | + hostapd/ctrl_iface.c | 9 +++++++++ |
| 296 | + src/ap/ap_config.c | 1 + |
| 297 | + src/ap/ap_config.h | 1 + |
| 298 | + 3 files changed, 11 insertions(+) |
| 299 | + |
| 300 | +diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| 301 | +index 5b7f075..87f219d 100644 |
| 302 | +--- a/hostapd/ctrl_iface.c |
| 303 | ++++ b/hostapd/ctrl_iface.c |
| 304 | +@@ -946,6 +946,10 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd, |
| 305 | + wpa_printf(MSG_DEBUG, "Invalid bss_term data"); |
| 306 | + return -1; |
| 307 | + } |
| 308 | ++ if (hapd->conf->bss_termination_tsf) { |
| 309 | ++ WPA_PUT_LE64(&bss_term_dur[2], hapd->conf->bss_termination_tsf); |
| 310 | ++ } |
| 311 | ++ |
| 312 | + end++; |
| 313 | + WPA_PUT_LE16(&bss_term_dur[10], atoi(end)); |
| 314 | + } |
| 315 | +@@ -1515,6 +1519,11 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd) |
| 316 | + #endif /* CONFIG_DPP */ |
| 317 | + } else if (os_strcasecmp(cmd, "setband") == 0) { |
| 318 | + ret = hostapd_ctrl_iface_set_band(hapd, value); |
| 319 | ++ } else if (os_strcasecmp(cmd, "bss_termination_tsf") == 0) { |
| 320 | ++ int termination_sec = atoi(value); |
| 321 | ++ hapd->conf->bss_termination_tsf = termination_sec; |
| 322 | ++ wpa_printf(MSG_DEBUG, "BSS Termination TSF: value = %d", |
| 323 | ++ termination_sec); |
| 324 | + } else { |
| 325 | + ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value); |
| 326 | + if (ret) |
| 327 | +diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c |
| 328 | +index 91ceb9c..262f8e7 100644 |
| 329 | +--- a/src/ap/ap_config.c |
| 330 | ++++ b/src/ap/ap_config.c |
| 331 | +@@ -164,6 +164,7 @@ void hostapd_config_defaults_bss(struct hostapd_bss_config *bss) |
| 332 | + #ifdef CONFIG_TESTING_OPTIONS |
| 333 | + bss->sae_commit_status = -1; |
| 334 | + #endif /* CONFIG_TESTING_OPTIONS */ |
| 335 | ++ bss->bss_termination_tsf = 0; |
| 336 | + } |
| 337 | + |
| 338 | + |
| 339 | +diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h |
| 340 | +index 09823bf..f0825f2 100644 |
| 341 | +--- a/src/ap/ap_config.h |
| 342 | ++++ b/src/ap/ap_config.h |
| 343 | +@@ -551,6 +551,7 @@ struct hostapd_bss_config { |
| 344 | + int wnm_sleep_mode; |
| 345 | + int wnm_sleep_mode_no_keys; |
| 346 | + int bss_transition; |
| 347 | ++ unsigned int bss_termination_tsf; |
| 348 | + |
| 349 | + /* IEEE 802.11u - Interworking */ |
| 350 | + int interworking; |
| 351 | +-- |
| 352 | +2.18.0 |
| 353 | + |
| 354 | diff --git a/package/network/services/hostapd/patches/906-2102-Disable-interface-if-BSS-Termination-TSF-is-set.patch b/package/network/services/hostapd/patches/906-2102-Disable-interface-if-BSS-Termination-TSF-is-set.patch |
| 355 | new file mode 100644 |
| 356 | index 0000000..b3d296b |
| 357 | --- /dev/null |
| 358 | +++ b/package/network/services/hostapd/patches/906-2102-Disable-interface-if-BSS-Termination-TSF-is-set.patch |
| 359 | @@ -0,0 +1,47 @@ |
| 360 | +From d9388fc13d85f057caf06b55c3ac1ba2e807b3d9 Mon Sep 17 00:00:00 2001 |
| 361 | +From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 362 | +Date: Mon, 25 Oct 2021 12:22:57 +0800 |
| 363 | +Subject: [PATCH] Disable interface if BSS Termination TSF is set |
| 364 | + |
| 365 | +--- |
| 366 | + src/ap/wnm_ap.c | 17 +++++++++++++++++ |
| 367 | + 1 file changed, 17 insertions(+) |
| 368 | + |
| 369 | +diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c |
| 370 | +index f3a7c92..9772835 100644 |
| 371 | +--- a/src/ap/wnm_ap.c |
| 372 | ++++ b/src/ap/wnm_ap.c |
| 373 | +@@ -755,6 +755,22 @@ static void set_disassoc_timer(struct hostapd_data *hapd, struct sta_info *sta, |
| 374 | + } |
| 375 | + |
| 376 | + |
| 377 | ++void bss_termination_disable_iface(void *eloop_ctx, void *timeout_ctx) |
| 378 | ++{ |
| 379 | ++ struct hostapd_data *hapd = eloop_ctx; |
| 380 | ++ hostapd_disable_iface(hapd->iface); |
| 381 | ++} |
| 382 | ++ |
| 383 | ++ |
| 384 | ++static void set_disable_iface_timer(struct hostapd_data *hapd, struct sta_info *sta, |
| 385 | ++ int disable_iface_timer) |
| 386 | ++{ |
| 387 | ++ wpa_printf(MSG_DEBUG, "Disable interface timer set to %d secs", disable_iface_timer); |
| 388 | ++ eloop_register_timeout(disable_iface_timer, 0, |
| 389 | ++ bss_termination_disable_iface, hapd, NULL); |
| 390 | ++} |
| 391 | ++ |
| 392 | ++ |
| 393 | + int wnm_send_ess_disassoc_imminent(struct hostapd_data *hapd, |
| 394 | + struct sta_info *sta, const char *url, |
| 395 | + int disassoc_timer) |
| 396 | +@@ -841,6 +857,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta, |
| 397 | + bss_term_dur) { |
| 398 | + os_memcpy(pos, bss_term_dur, 12); |
| 399 | + pos += 12; |
| 400 | ++ set_disable_iface_timer(hapd, sta, hapd->conf->bss_termination_tsf); |
| 401 | + } |
| 402 | + |
| 403 | + if (url) { |
| 404 | +-- |
| 405 | +2.18.0 |
| 406 | + |
| 407 | diff --git a/package/network/services/hostapd/patches/907-2102-Add-set_send_disassoc_frame_timer-to-send-disassocia.patch b/package/network/services/hostapd/patches/907-2102-Add-set_send_disassoc_frame_timer-to-send-disassocia.patch |
| 408 | new file mode 100644 |
| 409 | index 0000000..814658d |
| 410 | --- /dev/null |
| 411 | +++ b/package/network/services/hostapd/patches/907-2102-Add-set_send_disassoc_frame_timer-to-send-disassocia.patch |
| 412 | @@ -0,0 +1,63 @@ |
| 413 | +From cdba633ed9955ecf99f9d9833b10083b6e780314 Mon Sep 17 00:00:00 2001 |
| 414 | +From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 415 | +Date: Mon, 25 Oct 2021 12:46:01 +0800 |
| 416 | +Subject: [PATCH] Add set_send_disassoc_frame_timer() to send disassociate |
| 417 | + frame |
| 418 | + |
| 419 | +Function set_disassoc_timer() may fail if key was deleted first. This new |
| 420 | +function will not ask to delete key as set_disassoc_timer() did. |
| 421 | +--- |
| 422 | + src/ap/wnm_ap.c | 30 +++++++++++++++++++++++++++++- |
| 423 | + 1 file changed, 29 insertions(+), 1 deletion(-) |
| 424 | + |
| 425 | +diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c |
| 426 | +index 9772835..4edfecf 100644 |
| 427 | +--- a/src/ap/wnm_ap.c |
| 428 | ++++ b/src/ap/wnm_ap.c |
| 429 | +@@ -755,6 +755,34 @@ static void set_disassoc_timer(struct hostapd_data *hapd, struct sta_info *sta, |
| 430 | + } |
| 431 | + |
| 432 | + |
| 433 | ++static void set_send_disassoc_frame_timer(struct hostapd_data *hapd, struct sta_info *sta, |
| 434 | ++ int disassoc_timer) |
| 435 | ++{ |
| 436 | ++ int timeout, beacon_int; |
| 437 | ++ |
| 438 | ++ /* |
| 439 | ++ * Prevent STA from reconnecting using cached PMKSA to force |
| 440 | ++ * full authentication with the authentication server (which may |
| 441 | ++ * decide to reject the connection), |
| 442 | ++ */ |
| 443 | ++ wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr); |
| 444 | ++ |
| 445 | ++ beacon_int = hapd->iconf->beacon_int; |
| 446 | ++ if (beacon_int < 1) |
| 447 | ++ beacon_int = 100; /* best guess */ |
| 448 | ++ /* Calculate timeout in ms based on beacon_int in TU */ |
| 449 | ++ timeout = disassoc_timer * beacon_int * 128 / 125; |
| 450 | ++ wpa_printf(MSG_DEBUG, "Disassociation timer for " MACSTR |
| 451 | ++ " set to %d ms", MAC2STR(sta->addr), timeout); |
| 452 | ++ |
| 453 | ++ u16 reason = WLAN_REASON_PREV_AUTH_NOT_VALID; |
| 454 | ++ |
| 455 | ++ hostapd_drv_sta_disassoc(hapd, sta->addr, reason); |
| 456 | ++ if (sta) |
| 457 | ++ ap_sta_disassociate(hapd, sta, reason); |
| 458 | ++} |
| 459 | ++ |
| 460 | ++ |
| 461 | + void bss_termination_disable_iface(void *eloop_ctx, void *timeout_ctx) |
| 462 | + { |
| 463 | + struct hostapd_data *hapd = eloop_ctx; |
| 464 | +@@ -893,7 +921,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta, |
| 465 | + |
| 466 | + if (disassoc_timer) { |
| 467 | + /* send disassociation frame after time-out */ |
| 468 | +- set_disassoc_timer(hapd, sta, disassoc_timer); |
| 469 | ++ set_send_disassoc_frame_timer(hapd, sta, disassoc_timer); |
| 470 | + } |
| 471 | + |
| 472 | + return 0; |
| 473 | +-- |
| 474 | +2.18.0 |
| 475 | + |
| 476 | diff --git a/package/network/services/hostapd/patches/908-2102-Support-including-neighbor-report-elements-in-BTM-re.patch b/package/network/services/hostapd/patches/908-2102-Support-including-neighbor-report-elements-in-BTM-re.patch |
| 477 | new file mode 100644 |
| 478 | index 0000000..4389af5 |
| 479 | --- /dev/null |
| 480 | +++ b/package/network/services/hostapd/patches/908-2102-Support-including-neighbor-report-elements-in-BTM-re.patch |
| 481 | @@ -0,0 +1,31 @@ |
| 482 | +From f0403572a26f0e2acb6eb91a71516ddc65b3683f Mon Sep 17 00:00:00 2001 |
| 483 | +From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 484 | +Date: Mon, 25 Oct 2021 13:51:28 +0800 |
| 485 | +Subject: [PATCH] Support including neighbor report elements in BTM request |
| 486 | + |
| 487 | +--- |
| 488 | + hostapd/ctrl_iface.c | 7 ++++++- |
| 489 | + 1 file changed, 6 insertions(+), 1 deletion(-) |
| 490 | + |
| 491 | +diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| 492 | +index 87f219d..a5c2ae4 100644 |
| 493 | +--- a/hostapd/ctrl_iface.c |
| 494 | ++++ b/hostapd/ctrl_iface.c |
| 495 | +@@ -976,8 +976,13 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd, |
| 496 | + req_mode |= WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT; |
| 497 | + } |
| 498 | + |
| 499 | +- if (os_strstr(cmd, " pref=1")) |
| 500 | ++ if (os_strstr(cmd, " pref=1")) { |
| 501 | + req_mode |= WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED; |
| 502 | ++ if (nei_len == 0) { |
| 503 | ++ // Add neigibor report from neighbor report db to nei_rep buffer |
| 504 | ++ nei_len = hostapd_neighbor_insert_buffer (hapd, nei_rep, 1000); |
| 505 | ++ } |
| 506 | ++ } |
| 507 | + if (os_strstr(cmd, " abridged=1")) |
| 508 | + req_mode |= WNM_BSS_TM_REQ_ABRIDGED; |
| 509 | + if (os_strstr(cmd, " disassoc_imminent=1")) |
| 510 | +-- |
| 511 | +2.18.0 |
| 512 | + |
| 513 | diff --git a/package/network/services/hostapd/patches/909-2102-Add-hostapd_neighbor_set_own_report_pref.patch b/package/network/services/hostapd/patches/909-2102-Add-hostapd_neighbor_set_own_report_pref.patch |
| 514 | new file mode 100644 |
| 515 | index 0000000..7aaeea8 |
| 516 | --- /dev/null |
| 517 | +++ b/package/network/services/hostapd/patches/909-2102-Add-hostapd_neighbor_set_own_report_pref.patch |
| 518 | @@ -0,0 +1,89 @@ |
| 519 | +From 65aeee466fac6ef75fb7fc1ebb72c494275b900b Mon Sep 17 00:00:00 2001 |
| 520 | +From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 521 | +Date: Mon, 25 Oct 2021 14:53:40 +0800 |
| 522 | +Subject: [PATCH] Add hostapd_neighbor_set_own_report_pref() |
| 523 | + |
| 524 | +If my own BSS is going to terminate itself, the preference value of neighbor |
| 525 | +report must be set to 0. |
| 526 | +--- |
| 527 | + hostapd/ctrl_iface.c | 5 ++++- |
| 528 | + src/ap/neighbor_db.c | 37 +++++++++++++++++++++++++++++++++++++ |
| 529 | + src/ap/neighbor_db.h | 2 ++ |
| 530 | + 3 files changed, 43 insertions(+), 1 deletion(-) |
| 531 | + |
| 532 | +diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| 533 | +index a5c2ae4..d653ec8 100644 |
| 534 | +--- a/hostapd/ctrl_iface.c |
| 535 | ++++ b/hostapd/ctrl_iface.c |
| 536 | +@@ -985,8 +985,11 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd, |
| 537 | + } |
| 538 | + if (os_strstr(cmd, " abridged=1")) |
| 539 | + req_mode |= WNM_BSS_TM_REQ_ABRIDGED; |
| 540 | +- if (os_strstr(cmd, " disassoc_imminent=1")) |
| 541 | ++ if (os_strstr(cmd, " disassoc_imminent=1")) { |
| 542 | + req_mode |= WNM_BSS_TM_REQ_DISASSOC_IMMINENT; |
| 543 | ++ /* Set own BSS neighbor report preference value as 0 */ |
| 544 | ++ hostapd_neighbor_set_own_report_pref(hapd, nei_rep, nei_len, 0); |
| 545 | ++ } |
| 546 | + |
| 547 | + #ifdef CONFIG_MBO |
| 548 | + pos = os_strstr(cmd, "mbo="); |
| 549 | +diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c |
| 550 | +index 10143a0..1efd984 100644 |
| 551 | +--- a/src/ap/neighbor_db.c |
| 552 | ++++ b/src/ap/neighbor_db.c |
| 553 | +@@ -353,3 +353,40 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd) |
| 554 | + wpabuf_free(nr); |
| 555 | + #endif /* NEED_AP_MLME */ |
| 556 | + } |
| 557 | ++ |
| 558 | ++ |
| 559 | ++void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf, |
| 560 | ++ size_t buflen, const int pref) |
| 561 | ++{ |
| 562 | ++ struct hostapd_neighbor_entry *nr; |
| 563 | ++ char *pos, *end, *next_nr; |
| 564 | ++ |
| 565 | ++ pos = nei_buf; |
| 566 | ++ end = nei_buf + buflen; |
| 567 | ++ next_nr = nei_buf; |
| 568 | ++ |
| 569 | ++ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry, |
| 570 | ++ list) { |
| 571 | ++ pos = next_nr; |
| 572 | ++ next_nr = pos + 2 + wpabuf_len(nr->nr); |
| 573 | ++ /* Shift 2 bytes for Element ID and Neighbor report length */ |
| 574 | ++ pos = pos + 2; |
| 575 | ++ if(os_memcmp(pos, hapd->own_addr, ETH_ALEN) == 0) { |
| 576 | ++ /* Shift for BSSID + BSSID info + Op_class + channel num + PHY type */ |
| 577 | ++ pos = pos + 6 + 4 + 1 + 1 + 1; |
| 578 | ++ |
| 579 | ++ /* Iterate Subelement */ |
| 580 | ++ while (next_nr - pos > 0) { |
| 581 | ++ if (*pos == 3) { |
| 582 | ++ pos = pos + 2; |
| 583 | ++ *pos = pref; |
| 584 | ++ return; |
| 585 | ++ } else { |
| 586 | ++ pos++; |
| 587 | ++ int shift_len = *pos++; |
| 588 | ++ pos = pos + shift_len; |
| 589 | ++ } |
| 590 | ++ } |
| 591 | ++ } |
| 592 | ++ } |
| 593 | ++} |
| 594 | +diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h |
| 595 | +index e93d1d5..dc6807b 100644 |
| 596 | +--- a/src/ap/neighbor_db.h |
| 597 | ++++ b/src/ap/neighbor_db.h |
| 598 | +@@ -26,4 +26,6 @@ void hostapd_free_neighbor_db(struct hostapd_data *hapd); |
| 599 | + int hostapd_neighbor_count(struct hostapd_data *hapd); |
| 600 | + int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf, |
| 601 | + size_t buflen); |
| 602 | ++void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf, |
| 603 | ++ size_t buflen, const int pref); |
| 604 | + #endif /* NEIGHBOR_DB_H */ |
| 605 | +-- |
| 606 | +2.18.0 |
| 607 | + |
| 608 | -- |
| 609 | 2.18.0 |
| 610 | |