blob: 4b4a34b52d626652d7d11d5f1a6a4f321043163e [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/*
2 * wpa_supplicant - Event notifications
3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
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 "config.h"
14#include "wpa_supplicant_i.h"
15#include "wps_supplicant.h"
16#include "binder/binder.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
30int wpas_notify_supplicant_initialized(struct wpa_global *global)
31{
32#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
33 if (global->params.dbus_ctrl_interface) {
34 global->dbus = wpas_dbus_init(global);
35 if (global->dbus == NULL)
36 return -1;
37 }
38#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
39
40#ifdef CONFIG_BINDER
41 global->binder = wpas_binder_init(global);
42 if (!global->binder)
43 return -1;
44#endif /* CONFIG_BINDER */
45
46 return 0;
47}
48
49
50void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
51{
52#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
53 if (global->dbus)
54 wpas_dbus_deinit(global->dbus);
55#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
56
57#ifdef CONFIG_BINDER
58 if (global->binder)
59 wpas_binder_deinit(global->binder);
60#endif /* CONFIG_BINDER */
61}
62
63
64int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
65{
66 if (wpa_s->p2p_mgmt)
67 return 0;
68
69 if (wpas_dbus_register_interface(wpa_s))
70 return -1;
71
72 return 0;
73}
74
75
76void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
77{
78 if (wpa_s->p2p_mgmt)
79 return;
80
81 /* unregister interface in new DBus ctrl iface */
82 wpas_dbus_unregister_interface(wpa_s);
83}
84
85
86void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
87 enum wpa_states new_state,
88 enum wpa_states old_state)
89{
90 if (wpa_s->p2p_mgmt)
91 return;
92
93 /* notify the new DBus API */
94 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
95
96#ifdef CONFIG_FST
97 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
98 if (new_state == WPA_COMPLETED)
99 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
100 else if (old_state >= WPA_ASSOCIATED &&
101 new_state < WPA_ASSOCIATED)
102 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
103 }
104#endif /* CONFIG_FST */
105
106 if (new_state == WPA_COMPLETED)
107 wpas_p2p_notif_connected(wpa_s);
108 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
109 wpas_p2p_notif_disconnected(wpa_s);
110
111 sme_state_changed(wpa_s);
112
113#ifdef ANDROID
114 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
115 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
116 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
117 new_state,
118 MAC2STR(wpa_s->bssid),
119 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
120 wpa_ssid_txt(wpa_s->current_ssid->ssid,
121 wpa_s->current_ssid->ssid_len) : "");
122#endif /* ANDROID */
123}
124
125
126void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
127{
128 if (wpa_s->p2p_mgmt)
129 return;
130
131 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
132}
133
134
135void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
136{
137 if (wpa_s->p2p_mgmt)
138 return;
139
140 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
141}
142
143
144void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
145{
146 if (wpa_s->p2p_mgmt)
147 return;
148
149 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
150}
151
152
153void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
154{
155 if (wpa_s->p2p_mgmt)
156 return;
157
158 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
159}
160
161
162void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
163{
164 if (wpa_s->p2p_mgmt)
165 return;
166
167 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
168}
169
170
171void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
172{
173 if (wpa_s->p2p_mgmt)
174 return;
175
176 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
177}
178
179
180void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
181{
182 if (wpa_s->p2p_mgmt)
183 return;
184
185 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
186}
187
188
189void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
190{
191 if (wpa_s->p2p_mgmt)
192 return;
193
194 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
195}
196
197
198void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
199{
200 if (wpa_s->p2p_mgmt)
201 return;
202
203 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
204}
205
206
207void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
208{
209 if (wpa_s->p2p_mgmt)
210 return;
211
212 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
213}
214
215
216void wpas_notify_mac_address_changed(struct wpa_supplicant *wpa_s)
217{
218 if (wpa_s->p2p_mgmt)
219 return;
220
221 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_MAC_ADDRESS);
222}
223
224
225void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
226{
227 if (wpa_s->p2p_mgmt)
228 return;
229
230 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
231}
232
233
234void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
235 struct wpa_ssid *ssid)
236{
237 if (wpa_s->p2p_mgmt)
238 return;
239
240 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
241}
242
243
244void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
245 struct wpa_ssid *ssid)
246{
247 if (wpa_s->p2p_mgmt)
248 return;
249
250 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
251}
252
253
254void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
255 struct wpa_ssid *ssid,
256 enum wpa_ctrl_req_type rtype,
257 const char *default_txt)
258{
259 if (wpa_s->p2p_mgmt)
260 return;
261
262 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
263}
264
265
266void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
267{
268 if (wpa_s->p2p_mgmt)
269 return;
270
271 /* notify the new DBus API */
272 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
273}
274
275
276void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
277{
278 if (wpa_s->p2p_mgmt)
279 return;
280
281 wpas_dbus_signal_scan_done(wpa_s, success);
282}
283
284
285void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
286{
287 if (wpa_s->p2p_mgmt)
288 return;
289
290 wpas_wps_notify_scan_results(wpa_s);
291}
292
293
294void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
295 const struct wps_credential *cred)
296{
297 if (wpa_s->p2p_mgmt)
298 return;
299
300#ifdef CONFIG_WPS
301 /* notify the new DBus API */
302 wpas_dbus_signal_wps_cred(wpa_s, cred);
303#endif /* CONFIG_WPS */
304}
305
306
307void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
308 struct wps_event_m2d *m2d)
309{
310 if (wpa_s->p2p_mgmt)
311 return;
312
313#ifdef CONFIG_WPS
314 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
315#endif /* CONFIG_WPS */
316}
317
318
319void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
320 struct wps_event_fail *fail)
321{
322 if (wpa_s->p2p_mgmt)
323 return;
324
325#ifdef CONFIG_WPS
326 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
327#endif /* CONFIG_WPS */
328}
329
330
331void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
332{
333 if (wpa_s->p2p_mgmt)
334 return;
335
336#ifdef CONFIG_WPS
337 wpas_dbus_signal_wps_event_success(wpa_s);
338#endif /* CONFIG_WPS */
339}
340
341void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
342{
343 if (wpa_s->p2p_mgmt)
344 return;
345
346#ifdef CONFIG_WPS
347 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
348#endif /* CONFIG_WPS */
349}
350
351
352void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
353 struct wpa_ssid *ssid)
354{
355 if (wpa_s->p2p_mgmt)
356 return;
357
358 /*
359 * Networks objects created during any P2P activities should not be
360 * exposed out. They might/will confuse certain non-P2P aware
361 * applications since these network objects won't behave like
362 * regular ones.
363 */
364 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
365 wpas_dbus_register_network(wpa_s, ssid);
366 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_ADDED "%d",
367 ssid->id);
368 }
369}
370
371
372void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
373 struct wpa_ssid *ssid)
374{
375#ifdef CONFIG_P2P
376 wpas_dbus_register_persistent_group(wpa_s, ssid);
377#endif /* CONFIG_P2P */
378}
379
380
381void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
382 struct wpa_ssid *ssid)
383{
384#ifdef CONFIG_P2P
385 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
386#endif /* CONFIG_P2P */
387}
388
389
390void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
391 struct wpa_ssid *ssid)
392{
393 if (wpa_s->next_ssid == ssid)
394 wpa_s->next_ssid = NULL;
395 if (wpa_s->last_ssid == ssid)
396 wpa_s->last_ssid = NULL;
397 if (wpa_s->current_ssid == ssid)
398 wpa_s->current_ssid = NULL;
399#if defined(CONFIG_SME) && defined(CONFIG_SAE)
400 if (wpa_s->sme.ext_auth_wpa_ssid == ssid)
401 wpa_s->sme.ext_auth_wpa_ssid = NULL;
402#endif /* CONFIG_SME && CONFIG_SAE */
403 if (wpa_s->wpa)
404 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
405 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
406 !wpa_s->p2p_mgmt) {
407 wpas_dbus_unregister_network(wpa_s, ssid->id);
408 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_REMOVED "%d",
409 ssid->id);
410 }
411 if (network_is_persistent_group(ssid))
412 wpas_notify_persistent_group_removed(wpa_s, ssid);
413
414 wpas_p2p_network_removed(wpa_s, ssid);
415}
416
417
418void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
419 u8 bssid[], unsigned int id)
420{
421 if (wpa_s->p2p_mgmt)
422 return;
423
424 wpas_dbus_register_bss(wpa_s, bssid, id);
425 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
426 id, MAC2STR(bssid));
427}
428
429
430void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
431 u8 bssid[], unsigned int id)
432{
433 if (wpa_s->p2p_mgmt)
434 return;
435
436 wpas_dbus_unregister_bss(wpa_s, bssid, id);
437 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
438 id, MAC2STR(bssid));
439}
440
441
442void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
443 unsigned int id)
444{
445 if (wpa_s->p2p_mgmt)
446 return;
447
448 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
449}
450
451
452void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
453 unsigned int id)
454{
455 if (wpa_s->p2p_mgmt)
456 return;
457
458 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
459 id);
460}
461
462
463void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
464 unsigned int id)
465{
466 if (wpa_s->p2p_mgmt)
467 return;
468
469 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
470 id);
471}
472
473
474void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
475 unsigned int id)
476{
477 if (wpa_s->p2p_mgmt)
478 return;
479
480 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
481}
482
483
484void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
485 unsigned int id)
486{
487 if (wpa_s->p2p_mgmt)
488 return;
489
490 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
491}
492
493
494void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
495 unsigned int id)
496{
497 if (wpa_s->p2p_mgmt)
498 return;
499
500 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
501}
502
503
504void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
505 unsigned int id)
506{
507 if (wpa_s->p2p_mgmt)
508 return;
509
510#ifdef CONFIG_WPS
511 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
512#endif /* CONFIG_WPS */
513}
514
515
516void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
517 unsigned int id)
518{
519 if (wpa_s->p2p_mgmt)
520 return;
521
522 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
523}
524
525
526void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
527 unsigned int id)
528{
529 if (wpa_s->p2p_mgmt)
530 return;
531
532 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
533}
534
535
536void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
537{
538 if (wpa_s->p2p_mgmt)
539 return;
540
541 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
542}
543
544
545void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
546{
547 if (wpa_s->p2p_mgmt)
548 return;
549
550 wpas_dbus_signal_blob_added(wpa_s, name);
551}
552
553
554void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
555{
556 if (wpa_s->p2p_mgmt)
557 return;
558
559 wpas_dbus_signal_blob_removed(wpa_s, name);
560}
561
562
563void wpas_notify_debug_level_changed(struct wpa_global *global)
564{
565 wpas_dbus_signal_debug_level_changed(global);
566}
567
568
569void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
570{
571 wpas_dbus_signal_debug_timestamp_changed(global);
572}
573
574
575void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
576{
577 wpas_dbus_signal_debug_show_keys_changed(global);
578}
579
580
581void wpas_notify_suspend(struct wpa_global *global)
582{
583 struct wpa_supplicant *wpa_s;
584
585 os_get_time(&global->suspend_time);
586 wpa_printf(MSG_DEBUG, "System suspend notification");
587 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
588 wpa_drv_suspend(wpa_s);
589}
590
591
592void wpas_notify_resume(struct wpa_global *global)
593{
594 struct os_time now;
595 int slept;
596 struct wpa_supplicant *wpa_s;
597
598 if (global->suspend_time.sec == 0)
599 slept = -1;
600 else {
601 os_get_time(&now);
602 slept = now.sec - global->suspend_time.sec;
603 }
604 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
605 slept);
606
607 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
608 wpa_drv_resume(wpa_s);
609 if (wpa_s->wpa_state == WPA_DISCONNECTED)
610 wpa_supplicant_req_scan(wpa_s, 0, 100000);
611 }
612}
613
614
615#ifdef CONFIG_P2P
616
617void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
618{
619 /* Notify P2P find has stopped */
620 wpas_dbus_signal_p2p_find_stopped(wpa_s);
621}
622
623
624void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
625 const u8 *dev_addr, int new_device)
626{
627 if (new_device) {
628 /* Create the new peer object */
629 wpas_dbus_register_peer(wpa_s, dev_addr);
630 }
631
632 /* Notify a new peer has been detected*/
633 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
634}
635
636
637void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
638 const u8 *dev_addr)
639{
640 wpas_dbus_unregister_peer(wpa_s, dev_addr);
641
642 /* Create signal on interface object*/
643 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
644}
645
646
647void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
648 const struct wpa_ssid *ssid,
649 const char *role)
650{
651 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
652
653 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
654}
655
656
657void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
658 const u8 *src, u16 dev_passwd_id, u8 go_intent)
659{
660 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
661}
662
663
664void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
665 struct p2p_go_neg_results *res)
666{
667 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
668}
669
670
671void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
672 int status, const u8 *bssid)
673{
674 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
675}
676
677
678void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
679 int freq, const u8 *sa, u8 dialog_token,
680 u16 update_indic, const u8 *tlvs,
681 size_t tlvs_len)
682{
683 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
684 update_indic, tlvs, tlvs_len);
685}
686
687
688void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
689 const u8 *sa, u16 update_indic,
690 const u8 *tlvs, size_t tlvs_len)
691{
692 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
693 tlvs, tlvs_len);
694}
695
696
697/**
698 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
699 * @dev_addr: Who sent the request or responded to our request.
700 * @request: Will be 1 if request, 0 for response.
701 * @status: Valid only in case of response (0 in case of success)
702 * @config_methods: WPS config methods
703 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
704 *
705 * This can be used to notify:
706 * - Requests or responses
707 * - Various config methods
708 * - Failure condition in case of response
709 */
710void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
711 const u8 *dev_addr, int request,
712 enum p2p_prov_disc_status status,
713 u16 config_methods,
714 unsigned int generated_pin)
715{
716 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
717 status, config_methods,
718 generated_pin);
719}
720
721
722void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
723 struct wpa_ssid *ssid, int persistent,
724 int client, const u8 *ip)
725{
726 /* Notify a group has been started */
727 wpas_dbus_register_p2p_group(wpa_s, ssid);
728
729 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
730}
731
732
733void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
734 const char *reason)
735{
736 /* Notify a group formation failed */
737 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
738}
739
740
741void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
742 struct wps_event_fail *fail)
743{
744 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
745}
746
747
748void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
749 const u8 *sa, const u8 *go_dev_addr,
750 const u8 *bssid, int id, int op_freq)
751{
752 /* Notify a P2P Invitation Request */
753 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
754 id, op_freq);
755}
756
757#endif /* CONFIG_P2P */
758
759
760static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
761 const u8 *sta,
762 const u8 *p2p_dev_addr)
763{
764#ifdef CONFIG_P2P
765 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
766
767 /*
768 * Create 'peer-joined' signal on group object -- will also
769 * check P2P itself.
770 */
771 if (p2p_dev_addr)
772 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
773#endif /* CONFIG_P2P */
774
775 /* Register the station */
776 wpas_dbus_register_sta(wpa_s, sta);
777
778 /* Notify listeners a new station has been authorized */
779 wpas_dbus_signal_sta_authorized(wpa_s, sta);
780}
781
782
783static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
784 const u8 *sta,
785 const u8 *p2p_dev_addr)
786{
787#ifdef CONFIG_P2P
788 /*
789 * Create 'peer-disconnected' signal on group object if this
790 * is a P2P group.
791 */
792 if (p2p_dev_addr)
793 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
794#endif /* CONFIG_P2P */
795
796 /* Notify listeners a station has been deauthorized */
797 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
798
799 /* Unregister the station */
800 wpas_dbus_unregister_sta(wpa_s, sta);
801}
802
803
804void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
805 const u8 *mac_addr, int authorized,
806 const u8 *p2p_dev_addr)
807{
808 if (authorized)
809 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
810 else
811 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
812}
813
814
815void wpas_notify_certification(struct wpa_supplicant *wpa_s,
816 struct tls_cert_data *cert,
817 const char *cert_hash)
818{
819 int i;
820
821 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
822 "depth=%d subject='%s'%s%s%s%s",
823 cert->depth, cert->subject, cert_hash ? " hash=" : "",
824 cert_hash ? cert_hash : "",
825 cert->tod == 2 ? " tod=2" : "",
826 cert->tod == 1 ? " tod=1" : "");
827
828 if (cert->cert) {
829 char *cert_hex;
830 size_t len = wpabuf_len(cert->cert) * 2 + 1;
831 cert_hex = os_malloc(len);
832 if (cert_hex) {
833 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
834 wpabuf_len(cert->cert));
835 wpa_msg_ctrl(wpa_s, MSG_INFO,
836 WPA_EVENT_EAP_PEER_CERT
837 "depth=%d subject='%s' cert=%s",
838 cert->depth, cert->subject, cert_hex);
839 os_free(cert_hex);
840 }
841 }
842
843 for (i = 0; i < cert->num_altsubject; i++)
844 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
845 "depth=%d %s", cert->depth, cert->altsubject[i]);
846
847 /* notify the new DBus API */
848 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
849 cert->altsubject, cert->num_altsubject,
850 cert_hash, cert->cert);
851}
852
853
854void wpas_notify_preq(struct wpa_supplicant *wpa_s,
855 const u8 *addr, const u8 *dst, const u8 *bssid,
856 const u8 *ie, size_t ie_len, u32 ssi_signal)
857{
858#ifdef CONFIG_AP
859 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
860#endif /* CONFIG_AP */
861}
862
863
864void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
865 const char *parameter)
866{
867 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
868 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
869 "status='%s' parameter='%s'",
870 status, parameter);
871}
872
873
874void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
875{
876 wpa_msg(wpa_s, MSG_ERROR, WPA_EVENT_EAP_ERROR_CODE "%d", error_code);
877}
878
879
880void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s)
881{
882 wpas_dbus_signal_psk_mismatch(wpa_s);
883}
884
885
886void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
887 struct wpa_ssid *ssid)
888{
889 if (wpa_s->current_ssid != ssid)
890 return;
891
892 wpa_dbg(wpa_s, MSG_DEBUG,
893 "Network bssid config changed for the current network - within-ESS roaming %s",
894 ssid->bssid_set ? "disabled" : "enabled");
895
896 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
897 ssid->bssid_set ? ssid->bssid : NULL);
898}
899
900
901void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
902 struct wpa_ssid *ssid)
903{
904#ifdef CONFIG_P2P
905 if (ssid->disabled == 2) {
906 /* Changed from normal network profile to persistent group */
907 ssid->disabled = 0;
908 wpas_dbus_unregister_network(wpa_s, ssid->id);
909 ssid->disabled = 2;
910 ssid->p2p_persistent_group = 1;
911 wpas_dbus_register_persistent_group(wpa_s, ssid);
912 } else {
913 /* Changed from persistent group to normal network profile */
914 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
915 ssid->p2p_persistent_group = 0;
916 wpas_dbus_register_network(wpa_s, ssid);
917 }
918#endif /* CONFIG_P2P */
919}
920
921
922#ifdef CONFIG_MESH
923
924void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
925 struct wpa_ssid *ssid)
926{
927 if (wpa_s->p2p_mgmt)
928 return;
929
930 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
931}
932
933
934void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
935 const u8 *meshid, u8 meshid_len,
936 u16 reason_code)
937{
938 if (wpa_s->p2p_mgmt)
939 return;
940
941 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
942 reason_code);
943}
944
945
946void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
947 const u8 *peer_addr)
948{
949 if (wpa_s->p2p_mgmt)
950 return;
951
952 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
953}
954
955
956void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
957 const u8 *peer_addr, u16 reason_code)
958{
959 if (wpa_s->p2p_mgmt)
960 return;
961
962 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
963}
964
965#endif /* CONFIG_MESH */
966
967
968#ifdef CONFIG_INTERWORKING
969
970void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
971 struct wpa_bss *bss,
972 struct wpa_cred *cred, int excluded,
973 const char *type, int bh, int bss_load,
974 int conn_capab)
975{
976 wpa_msg(wpa_s, MSG_INFO, "%s" MACSTR " type=%s%s%s%s id=%d priority=%d sp_priority=%d",
977 excluded ? INTERWORKING_EXCLUDED : INTERWORKING_AP,
978 MAC2STR(bss->bssid), type,
979 bh ? " below_min_backhaul=1" : "",
980 bss_load ? " over_max_bss_load=1" : "",
981 conn_capab ? " conn_capab_missing=1" : "",
982 cred->id, cred->priority, cred->sp_priority);
983
984 wpas_dbus_signal_interworking_ap_added(wpa_s, bss, cred, type, excluded,
985 bh, bss_load, conn_capab);
986}
987
988
989void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
990{
991 wpas_dbus_signal_interworking_select_done(wpa_s);
992}
993
994#endif /* CONFIG_INTERWORKING */
995
996
997void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
998 struct rsn_pmksa_cache_entry *entry)
999{
1000 /* TODO: Notify external entities of the added PMKSA cache entry */
1001}
1002
1003
1004void wpas_notify_signal_change(struct wpa_supplicant *wpa_s)
1005{
1006 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE);
1007}