blob: 4c61ba7ee51115d916ff5872db6d1e74ec509c52 [file] [log] [blame]
Gabriel Biren631a8112022-12-01 22:29:32 +00001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <android-base/logging.h>
18
19#include "hidl_return_util.h"
20#include "hidl_struct_util.h"
21#include "wifi_nan_iface.h"
22#include "wifi_status_util.h"
23
24namespace android {
25namespace hardware {
26namespace wifi {
27namespace V1_6 {
28namespace implementation {
29using hidl_return_util::validateAndCall;
30
31WifiNanIface::WifiNanIface(const std::string& ifname, bool is_dedicated_iface,
32 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
33 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util)
34 : ifname_(ifname),
35 is_dedicated_iface_(is_dedicated_iface),
36 legacy_hal_(legacy_hal),
37 iface_util_(iface_util),
38 is_valid_(true) {
39 if (is_dedicated_iface_) {
40 // If using a dedicated iface, set the iface up first.
41 if (!iface_util_.lock()->setUpState(ifname_, true)) {
42 // Fatal failure, invalidate the iface object.
43 invalidate();
44 return;
45 }
46 }
47 // Register all the callbacks here. these should be valid for the lifetime
48 // of the object. Whenever the mode changes legacy HAL will remove
49 // all of these callbacks.
50 legacy_hal::NanCallbackHandlers callback_handlers;
51 android::wp<WifiNanIface> weak_ptr_this(this);
52
53 // Callback for response.
54 callback_handlers.on_notify_response = [weak_ptr_this](legacy_hal::transaction_id id,
55 const legacy_hal::NanResponseMsg& msg) {
56 const auto shared_ptr_this = weak_ptr_this.promote();
57 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
58 LOG(ERROR) << "Callback invoked on an invalid object";
59 return;
60 }
61 WifiNanStatus wifiNanStatus;
62 if (!hidl_struct_util::convertLegacyNanResponseHeaderToHidl(msg, &wifiNanStatus)) {
63 LOG(ERROR) << "Failed to convert nan response header";
64 return;
65 }
66
67 switch (msg.response_type) {
68 case legacy_hal::NAN_RESPONSE_ENABLED: {
69 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
70 if (!callback->notifyEnableResponse(id, wifiNanStatus).isOk()) {
71 LOG(ERROR) << "Failed to invoke the callback";
72 }
73 }
74 break;
75 }
76 case legacy_hal::NAN_RESPONSE_DISABLED: {
77 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
78 if (!callback->notifyDisableResponse(id, wifiNanStatus).isOk()) {
79 LOG(ERROR) << "Failed to invoke the callback";
80 }
81 }
82 break;
83 }
84 case legacy_hal::NAN_RESPONSE_PUBLISH: {
85 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
86 if (!callback->notifyStartPublishResponse(id, wifiNanStatus,
87 msg.body.publish_response.publish_id)
88 .isOk()) {
89 LOG(ERROR) << "Failed to invoke the callback";
90 }
91 }
92 break;
93 }
94 case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL: {
95 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
96 if (!callback->notifyStopPublishResponse(id, wifiNanStatus).isOk()) {
97 LOG(ERROR) << "Failed to invoke the callback";
98 }
99 }
100 break;
101 }
102 case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP: {
103 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
104 if (!callback->notifyTransmitFollowupResponse(id, wifiNanStatus).isOk()) {
105 LOG(ERROR) << "Failed to invoke the callback";
106 }
107 }
108 break;
109 }
110 case legacy_hal::NAN_RESPONSE_SUBSCRIBE: {
111 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
112 if (!callback->notifyStartSubscribeResponse(
113 id, wifiNanStatus,
114 msg.body.subscribe_response.subscribe_id)
115 .isOk()) {
116 LOG(ERROR) << "Failed to invoke the callback";
117 }
118 }
119 break;
120 }
121 case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL: {
122 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
123 if (!callback->notifyStopSubscribeResponse(id, wifiNanStatus).isOk()) {
124 LOG(ERROR) << "Failed to invoke the callback";
125 }
126 }
127 break;
128 }
129 case legacy_hal::NAN_RESPONSE_CONFIG: {
130 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
131 if (!callback->notifyConfigResponse(id, wifiNanStatus).isOk()) {
132 LOG(ERROR) << "Failed to invoke the callback";
133 }
134 }
135 break;
136 }
137 case legacy_hal::NAN_GET_CAPABILITIES: {
138 V1_6::NanCapabilities hidl_struct;
139 if (!hidl_struct_util::convertLegacyNanCapabilitiesResponseToHidl(
140 msg.body.nan_capabilities, &hidl_struct)) {
141 LOG(ERROR) << "Failed to convert nan capabilities response";
142 return;
143 }
144 for (const auto& callback : shared_ptr_this->getEventCallbacks_1_6()) {
145 if (!callback->notifyCapabilitiesResponse_1_6(id, wifiNanStatus, hidl_struct)
146 .isOk()) {
147 LOG(ERROR) << "Failed to invoke the callback";
148 }
149 }
150 break;
151 }
152 case legacy_hal::NAN_DP_INTERFACE_CREATE: {
153 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
154 if (!callback->notifyCreateDataInterfaceResponse(id, wifiNanStatus).isOk()) {
155 LOG(ERROR) << "Failed to invoke the callback";
156 }
157 }
158 break;
159 }
160 case legacy_hal::NAN_DP_INTERFACE_DELETE: {
161 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
162 if (!callback->notifyDeleteDataInterfaceResponse(id, wifiNanStatus).isOk()) {
163 LOG(ERROR) << "Failed to invoke the callback";
164 }
165 }
166 break;
167 }
168 case legacy_hal::NAN_DP_INITIATOR_RESPONSE: {
169 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
170 if (!callback->notifyInitiateDataPathResponse(
171 id, wifiNanStatus,
172 msg.body.data_request_response.ndp_instance_id)
173 .isOk()) {
174 LOG(ERROR) << "Failed to invoke the callback";
175 }
176 }
177 break;
178 }
179 case legacy_hal::NAN_DP_RESPONDER_RESPONSE: {
180 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
181 if (!callback->notifyRespondToDataPathIndicationResponse(id, wifiNanStatus)
182 .isOk()) {
183 LOG(ERROR) << "Failed to invoke the callback";
184 }
185 }
186 break;
187 }
188 case legacy_hal::NAN_DP_END: {
189 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
190 if (!callback->notifyTerminateDataPathResponse(id, wifiNanStatus).isOk()) {
191 LOG(ERROR) << "Failed to invoke the callback";
192 }
193 }
194 break;
195 }
196 case legacy_hal::NAN_RESPONSE_BEACON_SDF_PAYLOAD:
197 /* fall through */
198 case legacy_hal::NAN_RESPONSE_TCA:
199 /* fall through */
200 case legacy_hal::NAN_RESPONSE_STATS:
201 /* fall through */
202 case legacy_hal::NAN_RESPONSE_ERROR:
203 /* fall through */
204 default:
205 LOG(ERROR) << "Unknown or unhandled response type: " << msg.response_type;
206 return;
207 }
208 };
209
210 callback_handlers.on_event_disc_eng_event =
211 [weak_ptr_this](const legacy_hal::NanDiscEngEventInd& msg) {
212 const auto shared_ptr_this = weak_ptr_this.promote();
213 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
214 LOG(ERROR) << "Callback invoked on an invalid object";
215 return;
216 }
217 NanClusterEventInd hidl_struct;
218 // event types defined identically - hence can be cast
219 hidl_struct.eventType = (NanClusterEventType)msg.event_type;
220 hidl_struct.addr = msg.data.mac_addr.addr;
221
222 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
223 if (!callback->eventClusterEvent(hidl_struct).isOk()) {
224 LOG(ERROR) << "Failed to invoke the callback";
225 }
226 }
227 };
228
229 callback_handlers.on_event_disabled = [weak_ptr_this](const legacy_hal::NanDisabledInd& msg) {
230 const auto shared_ptr_this = weak_ptr_this.promote();
231 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
232 LOG(ERROR) << "Callback invoked on an invalid object";
233 return;
234 }
235 WifiNanStatus status;
236 hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
237 &status);
238
239 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
240 if (!callback->eventDisabled(status).isOk()) {
241 LOG(ERROR) << "Failed to invoke the callback";
242 }
243 }
244 };
245
246 callback_handlers.on_event_publish_terminated =
247 [weak_ptr_this](const legacy_hal::NanPublishTerminatedInd& msg) {
248 const auto shared_ptr_this = weak_ptr_this.promote();
249 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
250 LOG(ERROR) << "Callback invoked on an invalid object";
251 return;
252 }
253 WifiNanStatus status;
254 hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason,
255 sizeof(msg.nan_reason), &status);
256
257 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
258 if (!callback->eventPublishTerminated(msg.publish_id, status).isOk()) {
259 LOG(ERROR) << "Failed to invoke the callback";
260 }
261 }
262 };
263
264 callback_handlers.on_event_subscribe_terminated =
265 [weak_ptr_this](const legacy_hal::NanSubscribeTerminatedInd& msg) {
266 const auto shared_ptr_this = weak_ptr_this.promote();
267 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
268 LOG(ERROR) << "Callback invoked on an invalid object";
269 return;
270 }
271 WifiNanStatus status;
272 hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason,
273 sizeof(msg.nan_reason), &status);
274
275 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
276 if (!callback->eventSubscribeTerminated(msg.subscribe_id, status).isOk()) {
277 LOG(ERROR) << "Failed to invoke the callback";
278 }
279 }
280 };
281
282 callback_handlers.on_event_match = [weak_ptr_this](const legacy_hal::NanMatchInd& msg) {
283 const auto shared_ptr_this = weak_ptr_this.promote();
284 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
285 LOG(ERROR) << "Callback invoked on an invalid object";
286 return;
287 }
288 V1_6::NanMatchInd hidl_struct;
289 if (!hidl_struct_util::convertLegacyNanMatchIndToHidl(msg, &hidl_struct)) {
290 LOG(ERROR) << "Failed to convert nan capabilities response";
291 return;
292 }
293
294 for (const auto& callback : shared_ptr_this->getEventCallbacks_1_6()) {
295 if (!callback->eventMatch_1_6(hidl_struct).isOk()) {
296 LOG(ERROR) << "Failed to invoke the callback";
297 }
298 }
299 };
300
301 callback_handlers.on_event_match_expired = [weak_ptr_this](
302 const legacy_hal::NanMatchExpiredInd& msg) {
303 const auto shared_ptr_this = weak_ptr_this.promote();
304 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
305 LOG(ERROR) << "Callback invoked on an invalid object";
306 return;
307 }
308 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
309 if (!callback->eventMatchExpired(msg.publish_subscribe_id, msg.requestor_instance_id)
310 .isOk()) {
311 LOG(ERROR) << "Failed to invoke the callback";
312 }
313 }
314 };
315
316 callback_handlers.on_event_followup = [weak_ptr_this](const legacy_hal::NanFollowupInd& msg) {
317 const auto shared_ptr_this = weak_ptr_this.promote();
318 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
319 LOG(ERROR) << "Callback invoked on an invalid object";
320 return;
321 }
322 NanFollowupReceivedInd hidl_struct;
323 if (!hidl_struct_util::convertLegacyNanFollowupIndToHidl(msg, &hidl_struct)) {
324 LOG(ERROR) << "Failed to convert nan capabilities response";
325 return;
326 }
327
328 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
329 if (!callback->eventFollowupReceived(hidl_struct).isOk()) {
330 LOG(ERROR) << "Failed to invoke the callback";
331 }
332 }
333 };
334
335 callback_handlers.on_event_transmit_follow_up =
336 [weak_ptr_this](const legacy_hal::NanTransmitFollowupInd& msg) {
337 const auto shared_ptr_this = weak_ptr_this.promote();
338 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
339 LOG(ERROR) << "Callback invoked on an invalid object";
340 return;
341 }
342 WifiNanStatus status;
343 hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason,
344 sizeof(msg.nan_reason), &status);
345
346 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
347 if (!callback->eventTransmitFollowup(msg.id, status).isOk()) {
348 LOG(ERROR) << "Failed to invoke the callback";
349 }
350 }
351 };
352
353 callback_handlers.on_event_data_path_request =
354 [weak_ptr_this](const legacy_hal::NanDataPathRequestInd& msg) {
355 const auto shared_ptr_this = weak_ptr_this.promote();
356 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
357 LOG(ERROR) << "Callback invoked on an invalid object";
358 return;
359 }
360 NanDataPathRequestInd hidl_struct;
361 if (!hidl_struct_util::convertLegacyNanDataPathRequestIndToHidl(msg,
362 &hidl_struct)) {
363 LOG(ERROR) << "Failed to convert nan capabilities response";
364 return;
365 }
366
367 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
368 if (!callback->eventDataPathRequest(hidl_struct).isOk()) {
369 LOG(ERROR) << "Failed to invoke the callback";
370 }
371 }
372 };
373
374 callback_handlers.on_event_data_path_confirm =
375 [weak_ptr_this](const legacy_hal::NanDataPathConfirmInd& msg) {
376 const auto shared_ptr_this = weak_ptr_this.promote();
377 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
378 LOG(ERROR) << "Callback invoked on an invalid object";
379 return;
380 }
381 V1_6::NanDataPathConfirmInd hidl_struct;
382 if (!hidl_struct_util::convertLegacyNanDataPathConfirmIndToHidl(msg,
383 &hidl_struct)) {
384 LOG(ERROR) << "Failed to convert nan capabilities response";
385 return;
386 }
387
388 for (const auto& callback : shared_ptr_this->getEventCallbacks_1_6()) {
389 if (!callback->eventDataPathConfirm_1_6(hidl_struct).isOk()) {
390 LOG(ERROR) << "Failed to invoke the callback";
391 }
392 }
393 };
394
395 callback_handlers.on_event_data_path_end =
396 [weak_ptr_this](const legacy_hal::NanDataPathEndInd& msg) {
397 const auto shared_ptr_this = weak_ptr_this.promote();
398 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
399 LOG(ERROR) << "Callback invoked on an invalid object";
400 return;
401 }
402 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
403 for (int i = 0; i < msg.num_ndp_instances; ++i) {
404 if (!callback->eventDataPathTerminated(msg.ndp_instance_id[i]).isOk()) {
405 LOG(ERROR) << "Failed to invoke the callback";
406 }
407 }
408 }
409 };
410
411 callback_handlers.on_event_beacon_sdf_payload =
412 [weak_ptr_this](const legacy_hal::NanBeaconSdfPayloadInd& /* msg */) {
413 LOG(ERROR) << "on_event_beacon_sdf_payload - should not be called";
414 };
415
416 callback_handlers.on_event_range_request =
417 [weak_ptr_this](const legacy_hal::NanRangeRequestInd& /* msg */) {
418 LOG(ERROR) << "on_event_range_request - should not be called";
419 };
420
421 callback_handlers.on_event_range_report =
422 [weak_ptr_this](const legacy_hal::NanRangeReportInd& /* msg */) {
423 LOG(ERROR) << "on_event_range_report - should not be called";
424 };
425
426 callback_handlers.on_event_schedule_update =
427 [weak_ptr_this](const legacy_hal::NanDataPathScheduleUpdateInd& msg) {
428 const auto shared_ptr_this = weak_ptr_this.promote();
429 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
430 LOG(ERROR) << "Callback invoked on an invalid object";
431 return;
432 }
433 V1_6::NanDataPathScheduleUpdateInd hidl_struct;
434 if (!hidl_struct_util::convertLegacyNanDataPathScheduleUpdateIndToHidl(
435 msg, &hidl_struct)) {
436 LOG(ERROR) << "Failed to convert nan capabilities response";
437 return;
438 }
439
440 for (const auto& callback : shared_ptr_this->getEventCallbacks_1_6()) {
441 if (!callback->eventDataPathScheduleUpdate_1_6(hidl_struct).isOk()) {
442 LOG(ERROR) << "Failed to invoke the callback";
443 }
444 }
445 };
446
447 legacy_hal::wifi_error legacy_status =
448 legacy_hal_.lock()->nanRegisterCallbackHandlers(ifname_, callback_handlers);
449 if (legacy_status != legacy_hal::WIFI_SUCCESS) {
450 LOG(ERROR) << "Failed to register nan callbacks. Invalidating object";
451 invalidate();
452 }
453
454 // Register for iface state toggle events.
455 iface_util::IfaceEventHandlers event_handlers = {};
Ye Jiao2dc47ca2023-03-13 10:58:08 +0800456#ifndef WIFI_SKIP_STATE_TOGGLE_OFF_ON_FOR_NAN
Gabriel Biren631a8112022-12-01 22:29:32 +0000457 event_handlers.on_state_toggle_off_on = [weak_ptr_this](const std::string& /* iface_name */) {
458 const auto shared_ptr_this = weak_ptr_this.promote();
459 if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
460 LOG(ERROR) << "Callback invoked on an invalid object";
461 return;
462 }
463 // Tell framework that NAN has been disabled.
464 WifiNanStatus status = {NanStatusType::UNSUPPORTED_CONCURRENCY_NAN_DISABLED, ""};
465 for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
466 if (!callback->eventDisabled(status).isOk()) {
467 LOG(ERROR) << "Failed to invoke the callback";
468 }
469 }
470 };
Ye Jiao2dc47ca2023-03-13 10:58:08 +0800471#endif
Gabriel Biren631a8112022-12-01 22:29:32 +0000472 iface_util_.lock()->registerIfaceEventHandlers(ifname_, event_handlers);
473}
474
475void WifiNanIface::invalidate() {
476 if (!isValid()) {
477 return;
478 }
479 // send commands to HAL to actually disable and destroy interfaces
480 legacy_hal_.lock()->nanDisableRequest(ifname_, 0xFFFF);
481 legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFE, "aware_data0");
482 legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFD, "aware_data1");
483 iface_util_.lock()->unregisterIfaceEventHandlers(ifname_);
484 legacy_hal_.reset();
485 event_cb_handler_.invalidate();
486 event_cb_handler_1_2_.invalidate();
487 event_cb_handler_1_5_.invalidate();
488 is_valid_ = false;
489 if (is_dedicated_iface_) {
490 // If using a dedicated iface, set the iface down.
491 iface_util_.lock()->setUpState(ifname_, false);
492 }
493}
494
495bool WifiNanIface::isValid() {
496 return is_valid_;
497}
498
499std::string WifiNanIface::getName() {
500 return ifname_;
501}
502
503std::set<sp<V1_0::IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks() {
504 return event_cb_handler_.getCallbacks();
505}
506
507std::set<sp<V1_2::IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks_1_2() {
508 return event_cb_handler_1_2_.getCallbacks();
509}
510
511std::set<sp<V1_5::IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks_1_5() {
512 return event_cb_handler_1_5_.getCallbacks();
513}
514
515std::set<sp<V1_6::IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks_1_6() {
516 return event_cb_handler_1_6_.getCallbacks();
517}
518
519Return<void> WifiNanIface::getName(getName_cb hidl_status_cb) {
520 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
521 &WifiNanIface::getNameInternal, hidl_status_cb);
522}
523
524Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) {
525 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
526 &WifiNanIface::getTypeInternal, hidl_status_cb);
527}
528
529Return<void> WifiNanIface::registerEventCallback(
530 const sp<V1_0::IWifiNanIfaceEventCallback>& callback,
531 registerEventCallback_cb hidl_status_cb) {
532 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
533 &WifiNanIface::registerEventCallbackInternal, hidl_status_cb, callback);
534}
535
536Return<void> WifiNanIface::getCapabilitiesRequest(uint16_t cmd_id,
537 getCapabilitiesRequest_cb hidl_status_cb) {
538 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
539 &WifiNanIface::getCapabilitiesRequestInternal, hidl_status_cb, cmd_id);
540}
541
542Return<void> WifiNanIface::enableRequest(uint16_t cmd_id, const V1_0::NanEnableRequest& msg,
543 enableRequest_cb hidl_status_cb) {
544 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
545 &WifiNanIface::enableRequestInternal, hidl_status_cb, cmd_id, msg);
546}
547
548Return<void> WifiNanIface::configRequest(uint16_t cmd_id, const V1_0::NanConfigRequest& msg,
549 configRequest_cb hidl_status_cb) {
550 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
551 &WifiNanIface::configRequestInternal, hidl_status_cb, cmd_id, msg);
552}
553
554Return<void> WifiNanIface::disableRequest(uint16_t cmd_id, disableRequest_cb hidl_status_cb) {
555 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
556 &WifiNanIface::disableRequestInternal, hidl_status_cb, cmd_id);
557}
558
559Return<void> WifiNanIface::startPublishRequest(uint16_t cmd_id, const V1_0::NanPublishRequest& msg,
560 startPublishRequest_cb hidl_status_cb) {
561 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
562 &WifiNanIface::startPublishRequestInternal, hidl_status_cb, cmd_id, msg);
563}
564
565Return<void> WifiNanIface::stopPublishRequest(uint16_t cmd_id, uint8_t sessionId,
566 stopPublishRequest_cb hidl_status_cb) {
567 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
568 &WifiNanIface::stopPublishRequestInternal, hidl_status_cb, cmd_id,
569 sessionId);
570}
571
572Return<void> WifiNanIface::startSubscribeRequest(uint16_t cmd_id,
573 const V1_0::NanSubscribeRequest& msg,
574 startSubscribeRequest_cb hidl_status_cb) {
575 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
576 &WifiNanIface::startSubscribeRequestInternal, hidl_status_cb, cmd_id,
577 msg);
578}
579
580Return<void> WifiNanIface::stopSubscribeRequest(uint16_t cmd_id, uint8_t sessionId,
581 stopSubscribeRequest_cb hidl_status_cb) {
582 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
583 &WifiNanIface::stopSubscribeRequestInternal, hidl_status_cb, cmd_id,
584 sessionId);
585}
586
587Return<void> WifiNanIface::transmitFollowupRequest(uint16_t cmd_id,
588 const NanTransmitFollowupRequest& msg,
589 transmitFollowupRequest_cb hidl_status_cb) {
590 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
591 &WifiNanIface::transmitFollowupRequestInternal, hidl_status_cb, cmd_id,
592 msg);
593}
594
595Return<void> WifiNanIface::createDataInterfaceRequest(
596 uint16_t cmd_id, const hidl_string& iface_name,
597 createDataInterfaceRequest_cb hidl_status_cb) {
598 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
599 &WifiNanIface::createDataInterfaceRequestInternal, hidl_status_cb,
600 cmd_id, iface_name);
601}
602
603Return<void> WifiNanIface::deleteDataInterfaceRequest(
604 uint16_t cmd_id, const hidl_string& iface_name,
605 deleteDataInterfaceRequest_cb hidl_status_cb) {
606 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
607 &WifiNanIface::deleteDataInterfaceRequestInternal, hidl_status_cb,
608 cmd_id, iface_name);
609}
610
611Return<void> WifiNanIface::initiateDataPathRequest(uint16_t cmd_id,
612 const V1_0::NanInitiateDataPathRequest& msg,
613 initiateDataPathRequest_cb hidl_status_cb) {
614 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
615 &WifiNanIface::initiateDataPathRequestInternal, hidl_status_cb, cmd_id,
616 msg);
617}
618
619Return<void> WifiNanIface::respondToDataPathIndicationRequest(
620 uint16_t cmd_id, const V1_0::NanRespondToDataPathIndicationRequest& msg,
621 respondToDataPathIndicationRequest_cb hidl_status_cb) {
622 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
623 &WifiNanIface::respondToDataPathIndicationRequestInternal,
624 hidl_status_cb, cmd_id, msg);
625}
626
627Return<void> WifiNanIface::terminateDataPathRequest(uint16_t cmd_id, uint32_t ndpInstanceId,
628 terminateDataPathRequest_cb hidl_status_cb) {
629 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
630 &WifiNanIface::terminateDataPathRequestInternal, hidl_status_cb, cmd_id,
631 ndpInstanceId);
632}
633
634Return<void> WifiNanIface::registerEventCallback_1_2(
635 const sp<V1_2::IWifiNanIfaceEventCallback>& callback,
636 registerEventCallback_1_2_cb hidl_status_cb) {
637 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
638 &WifiNanIface::registerEventCallback_1_2Internal, hidl_status_cb,
639 callback);
640}
641
642Return<void> WifiNanIface::enableRequest_1_2(uint16_t cmd_id, const V1_0::NanEnableRequest& msg1,
643 const V1_2::NanConfigRequestSupplemental& msg2,
644 enableRequest_1_2_cb hidl_status_cb) {
645 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
646 &WifiNanIface::enableRequest_1_2Internal, hidl_status_cb, cmd_id, msg1,
647 msg2);
648}
649
650Return<void> WifiNanIface::configRequest_1_2(uint16_t cmd_id, const V1_0::NanConfigRequest& msg1,
651 const V1_2::NanConfigRequestSupplemental& msg2,
652 configRequest_1_2_cb hidl_status_cb) {
653 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
654 &WifiNanIface::configRequest_1_2Internal, hidl_status_cb, cmd_id, msg1,
655 msg2);
656}
657
658Return<void> WifiNanIface::enableRequest_1_4(uint16_t cmd_id, const V1_4::NanEnableRequest& msg1,
659 const V1_2::NanConfigRequestSupplemental& msg2,
660 enableRequest_1_4_cb hidl_status_cb) {
661 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
662 &WifiNanIface::enableRequest_1_4Internal, hidl_status_cb, cmd_id, msg1,
663 msg2);
664}
665
666Return<void> WifiNanIface::configRequest_1_4(uint16_t cmd_id, const V1_4::NanConfigRequest& msg1,
667 const V1_2::NanConfigRequestSupplemental& msg2,
668 configRequest_1_4_cb hidl_status_cb) {
669 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
670 &WifiNanIface::configRequest_1_4Internal, hidl_status_cb, cmd_id, msg1,
671 msg2);
672}
673
674Return<void> WifiNanIface::registerEventCallback_1_5(
675 const sp<V1_5::IWifiNanIfaceEventCallback>& callback,
676 registerEventCallback_1_5_cb hidl_status_cb) {
677 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
678 &WifiNanIface::registerEventCallback_1_5Internal, hidl_status_cb,
679 callback);
680}
681
682Return<void> WifiNanIface::enableRequest_1_5(uint16_t cmd_id, const V1_4::NanEnableRequest& msg1,
683 const V1_5::NanConfigRequestSupplemental& msg2,
684 enableRequest_1_5_cb hidl_status_cb) {
685 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
686 &WifiNanIface::enableRequest_1_5Internal, hidl_status_cb, cmd_id, msg1,
687 msg2);
688}
689
690Return<void> WifiNanIface::configRequest_1_5(uint16_t cmd_id, const V1_4::NanConfigRequest& msg1,
691 const V1_5::NanConfigRequestSupplemental& msg2,
692 configRequest_1_5_cb hidl_status_cb) {
693 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
694 &WifiNanIface::configRequest_1_5Internal, hidl_status_cb, cmd_id, msg1,
695 msg2);
696}
697
698Return<void> WifiNanIface::getCapabilitiesRequest_1_5(
699 uint16_t cmd_id, getCapabilitiesRequest_1_5_cb hidl_status_cb) {
700 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
701 &WifiNanIface::getCapabilitiesRequest_1_5Internal, hidl_status_cb,
702 cmd_id);
703}
704
705Return<void> WifiNanIface::enableRequest_1_6(uint16_t cmd_id, const V1_4::NanEnableRequest& msg1,
706 const V1_6::NanConfigRequestSupplemental& msg2,
707 enableRequest_1_5_cb hidl_status_cb) {
708 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
709 &WifiNanIface::enableRequest_1_6Internal, hidl_status_cb, cmd_id, msg1,
710 msg2);
711}
712
713Return<void> WifiNanIface::configRequest_1_6(uint16_t cmd_id, const V1_4::NanConfigRequest& msg1,
714 const V1_6::NanConfigRequestSupplemental& msg2,
715 configRequest_1_5_cb hidl_status_cb) {
716 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
717 &WifiNanIface::configRequest_1_6Internal, hidl_status_cb, cmd_id, msg1,
718 msg2);
719}
720
721Return<void> WifiNanIface::initiateDataPathRequest_1_6(uint16_t cmd_id,
722 const V1_6::NanInitiateDataPathRequest& msg,
723 initiateDataPathRequest_cb hidl_status_cb) {
724 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
725 &WifiNanIface::initiateDataPathRequest_1_6Internal, hidl_status_cb,
726 cmd_id, msg);
727}
728
729Return<void> WifiNanIface::respondToDataPathIndicationRequest_1_6(
730 uint16_t cmd_id, const V1_6::NanRespondToDataPathIndicationRequest& msg,
731 respondToDataPathIndicationRequest_cb hidl_status_cb) {
732 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
733 &WifiNanIface::respondToDataPathIndicationRequest_1_6Internal,
734 hidl_status_cb, cmd_id, msg);
735}
736
737Return<void> WifiNanIface::startPublishRequest_1_6(uint16_t cmd_id,
738 const V1_6::NanPublishRequest& msg,
739 startPublishRequest_cb hidl_status_cb) {
740 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
741 &WifiNanIface::startPublishRequest_1_6Internal, hidl_status_cb, cmd_id,
742 msg);
743}
744
745std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() {
746 return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
747}
748
749std::pair<WifiStatus, IfaceType> WifiNanIface::getTypeInternal() {
750 return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN};
751}
752
753Return<void> WifiNanIface::registerEventCallback_1_6(
754 const sp<V1_6::IWifiNanIfaceEventCallback>& callback,
755 registerEventCallback_1_6_cb hidl_status_cb) {
756 return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
757 &WifiNanIface::registerEventCallback_1_6Internal, hidl_status_cb,
758 callback);
759}
760
761WifiStatus WifiNanIface::registerEventCallbackInternal(
762 const sp<V1_0::IWifiNanIfaceEventCallback>& callback) {
763 if (!event_cb_handler_.addCallback(callback)) {
764 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
765 }
766 return createWifiStatus(WifiStatusCode::SUCCESS);
767}
768
769WifiStatus WifiNanIface::getCapabilitiesRequestInternal(uint16_t /* cmd_id */) {
770 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
771}
772
773WifiStatus WifiNanIface::enableRequestInternal(uint16_t /* cmd_id */,
774 const V1_0::NanEnableRequest& /* msg */) {
775 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
776}
777
778WifiStatus WifiNanIface::configRequestInternal(uint16_t /* cmd_id */,
779 const V1_0::NanConfigRequest& /* msg */) {
780 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
781}
782
783WifiStatus WifiNanIface::disableRequestInternal(uint16_t cmd_id) {
784 legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->nanDisableRequest(ifname_, cmd_id);
785 return createWifiStatusFromLegacyError(legacy_status);
786}
787
788WifiStatus WifiNanIface::startPublishRequestInternal(uint16_t /* cmd_id */,
789 const V1_0::NanPublishRequest& /* msg */) {
790 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
791}
792
793WifiStatus WifiNanIface::stopPublishRequestInternal(uint16_t cmd_id, uint8_t sessionId) {
794 legacy_hal::NanPublishCancelRequest legacy_msg;
795 legacy_msg.publish_id = sessionId;
796 legacy_hal::wifi_error legacy_status =
797 legacy_hal_.lock()->nanPublishCancelRequest(ifname_, cmd_id, legacy_msg);
798 return createWifiStatusFromLegacyError(legacy_status);
799}
800
801WifiStatus WifiNanIface::startSubscribeRequestInternal(uint16_t cmd_id,
802 const V1_0::NanSubscribeRequest& msg) {
803 legacy_hal::NanSubscribeRequest legacy_msg;
804 if (!hidl_struct_util::convertHidlNanSubscribeRequestToLegacy(msg, &legacy_msg)) {
805 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
806 }
807 legacy_hal::wifi_error legacy_status =
808 legacy_hal_.lock()->nanSubscribeRequest(ifname_, cmd_id, legacy_msg);
809 return createWifiStatusFromLegacyError(legacy_status);
810}
811
812WifiStatus WifiNanIface::stopSubscribeRequestInternal(uint16_t cmd_id, uint8_t sessionId) {
813 legacy_hal::NanSubscribeCancelRequest legacy_msg;
814 legacy_msg.subscribe_id = sessionId;
815 legacy_hal::wifi_error legacy_status =
816 legacy_hal_.lock()->nanSubscribeCancelRequest(ifname_, cmd_id, legacy_msg);
817 return createWifiStatusFromLegacyError(legacy_status);
818}
819
820WifiStatus WifiNanIface::transmitFollowupRequestInternal(uint16_t cmd_id,
821 const NanTransmitFollowupRequest& msg) {
822 legacy_hal::NanTransmitFollowupRequest legacy_msg;
823 if (!hidl_struct_util::convertHidlNanTransmitFollowupRequestToLegacy(msg, &legacy_msg)) {
824 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
825 }
826 legacy_hal::wifi_error legacy_status =
827 legacy_hal_.lock()->nanTransmitFollowupRequest(ifname_, cmd_id, legacy_msg);
828 return createWifiStatusFromLegacyError(legacy_status);
829}
830
831WifiStatus WifiNanIface::createDataInterfaceRequestInternal(uint16_t cmd_id,
832 const std::string& iface_name) {
833 legacy_hal::wifi_error legacy_status =
834 legacy_hal_.lock()->nanDataInterfaceCreate(ifname_, cmd_id, iface_name);
835 return createWifiStatusFromLegacyError(legacy_status);
836}
837WifiStatus WifiNanIface::deleteDataInterfaceRequestInternal(uint16_t cmd_id,
838 const std::string& iface_name) {
839 legacy_hal::wifi_error legacy_status =
840 legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, cmd_id, iface_name);
841 return createWifiStatusFromLegacyError(legacy_status);
842}
843WifiStatus WifiNanIface::initiateDataPathRequestInternal(
844 uint16_t cmd_id, const V1_0::NanInitiateDataPathRequest& msg) {
845 legacy_hal::NanDataPathInitiatorRequest legacy_msg;
846 if (!hidl_struct_util::convertHidlNanDataPathInitiatorRequestToLegacy(msg, &legacy_msg)) {
847 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
848 }
849 legacy_hal::wifi_error legacy_status =
850 legacy_hal_.lock()->nanDataRequestInitiator(ifname_, cmd_id, legacy_msg);
851 return createWifiStatusFromLegacyError(legacy_status);
852}
853WifiStatus WifiNanIface::respondToDataPathIndicationRequestInternal(
854 uint16_t cmd_id, const V1_0::NanRespondToDataPathIndicationRequest& msg) {
855 legacy_hal::NanDataPathIndicationResponse legacy_msg;
856 if (!hidl_struct_util::convertHidlNanDataPathIndicationResponseToLegacy(msg, &legacy_msg)) {
857 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
858 }
859 legacy_hal::wifi_error legacy_status =
860 legacy_hal_.lock()->nanDataIndicationResponse(ifname_, cmd_id, legacy_msg);
861 return createWifiStatusFromLegacyError(legacy_status);
862}
863WifiStatus WifiNanIface::terminateDataPathRequestInternal(uint16_t cmd_id, uint32_t ndpInstanceId) {
864 legacy_hal::wifi_error legacy_status =
865 legacy_hal_.lock()->nanDataEnd(ifname_, cmd_id, ndpInstanceId);
866 return createWifiStatusFromLegacyError(legacy_status);
867}
868
869WifiStatus WifiNanIface::registerEventCallback_1_2Internal(
870 const sp<V1_2::IWifiNanIfaceEventCallback>& callback) {
871 sp<V1_0::IWifiNanIfaceEventCallback> callback_1_0 = callback;
872 if (!event_cb_handler_.addCallback(callback_1_0)) {
873 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
874 }
875 if (!event_cb_handler_1_2_.addCallback(callback)) {
876 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
877 }
878 return createWifiStatus(WifiStatusCode::SUCCESS);
879}
880
881WifiStatus WifiNanIface::enableRequest_1_2Internal(
882 uint16_t /* cmd_id */, const V1_0::NanEnableRequest& /* msg1 */,
883 const V1_2::NanConfigRequestSupplemental& /* msg2 */) {
884 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
885}
886
887WifiStatus WifiNanIface::configRequest_1_2Internal(
888 uint16_t /* cmd_id */, const V1_0::NanConfigRequest& /* msg1 */,
889 const V1_2::NanConfigRequestSupplemental& /* msg2 */) {
890 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
891}
892
893WifiStatus WifiNanIface::enableRequest_1_4Internal(
894 uint16_t /* cmd_id */, const V1_4::NanEnableRequest& /* msg1 */,
895 const V1_2::NanConfigRequestSupplemental& /* msg2 */) {
896 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
897}
898
899WifiStatus WifiNanIface::configRequest_1_4Internal(
900 uint16_t /* cmd_id */, const V1_4::NanConfigRequest& /* msg1 */,
901 const V1_2::NanConfigRequestSupplemental& /* msg2 */) {
902 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
903}
904
905WifiStatus WifiNanIface::registerEventCallback_1_5Internal(
906 const sp<V1_5::IWifiNanIfaceEventCallback>& callback) {
907 sp<V1_0::IWifiNanIfaceEventCallback> callback_1_0 = callback;
908 if (!event_cb_handler_.addCallback(callback_1_0)) {
909 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
910 }
911 sp<V1_2::IWifiNanIfaceEventCallback> callback_1_2 = callback;
912 if (!event_cb_handler_1_2_.addCallback(callback_1_2)) {
913 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
914 }
915 if (!event_cb_handler_1_5_.addCallback(callback)) {
916 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
917 }
918 return createWifiStatus(WifiStatusCode::SUCCESS);
919}
920
921WifiStatus WifiNanIface::getCapabilitiesRequest_1_5Internal(uint16_t cmd_id) {
922 legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->nanGetCapabilities(ifname_, cmd_id);
923 return createWifiStatusFromLegacyError(legacy_status);
924}
925
926WifiStatus WifiNanIface::enableRequest_1_5Internal(
927 uint16_t /* cmd_id */, const V1_4::NanEnableRequest& /* msg1 */,
928 const V1_5::NanConfigRequestSupplemental& /* msg2 */) {
929 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
930}
931
932WifiStatus WifiNanIface::configRequest_1_5Internal(
933 uint16_t /* cmd_id */, const V1_4::NanConfigRequest& /* msg1 */,
934 const V1_5::NanConfigRequestSupplemental& /* msg2 */) {
935 return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
936}
937
938WifiStatus WifiNanIface::enableRequest_1_6Internal(uint16_t cmd_id,
939 const V1_4::NanEnableRequest& msg1,
940 const V1_6::NanConfigRequestSupplemental& msg2) {
941 legacy_hal::NanEnableRequest legacy_msg;
942 if (!hidl_struct_util::convertHidlNanEnableRequest_1_6ToLegacy(msg1, msg2, &legacy_msg)) {
943 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
944 }
945 legacy_hal::wifi_error legacy_status =
946 legacy_hal_.lock()->nanEnableRequest(ifname_, cmd_id, legacy_msg);
947 return createWifiStatusFromLegacyError(legacy_status);
948}
949
950WifiStatus WifiNanIface::configRequest_1_6Internal(uint16_t cmd_id,
951 const V1_4::NanConfigRequest& msg1,
952 const V1_6::NanConfigRequestSupplemental& msg2) {
953 legacy_hal::NanConfigRequest legacy_msg;
954 if (!hidl_struct_util::convertHidlNanConfigRequest_1_6ToLegacy(msg1, msg2, &legacy_msg)) {
955 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
956 }
957 legacy_hal::wifi_error legacy_status =
958 legacy_hal_.lock()->nanConfigRequest(ifname_, cmd_id, legacy_msg);
959 return createWifiStatusFromLegacyError(legacy_status);
960}
961
962WifiStatus WifiNanIface::initiateDataPathRequest_1_6Internal(
963 uint16_t cmd_id, const V1_6::NanInitiateDataPathRequest& msg) {
964 legacy_hal::NanDataPathInitiatorRequest legacy_msg;
965 if (!hidl_struct_util::convertHidlNanDataPathInitiatorRequest_1_6ToLegacy(msg, &legacy_msg)) {
966 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
967 }
968 legacy_hal::wifi_error legacy_status =
969 legacy_hal_.lock()->nanDataRequestInitiator(ifname_, cmd_id, legacy_msg);
970 return createWifiStatusFromLegacyError(legacy_status);
971}
972
973WifiStatus WifiNanIface::respondToDataPathIndicationRequest_1_6Internal(
974 uint16_t cmd_id, const V1_6::NanRespondToDataPathIndicationRequest& msg) {
975 legacy_hal::NanDataPathIndicationResponse legacy_msg;
976 if (!hidl_struct_util::convertHidlNanDataPathIndicationResponse_1_6ToLegacy(msg, &legacy_msg)) {
977 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
978 }
979 legacy_hal::wifi_error legacy_status =
980 legacy_hal_.lock()->nanDataIndicationResponse(ifname_, cmd_id, legacy_msg);
981 return createWifiStatusFromLegacyError(legacy_status);
982}
983
984WifiStatus WifiNanIface::startPublishRequest_1_6Internal(uint16_t cmd_id,
985 const V1_6::NanPublishRequest& msg) {
986 legacy_hal::NanPublishRequest legacy_msg;
987 if (!hidl_struct_util::convertHidlNanPublishRequestToLegacy(msg, &legacy_msg)) {
988 return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
989 }
990 legacy_hal::wifi_error legacy_status =
991 legacy_hal_.lock()->nanPublishRequest(ifname_, cmd_id, legacy_msg);
992 return createWifiStatusFromLegacyError(legacy_status);
993}
994
995WifiStatus WifiNanIface::registerEventCallback_1_6Internal(
996 const sp<V1_6::IWifiNanIfaceEventCallback>& callback) {
997 sp<V1_0::IWifiNanIfaceEventCallback> callback_1_0 = callback;
998 if (!event_cb_handler_.addCallback(callback_1_0)) {
999 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
1000 }
1001 sp<V1_2::IWifiNanIfaceEventCallback> callback_1_2 = callback;
1002 if (!event_cb_handler_1_2_.addCallback(callback_1_2)) {
1003 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
1004 }
1005 sp<V1_5::IWifiNanIfaceEventCallback> callback_1_5 = callback;
1006 if (!event_cb_handler_1_5_.addCallback(callback_1_5)) {
1007 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
1008 }
1009 if (!event_cb_handler_1_6_.addCallback(callback)) {
1010 return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
1011 }
1012 return createWifiStatus(WifiStatusCode::SUCCESS);
1013}
1014} // namespace implementation
1015} // namespace V1_6
1016} // namespace wifi
1017} // namespace hardware
1018} // namespace android