blob: e761c0087c214d46e2ab9d85afd544709ce8345e [file] [log] [blame]
From 413cb1d917383c5f4cb4bb6b94310c4f193a9187 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 1/9] 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 229edd2..ce6865d 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 992671b..1ae194d 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.18.0