wlan: Batch Scan to return complete scan results

HDD to return complete batch scan results to user space

Change-Id: I6681ecd54a39aae7bacdc3a887ec5752caecf940
CRs-Fixed: 563180
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index d60a467..307fae9 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -984,6 +984,7 @@
 {
     v_BOOL_t                     isLastAp;
     tANI_U32                     numApMetaInfo;
+    tANI_U32                     numNetworkInScanList;
     tANI_U32                     numberScanList;
     tANI_U32                     nextScanListOffset;
     tANI_U32                     nextApMetaInfoOffset;
@@ -1008,6 +1009,7 @@
     pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp;
     isLastAp = FALSE;
     numApMetaInfo = 0;
+    numNetworkInScanList = 0;
     numberScanList = 0;
     nextScanListOffset = 0;
     nextApMetaInfoOffset = 0;
@@ -1036,7 +1038,7 @@
 
     while (numberScanList)
     {
-        pScanList = (tpSirBatchScanList)(pBatchScanRsp->scanResults +
+        pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults +
                                           nextScanListOffset);
         if (NULL == pScanList)
         {
@@ -1045,9 +1047,10 @@
             isLastAp = TRUE;
            goto done;
         }
-        numApMetaInfo = pScanList->numNetworksInScanList;
+        numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList;
         VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
-            "Batch scan rsp: numApMetaInfo %d", numApMetaInfo);
+            "Batch scan rsp: numApMetaInfo %d scanId %d",
+            numApMetaInfo, pScanList->scanId);
 
         if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork))
         {
@@ -1057,6 +1060,9 @@
            goto done;
         }
 
+        /*Initialize next AP meta info offset for next scan list*/
+        nextApMetaInfoOffset = 0;
+
         while (numApMetaInfo)
         {
             pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList +
@@ -1098,7 +1104,9 @@
             numApMetaInfo--;
         }
 
-        nextScanListOffset += (sizeof(tSirBatchScanList) - (sizeof(tANI_U8)));
+        nextScanListOffset +=  ((sizeof(tSirBatchScanList) - sizeof(tANI_U8))
+                                + (sizeof(tSirBatchScanNetworkInfo)
+                                * numNetworkInScanList));
         numberScanList--;
     }