From f90e9c1c8b75cb8669e8b4dfdcdece13691384aa Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Thu, 9 May 2013 20:05:01 +0300 Subject: [PATCH] nl80211: Add driver_ops for starting radar detection This patch is based on the original work by Boris Presman and Victor Goldenshtein. Channel Switch Announcement support has been removed and event handling as well as channel set handling was changed, among various other changes. Cc: Boris Presman Cc: Victor Goldenshtein Signed-hostap: Simon Wunderlich --- src/drivers/driver.h | 8 ++++++++ src/drivers/driver_nl80211.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 9b39e7e3d..167268c08 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -2655,6 +2655,14 @@ struct wpa_driver_ops { * avoid frequency conflict in single channel concurrency. */ int (*switch_channel)(void *priv, unsigned int freq); + + /** + * start_dfs_cac - Listen for radar interference on the channel + * @priv: Private driver interface data + * @freq: Frequency (in MHz) of the channel + * Returns: 0 on success, -1 on failure + */ + int (*start_dfs_cac)(void *priv, int freq); }; diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 11140f9cd..e5fb23ff0 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -9446,6 +9446,40 @@ static int nl80211_set_p2p_powersave(void *priv, int legacy_ps, int opp_ps, } +static int nl80211_start_radar_detection(void *priv, int freq) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + int ret; + + wpa_printf(MSG_DEBUG, "nl80211: Start radar detection (CAC)"); + if (!(drv->capa.flags & WPA_DRIVER_FLAGS_RADAR)) { + wpa_printf(MSG_DEBUG, "nl80211: Driver does not support radar " + "detection"); + return -1; + } + + msg = nlmsg_alloc(); + if (!msg) + return -1; + + nl80211_cmd(bss->drv, msg, 0, NL80211_CMD_RADAR_DETECT); + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex); + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); + + /* only HT20 is supported at this point */ + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_HT20); + + ret = send_and_recv_msgs(drv, msg, NULL, NULL); + if (ret == 0) + return 0; + wpa_printf(MSG_DEBUG, "nl80211: Failed to start radar detection: " + "%d (%s)", ret, strerror(-ret)); +nla_put_failure: + return -1; +} + #ifdef CONFIG_TDLS static int nl80211_send_tdls_mgmt(void *priv, const u8 *dst, u8 action_code, @@ -9878,6 +9912,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { .set_rekey_info = nl80211_set_rekey_info, .poll_client = nl80211_poll_client, .set_p2p_powersave = nl80211_set_p2p_powersave, + .start_dfs_cac = nl80211_start_radar_detection, #ifdef CONFIG_TDLS .send_tdls_mgmt = nl80211_send_tdls_mgmt, .tdls_oper = nl80211_tdls_oper,