blob: 536f3e6a91644b909a44f61cf3255c1aa33b6ba3 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * wpa_supplicant - Event notifications
3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
4 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
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"
Dmitry Shmidte4663042016-04-04 10:07:49 -070016#include "binder/binder.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070017#include "dbus/dbus_common.h"
18#include "dbus/dbus_old.h"
19#include "dbus/dbus_new.h"
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080020#include "rsn_supp/wpa.h"
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080021#include "fst/fst.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070022#include "driver_i.h"
23#include "scan.h"
24#include "p2p_supplicant.h"
25#include "sme.h"
26#include "notify.h"
27
28int wpas_notify_supplicant_initialized(struct wpa_global *global)
29{
30#ifdef CONFIG_DBUS
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_DBUS */
37
Dmitry Shmidte4663042016-04-04 10:07:49 -070038#ifdef CONFIG_BINDER
39 global->binder = wpas_binder_init(global);
40 if (!global->binder)
41 return -1;
42#endif /* CONFIG_BINDER */
43
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070044 return 0;
45}
46
47
48void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
49{
50#ifdef CONFIG_DBUS
51 if (global->dbus)
52 wpas_dbus_deinit(global->dbus);
53#endif /* CONFIG_DBUS */
Dmitry Shmidte4663042016-04-04 10:07:49 -070054
55#ifdef CONFIG_BINDER
56 if (global->binder)
57 wpas_binder_deinit(global->binder);
58#endif /* CONFIG_BINDER */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070059}
60
61
62int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
63{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080064 if (wpa_s->p2p_mgmt)
65 return 0;
66
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070067 if (wpas_dbus_register_iface(wpa_s))
68 return -1;
69
70 if (wpas_dbus_register_interface(wpa_s))
71 return -1;
72
Roshan Pius54e763a2016-07-06 15:41:53 -070073 if (wpas_binder_register_interface(wpa_s))
74 return -1;
75
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070076 return 0;
77}
78
79
80void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
81{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080082 if (wpa_s->p2p_mgmt)
83 return;
84
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070085 /* unregister interface in old DBus ctrl iface */
86 wpas_dbus_unregister_iface(wpa_s);
87
88 /* unregister interface in new DBus ctrl iface */
89 wpas_dbus_unregister_interface(wpa_s);
Roshan Pius54e763a2016-07-06 15:41:53 -070090
91 wpas_binder_unregister_interface(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070092}
93
94
95void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
96 enum wpa_states new_state,
97 enum wpa_states old_state)
98{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080099 if (wpa_s->p2p_mgmt)
100 return;
101
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700102 /* notify the old DBus API */
103 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
104 old_state);
105
106 /* notify the new DBus API */
107 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
108
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800109#ifdef CONFIG_FST
110 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
111 if (new_state == WPA_COMPLETED)
112 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
113 else if (old_state >= WPA_ASSOCIATED &&
114 new_state < WPA_ASSOCIATED)
115 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
116 }
117#endif /* CONFIG_FST */
118
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700119 if (new_state == WPA_COMPLETED)
120 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700121 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700122 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700123
124 sme_state_changed(wpa_s);
125
126#ifdef ANDROID
127 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700128 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700129 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700130 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700131 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700132 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
133 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800134 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700135#endif /* ANDROID */
136}
137
138
Dmitry Shmidt04949592012-07-19 12:16:46 -0700139void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
140{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800141 if (wpa_s->p2p_mgmt)
142 return;
143
Dmitry Shmidt04949592012-07-19 12:16:46 -0700144 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
145}
146
147
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800148void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
149{
150 if (wpa_s->p2p_mgmt)
151 return;
152
153 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
154}
155
156
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700157void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
158{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800159 if (wpa_s->p2p_mgmt)
160 return;
161
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700162 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
163}
164
165
166void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
167{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800168 if (wpa_s->p2p_mgmt)
169 return;
170
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700171 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
172}
173
174
175void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
176{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800177 if (wpa_s->p2p_mgmt)
178 return;
179
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700180 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
181}
182
183
184void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
185{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800186 if (wpa_s->p2p_mgmt)
187 return;
188
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700189 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
190}
191
192
193void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
194 struct wpa_ssid *ssid)
195{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800196 if (wpa_s->p2p_mgmt)
197 return;
198
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700199 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
200}
201
202
203void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
204 struct wpa_ssid *ssid)
205{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800206 if (wpa_s->p2p_mgmt)
207 return;
208
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700209 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
210}
211
212
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800213void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
214 struct wpa_ssid *ssid,
215 enum wpa_ctrl_req_type rtype,
216 const char *default_txt)
217{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800218 if (wpa_s->p2p_mgmt)
219 return;
220
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800221 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
222}
223
224
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700225void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
226{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800227 if (wpa_s->p2p_mgmt)
228 return;
229
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700230 /* notify the old DBus API */
231 wpa_supplicant_dbus_notify_scanning(wpa_s);
232
233 /* notify the new DBus API */
234 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
235}
236
237
238void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
239{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800240 if (wpa_s->p2p_mgmt)
241 return;
242
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700243 wpas_dbus_signal_scan_done(wpa_s, success);
244}
245
246
247void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
248{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800249 if (wpa_s->p2p_mgmt)
250 return;
251
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700252 /* notify the old DBus API */
253 wpa_supplicant_dbus_notify_scan_results(wpa_s);
254
255 wpas_wps_notify_scan_results(wpa_s);
256}
257
258
259void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
260 const struct wps_credential *cred)
261{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800262 if (wpa_s->p2p_mgmt)
263 return;
264
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700265#ifdef CONFIG_WPS
266 /* notify the old DBus API */
267 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
268 /* notify the new DBus API */
269 wpas_dbus_signal_wps_cred(wpa_s, cred);
270#endif /* CONFIG_WPS */
271}
272
273
274void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
275 struct wps_event_m2d *m2d)
276{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800277 if (wpa_s->p2p_mgmt)
278 return;
279
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700280#ifdef CONFIG_WPS
281 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
282#endif /* CONFIG_WPS */
283}
284
285
286void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
287 struct wps_event_fail *fail)
288{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800289 if (wpa_s->p2p_mgmt)
290 return;
291
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700292#ifdef CONFIG_WPS
293 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
294#endif /* CONFIG_WPS */
295}
296
297
298void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
299{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800300 if (wpa_s->p2p_mgmt)
301 return;
302
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700303#ifdef CONFIG_WPS
304 wpas_dbus_signal_wps_event_success(wpa_s);
305#endif /* CONFIG_WPS */
306}
307
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700308void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
309{
310 if (wpa_s->p2p_mgmt)
311 return;
312
313#ifdef CONFIG_WPS
314 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
315#endif /* CONFIG_WPS */
316}
317
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700318
319void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
320 struct wpa_ssid *ssid)
321{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800322 if (wpa_s->p2p_mgmt)
323 return;
324
Jouni Malinen75ecf522011-06-27 15:19:46 -0700325 /*
326 * Networks objects created during any P2P activities should not be
327 * exposed out. They might/will confuse certain non-P2P aware
328 * applications since these network objects won't behave like
329 * regular ones.
330 */
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700331 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700332 wpas_dbus_register_network(wpa_s, ssid);
333}
334
335
336void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
337 struct wpa_ssid *ssid)
338{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700339#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700340 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700341#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700342}
343
344
345void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
346 struct wpa_ssid *ssid)
347{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700348#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700349 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700350#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700351}
352
353
354void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
355 struct wpa_ssid *ssid)
356{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800357 if (wpa_s->next_ssid == ssid)
358 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800359 if (wpa_s->wpa)
360 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700361 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
362 !wpa_s->p2p_mgmt)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700363 wpas_dbus_unregister_network(wpa_s, ssid->id);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800364 if (network_is_persistent_group(ssid))
365 wpas_notify_persistent_group_removed(wpa_s, ssid);
366
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800367 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700368}
369
370
371void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
372 u8 bssid[], unsigned int id)
373{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800374 if (wpa_s->p2p_mgmt)
375 return;
376
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700377 wpas_dbus_register_bss(wpa_s, bssid, id);
378 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
379 id, MAC2STR(bssid));
380}
381
382
383void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
384 u8 bssid[], unsigned int id)
385{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800386 if (wpa_s->p2p_mgmt)
387 return;
388
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700389 wpas_dbus_unregister_bss(wpa_s, bssid, id);
390 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
391 id, MAC2STR(bssid));
392}
393
394
395void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
396 unsigned int id)
397{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800398 if (wpa_s->p2p_mgmt)
399 return;
400
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700401 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
402}
403
404
405void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
406 unsigned int id)
407{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800408 if (wpa_s->p2p_mgmt)
409 return;
410
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700411 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
412 id);
413}
414
415
416void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
417 unsigned int id)
418{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800419 if (wpa_s->p2p_mgmt)
420 return;
421
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700422 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
423 id);
424}
425
426
427void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
428 unsigned int id)
429{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800430 if (wpa_s->p2p_mgmt)
431 return;
432
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700433 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
434}
435
436
437void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
438 unsigned int id)
439{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800440 if (wpa_s->p2p_mgmt)
441 return;
442
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700443 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
444}
445
446
447void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
448 unsigned int id)
449{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800450 if (wpa_s->p2p_mgmt)
451 return;
452
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700453 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
454}
455
456
457void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
458 unsigned int id)
459{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800460 if (wpa_s->p2p_mgmt)
461 return;
462
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800463#ifdef CONFIG_WPS
464 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
465#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700466}
467
468
469void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
470 unsigned int id)
471{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800472 if (wpa_s->p2p_mgmt)
473 return;
474
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700475 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
476}
477
478
479void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
480 unsigned int id)
481{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800482 if (wpa_s->p2p_mgmt)
483 return;
484
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700485 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
486}
487
488
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700489void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
490{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800491 if (wpa_s->p2p_mgmt)
492 return;
493
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700494 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
495}
496
497
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700498void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
499{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800500 if (wpa_s->p2p_mgmt)
501 return;
502
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700503 wpas_dbus_signal_blob_added(wpa_s, name);
504}
505
506
507void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
508{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800509 if (wpa_s->p2p_mgmt)
510 return;
511
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700512 wpas_dbus_signal_blob_removed(wpa_s, name);
513}
514
515
516void wpas_notify_debug_level_changed(struct wpa_global *global)
517{
518 wpas_dbus_signal_debug_level_changed(global);
519}
520
521
522void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
523{
524 wpas_dbus_signal_debug_timestamp_changed(global);
525}
526
527
528void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
529{
530 wpas_dbus_signal_debug_show_keys_changed(global);
531}
532
533
534void wpas_notify_suspend(struct wpa_global *global)
535{
536 struct wpa_supplicant *wpa_s;
537
538 os_get_time(&global->suspend_time);
539 wpa_printf(MSG_DEBUG, "System suspend notification");
540 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
541 wpa_drv_suspend(wpa_s);
542}
543
544
545void wpas_notify_resume(struct wpa_global *global)
546{
547 struct os_time now;
548 int slept;
549 struct wpa_supplicant *wpa_s;
550
551 if (global->suspend_time.sec == 0)
552 slept = -1;
553 else {
554 os_get_time(&now);
555 slept = now.sec - global->suspend_time.sec;
556 }
557 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
558 slept);
559
560 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
561 wpa_drv_resume(wpa_s);
562 if (wpa_s->wpa_state == WPA_DISCONNECTED)
563 wpa_supplicant_req_scan(wpa_s, 0, 100000);
564 }
565}
566
567
568#ifdef CONFIG_P2P
569
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700570void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
571{
572 /* Notify P2P find has stopped */
573 wpas_dbus_signal_p2p_find_stopped(wpa_s);
574}
575
576
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700577void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
578 const u8 *dev_addr, int new_device)
579{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700580 if (new_device) {
581 /* Create the new peer object */
582 wpas_dbus_register_peer(wpa_s, dev_addr);
583 }
584
585 /* Notify a new peer has been detected*/
586 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700587}
588
589
590void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
591 const u8 *dev_addr)
592{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700593 wpas_dbus_unregister_peer(wpa_s, dev_addr);
594
595 /* Create signal on interface object*/
596 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700597}
598
599
600void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
601 const struct wpa_ssid *ssid,
602 const char *role)
603{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700604 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700605
606 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700607}
608
609
610void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700611 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700612{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700613 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700614}
615
616
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800617void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
618 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700619{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800620 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700621}
622
623
624void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
625 int status, const u8 *bssid)
626{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700627 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700628}
629
630
631void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
632 int freq, const u8 *sa, u8 dialog_token,
633 u16 update_indic, const u8 *tlvs,
634 size_t tlvs_len)
635{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700636 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
637 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700638}
639
640
641void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
642 const u8 *sa, u16 update_indic,
643 const u8 *tlvs, size_t tlvs_len)
644{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700645 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
646 tlvs, tlvs_len);
647}
648
649
650/**
651 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
652 * @dev_addr: Who sent the request or responded to our request.
653 * @request: Will be 1 if request, 0 for response.
654 * @status: Valid only in case of response (0 in case of success)
655 * @config_methods: WPS config methods
656 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
657 *
658 * This can be used to notify:
659 * - Requests or responses
660 * - Various config methods
661 * - Failure condition in case of response
662 */
663void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
664 const u8 *dev_addr, int request,
665 enum p2p_prov_disc_status status,
666 u16 config_methods,
667 unsigned int generated_pin)
668{
669 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
670 status, config_methods,
671 generated_pin);
672}
673
674
675void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700676 struct wpa_ssid *ssid, int persistent,
Jouni Malinen75ecf522011-06-27 15:19:46 -0700677 int client)
678{
679 /* Notify a group has been started */
680 wpas_dbus_register_p2p_group(wpa_s, ssid);
681
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700682 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700683}
684
685
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800686void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
687 const char *reason)
688{
689 /* Notify a group formation failed */
690 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
691}
692
693
Jouni Malinen75ecf522011-06-27 15:19:46 -0700694void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
695 struct wps_event_fail *fail)
696{
697 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700698}
699
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800700
701void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
702 const u8 *sa, const u8 *go_dev_addr,
703 const u8 *bssid, int id, int op_freq)
704{
705 /* Notify a P2P Invitation Request */
706 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
707 id, op_freq);
708}
709
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700710#endif /* CONFIG_P2P */
711
712
713static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800714 const u8 *sta,
715 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700716{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700717#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800718 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
719
Jouni Malinen75ecf522011-06-27 15:19:46 -0700720 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700721 * Create 'peer-joined' signal on group object -- will also
722 * check P2P itself.
723 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800724 if (p2p_dev_addr)
725 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700726#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700727
728 /* Notify listeners a new station has been authorized */
729 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700730}
731
732
733static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700734 const u8 *sta,
735 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700736{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700737#ifdef CONFIG_P2P
738 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700739 * Create 'peer-disconnected' signal on group object if this
740 * is a P2P group.
741 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800742 if (p2p_dev_addr)
743 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700744#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700745
746 /* Notify listeners a station has been deauthorized */
747 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700748}
749
750
751void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800752 const u8 *mac_addr, int authorized,
753 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700754{
755 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800756 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700757 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700758 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700759}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700760
761
762void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800763 const char *subject, const char *altsubject[],
764 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700765 const struct wpabuf *cert)
766{
767 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
768 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800769 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700770 cert_hash ? cert_hash : "");
771
772 if (cert) {
773 char *cert_hex;
774 size_t len = wpabuf_len(cert) * 2 + 1;
775 cert_hex = os_malloc(len);
776 if (cert_hex) {
777 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
778 wpabuf_len(cert));
779 wpa_msg_ctrl(wpa_s, MSG_INFO,
780 WPA_EVENT_EAP_PEER_CERT
781 "depth=%d subject='%s' cert=%s",
782 depth, subject, cert_hex);
783 os_free(cert_hex);
784 }
785 }
786
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800787 if (altsubject) {
788 int i;
789
790 for (i = 0; i < num_altsubject; i++)
791 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
792 "depth=%d %s", depth, altsubject[i]);
793 }
794
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700795 /* notify the old DBus API */
796 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
797 cert_hash, cert);
798 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800799 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
800 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700801}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700802
803
804void wpas_notify_preq(struct wpa_supplicant *wpa_s,
805 const u8 *addr, const u8 *dst, const u8 *bssid,
806 const u8 *ie, size_t ie_len, u32 ssi_signal)
807{
808#ifdef CONFIG_AP
809 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
810#endif /* CONFIG_AP */
811}
812
813
814void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
815 const char *parameter)
816{
817 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700818 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
819 "status='%s' parameter='%s'",
820 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700821}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700822
823
824void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
825 struct wpa_ssid *ssid)
826{
827 if (wpa_s->current_ssid != ssid)
828 return;
829
830 wpa_dbg(wpa_s, MSG_DEBUG,
831 "Network bssid config changed for the current network - within-ESS roaming %s",
832 ssid->bssid_set ? "disabled" : "enabled");
833
834 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
835 ssid->bssid_set ? ssid->bssid : NULL);
836}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800837
838
839void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
840 struct wpa_ssid *ssid)
841{
842#ifdef CONFIG_P2P
843 if (ssid->disabled == 2) {
844 /* Changed from normal network profile to persistent group */
845 ssid->disabled = 0;
846 wpas_dbus_unregister_network(wpa_s, ssid->id);
847 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700848 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800849 wpas_dbus_register_persistent_group(wpa_s, ssid);
850 } else {
851 /* Changed from persistent group to normal network profile */
852 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700853 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800854 wpas_dbus_register_network(wpa_s, ssid);
855 }
856#endif /* CONFIG_P2P */
857}