1 /*
2  * Copyright (C) 2014 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.
15  */
16 
17 #include "sync.h"
18 #include <utils/Log.h>
19 #include "wifi_hal.h"
20 #include "nan_i.h"
21 #include "nancommand.h"
22 
23 
isNanResponse()24 int NanCommand::isNanResponse()
25 {
26     if (mNanVendorEvent == NULL) {
27         ALOGE("NULL check failed");
28         return WIFI_ERROR_INVALID_ARGS;
29     }
30 
31     NanMsgHeader *pHeader = (NanMsgHeader *)mNanVendorEvent;
32 
33     switch (pHeader->msgId) {
34     case NAN_MSG_ID_ERROR_RSP:
35     case NAN_MSG_ID_CONFIGURATION_RSP:
36     case NAN_MSG_ID_PUBLISH_SERVICE_CANCEL_RSP:
37     case NAN_MSG_ID_PUBLISH_SERVICE_RSP:
38     case NAN_MSG_ID_SUBSCRIBE_SERVICE_RSP:
39     case NAN_MSG_ID_SUBSCRIBE_SERVICE_CANCEL_RSP:
40     case NAN_MSG_ID_TRANSMIT_FOLLOWUP_RSP:
41     case NAN_MSG_ID_STATS_RSP:
42     case NAN_MSG_ID_ENABLE_RSP:
43     case NAN_MSG_ID_DISABLE_RSP:
44     case NAN_MSG_ID_TCA_RSP:
45     case NAN_MSG_ID_BEACON_SDF_RSP:
46     case NAN_MSG_ID_CAPABILITIES_RSP:
47         return 1;
48     default:
49         return 0;
50     }
51 }
52 
53 
getNanResponse(transaction_id * id,NanResponseMsg * pRsp)54 int NanCommand::getNanResponse(transaction_id *id, NanResponseMsg *pRsp)
55 {
56     if (mNanVendorEvent == NULL || pRsp == NULL) {
57         ALOGE("NULL check failed");
58         return WIFI_ERROR_INVALID_ARGS;
59     }
60 
61     NanMsgHeader *pHeader = (NanMsgHeader *)mNanVendorEvent;
62 
63     switch (pHeader->msgId) {
64         case NAN_MSG_ID_ERROR_RSP:
65         {
66             pNanErrorRspMsg pFwRsp = \
67                 (pNanErrorRspMsg)mNanVendorEvent;
68             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
69             pRsp->status = (NanStatusType)pFwRsp->status;
70             pRsp->value = pFwRsp->value;
71             pRsp->response_type = NAN_RESPONSE_ERROR;
72             break;
73         }
74         case NAN_MSG_ID_CONFIGURATION_RSP:
75         {
76             pNanConfigurationRspMsg pFwRsp = \
77                 (pNanConfigurationRspMsg)mNanVendorEvent;
78             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
79             pRsp->status = (NanStatusType)pFwRsp->status;
80             pRsp->value = pFwRsp->value;
81             pRsp->response_type = NAN_RESPONSE_CONFIG;
82         }
83         break;
84         case NAN_MSG_ID_PUBLISH_SERVICE_CANCEL_RSP:
85         {
86             pNanPublishServiceCancelRspMsg pFwRsp = \
87                 (pNanPublishServiceCancelRspMsg)mNanVendorEvent;
88             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
89             pRsp->status = (NanStatusType)pFwRsp->status;
90             pRsp->value = pFwRsp->value;
91             pRsp->response_type = NAN_RESPONSE_PUBLISH_CANCEL;
92             pRsp->body.publish_response.publish_id = \
93                 pFwRsp->fwHeader.handle;
94             break;
95         }
96         case NAN_MSG_ID_PUBLISH_SERVICE_RSP:
97         {
98             pNanPublishServiceRspMsg pFwRsp = \
99                 (pNanPublishServiceRspMsg)mNanVendorEvent;
100             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
101             pRsp->status = (NanStatusType)pFwRsp->status;
102             pRsp->value = pFwRsp->value;
103             pRsp->response_type = NAN_RESPONSE_PUBLISH;
104             pRsp->body.publish_response.publish_id = \
105                 pFwRsp->fwHeader.handle;
106             break;
107         }
108         case NAN_MSG_ID_SUBSCRIBE_SERVICE_RSP:
109         {
110             pNanSubscribeServiceRspMsg pFwRsp = \
111                 (pNanSubscribeServiceRspMsg)mNanVendorEvent;
112             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
113             pRsp->status = (NanStatusType)pFwRsp->status;
114             pRsp->value = pFwRsp->value;
115             pRsp->response_type = NAN_RESPONSE_SUBSCRIBE;
116             pRsp->body.subscribe_response.subscribe_id = \
117                 pFwRsp->fwHeader.handle;
118         }
119         break;
120         case NAN_MSG_ID_SUBSCRIBE_SERVICE_CANCEL_RSP:
121         {
122             pNanSubscribeServiceCancelRspMsg pFwRsp = \
123                 (pNanSubscribeServiceCancelRspMsg)mNanVendorEvent;
124             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
125             pRsp->status = (NanStatusType)pFwRsp->status;
126             pRsp->value = pFwRsp->value;
127             pRsp->response_type = NAN_RESPONSE_SUBSCRIBE_CANCEL;
128             pRsp->body.subscribe_response.subscribe_id = \
129                 pFwRsp->fwHeader.handle;
130             break;
131         }
132         case NAN_MSG_ID_TRANSMIT_FOLLOWUP_RSP:
133         {
134             pNanTransmitFollowupRspMsg pFwRsp = \
135                 (pNanTransmitFollowupRspMsg)mNanVendorEvent;
136             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
137             pRsp->status = (NanStatusType)pFwRsp->status;
138             pRsp->value = pFwRsp->value;
139             pRsp->response_type = NAN_RESPONSE_TRANSMIT_FOLLOWUP;
140             break;
141         }
142         case NAN_MSG_ID_STATS_RSP:
143         {
144             pNanStatsRspMsg pFwRsp = \
145                 (pNanStatsRspMsg)mNanVendorEvent;
146             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
147             pRsp->status = (NanStatusType)pFwRsp->statsRspParams.status;
148             pRsp->value = pFwRsp->statsRspParams.value;
149             pRsp->response_type = NAN_RESPONSE_STATS;
150             pRsp->body.stats_response.stats_type = \
151                 (NanStatsType)pFwRsp->statsRspParams.statsType;
152             ALOGV("%s: stats_type:%d",__func__,
153                   pRsp->body.stats_response.stats_type);
154             u8 *pInputTlv = pFwRsp->ptlv;
155             NanTlv outputTlv;
156             memset(&outputTlv, 0, sizeof(outputTlv));
157             u16 readLen = 0;
158             int remainingLen = (mNanDataLen -  \
159                 (sizeof(NanMsgHeader) + sizeof(NanStatsRspParams)));
160             if (remainingLen > 0) {
161                 readLen = NANTLV_ReadTlv(pInputTlv, &outputTlv);
162                 ALOGV("%s: Remaining Len:%d readLen:%d type:%d length:%d",
163                       __func__, remainingLen, readLen, outputTlv.type,
164                       outputTlv.length);
165                 if (outputTlv.length <= \
166                     sizeof(pRsp->body.stats_response.data)) {
167                     handleNanStatsResponse(pRsp->body.stats_response.stats_type,
168                                            (char *)outputTlv.value,
169                                            &pRsp->body.stats_response);
170                 }
171             }
172             else
173                 ALOGV("%s: No TLV's present",__func__);
174             break;
175         }
176         case NAN_MSG_ID_ENABLE_RSP:
177         {
178             pNanEnableRspMsg pFwRsp = \
179                 (pNanEnableRspMsg)mNanVendorEvent;
180             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
181             pRsp->status = (NanStatusType)pFwRsp->status;
182             pRsp->value = pFwRsp->value;
183             pRsp->response_type = NAN_RESPONSE_ENABLED;
184             break;
185         }
186         case NAN_MSG_ID_DISABLE_RSP:
187         {
188             pNanDisableRspMsg pFwRsp = \
189                 (pNanDisableRspMsg)mNanVendorEvent;
190             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
191             pRsp->status = (NanStatusType)pFwRsp->status;
192             pRsp->value = 0;
193             pRsp->response_type = NAN_RESPONSE_DISABLED;
194             break;
195         }
196         case NAN_MSG_ID_TCA_RSP:
197         {
198             pNanTcaRspMsg pFwRsp = \
199                 (pNanTcaRspMsg)mNanVendorEvent;
200             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
201             pRsp->status = (NanStatusType)pFwRsp->status;
202             pRsp->value = pFwRsp->value;
203             pRsp->response_type = NAN_RESPONSE_TCA;
204             break;
205         }
206         case NAN_MSG_ID_BEACON_SDF_RSP:
207         {
208             pNanBeaconSdfPayloadRspMsg pFwRsp = \
209                 (pNanBeaconSdfPayloadRspMsg)mNanVendorEvent;
210             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
211             pRsp->status = (NanStatusType)pFwRsp->status;
212             pRsp->value = 0;
213             pRsp->response_type = NAN_RESPONSE_BEACON_SDF_PAYLOAD;
214             break;
215         }
216         case NAN_MSG_ID_CAPABILITIES_RSP:
217         {
218             pNanCapabilitiesRspMsg pFwRsp = \
219                 (pNanCapabilitiesRspMsg)mNanVendorEvent;
220             *id = (transaction_id)pFwRsp->fwHeader.transactionId;
221             pRsp->status = (NanStatusType)pFwRsp->status;
222             pRsp->value = pFwRsp->value;
223             pRsp->response_type = NAN_GET_CAPABILITIES;
224             pRsp->body.nan_capabilities.max_concurrent_nan_clusters = \
225                         pFwRsp->max_concurrent_nan_clusters;
226             pRsp->body.nan_capabilities.max_publishes = \
227                         pFwRsp->max_publishes;
228             pRsp->body.nan_capabilities.max_subscribes = \
229                         pFwRsp->max_subscribes;
230             pRsp->body.nan_capabilities.max_service_name_len = \
231                         pFwRsp->max_service_name_len;
232             pRsp->body.nan_capabilities.max_match_filter_len = \
233                         pFwRsp->max_match_filter_len;
234             pRsp->body.nan_capabilities.max_total_match_filter_len = \
235                         pFwRsp->max_total_match_filter_len;
236             pRsp->body.nan_capabilities.max_service_specific_info_len = \
237                         pFwRsp->max_service_specific_info_len;
238             pRsp->body.nan_capabilities.max_vsa_data_len = \
239                         pFwRsp->max_vsa_data_len;
240             pRsp->body.nan_capabilities.max_mesh_data_len = \
241                         pFwRsp->max_mesh_data_len;
242             pRsp->body.nan_capabilities.max_ndi_interfaces = \
243                        pFwRsp->max_ndi_interfaces;
244             pRsp->body.nan_capabilities.max_ndp_sessions = \
245                        pFwRsp->max_ndp_sessions;
246             pRsp->body.nan_capabilities.max_app_info_len = \
247                        pFwRsp->max_app_info_len;
248             break;
249         }
250         default:
251             return  -1;
252     }
253     return  0;
254 }
255 
handleNanResponse()256 int NanCommand::handleNanResponse()
257 {
258     //parse the data and call
259     //the response callback handler with the populated
260     //NanResponseMsg
261     NanResponseMsg  rsp_data;
262     int ret;
263     transaction_id id;
264 
265     ALOGV("handleNanResponse called %p", this);
266     memset(&rsp_data, 0, sizeof(rsp_data));
267     //get the rsp_data
268     ret = getNanResponse(&id, &rsp_data);
269 
270     ALOGI("handleNanResponse ret:%d status:%u value:%u response_type:%u",
271           ret, rsp_data.status, rsp_data.value, rsp_data.response_type);
272     if (ret == 0 && (rsp_data.response_type == NAN_RESPONSE_STATS) &&
273         (mStaParam != NULL) &&
274         (rsp_data.body.stats_response.stats_type == NAN_STATS_ID_DE_TIMING_SYNC)) {
275         /*
276            Fill the staParam with appropriate values and return from here.
277            No need to call NotifyResponse as the request is for getting the
278            STA response
279         */
280         NanSyncStats *pSyncStats = &rsp_data.body.stats_response.data.sync_stats;
281         mStaParam->master_rank = pSyncStats->myRank;
282         mStaParam->master_pref = (pSyncStats->myRank & 0xFF00000000000000) >> 56;
283         mStaParam->random_factor = (pSyncStats->myRank & 0x00FF000000000000) >> 48;
284         mStaParam->hop_count = pSyncStats->currAmHopCount;
285         mStaParam->beacon_transmit_time = pSyncStats->currAmBTT;
286 
287         return ret;
288     }
289     //Call the NotifyResponse Handler
290     if (ret == 0 && mHandler.NotifyResponse) {
291         (*mHandler.NotifyResponse)(id, &rsp_data);
292     }
293     return ret;
294 }
295 
handleNanStatsResponse(NanStatsType stats_type,char * rspBuf,NanStatsResponse * pRsp)296 void NanCommand::handleNanStatsResponse(NanStatsType stats_type,
297                                        char *rspBuf,
298                                        NanStatsResponse *pRsp)
299 {
300     if (stats_type == NAN_STATS_ID_DE_PUBLISH) {
301         NanPublishStats publish_stats;
302         FwNanPublishStats *pPubStats = (FwNanPublishStats *)rspBuf;
303 
304         publish_stats.validPublishServiceReqMsgs =
305                                     pPubStats->validPublishServiceReqMsgs;
306         publish_stats.validPublishServiceRspMsgs =
307                                     pPubStats->validPublishServiceRspMsgs;
308         publish_stats.validPublishServiceCancelReqMsgs =
309                                     pPubStats->validPublishServiceCancelReqMsgs;
310         publish_stats.validPublishServiceCancelRspMsgs =
311                                     pPubStats->validPublishServiceCancelRspMsgs;
312         publish_stats.validPublishRepliedIndMsgs =
313                                     pPubStats->validPublishRepliedIndMsgs;
314         publish_stats.validPublishTerminatedIndMsgs =
315                                     pPubStats->validPublishTerminatedIndMsgs;
316         publish_stats.validActiveSubscribes = pPubStats->validActiveSubscribes;
317         publish_stats.validMatches = pPubStats->validMatches;
318         publish_stats.validFollowups = pPubStats->validFollowups;
319         publish_stats.invalidPublishServiceReqMsgs =
320                                     pPubStats->invalidPublishServiceReqMsgs;
321         publish_stats.invalidPublishServiceCancelReqMsgs =
322                                 pPubStats->invalidPublishServiceCancelReqMsgs;
323         publish_stats.invalidActiveSubscribes =
324                                 pPubStats->invalidActiveSubscribes;
325         publish_stats.invalidMatches = pPubStats->invalidMatches;
326         publish_stats.invalidFollowups = pPubStats->invalidFollowups;
327         publish_stats.publishCount = pPubStats->publishCount;
328         publish_stats.publishNewMatchCount = pPubStats->publishNewMatchCount;
329         publish_stats.pubsubGlobalNewMatchCount =
330                                pPubStats->pubsubGlobalNewMatchCount;
331         memcpy(&pRsp->data, &publish_stats, sizeof(NanPublishStats));
332     } else if (stats_type == NAN_STATS_ID_DE_SUBSCRIBE) {
333         NanSubscribeStats sub_stats;
334         FwNanSubscribeStats *pSubStats = (FwNanSubscribeStats *)rspBuf;
335 
336         sub_stats.validSubscribeServiceReqMsgs =
337                                 pSubStats->validSubscribeServiceReqMsgs;
338         sub_stats.validSubscribeServiceRspMsgs =
339                                 pSubStats->validSubscribeServiceRspMsgs;
340         sub_stats.validSubscribeServiceCancelReqMsgs =
341                                 pSubStats->validSubscribeServiceCancelReqMsgs;
342         sub_stats.validSubscribeServiceCancelRspMsgs =
343                                 pSubStats->validSubscribeServiceCancelRspMsgs;
344         sub_stats.validSubscribeTerminatedIndMsgs =
345                                 pSubStats->validSubscribeTerminatedIndMsgs;
346         sub_stats.validSubscribeMatchIndMsgs =
347                                 pSubStats->validSubscribeMatchIndMsgs;
348         sub_stats.validSubscribeUnmatchIndMsgs =
349                                 pSubStats->validSubscribeUnmatchIndMsgs;
350         sub_stats.validSolicitedPublishes =
351                                 pSubStats->validSolicitedPublishes;
352         sub_stats.validMatches = pSubStats->validMatches;
353         sub_stats.validFollowups = pSubStats->validFollowups;
354         sub_stats.invalidSubscribeServiceReqMsgs =
355                             pSubStats->invalidSubscribeServiceReqMsgs;
356         sub_stats.invalidSubscribeServiceCancelReqMsgs =
357                             pSubStats->invalidSubscribeServiceCancelReqMsgs;
358         sub_stats.invalidSubscribeFollowupReqMsgs =
359                             pSubStats->invalidSubscribeFollowupReqMsgs;
360         sub_stats.invalidSolicitedPublishes =
361                             pSubStats->invalidSolicitedPublishes;
362         sub_stats.invalidMatches = pSubStats->invalidMatches;
363         sub_stats.invalidFollowups = pSubStats->invalidFollowups;
364         sub_stats.subscribeCount = pSubStats->subscribeCount;
365         sub_stats.bloomFilterIndex = pSubStats->bloomFilterIndex;
366         sub_stats.subscribeNewMatchCount = pSubStats->subscribeNewMatchCount;
367         sub_stats.pubsubGlobalNewMatchCount =
368                                       pSubStats->pubsubGlobalNewMatchCount;
369         memcpy(&pRsp->data, &sub_stats, sizeof(NanSubscribeStats));
370     } else if (stats_type == NAN_STATS_ID_DE_DW) {
371         NanDWStats dw_stats;
372         FwNanMacStats *pMacStats = (FwNanMacStats *)rspBuf;
373 
374         dw_stats.validFrames = pMacStats->validFrames;
375         dw_stats.validActionFrames = pMacStats->validActionFrames;
376         dw_stats.validBeaconFrames = pMacStats->validBeaconFrames;
377         dw_stats.ignoredActionFrames = pMacStats->ignoredActionFrames;
378         dw_stats.invalidFrames = pMacStats->invalidFrames;
379         dw_stats.invalidActionFrames = pMacStats->invalidActionFrames;
380         dw_stats.invalidBeaconFrames = pMacStats->invalidBeaconFrames;
381         dw_stats.invalidMacHeaders = pMacStats->invalidMacHeaders;
382         dw_stats.invalidPafHeaders  = pMacStats->invalidPafHeaders;
383         dw_stats.nonNanBeaconFrames = pMacStats->nonNanBeaconFrames;
384         dw_stats.earlyActionFrames = pMacStats->earlyActionFrames;
385         dw_stats.inDwActionFrames = pMacStats->inDwActionFrames;
386         dw_stats.lateActionFrames = pMacStats->lateActionFrames;
387         dw_stats.framesQueued =  pMacStats->framesQueued;
388         dw_stats.totalTRSpUpdates = pMacStats->totalTRSpUpdates;
389         dw_stats.completeByTRSp = pMacStats->completeByTRSp;
390         dw_stats.completeByTp75DW = pMacStats->completeByTp75DW;
391         dw_stats.completeByTendDW = pMacStats->completeByTendDW;
392         dw_stats.lateActionFramesTx = pMacStats->lateActionFramesTx;
393         memcpy(&pRsp->data, &dw_stats, sizeof(NanDWStats));
394     } else if (stats_type == NAN_STATS_ID_DE_MAC) {
395         NanMacStats mac_stats;
396         FwNanMacStats *pMacStats = (FwNanMacStats *)rspBuf;
397 
398         mac_stats.validFrames = pMacStats->validFrames;
399         mac_stats.validActionFrames = pMacStats->validActionFrames;
400         mac_stats.validBeaconFrames = pMacStats->validBeaconFrames;
401         mac_stats.ignoredActionFrames = pMacStats->ignoredActionFrames;
402         mac_stats.invalidFrames = pMacStats->invalidFrames;
403         mac_stats.invalidActionFrames = pMacStats->invalidActionFrames;
404         mac_stats.invalidBeaconFrames = pMacStats->invalidBeaconFrames;
405         mac_stats.invalidMacHeaders = pMacStats->invalidMacHeaders;
406         mac_stats.invalidPafHeaders  = pMacStats->invalidPafHeaders;
407         mac_stats.nonNanBeaconFrames = pMacStats->nonNanBeaconFrames;
408         mac_stats.earlyActionFrames = pMacStats->earlyActionFrames;
409         mac_stats.inDwActionFrames = pMacStats->inDwActionFrames;
410         mac_stats.lateActionFrames = pMacStats->lateActionFrames;
411         mac_stats.framesQueued =  pMacStats->framesQueued;
412         mac_stats.totalTRSpUpdates = pMacStats->totalTRSpUpdates;
413         mac_stats.completeByTRSp = pMacStats->completeByTRSp;
414         mac_stats.completeByTp75DW = pMacStats->completeByTp75DW;
415         mac_stats.completeByTendDW = pMacStats->completeByTendDW;
416         mac_stats.lateActionFramesTx = pMacStats->lateActionFramesTx;
417         mac_stats.twIncreases = pMacStats->twIncreases;
418         mac_stats.twDecreases = pMacStats->twDecreases;
419         mac_stats.twChanges = pMacStats->twChanges;
420         mac_stats.twHighwater = pMacStats->twHighwater;
421         mac_stats.bloomFilterIndex = pMacStats->bloomFilterIndex;
422         memcpy(&pRsp->data, &mac_stats, sizeof(NanMacStats));
423     } else if (stats_type == NAN_STATS_ID_DE_TIMING_SYNC) {
424         NanSyncStats sync_stats;
425         FwNanSyncStats *pSyncStats = (FwNanSyncStats *)rspBuf;
426 
427         sync_stats.currTsf = pSyncStats->currTsf;
428         sync_stats.myRank = pSyncStats->myRank;
429         sync_stats.currAmRank = pSyncStats->currAmRank;
430         sync_stats.lastAmRank = pSyncStats->lastAmRank;
431         sync_stats.currAmBTT = pSyncStats->currAmBTT;
432         sync_stats.lastAmBTT = pSyncStats->lastAmBTT;
433         sync_stats.currAmHopCount = pSyncStats->currAmHopCount;
434         sync_stats.currRole = pSyncStats->currRole;
435         sync_stats.currClusterId = pSyncStats->currClusterId;
436 
437         sync_stats.timeSpentInCurrRole = pSyncStats->timeSpentInCurrRole;
438         sync_stats.totalTimeSpentAsMaster = pSyncStats->totalTimeSpentAsMaster;
439         sync_stats.totalTimeSpentAsNonMasterSync =
440                             pSyncStats->totalTimeSpentAsNonMasterSync;
441         sync_stats.totalTimeSpentAsNonMasterNonSync =
442                             pSyncStats->totalTimeSpentAsNonMasterNonSync;
443         sync_stats.transitionsToAnchorMaster =
444                             pSyncStats->transitionsToAnchorMaster;
445         sync_stats.transitionsToMaster =
446                             pSyncStats->transitionsToMaster;
447         sync_stats.transitionsToNonMasterSync =
448                             pSyncStats->transitionsToNonMasterSync;
449         sync_stats.transitionsToNonMasterNonSync =
450                             pSyncStats->transitionsToNonMasterNonSync;
451         sync_stats.amrUpdateCount = pSyncStats->amrUpdateCount;
452         sync_stats.amrUpdateRankChangedCount =
453                             pSyncStats->amrUpdateRankChangedCount;
454         sync_stats.amrUpdateBTTChangedCount =
455                             pSyncStats->amrUpdateBTTChangedCount;
456         sync_stats.amrUpdateHcChangedCount =
457                             pSyncStats->amrUpdateHcChangedCount;
458         sync_stats.amrUpdateNewDeviceCount =
459                             pSyncStats->amrUpdateNewDeviceCount;
460         sync_stats.amrExpireCount = pSyncStats->amrExpireCount;
461         sync_stats.mergeCount = pSyncStats->mergeCount;
462         sync_stats.beaconsAboveHcLimit = pSyncStats->beaconsAboveHcLimit;
463         sync_stats.beaconsBelowRssiThresh = pSyncStats->beaconsBelowRssiThresh;
464         sync_stats.beaconsIgnoredNoSpace = pSyncStats->beaconsIgnoredNoSpace;
465         sync_stats.beaconsForOurCluster = pSyncStats->beaconsForOtherCluster;
466         sync_stats.beaconsForOtherCluster = pSyncStats->beaconsForOtherCluster;
467         sync_stats.beaconCancelRequests = pSyncStats->beaconCancelRequests;
468         sync_stats.beaconCancelFailures = pSyncStats->beaconCancelFailures;
469         sync_stats.beaconUpdateRequests = pSyncStats->beaconUpdateRequests;
470         sync_stats.beaconUpdateFailures = pSyncStats->beaconUpdateFailures;
471         sync_stats.syncBeaconTxAttempts = pSyncStats->syncBeaconTxAttempts;
472         sync_stats.syncBeaconTxFailures = pSyncStats->syncBeaconTxFailures;
473         sync_stats.discBeaconTxAttempts = pSyncStats->discBeaconTxAttempts;
474         sync_stats.discBeaconTxFailures = pSyncStats->discBeaconTxFailures;
475         sync_stats.amHopCountExpireCount = pSyncStats->amHopCountExpireCount;
476         memcpy(&pRsp->data, &sync_stats, sizeof(NanSyncStats));
477     } else if (stats_type == NAN_STATS_ID_DE) {
478         NanDeStats de_stats;
479         FwNanDeStats *pDeStats = (FwNanDeStats *)rspBuf;
480 
481         de_stats.validErrorRspMsgs = pDeStats->validErrorRspMsgs;
482         de_stats.validTransmitFollowupReqMsgs =
483                         pDeStats->validTransmitFollowupReqMsgs;
484         de_stats.validTransmitFollowupRspMsgs =
485                         pDeStats->validTransmitFollowupRspMsgs;
486         de_stats.validFollowupIndMsgs =
487                         pDeStats->validFollowupIndMsgs;
488         de_stats.validConfigurationReqMsgs =
489                         pDeStats->validConfigurationReqMsgs;
490         de_stats.validConfigurationRspMsgs =
491                         pDeStats->validConfigurationRspMsgs;
492         de_stats.validStatsReqMsgs = pDeStats->validStatsReqMsgs;
493         de_stats.validStatsRspMsgs = pDeStats->validStatsRspMsgs;
494         de_stats.validEnableReqMsgs = pDeStats->validEnableReqMsgs;
495         de_stats.validEnableRspMsgs = pDeStats->validEnableRspMsgs;
496         de_stats.validDisableReqMsgs = pDeStats->validDisableReqMsgs;
497         de_stats.validDisableRspMsgs = pDeStats->validDisableRspMsgs;
498         de_stats.validDisableIndMsgs = pDeStats->validDisableIndMsgs;
499         de_stats.validEventIndMsgs = pDeStats->validEventIndMsgs;
500         de_stats.validTcaReqMsgs = pDeStats->validTcaReqMsgs;
501         de_stats.validTcaRspMsgs = pDeStats->validTcaRspMsgs;
502         de_stats.validTcaIndMsgs = pDeStats->validTcaIndMsgs;
503         de_stats.invalidTransmitFollowupReqMsgs =
504                             pDeStats->invalidTransmitFollowupReqMsgs;
505         de_stats.invalidConfigurationReqMsgs =
506                             pDeStats->invalidConfigurationReqMsgs;
507         de_stats.invalidStatsReqMsgs = pDeStats->invalidStatsReqMsgs;
508         de_stats.invalidEnableReqMsgs = pDeStats->invalidEnableReqMsgs;
509         de_stats.invalidDisableReqMsgs = pDeStats->invalidDisableReqMsgs;
510         de_stats.invalidTcaReqMsgs = pDeStats->invalidTcaReqMsgs;
511         memcpy(&pRsp->data, &de_stats, sizeof(NanDeStats));
512     } else {
513         ALOGE("Unknown stats_type:%d\n", stats_type);
514     }
515 }
516