HAL: ePNO and Gscan enhancements [DO NOT MERGE]
Ashwin [Fri, 12 Feb 2016 00:15:35 +0000 (16:15 -0800)]
1. Added support for ePNO Android N changes.
2. Gscan enhancements - added scan channel bucket and handling
the struct changes for results from driver, will need compatible
driver changes.

Change-Id: I804ffc8a8e1bf2adff04684d22cfd862f6fea927
Signed-off-by: Ashwin <ashwin.bhat@broadcom.com>

bcmdhd/wifi_hal/common.h
bcmdhd/wifi_hal/gscan.cpp

index 118e0fc..27f93f8 100644 (file)
@@ -15,7 +15,9 @@
 #define DEFAULT_EVENT_CB_SIZE   (64)
 #define DEFAULT_CMD_SIZE        (64)
 #define DOT11_OUI_LEN             3
+#define DOT11_MAX_SSID_LEN        32
 
+#define MAX_PROBE_RESP_IE_LEN      2048
 /*
  Vendor OUI - This is a unique identifier that identifies organization. Lets
  code Android specific functions with Google OUI; although vendors can do more
@@ -179,7 +181,7 @@ typedef struct {
 #define PNO_SSID_LOST    0x2
 
 typedef struct wifi_pno_result {
-    unsigned char ssid[32];
+    unsigned char ssid[DOT11_MAX_SSID_LEN];
     unsigned char ssid_len;
     signed char rssi;
     u16 channel;
@@ -187,6 +189,26 @@ typedef struct wifi_pno_result {
     mac_addr  bssid;
 } wifi_pno_result_t;
 
+typedef struct wifi_gscan_result {
+    u64 ts;                           // Time of discovery
+    u8 ssid[DOT11_MAX_SSID_LEN+1];    // null terminated
+    mac_addr bssid;                   // BSSID
+    u32 channel;                      // channel frequency in MHz
+    s32 rssi;                         // in db
+    u64 rtt;                          // in nanoseconds
+    u64 rtt_sd;                       // standard deviation in rtt
+    u16 beacon_period;                // units are Kusec
+    u16 capability;                   // Capability information
+    u32 pad;
+} wifi_gscan_result_t;
+
+typedef struct wifi_gscan_full_result {
+    wifi_gscan_result_t fixed;
+    u32 scan_ch_bucket;              // scan chbucket bitmask
+    u32 ie_length;                   // byte length of Information Elements
+    u8  ie_data[1];                  // IE data to follow
+} wifi_gscan_full_result_t;
+
 wifi_error wifi_register_handler(wifi_handle handle, int cmd, nl_recvmsg_msg_cb_t func, void *arg);
 wifi_error wifi_register_vendor_handler(wifi_handle handle,
             uint32_t id, int subcmd, nl_recvmsg_msg_cb_t func, void *arg);
index 0fa9417..fe8a3c3 100644 (file)
@@ -56,7 +56,7 @@ typedef enum {
     GSCAN_ATTRIBUTE_AP_FLAGS,                           /* flags on significant change event */
     GSCAN_ATTRIBUTE_NUM_CHANNELS,
     GSCAN_ATTRIBUTE_CHANNEL_LIST,
-
+    GSCAN_ATTRIBUTE_CH_BUCKET_BITMASK,
     /* remaining reserved for additional attributes */
 
     GSCAN_ATTRIBUTE_SSID = 40,
@@ -132,6 +132,15 @@ typedef enum {
     GSCAN_ATTRIBUTE_BUCKET_STEP_COUNT = 120,
     GSCAN_ATTRIBUTE_BUCKET_MAX_PERIOD,
 
+    /* ePNO cfg */
+    GSCAN_ATTRIBUTE_EPNO_5G_RSSI_THR = 130,
+    GSCAN_ATTRIBUTE_EPNO_2G_RSSI_THR,
+    GSCAN_ATTRIBUTE_EPNO_INIT_SCORE_MAX,
+    GSCAN_ATTRIBUTE_EPNO_CUR_CONN_BONUS,
+    GSCAN_ATTRIBUTE_EPNO_SAME_NETWORK_BONUS,
+    GSCAN_ATTRIBUTE_EPNO_SECURE_BONUS,
+    GSCAN_ATTRIBUTE_EPNO_5G_BONUS,
+
     GSCAN_ATTRIBUTE_MAX
 
 } GSCAN_ATTRIBUTE;
