[9610] wlbt: Proper fix for Android O Blacklist (wifihal)
authorSrishti <srishti.p@samsung.com>
Fri, 3 Nov 2017 10:50:39 +0000 (16:20 +0530)
committerTarun Karela <t.karela@samsung.com>
Mon, 4 Jun 2018 09:40:47 +0000 (10:40 +0100)
Wifi Hal Changes for implementation of wifi_set_bssid_blacklist
which caused problem in building Android O.

Change-Id: I0ef9bd5d8fa9d1bf21f790d3f287ce646f5ea66c
SCSC-Bug-Id: SSB-33754
Signed-off-by: Srishti <srishti.p@samsung.com>
Android.mk
common.h
gscan.cpp
roam.cpp [new file with mode: 0755]
wifi_hal.cpp

index 0a8d3254ce966451038c4cfc8bed44a0db4a9744..bb391cef2cae2f1c34077a19faaa0c5c4266ff23 100755 (executable)
@@ -26,7 +26,8 @@ LOCAL_SRC_FILES := \
        cpp_bindings.cpp \
        gscan.cpp \
        link_layer_stats.cpp \
-       wifi_offload.cpp
+       wifi_offload.cpp \
+       roam.cpp
 
 LOCAL_MODULE := libwifi-hal-slsi
 
index 679919673a694756f5e79f8435b7d285f93ca798..ff3f32e7ee5ce7c6e947df45ac3714ec6b54a32f 100755 (executable)
--- a/common.h
+++ b/common.h
 #define DEFAULT_CMD_SIZE        (64)
 #define DOT11_OUI_LEN             3
 
+typedef struct {
+       int num_bssid;
+       mac_addr bssids[MAX_BLACKLIST_BSSID];
+} wifi_bssid_params;
+
 /*
  Vendor OUI - This is a unique identifier that identifies organization. Lets
  code Android specific functions with Google OUI; although vendors can do more
 const uint32_t GOOGLE_OUI = 0x001A11;
 /* TODO: define vendor OUI here */
 
