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