developer | ac7492d | 2022-06-09 20:22:14 +0800 | [diff] [blame] | 1 | From be49aa855a83b3bb0c6a96380960b54cbdabcb56 Mon Sep 17 00:00:00 2001 |
| 2 | From: Howard Hsu <howard-yh.hsu@mediatek.com> |
| 3 | Date: Thu, 9 Jun 2022 20:02:06 +0800 |
| 4 | Subject: [PATCH 6/6] Add hostapd_neighbor_set_pref_by_non_pref_chan() |
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 | 2 ++ |
| 8 | src/ap/neighbor_db.c | 51 ++++++++++++++++++++++++++++++++++++++++++ |
| 9 | src/ap/neighbor_db.h | 4 ++++ |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 10 | 3 files changed, 57 insertions(+) |
| 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 |
| 13 | index d5d4e33..a888b76 100644 |
| 14 | --- a/src/ap/ctrl_iface_ap.c |
| 15 | +++ b/src/ap/ctrl_iface_ap.c |
| 16 | @@ -1249,6 +1249,8 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd, |
| 17 | |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 18 | |
| 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; |
| 25 | diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c |
developer | ac7492d | 2022-06-09 20:22:14 +0800 | [diff] [blame] | 26 | index 20a4417..8c27da9 100644 |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 27 | --- a/src/ap/neighbor_db.c |
| 28 | +++ b/src/ap/neighbor_db.c |
developer | ac7492d | 2022-06-09 20:22:14 +0800 | [diff] [blame] | 29 | @@ -391,3 +391,54 @@ void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_b |
developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 30 | } |
| 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 |
| 84 | diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h |
| 85 | index 2e16f72..a1ddc07 100644 |
| 86 | --- 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 | -- |
| 98 | 2.18.0 |
| 99 | |