+typedef enum {
+
+    GSCAN_ATTRIBUTE_NUM_BUCKETS = 10,
+    GSCAN_ATTRIBUTE_BASE_PERIOD,
+    GSCAN_ATTRIBUTE_BUCKETS_BAND,
+    GSCAN_ATTRIBUTE_BUCKET_ID,
+    GSCAN_ATTRIBUTE_BUCKET_PERIOD,
+    GSCAN_ATTRIBUTE_BUCKET_NUM_CHANNELS,
+    GSCAN_ATTRIBUTE_BUCKET_CHANNELS,
+    GSCAN_ATTRIBUTE_NUM_AP_PER_SCAN,
+    GSCAN_ATTRIBUTE_REPORT_THRESHOLD,
+    GSCAN_ATTRIBUTE_NUM_SCANS_TO_CACHE,
+    GSCAN_ATTRIBUTE_REPORT_THRESHOLD_NUM_SCANS,
+    GSCAN_ATTRIBUTE_BAND = GSCAN_ATTRIBUTE_BUCKETS_BAND,
+
+    GSCAN_ATTRIBUTE_ENABLE_FEATURE = 20,
+    GSCAN_ATTRIBUTE_SCAN_RESULTS_COMPLETE,              /* indicates no more results */
+    GSCAN_ATTRIBUTE_REPORT_EVENTS,
+
+    /* remaining reserved for additional attributes */
+    GSCAN_ATTRIBUTE_NUM_OF_RESULTS = 30,
+    GSCAN_ATTRIBUTE_SCAN_RESULTS,                       /* flat array of wifi_scan_result */
+    GSCAN_ATTRIBUTE_NUM_CHANNELS,
+    GSCAN_ATTRIBUTE_CHANNEL_LIST,
+    GSCAN_ATTRIBUTE_SCAN_ID,
+    GSCAN_ATTRIBUTE_SCAN_FLAGS,
+    GSCAN_ATTRIBUTE_SCAN_BUCKET_BIT,
+
+    /* remaining reserved for additional attributes */
+
+    GSCAN_ATTRIBUTE_SSID = 40,
+    GSCAN_ATTRIBUTE_BSSID,
+    GSCAN_ATTRIBUTE_CHANNEL,
+    GSCAN_ATTRIBUTE_RSSI,
+    GSCAN_ATTRIBUTE_TIMESTAMP,
+    GSCAN_ATTRIBUTE_RTT,
+    GSCAN_ATTRIBUTE_RTTSD,
+
+    /* remaining reserved for additional attributes */
+
+    GSCAN_ATTRIBUTE_HOTLIST_BSSIDS = 50,
+    GSCAN_ATTRIBUTE_RSSI_LOW,
+    GSCAN_ATTRIBUTE_RSSI_HIGH,
+    GSCAN_ATTRIBUTE_HOTLIST_ELEM,
+    GSCAN_ATTRIBUTE_HOTLIST_FLUSH,
+    GSCAN_ATTRIBUTE_CHANNEL_NUMBER,
+
+    /* remaining reserved for additional attributes */
+    GSCAN_ATTRIBUTE_RSSI_SAMPLE_SIZE = 60,
+    GSCAN_ATTRIBUTE_LOST_AP_SAMPLE_SIZE,
+    GSCAN_ATTRIBUTE_MIN_BREACHING,
+    GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_BSSIDS,
+
+    GSCAN_ATTRIBUTE_BUCKET_STEP_COUNT = 70,
+    GSCAN_ATTRIBUTE_BUCKET_EXPONENT,
+    GSCAN_ATTRIBUTE_BUCKET_MAX_PERIOD,
+
+    GSCAN_ATTRIBUTE_NUM_BSSID,
+    GSCAN_ATTRIBUTE_BLACKLIST_BSSID,
+
+    GSCAN_ATTRIBUTE_MAX
+
+} GSCAN_ATTRIBUTE;
 
 /*
  This enum defines ranges for various commands; commands themselves
index 90989f96eefb28e623dc874dd535d3ae4b059336..3fb6e38e1274856358466fb66f5a701e10433b9b 100755 (executable)
--- a/gscan.cpp
+++ b/gscan.cpp
@@ -1423,72 +1423,3 @@ wifi_error wifi_reset_passpoint_list(wifi_request_id id, wifi_interface_handle i
     wifi_unregister_cmd(handle, id);
     return result;
 }
-
-#if 0 // TODO: (IP) removed to make it build
-
-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() {
-        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;
-        }
-
-        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, &params);
-    wifi_error result = (wifi_error)cmd->start();
-    //release the reference of command as well
-    cmd->releaseRef();
-    return result;
-}
-#endif
diff --git a/roam.cpp b/roam.cpp
new file mode 100755 (executable)
index 0000000..2f5e8a1
--- /dev/null
+++ b/roam.cpp
@@ -0,0 +1,130 @@
+#include <stdint.h>\r
+#include <stddef.h>\r
+#include <fcntl.h>\r
+#include <sys/socket.h>\r
+#include <netlink/genl/genl.h>\r
+#include <netlink/genl/family.h>\r
+#include <netlink/genl/ctrl.h>\r
+#include <linux/rtnetlink.h>\r
+#include <netpacket/packet.h>\r
+#include <linux/filter.h>\r
+#include <linux/errqueue.h>\r
+\r
+#include <linux/pkt_sched.h>\r
+#include <netlink/object-api.h>\r
+#include <netlink/netlink.h>\r
+#include <netlink/socket.h>\r
+#include <netlink/handlers.h>\r
+\r
+#include "sync.h"\r
+\r
+#define LOG_TAG  "WifiHAL"\r
+\r
+#include <utils/Log.h>\r
+\r
+#include "wifi_hal.h"\r
+#include "common.h"\r
+#include "cpp_bindings.h"\r
+\r
+#define REQUEST_ID_MAX 1000\r
+#define get_requestid() ((arc4random()%REQUEST_ID_MAX) + 1)\r
+\r
+class BssidBlacklistCommand : public WifiCommand\r
+{\r
+private:\r
+    wifi_bssid_params *mParams;\r
+public:\r
+    BssidBlacklistCommand(wifi_interface_handle handle, int id,\r
+            wifi_bssid_params *params)\r
+        : WifiCommand(handle, id), mParams(params)\r
+    { }\r
+     int createRequest(WifiRequest& request) {\r
+        int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_SET_BSSID_BLACKLIST);\r
+        if (result < 0) {\r
+            return result;\r
+        }\r
+\r
+        nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);\r
+        result = request.put_u32(GSCAN_ATTRIBUTE_NUM_BSSID, mParams->num_bssid);\r
+        if (result < 0) {\r
+            return result;\r
+        }\r
+\r
+        for (int i = 0; i < mParams->num_bssid; i++) {\r
+            result = request.put_addr(GSCAN_ATTRIBUTE_BLACKLIST_BSSID, mParams->bssids[i]);\r
+            if (result < 0) {\r
+                return result;\r
+            }\r
+        }\r
+        request.attr_end(data);\r
+        return result;\r
+    }\r
+\r
+    int start() {\r
+        WifiRequest request(familyId(), ifaceId());\r
+        int result = createRequest(request);\r
+        if (result < 0) {\r
+            return result;\r
+        }\r
+\r
+        result = requestResponse(request);\r
+        if (result < 0) {\r
+            ALOGE("Failed to execute bssid blacklist request, result = %d", result);\r
+            return result;\r
+        }\r
+\r
+        return result;\r
+    }\r
+\r
+\r
+    virtual int handleResponse(WifiEvent& reply) {\r
+        /* Nothing to do on response! */\r
+        return NL_SKIP;\r
+    }\r
+};\r
+\r
+wifi_error wifi_set_bssid_blacklist(wifi_request_id id, wifi_interface_handle iface,\r
+        wifi_bssid_params params)\r
+{\r
+    BssidBlacklistCommand *cmd = new BssidBlacklistCommand(iface, id, &params);\r
+    wifi_error result = (wifi_error)cmd->start();\r
+    //release the reference of command as well\r
+    cmd->releaseRef();\r
+    return result;\r
+}\r
+\r
+/*to be implemented*/\r
+wifi_error wifi_get_roaming_capabilities(wifi_interface_handle iface,\r
+                                         wifi_roaming_capabilities *caps);\r
+\r
+/*to be implemented*/\r
+wifi_error wifi_enable_firmware_roaming(wifi_interface_handle handle,\r
+                                        fw_roaming_state_t state);\r
+\r
+wifi_error wifi_configure_roaming(wifi_interface_handle iface, wifi_roaming_config *roaming_config)\r
+{\r
+    wifi_error ret;\r
+    int requestId;\r
+    wifi_bssid_params bssid_params;\r
+    wifi_handle wifiHandle = getWifiHandle(iface);\r
+\r
+    if (!roaming_config) {\r
+        ALOGE("%s: Invalid Buffer provided. Exit", __FUNCTION__);\r
+        return WIFI_ERROR_INVALID_ARGS;\r
+   }\r
+\r
+    /* Generate request id randomly*/\r
+   requestId = get_requestid();\r
+   bssid_params.num_bssid = roaming_config->num_blacklist_bssid;\r
+\r
+   memcpy(bssid_params.bssids, roaming_config->blacklist_bssid,\r
+           (bssid_params.num_bssid * sizeof(mac_addr)));\r
+\r
+    ret = wifi_set_bssid_blacklist(requestId, iface, bssid_params);\r
+    if (ret != WIFI_SUCCESS) {\r
+        ALOGE("%s: Failed to configure blacklist bssids", __FUNCTION__);\r
+        return WIFI_ERROR_UNKNOWN;\r
+    }\r
+\r
+    return ret;\r
+}\r
index 7a79286b7831c9e8446a737dd57f71405f4ee331..04474d29d03bb8dcc8764f514945379ea8777c30 100755 (executable)
@@ -30,6 +30,7 @@
 #include "wifi_hal.h"
 #include "common.h"
 #include "cpp_bindings.h"
+#include "roam.h"
 
 
 #define WIFI_HAL_CMD_SOCK_PORT       644
@@ -123,13 +124,13 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn)
     fn->wifi_reset_epno_list = wifi_reset_epno_list;
     fn->wifi_set_passpoint_list = wifi_set_passpoint_list;
     fn->wifi_reset_passpoint_list = wifi_reset_passpoint_list;
-//    fn->wifi_set_bssid_blacklist = wifi_set_bssid_blacklist;  // TODO: (IP) make it build
     fn->wifi_start_rssi_monitoring = wifi_start_rssi_monitoring;
     fn->wifi_stop_rssi_monitoring = wifi_stop_rssi_monitoring;
     fn->wifi_set_link_stats = wifi_set_link_stats;
     fn->wifi_get_link_stats = wifi_get_link_stats;
     fn->wifi_clear_link_stats = wifi_clear_link_stats;
     fn->wifi_set_country_code = wifi_set_country_code;
+    fn->wifi_configure_roaming = wifi_configure_roaming;
 
     return WIFI_SUCCESS;
 }