Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Sumit Agre | 8ded125 | 2022-08-10 14:13:40 +0530 | [diff] [blame] | 15 | |
| 16 | * Changes from Qualcomm Innovation Center are provided under the following license: |
| 17 | |
| 18 | * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. |
| 19 | * SPDX-License-Identifier: BSD-3-Clause-Clear |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include <errno.h> |
| 23 | |
| 24 | #include "common.h" |
| 25 | #include "roamcommand.h" |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 26 | |
Veerendranath Jakkam | b53f700 | 2021-03-16 16:31:25 +0530 | [diff] [blame] | 27 | #define WLAN_ROAM_MAX_NUM_WHITE_LIST 8 |
Hu Wang | e963c59 | 2019-02-21 10:22:22 +0800 | [diff] [blame] | 28 | #define WLAN_ROAM_MAX_NUM_BLACK_LIST 16 |
| 29 | |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 30 | RoamCommand::RoamCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd) |
| 31 | : WifiVendorCommand(handle, id, vendor_id, subcmd) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | RoamCommand::~RoamCommand() |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | /* This function implements creation of Vendor command */ |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 40 | wifi_error RoamCommand::create() { |
| 41 | wifi_error ret = mMsg.create(NL80211_CMD_VENDOR, 0, 0); |
| 42 | if (ret != WIFI_SUCCESS) |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 43 | return ret; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 44 | |
| 45 | /* Insert the oui in the msg */ |
| 46 | ret = mMsg.put_u32(NL80211_ATTR_VENDOR_ID, mVendor_id); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 47 | if (ret != WIFI_SUCCESS) |
| 48 | return ret; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 49 | /* Insert the subcmd in the msg */ |
| 50 | ret = mMsg.put_u32(NL80211_ATTR_VENDOR_SUBCMD, mSubcmd); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 51 | if (ret != WIFI_SUCCESS) |
| 52 | return ret; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 53 | |
| 54 | ALOGV("%s: mVendor_id = %d, Subcmd = %d.", |
| 55 | __FUNCTION__, mVendor_id, mSubcmd); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 56 | return ret; |
| 57 | } |
| 58 | |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 59 | wifi_error RoamCommand::requestResponse() |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 60 | { |
| 61 | return WifiCommand::requestResponse(mMsg); |
| 62 | } |
| 63 | |
| 64 | wifi_error wifi_set_bssid_blacklist(wifi_request_id id, |
| 65 | wifi_interface_handle iface, |
| 66 | wifi_bssid_params params) |
| 67 | { |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 68 | wifi_error ret; |
| 69 | int i; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 70 | RoamCommand *roamCommand; |
| 71 | struct nlattr *nlData, *nlBssids; |
| 72 | interface_info *ifaceInfo = getIfaceInfo(iface); |
| 73 | wifi_handle wifiHandle = getWifiHandle(iface); |
| 74 | hal_info *info = getHalInfo(wifiHandle); |
| 75 | |
Hu Wang | e963c59 | 2019-02-21 10:22:22 +0800 | [diff] [blame] | 76 | if (!(info->supported_feature_set & WIFI_FEATURE_CONTROL_ROAMING)) { |
| 77 | ALOGE("%s: Roaming is not supported by driver", |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 78 | __FUNCTION__); |
| 79 | return WIFI_ERROR_NOT_SUPPORTED; |
| 80 | } |
| 81 | |
| 82 | for (i = 0; i < params.num_bssid; i++) { |
Hu Wang | 30864af | 2022-11-18 18:29:48 +0800 | [diff] [blame] | 83 | ALOGV("BSSID: %d : " MACSTR, i, MAC2STR(params.bssids[i])); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | roamCommand = |
| 87 | new RoamCommand(wifiHandle, |
| 88 | id, |
| 89 | OUI_QCA, |
| 90 | QCA_NL80211_VENDOR_SUBCMD_ROAM); |
| 91 | if (roamCommand == NULL) { |
| 92 | ALOGE("%s: Error roamCommand NULL", __FUNCTION__); |
| 93 | return WIFI_ERROR_UNKNOWN; |
| 94 | } |
| 95 | |
| 96 | /* Create the NL message. */ |
| 97 | ret = roamCommand->create(); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 98 | if (ret != WIFI_SUCCESS) |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 99 | goto cleanup; |
| 100 | |
| 101 | /* Set the interface Id of the message. */ |
| 102 | ret = roamCommand->set_iface_id(ifaceInfo->name); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 103 | if (ret != WIFI_SUCCESS) |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 104 | goto cleanup; |
| 105 | |
| 106 | /* Add the vendor specific attributes for the NL command. */ |
| 107 | nlData = roamCommand->attr_start(NL80211_ATTR_VENDOR_DATA); |
Sumit Agre | 8ded125 | 2022-08-10 14:13:40 +0530 | [diff] [blame] | 108 | if (!nlData){ |
| 109 | ret = WIFI_ERROR_UNKNOWN; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 110 | goto cleanup; |
Sumit Agre | 8ded125 | 2022-08-10 14:13:40 +0530 | [diff] [blame] | 111 | } |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 112 | |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 113 | ret = roamCommand->put_u32(QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD, |
Vamsi Krishna | b8b5cf9 | 2020-02-04 10:44:02 +0530 | [diff] [blame] | 114 | QCA_WLAN_VENDOR_ROAMING_SUBCMD_SET_BLACKLIST_BSSID); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 115 | if (ret != WIFI_SUCCESS) |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 116 | goto cleanup; |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 117 | |
| 118 | ret = roamCommand->put_u32( QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID, id); |
| 119 | if (ret != WIFI_SUCCESS) |
| 120 | goto cleanup; |
| 121 | |
| 122 | ret = roamCommand->put_u32( |
| 123 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_NUM_BSSID, |
| 124 | params.num_bssid); |
| 125 | if (ret != WIFI_SUCCESS) |
| 126 | goto cleanup; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 127 | |
| 128 | nlBssids = roamCommand->attr_start( |
| 129 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS); |
| 130 | for (i = 0; i < params.num_bssid; i++) { |
| 131 | struct nlattr *nl_ssid = roamCommand->attr_start(i); |
| 132 | |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 133 | ret = roamCommand->put_addr( |
| 134 | QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_SET_BSSID_PARAMS_BSSID, |
| 135 | (u8 *)params.bssids[i]); |
| 136 | if (ret != WIFI_SUCCESS) |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 137 | goto cleanup; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 138 | |
| 139 | roamCommand->attr_end(nl_ssid); |
| 140 | } |
| 141 | roamCommand->attr_end(nlBssids); |
| 142 | |
| 143 | roamCommand->attr_end(nlData); |
| 144 | |
| 145 | ret = roamCommand->requestResponse(); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 146 | if (ret != WIFI_SUCCESS) |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 147 | ALOGE("wifi_set_bssid_blacklist(): requestResponse Error:%d", ret); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 148 | |
| 149 | cleanup: |
| 150 | delete roamCommand; |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 151 | return ret; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 152 | |
| 153 | } |
| 154 | |
| 155 | wifi_error wifi_set_ssid_white_list(wifi_request_id id, wifi_interface_handle iface, |
| 156 | int num_networks, ssid_t *ssid_list) |
| 157 | { |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 158 | wifi_error ret; |
| 159 | int i; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 160 | RoamCommand *roamCommand; |
| 161 | struct nlattr *nlData, *nlSsids; |
| 162 | interface_info *ifaceInfo = getIfaceInfo(iface); |
| 163 | wifi_handle wifiHandle = getWifiHandle(iface); |
| 164 | char ssid[MAX_SSID_LENGTH + 1]; |
| 165 | |
| 166 | ALOGV("%s: Number of SSIDs : %d", __FUNCTION__, num_networks); |
| 167 | |
| 168 | roamCommand = new RoamCommand( |
| 169 | wifiHandle, |
| 170 | id, |
| 171 | OUI_QCA, |
| 172 | QCA_NL80211_VENDOR_SUBCMD_ROAM); |
| 173 | if (roamCommand == NULL) { |
| 174 | ALOGE("%s: Failed to create object of RoamCommand class", __FUNCTION__); |
| 175 | return WIFI_ERROR_UNKNOWN; |
| 176 | } |
| 177 | |
| 178 | /* Create the NL message. */ |
| 179 | ret = roamCommand->create(); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 180 | if (ret != WIFI_SUCCESS) { |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 181 | ALOGE("%s: Failed to create NL message, Error: %d", __FUNCTION__, ret); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 182 | goto cleanup; |
| 183 | } |
| 184 | |
| 185 | /* Set the interface Id of the message. */ |
| 186 | ret = roamCommand->set_iface_id(ifaceInfo->name); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 187 | if (ret != WIFI_SUCCESS) { |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 188 | ALOGE("%s: Failed to set interface Id of message, Error: %d", __FUNCTION__, ret); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 189 | goto cleanup; |
| 190 | } |
| 191 | |
| 192 | /* Add the vendor specific attributes for the NL command. */ |
| 193 | nlData = roamCommand->attr_start(NL80211_ATTR_VENDOR_DATA); |
| 194 | if (!nlData) { |
Sumit Agre | 8ded125 | 2022-08-10 14:13:40 +0530 | [diff] [blame] | 195 | ret = WIFI_ERROR_UNKNOWN; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 196 | goto cleanup; |
| 197 | } |
| 198 | |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 199 | ret = roamCommand->put_u32(QCA_WLAN_VENDOR_ATTR_ROAMING_SUBCMD, |
Vamsi Krishna | b8b5cf9 | 2020-02-04 10:44:02 +0530 | [diff] [blame] | 200 | QCA_WLAN_VENDOR_ROAMING_SUBCMD_SSID_WHITE_LIST); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 201 | if (ret != WIFI_SUCCESS) |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 202 | goto cleanup; |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 203 | ret = roamCommand->put_u32(QCA_WLAN_VENDOR_ATTR_ROAMING_REQ_ID, id); |
| 204 | if (ret != WIFI_SUCCESS) |
| 205 | goto cleanup; |
| 206 | ret = roamCommand->put_u32(QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_NUM_NETWORKS, |
| 207 | num_networks); |
| 208 | if (ret != WIFI_SUCCESS) |
| 209 | goto cleanup; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 210 | |
| 211 | nlSsids = roamCommand->attr_start(QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID_LIST); |
| 212 | for (i = 0; i < num_networks; i++) { |
| 213 | struct nlattr *nl_ssid = roamCommand->attr_start(i); |
| 214 | |
| 215 | memcpy(ssid, ssid_list[i].ssid_str, ssid_list[i].length); |
| 216 | ssid[ssid_list[i].length] = '\0'; |
| 217 | ALOGV("ssid[%d] : %s", i, ssid); |
| 218 | |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 219 | ret = roamCommand->put_bytes(QCA_WLAN_VENDOR_ATTR_ROAMING_PARAM_WHITE_LIST_SSID, |
| 220 | ssid, (ssid_list[i].length + 1)); |
| 221 | if (ret != WIFI_SUCCESS) { |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 222 | ALOGE("%s: Failed to add ssid atribute, Error: %d", __FUNCTION__, ret); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 223 | goto cleanup; |
| 224 | } |
| 225 | |
| 226 | roamCommand->attr_end(nl_ssid); |
| 227 | } |
| 228 | roamCommand->attr_end(nlSsids); |
| 229 | |
| 230 | roamCommand->attr_end(nlData); |
| 231 | |
| 232 | ret = roamCommand->requestResponse(); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 233 | if (ret != WIFI_SUCCESS) |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 234 | ALOGE("%s: Failed to send request, Error:%d", __FUNCTION__, ret); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 235 | |
| 236 | cleanup: |
| 237 | delete roamCommand; |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 238 | return ret; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | wifi_error wifi_get_roaming_capabilities(wifi_interface_handle iface, |
| 242 | wifi_roaming_capabilities *caps) |
| 243 | { |
| 244 | wifi_handle wifiHandle = getWifiHandle(iface); |
| 245 | hal_info *info = getHalInfo(wifiHandle); |
| 246 | |
| 247 | if (!caps) { |
| 248 | ALOGE("%s: Invalid Buffer provided. Exit", __FUNCTION__); |
| 249 | return WIFI_ERROR_INVALID_ARGS; |
| 250 | } |
| 251 | |
| 252 | if (!info) { |
| 253 | ALOGE("%s: hal_info is NULL", __FUNCTION__); |
| 254 | return WIFI_ERROR_INVALID_ARGS; |
| 255 | } |
| 256 | |
Hu Wang | e963c59 | 2019-02-21 10:22:22 +0800 | [diff] [blame] | 257 | // Per WiFi HAL design, roaming feature should have nothing to do with Gscan |
| 258 | // But for current driver impl, roaming_capa is provided as part of |
| 259 | // GSCAN_GET_CAPABILITY query, so if Gscan is not supported, roaming_capa |
| 260 | // is not set (uses initial value 0). |
| 261 | // To de-couple roaming with Gscan, set default values for roaming_capa |
| 262 | // if Gscan is not supported. |
| 263 | // TODO: removes below if driver has new API to get roaming_capa. |
| 264 | if (!(info->supported_feature_set & WIFI_FEATURE_GSCAN)) { |
| 265 | info->capa.roaming_capa.max_whitelist_size = WLAN_ROAM_MAX_NUM_WHITE_LIST; |
| 266 | info->capa.roaming_capa.max_blacklist_size = WLAN_ROAM_MAX_NUM_BLACK_LIST; |
| 267 | } |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 268 | memcpy(caps, &info->capa.roaming_capa, sizeof(wifi_roaming_capabilities)); |
| 269 | |
| 270 | return WIFI_SUCCESS; |
| 271 | } |
| 272 | |
| 273 | wifi_error wifi_configure_roaming(wifi_interface_handle iface, wifi_roaming_config *roaming_config) |
| 274 | { |
| 275 | wifi_error ret; |
| 276 | int requestId; |
| 277 | wifi_bssid_params bssid_params; |
| 278 | wifi_handle wifiHandle = getWifiHandle(iface); |
| 279 | hal_info *info = getHalInfo(wifiHandle); |
| 280 | |
| 281 | if (!roaming_config) { |
| 282 | ALOGE("%s: Invalid Buffer provided. Exit", __FUNCTION__); |
| 283 | return WIFI_ERROR_INVALID_ARGS; |
| 284 | } |
| 285 | |
| 286 | /* No request id from caller, so generate one and pass it on to the driver. |
| 287 | * Generate it randomly. |
| 288 | */ |
| 289 | requestId = get_requestid(); |
| 290 | |
| 291 | /* Set bssid blacklist */ |
| 292 | if (roaming_config->num_blacklist_bssid > info->capa.roaming_capa.max_blacklist_size) { |
| 293 | ALOGE("%s: Number of blacklist bssids(%d) provided is more than maximum blacklist bssids(%d)" |
| 294 | " supported", __FUNCTION__, roaming_config->num_blacklist_bssid, |
| 295 | info->capa.roaming_capa.max_blacklist_size); |
| 296 | return WIFI_ERROR_NOT_SUPPORTED; |
| 297 | } |
| 298 | bssid_params.num_bssid = roaming_config->num_blacklist_bssid; |
| 299 | |
| 300 | memcpy(bssid_params.bssids, roaming_config->blacklist_bssid, |
| 301 | (bssid_params.num_bssid * sizeof(mac_addr))); |
| 302 | |
| 303 | ret = wifi_set_bssid_blacklist(requestId, iface, bssid_params); |
| 304 | if (ret != WIFI_SUCCESS) { |
| 305 | ALOGE("%s: Failed to configure blacklist bssids", __FUNCTION__); |
| 306 | return WIFI_ERROR_UNKNOWN; |
| 307 | } |
| 308 | |
| 309 | /* Set ssid whitelist */ |
| 310 | if (roaming_config->num_whitelist_ssid > info->capa.roaming_capa.max_whitelist_size) { |
| 311 | ALOGE("%s: Number of whitelist ssid(%d) provided is more than maximum whitelist ssids(%d) " |
| 312 | "supported", __FUNCTION__, roaming_config->num_whitelist_ssid, |
| 313 | info->capa.roaming_capa.max_whitelist_size); |
| 314 | return WIFI_ERROR_NOT_SUPPORTED; |
| 315 | } |
Veerendranath Jakkam | 945c154 | 2019-12-05 22:43:17 +0530 | [diff] [blame] | 316 | |
| 317 | // Framework is always sending SSID length as 32 though null terminated lengths |
| 318 | // are lesser. Thus update correct lengths before sending to driver. |
| 319 | for (int i = 0; i < roaming_config->num_whitelist_ssid; i++) { |
| 320 | int j; |
| 321 | |
| 322 | for (j = 0; j < roaming_config->whitelist_ssid[i].length; j++) { |
| 323 | if (roaming_config->whitelist_ssid[i].ssid_str[j] == '\0') |
| 324 | break; |
| 325 | } |
| 326 | |
| 327 | if (roaming_config->whitelist_ssid[i].length == j) |
| 328 | continue; |
| 329 | |
| 330 | ALOGI("%s: ssid_str %s reported length = %d , null terminated length = %d", __FUNCTION__, |
| 331 | roaming_config->whitelist_ssid[i].ssid_str, |
| 332 | roaming_config->whitelist_ssid[i].length, j); |
| 333 | roaming_config->whitelist_ssid[i].length = j; |
| 334 | } |
| 335 | |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 336 | ret = wifi_set_ssid_white_list(requestId, iface, roaming_config->num_whitelist_ssid, |
| 337 | roaming_config->whitelist_ssid); |
| 338 | if (ret != WIFI_SUCCESS) |
| 339 | ALOGE("%s: Failed to configure whitelist ssids", __FUNCTION__); |
| 340 | |
| 341 | return ret; |
| 342 | } |
| 343 | |
| 344 | /* Enable/disable firmware roaming */ |
| 345 | wifi_error wifi_enable_firmware_roaming(wifi_interface_handle iface, fw_roaming_state_t state) |
| 346 | { |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 347 | int requestId; |
| 348 | wifi_error ret; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 349 | RoamCommand *roamCommand; |
| 350 | struct nlattr *nlData; |
| 351 | interface_info *ifaceInfo = getIfaceInfo(iface); |
| 352 | wifi_handle wifiHandle = getWifiHandle(iface); |
| 353 | qca_roaming_policy policy; |
| 354 | |
| 355 | ALOGV("%s: set firmware roam state : %d", __FUNCTION__, state); |
| 356 | |
| 357 | if (state == ROAMING_ENABLE) { |
| 358 | policy = QCA_ROAMING_ALLOWED_WITHIN_ESS; |
| 359 | } else if(state == ROAMING_DISABLE) { |
| 360 | policy = QCA_ROAMING_NOT_ALLOWED; |
| 361 | } else { |
| 362 | ALOGE("%s: Invalid state provided: %d. Exit \n", __FUNCTION__, state); |
| 363 | return WIFI_ERROR_INVALID_ARGS; |
| 364 | } |
| 365 | |
| 366 | /* No request id from caller, so generate one and pass it on to the driver. |
| 367 | * Generate it randomly. |
| 368 | */ |
| 369 | requestId = get_requestid(); |
| 370 | |
| 371 | roamCommand = |
| 372 | new RoamCommand(wifiHandle, |
| 373 | requestId, |
| 374 | OUI_QCA, |
| 375 | QCA_NL80211_VENDOR_SUBCMD_ROAMING); |
| 376 | if (roamCommand == NULL) { |
| 377 | ALOGE("%s: Failed to create object of RoamCommand class", __FUNCTION__); |
| 378 | return WIFI_ERROR_UNKNOWN; |
| 379 | } |
| 380 | |
| 381 | /* Create the NL message. */ |
| 382 | ret = roamCommand->create(); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 383 | if (ret != WIFI_SUCCESS) { |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 384 | ALOGE("%s: Failed to create NL message, Error: %d", __FUNCTION__, ret); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 385 | goto cleanup; |
| 386 | } |
| 387 | |
| 388 | /* Set the interface Id of the message. */ |
| 389 | ret = roamCommand->set_iface_id(ifaceInfo->name); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 390 | if (ret != WIFI_SUCCESS) { |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 391 | ALOGE("%s: Failed to set interface Id of message, Error: %d", __FUNCTION__, ret); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 392 | goto cleanup; |
| 393 | } |
| 394 | |
| 395 | /* Add the vendor specific attributes for the NL command. */ |
| 396 | nlData = roamCommand->attr_start(NL80211_ATTR_VENDOR_DATA); |
| 397 | if (!nlData) { |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 398 | ret = WIFI_ERROR_UNKNOWN; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 399 | goto cleanup; |
| 400 | } |
| 401 | |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 402 | ret = roamCommand->put_u32(QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY, policy); |
| 403 | if (ret != WIFI_SUCCESS) { |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 404 | ALOGE("%s: Failed to add roaming policy atribute, Error: %d", __FUNCTION__, ret); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 405 | goto cleanup; |
| 406 | } |
| 407 | |
| 408 | roamCommand->attr_end(nlData); |
| 409 | |
| 410 | ret = roamCommand->requestResponse(); |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 411 | if (ret != WIFI_SUCCESS) |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 412 | ALOGE("%s: Failed to send request, Error:%d", __FUNCTION__, ret); |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 413 | |
| 414 | cleanup: |
| 415 | delete roamCommand; |
Srinivas Dasari | 30b13c7 | 2017-08-08 15:44:23 +0530 | [diff] [blame] | 416 | return ret; |
Subhani Shaik | 4a7be10 | 2016-12-16 16:16:18 +0530 | [diff] [blame] | 417 | } |