WNM: Verify BSS TM target match against the current network profile
[mech_eap.git] / wpa_supplicant / notify.c
1 /*
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 "dbus/dbus_common.h"
17 #include "dbus/dbus_old.h"
18 #include "dbus/dbus_new.h"
19 #include "rsn_supp/wpa.h"
20 #include "fst/fst.h"
21 #include "driver_i.h"
22 #include "scan.h"
23 #include "p2p_supplicant.h"
24 #include "sme.h"
25 #include "notify.h"
26
27 int wpas_notify_supplicant_initialized(struct wpa_global *global)
28 {
29 #ifdef CONFIG_DBUS
30         if (global->params.dbus_ctrl_interface) {
31                 global->dbus = wpas_dbus_init(global);
32                 if (global->dbus == NULL)
33                         return -1;
34         }
35 #endif /* CONFIG_DBUS */
36
37         return 0;
38 }
39
40
41 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
42 {
43 #ifdef CONFIG_DBUS
44         if (global->dbus)
45                 wpas_dbus_deinit(global->dbus);
46 #endif /* CONFIG_DBUS */
47 }
48
49
50 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
51 {
52         if (wpa_s->p2p_mgmt)
53                 return 0;
54
55         if (wpas_dbus_register_iface(wpa_s))
56                 return -1;
57
58         if (wpas_dbus_register_interface(wpa_s))
59                 return -1;
60
61         return 0;
62 }
63
64
65 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
66 {
67         if (wpa_s->p2p_mgmt)
68                 return;
69
70         /* unregister interface in old DBus ctrl iface */
71         wpas_dbus_unregister_iface(wpa_s);
72
73         /* unregister interface in new DBus ctrl iface */
74         wpas_dbus_unregister_interface(wpa_s);
75 }
76
77
78 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
79                                enum wpa_states new_state,
80                                enum wpa_states old_state)
81 {
82         if (wpa_s->p2p_mgmt)
83                 return;
84
85         /* notify the old DBus API */
86         wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
87                                                 old_state);
88
89         /* notify the new DBus API */
90         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
91
92 #ifdef CONFIG_FST
93         if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
94                 if (new_state == WPA_COMPLETED)
95                         fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
96                 else if (old_state >= WPA_ASSOCIATED &&
97                          new_state < WPA_ASSOCIATED)
98                         fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
99         }
100 #endif /* CONFIG_FST */
101
102         if (new_state == WPA_COMPLETED)
103                 wpas_p2p_notif_connected(wpa_s);
104         else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
105                 wpas_p2p_notif_disconnected(wpa_s);
106
107         sme_state_changed(wpa_s);
108
109 #ifdef ANDROID
110         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
111                      "id=%d state=%d BSSID=" MACSTR " SSID=%s",
112                      wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
113                      new_state,
114                      MAC2STR(wpa_s->bssid),
115                      wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
116                      wpa_ssid_txt(wpa_s->current_ssid->ssid,
117                                   wpa_s->current_ssid->ssid_len) : "");
118 #endif /* ANDROID */
119 }
120
121
122 void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
123 {
124         if (wpa_s->p2p_mgmt)
125                 return;
126
127         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
128 }
129
130
131 void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
132 {
133         if (wpa_s->p2p_mgmt)
134                 return;
135
136         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
137 }
138
139
140 void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
141 {
142         if (wpa_s->p2p_mgmt)
143                 return;
144
145         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
146 }
147
148
149 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
150 {
151         if (wpa_s->p2p_mgmt)
152                 return;
153
154         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
155 }
156
157
158 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
159 {
160         if (wpa_s->p2p_mgmt)
161                 return;
162
163         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
164 }
165
166
167 void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
168 {
169         if (wpa_s->p2p_mgmt)
170                 return;
171
172         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
173 }
174
175
176 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
177                                          struct wpa_ssid *ssid)
178 {
179         if (wpa_s->p2p_mgmt)
180                 return;
181
182         wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
183 }
184
185
186 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
187                                   struct wpa_ssid *ssid)
188 {
189         if (wpa_s->p2p_mgmt)
190                 return;
191
192         wpas_dbus_signal_network_selected(wpa_s, ssid->id);
193 }
194
195
196 void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
197                                  struct wpa_ssid *ssid,
198                                  enum wpa_ctrl_req_type rtype,
199                                  const char *default_txt)
200 {
201         if (wpa_s->p2p_mgmt)
202                 return;
203
204         wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
205 }
206
207
208 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
209 {
210         if (wpa_s->p2p_mgmt)
211                 return;
212
213         /* notify the old DBus API */
214         wpa_supplicant_dbus_notify_scanning(wpa_s);
215
216         /* notify the new DBus API */
217         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
218 }
219
220
221 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
222 {
223         if (wpa_s->p2p_mgmt)
224                 return;
225
226         wpas_dbus_signal_scan_done(wpa_s, success);
227 }
228
229
230 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
231 {
232         if (wpa_s->p2p_mgmt)
233                 return;
234
235         /* notify the old DBus API */
236         wpa_supplicant_dbus_notify_scan_results(wpa_s);
237
238         wpas_wps_notify_scan_results(wpa_s);
239 }
240
241
242 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
243                                 const struct wps_credential *cred)
244 {
245         if (wpa_s->p2p_mgmt)
246                 return;
247
248 #ifdef CONFIG_WPS
249         /* notify the old DBus API */
250         wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
251         /* notify the new DBus API */
252         wpas_dbus_signal_wps_cred(wpa_s, cred);
253 #endif /* CONFIG_WPS */
254 }
255
256
257 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
258                                struct wps_event_m2d *m2d)
259 {
260         if (wpa_s->p2p_mgmt)
261                 return;
262
263 #ifdef CONFIG_WPS
264         wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
265 #endif /* CONFIG_WPS */
266 }
267
268
269 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
270                                 struct wps_event_fail *fail)
271 {
272         if (wpa_s->p2p_mgmt)
273                 return;
274
275 #ifdef CONFIG_WPS
276         wpas_dbus_signal_wps_event_fail(wpa_s, fail);
277 #endif /* CONFIG_WPS */
278 }
279
280
281 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
282 {
283         if (wpa_s->p2p_mgmt)
284                 return;
285
286 #ifdef CONFIG_WPS
287         wpas_dbus_signal_wps_event_success(wpa_s);
288 #endif /* CONFIG_WPS */
289 }
290
291 void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
292 {
293         if (wpa_s->p2p_mgmt)
294                 return;
295
296 #ifdef CONFIG_WPS
297         wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
298 #endif /* CONFIG_WPS */
299 }
300
301
302 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
303                                struct wpa_ssid *ssid)
304 {
305         if (wpa_s->p2p_mgmt)
306                 return;
307
308         /*
309          * Networks objects created during any P2P activities should not be
310          * exposed out. They might/will confuse certain non-P2P aware
311          * applications since these network objects won't behave like
312          * regular ones.
313          */
314         if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
315                 wpas_dbus_register_network(wpa_s, ssid);
316 }
317
318
319 void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
320                                         struct wpa_ssid *ssid)
321 {
322 #ifdef CONFIG_P2P
323         wpas_dbus_register_persistent_group(wpa_s, ssid);
324 #endif /* CONFIG_P2P */
325 }
326
327
328 void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
329                                           struct wpa_ssid *ssid)
330 {
331 #ifdef CONFIG_P2P
332         wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
333 #endif /* CONFIG_P2P */
334 }
335
336
337 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
338                                  struct wpa_ssid *ssid)
339 {
340         if (wpa_s->next_ssid == ssid)
341                 wpa_s->next_ssid = NULL;
342         if (wpa_s->wpa)
343                 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
344         if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
345             !wpa_s->p2p_mgmt)
346                 wpas_dbus_unregister_network(wpa_s, ssid->id);
347         if (network_is_persistent_group(ssid))
348                 wpas_notify_persistent_group_removed(wpa_s, ssid);
349
350         wpas_p2p_network_removed(wpa_s, ssid);
351 }
352
353
354 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
355                            u8 bssid[], unsigned int id)
356 {
357         if (wpa_s->p2p_mgmt)
358                 return;
359
360         wpas_dbus_register_bss(wpa_s, bssid, id);
361         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
362                      id, MAC2STR(bssid));
363 }
364
365
366 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
367                              u8 bssid[], unsigned int id)
368 {
369         if (wpa_s->p2p_mgmt)
370                 return;
371
372         wpas_dbus_unregister_bss(wpa_s, bssid, id);
373         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
374                      id, MAC2STR(bssid));
375 }
376
377
378 void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
379                                   unsigned int id)
380 {
381         if (wpa_s->p2p_mgmt)
382                 return;
383
384         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
385 }
386
387
388 void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
389                                     unsigned int id)
390 {
391         if (wpa_s->p2p_mgmt)
392                 return;
393
394         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
395                                           id);
396 }
397
398
399 void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
400                                      unsigned int id)
401 {
402         if (wpa_s->p2p_mgmt)
403                 return;
404
405         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
406                                           id);
407 }
408
409
410 void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
411                                   unsigned int id)
412 {
413         if (wpa_s->p2p_mgmt)
414                 return;
415
416         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
417 }
418
419
420 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
421                                    unsigned int id)
422 {
423         if (wpa_s->p2p_mgmt)
424                 return;
425
426         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
427 }
428
429
430 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
431                                    unsigned int id)
432 {
433         if (wpa_s->p2p_mgmt)
434                 return;
435
436         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
437 }
438
439
440 void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
441                                  unsigned int id)
442 {
443         if (wpa_s->p2p_mgmt)
444                 return;
445
446 #ifdef CONFIG_WPS
447         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
448 #endif /* CONFIG_WPS */
449 }
450
451
452 void wpas_notify_bss_ies_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_IES, id);
459 }
460
461
462 void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
463                                    unsigned int id)
464 {
465         if (wpa_s->p2p_mgmt)
466                 return;
467
468         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
469 }
470
471
472 void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
473 {
474         if (wpa_s->p2p_mgmt)
475                 return;
476
477         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
478 }
479
480
481 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
482 {
483         if (wpa_s->p2p_mgmt)
484                 return;
485
486         wpas_dbus_signal_blob_added(wpa_s, name);
487 }
488
489
490 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
491 {
492         if (wpa_s->p2p_mgmt)
493                 return;
494
495         wpas_dbus_signal_blob_removed(wpa_s, name);
496 }
497
498
499 void wpas_notify_debug_level_changed(struct wpa_global *global)
500 {
501         wpas_dbus_signal_debug_level_changed(global);
502 }
503
504
505 void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
506 {
507         wpas_dbus_signal_debug_timestamp_changed(global);
508 }
509
510
511 void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
512 {
513         wpas_dbus_signal_debug_show_keys_changed(global);
514 }
515
516
517 void wpas_notify_suspend(struct wpa_global *global)
518 {
519         struct wpa_supplicant *wpa_s;
520
521         os_get_time(&global->suspend_time);
522         wpa_printf(MSG_DEBUG, "System suspend notification");
523         for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
524                 wpa_drv_suspend(wpa_s);
525 }
526
527
528 void wpas_notify_resume(struct wpa_global *global)
529 {
530         struct os_time now;
531         int slept;
532         struct wpa_supplicant *wpa_s;
533
534         if (global->suspend_time.sec == 0)
535                 slept = -1;
536         else {
537                 os_get_time(&now);
538                 slept = now.sec - global->suspend_time.sec;
539         }
540         wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
541                    slept);
542
543         for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
544                 wpa_drv_resume(wpa_s);
545                 if (wpa_s->wpa_state == WPA_DISCONNECTED)
546                         wpa_supplicant_req_scan(wpa_s, 0, 100000);
547         }
548 }
549
550
551 #ifdef CONFIG_P2P
552
553 void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
554 {
555         /* Notify P2P find has stopped */
556         wpas_dbus_signal_p2p_find_stopped(wpa_s);
557 }
558
559
560 void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
561                                   const u8 *dev_addr, int new_device)
562 {
563         if (new_device) {
564                 /* Create the new peer object */
565                 wpas_dbus_register_peer(wpa_s, dev_addr);
566         }
567
568         /* Notify a new peer has been detected*/
569         wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
570 }
571
572
573 void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
574                                  const u8 *dev_addr)
575 {
576         wpas_dbus_unregister_peer(wpa_s, dev_addr);
577
578         /* Create signal on interface object*/
579         wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
580 }
581
582
583 void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
584                                    const struct wpa_ssid *ssid,
585                                    const char *role)
586 {
587         wpas_dbus_signal_p2p_group_removed(wpa_s, role);
588
589         wpas_dbus_unregister_p2p_group(wpa_s, ssid);
590 }
591
592
593 void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
594                                 const u8 *src, u16 dev_passwd_id, u8 go_intent)
595 {
596         wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
597 }
598
599
600 void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
601                                       struct p2p_go_neg_results *res)
602 {
603         wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
604 }
605
606
607 void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
608                                        int status, const u8 *bssid)
609 {
610         wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
611 }
612
613
614 void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
615                                 int freq, const u8 *sa, u8 dialog_token,
616                                 u16 update_indic, const u8 *tlvs,
617                                 size_t tlvs_len)
618 {
619         wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
620                                         update_indic, tlvs, tlvs_len);
621 }
622
623
624 void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
625                                  const u8 *sa, u16 update_indic,
626                                  const u8 *tlvs, size_t tlvs_len)
627 {
628         wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
629                                          tlvs, tlvs_len);
630 }
631
632
633 /**
634  * wpas_notify_p2p_provision_discovery - Notification of provision discovery
635  * @dev_addr: Who sent the request or responded to our request.
636  * @request: Will be 1 if request, 0 for response.
637  * @status: Valid only in case of response (0 in case of success)
638  * @config_methods: WPS config methods
639  * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
640  *
641  * This can be used to notify:
642  * - Requests or responses
643  * - Various config methods
644  * - Failure condition in case of response
645  */
646 void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
647                                          const u8 *dev_addr, int request,
648                                          enum p2p_prov_disc_status status,
649                                          u16 config_methods,
650                                          unsigned int generated_pin)
651 {
652         wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
653                                                  status, config_methods,
654                                                  generated_pin);
655 }
656
657
658 void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
659                                    struct wpa_ssid *ssid, int network_id,
660                                    int client)
661 {
662         /* Notify a group has been started */
663         wpas_dbus_register_p2p_group(wpa_s, ssid);
664
665         wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id);
666 }
667
668
669 void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
670                                              const char *reason)
671 {
672         /* Notify a group formation failed */
673         wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
674 }
675
676
677 void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
678                                 struct wps_event_fail *fail)
679 {
680         wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
681 }
682
683
684 void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
685                                          const u8 *sa, const u8 *go_dev_addr,
686                                          const u8 *bssid, int id, int op_freq)
687 {
688         /* Notify a P2P Invitation Request */
689         wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
690                                                  id, op_freq);
691 }
692
693 #endif /* CONFIG_P2P */
694
695
696 static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
697                                           const u8 *sta,
698                                           const u8 *p2p_dev_addr)
699 {
700 #ifdef CONFIG_P2P
701         wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
702
703         /*
704          * Create 'peer-joined' signal on group object -- will also
705          * check P2P itself.
706          */
707         if (p2p_dev_addr)
708                 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
709 #endif /* CONFIG_P2P */
710
711         /* Notify listeners a new station has been authorized */
712         wpas_dbus_signal_sta_authorized(wpa_s, sta);
713 }
714
715
716 static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
717                                             const u8 *sta,
718                                             const u8 *p2p_dev_addr)
719 {
720 #ifdef CONFIG_P2P
721         /*
722          * Create 'peer-disconnected' signal on group object if this
723          * is a P2P group.
724          */
725         if (p2p_dev_addr)
726                 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
727 #endif /* CONFIG_P2P */
728
729         /* Notify listeners a station has been deauthorized */
730         wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
731 }
732
733
734 void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
735                                 const u8 *mac_addr, int authorized,
736                                 const u8 *p2p_dev_addr)
737 {
738         if (authorized)
739                 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
740         else
741                 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
742 }
743
744
745 void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
746                                const char *subject, const char *altsubject[],
747                                int num_altsubject, const char *cert_hash,
748                                const struct wpabuf *cert)
749 {
750         wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
751                 "depth=%d subject='%s'%s%s",
752                 depth, subject, cert_hash ? " hash=" : "",
753                 cert_hash ? cert_hash : "");
754
755         if (cert) {
756                 char *cert_hex;
757                 size_t len = wpabuf_len(cert) * 2 + 1;
758                 cert_hex = os_malloc(len);
759                 if (cert_hex) {
760                         wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
761                                          wpabuf_len(cert));
762                         wpa_msg_ctrl(wpa_s, MSG_INFO,
763                                      WPA_EVENT_EAP_PEER_CERT
764                                      "depth=%d subject='%s' cert=%s",
765                                      depth, subject, cert_hex);
766                         os_free(cert_hex);
767                 }
768         }
769
770         if (altsubject) {
771                 int i;
772
773                 for (i = 0; i < num_altsubject; i++)
774                         wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
775                                 "depth=%d %s", depth, altsubject[i]);
776         }
777
778         /* notify the old DBus API */
779         wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
780                                                  cert_hash, cert);
781         /* notify the new DBus API */
782         wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
783                                        num_altsubject, cert_hash, cert);
784 }
785
786
787 void wpas_notify_preq(struct wpa_supplicant *wpa_s,
788                       const u8 *addr, const u8 *dst, const u8 *bssid,
789                       const u8 *ie, size_t ie_len, u32 ssi_signal)
790 {
791 #ifdef CONFIG_AP
792         wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
793 #endif /* CONFIG_AP */
794 }
795
796
797 void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
798                             const char *parameter)
799 {
800         wpas_dbus_signal_eap_status(wpa_s, status, parameter);
801         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
802                      "status='%s' parameter='%s'",
803                      status, parameter);
804 }
805
806
807 void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
808                                            struct wpa_ssid *ssid)
809 {
810         if (wpa_s->current_ssid != ssid)
811                 return;
812
813         wpa_dbg(wpa_s, MSG_DEBUG,
814                 "Network bssid config changed for the current network - within-ESS roaming %s",
815                 ssid->bssid_set ? "disabled" : "enabled");
816
817         wpa_drv_roaming(wpa_s, !ssid->bssid_set,
818                         ssid->bssid_set ? ssid->bssid : NULL);
819 }
820
821
822 void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
823                                       struct wpa_ssid *ssid)
824 {
825 #ifdef CONFIG_P2P
826         if (ssid->disabled == 2) {
827                 /* Changed from normal network profile to persistent group */
828                 ssid->disabled = 0;
829                 wpas_dbus_unregister_network(wpa_s, ssid->id);
830                 ssid->disabled = 2;
831                 ssid->p2p_persistent_group = 1;
832                 wpas_dbus_register_persistent_group(wpa_s, ssid);
833         } else {
834                 /* Changed from persistent group to normal network profile */
835                 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
836                 ssid->p2p_persistent_group = 0;
837                 wpas_dbus_register_network(wpa_s, ssid);
838         }
839 #endif /* CONFIG_P2P */
840 }