@@ -143,6 +152,21 @@ wifi_error wifi_enable_full_scan_results(wifi_request_id id, wifi_interface_hand
 wifi_error wifi_disable_full_scan_results(wifi_request_id id, wifi_interface_handle iface);
 int wifi_handle_full_scan_event(wifi_request_id id, WifiEvent& event,
          wifi_scan_result_handler handler);
+void convert_to_hal_result(wifi_scan_result *to, wifi_gscan_result_t *from);
+
+
+void convert_to_hal_result(wifi_scan_result *to, wifi_gscan_result_t *from)
+{
+    to->ts = from->ts;
+    to->channel = from->channel;
+    to->rssi = from->rssi;
+    to->rtt = from->rtt;
+    to->rtt_sd = from->rtt_sd;
+    to->beacon_period = from->beacon_period;
+    to->capability = from->capability;
+    memcpy(to->ssid, from->ssid, (DOT11_MAX_SSID_LEN+1));
+    memcpy(&to->bssid, &from->bssid, sizeof(mac_addr));
+}
 
 /////////////////////////////////////////////////////////////////////////////
 
@@ -632,28 +656,17 @@ public:
         int len = event.get_vendor_data_len();
         int event_id = event.get_vendor_subcmd();
 
-        if (event_id == GSCAN_EVENT_COMPLETE_SCAN) {
+        if ((event_id == GSCAN_EVENT_COMPLETE_SCAN) ||
+            (event_id == GSCAN_EVENT_SCAN_RESULTS_AVAILABLE)) {
             if (vendor_data == NULL || len != 4) {
-                ALOGI("Scan complete type not mentioned!");
+                ALOGI("Bad event data!");
                 return NL_SKIP;
             }
             wifi_scan_event evt_type;
-
             evt_type = (wifi_scan_event) event.get_u32(NL80211_ATTR_VENDOR_DATA);
-            ALOGV("Scan complete: Received event type %d", evt_type);
-            if(*mHandler.on_scan_event)
-                (*mHandler.on_scan_event)(evt_type, evt_type);
-        } else if (event_id == GSCAN_EVENT_SCAN_RESULTS_AVAILABLE) {
-
-            if (vendor_data == NULL || len != 4) {
-                ALOGI("No scan results found");
-                return NL_SKIP;
-            }
-
-            int num = event.get_u32(NL80211_ATTR_VENDOR_DATA);
-            ALOGV("Found %d scan results", num);
+            ALOGV("Received event type %d", evt_type);
             if(*mHandler.on_scan_event)
-                (*mHandler.on_scan_event)(id(), WIFI_SCAN_RESULTS_AVAILABLE);
+                (*mHandler.on_scan_event)(id(), evt_type);
         } else if (event_id == GSCAN_EVENT_FULL_SCAN_RESULTS) {
             wifi_handle_full_scan_event(id(), event, mHandler);
         }
@@ -729,21 +742,33 @@ int wifi_handle_full_scan_event(
     nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
     unsigned int len = event.get_vendor_data_len();
 
-    if (vendor_data == NULL || len < sizeof(wifi_scan_result)) {
+    if (vendor_data == NULL || len < sizeof(wifi_gscan_full_result_t)) {
         ALOGI("Full scan results: No scan results found");
         return NL_SKIP;
     }
 
-    wifi_scan_result *result = (wifi_scan_result *)event.get_vendor_data();
-
-    if (handler.on_full_scan_result)
-        (*handler.on_full_scan_result)(id, result, 0);
-
-    ALOGV("Full scan result: %-32s %02x:%02x:%02x:%02x:%02x:%02x %d %d %lld %lld %lld\n",
-        result->ssid, result->bssid[0], result->bssid[1], result->bssid[2], result->bssid[3],
-        result->bssid[4], result->bssid[5], result->rssi, result->channel, result->ts,
-        result->rtt, result->rtt_sd);
+    wifi_gscan_full_result_t *drv_res = (wifi_gscan_full_result_t *)event.get_vendor_data();
+    /* To protect against corrupted data, put a ceiling */
+    int ie_len = min(MAX_PROBE_RESP_IE_LEN, drv_res->ie_length);
+    wifi_scan_result *full_scan_result;
+    wifi_gscan_result_t *fixed = &drv_res->fixed;
 
+    full_scan_result = (wifi_scan_result *) malloc((ie_len + offsetof(wifi_scan_result, ie_data)));
+    if (!full_scan_result) {
+        ALOGE("Full scan results: Can't malloc!\n");
+        return NL_SKIP;
+    }
+    convert_to_hal_result(full_scan_result, fixed);
+    full_scan_result->ie_length = ie_len;
+    memcpy(full_scan_result->ie_data, drv_res->ie_data, ie_len);
+    if(handler.on_full_scan_result)
+        handler.on_full_scan_result(id, full_scan_result, drv_res->scan_ch_bucket);
+
+    ALOGD("Full scan result: %-32s %02x:%02x:%02x:%02x:%02x:%02x %d %d %lld %lld %lld %x %d\n",
+        fixed->ssid, fixed->bssid[0], fixed->bssid[1], fixed->bssid[2], fixed->bssid[3],
+        fixed->bssid[4], fixed->bssid[5], fixed->rssi, fixed->channel, fixed->ts,
+        fixed->rtt, fixed->rtt_sd, drv_res->scan_ch_bucket, drv_res->ie_length);
+    free(full_scan_result);
     return NL_SKIP;
 }
 
@@ -778,14 +803,11 @@ class GetScanResultsCommand : public WifiCommand {
     int mRetrieved;
     byte mFlush;
     int mCompleted;
-    static const int MAX_RESULTS = 320;
-    wifi_scan_result mScanResults[MAX_RESULTS];
-    int mNextScanResult;
 public:
     GetScanResultsCommand(wifi_interface_handle iface, byte flush,
             wifi_cached_scan_results *results, int max, int *num)
         : WifiCommand("GetScanResultsCommand", iface, -1), mScans(results), mMax(max), mNum(num),
-                mRetrieved(0), mFlush(flush), mCompleted(0), mNextScanResult(0)
+                mRetrieved(0), mFlush(flush), mCompleted(0)
     { }
 
     int createRequest(WifiRequest& request, int num, byte flush) {
@@ -877,7 +899,7 @@ public:
                 mCompleted = it.get_u8();
                 ALOGV("retrieved mCompleted flag : %d", mCompleted);
             } else if (it.get_type() == GSCAN_ATTRIBUTE_SCAN_RESULTS || it.get_type() == 0) {
-                int scan_id = 0, flags = 0, num = 0;
+                int scan_id = 0, flags = 0, num = 0, scan_ch_bucket_mask = 0;
                 for (nl_iterator it2(it.get()); it2.has_next(); it2.next()) {
                     if (it2.get_type() == GSCAN_ATTRIBUTE_SCAN_ID) {
                         scan_id = it2.get_u32();
@@ -888,20 +910,24 @@ public:
                     } else if (it2.get_type() == GSCAN_ATTRIBUTE_NUM_OF_RESULTS) {
                         num = it2.get_u32();
                         ALOGV("retrieved num_results: %d", num);
-                    } else if (it2.get_type() == GSCAN_ATTRIBUTE_SCAN_RESULTS) {
+                    } else if (it2.get_type() == GSCAN_ATTRIBUTE_CH_BUCKET_BITMASK) {
+                        scan_ch_bucket_mask = it2.get_u32();
+                        ALOGD("retrieved scan_ch_bucket_mask: %x", scan_ch_bucket_mask);
+                    } else if (it2.get_type() == GSCAN_ATTRIBUTE_SCAN_RESULTS && num) {
                         if (mRetrieved >= mMax) {
                             ALOGW("Stored %d scans, ignoring excess results", mRetrieved);
                             break;
                         }
-                        num = it2.get_len() / sizeof(wifi_scan_result);
-                        num = min(MAX_RESULTS - mNextScanResult, num);
-                        num = min((int)MAX_AP_CACHE_PER_SCAN, num);
-                        memcpy(mScanResults + mNextScanResult, it2.get_data(),
-                                sizeof(wifi_scan_result) * num);
-                        ALOGV("Retrieved %d scan results", num);
-                        wifi_scan_result *results = (wifi_scan_result *)it2.get_data();
+                        num = min(num, (int)(it2.get_len()/sizeof(wifi_scan_result)));
+                        num = min(num, (int)MAX_AP_CACHE_PER_SCAN);
+                        ALOGV("Copying %d scan results", num);
+                        wifi_gscan_result_t *results = (wifi_gscan_result_t *)it2.get_data();
+                        wifi_scan_result *mScanResults = mScans[mRetrieved].results;
+
                         for (int i = 0; i < num; i++) {
-                            wifi_scan_result *result = results + i;
+                            wifi_gscan_result_t *result = &results[i];
+                            convert_to_hal_result(&mScanResults[i], result);
+                            mScanResults[i].ie_length = 0;
                             ALOGV("%02d  %-32s  %02x:%02x:%02x:%02x:%02x:%02x  %04d", i,
                                 result->ssid, result->bssid[0], result->bssid[1], result->bssid[2],
                                 result->bssid[3], result->bssid[4], result->bssid[5],
@@ -910,10 +936,8 @@ public:
                         mScans[mRetrieved].scan_id = scan_id;
                         mScans[mRetrieved].flags = flags;
                         mScans[mRetrieved].num_results = num;
+                        mScans[mRetrieved].buckets_scanned = scan_ch_bucket_mask;
                         ALOGV("Setting result of scan_id : 0x%0x", mScans[mRetrieved].scan_id);
-                        memcpy(mScans[mRetrieved].results,
-                                &(mScanResults[mNextScanResult]), num * sizeof(wifi_scan_result));
-                        mNextScanResult += num;
                         mRetrieved++;
                     } else {
                         ALOGW("Ignoring invalid attribute type = %d, size = %d",
@@ -1092,9 +1116,12 @@ public:
 
         memset(mResults, 0, sizeof(wifi_scan_result) * MAX_RESULTS);
 
-        int num = len / sizeof(wifi_scan_result);
+        int num = len / sizeof(wifi_gscan_result_t);
+        wifi_gscan_result_t *inp = (wifi_gscan_result_t *)event.get_vendor_data();
         num = min(MAX_RESULTS, num);
-        memcpy(mResults, event.get_vendor_data(), num * sizeof(wifi_scan_result));
+        for (int i = 0; i < num; i++, inp++) {
+            convert_to_hal_result(&(mResults[i]), inp);
+        }
 
         if (event_id == GSCAN_EVENT_HOTLIST_RESULTS_FOUND) {
             ALOGI("FOUND %d hotlist APs", num);
@@ -1112,64 +1139,99 @@ public:
 class ePNOCommand : public WifiCommand
 {
 private:
-    const wifi_epno_network *ssid_list;
-    int num_ssid;
+    wifi_epno_params epno_params;
     wifi_epno_handler mHandler;
-    static const int MAX_RESULTS = 32;
-    wifi_scan_result mResults[MAX_RESULTS];
+    wifi_scan_result mResults[MAX_EPNO_NETWORKS];
 public:
     ePNOCommand(wifi_interface_handle handle, int id,
-            int num_networks, const wifi_epno_network *networks, wifi_epno_handler handler)
+            const wifi_epno_params *params, wifi_epno_handler handler)
         : WifiCommand("ePNOCommand", handle, id), mHandler(handler)
     {
-        ssid_list = networks;
-        num_ssid = num_networks;
+        if (params != NULL) {
+            memcpy(&epno_params, params, sizeof(wifi_epno_params));
+        } else {
+            memset(&epno_params, 0, sizeof(wifi_epno_params));
+        }
     }
-
     int createSetupRequest(WifiRequest& request) {
         int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_EPNO_SSID);
         if (result < 0) {
             return result;
         }
-
         nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
         result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_FLUSH, 1);
         if (result < 0) {
             return result;
         }
 
-        result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_SSID_NUM, num_ssid);
+        result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_5G_RSSI_THR,
+                            (u8)epno_params.min5GHz_rssi);
+        if (result < 0) {
+            return result;
+        }
+        result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_2G_RSSI_THR,
+                            (u8)epno_params.min24GHz_rssi);
+        if (result < 0) {
+            return result;
+        }
+        result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_INIT_SCORE_MAX,
+                            epno_params.initial_score_max);
+        if (result < 0) {
+            return result;
+        }
+        result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_CUR_CONN_BONUS,
+                            epno_params.current_connection_bonus);
+        if (result < 0) {
+            return result;
+        }
+        result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_SAME_NETWORK_BONUS,
+                            epno_params.same_network_bonus);
+        if (result < 0) {
+            return result;
+        }
+        result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_SECURE_BONUS,
+                            epno_params.secure_bonus);
+        if (result < 0) {
+            return result;
+        }
+        result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_5G_BONUS,
+                            epno_params.band5GHz_bonus);
+        if (result < 0) {
+            return result;
+        }
+        result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_SSID_NUM,
+                        epno_params.num_networks);
         if (result < 0) {
             return result;
         }
-
         struct nlattr * attr = request.attr_start(GSCAN_ATTRIBUTE_EPNO_SSID_LIST);
-        for (int i = 0; i < num_ssid; i++) {
+        wifi_epno_network *ssid_list = epno_params.networks;
+        for (int i = 0; i < epno_params.num_networks; i++) {
             nlattr *attr2 = request.attr_start(i);
             if (attr2 == NULL) {
                 return WIFI_ERROR_OUT_OF_MEMORY;
             }
-            result = request.put(GSCAN_ATTRIBUTE_EPNO_SSID, (void*)ssid_list[i].ssid, 32);
-            ALOGI("PNO network: SSID %s flags %d auth %d", ssid_list[i].ssid,
-                ssid_list[i].flags, ssid_list[i].auth_bit_field);
+            result = request.put(GSCAN_ATTRIBUTE_EPNO_SSID, ssid_list[i].ssid, DOT11_MAX_SSID_LEN);
+            ALOGI("PNO network: SSID %s flags %x auth %x", ssid_list[i].ssid,
+                ssid_list[i].flags,
+                ssid_list[i].auth_bit_field);
             if (result < 0) {
                 return result;
             }
-            result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_SSID_LEN, strlen(ssid_list[i].ssid));
+            result = request.put_u32(GSCAN_ATTRIBUTE_EPNO_SSID_LEN, strlen(ssid_list[i].ssid));
             if (result < 0) {
                 return result;
             }
-            result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_FLAGS, ssid_list[i].flags);
+            result = request.put_u32(GSCAN_ATTRIBUTE_EPNO_FLAGS, ssid_list[i].flags);
             if (result < 0) {
                 return result;
             }
-            result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_AUTH, ssid_list[i].auth_bit_field);
+            result = request.put_u32(GSCAN_ATTRIBUTE_EPNO_AUTH, ssid_list[i].auth_bit_field);
             if (result < 0) {
                 return result;
             }
             request.attr_end(attr2);
         }
