developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 1 | From 9af8c262f5405028d704a3b7f93c4fcb7ed5f7b4 Mon Sep 17 00:00:00 2001 |
developer | ac7492d | 2022-06-09 20:22:14 +0800 | [diff] [blame] | 2 | From: Howard Hsu <howard-yh.hsu@mediatek.com> |
| 3 | Date: Thu, 9 Jun 2022 20:00:49 +0800 |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 4 | Subject: [PATCH 99907/99916] Add hostapd_neighbor_set_own_report_pref() |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 5 | |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 6 | --- |
developer | ac7492d | 2022-06-09 20:22:14 +0800 | [diff] [blame] | 7 | 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(-) |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 11 | |
developer | ac7492d | 2022-06-09 20:22:14 +0800 | [diff] [blame] | 12 | diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 13 | index 1cbec537a..274b43587 100644 |
developer | ac7492d | 2022-06-09 20:22:14 +0800 | [diff] [blame] | 14 | --- a/src/ap/ctrl_iface_ap.c |
| 15 | +++ b/src/ap/ctrl_iface_ap.c |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 16 | @@ -1242,8 +1242,12 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd, |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 17 | } |
| 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 | + } |
developer | ac7492d | 2022-06-09 20:22:14 +0800 | [diff] [blame] | 26 | + |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 27 | |
| 28 | #ifdef CONFIG_MBO |
| 29 | pos = os_strstr(cmd, "mbo="); |
| 30 | diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 31 | index c12139067..134ed4a71 100644 |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 32 | --- a/src/ap/neighbor_db.c |
| 33 | +++ b/src/ap/neighbor_db.c |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 34 | @@ -357,3 +357,39 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd) |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 35 | 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 | +} |
| 74 | diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 75 | index 1ae194d98..2e16f7268 100644 |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 76 | --- 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 | -- |
developer | c41fcd3 | 2022-09-20 22:09:06 +0800 | [diff] [blame] | 86 | 2.25.1 |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 87 | |