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