[PATCH V2 3/7] rrm: add handling for co-located BSS

John Crispin john at phrozen.org
Mon Sep 21 07:46:18 EDT 2020


A BSS shall include the neighbor entry of a co-located BSS upon an incoming
request.

Signed-off-by: John Crispin <john at phrozen.org>
---
 src/ap/rrm.c | 117 ++++++++++++++++++++++++++++++++-------------------
 1 file changed, 74 insertions(+), 43 deletions(-)

diff --git a/src/ap/rrm.c b/src/ap/rrm.c
index f2d5cd16e..c9d51dfa7 100644
--- a/src/ap/rrm.c
+++ b/src/ap/rrm.c
@@ -196,6 +196,63 @@ static size_t hostapd_neighbor_report_len(struct wpabuf *buf,
 }
 
 
+static int hostapd_add_nei_report_entry(struct wpabuf *buf, struct hostapd_neighbor_entry *nr,
+					struct wpa_ssid_value *ssid, u8 lci,
+					u8 civic, u16 lci_max_age)
+{
+	u8 *msmt_token;
+	int send_lci;
+	size_t len;
+
+	if (ssid->ssid_len != nr->ssid.ssid_len ||
+	    os_memcmp(ssid->ssid, nr->ssid.ssid, ssid->ssid_len) != 0)
+		return 0;
+
+	send_lci = (lci != 0) && hostapd_check_lci_age(nr, lci_max_age);
+	len = hostapd_neighbor_report_len(buf, nr, send_lci, civic);
+
+	if (len - 2 > 0xff) {
+		wpa_printf(MSG_DEBUG,
+			   "NR entry for " MACSTR " exceeds 0xFF bytes",
+			   MAC2STR(nr->bssid));
+		return 0;
+	}
+
+	if (len > wpabuf_tailroom(buf))
+		return -1;
+
+	wpabuf_put_u8(buf, WLAN_EID_NEIGHBOR_REPORT);
+	wpabuf_put_u8(buf, len - 2);
+	wpabuf_put_buf(buf, nr->nr);
+
+	if (send_lci && nr->lci) {
+		wpabuf_put_u8(buf, WLAN_EID_MEASURE_REPORT);
+		wpabuf_put_u8(buf, wpabuf_len(nr->lci));
+		/*
+		 * Override measurement token - the first byte of the
+		 * Measurement Report element.
+		 */
+		msmt_token = wpabuf_put(buf, 0);
+		wpabuf_put_buf(buf, nr->lci);
+		*msmt_token = lci;
+	}
+
+	if (civic && nr->civic) {
+		wpabuf_put_u8(buf, WLAN_EID_MEASURE_REPORT);
+		wpabuf_put_u8(buf, wpabuf_len(nr->civic));
+		/*
+		 * Override measurement token - the first byte of the
+		 * Measurement Report element.
+		 */
+		msmt_token = wpabuf_put(buf, 0);
+		wpabuf_put_buf(buf, nr->civic);
+		*msmt_token = civic;
+	}
+
+	return 0;
+}
+
+
 static void hostapd_send_nei_report_resp(struct hostapd_data *hapd,
 					 const u8 *addr, u8 dialog_token,
 					 struct wpa_ssid_value *ssid, u8 lci,
@@ -203,7 +260,6 @@ static void hostapd_send_nei_report_resp(struct hostapd_data *hapd,
 {
 	struct hostapd_neighbor_entry *nr;
 	struct wpabuf *buf;
-	u8 *msmt_token;
 
 	/*
 	 * The number and length of the Neighbor Report elements in a Neighbor
@@ -220,52 +276,27 @@ static void hostapd_send_nei_report_resp(struct hostapd_data *hapd,
 
 	dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
 			 list) {
-		int send_lci;
-		size_t len;
-
-		if (ssid->ssid_len != nr->ssid.ssid_len ||
-		    os_memcmp(ssid->ssid, nr->ssid.ssid, ssid->ssid_len) != 0)
-			continue;
-
-		send_lci = (lci != 0) && hostapd_check_lci_age(nr, lci_max_age);
-		len = hostapd_neighbor_report_len(buf, nr, send_lci, civic);
-
-		if (len - 2 > 0xff) {
-			wpa_printf(MSG_DEBUG,
-				   "NR entry for " MACSTR " exceeds 0xFF bytes",
-				   MAC2STR(nr->bssid));
-			continue;
-		}
-
-		if (len > wpabuf_tailroom(buf))
+		if (hostapd_add_nei_report_entry(buf, nr, ssid, lci, civic, lci_max_age))
 			break;
+	}
 
-		wpabuf_put_u8(buf, WLAN_EID_NEIGHBOR_REPORT);
-		wpabuf_put_u8(buf, len - 2);
-		wpabuf_put_buf(buf, nr->nr);
+	if (!hapd->iconf->he_co_locate) {
+		int i;
 
-		if (send_lci && nr->lci) {
-			wpabuf_put_u8(buf, WLAN_EID_MEASURE_REPORT);
-			wpabuf_put_u8(buf, wpabuf_len(nr->lci));
-			/*
-			 * Override measurement token - the first byte of the
-			 * Measurement Report element.
-			 */
-			msmt_token = wpabuf_put(buf, 0);
-			wpabuf_put_buf(buf, nr->lci);
-			*msmt_token = lci;
-		}
+		for (i = 0; i < hapd->iface->interfaces->count; i++) {
+			struct hostapd_iface *iface = hapd->iface->interfaces->iface[i];
+			int j;
+
+			if (iface == hapd->iface || !iface->conf->he_co_locate)
+				continue;
 
-		if (civic && nr->civic) {
-			wpabuf_put_u8(buf, WLAN_EID_MEASURE_REPORT);
-			wpabuf_put_u8(buf, wpabuf_len(nr->civic));
-			/*
-			 * Override measurement token - the first byte of the
-			 * Measurement Report element.
-			 */
-			msmt_token = wpabuf_put(buf, 0);
-			wpabuf_put_buf(buf, nr->civic);
-			*msmt_token = civic;
+			for (j = 0; j < iface->num_bss; j++) {
+				nr = hostapd_neighbor_get(iface->bss[j], iface->bss[j]->own_addr, NULL);
+				if (!nr)
+					continue;
+				if (hostapd_add_nei_report_entry(buf, nr, ssid, lci, civic, lci_max_age))
+					break;
+			}
 		}
 	}
 
-- 
2.25.1




More information about the Hostap mailing list