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