| From 6fc069a54efb892e486dfde59cb97e0023dbbf5d Mon Sep 17 00:00:00 2001 |
| From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| Date: Wed, 19 Jan 2022 21:27:55 +0800 |
| Subject: [PATCH 8/9] Add hostapd_neighbor_set_own_report_pref() |
| |
| If my own BSS is going to terminate itself, the preference value of neighbor |
| report must be set to 0. |
| --- |
| hostapd/ctrl_iface.c | 5 ++++- |
| src/ap/neighbor_db.c | 36 ++++++++++++++++++++++++++++++++++++ |
| src/ap/neighbor_db.h | 2 ++ |
| 3 files changed, 42 insertions(+), 1 deletion(-) |
| |
| diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| index 5a82ae6..3146a25 100644 |
| --- a/hostapd/ctrl_iface.c |
| +++ b/hostapd/ctrl_iface.c |
| @@ -993,8 +993,11 @@ static int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd, |
| } |
| if (os_strstr(cmd, " abridged=1")) |
| req_mode |= WNM_BSS_TM_REQ_ABRIDGED; |
| - if (os_strstr(cmd, " disassoc_imminent=1")) |
| + if (os_strstr(cmd, " disassoc_imminent=1")) { |
| req_mode |= WNM_BSS_TM_REQ_DISASSOC_IMMINENT; |
| + /* Set own BSS neighbor report preference value as 0 */ |
| + hostapd_neighbor_set_own_report_pref(hapd, nei_rep, nei_len, 0); |
| + } |
| |
| #ifdef CONFIG_MBO |
| pos = os_strstr(cmd, "mbo="); |
| diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c |
| index ce6865d..bc1b163 100644 |
| --- a/src/ap/neighbor_db.c |
| +++ b/src/ap/neighbor_db.c |
| @@ -352,3 +352,39 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd) |
| wpabuf_free(nr); |
| #endif /* NEED_AP_MLME */ |
| } |
| + |
| + |
| +void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf, |
| + size_t buflen, const int pref) |
| +{ |
| + struct hostapd_neighbor_entry *nr; |
| + char *pos, *next_nr; |
| + |
| + pos = nei_buf; |
| + next_nr = nei_buf; |
| + |
| + 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 2 bytes for Element ID and Neighbor report length */ |
| + pos = pos + 2; |
| + if(os_memcmp(pos, hapd->own_addr, ETH_ALEN) == 0) { |
| + /* Shift for BSSID + BSSID info + Op_class + channel num + PHY type */ |
| + pos = pos + 6 + 4 + 1 + 1 + 1; |
| + |
| + /* Iterate Subelement */ |
| + while (next_nr - pos > 0) { |
| + if (*pos == 3) { |
| + pos = pos + 2; |
| + *pos = pref; |
| + return; |
| + } else { |
| + pos++; |
| + int shift_len = *pos++; |
| + pos = pos + shift_len; |
| + } |
| + } |
| + } |
| + } |
| +} |
| diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h |
| index 1ae194d..2e16f72 100644 |
| --- a/src/ap/neighbor_db.h |
| +++ b/src/ap/neighbor_db.h |
| @@ -27,4 +27,6 @@ void hostapd_free_neighbor_db(struct hostapd_data *hapd); |
| int hostapd_neighbor_count(struct hostapd_data *hapd); |
| 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); |
| #endif /* NEIGHBOR_DB_H */ |
| -- |
| 2.18.0 |
| |