blob: 563588ec09c4eceb6f1eecad0c0950117cae72e8 [file] [log] [blame]
developerc41fcd32022-09-20 22:09:06 +08001From 21c1940ecfd6d9404097868ad4a59a0d6a54ea69 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:02:06 +0800
developerc41fcd32022-09-20 22:09:06 +08004Subject: [PATCH 99908/99916] Add hostapd_neighbor_set_pref_by_non_pref_chan()
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 | 2 ++
8 src/ap/neighbor_db.c | 51 ++++++++++++++++++++++++++++++++++++++++++
9 src/ap/neighbor_db.h | 4 ++++
developere2cc0fa2022-03-29 17:31:03 +080010 3 files changed, 57 insertions(+)
11
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 274b43587..18bae5c8b 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@@ -1250,6 +1250,8 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
developerac7492d2022-06-09 20:22:14 +080017
developere2cc0fa2022-03-29 17:31:03 +080018
19 #ifdef CONFIG_MBO
20+ hostapd_neighbor_set_pref_by_non_pref_chan(hapd, sta, nei_rep, nei_len);
21+
22 pos = os_strstr(cmd, "mbo=");
23 if (pos) {
24 unsigned int mbo_reason, cell_pref, reassoc_delay;
25diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
developerc41fcd32022-09-20 22:09:06 +080026index 134ed4a71..9254d09fd 100644
developere2cc0fa2022-03-29 17:31:03 +080027--- a/src/ap/neighbor_db.c
28+++ b/src/ap/neighbor_db.c
developerc41fcd32022-09-20 22:09:06 +080029@@ -393,3 +393,54 @@ void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_b
developere2cc0fa2022-03-29 17:31:03 +080030 }
31 }
32 }
33+
34+#ifdef CONFIG_MBO
35+void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
36+ struct sta_info* sta, char *nei_buf, size_t buflen)
37+{
38+ struct hostapd_neighbor_entry *nr;
39+ struct mbo_non_pref_chan_info *info;
40+ u8 i;
41+
42+ for(info = sta->non_pref_chan; info; info = info->next) {
43+ /* Check OP_Class and Channel num */
44+ for(i = 0; i < info->num_channels; i++) {
45+ char *pos, *next_nr;
46+
47+ pos = nei_buf;
48+ next_nr = nei_buf;
49+
50+ /* Iterate Neighbor report database */
51+ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
52+ list) {
53+ pos = next_nr;
54+ next_nr = pos + 2 + wpabuf_len(nr->nr);
55+ /**
56+ * Shift 12 bytes for Element ID, Neighbor report length,
57+ * BSSID and BSSID info.
58+ */
59+ pos = pos + 12;
60+ int nr_op_class = *pos++;
61+ int nr_channel = *pos;
62+ if(info->op_class == nr_op_class && info->channels[i] == nr_channel) {
63+ /* Shift for Channel Num + PHY type */
64+ pos = pos + 1 + 1;
65+
66+ // Iterate Subelement
67+ while(next_nr - pos > 0) {
68+ if(*pos == 3) {
69+ pos = pos + 2;
70+ *pos = info->pref;
71+ break;
72+ }else {
73+ pos++;
74+ int shift_len = *pos++;
75+ pos = pos + shift_len;
76+ }
77+ }
78+ }
79+ }
80+ }
81+ }
82+}
83+#endif
84diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
developerc41fcd32022-09-20 22:09:06 +080085index 2e16f7268..a1ddc075b 100644
developere2cc0fa2022-03-29 17:31:03 +080086--- a/src/ap/neighbor_db.h
87+++ b/src/ap/neighbor_db.h
88@@ -29,4 +29,8 @@ int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
89 size_t buflen);
90 void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
91 size_t buflen, const int pref);
92+#ifdef CONFIG_MBO
93+void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
94+ struct sta_info* sta, char *nei_buf, size_t buflen);
95+#endif
96 #endif /* NEIGHBOR_DB_H */
97--
developerc41fcd32022-09-20 22:09:06 +0800982.25.1
developere2cc0fa2022-03-29 17:31:03 +080099