• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __WIFI_HAL_NAN_COMMAND_H__
19 
20 #include "common.h"
21 #include "cpp_bindings.h"
22 #include "wifi_hal.h"
23 #include "nan_cert.h"
24 
25 class NanCommand : public WifiVendorCommand
26 {
27 private:
28     NanCallbackHandler mHandler;
29     char *mNanVendorEvent;
30     u32 mNanDataLen;
31     NanStaParameter *mStaParam;
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(transaction_id *id, NanResponseMsg *pRsp);
41     //Function which will return the Nan Indication type based on
42     //the initial few bytes of mVendorData
43     NanIndicationType getIndicationType();
44     //Function which calls the necessaryIndication callback
45     //based on the indication type
46     int handleNanIndication();
47     //Various Functions to get the appropriate indications
48     int getNanPublishReplied(NanPublishRepliedInd *event);
49     int getNanPublishTerminated(NanPublishTerminatedInd *event);
50     int getNanMatch(NanMatchInd *event);
51     int getNanMatchExpired(NanMatchExpiredInd *event);
52     int getNanSubscribeTerminated(NanSubscribeTerminatedInd *event);
53     int getNanFollowup(NanFollowupInd *event);
54     int getNanDiscEngEvent(NanDiscEngEventInd *event);
55     int getNanDisabled(NanDisabledInd *event);
56     int getNanTca(NanTCAInd *event);
57     int getNanBeaconSdfPayload(NanBeaconSdfPayloadInd *event);
58     //Internal cleanup function
59     void cleanup();
60 
61     static NanCommand *mNanCommandInstance;
62 
63     // Other private helper functions
64     int calcNanTransmitPostDiscoverySize(
65         const NanTransmitPostDiscovery *pPostDiscovery);
66     void fillNanSocialChannelParamVal(
67         const NanSocialChannelScanParams *pScanParams,
68         u32* pChannelParamArr);
69     u32 getNanTransmitPostConnectivityCapabilityVal(
70         const NanTransmitPostConnectivityCapability *pCapab);
71     void fillNanTransmitPostDiscoveryVal(
72         const NanTransmitPostDiscovery *pTxDisc,
73         u8 *pOutValue);
74     int calcNanFurtherAvailabilityMapSize(
75         const NanFurtherAvailabilityMap *pFam);
76     void fillNanFurtherAvailabilityMapVal(
77         const NanFurtherAvailabilityMap *pFam,
78         u8 *pOutValue);
79 
80     void getNanReceivePostConnectivityCapabilityVal(
81         const u8* pInValue,
82         NanReceivePostConnectivityCapability *pRxCapab);
83     void getNanReceiveSdeaCtrlParams(const u8* pInValue,
84         NanSdeaCtrlParams *pPeerSdeaParams);
85     int getNanReceivePostDiscoveryVal(const u8 *pInValue,
86                                       u32 length,
87                                       NanReceivePostDiscovery *pRxDisc);
88     int getNanFurtherAvailabilityMap(const u8 *pInValue,
89                                      u32 length,
90                                      u8* num_chans,
91                                      NanFurtherAvailabilityChannel *pFac);
92     void handleNanStatsResponse(NanStatsType stats_type,
93                                 char* rspBuf,
94                                 NanStatsResponse *pRsp,
95                                 u32 message_len);
96 
97     //Function which unparses the data and calls the NotifyResponse
98     int handleNdpResponse(NanResponseType ndpCmdtyp, struct nlattr **tb_vendor);
99     int handleNdpIndication(u32 ndpCmdType, struct nlattr **tb_vendor);
100     int getNdpRequest(struct nlattr **tb_vendor, NanDataPathRequestInd *event);
101     int getNdpConfirm(struct nlattr **tb_vendor, NanDataPathConfirmInd *event);
102     int getNdpEnd(struct nlattr **tb_vendor, NanDataPathEndInd *event);
103     int getNanTransmitFollowupInd(NanTransmitFollowupInd *event);
104     int getNanRangeRequestReceivedInd(NanRangeRequestInd *event);
105     int getNanRangeReportInd(NanRangeReportInd *event);
106     int getNdpScheduleUpdate(struct nlattr **tb_vendor, NanDataPathScheduleUpdateInd *event);
107 public:
108     NanCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd);
109     static NanCommand* instance(wifi_handle handle);
110     virtual ~NanCommand();
111 
112     // This function implements creation of NAN specific Request
113     // based on  the request type
114     virtual wifi_error create();
115     virtual wifi_error requestEvent();
116     virtual int handleResponse(WifiEvent &reply);
117     virtual int handleEvent(WifiEvent &event);
118     wifi_error setCallbackHandler(NanCallbackHandler nHandler);
119 
120 
121     //Functions to fill the vendor data appropriately
122     wifi_error putNanEnable(transaction_id id, const NanEnableRequest *pReq);
123     wifi_error putNanDisable(transaction_id id);
124     wifi_error putNanPublish(transaction_id id, const NanPublishRequest *pReq);
125     wifi_error putNanPublishCancel(transaction_id id, const NanPublishCancelRequest *pReq);
126     wifi_error putNanSubscribe(transaction_id id, const NanSubscribeRequest *pReq);
127     wifi_error putNanSubscribeCancel(transaction_id id, const NanSubscribeCancelRequest *pReq);
128     wifi_error putNanTransmitFollowup(transaction_id id, const NanTransmitFollowupRequest *pReq);
129     wifi_error putNanStats(transaction_id id, const NanStatsRequest *pReq);
130     wifi_error putNanConfig(transaction_id id, const NanConfigRequest *pReq);
131     wifi_error putNanTCA(transaction_id id, const NanTCARequest *pReq);
132     wifi_error putNanBeaconSdfPayload(transaction_id id, const NanBeaconSdfPayloadRequest *pReq);
133     wifi_error getNanStaParameter(wifi_interface_handle iface, NanStaParameter *pRsp);
134     wifi_error putNanCapabilities(transaction_id id);
135     wifi_error putNanDebugCommand(NanDebugParams debug, int debug_msg_length);
136 
137     /* Functions for NAN error translation
138        For NanResponse, NanPublishTerminatedInd, NanSubscribeTerminatedInd,
139        NanDisabledInd, NanTransmitFollowupInd:
140        function to translate firmware specific errors
141        to generic freamework error along with the error string
142     */
143     void NanErrorTranslation(NanInternalStatusType firmwareErrorRecvd,
144                              u32 valueRcvd,
145                              void *pRsp,
146                              bool is_ndp_rsp);
147 };
148 #endif /* __WIFI_HAL_NAN_COMMAND_H__ */
149 
150