From 10d7569efc019c6158fc65fde46d5824c5779a8e Mon Sep 17 00:00:00 2001 From: Pragya Gupta Date: Tue, 26 Jul 2016 10:30:44 +0530 Subject: [PATCH] [7570] wlbt: Support for Roam BSSID Blacklist Changes to add suport for Roam BSSID Blacklist Change-Id: I01b76bca68d088664df302cc1c2ef5a46c5bdf4b SCSC-Bug-Id: SSB-19140 Signed-off-by: Pragya Gupta --- common.h | 1 + gscan.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ wifi_hal.cpp | 1 + 3 files changed, 72 insertions(+) diff --git a/common.h b/common.h index 1047158..24176a2 100755 --- a/common.h +++ b/common.h @@ -76,6 +76,7 @@ typedef enum { SLSI_NL80211_VENDOR_SUBCMD_RESET_SIGNIFICANT_CHANGE, SLSI_NL80211_VENDOR_SUBCMD_SET_GSCAN_OUI, SLSI_NL80211_VENDOR_SUBCMD_SET_NODFS, + /*Add any GSCAN subcmds before this*/ SLSI_NL80211_VENDOR_SUBCMD_START_KEEP_ALIVE_OFFLOAD, SLSI_NL80211_VENDOR_SUBCMD_STOP_KEEP_ALIVE_OFFLOAD, SLSI_NL80211_VENDOR_SUBCMD_SET_BSSID_BLACKLIST, diff --git a/gscan.cpp b/gscan.cpp index 5de04e4..3df0790 100755 --- a/gscan.cpp +++ b/gscan.cpp @@ -83,6 +83,9 @@ typedef enum { GSCAN_ATTRIBUTE_BUCKET_EXPONENT, GSCAN_ATTRIBUTE_BUCKET_MAX_PERIOD, + GSCAN_ATTRIBUTE_NUM_BSSID, + GSCAN_ATTRIBUTE_BLACKLIST_BSSID, + GSCAN_ATTRIBUTE_MAX } GSCAN_ATTRIBUTE; @@ -1413,3 +1416,70 @@ wifi_error wifi_reset_passpoint_list(wifi_request_id id, wifi_interface_handle i wifi_unregister_cmd(handle, id); return result; } +class BssidBlacklistCommand : public WifiCommand +{ +private: + wifi_bssid_params *mParams; +public: + BssidBlacklistCommand(wifi_interface_handle handle, int id, + wifi_bssid_params *params) + : WifiCommand(handle, id), mParams(params) + { } + int createRequest(WifiRequest& request) { + int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_SET_BSSID_BLACKLIST); + if (result < 0) { + return result; + } + + nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); + result = request.put_u32(GSCAN_ATTRIBUTE_NUM_BSSID, mParams->num_bssid); + if (result < 0) { + return result; + } + + for (int i = 0; i < mParams->num_bssid; i++) { + result = request.put_addr(GSCAN_ATTRIBUTE_BLACKLIST_BSSID, mParams->bssids[i]); + if (result < 0) { + return result; + } + } + request.attr_end(data); + return result; + } + + int start() { + ALOGD("Executing bssid blacklist request, num = %d", mParams->num_bssid); + WifiRequest request(familyId(), ifaceId()); + int result = createRequest(request); + if (result < 0) { + return result; + } + + result = requestResponse(request); + if (result < 0) { + ALOGE("Failed to execute bssid blacklist request, result = %d", result); + return result; + } + + ALOGI("Successfully added %d blacklist bssids", mParams->num_bssid); + return result; + } + + + virtual int handleResponse(WifiEvent& reply) { + /* Nothing to do on response! */ + return NL_SKIP; + } +}; + +wifi_error wifi_set_bssid_blacklist(wifi_request_id id, wifi_interface_handle iface, + wifi_bssid_params params) +{ + wifi_handle handle = getWifiHandle(iface); + + BssidBlacklistCommand *cmd = new BssidBlacklistCommand(iface, id, ¶ms); + wifi_error result = (wifi_error)cmd->start(); + //release the reference of command as well + cmd->releaseRef(); + return result; +} \ No newline at end of file diff --git a/wifi_hal.cpp b/wifi_hal.cpp index 41a9131..18dfe3a 100755 --- a/wifi_hal.cpp +++ b/wifi_hal.cpp @@ -116,6 +116,7 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) fn->wifi_set_passpoint_list = wifi_set_passpoint_list; fn->wifi_reset_passpoint_list = wifi_reset_passpoint_list; #endif + fn->wifi_set_bssid_blacklist = wifi_set_bssid_blacklist; return WIFI_SUCCESS; } -- 2.20.1