• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hidl interface for wpa_supplicant daemon
3  * Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2004-2016, Roshan Pius <rpius@google.com>
5  *
6  * This software may be distributed under the terms of the BSD license.
7  * See README for more details.
8  */
9 
10 #include <hwbinder/IPCThreadState.h>
11 
12 #include <hidl/HidlTransportSupport.h>
13 #include "hidl_manager.h"
14 
15 extern "C"
16 {
17 #include "hidl.h"
18 #include "hidl_i.h"
19 #include "utils/common.h"
20 #include "utils/eloop.h"
21 #include "utils/includes.h"
22 }
23 
24 using android::hardware::configureRpcThreadpool;
25 using android::hardware::handleTransportPoll;
26 using android::hardware::setupTransportPolling;
27 using android::hardware::wifi::supplicant::V1_2::implementation::HidlManager;
28 using namespace android::hardware::wifi::supplicant::V1_2;
29 
30 static void wpas_hidl_notify_dpp_failure(struct wpa_supplicant *wpa_s, DppFailureCode code);
31 static void wpas_hidl_notify_dpp_progress(struct wpa_supplicant *wpa_s, DppProgressCode code);
32 
wpas_hidl_sock_handler(int sock,void *,void *)33 void wpas_hidl_sock_handler(
34     int sock, void * /* eloop_ctx */, void * /* sock_ctx */)
35 {
36 	handleTransportPoll(sock);
37 }
38 
wpas_hidl_init(struct wpa_global * global)39 struct wpas_hidl_priv *wpas_hidl_init(struct wpa_global *global)
40 {
41 	struct wpas_hidl_priv *priv;
42 	HidlManager *hidl_manager;
43 
44 	priv = (wpas_hidl_priv *)os_zalloc(sizeof(*priv));
45 	if (!priv)
46 		return NULL;
47 	priv->global = global;
48 
49 	wpa_printf(MSG_DEBUG, "Initing hidl control");
50 
51 	configureRpcThreadpool(1, true /* callerWillJoin */);
52 	priv->hidl_fd = setupTransportPolling();
53 	if (priv->hidl_fd < 0)
54 		goto err;
55 
56 	wpa_printf(MSG_INFO, "Processing hidl events on FD %d", priv->hidl_fd);
57 	// Look for read events from the hidl socket in the eloop.
58 	if (eloop_register_read_sock(
59 		priv->hidl_fd, wpas_hidl_sock_handler, global, priv) < 0)
60 		goto err;
61 
62 	hidl_manager = HidlManager::getInstance();
63 	if (!hidl_manager)
64 		goto err;
65 	hidl_manager->registerHidlService(global);
66 	// We may not need to store this hidl manager reference in the
67 	// global data strucure because we've made it a singleton class.
68 	priv->hidl_manager = (void *)hidl_manager;
69 
70 	return priv;
71 err:
72 	wpas_hidl_deinit(priv);
73 	return NULL;
74 }
75 
wpas_hidl_deinit(struct wpas_hidl_priv * priv)76 void wpas_hidl_deinit(struct wpas_hidl_priv *priv)
77 {
78 	if (!priv)
79 		return;
80 
81 	wpa_printf(MSG_DEBUG, "Deiniting hidl control");
82 
83 	HidlManager::destroyInstance();
84 	eloop_unregister_read_sock(priv->hidl_fd);
85 	os_free(priv);
86 }
87 
wpas_hidl_register_interface(struct wpa_supplicant * wpa_s)88 int wpas_hidl_register_interface(struct wpa_supplicant *wpa_s)
89 {
90 	if (!wpa_s || !wpa_s->global->hidl)
91 		return 1;
92 
93 	wpa_printf(
94 	    MSG_DEBUG, "Registering interface to hidl control: %s",
95 	    wpa_s->ifname);
96 
97 	HidlManager *hidl_manager = HidlManager::getInstance();
98 	if (!hidl_manager)
99 		return 1;
100 
101 	return hidl_manager->registerInterface(wpa_s);
102 }
103 
wpas_hidl_unregister_interface(struct wpa_supplicant * wpa_s)104 int wpas_hidl_unregister_interface(struct wpa_supplicant *wpa_s)
105 {
106 	if (!wpa_s || !wpa_s->global->hidl)
107 		return 1;
108 
109 	wpa_printf(
110 	    MSG_DEBUG, "Deregistering interface from hidl control: %s",
111 	    wpa_s->ifname);
112 
113 	HidlManager *hidl_manager = HidlManager::getInstance();
114 	if (!hidl_manager)
115 		return 1;
116 
117 	return hidl_manager->unregisterInterface(wpa_s);
118 }
119 
wpas_hidl_register_network(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)120 int wpas_hidl_register_network(
121     struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
122 {
123 	if (!wpa_s || !wpa_s->global->hidl || !ssid)
124 		return 1;
125 
126 	wpa_printf(
127 	    MSG_DEBUG, "Registering network to hidl control: %d", ssid->id);
128 
129 	HidlManager *hidl_manager = HidlManager::getInstance();
130 	if (!hidl_manager)
131 		return 1;
132 
133 	return hidl_manager->registerNetwork(wpa_s, ssid);
134 }
135 
wpas_hidl_unregister_network(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)136 int wpas_hidl_unregister_network(
137     struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
138 {
139 	if (!wpa_s || !wpa_s->global->hidl || !ssid)
140 		return 1;
141 
142 	wpa_printf(
143 	    MSG_DEBUG, "Deregistering network from hidl control: %d", ssid->id);
144 
145 	HidlManager *hidl_manager = HidlManager::getInstance();
146 	if (!hidl_manager)
147 		return 1;
148 
149 	return hidl_manager->unregisterNetwork(wpa_s, ssid);
150 }
151 
wpas_hidl_notify_state_changed(struct wpa_supplicant * wpa_s)152 int wpas_hidl_notify_state_changed(struct wpa_supplicant *wpa_s)
153 {
154 	if (!wpa_s || !wpa_s->global->hidl)
155 		return 1;
156 
157 	wpa_printf(
158 	    MSG_DEBUG, "Notifying state change event to hidl control: %d",
159 	    wpa_s->wpa_state);
160 
161 	HidlManager *hidl_manager = HidlManager::getInstance();
162 	if (!hidl_manager)
163 		return 1;
164 
165 	return hidl_manager->notifyStateChange(wpa_s);
166 }
167 
wpas_hidl_notify_network_request(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,enum wpa_ctrl_req_type rtype,const char * default_txt)168 int wpas_hidl_notify_network_request(
169     struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
170     enum wpa_ctrl_req_type rtype, const char *default_txt)
171 {
172 	if (!wpa_s || !wpa_s->global->hidl || !ssid)
173 		return 1;
174 
175 	wpa_printf(
176 	    MSG_DEBUG, "Notifying network request to hidl control: %d",
177 	    ssid->id);
178 
179 	HidlManager *hidl_manager = HidlManager::getInstance();
180 	if (!hidl_manager)
181 		return 1;
182 
183 	return hidl_manager->notifyNetworkRequest(
184 	    wpa_s, ssid, rtype, default_txt);
185 }
186 
wpas_hidl_notify_anqp_query_done(struct wpa_supplicant * wpa_s,const u8 * bssid,const char * result,const struct wpa_bss_anqp * anqp)187 void wpas_hidl_notify_anqp_query_done(
188     struct wpa_supplicant *wpa_s, const u8 *bssid, const char *result,
189     const struct wpa_bss_anqp *anqp)
190 {
191 	if (!wpa_s || !wpa_s->global->hidl || !bssid || !result || !anqp)
192 		return;
193 
194 	wpa_printf(
195 	    MSG_DEBUG,
196 	    "Notifying ANQP query done to hidl control: " MACSTR "result: %s",
197 	    MAC2STR(bssid), result);
198 
199 	HidlManager *hidl_manager = HidlManager::getInstance();
200 	if (!hidl_manager)
201 		return;
202 
203 	hidl_manager->notifyAnqpQueryDone(wpa_s, bssid, result, anqp);
204 }
205 
wpas_hidl_notify_hs20_icon_query_done(struct wpa_supplicant * wpa_s,const u8 * bssid,const char * file_name,const u8 * image,u32 image_length)206 void wpas_hidl_notify_hs20_icon_query_done(
207     struct wpa_supplicant *wpa_s, const u8 *bssid, const char *file_name,
208     const u8 *image, u32 image_length)
209 {
210 	if (!wpa_s || !wpa_s->global->hidl || !bssid || !file_name || !image)
211 		return;
212 
213 	wpa_printf(
214 	    MSG_DEBUG,
215 	    "Notifying HS20 icon query done to hidl control: " MACSTR
216 	    "file_name: %s",
217 	    MAC2STR(bssid), file_name);
218 
219 	HidlManager *hidl_manager = HidlManager::getInstance();
220 	if (!hidl_manager)
221 		return;
222 
223 	hidl_manager->notifyHs20IconQueryDone(
224 	    wpa_s, bssid, file_name, image, image_length);
225 }
226 
wpas_hidl_notify_hs20_rx_subscription_remediation(struct wpa_supplicant * wpa_s,const char * url,u8 osu_method)227 void wpas_hidl_notify_hs20_rx_subscription_remediation(
228     struct wpa_supplicant *wpa_s, const char *url, u8 osu_method)
229 {
230 	if (!wpa_s || !wpa_s->global->hidl || !url)
231 		return;
232 
233 	wpa_printf(
234 	    MSG_DEBUG,
235 	    "Notifying HS20 subscription remediation rx to hidl control: %s",
236 	    url);
237 
238 	HidlManager *hidl_manager = HidlManager::getInstance();
239 	if (!hidl_manager)
240 		return;
241 
242 	hidl_manager->notifyHs20RxSubscriptionRemediation(
243 	    wpa_s, url, osu_method);
244 }
245 
wpas_hidl_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant * wpa_s,u8 code,u16 reauth_delay,const char * url)246 void wpas_hidl_notify_hs20_rx_deauth_imminent_notice(
247     struct wpa_supplicant *wpa_s, u8 code, u16 reauth_delay, const char *url)
248 {
249 	if (!wpa_s || !wpa_s->global->hidl || !url)
250 		return;
251 
252 	wpa_printf(
253 	    MSG_DEBUG,
254 	    "Notifying HS20 deauth imminent notice rx to hidl control: %s",
255 	    url);
256 
257 	HidlManager *hidl_manager = HidlManager::getInstance();
258 	if (!hidl_manager)
259 		return;
260 
261 	hidl_manager->notifyHs20RxDeauthImminentNotice(
262 	    wpa_s, code, reauth_delay, url);
263 }
264 
wpas_hidl_notify_disconnect_reason(struct wpa_supplicant * wpa_s)265 void wpas_hidl_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
266 {
267 	if (!wpa_s)
268 		return;
269 
270 	wpa_printf(
271 	    MSG_DEBUG, "Notifying disconnect reason to hidl control: %d",
272 	    wpa_s->disconnect_reason);
273 
274 	HidlManager *hidl_manager = HidlManager::getInstance();
275 	if (!hidl_manager)
276 		return;
277 
278 	hidl_manager->notifyDisconnectReason(wpa_s);
279 }
280 
wpas_hidl_notify_assoc_reject(struct wpa_supplicant * wpa_s)281 void wpas_hidl_notify_assoc_reject(struct wpa_supplicant *wpa_s)
282 {
283 	if (!wpa_s)
284 		return;
285 
286 	wpa_printf(
287 	    MSG_DEBUG, "Notifying assoc reject to hidl control: %d",
288 	    wpa_s->assoc_status_code);
289 
290 	HidlManager *hidl_manager = HidlManager::getInstance();
291 	if (!hidl_manager)
292 		return;
293 
294 	hidl_manager->notifyAssocReject(wpa_s);
295 }
296 
wpas_hidl_notify_auth_timeout(struct wpa_supplicant * wpa_s)297 void wpas_hidl_notify_auth_timeout(struct wpa_supplicant *wpa_s)
298 {
299 	if (!wpa_s)
300 		return;
301 
302 	wpa_printf(MSG_DEBUG, "Notifying auth timeout to hidl control");
303 
304 	HidlManager *hidl_manager = HidlManager::getInstance();
305 	if (!hidl_manager)
306 		return;
307 
308 	hidl_manager->notifyAuthTimeout(wpa_s);
309 }
310 
wpas_hidl_notify_bssid_changed(struct wpa_supplicant * wpa_s)311 void wpas_hidl_notify_bssid_changed(struct wpa_supplicant *wpa_s)
312 {
313 	if (!wpa_s)
314 		return;
315 
316 	wpa_printf(MSG_DEBUG, "Notifying bssid changed to hidl control");
317 
318 	HidlManager *hidl_manager = HidlManager::getInstance();
319 	if (!hidl_manager)
320 		return;
321 
322 	hidl_manager->notifyBssidChanged(wpa_s);
323 }
324 
wpas_hidl_notify_wps_event_fail(struct wpa_supplicant * wpa_s,uint8_t * peer_macaddr,uint16_t config_error,uint16_t error_indication)325 void wpas_hidl_notify_wps_event_fail(
326     struct wpa_supplicant *wpa_s, uint8_t *peer_macaddr, uint16_t config_error,
327     uint16_t error_indication)
328 {
329 	if (!wpa_s || !peer_macaddr)
330 		return;
331 
332 	wpa_printf(
333 	    MSG_DEBUG, "Notifying Wps event fail to hidl control: %d, %d",
334 	    config_error, error_indication);
335 
336 	HidlManager *hidl_manager = HidlManager::getInstance();
337 	if (!hidl_manager)
338 		return;
339 
340 	hidl_manager->notifyWpsEventFail(
341 	    wpa_s, peer_macaddr, config_error, error_indication);
342 }
343 
wpas_hidl_notify_wps_event_success(struct wpa_supplicant * wpa_s)344 void wpas_hidl_notify_wps_event_success(struct wpa_supplicant *wpa_s)
345 {
346 	if (!wpa_s)
347 		return;
348 
349 	wpa_printf(MSG_DEBUG, "Notifying Wps event success to hidl control");
350 
351 	HidlManager *hidl_manager = HidlManager::getInstance();
352 	if (!hidl_manager)
353 		return;
354 
355 	hidl_manager->notifyWpsEventSuccess(wpa_s);
356 }
357 
wpas_hidl_notify_wps_event_pbc_overlap(struct wpa_supplicant * wpa_s)358 void wpas_hidl_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
359 {
360 	if (!wpa_s)
361 		return;
362 
363 	wpa_printf(
364 	    MSG_DEBUG, "Notifying Wps event PBC overlap to hidl control");
365 
366 	HidlManager *hidl_manager = HidlManager::getInstance();
367 	if (!hidl_manager)
368 		return;
369 
370 	hidl_manager->notifyWpsEventPbcOverlap(wpa_s);
371 }
372 
wpas_hidl_notify_p2p_device_found(struct wpa_supplicant * wpa_s,const u8 * addr,const struct p2p_peer_info * info,const u8 * peer_wfd_device_info,u8 peer_wfd_device_info_len)373 void wpas_hidl_notify_p2p_device_found(
374     struct wpa_supplicant *wpa_s, const u8 *addr,
375     const struct p2p_peer_info *info, const u8 *peer_wfd_device_info,
376     u8 peer_wfd_device_info_len)
377 {
378 	if (!wpa_s || !addr || !info)
379 		return;
380 
381 	wpa_printf(
382 	    MSG_DEBUG, "Notifying P2P device found to hidl control " MACSTR,
383 	    MAC2STR(info->p2p_device_addr));
384 
385 	HidlManager *hidl_manager = HidlManager::getInstance();
386 	if (!hidl_manager)
387 		return;
388 
389 	hidl_manager->notifyP2pDeviceFound(
390 	    wpa_s, addr, info, peer_wfd_device_info, peer_wfd_device_info_len);
391 }
392 
wpas_hidl_notify_p2p_device_lost(struct wpa_supplicant * wpa_s,const u8 * p2p_device_addr)393 void wpas_hidl_notify_p2p_device_lost(
394     struct wpa_supplicant *wpa_s, const u8 *p2p_device_addr)
395 {
396 	if (!wpa_s || !p2p_device_addr)
397 		return;
398 
399 	wpa_printf(
400 	    MSG_DEBUG, "Notifying P2P device lost to hidl control " MACSTR,
401 	    MAC2STR(p2p_device_addr));
402 
403 	HidlManager *hidl_manager = HidlManager::getInstance();
404 	if (!hidl_manager)
405 		return;
406 
407 	hidl_manager->notifyP2pDeviceLost(wpa_s, p2p_device_addr);
408 }
409 
wpas_hidl_notify_p2p_find_stopped(struct wpa_supplicant * wpa_s)410 void wpas_hidl_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
411 {
412 	if (!wpa_s)
413 		return;
414 
415 	wpa_printf(MSG_DEBUG, "Notifying P2P find stop to hidl control");
416 
417 	HidlManager *hidl_manager = HidlManager::getInstance();
418 	if (!hidl_manager)
419 		return;
420 
421 	hidl_manager->notifyP2pFindStopped(wpa_s);
422 }
423 
wpas_hidl_notify_p2p_go_neg_req(struct wpa_supplicant * wpa_s,const u8 * src_addr,u16 dev_passwd_id,u8 go_intent)424 void wpas_hidl_notify_p2p_go_neg_req(
425     struct wpa_supplicant *wpa_s, const u8 *src_addr, u16 dev_passwd_id,
426     u8 go_intent)
427 {
428 	if (!wpa_s || !src_addr)
429 		return;
430 
431 	wpa_printf(
432 	    MSG_DEBUG,
433 	    "Notifying P2P GO negotiation request to hidl control " MACSTR,
434 	    MAC2STR(src_addr));
435 
436 	HidlManager *hidl_manager = HidlManager::getInstance();
437 	if (!hidl_manager)
438 		return;
439 
440 	hidl_manager->notifyP2pGoNegReq(
441 	    wpa_s, src_addr, dev_passwd_id, go_intent);
442 }
443 
wpas_hidl_notify_p2p_go_neg_completed(struct wpa_supplicant * wpa_s,const struct p2p_go_neg_results * res)444 void wpas_hidl_notify_p2p_go_neg_completed(
445     struct wpa_supplicant *wpa_s, const struct p2p_go_neg_results *res)
446 {
447 	if (!wpa_s || !res)
448 		return;
449 
450 	wpa_printf(
451 	    MSG_DEBUG,
452 	    "Notifying P2P GO negotiation completed to hidl control: %d",
453 	    res->status);
454 
455 	HidlManager *hidl_manager = HidlManager::getInstance();
456 	if (!hidl_manager)
457 		return;
458 
459 	hidl_manager->notifyP2pGoNegCompleted(wpa_s, res);
460 }
461 
wpas_hidl_notify_p2p_group_formation_failure(struct wpa_supplicant * wpa_s,const char * reason)462 void wpas_hidl_notify_p2p_group_formation_failure(
463     struct wpa_supplicant *wpa_s, const char *reason)
464 {
465 	if (!wpa_s || !reason)
466 		return;
467 
468 	wpa_printf(
469 	    MSG_DEBUG,
470 	    "Notifying P2P Group formation failure to hidl control: %s",
471 	    reason);
472 
473 	HidlManager *hidl_manager = HidlManager::getInstance();
474 	if (!hidl_manager)
475 		return;
476 
477 	hidl_manager->notifyP2pGroupFormationFailure(wpa_s, reason);
478 }
479 
wpas_hidl_notify_p2p_group_started(struct wpa_supplicant * wpa_s,const struct wpa_ssid * ssid,int persistent,int client)480 void wpas_hidl_notify_p2p_group_started(
481     struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int persistent,
482     int client)
483 {
484 	if (!wpa_s || !ssid)
485 		return;
486 
487 	wpa_printf(
488 	    MSG_DEBUG, "Notifying P2P Group start to hidl control: %d",
489 	    ssid->id);
490 
491 	HidlManager *hidl_manager = HidlManager::getInstance();
492 	if (!hidl_manager)
493 		return;
494 
495 	hidl_manager->notifyP2pGroupStarted(wpa_s, ssid, persistent, client);
496 }
497 
wpas_hidl_notify_p2p_group_removed(struct wpa_supplicant * wpa_s,const struct wpa_ssid * ssid,const char * role)498 void wpas_hidl_notify_p2p_group_removed(
499     struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, const char *role)
500 {
501 	if (!wpa_s || !ssid || !role)
502 		return;
503 
504 	wpa_printf(
505 	    MSG_DEBUG, "Notifying P2P Group removed to hidl control: %d",
506 	    ssid->id);
507 
508 	HidlManager *hidl_manager = HidlManager::getInstance();
509 	if (!hidl_manager)
510 		return;
511 
512 	hidl_manager->notifyP2pGroupRemoved(wpa_s, ssid, role);
513 }
514 
wpas_hidl_notify_p2p_invitation_received(struct wpa_supplicant * wpa_s,const u8 * sa,const u8 * go_dev_addr,const u8 * bssid,int id,int op_freq)515 void wpas_hidl_notify_p2p_invitation_received(
516     struct wpa_supplicant *wpa_s, const u8 *sa, const u8 *go_dev_addr,
517     const u8 *bssid, int id, int op_freq)
518 {
519 	if (!wpa_s || !sa || !go_dev_addr || !bssid)
520 		return;
521 
522 	wpa_printf(
523 	    MSG_DEBUG,
524 	    "Notifying P2P invitation received to hidl control: %d " MACSTR, id,
525 	    MAC2STR(bssid));
526 
527 	HidlManager *hidl_manager = HidlManager::getInstance();
528 	if (!hidl_manager)
529 		return;
530 
531 	hidl_manager->notifyP2pInvitationReceived(
532 	    wpa_s, sa, go_dev_addr, bssid, id, op_freq);
533 }
534 
wpas_hidl_notify_p2p_invitation_result(struct wpa_supplicant * wpa_s,int status,const u8 * bssid)535 void wpas_hidl_notify_p2p_invitation_result(
536     struct wpa_supplicant *wpa_s, int status, const u8 *bssid)
537 {
538 	if (!wpa_s)
539 		return;
540 	if (bssid) {
541 		wpa_printf(
542 		    MSG_DEBUG,
543 		    "Notifying P2P invitation result to hidl control: " MACSTR,
544 		    MAC2STR(bssid));
545 	} else {
546 		wpa_printf(
547 		    MSG_DEBUG,
548 		    "Notifying P2P invitation result to hidl control: NULL "
549 		    "bssid");
550 	}
551 
552 	HidlManager *hidl_manager = HidlManager::getInstance();
553 	if (!hidl_manager)
554 		return;
555 
556 	hidl_manager->notifyP2pInvitationResult(wpa_s, status, bssid);
557 }
558 
wpas_hidl_notify_p2p_provision_discovery(struct wpa_supplicant * wpa_s,const u8 * dev_addr,int request,enum p2p_prov_disc_status status,u16 config_methods,unsigned int generated_pin)559 void wpas_hidl_notify_p2p_provision_discovery(
560     struct wpa_supplicant *wpa_s, const u8 *dev_addr, int request,
561     enum p2p_prov_disc_status status, u16 config_methods,
562     unsigned int generated_pin)
563 {
564 	if (!wpa_s || !dev_addr)
565 		return;
566 
567 	wpa_printf(
568 	    MSG_DEBUG,
569 	    "Notifying P2P provision discovery to hidl control " MACSTR,
570 	    MAC2STR(dev_addr));
571 
572 	HidlManager *hidl_manager = HidlManager::getInstance();
573 	if (!hidl_manager)
574 		return;
575 
576 	hidl_manager->notifyP2pProvisionDiscovery(
577 	    wpa_s, dev_addr, request, status, config_methods, generated_pin);
578 }
579 
wpas_hidl_notify_p2p_sd_response(struct wpa_supplicant * wpa_s,const u8 * sa,u16 update_indic,const u8 * tlvs,size_t tlvs_len)580 void wpas_hidl_notify_p2p_sd_response(
581     struct wpa_supplicant *wpa_s, const u8 *sa, u16 update_indic,
582     const u8 *tlvs, size_t tlvs_len)
583 {
584 	if (!wpa_s || !sa || !tlvs)
585 		return;
586 
587 	wpa_printf(
588 	    MSG_DEBUG,
589 	    "Notifying P2P service discovery response to hidl control " MACSTR,
590 	    MAC2STR(sa));
591 
592 	HidlManager *hidl_manager = HidlManager::getInstance();
593 	if (!hidl_manager)
594 		return;
595 
596 	hidl_manager->notifyP2pSdResponse(
597 	    wpa_s, sa, update_indic, tlvs, tlvs_len);
598 }
599 
wpas_hidl_notify_ap_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr)600 void wpas_hidl_notify_ap_sta_authorized(
601     struct wpa_supplicant *wpa_s, const u8 *sta, const u8 *p2p_dev_addr)
602 {
603 	if (!wpa_s || !sta)
604 		return;
605 
606 	wpa_printf(
607 	    MSG_DEBUG,
608 	    "Notifying P2P AP STA authorized to hidl control " MACSTR,
609 	    MAC2STR(sta));
610 
611 	HidlManager *hidl_manager = HidlManager::getInstance();
612 	if (!hidl_manager)
613 		return;
614 
615 	hidl_manager->notifyApStaAuthorized(wpa_s, sta, p2p_dev_addr);
616 }
617 
wpas_hidl_notify_ap_sta_deauthorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr)618 void wpas_hidl_notify_ap_sta_deauthorized(
619     struct wpa_supplicant *wpa_s, const u8 *sta, const u8 *p2p_dev_addr)
620 {
621 	if (!wpa_s || !sta)
622 		return;
623 
624 	wpa_printf(
625 	    MSG_DEBUG,
626 	    "Notifying P2P AP STA deauthorized to hidl control " MACSTR,
627 	    MAC2STR(sta));
628 
629 	HidlManager *hidl_manager = HidlManager::getInstance();
630 	if (!hidl_manager)
631 		return;
632 
633 	hidl_manager->notifyApStaDeauthorized(wpa_s, sta, p2p_dev_addr);
634 }
635 
wpas_hidl_notify_eap_error(struct wpa_supplicant * wpa_s,int error_code)636 void wpas_hidl_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
637 {
638 	if (!wpa_s)
639 		return;
640 
641 	wpa_printf(MSG_DEBUG, "Notifying EAP Error: %d ", error_code);
642 
643 	HidlManager *hidl_manager = HidlManager::getInstance();
644 	if (!hidl_manager)
645 		return;
646 
647 	hidl_manager->notifyEapError(wpa_s, error_code);
648 }
649 
wpas_hidl_notify_dpp_config_received(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)650 void wpas_hidl_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
651 	    struct wpa_ssid *ssid)
652 {
653 	if (!wpa_s || !ssid)
654 		return;
655 
656 	wpa_printf(
657 	    MSG_DEBUG,
658 	    "Notifying DPP configuration received for SSID %d", ssid->id);
659 
660 	HidlManager *hidl_manager = HidlManager::getInstance();
661 	if (!hidl_manager)
662 		return;
663 
664 	hidl_manager->notifyDppConfigReceived(wpa_s, ssid);
665 }
666 
wpas_hidl_notify_dpp_config_sent(struct wpa_supplicant * wpa_s)667 void wpas_hidl_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
668 {
669 	if (!wpa_s)
670 		return;
671 
672 	wpa_printf(
673 	    MSG_DEBUG,
674 	    "Notifying DPP configuration sent");
675 
676 	HidlManager *hidl_manager = HidlManager::getInstance();
677 	if (!hidl_manager)
678 		return;
679 
680 	hidl_manager->notifyDppConfigSent(wpa_s);
681 }
682 
683 /* DPP Progress notifications */
wpas_hidl_notify_dpp_auth_success(struct wpa_supplicant * wpa_s)684 void wpas_hidl_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
685 {
686 	if (!wpa_s)
687 		return;
688 
689 	wpas_hidl_notify_dpp_progress(wpa_s, DppProgressCode::AUTHENTICATION_SUCCESS);
690 }
691 
wpas_hidl_notify_dpp_resp_pending(struct wpa_supplicant * wpa_s)692 void wpas_hidl_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
693 {
694 	if (!wpa_s)
695 		return;
696 
697 	wpas_hidl_notify_dpp_progress(wpa_s, DppProgressCode::RESPONSE_PENDING);
698 }
699 
700 /* DPP Failure notifications */
wpas_hidl_notify_dpp_not_compatible(struct wpa_supplicant * wpa_s)701 void wpas_hidl_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
702 {
703 	if (!wpa_s)
704 		return;
705 
706 	wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::NOT_COMPATIBLE);
707 }
708 
wpas_hidl_notify_dpp_missing_auth(struct wpa_supplicant * wpa_s)709 void wpas_hidl_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
710 {
711 	if (!wpa_s)
712 		return;
713 }
714 
wpas_hidl_notify_dpp_configuration_failure(struct wpa_supplicant * wpa_s)715 void wpas_hidl_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
716 {
717 	if (!wpa_s)
718 		return;
719 
720 	wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::CONFIGURATION);
721 }
722 
wpas_hidl_notify_dpp_timeout(struct wpa_supplicant * wpa_s)723 void wpas_hidl_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
724 {
725 	if (!wpa_s)
726 		return;
727 
728 	wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::TIMEOUT);
729 }
730 
wpas_hidl_notify_dpp_auth_failure(struct wpa_supplicant * wpa_s)731 void wpas_hidl_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
732 {
733 	if (!wpa_s)
734 		return;
735 
736 	wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::AUTHENTICATION);
737 }
738 
wpas_hidl_notify_dpp_fail(struct wpa_supplicant * wpa_s)739 void wpas_hidl_notify_dpp_fail(struct wpa_supplicant *wpa_s)
740 {
741 	if (!wpa_s)
742 		return;
743 
744 	wpas_hidl_notify_dpp_failure(wpa_s, DppFailureCode::FAILURE);
745 }
746 
747 /* DPP notification helper functions */
wpas_hidl_notify_dpp_failure(struct wpa_supplicant * wpa_s,DppFailureCode code)748 static void wpas_hidl_notify_dpp_failure(struct wpa_supplicant *wpa_s, DppFailureCode code)
749 {
750 	if (!wpa_s)
751 		return;
752 
753 	wpa_printf(
754 	    MSG_DEBUG,
755 	    "Notifying DPP failure event %d", code);
756 
757 	HidlManager *hidl_manager = HidlManager::getInstance();
758 	if (!hidl_manager)
759 		return;
760 
761 	hidl_manager->notifyDppFailure(wpa_s, code);
762 }
763 
wpas_hidl_notify_dpp_progress(struct wpa_supplicant * wpa_s,DppProgressCode code)764 static void wpas_hidl_notify_dpp_progress(struct wpa_supplicant *wpa_s, DppProgressCode code)
765 {
766 	if (!wpa_s)
767 		return;
768 
769 	wpa_printf(
770 	    MSG_DEBUG,
771 	    "Notifying DPP progress event %d", code);
772 
773 	HidlManager *hidl_manager = HidlManager::getInstance();
774 	if (!hidl_manager)
775 		return;
776 
777 	hidl_manager->notifyDppProgress(wpa_s, code);
778 }
779