blob: ce6d8a26d7a6b03d1d8782d2e6ed8d7cdf02d5a3 [file] [log] [blame]
developerc41fcd32022-09-20 22:09:06 +08001From ad6a0480d6e495796ac74b8ec53bcc2e85534caf Mon Sep 17 00:00:00 2001
developere2cc0fa2022-03-29 17:31:03 +08002From: "howard.hsu" <howard-yh.hsu@mediatek.com>
3Date: Wed, 19 Jan 2022 19:18:07 +0800
developerc41fcd32022-09-20 22:09:06 +08004Subject: [PATCH 99900/99916] Add hostapd_neighbor_count() and
developere2cc0fa2022-03-29 17:31:03 +08005 hostapd_neighbor_insert_buffer ()
6
7The first function can count the number of neighbor report in neighbore report
8database. The second can iterate neighbor report database to build up neighbor
9report data.
10---
11 src/ap/neighbor_db.c | 32 ++++++++++++++++++++++++++++++++
12 src/ap/neighbor_db.h | 3 +++
13 2 files changed, 35 insertions(+)
14
15diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
developerc41fcd32022-09-20 22:09:06 +080016index 52f25eb7a..c12139067 100644
developere2cc0fa2022-03-29 17:31:03 +080017--- a/src/ap/neighbor_db.c
18+++ b/src/ap/neighbor_db.c
19@@ -89,6 +89,38 @@ int hostapd_neighbor_show(struct hostapd_data *hapd, char *buf, size_t buflen)
20 }
21
22
23+int hostapd_neighbor_count(struct hostapd_data *hapd)
24+{
25+ struct hostapd_neighbor_entry *nr;
26+ int count = 0;
27+
28+ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
29+ list) {
30+ count++;
31+ }
32+ return count;
33+}
34+
35+
36+int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
37+ size_t buflen)
38+{
39+ struct hostapd_neighbor_entry *nr;
40+ char *pos = buf;
41+
42+ dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
43+ list) {
44+ /* For neighbor report IE, we only need bssid and nr*/
45+ *pos++ = WLAN_EID_NEIGHBOR_REPORT;
46+ *pos++ = wpabuf_len(nr->nr);
47+ os_memcpy(pos, wpabuf_head(nr->nr), wpabuf_len(nr->nr));
48+ pos += wpabuf_len(nr->nr);
49+ }
50+
51+ return pos - buf;
52+}
53+
54+
55 static void hostapd_neighbor_clear_entry(struct hostapd_neighbor_entry *nr)
56 {
57 wpabuf_free(nr->nr);
58diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
developerc41fcd32022-09-20 22:09:06 +080059index 992671b62..1ae194d98 100644
developere2cc0fa2022-03-29 17:31:03 +080060--- a/src/ap/neighbor_db.h
61+++ b/src/ap/neighbor_db.h
62@@ -24,4 +24,7 @@ int hostapd_neighbor_remove(struct hostapd_data *hapd, const u8 *bssid,
63 const struct wpa_ssid_value *ssid);
64 void hostapd_free_neighbor_db(struct hostapd_data *hapd);
65
66+int hostapd_neighbor_count(struct hostapd_data *hapd);
67+int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
68+ size_t buflen);
69 #endif /* NEIGHBOR_DB_H */
70--
developerc41fcd32022-09-20 22:09:06 +0800712.25.1
developere2cc0fa2022-03-29 17:31:03 +080072