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