blob: 632475c4e50bc86c46463bc798ad9ad26d801f62 [file] [log] [blame]
developere2cc0fa2022-03-29 17:31:03 +08001From 7aab6cf66cfb7dea480d16e312e0f0eb08e758ab Mon Sep 17 00:00:00 2001
2From: "howard.hsu" <howard-yh.hsu@mediatek.com>
3Date: Wed, 19 Jan 2022 21:32:17 +0800
4Subject: [PATCH 9/9] Add hostapd_neighbor_set_pref_by_non_pref_chan()
5
6The preference value of neighbor report shall be modified according to struct
7non_pref_chan_info.
8---
9 hostapd/ctrl_iface.c | 2 ++
10 src/ap/neighbor_db.c | 51 ++++++++++++++++++++++++++++++++++++++++++++
11 src/ap/neighbor_db.h | 4 ++++
12 3 files changed, 57 insertions(+)
13
14diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
15index 3146a25..974e5b9 100644
16--- a/hostapd/ctrl_iface.c
17+++ b/hostapd/ctrl_iface.c
18@@ -1000,6 +1000,8 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
19 }
20
21 #ifdef CONFIG_MBO
22+ hostapd_neighbor_set_pref_by_non_pref_chan(hapd, sta, nei_rep, nei_len);
23+
24 pos = os_strstr(cmd, "mbo=");
25 if (pos) {
26 unsigned int mbo_reason, cell_pref, reassoc_delay;
27diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
28index bc1b163..75b6fcc 100644
29--- a/src/ap/neighbor_db.c
30+++ b/src/ap/neighbor_db.c
31@@ -388,3 +388,54 @@ void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_b
32 }
33 }
34 }
35+
36+#ifdef CONFIG_MBO
37+void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
38+ struct sta_info* sta, char *nei_buf, size_t buflen)
39+{
40+ struct hostapd_neighbor_entry *nr;
41+ struct mbo_non_pref_chan_info *info;
42+ u8 i;
43+
44+ for(info = sta->non_pref_chan; info; info = info->next) {
45+ /* Check OP_Class and Channel num */
46+ for(i = 0; i < info->num_channels; i++) {
47+ char *pos, *next_nr;
48+
49+ pos = nei_buf;
50+ next_nr = nei_buf;
51+
52+ /* Iterate Neighbor report database */
53+ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
54+ list) {
55+ pos = next_nr;
56+ next_nr = pos + 2 + wpabuf_len(nr->nr);
57+ /**
58+ * Shift 12 bytes for Element ID, Neighbor report length,
59+ * BSSID and BSSID info.
60+ */
61+ pos = pos + 12;
62+ int nr_op_class = *pos++;
63+ int nr_channel = *pos;
64+ if(info->op_class == nr_op_class && info->channels[i] == nr_channel) {
65+ /* Shift for Channel Num + PHY type */
66+ pos = pos + 1 + 1;
67+
68+ // Iterate Subelement
69+ while(next_nr - pos > 0) {
70+ if(*pos == 3) {
71+ pos = pos + 2;
72+ *pos = info->pref;
73+ break;
74+ }else {
75+ pos++;
76+ int shift_len = *pos++;
77+ pos = pos + shift_len;
78+ }
79+ }
80+ }
81+ }
82+ }
83+ }
84+}
85+#endif
86diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
87index 2e16f72..a1ddc07 100644
88--- a/src/ap/neighbor_db.h
89+++ b/src/ap/neighbor_db.h
90@@ -29,4 +29,8 @@ int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
91 size_t buflen);
92 void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
93 size_t buflen, const int pref);
94+#ifdef CONFIG_MBO
95+void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
96+ struct sta_info* sta, char *nei_buf, size_t buflen);
97+#endif
98 #endif /* NEIGHBOR_DB_H */
99--
1002.18.0
101