1 /*
2 * wpa_supplicant - Event notifications
3 * Copyright (c) 2009-2010, Jouni Malinen <[email protected]>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9 #include "utils/includes.h"
10
11 #include "utils/common.h"
12 #include "common/wpa_ctrl.h"
13 #include "common/nan_de.h"
14 #include "config.h"
15 #include "wpa_supplicant_i.h"
16 #include "wps_supplicant.h"
17 #include "dbus/dbus_common.h"
18 #include "dbus/dbus_new.h"
19 #include "rsn_supp/wpa.h"
20 #include "rsn_supp/pmksa_cache.h"
21 #include "fst/fst.h"
22 #include "crypto/tls.h"
23 #include "bss.h"
24 #include "driver_i.h"
25 #include "scan.h"
26 #include "p2p_supplicant.h"
27 #include "sme.h"
28 #include "notify.h"
29 #include "aidl/vendor/aidl.h"
30
31 #ifdef MAINLINE_SUPPLICANT
32 #include "aidl/mainline/service.h"
33 #endif
34
wpas_notify_supplicant_initialized(struct wpa_global * global)35 int wpas_notify_supplicant_initialized(struct wpa_global *global)
36 {
37 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
38 if (global->params.dbus_ctrl_interface) {
39 global->dbus = wpas_dbus_init(global);
40 if (global->dbus == NULL)
41 return -1;
42 }
43 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
44
45 #ifdef CONFIG_AIDL
46 // Initialize AIDL here if daemonize is disabled.
47 // Otherwise initialize it later.
48 if (!global->params.daemonize) {
49 global->aidl = wpas_aidl_init(global);
50 if (!global->aidl)
51 return -1;
52 }
53 #endif /* CONFIG_AIDL */
54
55 #ifdef MAINLINE_SUPPLICANT
56 global->aidl = mainline_aidl_init(global);
57 if (!global->aidl)
58 return -1;
59 #endif /* MAINLINE_SUPPLICANT */
60
61 return 0;
62 }
63
64
wpas_notify_supplicant_deinitialized(struct wpa_global * global)65 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
66 {
67 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
68 if (global->dbus)
69 wpas_dbus_deinit(global->dbus);
70 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
71
72 #ifdef CONFIG_AIDL
73 if (global->aidl)
74 wpas_aidl_deinit(global->aidl);
75 #endif /* CONFIG_AIDL */
76
77 #ifdef MAINLINE_SUPPLICANT
78 if (global->aidl)
79 mainline_aidl_deinit(global->aidl);
80 #endif /* MAINLINE_SUPPLICANT */
81
82 }
83
84
wpas_notify_iface_added(struct wpa_supplicant * wpa_s)85 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
86 {
87 if (!wpa_s->p2p_mgmt) {
88 if (wpas_dbus_register_interface(wpa_s))
89 return -1;
90 }
91
92 #ifdef CONFIG_AIDL
93 /*
94 * AIDL initialization may not be complete here if daemonize is enabled.
95 * Initialization is done after daemonizing in order to avoid
96 * issues with the file descriptor.
97 */
98 if (!wpa_s->global->aidl)
99 return 0;
100 /* AIDL interface wants to keep track of the P2P mgmt iface. */
101 if (wpas_aidl_register_interface(wpa_s))
102 return -1;
103 #endif
104
105 return 0;
106 }
107
108
wpas_notify_iface_removed(struct wpa_supplicant * wpa_s)109 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
110 {
111 if (!wpa_s->p2p_mgmt) {
112 /* unregister interface in new DBus ctrl iface */
113 wpas_dbus_unregister_interface(wpa_s);
114 }
115
116 /* AIDL interface wants to keep track of the P2P mgmt iface. */
117 wpas_aidl_unregister_interface(wpa_s);
118 }
119
120
wpas_notify_state_changed(struct wpa_supplicant * wpa_s,enum wpa_states new_state,enum wpa_states old_state)121 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
122 enum wpa_states new_state,
123 enum wpa_states old_state)
124 {
125 if (wpa_s->p2p_mgmt)
126 return;
127
128 /* notify the new DBus API */
129 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
130
131 #ifdef CONFIG_FST
132 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
133 if (new_state == WPA_COMPLETED)
134 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
135 else if (old_state >= WPA_ASSOCIATED &&
136 new_state < WPA_ASSOCIATED)
137 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
138 }
139 #endif /* CONFIG_FST */
140
141 if (new_state == WPA_COMPLETED)
142 wpas_p2p_notif_connected(wpa_s);
143 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
144 wpas_p2p_notif_disconnected(wpa_s);
145
146 sme_state_changed(wpa_s);
147
148 #ifdef ANDROID
149 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
150 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
151 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
152 new_state,
153 MAC2STR(wpa_s->bssid),
154 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
155 wpa_ssid_txt(wpa_s->current_ssid->ssid,
156 wpa_s->current_ssid->ssid_len) : "");
157 #endif /* ANDROID */
158
159 wpas_aidl_notify_state_changed(wpa_s);
160 }
161
162
wpas_notify_disconnect_reason(struct wpa_supplicant * wpa_s)163 void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
164 {
165 if (wpa_s->p2p_mgmt)
166 return;
167
168 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
169
170 wpas_aidl_notify_disconnect_reason(wpa_s);
171 }
172
173
wpas_notify_mlo_info_change_reason(struct wpa_supplicant * wpa_s,enum mlo_info_change_reason reason)174 void wpas_notify_mlo_info_change_reason(struct wpa_supplicant *wpa_s,
175 enum mlo_info_change_reason reason)
176 {
177 if (wpa_s->p2p_mgmt)
178 return;
179
180 wpas_aidl_notify_mlo_info_change_reason(wpa_s, reason);
181 }
182
183
wpas_notify_auth_status_code(struct wpa_supplicant * wpa_s)184 void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
185 {
186 if (wpa_s->p2p_mgmt)
187 return;
188
189 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
190 }
191
192
wpas_notify_assoc_status_code(struct wpa_supplicant * wpa_s,const u8 * bssid,u8 timed_out,const u8 * assoc_resp_ie,size_t assoc_resp_ie_len)193 void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s,
194 const u8 *bssid, u8 timed_out,
195 const u8 *assoc_resp_ie, size_t assoc_resp_ie_len)
196 {
197 if (wpa_s->p2p_mgmt)
198 return;
199
200 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
201
202 wpas_aidl_notify_assoc_reject(wpa_s, bssid, timed_out, assoc_resp_ie, assoc_resp_ie_len);
203 }
204
wpas_notify_auth_timeout(struct wpa_supplicant * wpa_s)205 void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
206 if (wpa_s->p2p_mgmt)
207 return;
208
209 wpas_aidl_notify_auth_timeout(wpa_s);
210 }
211
wpas_notify_roam_time(struct wpa_supplicant * wpa_s)212 void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
213 {
214 if (wpa_s->p2p_mgmt)
215 return;
216
217 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
218 }
219
220
wpas_notify_roam_complete(struct wpa_supplicant * wpa_s)221 void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
222 {
223 if (wpa_s->p2p_mgmt)
224 return;
225
226 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
227 }
228
229
wpas_notify_scan_in_progress_6ghz(struct wpa_supplicant * wpa_s)230 void wpas_notify_scan_in_progress_6ghz(struct wpa_supplicant *wpa_s)
231 {
232 if (wpa_s->p2p_mgmt)
233 return;
234
235 wpas_dbus_signal_prop_changed(wpa_s,
236 WPAS_DBUS_PROP_SCAN_IN_PROGRESS_6GHZ);
237 }
238
239
wpas_notify_session_length(struct wpa_supplicant * wpa_s)240 void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
241 {
242 if (wpa_s->p2p_mgmt)
243 return;
244
245 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
246 }
247
248
wpas_notify_bss_tm_status(struct wpa_supplicant * wpa_s)249 void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
250 {
251 if (wpa_s->p2p_mgmt)
252 return;
253
254 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
255
256 #ifdef CONFIG_WNM
257 wpas_aidl_notify_bss_tm_status(wpa_s);
258 #endif
259 }
260
261
wpas_notify_network_changed(struct wpa_supplicant * wpa_s)262 void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
263 {
264 if (wpa_s->p2p_mgmt)
265 return;
266
267 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
268 }
269
270
wpas_notify_ap_scan_changed(struct wpa_supplicant * wpa_s)271 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
272 {
273 if (wpa_s->p2p_mgmt)
274 return;
275
276 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
277 }
278
279
wpas_notify_bssid_changed(struct wpa_supplicant * wpa_s)280 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
281 {
282 if (wpa_s->p2p_mgmt)
283 return;
284
285 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
286
287 wpas_aidl_notify_bssid_changed(wpa_s);
288 }
289
290
wpas_notify_mac_address_changed(struct wpa_supplicant * wpa_s)291 void wpas_notify_mac_address_changed(struct wpa_supplicant *wpa_s)
292 {
293 if (wpa_s->p2p_mgmt)
294 return;
295
296 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_MAC_ADDRESS);
297 }
298
299
wpas_notify_auth_changed(struct wpa_supplicant * wpa_s)300 void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
301 {
302 if (wpa_s->p2p_mgmt)
303 return;
304
305 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
306 }
307
308
wpas_notify_network_enabled_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)309 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
310 struct wpa_ssid *ssid)
311 {
312 if (wpa_s->p2p_mgmt)
313 return;
314
315 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
316 }
317
318
wpas_notify_network_selected(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)319 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
320 struct wpa_ssid *ssid)
321 {
322 if (wpa_s->p2p_mgmt)
323 return;
324
325 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
326 }
327
328
wpas_notify_network_request(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,enum wpa_ctrl_req_type rtype,const char * default_txt)329 void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
330 struct wpa_ssid *ssid,
331 enum wpa_ctrl_req_type rtype,
332 const char *default_txt)
333 {
334 if (wpa_s->p2p_mgmt)
335 return;
336
337 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
338
339 wpas_aidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
340 }
341
342
wpas_notify_permanent_id_req_denied(struct wpa_supplicant * wpa_s)343 void wpas_notify_permanent_id_req_denied(struct wpa_supplicant *wpa_s)
344 {
345 wpas_aidl_notify_permanent_id_req_denied(wpa_s);
346 }
347
348
wpas_notify_scanning(struct wpa_supplicant * wpa_s)349 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
350 {
351 if (wpa_s->p2p_mgmt)
352 return;
353
354 /* notify the new DBus API */
355 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
356 }
357
358
wpas_notify_scan_done(struct wpa_supplicant * wpa_s,int success)359 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
360 {
361 if (wpa_s->p2p_mgmt)
362 return;
363
364 wpas_dbus_signal_scan_done(wpa_s, success);
365 }
366
367
wpas_notify_scan_results(struct wpa_supplicant * wpa_s)368 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
369 {
370 if (wpa_s->p2p_mgmt)
371 return;
372
373 wpas_wps_notify_scan_results(wpa_s);
374 }
375
376
wpas_notify_wps_credential(struct wpa_supplicant * wpa_s,const struct wps_credential * cred)377 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
378 const struct wps_credential *cred)
379 {
380 if (wpa_s->p2p_mgmt)
381 return;
382
383 #ifdef CONFIG_WPS
384 /* notify the new DBus API */
385 wpas_dbus_signal_wps_cred(wpa_s, cred);
386 #endif /* CONFIG_WPS */
387 }
388
389
wpas_notify_wps_event_m2d(struct wpa_supplicant * wpa_s,struct wps_event_m2d * m2d)390 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
391 struct wps_event_m2d *m2d)
392 {
393 if (wpa_s->p2p_mgmt)
394 return;
395
396 #ifdef CONFIG_WPS
397 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
398 #endif /* CONFIG_WPS */
399 }
400
401
wpas_notify_wps_event_fail(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)402 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
403 struct wps_event_fail *fail)
404 {
405 if (wpa_s->p2p_mgmt)
406 return;
407
408 #ifdef CONFIG_WPS
409 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
410
411 wpas_aidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
412 fail->config_error,
413 fail->error_indication);
414 #endif /* CONFIG_WPS */
415 }
416
417
wpas_notify_wps_event_success(struct wpa_supplicant * wpa_s)418 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
419 {
420 if (wpa_s->p2p_mgmt)
421 return;
422
423 #ifdef CONFIG_WPS
424 wpas_dbus_signal_wps_event_success(wpa_s);
425
426 wpas_aidl_notify_wps_event_success(wpa_s);
427 #endif /* CONFIG_WPS */
428 }
429
wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant * wpa_s)430 void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
431 {
432 if (wpa_s->p2p_mgmt)
433 return;
434
435 #ifdef CONFIG_WPS
436 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
437
438 wpas_aidl_notify_wps_event_pbc_overlap(wpa_s);
439 #endif /* CONFIG_WPS */
440 }
441
442
wpas_notify_network_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)443 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
444 struct wpa_ssid *ssid)
445 {
446 if (wpa_s->p2p_mgmt)
447 return;
448
449 /*
450 * Networks objects created during any P2P activities should not be
451 * exposed out. They might/will confuse certain non-P2P aware
452 * applications since these network objects won't behave like
453 * regular ones.
454 */
455 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
456 wpas_dbus_register_network(wpa_s, ssid);
457 wpas_aidl_register_network(wpa_s, ssid);
458 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_ADDED "%d",
459 ssid->id);
460 }
461 }
462
463
wpas_notify_persistent_group_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)464 void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
465 struct wpa_ssid *ssid)
466 {
467 #ifdef CONFIG_P2P
468 wpas_dbus_register_persistent_group(wpa_s, ssid);
469 wpas_aidl_register_network(wpa_s, ssid);
470 #endif /* CONFIG_P2P */
471 }
472
473
wpas_notify_persistent_group_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)474 void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
475 struct wpa_ssid *ssid)
476 {
477 #ifdef CONFIG_P2P
478 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
479 wpas_aidl_unregister_network(wpa_s, ssid);
480 #endif /* CONFIG_P2P */
481 }
482
483
wpas_notify_network_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)484 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
485 struct wpa_ssid *ssid)
486 {
487 if (wpa_s->next_ssid == ssid)
488 wpa_s->next_ssid = NULL;
489 if (wpa_s->last_ssid == ssid)
490 wpa_s->last_ssid = NULL;
491 if (wpa_s->current_ssid == ssid)
492 wpa_s->current_ssid = NULL;
493 if (wpa_s->ml_connect_probe_ssid == ssid) {
494 wpa_s->ml_connect_probe_ssid = NULL;
495 wpa_s->ml_connect_probe_bss = NULL;
496 }
497 if (wpa_s->connect_without_scan == ssid)
498 wpa_s->connect_without_scan = NULL;
499 #if defined(CONFIG_SME) && defined(CONFIG_SAE)
500 if (wpa_s->sme.ext_auth_wpa_ssid == ssid)
501 wpa_s->sme.ext_auth_wpa_ssid = NULL;
502 #endif /* CONFIG_SME && CONFIG_SAE */
503 if (wpa_s->wpa) {
504 if ((wpa_key_mgmt_sae(ssid->key_mgmt) &&
505 (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SAE_OFFLOAD_STA)) ||
506 ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) &&
507 (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA))) {
508 /* For cases when PMK is generated at the driver */
509 struct wpa_pmkid_params params;
510
511 os_memset(¶ms, 0, sizeof(params));
512 params.ssid = ssid->ssid;
513 params.ssid_len = ssid->ssid_len;
514 wpa_drv_remove_pmkid(wpa_s, ¶ms);
515 }
516 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
517 }
518 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
519 !wpa_s->p2p_mgmt) {
520 wpas_dbus_unregister_network(wpa_s, ssid->id);
521 wpas_aidl_unregister_network(wpa_s, ssid);
522 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_REMOVED "%d",
523 ssid->id);
524 }
525 if (network_is_persistent_group(ssid))
526 wpas_notify_persistent_group_removed(wpa_s, ssid);
527
528 wpas_p2p_network_removed(wpa_s, ssid);
529 }
530
531
wpas_notify_bss_added(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)532 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
533 u8 bssid[], unsigned int id)
534 {
535 if (wpa_s->p2p_mgmt)
536 return;
537
538 wpas_dbus_register_bss(wpa_s, bssid, id);
539 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
540 id, MAC2STR(bssid));
541 }
542
543
wpas_notify_bss_removed(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)544 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
545 u8 bssid[], unsigned int id)
546 {
547 if (wpa_s->p2p_mgmt)
548 return;
549
550 wpas_dbus_unregister_bss(wpa_s, bssid, id);
551 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
552 id, MAC2STR(bssid));
553 }
554
555
wpas_notify_bss_freq_changed(struct wpa_supplicant * wpa_s,unsigned int id)556 void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
557 unsigned int id)
558 {
559 if (wpa_s->p2p_mgmt)
560 return;
561
562 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
563 }
564
565
wpas_notify_bss_signal_changed(struct wpa_supplicant * wpa_s,unsigned int id)566 void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
567 unsigned int id)
568 {
569 if (wpa_s->p2p_mgmt)
570 return;
571
572 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
573 id);
574 }
575
576
wpas_notify_bss_privacy_changed(struct wpa_supplicant * wpa_s,unsigned int id)577 void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
578 unsigned int id)
579 {
580 if (wpa_s->p2p_mgmt)
581 return;
582
583 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
584 id);
585 }
586
587
wpas_notify_bss_mode_changed(struct wpa_supplicant * wpa_s,unsigned int id)588 void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
589 unsigned int id)
590 {
591 if (wpa_s->p2p_mgmt)
592 return;
593
594 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
595 }
596
597
wpas_notify_bss_wpaie_changed(struct wpa_supplicant * wpa_s,unsigned int id)598 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
599 unsigned int id)
600 {
601 if (wpa_s->p2p_mgmt)
602 return;
603
604 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
605 }
606
607
wpas_notify_bss_rsnie_changed(struct wpa_supplicant * wpa_s,unsigned int id)608 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
609 unsigned int id)
610 {
611 if (wpa_s->p2p_mgmt)
612 return;
613
614 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
615 }
616
617
wpas_notify_bss_wps_changed(struct wpa_supplicant * wpa_s,unsigned int id)618 void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
619 unsigned int id)
620 {
621 if (wpa_s->p2p_mgmt)
622 return;
623
624 #ifdef CONFIG_WPS
625 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
626 #endif /* CONFIG_WPS */
627 }
628
629
wpas_notify_bss_ies_changed(struct wpa_supplicant * wpa_s,unsigned int id)630 void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
631 unsigned int id)
632 {
633 if (wpa_s->p2p_mgmt)
634 return;
635
636 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
637 }
638
639
wpas_notify_bss_rates_changed(struct wpa_supplicant * wpa_s,unsigned int id)640 void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
641 unsigned int id)
642 {
643 if (wpa_s->p2p_mgmt)
644 return;
645
646 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
647 }
648
649
wpas_notify_bss_seen(struct wpa_supplicant * wpa_s,unsigned int id)650 void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
651 {
652 if (wpa_s->p2p_mgmt)
653 return;
654
655 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
656 }
657
658
wpas_notify_bss_anqp_changed(struct wpa_supplicant * wpa_s,unsigned int id)659 void wpas_notify_bss_anqp_changed(struct wpa_supplicant *wpa_s, unsigned int id)
660 {
661 if (wpa_s->p2p_mgmt)
662 return;
663
664 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_ANQP, id);
665 }
666
667
wpas_notify_blob_added(struct wpa_supplicant * wpa_s,const char * name)668 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
669 {
670 if (wpa_s->p2p_mgmt)
671 return;
672
673 wpas_dbus_signal_blob_added(wpa_s, name);
674 }
675
676
wpas_notify_blob_removed(struct wpa_supplicant * wpa_s,const char * name)677 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
678 {
679 if (wpa_s->p2p_mgmt)
680 return;
681
682 wpas_dbus_signal_blob_removed(wpa_s, name);
683 }
684
685
wpas_notify_debug_level_changed(struct wpa_global * global)686 void wpas_notify_debug_level_changed(struct wpa_global *global)
687 {
688 wpas_dbus_signal_debug_level_changed(global);
689 }
690
691
wpas_notify_debug_timestamp_changed(struct wpa_global * global)692 void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
693 {
694 wpas_dbus_signal_debug_timestamp_changed(global);
695 }
696
697
wpas_notify_debug_show_keys_changed(struct wpa_global * global)698 void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
699 {
700 wpas_dbus_signal_debug_show_keys_changed(global);
701 }
702
703
wpas_notify_suspend(struct wpa_global * global)704 void wpas_notify_suspend(struct wpa_global *global)
705 {
706 struct wpa_supplicant *wpa_s;
707
708 os_get_time(&global->suspend_time);
709 wpa_printf(MSG_DEBUG, "System suspend notification");
710 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
711 wpa_drv_suspend(wpa_s);
712 }
713
714
wpas_notify_resume(struct wpa_global * global)715 void wpas_notify_resume(struct wpa_global *global)
716 {
717 struct os_time now;
718 int slept;
719 struct wpa_supplicant *wpa_s;
720
721 if (global->suspend_time.sec == 0)
722 slept = -1;
723 else {
724 os_get_time(&now);
725 slept = now.sec - global->suspend_time.sec;
726 }
727 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
728 slept);
729
730 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
731 wpa_drv_resume(wpa_s);
732 if (wpa_s->wpa_state == WPA_DISCONNECTED)
733 wpa_supplicant_req_scan(wpa_s, 0, 100000);
734 }
735 }
736
737
738 #ifdef CONFIG_P2P
739
wpas_notify_p2p_find_stopped(struct wpa_supplicant * wpa_s)740 void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
741 {
742 /* Notify P2P find has stopped */
743 wpas_dbus_signal_p2p_find_stopped(wpa_s);
744
745 wpas_aidl_notify_p2p_find_stopped(wpa_s);
746 }
747
748
wpas_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,const u8 * peer_wfd_r2_device_info,u8 peer_wfd_r2_device_info_len,int new_device)749 void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
750 const u8 *addr, const struct p2p_peer_info *info,
751 const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
752 const u8* peer_wfd_r2_device_info, u8 peer_wfd_r2_device_info_len,
753 int new_device)
754 {
755 if (new_device) {
756 /* Create the new peer object */
757 wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
758 }
759
760 /* Notify a new peer has been detected*/
761 wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
762
763 wpas_aidl_notify_p2p_device_found(wpa_s, addr, info,
764 peer_wfd_device_info,
765 peer_wfd_device_info_len,
766 peer_wfd_r2_device_info,
767 peer_wfd_r2_device_info_len);
768 }
769
770
wpas_notify_p2p_device_lost(struct wpa_supplicant * wpa_s,const u8 * dev_addr)771 void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
772 const u8 *dev_addr)
773 {
774 wpas_dbus_unregister_peer(wpa_s, dev_addr);
775
776 /* Create signal on interface object*/
777 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
778
779 wpas_aidl_notify_p2p_device_lost(wpa_s, dev_addr);
780 }
781
782
wpas_notify_p2p_group_removed(struct wpa_supplicant * wpa_s,const struct wpa_ssid * ssid,const char * role)783 void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
784 const struct wpa_ssid *ssid,
785 const char *role)
786 {
787 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
788
789 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
790
791 wpas_aidl_notify_p2p_group_removed(wpa_s, ssid, role);
792 }
793
794
wpas_notify_p2p_go_neg_req(struct wpa_supplicant * wpa_s,const u8 * src,u16 dev_passwd_id,u8 go_intent)795 void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
796 const u8 *src, u16 dev_passwd_id, u8 go_intent)
797 {
798 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
799
800 wpas_aidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
801 }
802
803
wpas_notify_p2p_go_neg_completed(struct wpa_supplicant * wpa_s,struct p2p_go_neg_results * res)804 void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
805 struct p2p_go_neg_results *res)
806 {
807 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
808
809 wpas_aidl_notify_p2p_go_neg_completed(wpa_s, res);
810 }
811
812
wpas_notify_p2p_invitation_result(struct wpa_supplicant * wpa_s,int status,const u8 * bssid)813 void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
814 int status, const u8 *bssid)
815 {
816 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
817
818 wpas_aidl_notify_p2p_invitation_result(wpa_s, status, bssid);
819 }
820
821
wpas_notify_p2p_sd_request(struct wpa_supplicant * wpa_s,int freq,const u8 * sa,u8 dialog_token,u16 update_indic,const u8 * tlvs,size_t tlvs_len)822 void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
823 int freq, const u8 *sa, u8 dialog_token,
824 u16 update_indic, const u8 *tlvs,
825 size_t tlvs_len)
826 {
827 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
828 update_indic, tlvs, tlvs_len);
829 }
830
831
wpas_notify_p2p_sd_response(struct wpa_supplicant * wpa_s,const u8 * sa,u16 update_indic,const u8 * tlvs,size_t tlvs_len)832 void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
833 const u8 *sa, u16 update_indic,
834 const u8 *tlvs, size_t tlvs_len)
835 {
836 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
837 tlvs, tlvs_len);
838
839 wpas_aidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
840 tlvs, tlvs_len);
841 }
842
843
844 /**
845 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
846 * @dev_addr: Who sent the request or responded to our request.
847 * @request: Will be 1 if request, 0 for response.
848 * @status: Valid only in case of response (0 in case of success)
849 * @config_methods: WPS config methods
850 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
851 * @group_ifname: Group interface name of the group owner in case the provision
852 * discovery request is received with P2P Group ID attribute.
853 * i.e., valid only when the peer device is joining an
854 * operating P2P group.
855 *
856 * This can be used to notify:
857 * - Requests or responses
858 * - Various config methods
859 * - Failure condition in case of response
860 */
wpas_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,const char * group_ifname)861 void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
862 const u8 *dev_addr, int request,
863 enum p2p_prov_disc_status status,
864 u16 config_methods,
865 unsigned int generated_pin,
866 const char *group_ifname)
867 {
868 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
869 status, config_methods,
870 generated_pin);
871
872 wpas_aidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
873 status, config_methods,
874 generated_pin, group_ifname);
875
876 }
877
878
wpas_notify_p2p_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,int persistent,int client,const u8 * ip)879 void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
880 struct wpa_ssid *ssid, int persistent,
881 int client, const u8 *ip)
882 {
883 /* Notify a group has been started */
884 wpas_dbus_register_p2p_group(wpa_s, ssid);
885
886 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
887
888 wpas_aidl_notify_p2p_group_started(wpa_s, ssid, persistent, client, ip);
889 }
890
891
wpas_notify_p2p_group_formation_failure(struct wpa_supplicant * wpa_s,const char * reason)892 void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
893 const char *reason)
894 {
895 /* Notify a group formation failed */
896 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
897
898 wpas_aidl_notify_p2p_group_formation_failure(wpa_s, reason);
899 }
900
901
wpas_notify_p2p_wps_failed(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)902 void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
903 struct wps_event_fail *fail)
904 {
905 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
906 }
907
908
wpas_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)909 void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
910 const u8 *sa, const u8 *go_dev_addr,
911 const u8 *bssid, int id, int op_freq)
912 {
913 /* Notify a P2P Invitation Request */
914 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
915 id, op_freq);
916
917 wpas_aidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
918 id, op_freq);
919 }
920
921 #endif /* CONFIG_P2P */
922
923
wpas_notify_ap_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr,const u8 * ip)924 static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
925 const u8 *sta,
926 const u8 *p2p_dev_addr, const u8 *ip)
927 {
928 #ifdef CONFIG_P2P
929 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
930
931 /*
932 * Create 'peer-joined' signal on group object -- will also
933 * check P2P itself.
934 */
935 if (p2p_dev_addr)
936 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
937 #endif /* CONFIG_P2P */
938
939 /* Register the station */
940 wpas_dbus_register_sta(wpa_s, sta);
941
942 /* Notify listeners a new station has been authorized */
943 wpas_dbus_signal_sta_authorized(wpa_s, sta);
944
945 wpas_aidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr, ip);
946 }
947
948
wpas_notify_ap_sta_deauthorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr)949 static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
950 const u8 *sta,
951 const u8 *p2p_dev_addr)
952 {
953 #ifdef CONFIG_P2P
954 /*
955 * Create 'peer-disconnected' signal on group object if this
956 * is a P2P group.
957 */
958 if (p2p_dev_addr)
959 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
960 #endif /* CONFIG_P2P */
961
962 /* Notify listeners a station has been deauthorized */
963 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
964
965 wpas_aidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
966 /* Unregister the station */
967 wpas_dbus_unregister_sta(wpa_s, sta);
968 }
969
970
wpas_notify_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * mac_addr,int authorized,const u8 * p2p_dev_addr,const u8 * ip)971 void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
972 const u8 *mac_addr, int authorized,
973 const u8 *p2p_dev_addr, const u8 *ip)
974 {
975 if (authorized)
976 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr,
977 ip);
978 else
979 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
980 }
981
982
wpas_notify_certification(struct wpa_supplicant * wpa_s,struct tls_cert_data * cert,const char * cert_hash)983 void wpas_notify_certification(struct wpa_supplicant *wpa_s,
984 struct tls_cert_data *cert,
985 const char *cert_hash)
986 {
987 int i;
988
989 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
990 "depth=%d subject='%s'%s%s%s%s",
991 cert->depth, cert->subject, cert_hash ? " hash=" : "",
992 cert_hash ? cert_hash : "",
993 cert->tod == 2 ? " tod=2" : "",
994 cert->tod == 1 ? " tod=1" : "");
995
996 if (cert->cert) {
997 char *cert_hex;
998 size_t len = wpabuf_len(cert->cert) * 2 + 1;
999 cert_hex = os_malloc(len);
1000 if (cert_hex) {
1001 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
1002 wpabuf_len(cert->cert));
1003 wpa_msg_ctrl(wpa_s, MSG_INFO,
1004 WPA_EVENT_EAP_PEER_CERT
1005 "depth=%d subject='%s' cert=%s",
1006 cert->depth, cert->subject, cert_hex);
1007 os_free(cert_hex);
1008 }
1009 }
1010
1011 for (i = 0; i < cert->num_altsubject; i++)
1012 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
1013 "depth=%d %s", cert->depth, cert->altsubject[i]);
1014
1015 wpas_aidl_notify_ceritification(wpa_s, cert->depth, cert->subject,
1016 cert->altsubject, cert->num_altsubject,
1017 cert_hash, cert->cert);
1018
1019 /* notify the new DBus API */
1020 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
1021 cert->altsubject, cert->num_altsubject,
1022 cert_hash, cert->cert);
1023 }
1024
1025
wpas_notify_preq(struct wpa_supplicant * wpa_s,const u8 * addr,const u8 * dst,const u8 * bssid,const u8 * ie,size_t ie_len,u32 ssi_signal)1026 void wpas_notify_preq(struct wpa_supplicant *wpa_s,
1027 const u8 *addr, const u8 *dst, const u8 *bssid,
1028 const u8 *ie, size_t ie_len, u32 ssi_signal)
1029 {
1030 #ifdef CONFIG_AP
1031 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
1032 #endif /* CONFIG_AP */
1033 }
1034
1035
wpas_notify_eap_status(struct wpa_supplicant * wpa_s,const char * status,const char * parameter)1036 void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
1037 const char *parameter)
1038 {
1039 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
1040 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
1041 "status='%s' parameter='%s'",
1042 status, parameter);
1043 }
1044
1045
wpas_notify_eap_error(struct wpa_supplicant * wpa_s,int error_code)1046 void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
1047 {
1048 wpa_dbg(wpa_s, MSG_ERROR,
1049 "EAP Error code = %d", error_code);
1050 wpas_aidl_notify_eap_error(wpa_s, error_code);
1051 }
1052
1053
wpas_notify_psk_mismatch(struct wpa_supplicant * wpa_s)1054 void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s)
1055 {
1056 wpas_dbus_signal_psk_mismatch(wpa_s);
1057 }
1058
1059
wpas_notify_network_bssid_set_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)1060 void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
1061 struct wpa_ssid *ssid)
1062 {
1063 if (wpa_s->current_ssid != ssid)
1064 return;
1065
1066 wpa_dbg(wpa_s, MSG_DEBUG,
1067 "Network bssid config changed for the current network - within-ESS roaming %s",
1068 ssid->bssid_set ? "disabled" : "enabled");
1069
1070 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
1071 ssid->bssid_set ? ssid->bssid : NULL);
1072 }
1073
1074
wpas_notify_network_type_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)1075 void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
1076 struct wpa_ssid *ssid)
1077 {
1078 #ifdef CONFIG_P2P
1079 if (ssid->disabled == 2) {
1080 /* Changed from normal network profile to persistent group */
1081 ssid->disabled = 0;
1082 wpas_dbus_unregister_network(wpa_s, ssid->id);
1083 ssid->disabled = 2;
1084 ssid->p2p_persistent_group = 1;
1085 wpas_dbus_register_persistent_group(wpa_s, ssid);
1086 } else {
1087 /* Changed from persistent group to normal network profile */
1088 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
1089 ssid->p2p_persistent_group = 0;
1090 wpas_dbus_register_network(wpa_s, ssid);
1091 }
1092 #endif /* CONFIG_P2P */
1093 }
1094
wpas_notify_anqp_query_done(struct wpa_supplicant * wpa_s,const u8 * bssid,const char * result,const struct wpa_bss_anqp * anqp)1095 void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1096 const char *result,
1097 const struct wpa_bss_anqp *anqp)
1098 {
1099 wpa_msg(wpa_s, MSG_INFO, ANQP_QUERY_DONE "addr=" MACSTR " result=%s",
1100 MAC2STR(bssid), result);
1101 #ifdef CONFIG_INTERWORKING
1102 if (!wpa_s || !bssid || !anqp)
1103 return;
1104
1105 wpas_aidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
1106 wpas_dbus_signal_anqp_query_done(wpa_s, bssid, result);
1107 #endif /* CONFIG_INTERWORKING */
1108 }
1109
wpas_notify_hs20_icon_query_done(struct wpa_supplicant * wpa_s,const u8 * bssid,const char * file_name,const u8 * image,u32 image_length)1110 void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1111 const char* file_name, const u8* image,
1112 u32 image_length)
1113 {
1114 #ifdef CONFIG_HS20
1115 if (!wpa_s || !bssid || !file_name || !image)
1116 return;
1117
1118 wpas_aidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
1119 image_length);
1120 #endif /* CONFIG_HS20 */
1121 }
1122
wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant * wpa_s,const char * url,u8 osu_method)1123 void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
1124 const char* url,
1125 u8 osu_method)
1126 {
1127 #ifdef CONFIG_HS20
1128 if (!wpa_s || !url)
1129 return;
1130
1131 wpas_aidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
1132 #endif /* CONFIG_HS20 */
1133 }
1134
wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant * wpa_s,u8 code,u16 reauth_delay,const char * url)1135 void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1136 u8 code, u16 reauth_delay,
1137 const char *url)
1138 {
1139 #ifdef CONFIG_HS20
1140 if (!wpa_s)
1141 return;
1142
1143 wpas_aidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
1144 url);
1145 #endif /* CONFIG_HS20 */
1146 }
1147
1148
1149 #ifdef CONFIG_MESH
1150
wpas_notify_mesh_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)1151 void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1152 struct wpa_ssid *ssid)
1153 {
1154 if (wpa_s->p2p_mgmt)
1155 return;
1156
1157 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1158 }
1159
1160
wpas_notify_mesh_group_removed(struct wpa_supplicant * wpa_s,const u8 * meshid,u8 meshid_len,u16 reason_code)1161 void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1162 const u8 *meshid, u8 meshid_len,
1163 u16 reason_code)
1164 {
1165 if (wpa_s->p2p_mgmt)
1166 return;
1167
1168 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1169 reason_code);
1170 }
1171
1172
wpas_notify_mesh_peer_connected(struct wpa_supplicant * wpa_s,const u8 * peer_addr)1173 void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1174 const u8 *peer_addr)
1175 {
1176 if (wpa_s->p2p_mgmt)
1177 return;
1178
1179 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR,
1180 MAC2STR(peer_addr));
1181 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1182 }
1183
1184
wpas_notify_mesh_peer_disconnected(struct wpa_supplicant * wpa_s,const u8 * peer_addr,u16 reason_code)1185 void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
1186 const u8 *peer_addr, u16 reason_code)
1187 {
1188 if (wpa_s->p2p_mgmt)
1189 return;
1190
1191 wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
1192 MAC2STR(peer_addr));
1193 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1194 }
1195
1196 #endif /* CONFIG_MESH */
1197
1198 /*
1199 * DPP Notifications
1200 */
1201
1202 /* DPP Success notifications */
1203
wpas_notify_dpp_config_received(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,bool conn_status_requested)1204 void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
1205 struct wpa_ssid *ssid, bool conn_status_requested)
1206 {
1207 #ifdef CONFIG_DPP
1208 if (!wpa_s)
1209 return;
1210
1211 wpas_aidl_notify_dpp_config_received(wpa_s, ssid, conn_status_requested);
1212 #endif /* CONFIG_DPP */
1213 }
1214
wpas_notify_dpp_config_sent(struct wpa_supplicant * wpa_s)1215 void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
1216 {
1217 #ifdef CONFIG_DPP
1218 if (!wpa_s)
1219 return;
1220
1221 wpas_aidl_notify_dpp_config_sent(wpa_s);
1222 #endif /* CONFIG_DPP */
1223 }
1224
1225 #ifdef CONFIG_DPP
wpas_notify_dpp_connection_status_sent(struct wpa_supplicant * wpa_s,enum dpp_status_error result)1226 void wpas_notify_dpp_connection_status_sent(struct wpa_supplicant *wpa_s,
1227 enum dpp_status_error result)
1228 {
1229 #ifdef CONFIG_DPP2
1230 if (!wpa_s)
1231 return;
1232
1233 wpas_aidl_notify_dpp_connection_status_sent(wpa_s, result);
1234 #endif /* CONFIG_DPP2 */
1235 }
1236 #endif /* CONFIG_DPP */
1237
1238 /* DPP Progress notifications */
wpas_notify_dpp_auth_success(struct wpa_supplicant * wpa_s)1239 void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
1240 {
1241 #ifdef CONFIG_DPP
1242 if (!wpa_s)
1243 return;
1244
1245 wpas_aidl_notify_dpp_auth_success(wpa_s);
1246 #endif /* CONFIG_DPP */
1247 }
1248
wpas_notify_dpp_resp_pending(struct wpa_supplicant * wpa_s)1249 void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
1250 {
1251 #ifdef CONFIG_DPP
1252 if (!wpa_s)
1253 return;
1254
1255 wpas_aidl_notify_dpp_resp_pending(wpa_s);
1256 #endif /* CONFIG_DPP */
1257 }
1258
1259 /* DPP Failure notifications */
wpas_notify_dpp_not_compatible(struct wpa_supplicant * wpa_s)1260 void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
1261 {
1262 #ifdef CONFIG_DPP
1263 if (!wpa_s)
1264 return;
1265
1266 wpas_aidl_notify_dpp_not_compatible(wpa_s);
1267 #endif /* CONFIG_DPP */
1268 }
1269
wpas_notify_dpp_missing_auth(struct wpa_supplicant * wpa_s)1270 void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
1271 {
1272 #ifdef CONFIG_DPP
1273 if (!wpa_s)
1274 return;
1275
1276 wpas_aidl_notify_dpp_missing_auth(wpa_s);
1277 #endif /* CONFIG_DPP */
1278 }
1279
wpas_notify_dpp_configuration_failure(struct wpa_supplicant * wpa_s)1280 void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
1281 {
1282 #ifdef CONFIG_DPP
1283 if (!wpa_s)
1284 return;
1285
1286 wpas_aidl_notify_dpp_configuration_failure(wpa_s);
1287 #endif /* CONFIG_DPP */
1288 }
1289
wpas_notify_dpp_timeout(struct wpa_supplicant * wpa_s)1290 void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
1291 {
1292 #ifdef CONFIG_DPP
1293 if (!wpa_s)
1294 return;
1295
1296 wpas_aidl_notify_dpp_timeout(wpa_s);
1297 #endif /* CONFIG_DPP */
1298 }
1299
wpas_notify_dpp_auth_failure(struct wpa_supplicant * wpa_s)1300 void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
1301 {
1302 #ifdef CONFIG_DPP
1303 if (!wpa_s)
1304 return;
1305
1306 wpas_aidl_notify_dpp_auth_failure(wpa_s);
1307 #endif /* CONFIG_DPP */
1308 }
1309
wpas_notify_dpp_failure(struct wpa_supplicant * wpa_s)1310 void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
1311 {
1312 #ifdef CONFIG_DPP
1313 if (!wpa_s)
1314 return;
1315
1316 wpas_aidl_notify_dpp_fail(wpa_s);
1317 #endif /* CONFIG_DPP */
1318 }
1319
wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant * wpa_s)1320 void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
1321 {
1322 #ifdef CONFIG_DPP2
1323 wpas_aidl_notify_dpp_config_sent_wait_response(wpa_s);
1324 #endif /* CONFIG_DPP2 */
1325 }
1326
wpas_notify_dpp_config_accepted(struct wpa_supplicant * wpa_s)1327 void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
1328 {
1329 #ifdef CONFIG_DPP2
1330 wpas_aidl_notify_dpp_config_accepted(wpa_s);
1331 #endif /* CONFIG_DPP2 */
1332 }
1333
1334 #ifdef CONFIG_DPP
wpas_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)1335 void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
1336 enum dpp_status_error status, const char *ssid,
1337 const char *channel_list, unsigned short band_list[], int size)
1338 {
1339 #ifdef CONFIG_DPP2
1340 wpas_aidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
1341 #endif /* CONFIG_DPP2 */
1342 }
1343 #endif /* CONFIG_DPP */
1344
wpas_notify_dpp_config_rejected(struct wpa_supplicant * wpa_s)1345 void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
1346 {
1347 #ifdef CONFIG_DPP2
1348 wpas_aidl_notify_dpp_config_rejected(wpa_s);
1349 #endif /* CONFIG_DPP2 */
1350 }
1351
wpas_notify_pmk_cache_added(struct wpa_supplicant * wpa_s,struct rsn_pmksa_cache_entry * entry)1352 void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1353 struct rsn_pmksa_cache_entry *entry)
1354 {
1355 if (!wpa_s)
1356 return;
1357
1358 wpas_aidl_notify_pmk_cache_added(wpa_s, entry);
1359 }
1360
wpas_notify_transition_disable(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,u8 bitmap)1361 void wpas_notify_transition_disable(struct wpa_supplicant *wpa_s,
1362 struct wpa_ssid *ssid,
1363 u8 bitmap)
1364 {
1365 if (!wpa_s)
1366 return;
1367
1368 if (!ssid)
1369 return;
1370
1371 wpas_aidl_notify_transition_disable(wpa_s, ssid, bitmap);
1372 }
1373
wpas_notify_network_not_found(struct wpa_supplicant * wpa_s)1374 void wpas_notify_network_not_found(struct wpa_supplicant *wpa_s)
1375 {
1376 if (!wpa_s)
1377 return;
1378
1379 wpas_aidl_notify_network_not_found(wpa_s);
1380 }
1381
1382 #ifdef CONFIG_INTERWORKING
1383
wpas_notify_interworking_ap_added(struct wpa_supplicant * wpa_s,struct wpa_bss * bss,struct wpa_cred * cred,int excluded,const char * type,int bh,int bss_load,int conn_capab)1384 void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
1385 struct wpa_bss *bss,
1386 struct wpa_cred *cred, int excluded,
1387 const char *type, int bh, int bss_load,
1388 int conn_capab)
1389 {
1390 wpa_msg(wpa_s, MSG_INFO, "%s" MACSTR " type=%s%s%s%s id=%d priority=%d sp_priority=%d",
1391 excluded ? INTERWORKING_EXCLUDED : INTERWORKING_AP,
1392 MAC2STR(bss->bssid), type,
1393 bh ? " below_min_backhaul=1" : "",
1394 bss_load ? " over_max_bss_load=1" : "",
1395 conn_capab ? " conn_capab_missing=1" : "",
1396 cred->id, cred->priority, cred->sp_priority);
1397
1398 wpas_dbus_signal_interworking_ap_added(wpa_s, bss, cred, type, excluded,
1399 bh, bss_load, conn_capab);
1400 }
1401
1402
wpas_notify_interworking_select_done(struct wpa_supplicant * wpa_s)1403 void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
1404 {
1405 wpas_dbus_signal_interworking_select_done(wpa_s);
1406 }
1407
1408
1409 #endif /* CONFIG_INTERWORKING */
1410
wpas_notify_eap_method_selected(struct wpa_supplicant * wpa_s,const char * reason_string)1411 void wpas_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
1412 const char* reason_string)
1413 {
1414 wpas_aidl_notify_eap_method_selected(wpa_s, reason_string);
1415 }
1416
wpas_notify_ssid_temp_disabled(struct wpa_supplicant * wpa_s,const char * reason_string)1417 void wpas_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
1418 const char *reason_string)
1419 {
1420 wpas_aidl_notify_ssid_temp_disabled(wpa_s, reason_string);
1421 }
1422
wpas_notify_open_ssl_failure(struct wpa_supplicant * wpa_s,const char * reason_string)1423 void wpas_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
1424 const char *reason_string)
1425 {
1426 wpas_aidl_notify_open_ssl_failure(wpa_s, reason_string);
1427 }
1428
wpas_notify_qos_policy_reset(struct wpa_supplicant * wpa_s)1429 void wpas_notify_qos_policy_reset(struct wpa_supplicant *wpa_s)
1430 {
1431 if (!wpa_s)
1432 return;
1433
1434 wpas_aidl_notify_qos_policy_reset(wpa_s);
1435 }
1436
wpas_notify_qos_policy_request(struct wpa_supplicant * wpa_s,struct dscp_policy_data * policies,int num_policies)1437 void wpas_notify_qos_policy_request(struct wpa_supplicant *wpa_s,
1438 struct dscp_policy_data *policies, int num_policies)
1439 {
1440 if (!wpa_s || !policies)
1441 return;
1442
1443 wpas_aidl_notify_qos_policy_request(wpa_s, policies, num_policies);
1444 }
1445
wpas_notify_frequency_changed(struct wpa_supplicant * wpa_s,int frequency)1446 void wpas_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency)
1447 {
1448 if (!wpa_s)
1449 return;
1450
1451 wpas_aidl_notify_frequency_changed(wpa_s, frequency);
1452 }
1453
wpas_get_certificate(const char * alias,uint8_t ** value)1454 ssize_t wpas_get_certificate(const char *alias, uint8_t** value)
1455 {
1456 wpa_printf(MSG_INFO, "wpas_get_certificate");
1457 return wpas_aidl_get_certificate(alias, value);
1458 }
1459
wpas_list_aliases(const char * prefix,char *** aliases)1460 ssize_t wpas_list_aliases(const char *prefix, char ***aliases)
1461 {
1462 return wpas_aidl_list_aliases(prefix, aliases);
1463 }
1464
wpas_notify_signal_change(struct wpa_supplicant * wpa_s)1465 void wpas_notify_signal_change(struct wpa_supplicant *wpa_s)
1466 {
1467 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE);
1468 }
1469
wpas_notify_qos_policy_scs_response(struct wpa_supplicant * wpa_s,unsigned int num_scs_resp,int ** scs_resp)1470 void wpas_notify_qos_policy_scs_response(struct wpa_supplicant *wpa_s,
1471 unsigned int num_scs_resp, int **scs_resp)
1472 {
1473 if (!wpa_s || !num_scs_resp || !scs_resp)
1474 return;
1475
1476 wpas_aidl_notify_qos_policy_scs_response(wpa_s, num_scs_resp, scs_resp);
1477 }
1478
wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant * wpa_s,const char * url)1479 void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
1480 const char *url)
1481 {
1482 #ifdef CONFIG_HS20
1483 if (!wpa_s || !url)
1484 return;
1485
1486 wpa_msg(wpa_s, MSG_INFO, HS20_T_C_ACCEPTANCE "%s", url);
1487 wpas_aidl_notify_hs20_rx_terms_and_conditions_acceptance(wpa_s, url);
1488 wpas_dbus_signal_hs20_t_c_acceptance(wpa_s, url);
1489 #endif /* CONFIG_HS20 */
1490 }
1491
1492 #ifdef CONFIG_NAN_USD
1493
wpas_notify_nan_discovery_result(struct wpa_supplicant * wpa_s,enum nan_service_protocol_type srv_proto_type,int subscribe_id,int peer_publish_id,const u8 * peer_addr,bool fsd,bool fsd_gas,const u8 * ssi,size_t ssi_len)1494 void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
1495 enum nan_service_protocol_type
1496 srv_proto_type,
1497 int subscribe_id, int peer_publish_id,
1498 const u8 *peer_addr,
1499 bool fsd, bool fsd_gas,
1500 const u8 *ssi, size_t ssi_len)
1501 {
1502 char *ssi_hex;
1503
1504 ssi_hex = os_zalloc(2 * ssi_len + 1);
1505 if (!ssi_hex)
1506 return;
1507 if (ssi)
1508 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1509 wpa_msg(wpa_s, MSG_INFO, NAN_DISCOVERY_RESULT
1510 "subscribe_id=%d publish_id=%d address=" MACSTR
1511 " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s",
1512 subscribe_id, peer_publish_id, MAC2STR(peer_addr),
1513 fsd, fsd_gas, srv_proto_type, ssi_hex);
1514 os_free(ssi_hex);
1515 }
1516
1517
wpas_notify_nan_replied(struct wpa_supplicant * wpa_s,enum nan_service_protocol_type srv_proto_type,int publish_id,int peer_subscribe_id,const u8 * peer_addr,const u8 * ssi,size_t ssi_len)1518 void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s,
1519 enum nan_service_protocol_type srv_proto_type,
1520 int publish_id, int peer_subscribe_id,
1521 const u8 *peer_addr,
1522 const u8 *ssi, size_t ssi_len)
1523 {
1524 char *ssi_hex;
1525
1526 ssi_hex = os_zalloc(2 * ssi_len + 1);
1527 if (!ssi_hex)
1528 return;
1529 if (ssi)
1530 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1531 wpa_msg(wpa_s, MSG_INFO, NAN_REPLIED
1532 "publish_id=%d address=" MACSTR
1533 " subscribe_id=%d srv_proto_type=%u ssi=%s",
1534 publish_id, MAC2STR(peer_addr), peer_subscribe_id,
1535 srv_proto_type, ssi_hex);
1536 os_free(ssi_hex);
1537 }
1538
1539
wpas_notify_nan_receive(struct wpa_supplicant * wpa_s,int id,int peer_instance_id,const u8 * peer_addr,const u8 * ssi,size_t ssi_len)1540 void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id,
1541 int peer_instance_id, const u8 *peer_addr,
1542 const u8 *ssi, size_t ssi_len)
1543 {
1544 char *ssi_hex;
1545
1546 ssi_hex = os_zalloc(2 * ssi_len + 1);
1547 if (!ssi_hex)
1548 return;
1549 if (ssi)
1550 wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1551 wpa_msg(wpa_s, MSG_INFO, NAN_RECEIVE
1552 "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s",
1553 id, peer_instance_id, MAC2STR(peer_addr), ssi_hex);
1554 os_free(ssi_hex);
1555 }
1556
1557
nan_reason_txt(enum nan_de_reason reason)1558 static const char * nan_reason_txt(enum nan_de_reason reason)
1559 {
1560 switch (reason) {
1561 case NAN_DE_REASON_TIMEOUT:
1562 return "timeout";
1563 case NAN_DE_REASON_USER_REQUEST:
1564 return "user-request";
1565 case NAN_DE_REASON_FAILURE:
1566 return "failure";
1567 }
1568
1569 return "unknown";
1570 }
1571
1572
wpas_notify_nan_publish_terminated(struct wpa_supplicant * wpa_s,int publish_id,enum nan_de_reason reason)1573 void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s,
1574 int publish_id,
1575 enum nan_de_reason reason)
1576 {
1577 wpa_msg(wpa_s, MSG_INFO, NAN_PUBLISH_TERMINATED
1578 "publish_id=%d reason=%s",
1579 publish_id, nan_reason_txt(reason));
1580 }
1581
1582
wpas_notify_nan_subscribe_terminated(struct wpa_supplicant * wpa_s,int subscribe_id,enum nan_de_reason reason)1583 void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s,
1584 int subscribe_id,
1585 enum nan_de_reason reason)
1586 {
1587 wpa_msg(wpa_s, MSG_INFO, NAN_SUBSCRIBE_TERMINATED
1588 "subscribe_id=%d reason=%s",
1589 subscribe_id, nan_reason_txt(reason));
1590 }
1591
1592 #endif /* CONFIG_NAN_USD */
1593