| From ad6a0480d6e495796ac74b8ec53bcc2e85534caf Mon Sep 17 00:00:00 2001 |
| From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| Date: Wed, 19 Jan 2022 19:18:07 +0800 |
| Subject: [PATCH 99900/99916] Add hostapd_neighbor_count() and |
| hostapd_neighbor_insert_buffer () |
| |
| The first function can count the number of neighbor report in neighbore report |
| database. The second can iterate neighbor report database to build up neighbor |
| report data. |
| --- |
| src/ap/neighbor_db.c | 32 ++++++++++++++++++++++++++++++++ |
| src/ap/neighbor_db.h | 3 +++ |
| 2 files changed, 35 insertions(+) |
| |
| diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c |
| index 52f25eb7a..c12139067 100644 |
| --- a/src/ap/neighbor_db.c |
| +++ b/src/ap/neighbor_db.c |
| @@ -89,6 +89,38 @@ int hostapd_neighbor_show(struct hostapd_data *hapd, char *buf, size_t buflen) |
| } |
| |
| |
| +int hostapd_neighbor_count(struct hostapd_data *hapd) |
| +{ |
| + struct hostapd_neighbor_entry *nr; |
| + int count = 0; |
| + |
| + dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry, |
| + list) { |
| + count++; |
| + } |
| + return count; |
| +} |
| + |
| + |
| +int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf, |
| + size_t buflen) |
| +{ |
| + struct hostapd_neighbor_entry *nr; |
| + char *pos = buf; |
| + |
| + dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry, |
| + list) { |
| + /* For neighbor report IE, we only need bssid and nr*/ |
| + *pos++ = WLAN_EID_NEIGHBOR_REPORT; |
| + *pos++ = wpabuf_len(nr->nr); |
| + os_memcpy(pos, wpabuf_head(nr->nr), wpabuf_len(nr->nr)); |
| + pos += wpabuf_len(nr->nr); |
| + } |
| + |
| + return pos - buf; |
| +} |
| + |
| + |
| static void hostapd_neighbor_clear_entry(struct hostapd_neighbor_entry *nr) |
| { |
| wpabuf_free(nr->nr); |
| diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h |
| index 992671b62..1ae194d98 100644 |
| --- a/src/ap/neighbor_db.h |
| +++ b/src/ap/neighbor_db.h |
| @@ -24,4 +24,7 @@ int hostapd_neighbor_remove(struct hostapd_data *hapd, const u8 *bssid, |
| const struct wpa_ssid_value *ssid); |
| 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); |
| #endif /* NEIGHBOR_DB_H */ |
| -- |
| 2.25.1 |
| |