diff mbox series

[1/2] rrm: Use helper method to create neigh report ies

Message ID 1553178806-28307-1-git-send-email-greearb@candelatech.com
State Deferred
Headers show
Series [1/2] rrm: Use helper method to create neigh report ies | expand

Commit Message

Ben Greear March 21, 2019, 2:33 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

This way we can call it from elsewhere as needed.  Should
be no functional change.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 src/ap/rrm.c | 50 +++++++++++++++++++++++++++++---------------------
 src/ap/rrm.h |  3 +++
 2 files changed, 32 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/src/ap/rrm.c b/src/ap/rrm.c
index f2d5cd1..117f631 100644
--- a/src/ap/rrm.c
+++ b/src/ap/rrm.c
@@ -195,36 +195,21 @@  static size_t hostapd_neighbor_report_len(struct wpabuf *buf,
 	return len;
 }
 
-
-static void hostapd_send_nei_report_resp(struct hostapd_data *hapd,
-					 const u8 *addr, u8 dialog_token,
-					 struct wpa_ssid_value *ssid, u8 lci,
-					 u8 civic, u16 lci_max_age)
+void hostapd_rrm_add_neigh_report_ies(struct hostapd_data *hapd,
+				      struct wpabuf *buf, struct wpa_ssid_value *ssid,
+				      u8 lci, u8 civic, u16 lci_max_age)
 {
 	struct hostapd_neighbor_entry *nr;
-	struct wpabuf *buf;
 	u8 *msmt_token;
 
-	/*
-	 * The number and length of the Neighbor Report elements in a Neighbor
-	 * Report frame is limited by the maximum allowed MMPDU size; + 3 bytes
-	 * of RRM header.
-	 */
-	buf = wpabuf_alloc(3 + IEEE80211_MAX_MMPDU_SIZE);
-	if (!buf)
-		return;
-
-	wpabuf_put_u8(buf, WLAN_ACTION_RADIO_MEASUREMENT);
-	wpabuf_put_u8(buf, WLAN_RRM_NEIGHBOR_REPORT_RESPONSE);
-	wpabuf_put_u8(buf, dialog_token);
-
 	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)
+		if (ssid &&
+		    (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);
@@ -268,6 +253,29 @@  static void hostapd_send_nei_report_resp(struct hostapd_data *hapd,
 			*msmt_token = civic;
 		}
 	}
+}
+
+static void hostapd_send_nei_report_resp(struct hostapd_data *hapd,
+					 const u8 *addr, u8 dialog_token,
+					 struct wpa_ssid_value *ssid, u8 lci,
+					 u8 civic, u16 lci_max_age)
+{
+	struct wpabuf *buf;
+
+	/*
+	 * The number and length of the Neighbor Report elements in a Neighbor
+	 * Report frame is limited by the maximum allowed MMPDU size; + 3 bytes
+	 * of RRM header.
+	 */
+	buf = wpabuf_alloc(3 + IEEE80211_MAX_MMPDU_SIZE);
+	if (!buf)
+		return;
+
+	wpabuf_put_u8(buf, WLAN_ACTION_RADIO_MEASUREMENT);
+	wpabuf_put_u8(buf, WLAN_RRM_NEIGHBOR_REPORT_RESPONSE);
+	wpabuf_put_u8(buf, dialog_token);
+
+	hostapd_rrm_add_neigh_report_ies(hapd, buf, ssid, lci, civic, lci_max_age);
 
 	hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
 				wpabuf_head(buf), wpabuf_len(buf));
diff --git a/src/ap/rrm.h b/src/ap/rrm.h
index 02cd522..b507a8d 100644
--- a/src/ap/rrm.h
+++ b/src/ap/rrm.h
@@ -29,5 +29,8 @@  int hostapd_send_beacon_req(struct hostapd_data *hapd, const u8 *addr,
 void hostapd_rrm_beacon_req_tx_status(struct hostapd_data *hapd,
 				      const struct ieee80211_mgmt *mgmt,
 				      size_t len, int ok);
+void hostapd_rrm_add_neigh_report_ies(struct hostapd_data *hapd,
+				      struct wpabuf *buf, struct wpa_ssid_value *ssid,
+				      u8 lci, u8 civic, u16 lci_max_age);
 
 #endif /* RRM_H */