aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Spinadel <david.spinadel@intel.com>2016-04-06 16:42:11 (GMT)
committerJouni Malinen <j@w1.fi>2016-04-17 09:29:12 (GMT)
commitf4f185a224ffde55802ce33a856dd3ddf929dfcf (patch)
tree03eceb1be6d1844d7e6ca86ac39b89cbbbb272fe /src
parent629e1804da3bb6eed347b51922fc2fe6aa05f2e5 (diff)
downloadhostap-f4f185a224ffde55802ce33a856dd3ddf929dfcf.zip
hostap-f4f185a224ffde55802ce33a856dd3ddf929dfcf.tar.gz
hostap-f4f185a224ffde55802ce33a856dd3ddf929dfcf.tar.bz2
hostapd: Add LCI request
Add a hostapd control interface command REQ_LCI to request LCI from an associated station using radio measurement. Signed-off-by: David Spinadel <david.spinadel@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/ap/hostapd.c3
-rw-r--r--src/ap/hostapd.h3
-rw-r--r--src/ap/rrm.c154
-rw-r--r--src/ap/rrm.h2
-rw-r--r--src/common/ieee802_11_defs.h2
5 files changed, 163 insertions, 1 deletions
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 336cfca..42c1aaa 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -44,6 +44,7 @@
#include "dhcp_snoop.h"
#include "ndisc_snoop.h"
#include "neighbor_db.h"
+#include "rrm.h"
static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason);
@@ -337,7 +338,7 @@ static void hostapd_free_hapd_data(struct hostapd_data *hapd)
hapd->mesh_pending_auth = NULL;
#endif /* CONFIG_MESH */
- hostpad_free_neighbor_db(hapd);
+ hostapd_clean_rrm(hapd);
}
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index a06b727..76b0ca6 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -298,6 +298,9 @@ struct hostapd_data {
#endif /* CONFIG_MBO */
struct dl_list nr_db;
+
+ u8 lci_req_token;
+ unsigned int lci_req_active:1;
};
diff --git a/src/ap/rrm.c b/src/ap/rrm.c
index 92985dc..8548ea4 100644
--- a/src/ap/rrm.c
+++ b/src/ap/rrm.c
@@ -12,8 +12,72 @@
#include "utils/common.h"
#include "hostapd.h"
#include "ap_drv_ops.h"
+#include "sta_info.h"
+#include "eloop.h"
+#include "neighbor_db.h"
#include "rrm.h"
+#define HOSTAPD_RRM_REQUEST_TIMEOUT 5
+
+
+static void hostapd_lci_rep_timeout_handler(void *eloop_data, void *user_ctx)
+{
+ struct hostapd_data *hapd = eloop_data;
+
+ wpa_printf(MSG_DEBUG, "RRM: LCI request (token %u) timed out",
+ hapd->lci_req_token);
+ hapd->lci_req_active = 0;
+}
+
+
+static void hostapd_handle_lci_report(struct hostapd_data *hapd, u8 token,
+ const u8 *pos, size_t len)
+{
+ if (!hapd->lci_req_active || hapd->lci_req_token != token) {
+ wpa_printf(MSG_DEBUG, "Unexpected LCI report, token %u", token);
+ return;
+ }
+
+ hapd->lci_req_active = 0;
+ eloop_cancel_timeout(hostapd_lci_rep_timeout_handler, hapd, NULL);
+ wpa_printf(MSG_DEBUG, "LCI report token %u len %zu", token, len);
+}
+
+
+static void hostapd_handle_radio_msmt_report(struct hostapd_data *hapd,
+ const u8 *buf, size_t len)
+{
+ const struct ieee80211_mgmt *mgmt = (const struct ieee80211_mgmt *) buf;
+ const u8 *pos, *ie, *end;
+ u8 token;
+
+ end = buf + len;
+ token = mgmt->u.action.u.rrm.dialog_token;
+ pos = mgmt->u.action.u.rrm.variable;
+
+ while ((ie = get_ie(pos, end - pos, WLAN_EID_MEASURE_REPORT))) {
+ if (ie[1] < 5) {
+ wpa_printf(MSG_DEBUG, "Bad Measurement Report element");
+ break;
+ }
+
+ wpa_printf(MSG_DEBUG, "Measurement report type %u", ie[4]);
+
+ switch (ie[4]) {
+ case MEASURE_TYPE_LCI:
+ hostapd_handle_lci_report(hapd, token, ie + 2, ie[1]);
+ break;
+ default:
+ wpa_printf(MSG_DEBUG,
+ "Measurement report type %u is not supported",
+ ie[4]);
+ break;
+ }
+
+ pos = ie + ie[1] + 2;
+ }
+}
+
static u16 hostapd_parse_location_lci_req_age(const u8 *buf, size_t len)
{
@@ -229,6 +293,9 @@ void hostapd_handle_radio_measurement(struct hostapd_data *hapd,
mgmt->u.action.u.rrm.action, MAC2STR(mgmt->sa));
switch (mgmt->u.action.u.rrm.action) {
+ case WLAN_RRM_RADIO_MEASUREMENT_REPORT:
+ hostapd_handle_radio_msmt_report(hapd, buf, len);
+ break;
case WLAN_RRM_NEIGHBOR_REPORT_REQUEST:
hostapd_handle_nei_report_req(hapd, buf, len);
break;
@@ -238,3 +305,90 @@ void hostapd_handle_radio_measurement(struct hostapd_data *hapd,
break;
}
}
+
+
+int hostapd_send_lci_req(struct hostapd_data *hapd, const u8 *addr)
+{
+ struct wpabuf *buf;
+ struct sta_info *sta = ap_get_sta(hapd, addr);
+ int ret;
+
+ if (!sta) {
+ wpa_printf(MSG_INFO,
+ "Request LCI: Destination address is not in station list");
+ return -1;
+ }
+
+ if (!(sta->flags & WLAN_STA_AUTHORIZED)) {
+ wpa_printf(MSG_INFO,
+ "Request LCI: Destination address is not connected");
+ return -1;
+ }
+
+ if (!(sta->rrm_enabled_capa[1] & WLAN_RRM_CAPS_LCI_MEASUREMENT)) {
+ wpa_printf(MSG_INFO,
+ "Request LCI: Station does not support LCI in RRM");
+ return -1;
+ }
+
+ if (hapd->lci_req_active) {
+ wpa_printf(MSG_DEBUG,
+ "Request LCI: LCI request is already in process, overriding");
+ hapd->lci_req_active = 0;
+ eloop_cancel_timeout(hostapd_lci_rep_timeout_handler, hapd,
+ NULL);
+ }
+
+ /* Measurement request (5) + Measurement element with LCI (10) */
+ buf = wpabuf_alloc(5 + 10);
+ if (!buf)
+ return -1;
+
+ hapd->lci_req_token++;
+ /* For wraparounds - the token must be nonzero */
+ if (!hapd->lci_req_token)
+ hapd->lci_req_token++;
+
+ wpabuf_put_u8(buf, WLAN_ACTION_RADIO_MEASUREMENT);
+ wpabuf_put_u8(buf, WLAN_RRM_RADIO_MEASUREMENT_REQUEST);
+ wpabuf_put_u8(buf, hapd->lci_req_token);
+ wpabuf_put_le16(buf, 0); /* Number of repetitions */
+
+ wpabuf_put_u8(buf, WLAN_EID_MEASURE_REQUEST);
+ wpabuf_put_u8(buf, 3 + 1 + 4);
+
+ wpabuf_put_u8(buf, 1); /* Measurement Token */
+ /*
+ * Parallel and Enable bits are 0, Duration, Request, and Report are
+ * reserved.
+ */
+ wpabuf_put_u8(buf, 0);
+ wpabuf_put_u8(buf, MEASURE_TYPE_LCI);
+
+ wpabuf_put_u8(buf, LOCATION_SUBJECT_REMOTE);
+
+ wpabuf_put_u8(buf, LCI_REQ_SUBELEM_MAX_AGE);
+ wpabuf_put_u8(buf, 2);
+ wpabuf_put_le16(buf, 0xffff);
+
+ ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
+ wpabuf_head(buf), wpabuf_len(buf));
+ wpabuf_free(buf);
+ if (ret)
+ return ret;
+
+ hapd->lci_req_active = 1;
+
+ eloop_register_timeout(HOSTAPD_RRM_REQUEST_TIMEOUT, 0,
+ hostapd_lci_rep_timeout_handler, hapd, NULL);
+
+ return 0;
+}
+
+
+void hostapd_clean_rrm(struct hostapd_data *hapd)
+{
+ hostpad_free_neighbor_db(hapd);
+ eloop_cancel_timeout(hostapd_lci_rep_timeout_handler, hapd, NULL);
+ hapd->lci_req_active = 0;
+}
diff --git a/src/ap/rrm.h b/src/ap/rrm.h
index 3df49ab..f3e15bd 100644
--- a/src/ap/rrm.h
+++ b/src/ap/rrm.h
@@ -12,5 +12,7 @@
void hostapd_handle_radio_measurement(struct hostapd_data *hapd,
const u8 *buf, size_t len);
+int hostapd_send_lci_req(struct hostapd_data *hapd, const u8 *addr);
+void hostapd_clean_rrm(struct hostapd_data *hapd);
#endif /* RRM_H */
diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index a713764..cbf8336 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -366,6 +366,8 @@
/* byte 1 (out of 5) */
#define WLAN_RRM_CAPS_LINK_MEASUREMENT BIT(0)
#define WLAN_RRM_CAPS_NEIGHBOR_REPORT BIT(1)
+/* byte 2 (out of 5) */
+#define WLAN_RRM_CAPS_LCI_MEASUREMENT BIT(4)
/* Timeout Interval Type */
#define WLAN_TIMEOUT_REASSOC_DEADLINE 1