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