blob: 632475c4e50bc86c46463bc798ad9ad26d801f62 [file] [log] [blame]
From 7aab6cf66cfb7dea480d16e312e0f0eb08e758ab Mon Sep 17 00:00:00 2001
From: "howard.hsu" <howard-yh.hsu@mediatek.com>
Date: Wed, 19 Jan 2022 21:32:17 +0800
Subject: [PATCH 9/9] Add hostapd_neighbor_set_pref_by_non_pref_chan()
The preference value of neighbor report shall be modified according to struct
non_pref_chan_info.
---
hostapd/ctrl_iface.c | 2 ++
src/ap/neighbor_db.c | 51 ++++++++++++++++++++++++++++++++++++++++++++
src/ap/neighbor_db.h | 4 ++++
3 files changed, 57 insertions(+)
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 3146a25..974e5b9 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -1000,6 +1000,8 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
}
#ifdef CONFIG_MBO
+ hostapd_neighbor_set_pref_by_non_pref_chan(hapd, sta, nei_rep, nei_len);
+
pos = os_strstr(cmd, "mbo=");
if (pos) {
unsigned int mbo_reason, cell_pref, reassoc_delay;
diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
index bc1b163..75b6fcc 100644
--- a/src/ap/neighbor_db.c
+++ b/src/ap/neighbor_db.c
@@ -388,3 +388,54 @@ void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_b
}
}
}
+
+#ifdef CONFIG_MBO
+void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
+ struct sta_info* sta, char *nei_buf, size_t buflen)
+{
+ struct hostapd_neighbor_entry *nr;
+ struct mbo_non_pref_chan_info *info;
+ u8 i;
+
+ for(info = sta->non_pref_chan; info; info = info->next) {
+ /* Check OP_Class and Channel num */
+ for(i = 0; i < info->num_channels; i++) {
+ char *pos, *next_nr;
+
+ pos = nei_buf;
+ next_nr = nei_buf;
+
+ /* Iterate Neighbor report database */
+ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
+ list) {
+ pos = next_nr;
+ next_nr = pos + 2 + wpabuf_len(nr->nr);
+ /**
+ * Shift 12 bytes for Element ID, Neighbor report length,
+ * BSSID and BSSID info.
+ */
+ pos = pos + 12;
+ int nr_op_class = *pos++;
+ int nr_channel = *pos;
+ if(info->op_class == nr_op_class && info->channels[i] == nr_channel) {
+ /* Shift for Channel Num + PHY type */
+ pos = pos + 1 + 1;
+
+ // Iterate Subelement
+ while(next_nr - pos > 0) {
+ if(*pos == 3) {
+ pos = pos + 2;
+ *pos = info->pref;
+ break;
+ }else {
+ pos++;
+ int shift_len = *pos++;
+ pos = pos + shift_len;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+#endif
diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
index 2e16f72..a1ddc07 100644
--- a/src/ap/neighbor_db.h
+++ b/src/ap/neighbor_db.h
@@ -29,4 +29,8 @@ int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
size_t buflen);
void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
size_t buflen, const int pref);
+#ifdef CONFIG_MBO
+void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
+ struct sta_info* sta, char *nei_buf, size_t buflen);
+#endif
#endif /* NEIGHBOR_DB_H */
--
2.18.0