developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 1 | From 413cb1d917383c5f4cb4bb6b94310c4f193a9187 Mon Sep 17 00:00:00 2001 |
| 2 | From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 3 | Date: Wed, 19 Jan 2022 19:18:07 +0800 |
| 4 | Subject: [PATCH 1/9] Add hostapd_neighbor_count() and |
| 5 | hostapd_neighbor_insert_buffer () |
| 6 | |
| 7 | The first function can count the number of neighbor report in neighbore report |
| 8 | database. The second can iterate neighbor report database to build up neighbor |
| 9 | report data. |
| 10 | --- |
| 11 | src/ap/neighbor_db.c | 32 ++++++++++++++++++++++++++++++++ |
| 12 | src/ap/neighbor_db.h | 3 +++ |
| 13 | 2 files changed, 35 insertions(+) |
| 14 | |
| 15 | diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c |
| 16 | index 229edd2..ce6865d 100644 |
| 17 | --- 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); |
| 58 | diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h |
| 59 | index 992671b..1ae194d 100644 |
| 60 | --- 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 | -- |
| 71 | 2.18.0 |
| 72 | |