[3/3] driver_nl80211: add support for starting FTM responder

Message ID 20181203170622.9522-4-andrei.otcheretianski@intel.com
State New
Headers show
Series
  • AP: Support FTM responder configuration
Related show

Commit Message

Andrei Otcheretianski Dec. 3, 2018, 5:06 p.m.
From: Johannes Berg <johannes.berg@intel.com>

Add support for starting FTM responder when in AP mode,
this just sends the appropriate NEW/SET_BEACON command to
the driver with the LCI/civic location data.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 src/drivers/driver_nl80211.c      | 33 +++++++++++++++++++++++++++++--
 src/drivers/driver_nl80211_capa.c |  4 ++++
 2 files changed, 35 insertions(+), 2 deletions(-)

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 871a5d0b4a..deaf02019b 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -3968,7 +3968,7 @@  static int wpa_driver_nl80211_set_ap(void *priv,
 	struct wpa_driver_nl80211_data *drv = bss->drv;
 	struct nl_msg *msg;
 	u8 cmd = NL80211_CMD_NEW_BEACON;
-	int ret;
+	int ret = -ENOBUFS;
 	int beacon_set;
 	int num_suites;
 	int smps_mode;
@@ -4174,6 +4174,35 @@  static int wpa_driver_nl80211_set_ap(void *priv,
 			goto fail;
 	}
 
+	if (params->ftm_responder) {
+		struct nlattr *ftm;
+
+		if (!(drv->capa.flags & WPA_DRIVER_FLAGS_FTM_RESPONDER)) {
+			ret = -ENOTSUP;
+			goto fail;
+		}
+
+		ftm = nla_nest_start(msg, NL80211_ATTR_FTM_RESPONDER);
+		if (!ftm)
+			goto fail;
+
+		if (nla_put_flag(msg, NL80211_FTM_RESP_ATTR_ENABLED))
+			goto fail;
+
+		if (params->lci &&
+		    nla_put(msg, NL80211_FTM_RESP_ATTR_LCI,
+			    wpabuf_len(params->lci), wpabuf_head(params->lci)))
+			goto fail;
+
+		if (params->civic &&
+		    nla_put(msg, NL80211_FTM_RESP_ATTR_CIVICLOC,
+			    wpabuf_len(params->civic),
+			    wpabuf_head(params->civic)))
+			goto fail;
+
+		nla_nest_end(msg, ftm);
+	}
+
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
 	if (ret) {
 		wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
@@ -4225,7 +4254,7 @@  static int wpa_driver_nl80211_set_ap(void *priv,
 	return ret;
 fail:
 	nlmsg_free(msg);
-	return -ENOBUFS;
+	return ret;
 }
 
 
diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c
index 7b360d209a..8e2ebd2102 100644
--- a/src/drivers/driver_nl80211_capa.c
+++ b/src/drivers/driver_nl80211_capa.c
@@ -428,6 +428,10 @@  static void wiphy_info_ext_feature_flags(struct wiphy_info_data *info,
 		    NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION))
 		capa->flags |= WPA_DRIVER_FLAGS_OCE_STA;
 #endif /* CONFIG_MBO */
+
+	if (ext_feature_isset(ext_features, len,
+			      NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER))
+		capa->flags |= WPA_DRIVER_FLAGS_FTM_RESPONDER;
 }