Commit | Line | Data |
---|---|---|
d3a587e8 JPS |
1 | |
2 | #include <stdint.h> | |
3 | #include <stddef.h> | |
4 | #include <fcntl.h> | |
5 | #include <sys/socket.h> | |
6 | #include <netlink/genl/genl.h> | |
7 | #include <netlink/genl/family.h> | |
8 | #include <netlink/genl/ctrl.h> | |
9 | #include <linux/rtnetlink.h> | |
10 | #include <netpacket/packet.h> | |
11 | #include <linux/filter.h> | |
12 | #include <linux/errqueue.h> | |
13 | #include <linux/pkt_sched.h> | |
14 | #include <netlink/object-api.h> | |
15 | #include <netlink/netlink.h> | |
16 | #include <netlink/socket.h> | |
17 | #include <netlink/handlers.h> | |
18 | ||
19 | #include "sync.h" | |
20 | ||
21 | #include <utils/Log.h> | |
22 | ||
23 | #include "wifi_hal.h" | |
24 | #include "common.h" | |
25 | #include "cpp_bindings.h" | |
26 | ||
27 | #define SLSI_WIFI_HAL_NAN_VERSION 1 | |
28 | ||
29 | #define CHECK_WIFI_STATUS_RETURN_FAIL(result, LOGSTR) \ | |
30 | if (result != WIFI_SUCCESS) {\ | |
31 | ALOGE(LOGSTR" [result:%d]", result);\ | |
32 | return result;\ | |
33 | } | |
34 | ||
35 | #define CHECK_CONFIG_PUT_8_RETURN_FAIL(config, val, nan_attribute, request, result, FAIL_STR) \ | |
36 | if (config) {\ | |
37 | result = request.put_u8(nan_attribute, val); \ | |
38 | if (result != WIFI_SUCCESS) {\ | |
39 | ALOGE(FAIL_STR" [result:%d]", result);\ | |
40 | return result;\ | |
41 | }\ | |
42 | } | |
43 | ||
44 | #define CHECK_CONFIG_PUT_16_RETURN_FAIL(config, val, nan_attribute, request, result, FAIL_STR) \ | |
45 | if (config) {\ | |
46 | result = request.put_u16(nan_attribute, val); \ | |
47 | if (result != WIFI_SUCCESS) {\ | |
48 | ALOGE(FAIL_STR" [result:%d]", result);\ | |
49 | return result;\ | |
50 | }\ | |
51 | } | |
52 | ||
53 | ||
54 | #define CHECK_CONFIG_PUT_32_RETURN_FAIL(config, val, nan_attribute, request, result, FAIL_STR) \ | |
55 | if (config) {\ | |
56 | result = request.put_u32(nan_attribute, val); \ | |
57 | if (result != WIFI_SUCCESS) {\ | |
58 | ALOGE(FAIL_STR" [result:%d]", result);\ | |
59 | return result;\ | |
60 | }\ | |
61 | } | |
62 | ||
63 | #define CHECK_CONFIG_PUT_RETURN_FAIL(config, valptr, len, nan_attribute, request, result, FAIL_STR) \ | |
64 | if (config) {\ | |
65 | result = request.put(nan_attribute, valptr, len); \ | |
66 | if (result != WIFI_SUCCESS) {\ | |
67 | ALOGE(FAIL_STR" [result:%d]", result);\ | |
68 | return result;\ | |
69 | }\ | |
70 | } | |
71 | ||
72 | typedef enum { | |
73 | NAN_REQ_ATTR_MASTER_PREF, | |
74 | NAN_REQ_ATTR_CLUSTER_LOW, | |
75 | NAN_REQ_ATTR_CLUSTER_HIGH, | |
76 | NAN_REQ_ATTR_HOP_COUNT_LIMIT_VAL, | |
77 | NAN_REQ_ATTR_SID_BEACON_VAL, | |
78 | ||
79 | NAN_REQ_ATTR_SUPPORT_2G4_VAL, | |
80 | NAN_REQ_ATTR_SUPPORT_5G_VAL, | |
81 | ||
82 | NAN_REQ_ATTR_RSSI_CLOSE_2G4_VAL, | |
83 | NAN_REQ_ATTR_RSSI_MIDDLE_2G4_VAL, | |
84 | NAN_REQ_ATTR_RSSI_PROXIMITY_2G4_VAL, | |
85 | NAN_REQ_ATTR_BEACONS_2G4_VAL, | |
86 | NAN_REQ_ATTR_SDF_2G4_VAL, | |
87 | NAN_REQ_ATTR_CHANNEL_2G4_MHZ_VAL, | |
88 | NAN_REQ_ATTR_RSSI_PROXIMITY_VAL, | |
89 | ||
90 | ||
91 | NAN_REQ_ATTR_RSSI_CLOSE_5G_VAL, | |
92 | NAN_REQ_ATTR_RSSI_CLOSE_PROXIMITY_5G_VAL, | |
93 | NAN_REQ_ATTR_RSSI_MIDDLE_5G_VAL, | |
94 | NAN_REQ_ATTR_RSSI_PROXIMITY_5G_VAL, | |
95 | NAN_REQ_ATTR_BEACON_5G_VAL, | |
96 | NAN_REQ_ATTR_SDF_5G_VAL, | |
97 | NAN_REQ_ATTR_CHANNEL_5G_MHZ_VAL, | |
98 | ||
99 | NAN_REQ_ATTR_RSSI_WINDOW_SIZE_VAL, | |
100 | NAN_REQ_ATTR_OUI_VAL, | |
101 | NAN_REQ_ATTR_MAC_ADDR_VAL, | |
102 | NAN_REQ_ATTR_CLUSTER_VAL, | |
103 | NAN_REQ_ATTR_SOCIAL_CH_SCAN_DWELL_TIME, | |
104 | NAN_REQ_ATTR_SOCIAL_CH_SCAN_PERIOD, | |
105 | NAN_REQ_ATTR_RANDOM_FACTOR_FORCE_VAL, | |
106 | NAN_REQ_ATTR_HOP_COUNT_FORCE_VAL, | |
107 | NAN_REQ_ATTR_CONN_CAPABILITY_PAYLOAD_TX, | |
108 | NAN_REQ_ATTR_CONN_CAPABILITY_IBSS, | |
109 | NAN_REQ_ATTR_CONN_CAPABILITY_WFD, | |
110 | NAN_REQ_ATTR_CONN_CAPABILITY_WFDS, | |
111 | NAN_REQ_ATTR_CONN_CAPABILITY_TDLS, | |
112 | NAN_REQ_ATTR_CONN_CAPABILITY_MESH, | |
113 | NAN_REQ_ATTR_CONN_CAPABILITY_WLAN_INFRA, | |
114 | NAN_REQ_ATTR_DISCOVERY_ATTR_NUM_ENTRIES, | |
115 | NAN_REQ_ATTR_DISCOVERY_ATTR_VAL, | |
116 | NAN_REQ_ATTR_CONN_TYPE, | |
117 | NAN_REQ_ATTR_NAN_ROLE, | |
118 | NAN_REQ_ATTR_TRANSMIT_FREQ, | |
119 | NAN_REQ_ATTR_AVAILABILITY_DURATION, | |
120 | NAN_REQ_ATTR_AVAILABILITY_INTERVAL, | |
121 | NAN_REQ_ATTR_MESH_ID_LEN, | |
122 | NAN_REQ_ATTR_MESH_ID, | |
123 | NAN_REQ_ATTR_INFRASTRUCTURE_SSID_LEN, | |
124 | NAN_REQ_ATTR_INFRASTRUCTURE_SSID, | |
125 | NAN_REQ_ATTR_FURTHER_AVAIL_NUM_ENTRIES, | |
126 | NAN_REQ_ATTR_FURTHER_AVAIL_VAL, | |
127 | NAN_REQ_ATTR_FURTHER_AVAIL_ENTRY_CTRL, | |
128 | NAN_REQ_ATTR_FURTHER_AVAIL_CHAN_CLASS, | |
129 | NAN_REQ_ATTR_FURTHER_AVAIL_CHAN, | |
130 | NAN_REQ_ATTR_FURTHER_AVAIL_CHAN_MAPID, | |
131 | NAN_REQ_ATTR_FURTHER_AVAIL_INTERVAL_BITMAP, | |
132 | NAN_REQ_ATTR_PUBLISH_ID, | |
133 | NAN_REQ_ATTR_PUBLISH_TTL, | |
134 | NAN_REQ_ATTR_PUBLISH_PERIOD, | |
135 | NAN_REQ_ATTR_PUBLISH_TYPE, | |
136 | NAN_REQ_ATTR_PUBLISH_TX_TYPE, | |
137 | NAN_REQ_ATTR_PUBLISH_COUNT, | |
138 | NAN_REQ_ATTR_PUBLISH_SERVICE_NAME_LEN, | |
139 | NAN_REQ_ATTR_PUBLISH_SERVICE_NAME, | |
140 | NAN_REQ_ATTR_PUBLISH_MATCH_ALGO, | |
141 | NAN_REQ_ATTR_PUBLISH_SERVICE_INFO_LEN, | |
142 | NAN_REQ_ATTR_PUBLISH_SERVICE_INFO, | |
143 | NAN_REQ_ATTR_PUBLISH_RX_MATCH_FILTER_LEN, | |
144 | NAN_REQ_ATTR_PUBLISH_RX_MATCH_FILTER, | |
145 | NAN_REQ_ATTR_PUBLISH_TX_MATCH_FILTER_LEN, | |
146 | NAN_REQ_ATTR_PUBLISH_TX_MATCH_FILTER, | |
147 | NAN_REQ_ATTR_PUBLISH_RSSI_THRESHOLD_FLAG, | |
148 | NAN_REQ_ATTR_PUBLISH_CONN_MAP, | |
149 | NAN_REQ_ATTR_PUBLISH_RECV_IND_CFG, | |
150 | NAN_REQ_ATTR_SUBSCRIBE_ID, | |
151 | NAN_REQ_ATTR_SUBSCRIBE_TTL, | |
152 | NAN_REQ_ATTR_SUBSCRIBE_PERIOD, | |
153 | NAN_REQ_ATTR_SUBSCRIBE_TYPE, | |
154 | NAN_REQ_ATTR_SUBSCRIBE_RESP_FILTER_TYPE, | |
155 | NAN_REQ_ATTR_SUBSCRIBE_RESP_INCLUDE, | |
156 | NAN_REQ_ATTR_SUBSCRIBE_USE_RESP_FILTER, | |
157 | NAN_REQ_ATTR_SUBSCRIBE_SSI_REQUIRED, | |
158 | NAN_REQ_ATTR_SUBSCRIBE_MATCH_INDICATOR, | |
159 | NAN_REQ_ATTR_SUBSCRIBE_COUNT, | |
160 | NAN_REQ_ATTR_SUBSCRIBE_SERVICE_NAME_LEN, | |
161 | NAN_REQ_ATTR_SUBSCRIBE_SERVICE_NAME, | |
162 | NAN_REQ_ATTR_SUBSCRIBE_SERVICE_INFO_LEN, | |
163 | NAN_REQ_ATTR_SUBSCRIBE_SERVICE_INFO, | |
164 | NAN_REQ_ATTR_SUBSCRIBE_RX_MATCH_FILTER_LEN, | |
165 | NAN_REQ_ATTR_SUBSCRIBE_RX_MATCH_FILTER, | |
166 | NAN_REQ_ATTR_SUBSCRIBE_TX_MATCH_FILTER_LEN, | |
167 | NAN_REQ_ATTR_SUBSCRIBE_TX_MATCH_FILTER, | |
168 | NAN_REQ_ATTR_SUBSCRIBE_RSSI_THRESHOLD_FLAG, | |
169 | NAN_REQ_ATTR_SUBSCRIBE_CONN_MAP, | |
170 | NAN_REQ_ATTR_SUBSCRIBE_NUM_INTF_ADDR_PRESENT, | |
171 | NAN_REQ_ATTR_SUBSCRIBE_INTF_ADDR, | |
172 | NAN_REQ_ATTR_SUBSCRIBE_RECV_IND_CFG, | |
173 | NAN_REQ_ATTR_FOLLOWUP_ID, | |
174 | NAN_REQ_ATTR_FOLLOWUP_REQUESTOR_ID, | |
175 | NAN_REQ_ATTR_FOLLOWUP_ADDR, | |
176 | NAN_REQ_ATTR_FOLLOWUP_PRIORITY, | |
177 | NAN_REQ_ATTR_FOLLOWUP_SERVICE_NAME_LEN, | |
178 | NAN_REQ_ATTR_FOLLOWUP_SERVICE_NAME, | |
179 | NAN_REQ_ATTR_FOLLOWUP_TX_WINDOW, | |
180 | NAN_REQ_ATTR_FOLLOWUP_RECV_IND_CFG, | |
f8c9e3bb JPS |
181 | NAN_REQ_ATTR_SUBSCRIBE_SID_BEACON_VAL, |
182 | NAN_REQ_ATTR_DW_2G4_INTERVAL, | |
183 | NAN_REQ_ATTR_DW_5G_INTERVAL, | |
184 | NAN_REQ_ATTR_DISC_MAC_ADDR_RANDOM_INTERVAL, | |
185 | NAN_REQ_ATTR_PUBLISH_SDEA_LEN, | |
e8aa68c3 JPS |
186 | NAN_REQ_ATTR_PUBLISH_SDEA, |
187 | ||
188 | NAN_REQ_ATTR_RANGING_AUTO_RESPONSE, | |
189 | NAN_REQ_ATTR_SDEA_PARAM_NDP_TYPE, | |
190 | NAN_REQ_ATTR_SDEA_PARAM_SECURITY_CFG, | |
191 | NAN_REQ_ATTR_SDEA_PARAM_RANGING_STATE, | |
192 | NAN_REQ_ATTR_SDEA_PARAM_RANGE_REPORT, | |
193 | NAN_REQ_ATTR_SDEA_PARAM_QOS_CFG, | |
194 | NAN_REQ_ATTR_RANGING_CFG_INTERVAL, | |
195 | NAN_REQ_ATTR_RANGING_CFG_INDICATION, | |
196 | NAN_REQ_ATTR_RANGING_CFG_INGRESS_MM, | |
197 | NAN_REQ_ATTR_RANGING_CFG_EGRESS_MM, | |
198 | NAN_REQ_ATTR_CIPHER_TYPE, | |
199 | NAN_REQ_ATTR_SCID_LEN, | |
200 | NAN_REQ_ATTR_SCID, | |
201 | NAN_REQ_ATTR_SECURITY_KEY_TYPE, | |
202 | NAN_REQ_ATTR_SECURITY_PMK_LEN, | |
203 | NAN_REQ_ATTR_SECURITY_PMK, | |
204 | NAN_REQ_ATTR_SECURITY_PASSPHRASE_LEN, | |
205 | NAN_REQ_ATTR_SECURITY_PASSPHRASE, | |
206 | NAN_REQ_ATTR_RANGE_RESPONSE_CFG_PUBLISH_ID, | |
207 | NAN_REQ_ATTR_RANGE_RESPONSE_CFG_REQUESTOR_ID, | |
208 | NAN_REQ_ATTR_RANGE_RESPONSE_CFG_PEER_ADDR, | |
209 | NAN_REQ_ATTR_RANGE_RESPONSE_CFG_RANGING_RESPONSE | |
d3a587e8 JPS |
210 | } NAN_REQ_ATTRIBUTES; |
211 | ||
212 | typedef enum { | |
f8c9e3bb JPS |
213 | NAN_REPLY_ATTR_STATUS_TYPE, |
214 | NAN_REPLY_ATTR_VALUE, | |
215 | NAN_REPLY_ATTR_RESPONSE_TYPE, | |
216 | NAN_REPLY_ATTR_PUBLISH_SUBSCRIBE_TYPE, | |
217 | NAN_REPLY_ATTR_CAP_MAX_CONCURRENT_CLUSTER, | |
218 | NAN_REPLY_ATTR_CAP_MAX_PUBLISHES, | |
219 | NAN_REPLY_ATTR_CAP_MAX_SUBSCRIBES, | |
220 | NAN_REPLY_ATTR_CAP_MAX_SERVICE_NAME_LEN, | |
221 | NAN_REPLY_ATTR_CAP_MAX_MATCH_FILTER_LEN, | |
222 | NAN_REPLY_ATTR_CAP_MAX_TOTAL_MATCH_FILTER_LEN, | |
223 | NAN_REPLY_ATTR_CAP_MAX_SERVICE_SPECIFIC_INFO_LEN, | |
224 | NAN_REPLY_ATTR_CAP_MAX_VSA_DATA_LEN, | |
225 | NAN_REPLY_ATTR_CAP_MAX_MESH_DATA_LEN, | |
226 | NAN_REPLY_ATTR_CAP_MAX_NDI_INTERFACES, | |
227 | NAN_REPLY_ATTR_CAP_MAX_NDP_SESSIONS, | |
228 | NAN_REPLY_ATTR_CAP_MAX_APP_INFO_LEN, | |
d3a587e8 JPS |
229 | } NAN_RESP_ATTRIBUTES; |
230 | ||
231 | typedef enum { | |
650a9e6a | 232 | NAN_EVT_ATTR_MATCH_PUBLISH_SUBSCRIBE_ID = 0, |
d3a587e8 JPS |
233 | NAN_EVT_ATTR_MATCH_REQUESTOR_INSTANCE_ID, |
234 | NAN_EVT_ATTR_MATCH_ADDR, | |
235 | NAN_EVT_ATTR_MATCH_SERVICE_SPECIFIC_INFO_LEN, | |
236 | NAN_EVT_ATTR_MATCH_SERVICE_SPECIFIC_INFO, | |
237 | NAN_EVT_ATTR_MATCH_SDF_MATCH_FILTER_LEN, | |
238 | NAN_EVT_ATTR_MATCH_SDF_MATCH_FILTER, | |
239 | NAN_EVT_ATTR_MATCH_MATCH_OCCURED_FLAG, | |
240 | NAN_EVT_ATTR_MATCH_OUT_OF_RESOURCE_FLAG, | |
241 | NAN_EVT_ATTR_MATCH_RSSI_VALUE, | |
242 | /*CONN_CAPABILITY*/ | |
650a9e6a | 243 | NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_WFD_SUPPORTED = 10, |
d3a587e8 JPS |
244 | NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_WFDS_SUPPORTED, |
245 | NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_TDLS_SUPPORTED, | |
246 | NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_IBSS_SUPPORTED, | |
247 | NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_MESH_SUPPORTED, | |
248 | NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_WLAN_INFRA_FIELD, | |
249 | NAN_EVT_ATTR_MATCH_NUM_RX_DISCOVERY_ATTR, | |
250 | NAN_EVT_ATTR_MATCH_RX_DISCOVERY_ATTR, | |
251 | /*NANRECEIVEPOSTDISCOVERY DISCOVERY_ATTR,*/ | |
252 | NAN_EVT_ATTR_MATCH_DISC_ATTR_TYPE, | |
253 | NAN_EVT_ATTR_MATCH_DISC_ATTR_ROLE, | |
650a9e6a | 254 | NAN_EVT_ATTR_MATCH_DISC_ATTR_DURATION = 20, |
d3a587e8 JPS |
255 | NAN_EVT_ATTR_MATCH_DISC_ATTR_AVAIL_INTERVAL_BITMAP, |
256 | NAN_EVT_ATTR_MATCH_DISC_ATTR_MAPID, | |
257 | NAN_EVT_ATTR_MATCH_DISC_ATTR_ADDR, | |
258 | NAN_EVT_ATTR_MATCH_DISC_ATTR_MESH_ID_LEN, | |
259 | NAN_EVT_ATTR_MATCH_DISC_ATTR_MESH_ID, | |
260 | NAN_EVT_ATTR_MATCH_DISC_ATTR_INFRASTRUCTURE_SSID_LEN, | |
261 | NAN_EVT_ATTR_MATCH_DISC_ATTR_INFRASTRUCTURE_SSID_VAL, | |
262 | ||
263 | NAN_EVT_ATTR_MATCH_NUM_CHANS, | |
264 | NAN_EVT_ATTR_MATCH_FAMCHAN, | |
265 | /*FAMCHAN[32],*/ | |
650a9e6a | 266 | NAN_EVT_ATTR_MATCH_FAM_ENTRY_CONTROL = 30, |
d3a587e8 JPS |
267 | NAN_EVT_ATTR_MATCH_FAM_CLASS_VAL, |
268 | NAN_EVT_ATTR_MATCH_FAM_CHANNEL, | |
269 | NAN_EVT_ATTR_MATCH_FAM_MAPID, | |
270 | NAN_EVT_ATTR_MATCH_FAM_AVAIL_INTERVAL_BITMAP, | |
271 | NAN_EVT_ATTR_MATCH_CLUSTER_ATTRIBUTE_LEN, | |
272 | NAN_EVT_ATTR_MATCH_CLUSTER_ATTRIBUTE, | |
273 | NAN_EVT_ATTR_PUBLISH_ID, | |
274 | NAN_EVT_ATTR_PUBLISH_REASON, | |
275 | NAN_EVT_ATTR_SUBSCRIBE_ID, | |
650a9e6a | 276 | NAN_EVT_ATTR_SUBSCRIBE_REASON = 40, |
d3a587e8 JPS |
277 | NAN_EVT_ATTR_DISABLED_REASON, |
278 | NAN_EVT_ATTR_FOLLOWUP_PUBLISH_SUBSCRIBE_ID, | |
279 | NAN_EVT_ATTR_FOLLOWUP_REQUESTOR_INSTANCE_ID, | |
280 | NAN_EVT_ATTR_FOLLOWUP_ADDR, | |
281 | NAN_EVT_ATTR_FOLLOWUP_DW_OR_FAW, | |
282 | NAN_EVT_ATTR_FOLLOWUP_SERVICE_SPECIFIC_INFO_LEN, | |
283 | NAN_EVT_ATTR_FOLLOWUP_SERVICE_SPECIFIC_INFO, | |
f8c9e3bb | 284 | NAN_EVT_ATTR_DISCOVERY_ENGINE_EVT_TYPE , |
d3a587e8 | 285 | NAN_EVT_ATTR_DISCOVERY_ENGINE_MAC_ADDR, |
650a9e6a | 286 | NAN_EVT_ATTR_DISCOVERY_ENGINE_CLUSTER = 50, |
f8c9e3bb | 287 | NAN_EVT_ATTR_SDEA, |
e8aa68c3 JPS |
288 | NAN_EVT_ATTR_SDEA_LEN, |
289 | NAN_EVT_ATTR_SCID, | |
290 | NAN_EVT_ATTR_SCID_LEN, | |
291 | NAN_EVT_ATTR_SDEA_PARAM_CONFIG_NAN_DATA_PATH, | |
292 | NAN_EVT_ATTR_SDEA_PARAM_NDP_TYPE, | |
293 | NAN_EVT_ATTR_SDEA_PARAM_SECURITY_CONFIG, | |
294 | NAN_EVT_ATTR_SDEA_PARAM_RANGE_STATE, | |
295 | NAN_EVT_ATTR_SDEA_PARAM_RANGE_REPORT, | |
650a9e6a | 296 | NAN_EVT_ATTR_SDEA_PARAM_QOS_CFG = 60, |
e8aa68c3 | 297 | NAN_EVT_ATTR_RANGE_MEASUREMENT_MM, |
650a9e6a JPS |
298 | NAN_EVT_ATTR_RANGEING_EVENT_TYPE, |
299 | NAN_EVT_ATTR_SECURITY_CIPHER_TYPE, | |
300 | NAN_EVT_ATTR_STATUS | |
d3a587e8 JPS |
301 | } NAN_EVT_ATTRIBUTES; |
302 | ||
303 | class NanCommand : public WifiCommand { | |
304 | static NanCallbackHandler callbackEventHandler; | |
305 | int subscribeID[2]; | |
306 | int publishID[2]; | |
307 | int followupID[2]; | |
650a9e6a JPS |
308 | transaction_id followupTid; |
309 | transaction_id publishTid; | |
310 | transaction_id publishCancelTid; | |
311 | transaction_id subscribeTid; | |
312 | transaction_id subscribeCancelTid; | |
313 | transaction_id enableTid; | |
314 | transaction_id disableTid; | |
315 | transaction_id configTid; | |
316 | transaction_id capabilitiesTid; | |
d3a587e8 JPS |
317 | int version; |
318 | NanCapabilities capabilities; | |
319 | ||
320 | void registerNanEvents(void) { | |
321 | registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_PUBLISH_TERMINATED); | |
322 | registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_MATCH); | |
323 | registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_MATCH_EXPIRED); | |
324 | registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_SUBSCRIBE_TERMINATED); | |
325 | registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_FOLLOWUP); | |
326 | registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_DISCOVERY_ENGINE); | |
650a9e6a | 327 | registerVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_TRANSMIT_FOLLOWUP_STATUS); |
d3a587e8 JPS |
328 | } |
329 | ||
330 | void unregisterNanEvents(void) { | |
331 | unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_PUBLISH_TERMINATED); | |
332 | unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_MATCH); | |
333 | unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_MATCH_EXPIRED); | |
334 | unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_SUBSCRIBE_TERMINATED); | |
335 | unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_FOLLOWUP); | |
336 | unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_DISCOVERY_ENGINE); | |
650a9e6a | 337 | unregisterVendorHandler(GOOGLE_OUI, SLSI_NAN_EVENT_TRANSMIT_FOLLOWUP_STATUS); |
d3a587e8 JPS |
338 | } |
339 | ||
340 | int processResponse(WifiEvent &reply, NanResponseMsg *response) { | |
341 | NanCapabilities *capabilities = &response->body.nan_capabilities; | |
342 | nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA); | |
d3a587e8 JPS |
343 | unsigned int val; |
344 | ||
345 | for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) { | |
346 | switch(nl_itr.get_type()) { | |
347 | case NAN_REPLY_ATTR_STATUS_TYPE: | |
348 | response->status = NanStatusType(nl_itr.get_u32()); | |
349 | break; | |
350 | case NAN_REPLY_ATTR_VALUE: | |
351 | val = nl_itr.get_u32(); | |
352 | if (val) { | |
353 | strncpy(response->nan_error, "Lower_layer_error",NAN_ERROR_STR_LEN); | |
354 | } | |
355 | break; | |
356 | case NAN_REPLY_ATTR_RESPONSE_TYPE: | |
357 | response->response_type = NanResponseType(nl_itr.get_u32()); | |
358 | break; | |
359 | case NAN_REPLY_ATTR_PUBLISH_SUBSCRIBE_TYPE: | |
360 | response->body.publish_response.publish_id = nl_itr.get_u16(); | |
361 | break; | |
362 | case NAN_REPLY_ATTR_CAP_MAX_CONCURRENT_CLUSTER: | |
363 | capabilities->max_concurrent_nan_clusters = nl_itr.get_u32(); | |
364 | break; | |
365 | case NAN_REPLY_ATTR_CAP_MAX_PUBLISHES: | |
366 | capabilities->max_publishes = nl_itr.get_u32(); | |
367 | break; | |
368 | case NAN_REPLY_ATTR_CAP_MAX_SUBSCRIBES: | |
369 | capabilities->max_subscribes = nl_itr.get_u32(); | |
370 | break; | |
371 | case NAN_REPLY_ATTR_CAP_MAX_SERVICE_NAME_LEN: | |
372 | capabilities->max_service_name_len = nl_itr.get_u32(); | |
373 | break; | |
374 | case NAN_REPLY_ATTR_CAP_MAX_MATCH_FILTER_LEN: | |
375 | capabilities->max_match_filter_len = nl_itr.get_u32(); | |
376 | break; | |
377 | case NAN_REPLY_ATTR_CAP_MAX_TOTAL_MATCH_FILTER_LEN: | |
378 | capabilities->max_total_match_filter_len = nl_itr.get_u32(); | |
379 | break; | |
380 | case NAN_REPLY_ATTR_CAP_MAX_SERVICE_SPECIFIC_INFO_LEN: | |
381 | capabilities->max_service_specific_info_len = nl_itr.get_u32(); | |
382 | break; | |
383 | case NAN_REPLY_ATTR_CAP_MAX_VSA_DATA_LEN: | |
384 | capabilities->max_vsa_data_len = nl_itr.get_u32(); | |
385 | break; | |
386 | case NAN_REPLY_ATTR_CAP_MAX_MESH_DATA_LEN: | |
387 | capabilities->max_mesh_data_len = nl_itr.get_u32(); | |
388 | break; | |
389 | case NAN_REPLY_ATTR_CAP_MAX_NDI_INTERFACES: | |
390 | capabilities->max_ndi_interfaces = nl_itr.get_u32(); | |
391 | break; | |
392 | case NAN_REPLY_ATTR_CAP_MAX_NDP_SESSIONS: | |
393 | capabilities->max_ndp_sessions = nl_itr.get_u32(); | |
394 | break; | |
395 | case NAN_REPLY_ATTR_CAP_MAX_APP_INFO_LEN: | |
396 | capabilities->max_app_info_len = nl_itr.get_u32(); | |
397 | break; | |
398 | default : | |
399 | ALOGE("received unknown type(%d) in response", nl_itr.get_type()); | |
400 | return NL_SKIP; | |
401 | } | |
402 | } | |
403 | this->capabilities = *capabilities; | |
404 | return NL_OK; | |
405 | } | |
406 | ||
407 | int processMatchEvent(WifiEvent &event) { | |
408 | NanMatchInd ind; | |
409 | memset(&ind,0,sizeof(NanMatchInd)); | |
410 | int famchan_idx = 0, disc_idx = 0; | |
411 | nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA); | |
412 | ||
413 | for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) { | |
414 | switch(nl_itr.get_type()) { | |
415 | case NAN_EVT_ATTR_MATCH_PUBLISH_SUBSCRIBE_ID: | |
416 | ind.publish_subscribe_id = nl_itr.get_u16(); | |
417 | break; | |
418 | case NAN_EVT_ATTR_MATCH_REQUESTOR_INSTANCE_ID: | |
419 | ind.requestor_instance_id = nl_itr.get_u32(); | |
420 | break; | |
421 | case NAN_EVT_ATTR_MATCH_ADDR: | |
422 | memcpy(ind.addr, nl_itr.get_data(), NAN_MAC_ADDR_LEN); | |
423 | break; | |
424 | case NAN_EVT_ATTR_MATCH_SERVICE_SPECIFIC_INFO_LEN: | |
425 | ind.service_specific_info_len = nl_itr.get_u16(); | |
426 | break; | |
427 | case NAN_EVT_ATTR_MATCH_SERVICE_SPECIFIC_INFO: | |
428 | memcpy(ind.service_specific_info, nl_itr.get_data(), ind.service_specific_info_len); | |
429 | break; | |
430 | case NAN_EVT_ATTR_MATCH_SDF_MATCH_FILTER_LEN: | |
431 | ind.sdf_match_filter_len = nl_itr.get_u16(); | |
432 | break; | |
433 | case NAN_EVT_ATTR_MATCH_SDF_MATCH_FILTER: | |
434 | memcpy(ind.sdf_match_filter, nl_itr.get_data(), ind.sdf_match_filter_len); | |
435 | break; | |
436 | case NAN_EVT_ATTR_MATCH_MATCH_OCCURED_FLAG: | |
437 | ind.match_occured_flag = nl_itr.get_u8(); | |
438 | break; | |
439 | case NAN_EVT_ATTR_MATCH_OUT_OF_RESOURCE_FLAG: | |
440 | ind.out_of_resource_flag = nl_itr.get_u8(); | |
441 | break; | |
442 | case NAN_EVT_ATTR_MATCH_RSSI_VALUE: | |
443 | ind.rssi_value = nl_itr.get_u8(); | |
444 | break; | |
445 | case NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_IBSS_SUPPORTED: | |
446 | ind.conn_capability.is_ibss_supported = nl_itr.get_u8(); | |
447 | break; | |
448 | case NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_WFD_SUPPORTED: | |
449 | ind.conn_capability.is_wfd_supported = nl_itr.get_u8(); | |
450 | break; | |
451 | case NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_WFDS_SUPPORTED: | |
452 | ind.conn_capability.is_wfds_supported = nl_itr.get_u8(); | |
453 | break; | |
454 | case NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_TDLS_SUPPORTED: | |
455 | ind.conn_capability.is_tdls_supported = nl_itr.get_u8(); | |
456 | break; | |
457 | case NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_IS_MESH_SUPPORTED: | |
458 | ind.conn_capability.is_mesh_supported= nl_itr.get_u8(); | |
459 | break; | |
460 | case NAN_EVT_ATTR_MATCH_CONN_CAPABILITY_WLAN_INFRA_FIELD: | |
461 | ind.conn_capability.wlan_infra_field = nl_itr.get_u8(); | |
462 | break; | |
463 | case NAN_EVT_ATTR_MATCH_NUM_RX_DISCOVERY_ATTR: | |
464 | ind.num_rx_discovery_attr = nl_itr.get_u8(); | |
465 | break; | |
466 | case NAN_EVT_ATTR_MATCH_RX_DISCOVERY_ATTR: | |
467 | NanReceivePostDiscovery *disc_attr; | |
468 | disc_attr = &ind.discovery_attr[disc_idx]; | |
469 | disc_idx++; | |
470 | for(nl_iterator nl_nested_itr((struct nlattr *)nl_itr.get_data()); nl_nested_itr.has_next(); nl_nested_itr.next()) { | |
471 | switch(nl_nested_itr.get_type()) { | |
472 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_TYPE: | |
473 | disc_attr->type = (NanConnectionType)nl_nested_itr.get_u8(); | |
474 | break; | |
475 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_ROLE: | |
476 | disc_attr->role = (NanDeviceRole)nl_nested_itr.get_u8(); | |
477 | break; | |
478 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_DURATION: | |
479 | disc_attr->duration = (NanAvailDuration)nl_nested_itr.get_u8(); | |
480 | break; | |
481 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_AVAIL_INTERVAL_BITMAP: | |
482 | disc_attr->avail_interval_bitmap = nl_nested_itr.get_u32(); | |
483 | break; | |
484 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_MAPID: | |
485 | disc_attr->mapid = nl_nested_itr.get_u8(); | |
486 | break; | |
487 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_ADDR: | |
488 | memcpy(disc_attr->addr, nl_nested_itr.get_data(), NAN_MAC_ADDR_LEN); | |
489 | break; | |
490 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_MESH_ID_LEN: | |
491 | disc_attr->mesh_id_len = nl_nested_itr.get_u8(); | |
492 | break; | |
493 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_MESH_ID: | |
494 | memcpy(disc_attr->mesh_id, nl_nested_itr.get_data(), disc_attr->mesh_id_len); | |
495 | break; | |
496 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_INFRASTRUCTURE_SSID_LEN: | |
497 | disc_attr->infrastructure_ssid_len = nl_nested_itr.get_u16(); | |
498 | break; | |
499 | case NAN_EVT_ATTR_MATCH_DISC_ATTR_INFRASTRUCTURE_SSID_VAL: | |
500 | memcpy(disc_attr->infrastructure_ssid_val, nl_nested_itr.get_data(), disc_attr->infrastructure_ssid_len); | |
501 | break; | |
502 | } | |
503 | } | |
504 | break; | |
505 | case NAN_EVT_ATTR_MATCH_NUM_CHANS: | |
506 | ind.num_chans = nl_itr.get_u8(); | |
507 | break; | |
508 | case NAN_EVT_ATTR_MATCH_FAMCHAN: | |
509 | NanFurtherAvailabilityChannel *famchan; | |
510 | famchan = &ind.famchan[famchan_idx]; | |
511 | famchan_idx++; | |
512 | for(nl_iterator nl_nested_itr((struct nlattr *)nl_itr.get_data()); nl_nested_itr.has_next(); nl_nested_itr.next()) { | |
513 | switch(nl_nested_itr.get_type()) { | |
514 | case NAN_EVT_ATTR_MATCH_FAM_ENTRY_CONTROL: | |
515 | famchan->entry_control = (NanAvailDuration)nl_nested_itr.get_u8(); | |
516 | break; | |
517 | case NAN_EVT_ATTR_MATCH_FAM_CLASS_VAL: | |
518 | famchan->class_val = nl_nested_itr.get_u8(); | |
519 | break; | |
520 | case NAN_EVT_ATTR_MATCH_FAM_CHANNEL: | |
521 | famchan->channel = nl_nested_itr.get_u8(); | |
522 | break; | |
523 | case NAN_EVT_ATTR_MATCH_FAM_MAPID: | |
524 | famchan->mapid = nl_nested_itr.get_u8(); | |
525 | break; | |
526 | case NAN_EVT_ATTR_MATCH_FAM_AVAIL_INTERVAL_BITMAP: | |
527 | famchan->avail_interval_bitmap = nl_nested_itr.get_u32(); | |
528 | break; | |
529 | } | |
530 | } | |
45011ff7 | 531 | break; |
d3a587e8 JPS |
532 | case NAN_EVT_ATTR_MATCH_CLUSTER_ATTRIBUTE_LEN: |
533 | ind.cluster_attribute_len = nl_itr.get_u8(); | |
534 | break; | |
535 | case NAN_EVT_ATTR_MATCH_CLUSTER_ATTRIBUTE: | |
536 | memcpy(ind.cluster_attribute, nl_itr.get_data(), ind.cluster_attribute_len); | |
537 | break; | |
f8c9e3bb JPS |
538 | case NAN_EVT_ATTR_SDEA_LEN: |
539 | ind.sdea_service_specific_info_len = nl_itr.get_u16(); | |
540 | break; | |
541 | case NAN_EVT_ATTR_SDEA: | |
542 | memcpy(ind.sdea_service_specific_info, nl_itr.get_data(), ind.sdea_service_specific_info_len); | |
543 | break; | |
e8aa68c3 JPS |
544 | case NAN_EVT_ATTR_SCID_LEN: |
545 | ind.scid_len = nl_itr.get_u32(); | |
546 | break; | |
547 | case NAN_EVT_ATTR_SCID: | |
548 | memcpy(ind.scid, nl_itr.get_data(), ind.scid_len); | |
549 | break; | |
550 | case NAN_EVT_ATTR_SDEA_PARAM_CONFIG_NAN_DATA_PATH: | |
551 | ind.peer_sdea_params.config_nan_data_path = nl_itr.get_u8(); | |
552 | break; | |
553 | case NAN_EVT_ATTR_SDEA_PARAM_NDP_TYPE: | |
554 | ind.peer_sdea_params.ndp_type = (NdpType)nl_itr.get_u8(); | |
555 | break; | |
556 | case NAN_EVT_ATTR_SDEA_PARAM_SECURITY_CONFIG: | |
557 | ind.peer_sdea_params.security_cfg = (NanDataPathSecurityCfgStatus)nl_itr.get_u8(); | |
558 | break; | |
559 | case NAN_EVT_ATTR_SDEA_PARAM_RANGE_STATE: | |
560 | ind.peer_sdea_params.ranging_state = (NanRangingState)nl_itr.get_u8(); | |
561 | break; | |
562 | case NAN_EVT_ATTR_SDEA_PARAM_RANGE_REPORT: | |
563 | ind.peer_sdea_params.range_report = (NanRangeReport)nl_itr.get_u8(); | |
564 | break; | |
565 | case NAN_EVT_ATTR_SDEA_PARAM_QOS_CFG: | |
566 | ind.peer_sdea_params.qos_cfg = (NanQosCfgStatus)nl_itr.get_u8(); | |
567 | break; | |
568 | case NAN_EVT_ATTR_RANGE_MEASUREMENT_MM: | |
569 | ind.range_info.range_measurement_mm = nl_itr.get_u32(); | |
570 | break; | |
571 | case NAN_EVT_ATTR_RANGEING_EVENT_TYPE: | |
572 | ind.range_info.ranging_event_type = nl_itr.get_u32(); | |
573 | break; | |
d3a587e8 JPS |
574 | } |
575 | } | |
45011ff7 | 576 | |
d3a587e8 JPS |
577 | if (this->callbackEventHandler.EventMatch) |
578 | this->callbackEventHandler.EventMatch(&ind); | |
579 | return NL_OK; | |
580 | } | |
581 | ||
582 | int processMatchExpiredEvent(WifiEvent &event) { | |
583 | NanMatchExpiredInd ind; | |
584 | memset(&ind,0,sizeof(NanMatchExpiredInd)); | |
585 | ||
586 | for(nl_iterator nl_itr((struct nlattr *)event.get_vendor_data()); nl_itr.has_next(); nl_itr.next()) { | |
587 | switch(nl_itr.get_type()) { | |
588 | case NAN_EVT_ATTR_MATCH_PUBLISH_SUBSCRIBE_ID: | |
589 | ind.publish_subscribe_id = nl_itr.get_u16(); | |
590 | break; | |
591 | case NAN_EVT_ATTR_MATCH_REQUESTOR_INSTANCE_ID: | |
592 | ind.requestor_instance_id = nl_itr.get_u32(); | |
593 | break; | |
594 | default : | |
595 | ALOGE("processMatchExpiredEvent: unknown attribute(%d)", nl_itr.get_type()); | |
596 | return NL_SKIP; | |
597 | } | |
598 | } | |
599 | ||
600 | if (callbackEventHandler.EventMatchExpired) | |
601 | callbackEventHandler.EventMatchExpired(&ind); | |
602 | ||
603 | return NL_OK; | |
604 | } | |
605 | ||
606 | int processPublishTerminatedEvent(WifiEvent &event) { | |
607 | NanPublishTerminatedInd ind; | |
608 | memset(&ind,0,sizeof(ind)); | |
609 | ||
610 | for(nl_iterator nl_itr((struct nlattr *)event.get_vendor_data()); nl_itr.has_next(); nl_itr.next()) { | |
611 | switch(nl_itr.get_type()) { | |
612 | case NAN_EVT_ATTR_PUBLISH_ID: | |
613 | ind.publish_id = nl_itr.get_u16(); | |
614 | break; | |
615 | case NAN_EVT_ATTR_PUBLISH_REASON: | |
616 | ind.reason = (NanStatusType)nl_itr.get_u32(); | |
617 | break; | |
618 | default : | |
619 | ALOGE("processPublishTerminatedEvent: unknown attribute(%d)", nl_itr.get_type()); | |
620 | return NL_SKIP; | |
621 | } | |
622 | } | |
623 | ||
624 | if (callbackEventHandler.EventPublishTerminated) | |
625 | callbackEventHandler.EventPublishTerminated(&ind); | |
626 | ||
627 | return NL_OK; | |
628 | ||
629 | } | |
630 | ||
631 | int processSubscribeTerminatedEvent(WifiEvent &event) { | |
632 | NanSubscribeTerminatedInd ind; | |
633 | memset(&ind,0,sizeof(ind)); | |
634 | ||
635 | for(nl_iterator nl_itr((struct nlattr *)event.get_vendor_data()); nl_itr.has_next(); nl_itr.next()) { | |
636 | switch(nl_itr.get_type()) { | |
637 | case NAN_EVT_ATTR_SUBSCRIBE_ID: | |
638 | ind.subscribe_id = nl_itr.get_u16(); | |
639 | break; | |
640 | case NAN_EVT_ATTR_SUBSCRIBE_REASON: | |
641 | ind.reason = (NanStatusType)nl_itr.get_u32(); | |
642 | break; | |
643 | default : | |
644 | ALOGE("processSubscribeTerminatedEvent: unknown attribute(%d)", nl_itr.get_type()); | |
645 | return NL_SKIP; | |
646 | } | |
647 | } | |
648 | ||
649 | if (callbackEventHandler.EventSubscribeTerminated) | |
650 | callbackEventHandler.EventSubscribeTerminated(&ind); | |
651 | ||
652 | return NL_OK; | |
653 | } | |
654 | ||
655 | int processFollowupEvent(WifiEvent &event) { | |
656 | NanFollowupInd ind; | |
f8c9e3bb | 657 | nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA); |
d3a587e8 JPS |
658 | memset(&ind,0,sizeof(ind)); |
659 | ||
f8c9e3bb | 660 | for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) { |
d3a587e8 JPS |
661 | switch(nl_itr.get_type()) { |
662 | case NAN_EVT_ATTR_FOLLOWUP_PUBLISH_SUBSCRIBE_ID: | |
663 | ind.publish_subscribe_id = nl_itr.get_u16(); | |
664 | break; | |
665 | case NAN_EVT_ATTR_FOLLOWUP_REQUESTOR_INSTANCE_ID: | |
666 | ind.requestor_instance_id = nl_itr.get_u32(); | |
667 | break; | |
668 | case NAN_EVT_ATTR_FOLLOWUP_ADDR: | |
669 | memcpy(ind.addr, nl_itr.get_data(), NAN_MAC_ADDR_LEN); | |
670 | break; | |
671 | case NAN_EVT_ATTR_FOLLOWUP_DW_OR_FAW: | |
672 | ind.dw_or_faw = nl_itr.get_u8(); | |
673 | break; | |
674 | case NAN_EVT_ATTR_FOLLOWUP_SERVICE_SPECIFIC_INFO_LEN: | |
675 | ind.service_specific_info_len = nl_itr.get_u16(); | |
676 | break; | |
677 | case NAN_EVT_ATTR_FOLLOWUP_SERVICE_SPECIFIC_INFO: | |
678 | memcpy(ind.service_specific_info, nl_itr.get_data(), ind.service_specific_info_len); | |
679 | break; | |
f8c9e3bb JPS |
680 | case NAN_EVT_ATTR_SDEA_LEN: |
681 | ind.sdea_service_specific_info_len = nl_itr.get_u16(); | |
682 | break; | |
683 | case NAN_EVT_ATTR_SDEA: | |
684 | memcpy(ind.sdea_service_specific_info, nl_itr.get_data(), ind.sdea_service_specific_info_len); | |
685 | break; | |
d3a587e8 JPS |
686 | default : |
687 | ALOGE("processNanDisabledEvent: unknown attribute(%d)", nl_itr.get_type()); | |
688 | return NL_SKIP; | |
689 | } | |
690 | } | |
691 | ||
692 | if (callbackEventHandler.EventFollowup) | |
693 | callbackEventHandler.EventFollowup(&ind); | |
694 | ||
695 | return NL_OK; | |
696 | } | |
697 | ||
698 | int processNanDisabledEvent(WifiEvent &event) { | |
699 | NanDisabledInd ind; | |
700 | memset(&ind,0,sizeof(ind)); | |
f8c9e3bb JPS |
701 | nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA); |
702 | for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) { | |
d3a587e8 JPS |
703 | switch(nl_itr.get_type()) { |
704 | case NAN_EVT_ATTR_DISABLED_REASON: | |
705 | ind.reason = (NanStatusType)nl_itr.get_u32(); | |
706 | break; | |
707 | default : | |
708 | ALOGE("processNanDisabledEvent: unknown attribute(%d)", nl_itr.get_type()); | |
709 | return NL_SKIP; | |
710 | } | |
711 | } | |
712 | ||
713 | if (callbackEventHandler.EventDisabled) | |
714 | callbackEventHandler.EventDisabled(&ind); | |
715 | ||
716 | return NL_OK; | |
717 | } | |
718 | ||
719 | int processNanDiscoveryEvent(WifiEvent &event) { | |
720 | NanDiscEngEventInd ind; | |
721 | memset(&ind,0,sizeof(ind)); | |
cdcc8b21 | 722 | u8 *addr = NULL; |
f8c9e3bb JPS |
723 | nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA); |
724 | for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) { | |
d3a587e8 JPS |
725 | switch(nl_itr.get_type()) { |
726 | case NAN_EVT_ATTR_DISCOVERY_ENGINE_EVT_TYPE: | |
727 | ind.event_type = (NanDiscEngEventType)nl_itr.get_u16(); | |
728 | break; | |
729 | case NAN_EVT_ATTR_DISCOVERY_ENGINE_MAC_ADDR: | |
730 | addr = (u8 *)nl_itr.get_data(); | |
731 | break; | |
732 | default : | |
733 | ALOGE("processNanDiscoveryEvent: unknown attribute(%d)", nl_itr.get_type()); | |
734 | return NL_SKIP; | |
735 | } | |
736 | } | |
cdcc8b21 JPS |
737 | if (addr) { |
738 | if (ind.event_type == NAN_EVENT_ID_DISC_MAC_ADDR) | |
739 | memcpy(ind.data.mac_addr.addr, addr, NAN_MAC_ADDR_LEN); | |
740 | else | |
741 | memcpy(ind.data.cluster.addr, addr, NAN_MAC_ADDR_LEN); | |
742 | } else { | |
743 | ALOGE("processNanDiscoveryEvent: No Mac/cluster Address"); | |
744 | } | |
d3a587e8 JPS |
745 | |
746 | if (callbackEventHandler.EventDiscEngEvent) | |
747 | callbackEventHandler.EventDiscEngEvent(&ind); | |
748 | ||
749 | return NL_OK; | |
750 | } | |
751 | ||
650a9e6a JPS |
752 | int processNanFollowupStatus(WifiEvent &event) { |
753 | NanTransmitFollowupInd ind; | |
754 | memset(&ind,0,sizeof(ind)); | |
755 | ind.id = followupTid; | |
756 | followupTid = 0; | |
757 | nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA); | |
758 | for(nl_iterator nl_itr(vendor_data); nl_itr.has_next(); nl_itr.next()) { | |
759 | if (nl_itr.get_type() == NAN_EVT_ATTR_STATUS) { | |
760 | ind.reason = (NanStatusType)nl_itr.get_u16(); | |
761 | } else { | |
762 | ALOGE("processNanFollowupStatus: unknown attribute(%d)", nl_itr.get_type()); | |
763 | return NL_SKIP; | |
764 | } | |
765 | } | |
766 | ||
767 | if (callbackEventHandler.EventTransmitFollowup) | |
768 | callbackEventHandler.EventTransmitFollowup(&ind); | |
769 | ||
770 | return NL_OK; | |
771 | } | |
772 | ||
e8aa68c3 JPS |
773 | int putSdeaParams(NanSdeaCtrlParams *sdea_params, WifiRequest *request) |
774 | { | |
775 | int result; | |
776 | ||
777 | if (!sdea_params->config_nan_data_path) | |
778 | return 0; | |
779 | ||
780 | result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_NDP_TYPE, sdea_params->ndp_type); | |
781 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM ndp_type"); | |
782 | ||
783 | result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_SECURITY_CFG, sdea_params->security_cfg); | |
784 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM security_cfg"); | |
785 | ||
786 | result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_RANGING_STATE, sdea_params->ranging_state); | |
787 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM ranging_state"); | |
788 | ||
789 | result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_RANGE_REPORT, sdea_params->range_report); | |
790 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM range_report"); | |
791 | ||
792 | result = request->put_u8(NAN_REQ_ATTR_SDEA_PARAM_QOS_CFG, sdea_params->qos_cfg); | |
793 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put SDEA PARAM qos_cfg"); | |
794 | ||
795 | return result; | |
796 | } | |
797 | ||
798 | int putRangingCfg(NanRangingCfg *ranging_cfg, WifiRequest *request) | |
799 | { | |
800 | int result; | |
801 | ||
802 | result = request->put_u32(NAN_REQ_ATTR_RANGING_CFG_INTERVAL, ranging_cfg->ranging_interval_msec); | |
803 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put Ranging CFG ranging_interval_msec"); | |
804 | ||
805 | result = request->put_u32(NAN_REQ_ATTR_RANGING_CFG_INDICATION, ranging_cfg->config_ranging_indications); | |
806 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put Ranging CFG config_ranging_indications"); | |
807 | ||
808 | result = request->put_u32(NAN_REQ_ATTR_RANGING_CFG_INGRESS_MM, ranging_cfg->distance_ingress_mm); | |
809 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put Ranging CFG distance_ingress_mm"); | |
810 | ||
811 | result = request->put_u32(NAN_REQ_ATTR_RANGING_CFG_EGRESS_MM, ranging_cfg->distance_egress_mm); | |
812 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put Ranging CFG distance_egress_mm"); | |
813 | ||
814 | return result; | |
815 | } | |
816 | ||
817 | int putRangeResponseCfg(NanRangeResponseCfg *range_resp_cfg, WifiRequest *request) | |
818 | { | |
819 | int result; | |
820 | ||
821 | result = request->put_u16(NAN_REQ_ATTR_RANGE_RESPONSE_CFG_PUBLISH_ID, range_resp_cfg->publish_id); | |
822 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put range response cfg::publish_id"); | |
823 | ||
824 | result = request->put_u32(NAN_REQ_ATTR_RANGE_RESPONSE_CFG_REQUESTOR_ID, range_resp_cfg->requestor_instance_id); | |
825 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put range response cfg::requestor_instance_id"); | |
826 | ||
827 | result = request->put_addr(NAN_REQ_ATTR_RANGE_RESPONSE_CFG_PEER_ADDR, range_resp_cfg->peer_addr); | |
828 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put range response cfg::peer_addr"); | |
829 | ||
830 | result = request->put_u16(NAN_REQ_ATTR_RANGE_RESPONSE_CFG_RANGING_RESPONSE, range_resp_cfg->ranging_response); | |
831 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "Failed to put range response cfg::ranging_response"); | |
832 | ||
833 | return result; | |
834 | } | |
835 | ||
836 | int putSecurityInfo(u32 cipher, NanSecurityKeyInfo *key_info, u32 scid_len, u8 *scid, WifiRequest *request) | |
837 | { | |
838 | int result; | |
839 | ||
840 | result = request->put_u32(NAN_REQ_ATTR_CIPHER_TYPE, cipher); | |
841 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put cipher_type"); | |
842 | ||
843 | result = request->put_u32(NAN_REQ_ATTR_SECURITY_KEY_TYPE, key_info->key_type); | |
844 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put cipher_type"); | |
845 | ||
846 | if (key_info->key_type == NAN_SECURITY_KEY_INPUT_PMK) { | |
847 | result = request->put_u32(NAN_REQ_ATTR_SECURITY_PMK_LEN, key_info->body.pmk_info.pmk_len); | |
848 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put key_info->body.pmk_info.pmk_len"); | |
849 | result = request->put(NAN_REQ_ATTR_SECURITY_PMK, key_info->body.pmk_info.pmk, key_info->body.pmk_info.pmk_len); | |
850 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put key_info->body.pmk_info.pmk"); | |
851 | } else { | |
852 | result = request->put_u32(NAN_REQ_ATTR_SECURITY_PASSPHRASE_LEN, key_info->body.passphrase_info.passphrase_len); | |
853 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put key_info->body.passphrase_info.passphrase_len"); | |
854 | result = request->put(NAN_REQ_ATTR_SECURITY_PASSPHRASE, key_info->body.passphrase_info.passphrase, | |
855 | key_info->body.passphrase_info.passphrase_len); | |
856 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put key_info->body.passphrase_info.passphrase"); | |
857 | } | |
858 | ||
859 | result = request->put_u32(NAN_REQ_ATTR_SCID_LEN, scid_len); | |
860 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put scid_len"); | |
861 | if (scid_len) { | |
862 | result = request->put(NAN_REQ_ATTR_SCID, scid, scid_len); | |
863 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put scid"); | |
864 | } | |
865 | return result; | |
866 | } | |
867 | ||
d3a587e8 JPS |
868 | public: |
869 | NanCommand(wifi_interface_handle iface, int id) | |
870 | : WifiCommand(iface, id) | |
871 | { | |
872 | subscribeID[0] = 0; | |
873 | subscribeID[1] = 0; | |
874 | publishID[0] = 0; | |
875 | publishID[1] = 0; | |
876 | followupID[0] = 0; | |
650a9e6a JPS |
877 | followupID[1] = 0; |
878 | ||
879 | followupTid = 0; | |
880 | publishTid = 0; | |
881 | publishCancelTid = 0; | |
882 | subscribeTid = 0; | |
883 | subscribeCancelTid = 0; | |
884 | enableTid = 0; | |
885 | disableTid = 0; | |
886 | configTid = 0; | |
887 | capabilitiesTid = 0; | |
888 | ||
d3a587e8 JPS |
889 | version = 0; |
890 | memset(&capabilities, 0, sizeof(capabilities)); | |
891 | } | |
892 | ||
650a9e6a JPS |
893 | int enable(transaction_id id, NanEnableRequest *msg) { |
894 | ALOGD("NAN enable id:%d", id); | |
d3a587e8 JPS |
895 | WifiRequest request(familyId(), ifaceId()); |
896 | ||
897 | int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_ENABLE); | |
898 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to create WifiRequest"); | |
899 | ||
900 | nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); | |
901 | if (!data) { | |
902 | ALOGE("enable: request.attr_start fail"); | |
903 | return WIFI_ERROR_OUT_OF_MEMORY; | |
904 | } | |
49e66671 JPS |
905 | /* Valid master pref values are 2-254 */ |
906 | int master_pref; | |
907 | if (msg->master_pref < 2) | |
908 | master_pref = 2; | |
909 | else if (msg->master_pref > 254) | |
910 | master_pref = 254; | |
911 | else | |
912 | master_pref = msg->master_pref; | |
913 | result = request.put_u8(NAN_REQ_ATTR_MASTER_PREF, master_pref); | |
d3a587e8 JPS |
914 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put master_pref"); |
915 | ||
916 | result = request.put_u16(NAN_REQ_ATTR_CLUSTER_LOW, msg->cluster_low); | |
917 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put cluster_low"); | |
918 | ||
919 | result = request.put_u16(NAN_REQ_ATTR_CLUSTER_HIGH, msg->cluster_high); | |
920 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put cluster_high"); | |
921 | ||
922 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_support_5g, msg->support_5g_val, | |
923 | NAN_REQ_ATTR_SUPPORT_5G_VAL, request, result, "enable:Failed to put support_5g_val"); | |
924 | ||
925 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_sid_beacon, msg->sid_beacon_val, | |
926 | NAN_REQ_ATTR_SID_BEACON_VAL, request, result, "enable:Failed to put sid_beacon_val"); | |
927 | ||
928 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_2dot4g_rssi_close, msg->rssi_close_2dot4g_val, | |
929 | NAN_REQ_ATTR_RSSI_CLOSE_2G4_VAL, request, result, "enable:Failed to put rssi_close_2dot4g_val"); | |
930 | ||
931 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_2dot4g_rssi_middle, msg->rssi_middle_2dot4g_val, | |
932 | NAN_REQ_ATTR_RSSI_MIDDLE_2G4_VAL, request, result, "enable:Failed to put rssi_middle_2dot4g_val"); | |
933 | ||
934 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_2dot4g_rssi_proximity, msg->rssi_proximity_2dot4g_val, | |
935 | NAN_REQ_ATTR_RSSI_PROXIMITY_2G4_VAL, request, result, "enable:Failed to put rssi_proximity_2dot4g_val"); | |
936 | ||
937 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_hop_count_limit, msg->hop_count_limit_val, | |
938 | NAN_REQ_ATTR_HOP_COUNT_LIMIT_VAL, request, result, "enable:Failed to put hop_count_limit_val"); | |
939 | ||
940 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_2dot4g_support, msg->support_2dot4g_val, | |
941 | NAN_REQ_ATTR_SUPPORT_2G4_VAL, request, result, "enable:Failed to put support_2dot4g_val"); | |
942 | ||
943 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_2dot4g_beacons, msg->beacon_2dot4g_val, | |
944 | NAN_REQ_ATTR_BEACONS_2G4_VAL, request, result, "enable:Failed to put beacon_2dot4g_val"); | |
945 | ||
946 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_2dot4g_sdf, msg->sdf_2dot4g_val, | |
947 | NAN_REQ_ATTR_SDF_2G4_VAL, request, result, "enable:Failed to put sdf_2dot4g_val"); | |
948 | ||
949 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_5g_beacons, msg->beacon_5g_val, | |
950 | NAN_REQ_ATTR_BEACON_5G_VAL, request, result, "enable:Failed to put beacon_5g_val"); | |
951 | ||
952 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_5g_sdf, msg->sdf_5g_val, | |
953 | NAN_REQ_ATTR_SDF_5G_VAL, request, result, "enable:Failed to put sdf_5g_val"); | |
954 | ||
955 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_5g_rssi_close, msg->rssi_close_5g_val, | |
956 | NAN_REQ_ATTR_RSSI_CLOSE_5G_VAL, request, result, "enable:Failed to put rssi_close_5g_val"); | |
957 | ||
958 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_5g_rssi_middle, msg->rssi_middle_5g_val, | |
959 | NAN_REQ_ATTR_RSSI_MIDDLE_5G_VAL, request, result, "enable:Failed to put rssi_middle_5g_val"); | |
960 | ||
961 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_5g_rssi_close_proximity, msg->rssi_close_proximity_5g_val, | |
962 | NAN_REQ_ATTR_RSSI_CLOSE_PROXIMITY_5G_VAL, request, result, "enable:Failed to put rssi_close_proximity_5g_val"); | |
963 | ||
964 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_rssi_window_size, msg->rssi_window_size_val, | |
965 | NAN_REQ_ATTR_RSSI_WINDOW_SIZE_VAL, request, result, "enable:Failed to put rssi_window_size_val"); | |
966 | ||
967 | CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_oui, msg->oui_val, | |
968 | NAN_REQ_ATTR_OUI_VAL, request, result, "enable:Failed to put oui_val"); | |
969 | ||
970 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->config_intf_addr, msg->intf_addr_val, NAN_MAC_ADDR_LEN, | |
971 | NAN_REQ_ATTR_MAC_ADDR_VAL, request, result, "enable:Failed to put intf_addr_val"); | |
972 | ||
973 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->config_cluster_attribute_val, | |
974 | NAN_REQ_ATTR_CLUSTER_VAL, request, result, "enable:Failed to put config_cluster_attribute_val"); | |
975 | ||
976 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->config_scan_params, msg->scan_params_val.dwell_time, sizeof(msg->scan_params_val.dwell_time), | |
977 | NAN_REQ_ATTR_SOCIAL_CH_SCAN_DWELL_TIME, request, result, "enable:Failed to put scan_params_val.dwell_time"); | |
978 | ||
979 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->config_scan_params, msg->scan_params_val.scan_period, sizeof(msg->scan_params_val.scan_period), | |
980 | NAN_REQ_ATTR_SOCIAL_CH_SCAN_PERIOD, request, result, "enable:Failed to put scan_params_val.scan_period"); | |
981 | ||
982 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_random_factor_force, msg->random_factor_force_val, | |
983 | NAN_REQ_ATTR_RANDOM_FACTOR_FORCE_VAL, request, result, "enable:Failed to put random_factor_force_val"); | |
984 | ||
985 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_hop_count_force, msg->hop_count_force_val, | |
986 | NAN_REQ_ATTR_HOP_COUNT_FORCE_VAL, request, result, "enable:Failed to put hop_count_force_val"); | |
987 | ||
988 | CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_24g_channel, msg->channel_24g_val, | |
989 | NAN_REQ_ATTR_CHANNEL_2G4_MHZ_VAL, request, result, "enable:Failed to put channel_24g_val"); | |
990 | ||
991 | CHECK_CONFIG_PUT_32_RETURN_FAIL(msg->config_5g_channel, msg->channel_5g_val, | |
992 | NAN_REQ_ATTR_CHANNEL_5G_MHZ_VAL, request, result, "enable:Failed to put channel_5g_val"); | |
993 | ||
f8c9e3bb JPS |
994 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_subscribe_sid_beacon, msg->subscribe_sid_beacon_val, |
995 | NAN_REQ_ATTR_SUBSCRIBE_SID_BEACON_VAL, request, result, "enable:Failed to put subscribe_sid_beacon_val"); | |
996 | ||
997 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_dw.config_2dot4g_dw_band, msg->config_dw.dw_2dot4g_interval_val, | |
998 | NAN_REQ_ATTR_DW_2G4_INTERVAL, request, result, "enable:Failed to put dw_2dot4g_interval_val"); | |
999 | ||
1000 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_dw.config_5g_dw_band, msg->config_dw.dw_5g_interval_val, | |
1001 | NAN_REQ_ATTR_DW_5G_INTERVAL, request, result, "enable:Failed to put dw_5g_interval_val"); | |
1002 | ||
1003 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_disc_mac_addr_randomization, msg->disc_mac_addr_rand_interval_sec, | |
1004 | NAN_REQ_ATTR_DISC_MAC_ADDR_RANDOM_INTERVAL, request, result, "enable:Failed to put disc_mac_addr_rand_interval_sec"); | |
1005 | ||
d3a587e8 JPS |
1006 | request.attr_end(data); |
1007 | ||
1008 | registerNanEvents(); | |
650a9e6a | 1009 | enableTid = id; |
d3a587e8 JPS |
1010 | result = requestResponse(request); |
1011 | if (result != WIFI_SUCCESS) { | |
650a9e6a | 1012 | enableTid = 0; |
d3a587e8 JPS |
1013 | ALOGE("failed to NAN; result = %d", result); |
1014 | unregisterNanEvents(); | |
1015 | } else { | |
1016 | ALOGD("Start NAN...success"); | |
1017 | } | |
1018 | return result; | |
1019 | } | |
1020 | ||
650a9e6a | 1021 | int disable(transaction_id id) |
d3a587e8 | 1022 | { |
650a9e6a | 1023 | ALOGD("NAN disable id:%d", id); |
d3a587e8 JPS |
1024 | WifiRequest request(familyId(), ifaceId()); |
1025 | ||
1026 | unregisterNanEvents(); | |
1027 | ||
1028 | int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_DISABLE); | |
1029 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "disable:Failed to create WifiRequest"); | |
650a9e6a | 1030 | disableTid = id; |
d3a587e8 JPS |
1031 | result = requestResponse(request); |
1032 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "disable:Failed to requestResponse"); | |
1033 | return result; | |
1034 | } | |
1035 | ||
650a9e6a JPS |
1036 | int config(transaction_id id, NanConfigRequest *msg) { |
1037 | ALOGD("NAN config id:%d", id); | |
d3a587e8 JPS |
1038 | WifiRequest request(familyId(), ifaceId()); |
1039 | ||
1040 | int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_CONFIG); | |
1041 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "config:Failed to create WifiRequest"); | |
1042 | ||
1043 | nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); | |
1044 | if (!data) { | |
1045 | ALOGE("config: request.attr_start fail"); | |
1046 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1047 | } | |
1048 | ||
1049 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_sid_beacon, msg->sid_beacon, | |
1050 | NAN_REQ_ATTR_SID_BEACON_VAL, request, result, "config:Failed to put sid_beacon"); | |
1051 | ||
1052 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_rssi_proximity, msg->rssi_proximity, | |
1053 | NAN_REQ_ATTR_RSSI_PROXIMITY_2G4_VAL, request, result, "config:Failed to put rssi_proximity"); | |
1054 | ||
1055 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_master_pref, msg->master_pref, | |
1056 | NAN_REQ_ATTR_MASTER_PREF, request, result, "config:Failed to put master_pref"); | |
1057 | ||
1058 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_5g_rssi_close_proximity, msg->rssi_close_proximity_5g_val, | |
1059 | NAN_REQ_ATTR_RSSI_CLOSE_PROXIMITY_5G_VAL, request, result, "config:Failed to put rssi_close_proximity_5g_val"); | |
1060 | ||
1061 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_rssi_window_size, msg->rssi_window_size_val, | |
1062 | NAN_REQ_ATTR_RSSI_WINDOW_SIZE_VAL, request, result, "config:Failed to put rssi_window_size_val"); | |
1063 | ||
1064 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->config_cluster_attribute_val, | |
1065 | NAN_REQ_ATTR_CLUSTER_VAL, request, result, "config:Failed to put config_cluster_attribute_val"); | |
1066 | ||
1067 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->config_scan_params, msg->scan_params_val.dwell_time, sizeof(msg->scan_params_val.dwell_time), | |
1068 | NAN_REQ_ATTR_SOCIAL_CH_SCAN_DWELL_TIME, request, result, "config:Failed to put scan_params_val.dwell_time"); | |
1069 | ||
1070 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->config_scan_params, msg->scan_params_val.scan_period, sizeof(msg->scan_params_val.scan_period), | |
1071 | NAN_REQ_ATTR_SOCIAL_CH_SCAN_PERIOD, request, result, "config:Failed to put scan_params_val.scan_period"); | |
1072 | ||
1073 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_random_factor_force, msg->random_factor_force_val, | |
1074 | NAN_REQ_ATTR_RANDOM_FACTOR_FORCE_VAL, request, result, "config:Failed to put random_factor_force_val"); | |
1075 | ||
1076 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_hop_count_force, msg->hop_count_force_val, | |
1077 | NAN_REQ_ATTR_HOP_COUNT_FORCE_VAL, request, result, "config:Failed to put hop_count_force_val"); | |
1078 | ||
1079 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_conn_capability, msg->conn_capability_val.payload_transmit_flag, | |
1080 | NAN_REQ_ATTR_CONN_CAPABILITY_PAYLOAD_TX, request, result, "config:Failed to put payload_transmit_flag"); | |
1081 | ||
1082 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_conn_capability, msg->conn_capability_val.is_wfd_supported, | |
1083 | NAN_REQ_ATTR_CONN_CAPABILITY_WFD, request, result, "config:Failed to put is_wfd_supported"); | |
1084 | ||
1085 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_conn_capability, msg->conn_capability_val.is_wfds_supported, | |
1086 | NAN_REQ_ATTR_CONN_CAPABILITY_WFDS, request, result, "config:Failed to put is_wfds_supported"); | |
1087 | ||
1088 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_conn_capability, msg->conn_capability_val.is_tdls_supported, | |
1089 | NAN_REQ_ATTR_CONN_CAPABILITY_TDLS, request, result, "config:Failed to put is_tdls_supported"); | |
1090 | ||
1091 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_conn_capability, msg->conn_capability_val.is_ibss_supported, | |
1092 | NAN_REQ_ATTR_CONN_CAPABILITY_IBSS, request, result, "config:Failed to put is_ibss_supported"); | |
1093 | ||
1094 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_conn_capability, msg->conn_capability_val.is_mesh_supported, | |
1095 | NAN_REQ_ATTR_CONN_CAPABILITY_MESH, request, result, "config:Failed to put is_mesh_supported"); | |
1096 | ||
1097 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_conn_capability, msg->conn_capability_val.wlan_infra_field, | |
1098 | NAN_REQ_ATTR_CONN_CAPABILITY_WLAN_INFRA, request, result, "config:Failed to put wlan_infra_field"); | |
1099 | ||
1100 | if (msg->num_config_discovery_attr) { | |
1101 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->num_config_discovery_attr, | |
1102 | NAN_REQ_ATTR_DISCOVERY_ATTR_NUM_ENTRIES, request, result, "config:Failed to put msg->num_config_discovery_attr"); | |
1103 | for (int i = 0; i < msg->num_config_discovery_attr; i++) { | |
1104 | nlattr *nl_disc_attribute = request.attr_start(NAN_REQ_ATTR_DISCOVERY_ATTR_VAL); | |
1105 | NanTransmitPostDiscovery *discovery_attr = &msg->discovery_attr_val[i]; | |
1106 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, discovery_attr->type, | |
1107 | NAN_REQ_ATTR_CONN_TYPE, request, result, "config:Failed to put discovery_attr->type"); | |
1108 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, discovery_attr->role, | |
1109 | NAN_REQ_ATTR_NAN_ROLE, request, result, "config:Failed to put discovery_attr->role"); | |
1110 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, discovery_attr->transmit_freq, | |
1111 | NAN_REQ_ATTR_TRANSMIT_FREQ, request, result, "config:Failed to put discovery_attr->transmit_freq"); | |
1112 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, discovery_attr->duration, | |
1113 | NAN_REQ_ATTR_AVAILABILITY_DURATION, request, result, "config:Failed to put discovery_attr->duration"); | |
1114 | CHECK_CONFIG_PUT_32_RETURN_FAIL(1, discovery_attr->avail_interval_bitmap, | |
1115 | NAN_REQ_ATTR_AVAILABILITY_INTERVAL, request, result, "config:Failed to put discovery_attr->avail_interval_bitmap"); | |
1116 | CHECK_CONFIG_PUT_RETURN_FAIL(1, discovery_attr->addr, NAN_MAC_ADDR_LEN, | |
1117 | NAN_REQ_ATTR_MAC_ADDR_VAL, request, result, "config:Failed to put discovery_attr->addr"); | |
1118 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, discovery_attr->mesh_id_len, | |
1119 | NAN_REQ_ATTR_MESH_ID_LEN, request, result, "config:Failed to put discovery_attr->mesh_id"); | |
1120 | CHECK_CONFIG_PUT_RETURN_FAIL(discovery_attr->mesh_id_len, discovery_attr->mesh_id, discovery_attr->mesh_id_len, | |
1121 | NAN_REQ_ATTR_MESH_ID, request, result, "config:Failed to put discovery_attr->mesh_id"); | |
1122 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, discovery_attr->infrastructure_ssid_len, | |
1123 | NAN_REQ_ATTR_INFRASTRUCTURE_SSID_LEN, request, result, "config:Failed to put discovery_attr->infrastructure_ssid_val"); | |
1124 | CHECK_CONFIG_PUT_RETURN_FAIL(discovery_attr->infrastructure_ssid_len, discovery_attr->infrastructure_ssid_val, discovery_attr->infrastructure_ssid_len, | |
1125 | NAN_REQ_ATTR_INFRASTRUCTURE_SSID, request, result, "config:Failed to put discovery_attr->infrastructure_ssid_val"); | |
1126 | request.attr_end(nl_disc_attribute); | |
1127 | } | |
1128 | } | |
1129 | ||
1130 | if (msg->config_fam) { | |
1131 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->fam_val.numchans, | |
1132 | NAN_REQ_ATTR_FURTHER_AVAIL_NUM_ENTRIES, request, result, "config:Failed to put msg->fam_val.numchans"); | |
1133 | for (int i = 0; i < msg->fam_val.numchans; i++) { | |
1134 | nlattr *nl_fam_attribute = request.attr_start(NAN_REQ_ATTR_FURTHER_AVAIL_VAL); | |
1135 | NanFurtherAvailabilityChannel *further_avail_chan = &msg->fam_val.famchan[i]; | |
1136 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, further_avail_chan->entry_control, | |
1137 | NAN_REQ_ATTR_FURTHER_AVAIL_ENTRY_CTRL, request, result, "config:Failed to put further_avail_chan->entry_control"); | |
1138 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, further_avail_chan->class_val, | |
1139 | NAN_REQ_ATTR_FURTHER_AVAIL_CHAN_CLASS, request, result, "config:Failed to put further_avail_chan->class_val"); | |
1140 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, further_avail_chan->channel, | |
1141 | NAN_REQ_ATTR_FURTHER_AVAIL_CHAN, request, result, "config:Failed to put further_avail_chan->channel"); | |
1142 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, further_avail_chan->mapid, | |
1143 | NAN_REQ_ATTR_FURTHER_AVAIL_CHAN_MAPID, request, result, "config:Failed to put further_avail_chan->mapid"); | |
1144 | CHECK_CONFIG_PUT_32_RETURN_FAIL(1, further_avail_chan->avail_interval_bitmap, | |
1145 | NAN_REQ_ATTR_FURTHER_AVAIL_INTERVAL_BITMAP, request, result, "config:Failed to put further_avail_chan->avail_interval_bitmap"); | |
1146 | request.attr_end(nl_fam_attribute); | |
1147 | } | |
1148 | } | |
1149 | ||
f8c9e3bb JPS |
1150 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_subscribe_sid_beacon, msg->subscribe_sid_beacon_val, |
1151 | NAN_REQ_ATTR_SUBSCRIBE_SID_BEACON_VAL, request, result, "config:Failed to put subscribe_sid_beacon_val"); | |
1152 | ||
1153 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_dw.config_2dot4g_dw_band, msg->config_dw.dw_2dot4g_interval_val, | |
1154 | NAN_REQ_ATTR_DW_2G4_INTERVAL, request, result, "config:Failed to put dw_2dot4g_interval_val"); | |
1155 | ||
1156 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_dw.config_5g_dw_band, msg->config_dw.dw_5g_interval_val, | |
1157 | NAN_REQ_ATTR_DW_5G_INTERVAL, request, result, "config:Failed to put dw_5g_interval_val"); | |
1158 | ||
1159 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->config_disc_mac_addr_randomization, msg->disc_mac_addr_rand_interval_sec, | |
1160 | NAN_REQ_ATTR_DISC_MAC_ADDR_RANDOM_INTERVAL, request, result, "config:Failed to put disc_mac_addr_rand_interval_sec"); | |
1161 | ||
d3a587e8 | 1162 | request.attr_end(data); |
650a9e6a | 1163 | configTid = id; |
d3a587e8 JPS |
1164 | result = requestResponse(request); |
1165 | if (result != WIFI_SUCCESS) { | |
650a9e6a | 1166 | configTid = 0; |
d3a587e8 JPS |
1167 | ALOGE("failed to set_config; result = %d", result); |
1168 | } else { | |
49e66671 | 1169 | ALOGD("NAN config...success"); |
d3a587e8 JPS |
1170 | } |
1171 | return result; | |
1172 | } | |
1173 | ||
1174 | static int setCallbackHandler(NanCallbackHandler handlers) { | |
1175 | callbackEventHandler = handlers; | |
1176 | return WIFI_SUCCESS; | |
1177 | } | |
1178 | ||
1179 | static int getVersion(NanVersion *version) { | |
1180 | *version = SLSI_WIFI_HAL_NAN_VERSION; | |
1181 | return WIFI_SUCCESS; | |
1182 | } | |
1183 | ||
650a9e6a JPS |
1184 | int publish(transaction_id id, NanPublishRequest *msg) { |
1185 | ALOGD("NAN publish transId:%d publishId:%d publishType:%d", id, msg->publish_id, msg->publish_type); | |
d3a587e8 JPS |
1186 | WifiRequest request(familyId(), ifaceId()); |
1187 | ||
1188 | int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_PUBLISH); | |
1189 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "publish:Failed to create WifiRequest"); | |
1190 | ||
1191 | nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); | |
1192 | if (!data) { | |
1193 | ALOGE("publish: request.attr_start fail"); | |
1194 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1195 | } | |
1196 | ||
1197 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->publish_id, msg->publish_id, | |
1198 | NAN_REQ_ATTR_PUBLISH_ID, request, result, "publish:Failed to put msg->publish_id"); | |
1199 | ||
1200 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->ttl, msg->ttl, | |
1201 | NAN_REQ_ATTR_PUBLISH_TTL, request, result, "publish:Failed to put msg->ttl"); | |
1202 | ||
1203 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->period, | |
1204 | NAN_REQ_ATTR_PUBLISH_PERIOD, request, result, "publish:Failed to put msg->period"); | |
1205 | ||
1206 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->publish_type, | |
1207 | NAN_REQ_ATTR_PUBLISH_TYPE, request, result, "publish:Failed to put msg->publish_type"); | |
1208 | ||
1209 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->tx_type, | |
1210 | NAN_REQ_ATTR_PUBLISH_TX_TYPE, request, result, "publish:Failed to put msg->tx_type"); | |
1211 | ||
1212 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->publish_count, | |
1213 | NAN_REQ_ATTR_PUBLISH_COUNT, request, result, "publish:Failed to put msg->publish_count"); | |
1214 | ||
1215 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->service_name_len, msg->service_name_len, | |
1216 | NAN_REQ_ATTR_PUBLISH_SERVICE_NAME_LEN, request, result, "publish:Failed to put msg->service_name_len"); | |
1217 | ||
1218 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->service_name_len, msg->service_name, msg->service_name_len, | |
1219 | NAN_REQ_ATTR_PUBLISH_SERVICE_NAME, request, result, "publish:Failed to put msg->service_name"); | |
1220 | ||
1221 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->publish_match_indicator, | |
1222 | NAN_REQ_ATTR_PUBLISH_MATCH_ALGO, request, result, "publish:Failed to put msg->publish_match_indicator"); | |
1223 | ||
1224 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->service_specific_info_len, msg->service_specific_info_len, | |
1225 | NAN_REQ_ATTR_PUBLISH_SERVICE_INFO_LEN, request, result, "publish:Failed to put msg->service_specific_info_len"); | |
1226 | ||
1227 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->service_specific_info_len, msg->service_specific_info, msg->service_specific_info_len, | |
1228 | NAN_REQ_ATTR_PUBLISH_SERVICE_INFO, request, result, "publish:Failed to put msg->service_specific_info"); | |
1229 | ||
1230 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->rx_match_filter_len, msg->rx_match_filter_len, | |
1231 | NAN_REQ_ATTR_PUBLISH_RX_MATCH_FILTER_LEN, request, result, "publish:Failed to put msg->rx_match_filter_len"); | |
1232 | ||
1233 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->rx_match_filter_len, msg->rx_match_filter, msg->rx_match_filter_len, | |
1234 | NAN_REQ_ATTR_PUBLISH_RX_MATCH_FILTER, request, result, "publish:Failed to put msg->rx_match_filter"); | |
1235 | ||
1236 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->tx_match_filter_len, msg->tx_match_filter_len, | |
1237 | NAN_REQ_ATTR_PUBLISH_TX_MATCH_FILTER_LEN, request, result, "publish:Failed to put msg->tx_match_filter_len"); | |
1238 | ||
1239 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->tx_match_filter_len, msg->tx_match_filter, msg->tx_match_filter_len, | |
1240 | NAN_REQ_ATTR_PUBLISH_TX_MATCH_FILTER, request, result, "publish:Failed to put msg->tx_match_filter"); | |
1241 | ||
1242 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->rssi_threshold_flag, | |
1243 | NAN_REQ_ATTR_PUBLISH_RSSI_THRESHOLD_FLAG, request, result, "publish:Failed to put msg->rssi_threshold_flag"); | |
1244 | ||
1245 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->connmap, | |
1246 | NAN_REQ_ATTR_PUBLISH_CONN_MAP, request, result, "publish:Failed to put msg->connmap"); | |
1247 | ||
1248 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->recv_indication_cfg, | |
1249 | NAN_REQ_ATTR_PUBLISH_RECV_IND_CFG, request, result, "publish:Failed to put msg->recv_indication_cfg"); | |
1250 | ||
f8c9e3bb JPS |
1251 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->sdea_service_specific_info_len, |
1252 | NAN_REQ_ATTR_PUBLISH_SDEA_LEN, request, result, "publish:Failed to put msg->sdea_service_specific_info_len"); | |
1253 | ||
1254 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->sdea_service_specific_info_len, msg->sdea_service_specific_info, msg->sdea_service_specific_info_len, | |
1255 | NAN_REQ_ATTR_PUBLISH_SDEA, request, result, "publish:Failed to put msg->sdea_service_specific_info"); | |
1256 | ||
e8aa68c3 JPS |
1257 | result = request.put_u8(NAN_REQ_ATTR_RANGING_AUTO_RESPONSE, msg->ranging_auto_response); |
1258 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put ranging_auto_response"); | |
1259 | ||
1260 | result = putSdeaParams(&msg->sdea_params, &request); | |
1261 | if (result != 0) | |
1262 | return result; | |
1263 | result = putRangingCfg(&msg->ranging_cfg, &request); | |
1264 | if (result != 0) | |
1265 | return result; | |
1266 | result = putSecurityInfo(msg->cipher_type, &msg->key_info, msg->scid_len, msg->scid, &request); | |
1267 | if (result != 0) | |
1268 | return result; | |
1269 | result = putRangeResponseCfg(&msg->range_response_cfg, &request); | |
1270 | if (result != 0) | |
1271 | return result; | |
1272 | ||
d3a587e8 | 1273 | request.attr_end(data); |
650a9e6a | 1274 | publishTid = id; |
d3a587e8 JPS |
1275 | result = requestResponse(request); |
1276 | if (result != WIFI_SUCCESS) { | |
650a9e6a | 1277 | publishTid = 0; |
d3a587e8 JPS |
1278 | ALOGE("failed to publish; result = %d", result); |
1279 | } else { | |
49e66671 | 1280 | ALOGD("NAN publish...success"); |
d3a587e8 JPS |
1281 | } |
1282 | return result; | |
1283 | } | |
1284 | ||
650a9e6a JPS |
1285 | int publishCancel(transaction_id id, NanPublishCancelRequest *msg) { |
1286 | ALOGD("NAN publishCancel transId:%d, publish_id:%d", id, msg->publish_id); | |
d3a587e8 JPS |
1287 | WifiRequest request(familyId(), ifaceId()); |
1288 | ||
1289 | int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_PUBLISHCANCEL); | |
1290 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "publishCancel:Failed to create WifiRequest"); | |
1291 | ||
1292 | nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); | |
1293 | if (!data) { | |
1294 | ALOGE("publishCancel: request.attr_start fail"); | |
1295 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1296 | } | |
1297 | ||
1298 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->publish_id, | |
1299 | NAN_REQ_ATTR_PUBLISH_ID, request, result, "publishCancel:Failed to put msg->publish_id"); | |
1300 | ||
1301 | request.attr_end(data); | |
650a9e6a | 1302 | publishCancelTid = id; |
d3a587e8 JPS |
1303 | result = requestResponse(request); |
1304 | if (result != WIFI_SUCCESS) { | |
650a9e6a | 1305 | publishCancelTid = 0; |
d3a587e8 JPS |
1306 | ALOGE("failed to publishCancel; result = %d", result); |
1307 | } else { | |
49e66671 | 1308 | ALOGD("NAN publishCancel...success"); |
d3a587e8 JPS |
1309 | } |
1310 | return result; | |
1311 | ||
1312 | } | |
1313 | ||
650a9e6a JPS |
1314 | int subscribe(transaction_id id, NanSubscribeRequest *msg) { |
1315 | ALOGD("NAN subscribe trans_id:%d subscribe_id:%d subscribetype:%d", id, msg->subscribe_id, msg->subscribe_type); | |
d3a587e8 JPS |
1316 | WifiRequest request(familyId(), ifaceId()); |
1317 | ||
1318 | int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_SUBSCRIBE); | |
1319 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "subscribe:Failed to create WifiRequest"); | |
1320 | ||
1321 | nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); | |
1322 | if (!data) { | |
1323 | ALOGE("subscribe: request.attr_start fail"); | |
1324 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1325 | } | |
1326 | ||
1327 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->subscribe_id, msg->subscribe_id, | |
1328 | NAN_REQ_ATTR_SUBSCRIBE_ID, request, result, "subscribe:Failed to put msg->publish_id"); | |
1329 | ||
1330 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->ttl, | |
1331 | NAN_REQ_ATTR_SUBSCRIBE_TTL, request, result, "subscribe:Failed to put msg->ttl"); | |
1332 | ||
1333 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->period, | |
1334 | NAN_REQ_ATTR_SUBSCRIBE_PERIOD, request, result, "subscribe:Failed to put msg->period"); | |
1335 | ||
1336 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->subscribe_type, | |
1337 | NAN_REQ_ATTR_SUBSCRIBE_TYPE, request, result, "subscribe:Failed to put msg->subscribe_type"); | |
1338 | ||
1339 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->serviceResponseFilter, | |
1340 | NAN_REQ_ATTR_SUBSCRIBE_RESP_FILTER_TYPE, request, result, "subscribe:Failed to put msg->serviceResponseFilter"); | |
1341 | ||
1342 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->serviceResponseInclude, | |
1343 | NAN_REQ_ATTR_SUBSCRIBE_RESP_INCLUDE, request, result, "subscribe:Failed to put msg->serviceResponseInclude"); | |
1344 | ||
1345 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->useServiceResponseFilter, | |
1346 | NAN_REQ_ATTR_SUBSCRIBE_USE_RESP_FILTER, request, result, "subscribe:Failed to put msg->useServiceResponseFilter"); | |
1347 | ||
1348 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->ssiRequiredForMatchIndication, | |
1349 | NAN_REQ_ATTR_SUBSCRIBE_SSI_REQUIRED, request, result, "subscribe:Failed to put msg->ssiRequiredForMatchIndication"); | |
1350 | ||
1351 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->subscribe_match_indicator, | |
1352 | NAN_REQ_ATTR_SUBSCRIBE_MATCH_INDICATOR, request, result, "subscribe:Failed to put msg->subscribe_match_indicator"); | |
1353 | ||
1354 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->subscribe_count, | |
1355 | NAN_REQ_ATTR_SUBSCRIBE_COUNT, request, result, "subscribe:Failed to put msg->subscribe_count"); | |
1356 | ||
1357 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->service_name_len, msg->service_name_len, | |
1358 | NAN_REQ_ATTR_SUBSCRIBE_SERVICE_NAME_LEN, request, result, "subscribe:Failed to put msg->service_name_len"); | |
1359 | ||
1360 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->service_name_len, msg->service_name, msg->service_name_len, | |
1361 | NAN_REQ_ATTR_SUBSCRIBE_SERVICE_NAME, request, result, "subscribe:Failed to put msg->service_name"); | |
1362 | ||
1363 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->service_specific_info_len, msg->service_specific_info_len, | |
1364 | NAN_REQ_ATTR_SUBSCRIBE_SERVICE_INFO_LEN, request, result, "subscribe:Failed to put msg->service_specific_info_len"); | |
1365 | ||
1366 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->service_specific_info_len, msg->service_specific_info, msg->service_specific_info_len, | |
1367 | NAN_REQ_ATTR_SUBSCRIBE_SERVICE_INFO, request, result, "subscribe:Failed to put msg->service_specific_info"); | |
1368 | ||
1369 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->rx_match_filter_len, msg->rx_match_filter_len, | |
1370 | NAN_REQ_ATTR_SUBSCRIBE_RX_MATCH_FILTER_LEN, request, result, "subscribe:Failed to put msg->rx_match_filter_len"); | |
1371 | ||
1372 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->rx_match_filter_len, msg->rx_match_filter, msg->rx_match_filter_len, | |
1373 | NAN_REQ_ATTR_SUBSCRIBE_RX_MATCH_FILTER, request, result, "subscribe:Failed to put msg->rx_match_filter"); | |
1374 | ||
1375 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->tx_match_filter_len, msg->tx_match_filter_len, | |
1376 | NAN_REQ_ATTR_SUBSCRIBE_TX_MATCH_FILTER_LEN, request, result, "subscribe:Failed to put msg->tx_match_filter_len"); | |
1377 | ||
1378 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->tx_match_filter_len, msg->tx_match_filter, msg->tx_match_filter_len, | |
1379 | NAN_REQ_ATTR_SUBSCRIBE_TX_MATCH_FILTER, request, result, "subscribe:Failed to put msg->tx_match_filter"); | |
1380 | ||
1381 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->rssi_threshold_flag, | |
1382 | NAN_REQ_ATTR_SUBSCRIBE_RSSI_THRESHOLD_FLAG, request, result, "subscribe:Failed to put msg->rssi_threshold_flag"); | |
1383 | ||
1384 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->connmap, | |
1385 | NAN_REQ_ATTR_SUBSCRIBE_CONN_MAP, request, result, "subscribe:Failed to put msg->connmap"); | |
1386 | ||
1387 | CHECK_CONFIG_PUT_8_RETURN_FAIL(msg->num_intf_addr_present, msg->num_intf_addr_present, | |
1388 | NAN_REQ_ATTR_SUBSCRIBE_NUM_INTF_ADDR_PRESENT, request, result, "subscribe:Failed to put msg->num_intf_addr_present"); | |
1389 | ||
1390 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->num_intf_addr_present, msg->intf_addr, NAN_MAC_ADDR_LEN * msg->num_intf_addr_present, | |
1391 | NAN_REQ_ATTR_SUBSCRIBE_INTF_ADDR, request, result, "subscribe:Failed to put msg->intf_addr"); | |
1392 | ||
1393 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->recv_indication_cfg, | |
1394 | NAN_REQ_ATTR_SUBSCRIBE_RECV_IND_CFG, request, result, "subscribe:Failed to put msg->recv_indication_cfg"); | |
1395 | ||
f8c9e3bb JPS |
1396 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->sdea_service_specific_info_len, |
1397 | NAN_REQ_ATTR_PUBLISH_SDEA_LEN, request, result, "subscribe:Failed to put msg->sdea_service_specific_info_len"); | |
1398 | ||
1399 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->sdea_service_specific_info_len, msg->sdea_service_specific_info, msg->sdea_service_specific_info_len, | |
1400 | NAN_REQ_ATTR_PUBLISH_SDEA, request, result, "subscribe:Failed to put msg->sdea_service_specific_info"); | |
1401 | ||
e8aa68c3 JPS |
1402 | result = request.put_u8(NAN_REQ_ATTR_RANGING_AUTO_RESPONSE, msg->ranging_auto_response); |
1403 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "enable:Failed to put ranging_auto_response"); | |
1404 | ||
1405 | result = putSdeaParams(&msg->sdea_params, &request); | |
1406 | if (result != 0) | |
1407 | return result; | |
1408 | result = putRangingCfg(&msg->ranging_cfg, &request); | |
1409 | if (result != 0) | |
1410 | return result; | |
1411 | result = putSecurityInfo(msg->cipher_type, &msg->key_info, msg->scid_len, msg->scid, &request); | |
1412 | if (result != 0) | |
1413 | return result; | |
1414 | result = putRangeResponseCfg(&msg->range_response_cfg, &request); | |
1415 | if (result != 0) | |
1416 | return result; | |
f8c9e3bb | 1417 | |
d3a587e8 | 1418 | request.attr_end(data); |
650a9e6a | 1419 | subscribeTid = id; |
d3a587e8 JPS |
1420 | result = requestResponse(request); |
1421 | if (result != WIFI_SUCCESS) { | |
650a9e6a | 1422 | subscribeTid = 0; |
d3a587e8 JPS |
1423 | ALOGE("failed to subscribe; result = %d", result); |
1424 | } else { | |
49e66671 | 1425 | ALOGD("NAN subscribe...success"); |
d3a587e8 JPS |
1426 | } |
1427 | return result; | |
1428 | ||
1429 | } | |
1430 | ||
650a9e6a JPS |
1431 | int subscribeCancel(transaction_id id, NanSubscribeCancelRequest *msg) { |
1432 | ALOGD("NAN subscribeCancel transId:%d subscribeId:%d", id, msg->subscribe_id); | |
d3a587e8 JPS |
1433 | WifiRequest request(familyId(), ifaceId()); |
1434 | ||
1435 | int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_SUBSCRIBECANCEL); | |
1436 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "subscribeCancel:Failed to create WifiRequest"); | |
1437 | ||
1438 | nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); | |
1439 | if (!data) { | |
1440 | ALOGE("subscribeCancel: request.attr_start fail"); | |
1441 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1442 | } | |
1443 | ||
1444 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->subscribe_id, | |
1445 | NAN_REQ_ATTR_SUBSCRIBE_ID, request, result, "subscribeCancel:Failed to put msg->subscribe_id"); | |
1446 | ||
1447 | request.attr_end(data); | |
650a9e6a | 1448 | subscribeCancelTid = id; |
d3a587e8 JPS |
1449 | result = requestResponse(request); |
1450 | if (result != WIFI_SUCCESS) { | |
650a9e6a | 1451 | subscribeCancelTid = 0; |
d3a587e8 JPS |
1452 | ALOGE("failed to subscribeCancel; result = %d", result); |
1453 | } else { | |
49e66671 | 1454 | ALOGD("NAN subscribeCancel...success"); |
d3a587e8 JPS |
1455 | } |
1456 | return result; | |
1457 | } | |
1458 | ||
650a9e6a JPS |
1459 | int followup(transaction_id id, NanTransmitFollowupRequest *msg) { |
1460 | ALOGD("NAN followup transid:%d pub/subId:%d reqInstId:%d", id, msg->publish_subscribe_id, msg->requestor_instance_id); | |
d3a587e8 JPS |
1461 | WifiRequest request(familyId(), ifaceId()); |
1462 | ||
1463 | int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_TXFOLLOWUP); | |
1464 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "followup:Failed to create WifiRequest"); | |
1465 | ||
1466 | nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); | |
1467 | if (!data) { | |
1468 | ALOGE("followup: request.attr_start fail"); | |
1469 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1470 | } | |
1471 | ||
1472 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->publish_subscribe_id, | |
1473 | NAN_REQ_ATTR_FOLLOWUP_ID, request, result, "followup:Failed to put msg->publish_subscribe_id"); | |
1474 | ||
1475 | CHECK_CONFIG_PUT_32_RETURN_FAIL(1, msg->requestor_instance_id, | |
1476 | NAN_REQ_ATTR_FOLLOWUP_REQUESTOR_ID, request, result, "followup:Failed to put msg->requestor_instance_id"); | |
1477 | ||
1478 | CHECK_CONFIG_PUT_RETURN_FAIL(1, msg->addr, NAN_MAC_ADDR_LEN, | |
1479 | NAN_REQ_ATTR_FOLLOWUP_ADDR, request, result, "followup:Failed to put msg->addr"); | |
1480 | ||
1481 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->priority, | |
1482 | NAN_REQ_ATTR_FOLLOWUP_PRIORITY, request, result, "followup:Failed to put msg->priority"); | |
1483 | ||
1484 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->dw_or_faw, | |
1485 | NAN_REQ_ATTR_FOLLOWUP_TX_WINDOW, request, result, "followup:Failed to put msg->dw_or_faw"); | |
1486 | ||
1487 | CHECK_CONFIG_PUT_16_RETURN_FAIL(msg->service_specific_info_len, msg->service_specific_info_len, | |
1488 | NAN_REQ_ATTR_FOLLOWUP_SERVICE_NAME_LEN, request, result, "followup:Failed to put msg->service_specific_info_len"); | |
1489 | ||
1490 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->service_specific_info_len, msg->service_specific_info, msg->service_specific_info_len, | |
1491 | NAN_REQ_ATTR_FOLLOWUP_SERVICE_NAME, request, result, "followup:Failed to put msg->service_specific_info"); | |
1492 | ||
1493 | CHECK_CONFIG_PUT_8_RETURN_FAIL(1, msg->recv_indication_cfg, | |
1494 | NAN_REQ_ATTR_FOLLOWUP_RECV_IND_CFG, request, result, "followup:Failed to put msg->recv_indication_cfg"); | |
1495 | ||
f8c9e3bb JPS |
1496 | CHECK_CONFIG_PUT_16_RETURN_FAIL(1, msg->sdea_service_specific_info_len, |
1497 | NAN_REQ_ATTR_PUBLISH_SDEA_LEN, request, result, "publish:Failed to put msg->sdea_service_specific_info_len"); | |
1498 | ||
1499 | CHECK_CONFIG_PUT_RETURN_FAIL(msg->sdea_service_specific_info_len, msg->sdea_service_specific_info, msg->sdea_service_specific_info_len, | |
1500 | NAN_REQ_ATTR_PUBLISH_SDEA, request, result, "publish:Failed to put msg->sdea_service_specific_info"); | |
1501 | ||
d3a587e8 | 1502 | request.attr_end(data); |
650a9e6a | 1503 | followupTid = id; |
d3a587e8 JPS |
1504 | result = requestResponse(request); |
1505 | if (result != WIFI_SUCCESS) { | |
650a9e6a | 1506 | followupTid = 0; |
d3a587e8 JPS |
1507 | ALOGE("failed to followup; result = %d", result); |
1508 | } else { | |
49e66671 | 1509 | ALOGD("NAN followup...success"); |
d3a587e8 JPS |
1510 | } |
1511 | return result; | |
1512 | ||
1513 | } | |
1514 | ||
650a9e6a JPS |
1515 | int getCapabilities(transaction_id id) { |
1516 | ALOGD("NAN getCapabilities transId:%d", id); | |
d3a587e8 JPS |
1517 | WifiRequest request(familyId(), ifaceId()); |
1518 | ||
1519 | int result = request.create(GOOGLE_OUI, SLSI_NL80211_VENDOR_SUBCMD_NAN_CAPABILITIES); | |
1520 | CHECK_WIFI_STATUS_RETURN_FAIL(result, "getCapabilities:Failed to create WifiRequest"); | |
1521 | ||
650a9e6a | 1522 | capabilitiesTid = id; |
d3a587e8 JPS |
1523 | result = requestResponse(request); |
1524 | if (result != WIFI_SUCCESS) { | |
650a9e6a | 1525 | capabilitiesTid = 0; |
d3a587e8 JPS |
1526 | ALOGE("failed to getCapabilities; result = %d", result); |
1527 | } else { | |
49e66671 | 1528 | ALOGD("NAN getCapabilities...success"); |
d3a587e8 JPS |
1529 | } |
1530 | return result; | |
1531 | } | |
1532 | ||
1533 | int handleEvent(WifiEvent &event) { | |
1534 | int ret; | |
d3a587e8 JPS |
1535 | |
1536 | if (event.get_cmd() != NL80211_CMD_VENDOR) { | |
650a9e6a | 1537 | ALOGD("NAN %s Ignoring event with cmd = %d", __func__, event.get_cmd()); |
d3a587e8 JPS |
1538 | return NL_SKIP; |
1539 | } | |
1540 | ||
1541 | int id = event.get_vendor_id(); | |
1542 | int subcmd = event.get_vendor_subcmd(); | |
1543 | ||
650a9e6a | 1544 | ALOGI("NAN %s Id = %0x, subcmd = %d", __func__, id, subcmd); |
d3a587e8 JPS |
1545 | |
1546 | switch(subcmd) { | |
1547 | case SLSI_NAN_EVENT_MATCH: | |
1548 | ret = processMatchEvent(event); | |
1549 | break; | |
1550 | case SLSI_NAN_EVENT_MATCH_EXPIRED: | |
1551 | ret = processMatchExpiredEvent(event); | |
1552 | break; | |
1553 | case SLSI_NAN_EVENT_PUBLISH_TERMINATED: | |
1554 | ret = processPublishTerminatedEvent(event); | |
1555 | break; | |
1556 | case SLSI_NAN_EVENT_SUBSCRIBE_TERMINATED: | |
1557 | ret = processSubscribeTerminatedEvent(event); | |
1558 | break; | |
1559 | case SLSI_NAN_EVENT_FOLLOWUP: | |
1560 | ret = processFollowupEvent(event); | |
1561 | break; | |
1562 | case SLSI_NAN_EVENT_DISABLED: | |
1563 | ret = processNanDisabledEvent(event); | |
1564 | break; | |
1565 | case SLSI_NAN_EVENT_DISCOVERY_ENGINE: | |
1566 | ret = processNanDiscoveryEvent(event); | |
1567 | break; | |
650a9e6a JPS |
1568 | case SLSI_NAN_EVENT_TRANSMIT_FOLLOWUP_STATUS: |
1569 | ret = processNanFollowupStatus(event); | |
1570 | break; | |
d3a587e8 JPS |
1571 | } |
1572 | ||
1573 | return NL_OK; | |
1574 | } | |
1575 | ||
1576 | int handleResponse(WifiEvent &reply) { | |
d3a587e8 | 1577 | if (reply.get_cmd() != NL80211_CMD_VENDOR) { |
650a9e6a | 1578 | ALOGD("NAN %s Ignoring reply with cmd = %d", __func__, reply.get_cmd()); |
d3a587e8 JPS |
1579 | return NL_SKIP; |
1580 | } | |
1581 | ||
d3a587e8 JPS |
1582 | NanResponseMsg response; |
1583 | memset(&response, 0, sizeof(response)); | |
1584 | ||
1585 | if (processResponse(reply, &response) == NL_SKIP) | |
1586 | return NL_SKIP; | |
1587 | ||
650a9e6a JPS |
1588 | transaction_id id = 0; |
1589 | switch ((int)response.response_type) { | |
1590 | case NAN_RESPONSE_PUBLISH: | |
1591 | id = publishTid; | |
1592 | publishTid = 0; | |
1593 | break; | |
1594 | case NAN_RESPONSE_ENABLED: | |
1595 | id = enableTid; | |
1596 | enableTid = 0; | |
1597 | break; | |
1598 | case NAN_RESPONSE_DISABLED: | |
1599 | id = disableTid; | |
1600 | disableTid = 0; | |
1601 | break; | |
1602 | case NAN_RESPONSE_PUBLISH_CANCEL: | |
1603 | id = publishCancelTid; | |
1604 | publishCancelTid = 0; | |
1605 | break; | |
1606 | case NAN_RESPONSE_SUBSCRIBE_CANCEL: | |
1607 | id = subscribeCancelTid; | |
1608 | subscribeCancelTid = 0; | |
1609 | break; | |
1610 | case NAN_RESPONSE_CONFIG: | |
1611 | id = configTid; | |
1612 | configTid = 0; | |
1613 | break; | |
1614 | case NAN_GET_CAPABILITIES: | |
1615 | id = capabilitiesTid; | |
1616 | capabilitiesTid = 0; | |
1617 | break; | |
1618 | case NAN_RESPONSE_SUBSCRIBE: | |
1619 | id = subscribeTid; | |
1620 | subscribeTid = 0; | |
1621 | break; | |
1622 | case NAN_RESPONSE_TRANSMIT_FOLLOWUP: | |
1623 | id = followupTid; | |
1624 | /* followupTid is required on receiving followup_up transmit status. | |
1625 | * Do not reset followupTid here*/ | |
1626 | break; | |
1627 | } | |
1628 | ALOGD("NAN %s transId:%d status:%d, response:%d", __func__, id, response.status, response.response_type); | |
d3a587e8 | 1629 | if (callbackEventHandler.NotifyResponse) |
650a9e6a | 1630 | callbackEventHandler.NotifyResponse(id, &response); |
d3a587e8 JPS |
1631 | return NL_OK; |
1632 | } | |
1633 | }; | |
1634 | ||
1635 | NanCallbackHandler NanCommand::callbackEventHandler; | |
1636 | ||
1637 | NanCommand *nan_get_object(transaction_id id, | |
1638 | wifi_interface_handle iface) { | |
1639 | wifi_handle handle = getWifiHandle(iface); | |
650a9e6a | 1640 | NanCommand *nanRequest = (NanCommand *)wifi_get_nan_cmd(handle); |
d3a587e8 JPS |
1641 | if (!nanRequest) { |
1642 | nanRequest = new NanCommand(iface, id); | |
1643 | if (!nanRequest){ | |
1644 | ALOGE("Could not alloc NanCommand"); | |
1645 | return NULL; | |
1646 | } | |
1647 | } | |
1648 | return nanRequest; | |
1649 | } | |
1650 | ||
1651 | wifi_error nan_enable_request(transaction_id id, | |
1652 | wifi_interface_handle iface, | |
1653 | NanEnableRequest *msg) { | |
1654 | wifi_handle handle = getWifiHandle(iface); | |
1655 | wifi_error ret; | |
1656 | ||
1657 | NanCommand *nanRequest = new NanCommand(iface, id); | |
1658 | if (!nanRequest) { | |
1659 | ALOGE("nan_enable_request:: Unable to create NanCommand"); | |
1660 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1661 | } | |
1662 | ||
650a9e6a JPS |
1663 | wifi_set_nan_cmd(handle, nanRequest); |
1664 | ret = (wifi_error)nanRequest->enable(id, msg); | |
d3a587e8 | 1665 | if (ret != WIFI_SUCCESS) { |
650a9e6a | 1666 | wifi_reset_nan_cmd(handle); |
d3a587e8 JPS |
1667 | delete nanRequest; |
1668 | } | |
1669 | return ret; | |
1670 | } | |
1671 | ||
1672 | /* Disable NAN functionality. */ | |
1673 | wifi_error nan_disable_request(transaction_id id, wifi_interface_handle iface) { | |
1674 | NanCommand *nanRequest = nan_get_object(id, iface); | |
1675 | wifi_error ret; | |
1676 | ||
1677 | if (!nanRequest) { | |
1678 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1679 | } | |
650a9e6a JPS |
1680 | ret = (wifi_error)nanRequest->disable(id); |
1681 | wifi_reset_nan_cmd(getWifiHandle(iface)); | |
d3a587e8 JPS |
1682 | delete nanRequest; |
1683 | return ret; | |
1684 | } | |
1685 | ||
1686 | /* Publish request to advertize a service. */ | |
1687 | wifi_error nan_publish_request(transaction_id id, | |
1688 | wifi_interface_handle iface, | |
1689 | NanPublishRequest *msg) { | |
1690 | NanCommand *nanRequest = nan_get_object(id, iface); | |
1691 | if (!nanRequest) { | |
1692 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1693 | } | |
650a9e6a | 1694 | return (wifi_error)nanRequest->publish(id, msg); |
d3a587e8 JPS |
1695 | } |
1696 | ||
1697 | /* Cancel previous publish requests. */ | |
1698 | wifi_error nan_publish_cancel_request(transaction_id id, | |
1699 | wifi_interface_handle iface, | |
1700 | NanPublishCancelRequest *msg) { | |
1701 | NanCommand *nanRequest = nan_get_object(id, iface); | |
1702 | if (!nanRequest) { | |
1703 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1704 | } | |
650a9e6a | 1705 | return (wifi_error)nanRequest->publishCancel(id, msg); |
d3a587e8 JPS |
1706 | } |
1707 | ||
1708 | /* Subscribe request to search for a service. */ | |
1709 | wifi_error nan_subscribe_request(transaction_id id, | |
1710 | wifi_interface_handle iface, | |
1711 | NanSubscribeRequest *msg) { | |
1712 | NanCommand *nanRequest = nan_get_object(id, iface); | |
1713 | if (!nanRequest) { | |
1714 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1715 | } | |
650a9e6a | 1716 | return (wifi_error)nanRequest->subscribe(id, msg); |
d3a587e8 JPS |
1717 | } |
1718 | ||
1719 | /* Cancel previous subscribe requests. */ | |
1720 | wifi_error nan_subscribe_cancel_request(transaction_id id, | |
1721 | wifi_interface_handle iface, | |
1722 | NanSubscribeCancelRequest *msg) { | |
1723 | NanCommand *nanRequest = nan_get_object(id, iface); | |
1724 | if (!nanRequest) { | |
1725 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1726 | } | |
650a9e6a | 1727 | return (wifi_error)nanRequest->subscribeCancel(id, msg); |
d3a587e8 JPS |
1728 | } |
1729 | ||
1730 | /* NAN transmit follow up request. */ | |
1731 | wifi_error nan_transmit_followup_request(transaction_id id, | |
1732 | wifi_interface_handle iface, | |
1733 | NanTransmitFollowupRequest *msg) { | |
1734 | NanCommand *nanRequest = nan_get_object(id, iface); | |
1735 | if (!nanRequest) { | |
1736 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1737 | } | |
650a9e6a | 1738 | return (wifi_error)nanRequest->followup(id, msg); |
d3a587e8 JPS |
1739 | } |
1740 | ||
1741 | /* NAN configuration request. */ | |
1742 | wifi_error nan_config_request(transaction_id id, | |
1743 | wifi_interface_handle iface, | |
1744 | NanConfigRequest *msg) { | |
1745 | NanCommand *nanRequest = nan_get_object(id, iface); | |
1746 | if (!nanRequest) { | |
1747 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1748 | } | |
650a9e6a | 1749 | return (wifi_error)nanRequest->config(id, msg); |
d3a587e8 JPS |
1750 | } |
1751 | ||
1752 | /* Register NAN callbacks. */ | |
1753 | wifi_error nan_register_handler(wifi_interface_handle iface, | |
1754 | NanCallbackHandler handlers) { | |
1755 | return (wifi_error)NanCommand::setCallbackHandler(handlers); | |
1756 | } | |
1757 | ||
1758 | /* Get NAN HAL version. */ | |
1759 | wifi_error nan_get_version(wifi_handle handle, | |
1760 | NanVersion *version) { | |
1761 | return (wifi_error)NanCommand::getVersion(version); | |
1762 | } | |
1763 | ||
1764 | /* Get NAN capabilities. */ | |
1765 | wifi_error nan_get_capabilities(transaction_id id, | |
1766 | wifi_interface_handle iface) { | |
1767 | NanCommand *nanRequest = nan_get_object(id, iface); | |
1768 | if (!nanRequest) { | |
1769 | return WIFI_ERROR_OUT_OF_MEMORY; | |
1770 | } | |
650a9e6a | 1771 | return (wifi_error)nanRequest->getCapabilities(id); |
d3a587e8 JPS |
1772 | } |
1773 |