-
         request.attr_end(attr);
         request.attr_end(data);
         return result;
@@ -1191,7 +1253,7 @@ public:
     }
 
     int start() {
-        ALOGI("Executing ePNO setup request, num = %d", num_ssid);
+        ALOGI("Executing ePNO setup request, num = %d", epno_params.num_networks);
         WifiRequest request(familyId(), ifaceId());
         int result = createSetupRequest(request);
         if (result < 0) {
@@ -1205,7 +1267,7 @@ public:
             return result;
         }
 
-        ALOGI("Successfully set %d SSIDs for ePNO", num_ssid);
+        ALOGI("Successfully set %d SSIDs for ePNO", epno_params.num_networks);
         registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_EPNO_EVENT);
         ALOGI("successfully restarted the scan");
         return result;
@@ -1248,11 +1310,11 @@ public:
             return NL_SKIP;
         }
 
-        memset(mResults, 0, sizeof(wifi_scan_result) * MAX_RESULTS);
+        memset(mResults, 0, sizeof(wifi_scan_result) * MAX_EPNO_NETWORKS);
 
-        int num = len / sizeof(wifi_pno_result_t);
-        int i;
-        num = min(MAX_RESULTS, num);
+        unsigned int num = len / sizeof(wifi_pno_result_t);
+        unsigned int i;
+        num = min(MAX_EPNO_NETWORKS, num);
         wifi_pno_result_t *res = (wifi_pno_result_t *) event.get_vendor_data();
         for (i = 0; i < num; i++) {
             if (res[i].flags == PNO_SSID_FOUND) {
@@ -1506,6 +1568,16 @@ wifi_error wifi_reset_significant_change_handler(wifi_request_id id, wifi_interf
 
 wifi_error wifi_reset_epno_list(wifi_request_id id, wifi_interface_handle iface)
 {
+    if (id == -1) {
+        wifi_epno_handler handler;
+        wifi_handle handle = getWifiHandle(iface);
+
+        memset(&handler, 0, sizeof(handler));
+        ePNOCommand *cmd = new ePNOCommand(iface, id, NULL, handler);
+        cmd->cancel();
+        cmd->releaseRef();
+        return WIFI_SUCCESS;
+    }
     return wifi_cancel_cmd(id, iface);
 }
 
@@ -1513,14 +1585,9 @@ wifi_error wifi_set_epno_list(wifi_request_id id, wifi_interface_handle iface,
         const wifi_epno_params *params, wifi_epno_handler handler)
 {
      wifi_handle handle = getWifiHandle(iface);
-     int num_networks = params->num_networks;
-     const wifi_epno_network *networks = params->networks;
 
-     ePNOCommand *cmd = new ePNOCommand(iface, id, num_networks, networks, handler);
+     ePNOCommand *cmd = new ePNOCommand(iface, id, params, handler);
      wifi_register_cmd(handle, id, cmd);
-     if (num_networks == 0 || networks == NULL) {
-         return wifi_reset_epno_list(id, iface);
-     }
      wifi_error result = (wifi_error)cmd->start();
      if (result != WIFI_SUCCESS) {
          wifi_unregister_cmd(handle, id);
@@ -1611,12 +1678,14 @@ class AnqpoConfigureCommand : public WifiCommand
     int num_hs;
     wifi_passpoint_network *mNetworks;
     wifi_passpoint_event_handler mHandler;
+    wifi_scan_result *mResult;
 public:
     AnqpoConfigureCommand(wifi_request_id id, wifi_interface_handle iface,
         int num, wifi_passpoint_network *hs_list, wifi_passpoint_event_handler handler)
         : WifiCommand("AnqpoConfigureCommand", iface, id), num_hs(num), mNetworks(hs_list),
             mHandler(handler)
     {
+        mResult = NULL;
     }
 
     int createRequest(WifiRequest& request, int val) {
@@ -1725,27 +1794,33 @@ public:
             ALOGI("No scan results found");
             return NL_SKIP;
         }
+        mResult = (wifi_scan_result *)malloc(sizeof(wifi_scan_result));
+        if (!mResult) {
+            return NL_SKIP;
+        }
+        wifi_gscan_full_result_t *drv_res = (wifi_gscan_full_result_t *)event.get_vendor_data();
+        wifi_gscan_result_t *fixed = &drv_res->fixed;
+        convert_to_hal_result(mResult, fixed);
 
-        wifi_scan_result *result = (wifi_scan_result *)event.get_vendor_data();
-        byte *anqp = (byte *)result + offsetof(wifi_scan_result, ie_data) + result->ie_length;
+        byte *anqp = (byte *)drv_res + offsetof(wifi_gscan_full_result_t, ie_data) + drv_res->ie_length;
         wifi_anqp_gas_resp *gas = (wifi_anqp_gas_resp *)anqp;
         int anqp_len = offsetof(wifi_anqp_gas_resp, data) + gas->data_len;
         int networkId = *(int *)((byte *)anqp + anqp_len);
 
-        ALOGI("%-32s\t", result->ssid);
+        ALOGI("%-32s\t", mResult->ssid);
 
-        ALOGI("%02x:%02x:%02x:%02x:%02x:%02x ", result->bssid[0], result->bssid[1],
-                result->bssid[2], result->bssid[3], result->bssid[4], result->bssid[5]);
+        ALOGI("%02x:%02x:%02x:%02x:%02x:%02x ", mResult->bssid[0], mResult->bssid[1],
+                mResult->bssid[2], mResult->bssid[3], mResult->bssid[4], mResult->bssid[5]);
 
-        ALOGI("%d\t", result->rssi);
-        ALOGI("%d\t", result->channel);
-        ALOGI("%lld\t", result->ts);
-        ALOGI("%lld\t", result->rtt);
-        ALOGI("%lld\n", result->rtt_sd);
+        ALOGI("%d\t", mResult->rssi);
+        ALOGI("%d\t", mResult->channel);
+        ALOGI("%lld\t", mResult->ts);
+        ALOGI("%lld\t", mResult->rtt);
+        ALOGI("%lld\n", mResult->rtt_sd);
 
         if(*mHandler.on_passpoint_network_found)
-            (*mHandler.on_passpoint_network_found)(id(), networkId, result, anqp_len, anqp);
-
+            (*mHandler.on_passpoint_network_found)(id(), networkId, mResult, anqp_len, anqp);
+        free(mResult);
         return NL_SKIP;
     }
 };