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