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 #ifndef __WIFI_HAL_NAN_COMMAND_H__ 18 #define __WIFH_HAL_NAN_COMMAND_H__ 19 20 #include "common.h" 21 #include "cpp_bindings.h" 22 #include "nan.h" 23 24 class NanCommand : public WifiVendorCommand 25 { 26 private: 27 NanCallbackHandler mHandler; 28 char *mNanVendorEvent; 29 u32 mNanDataLen; 30 NanStaParameter *mStaParam; 31 void *mUserData; 32 33 //Function to check the initial few bytes of data to 34 //determine whether NanResponse or NanEvent 35 int isNanResponse(); 36 //Function which unparses the data and calls the NotifyResponse 37 int handleNanResponse(); 38 //Function which will parse the mVendorData and gets 39 // the rsp_data appropriately. 40 int getNanResponse(NanResponseMsg *pRsp); 41 42 //Function which will return the Nan Indication type based on 43 //the initial few bytes of mVendorData 44 NanIndicationType getIndicationType(); 45 //Function which calls the necessaryIndication callback 46 //based on the indication type 47 int handleNanIndication(); 48 //Various Functions to get the appropriate indications 49 int getNanPublishReplied(NanPublishRepliedInd *event); 50 int getNanPublishTerminated(NanPublishTerminatedInd *event); 51 int getNanMatch(NanMatchInd *event); 52 int getNanUnMatch(NanUnmatchInd *event); 53 int getNanSubscribeTerminated(NanSubscribeTerminatedInd *event); 54 int getNanFollowup(NanFollowupInd *event); 55 int getNanDiscEngEvent(NanDiscEngEventInd *event); 56 int getNanDisabled(NanDisabledInd *event); 57 int getNanTca(NanTCAInd *event); 58 int getNanBeaconSdfPayload(NanBeaconSdfPayloadInd *event); 59 60 //Making the constructor private since this class is a singleton 61 NanCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd); 62 63 static NanCommand *mNanCommandInstance; 64 65 // Other private helper functions 66 int calcNanTransmitPostDiscoverySize( 67 const NanTransmitPostDiscovery *pPostDiscovery); 68 void fillNanSocialChannelParamVal( 69 const NanSocialChannelScanParams *pScanParams, 70 u32* pChannelParamArr); 71 u32 getNanTransmitPostConnectivityCapabilityVal( 72 const NanTransmitPostConnectivityCapability *pCapab); 73 void fillNanTransmitPostDiscoveryVal( 74 const NanTransmitPostDiscovery *pTxDisc, 75 u8 *pOutValue); 76 int calcNanFurtherAvailabilityMapSize( 77 const NanFurtherAvailabilityMap *pFam); 78 void fillNanFurtherAvailabilityMapVal( 79 const NanFurtherAvailabilityMap *pFam, 80 u8 *pOutValue); 81 82 void getNanReceivePostConnectivityCapabilityVal( 83 const u8* pInValue, 84 NanReceivePostConnectivityCapability *pRxCapab); 85 int getNanReceivePostDiscoveryVal(const u8 *pInValue, 86 u32 length, 87 NanReceivePostDiscovery *pRxDisc); 88 int getNanFurtherAvailabilityMap(const u8 *pInValue, 89 u32 length, 90 NanFurtherAvailabilityMap *pFam); 91 92 public: 93 static NanCommand* instance(wifi_handle handle); 94 virtual ~NanCommand(); 95 96 // This function implements creation of NAN specific Request 97 // based on the request type 98 virtual int create(); 99 virtual int requestEvent(); 100 virtual int handleResponse(WifiEvent reply); 101 virtual int handleEvent(WifiEvent &event); 102 int setCallbackHandler(NanCallbackHandler nHandler, 103 void *pUserData); 104 105 106 //Functions to fill the vendor data appropriately 107 int putNanEnable(const NanEnableRequest *pReq); 108 int putNanDisable(const NanDisableRequest *pReq); 109 int putNanPublish(const NanPublishRequest *pReq); 110 int putNanPublishCancel(const NanPublishCancelRequest *pReq); 111 int putNanSubscribe(const NanSubscribeRequest *pReq); 112 int putNanSubscribeCancel(const NanSubscribeCancelRequest *pReq); 113 int putNanTransmitFollowup(const NanTransmitFollowupRequest *pReq); 114 int putNanStats(const NanStatsRequest *pReq); 115 int putNanConfig(const NanConfigRequest *pReq); 116 int putNanTCA(const NanTCARequest *pReq); 117 int putNanBeaconSdfPayload(const NanBeaconSdfPayloadRequest *pReq); 118 int getNanStaParameter(NanStaParameter *pRsp); 119 120 //Set the Id of the request 121 void setId(int nId); 122 }; 123 #endif /* __WIFH_HAL_NAN_COMMAND_H__ */ 124 125