blob: 37ff1ac3de1d2805890f12b21481c11ae3fd1131 [file] [log] [blame]
developerc41fcd32022-09-20 22:09:06 +08001From 9af8c262f5405028d704a3b7f93c4fcb7ed5f7b4 Mon Sep 17 00:00:00 2001
developerac7492d2022-06-09 20:22:14 +08002From: Howard Hsu <howard-yh.hsu@mediatek.com>
3Date: Thu, 9 Jun 2022 20:00:49 +0800
developerc41fcd32022-09-20 22:09:06 +08004Subject: [PATCH 99907/99916] Add hostapd_neighbor_set_own_report_pref()
developere2cc0fa2022-03-29 17:31:03 +08005
developere2cc0fa2022-03-29 17:31:03 +08006---
developerac7492d2022-06-09 20:22:14 +08007 src/ap/ctrl_iface_ap.c | 6 +++++-
8 src/ap/neighbor_db.c | 36 ++++++++++++++++++++++++++++++++++++
9 src/ap/neighbor_db.h | 2 ++
10 3 files changed, 43 insertions(+), 1 deletion(-)
developere2cc0fa2022-03-29 17:31:03 +080011
developerac7492d2022-06-09 20:22:14 +080012diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
developerc41fcd32022-09-20 22:09:06 +080013index 1cbec537a..274b43587 100644
developerac7492d2022-06-09 20:22:14 +080014--- a/src/ap/ctrl_iface_ap.c
15+++ b/src/ap/ctrl_iface_ap.c
developerc41fcd32022-09-20 22:09:06 +080016@@ -1242,8 +1242,12 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
developere2cc0fa2022-03-29 17:31:03 +080017 }
18 if (os_strstr(cmd, " abridged=1"))
19 req_mode |= WNM_BSS_TM_REQ_ABRIDGED;
20- if (os_strstr(cmd, " disassoc_imminent=1"))
21+ if (os_strstr(cmd, " disassoc_imminent=1")) {
22 req_mode |= WNM_BSS_TM_REQ_DISASSOC_IMMINENT;
23+ /* Set own BSS neighbor report preference value as 0 */
24+ hostapd_neighbor_set_own_report_pref(hapd, nei_rep, nei_len, 0);
25+ }
developerac7492d2022-06-09 20:22:14 +080026+
developere2cc0fa2022-03-29 17:31:03 +080027
28 #ifdef CONFIG_MBO
29 pos = os_strstr(cmd, "mbo=");
30diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
developerc41fcd32022-09-20 22:09:06 +080031index c12139067..134ed4a71 100644
developere2cc0fa2022-03-29 17:31:03 +080032--- a/src/ap/neighbor_db.c
33+++ b/src/ap/neighbor_db.c
developerc41fcd32022-09-20 22:09:06 +080034@@ -357,3 +357,39 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd)
developere2cc0fa2022-03-29 17:31:03 +080035 wpabuf_free(nr);
36 #endif /* NEED_AP_MLME */
37 }
38+
39+
40+void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
41+ size_t buflen, const int pref)
42+{
43+ struct hostapd_neighbor_entry *nr;
44+ char *pos, *next_nr;
45+
46+ pos = nei_buf;
47+ next_nr = nei_buf;
48+
49+ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
50+ list) {
51+ pos = next_nr;
52+ next_nr = pos + 2 + wpabuf_len(nr->nr);
53+ /* Shift 2 bytes for Element ID and Neighbor report length */
54+ pos = pos + 2;
55+ if(os_memcmp(pos, hapd->own_addr, ETH_ALEN) == 0) {
56+ /* Shift for BSSID + BSSID info + Op_class + channel num + PHY type */
57+ pos = pos + 6 + 4 + 1 + 1 + 1;
58+
59+ /* Iterate Subelement */
60+ while (next_nr - pos > 0) {
61+ if (*pos == 3) {
62+ pos = pos + 2;
63+ *pos = pref;
64+ return;
65+ } else {
66+ pos++;
67+ int shift_len = *pos++;
68+ pos = pos + shift_len;
69+ }
70+ }
71+ }
72+ }
73+}
74diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
developerc41fcd32022-09-20 22:09:06 +080075index 1ae194d98..2e16f7268 100644
developere2cc0fa2022-03-29 17:31:03 +080076--- a/src/ap/neighbor_db.h
77+++ b/src/ap/neighbor_db.h
78@@ -27,4 +27,6 @@ void hostapd_free_neighbor_db(struct hostapd_data *hapd);
79 int hostapd_neighbor_count(struct hostapd_data *hapd);
80 int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
81 size_t buflen);
82+void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
83+ size_t buflen, const int pref);
84 #endif /* NEIGHBOR_DB_H */
85--
developerc41fcd32022-09-20 22:09:06 +0800862.25.1
developere2cc0fa2022-03-29 17:31:03 +080087