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