blob: 61469dc67d3c9fbbaf9539e7839c99f2305f103c [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 */
Roshan Piuse8d0d162016-08-01 13:09:26 -0700136
137 wpas_binder_notify_state_changed(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700138}
139
140
Dmitry Shmidt04949592012-07-19 12:16:46 -0700141void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
142{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800143 if (wpa_s->p2p_mgmt)
144 return;
145
Dmitry Shmidt04949592012-07-19 12:16:46 -0700146 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
147}
148
149
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800150void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
151{
152 if (wpa_s->p2p_mgmt)
153 return;
154
155 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
156}
157
158
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700159void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
160{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800161 if (wpa_s->p2p_mgmt)
162 return;
163
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700164 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
165}
166
167
168void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
169{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800170 if (wpa_s->p2p_mgmt)
171 return;
172
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700173 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
174}
175
176
177void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
178{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800179 if (wpa_s->p2p_mgmt)
180 return;
181
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700182 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
183}
184
185
186void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
187{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800188 if (wpa_s->p2p_mgmt)
189 return;
190
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700191 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
192}
193
194
195void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
196 struct wpa_ssid *ssid)
197{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800198 if (wpa_s->p2p_mgmt)
199 return;
200
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700201 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
202}
203
204
205void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
206 struct wpa_ssid *ssid)
207{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800208 if (wpa_s->p2p_mgmt)
209 return;
210
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700211 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
212}
213
214
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800215void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
216 struct wpa_ssid *ssid,
217 enum wpa_ctrl_req_type rtype,
218 const char *default_txt)
219{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800220 if (wpa_s->p2p_mgmt)
221 return;
222
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800223 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
224}
225
226
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700227void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
228{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800229 if (wpa_s->p2p_mgmt)
230 return;
231
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700232 /* notify the old DBus API */
233 wpa_supplicant_dbus_notify_scanning(wpa_s);
234
235 /* notify the new DBus API */
236 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
237}
238
239
240void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
241{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800242 if (wpa_s->p2p_mgmt)
243 return;
244
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700245 wpas_dbus_signal_scan_done(wpa_s, success);
246}
247
248
249void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
250{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800251 if (wpa_s->p2p_mgmt)
252 return;
253
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700254 /* notify the old DBus API */
255 wpa_supplicant_dbus_notify_scan_results(wpa_s);
256
257 wpas_wps_notify_scan_results(wpa_s);
258}
259
260
261void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
262 const struct wps_credential *cred)
263{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800264 if (wpa_s->p2p_mgmt)
265 return;
266
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700267#ifdef CONFIG_WPS
268 /* notify the old DBus API */
269 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
270 /* notify the new DBus API */
271 wpas_dbus_signal_wps_cred(wpa_s, cred);
272#endif /* CONFIG_WPS */
273}
274
275
276void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
277 struct wps_event_m2d *m2d)
278{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800279 if (wpa_s->p2p_mgmt)
280 return;
281
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700282#ifdef CONFIG_WPS
283 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
284#endif /* CONFIG_WPS */
285}
286
287
288void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
289 struct wps_event_fail *fail)
290{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800291 if (wpa_s->p2p_mgmt)
292 return;
293
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700294#ifdef CONFIG_WPS
295 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
296#endif /* CONFIG_WPS */
297}
298
299
300void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
301{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800302 if (wpa_s->p2p_mgmt)
303 return;
304
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700305#ifdef CONFIG_WPS
306 wpas_dbus_signal_wps_event_success(wpa_s);
307#endif /* CONFIG_WPS */
308}
309
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700310void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
311{
312 if (wpa_s->p2p_mgmt)
313 return;
314
315#ifdef CONFIG_WPS
316 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
317#endif /* CONFIG_WPS */
318}
319
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700320
321void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
322 struct wpa_ssid *ssid)
323{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800324 if (wpa_s->p2p_mgmt)
325 return;
326
Jouni Malinen75ecf522011-06-27 15:19:46 -0700327 /*
328 * Networks objects created during any P2P activities should not be
329 * exposed out. They might/will confuse certain non-P2P aware
330 * applications since these network objects won't behave like
331 * regular ones.
332 */
Roshan Piusd3854452016-07-07 16:46:41 -0700333 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700334 wpas_dbus_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700335 wpas_binder_register_network(wpa_s, ssid);
336 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700337}
338
339
340void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
341 struct wpa_ssid *ssid)
342{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700343#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700344 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700345#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700346}
347
348
349void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
350 struct wpa_ssid *ssid)
351{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700352#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700353 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700354#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700355}
356
357
358void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
359 struct wpa_ssid *ssid)
360{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800361 if (wpa_s->next_ssid == ssid)
362 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800363 if (wpa_s->wpa)
364 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700365 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700366 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700367 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Piusd3854452016-07-07 16:46:41 -0700368 wpas_binder_unregister_network(wpa_s, ssid);
369 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800370 if (network_is_persistent_group(ssid))
371 wpas_notify_persistent_group_removed(wpa_s, ssid);
372
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800373 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700374}
375
376
377void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
378 u8 bssid[], unsigned int id)
379{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800380 if (wpa_s->p2p_mgmt)
381 return;
382
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700383 wpas_dbus_register_bss(wpa_s, bssid, id);
384 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
385 id, MAC2STR(bssid));
386}
387
388
389void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
390 u8 bssid[], unsigned int id)
391{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800392 if (wpa_s->p2p_mgmt)
393 return;
394
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700395 wpas_dbus_unregister_bss(wpa_s, bssid, id);
396 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
397 id, MAC2STR(bssid));
398}
399
400
401void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
402 unsigned int id)
403{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800404 if (wpa_s->p2p_mgmt)
405 return;
406
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700407 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
408}
409
410
411void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
412 unsigned int id)
413{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800414 if (wpa_s->p2p_mgmt)
415 return;
416
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700417 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
418 id);
419}
420
421
422void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
423 unsigned int id)
424{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800425 if (wpa_s->p2p_mgmt)
426 return;
427
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700428 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
429 id);
430}
431
432
433void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
434 unsigned int id)
435{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800436 if (wpa_s->p2p_mgmt)
437 return;
438
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700439 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
440}
441
442
443void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
444 unsigned int id)
445{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800446 if (wpa_s->p2p_mgmt)
447 return;
448
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700449 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
450}
451
452
453void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
454 unsigned int id)
455{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800456 if (wpa_s->p2p_mgmt)
457 return;
458
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700459 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
460}
461
462
463void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
464 unsigned int id)
465{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800466 if (wpa_s->p2p_mgmt)
467 return;
468
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800469#ifdef CONFIG_WPS
470 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
471#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700472}
473
474
475void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
476 unsigned int id)
477{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800478 if (wpa_s->p2p_mgmt)
479 return;
480
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700481 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
482}
483
484
485void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
486 unsigned int id)
487{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800488 if (wpa_s->p2p_mgmt)
489 return;
490
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700491 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
492}
493
494
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700495void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
496{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800497 if (wpa_s->p2p_mgmt)
498 return;
499
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700500 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
501}
502
503
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700504void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
505{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800506 if (wpa_s->p2p_mgmt)
507 return;
508
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700509 wpas_dbus_signal_blob_added(wpa_s, name);
510}
511
512
513void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
514{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800515 if (wpa_s->p2p_mgmt)
516 return;
517
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700518 wpas_dbus_signal_blob_removed(wpa_s, name);
519}
520
521
522void wpas_notify_debug_level_changed(struct wpa_global *global)
523{
524 wpas_dbus_signal_debug_level_changed(global);
525}
526
527
528void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
529{
530 wpas_dbus_signal_debug_timestamp_changed(global);
531}
532
533
534void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
535{
536 wpas_dbus_signal_debug_show_keys_changed(global);
537}
538
539
540void wpas_notify_suspend(struct wpa_global *global)
541{
542 struct wpa_supplicant *wpa_s;
543
544 os_get_time(&global->suspend_time);
545 wpa_printf(MSG_DEBUG, "System suspend notification");
546 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
547 wpa_drv_suspend(wpa_s);
548}
549
550
551void wpas_notify_resume(struct wpa_global *global)
552{
553 struct os_time now;
554 int slept;
555 struct wpa_supplicant *wpa_s;
556
557 if (global->suspend_time.sec == 0)
558 slept = -1;
559 else {
560 os_get_time(&now);
561 slept = now.sec - global->suspend_time.sec;
562 }
563 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
564 slept);
565
566 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
567 wpa_drv_resume(wpa_s);
568 if (wpa_s->wpa_state == WPA_DISCONNECTED)
569 wpa_supplicant_req_scan(wpa_s, 0, 100000);
570 }
571}
572
573
574#ifdef CONFIG_P2P
575
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700576void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
577{
578 /* Notify P2P find has stopped */
579 wpas_dbus_signal_p2p_find_stopped(wpa_s);
580}
581
582
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700583void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
584 const u8 *dev_addr, int new_device)
585{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700586 if (new_device) {
587 /* Create the new peer object */
588 wpas_dbus_register_peer(wpa_s, dev_addr);
589 }
590
591 /* Notify a new peer has been detected*/
592 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700593}
594
595
596void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
597 const u8 *dev_addr)
598{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700599 wpas_dbus_unregister_peer(wpa_s, dev_addr);
600
601 /* Create signal on interface object*/
602 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700603}
604
605
606void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
607 const struct wpa_ssid *ssid,
608 const char *role)
609{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700610 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700611
612 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700613}
614
615
616void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700617 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700618{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700619 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700620}
621
622
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800623void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
624 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700625{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800626 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700627}
628
629
630void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
631 int status, const u8 *bssid)
632{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700633 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700634}
635
636
637void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
638 int freq, const u8 *sa, u8 dialog_token,
639 u16 update_indic, const u8 *tlvs,
640 size_t tlvs_len)
641{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700642 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
643 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700644}
645
646
647void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
648 const u8 *sa, u16 update_indic,
649 const u8 *tlvs, size_t tlvs_len)
650{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700651 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
652 tlvs, tlvs_len);
653}
654
655
656/**
657 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
658 * @dev_addr: Who sent the request or responded to our request.
659 * @request: Will be 1 if request, 0 for response.
660 * @status: Valid only in case of response (0 in case of success)
661 * @config_methods: WPS config methods
662 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
663 *
664 * This can be used to notify:
665 * - Requests or responses
666 * - Various config methods
667 * - Failure condition in case of response
668 */
669void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
670 const u8 *dev_addr, int request,
671 enum p2p_prov_disc_status status,
672 u16 config_methods,
673 unsigned int generated_pin)
674{
675 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
676 status, config_methods,
677 generated_pin);
678}
679
680
681void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700682 struct wpa_ssid *ssid, int persistent,
Jouni Malinen75ecf522011-06-27 15:19:46 -0700683 int client)
684{
685 /* Notify a group has been started */
686 wpas_dbus_register_p2p_group(wpa_s, ssid);
687
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700688 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700689}
690
691
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800692void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
693 const char *reason)
694{
695 /* Notify a group formation failed */
696 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
697}
698
699
Jouni Malinen75ecf522011-06-27 15:19:46 -0700700void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
701 struct wps_event_fail *fail)
702{
703 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700704}
705
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800706
707void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
708 const u8 *sa, const u8 *go_dev_addr,
709 const u8 *bssid, int id, int op_freq)
710{
711 /* Notify a P2P Invitation Request */
712 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
713 id, op_freq);
714}
715
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700716#endif /* CONFIG_P2P */
717
718
719static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800720 const u8 *sta,
721 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700722{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700723#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800724 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
725
Jouni Malinen75ecf522011-06-27 15:19:46 -0700726 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700727 * Create 'peer-joined' signal on group object -- will also
728 * check P2P itself.
729 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800730 if (p2p_dev_addr)
731 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700732#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700733
734 /* Notify listeners a new station has been authorized */
735 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700736}
737
738
739static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700740 const u8 *sta,
741 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700742{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700743#ifdef CONFIG_P2P
744 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700745 * Create 'peer-disconnected' signal on group object if this
746 * is a P2P group.
747 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800748 if (p2p_dev_addr)
749 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700750#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700751
752 /* Notify listeners a station has been deauthorized */
753 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700754}
755
756
757void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800758 const u8 *mac_addr, int authorized,
759 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700760{
761 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800762 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700763 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700764 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700765}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700766
767
768void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800769 const char *subject, const char *altsubject[],
770 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700771 const struct wpabuf *cert)
772{
773 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
774 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800775 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700776 cert_hash ? cert_hash : "");
777
778 if (cert) {
779 char *cert_hex;
780 size_t len = wpabuf_len(cert) * 2 + 1;
781 cert_hex = os_malloc(len);
782 if (cert_hex) {
783 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
784 wpabuf_len(cert));
785 wpa_msg_ctrl(wpa_s, MSG_INFO,
786 WPA_EVENT_EAP_PEER_CERT
787 "depth=%d subject='%s' cert=%s",
788 depth, subject, cert_hex);
789 os_free(cert_hex);
790 }
791 }
792
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800793 if (altsubject) {
794 int i;
795
796 for (i = 0; i < num_altsubject; i++)
797 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
798 "depth=%d %s", depth, altsubject[i]);
799 }
800
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700801 /* notify the old DBus API */
802 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
803 cert_hash, cert);
804 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800805 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
806 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700807}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700808
809
810void wpas_notify_preq(struct wpa_supplicant *wpa_s,
811 const u8 *addr, const u8 *dst, const u8 *bssid,
812 const u8 *ie, size_t ie_len, u32 ssi_signal)
813{
814#ifdef CONFIG_AP
815 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
816#endif /* CONFIG_AP */
817}
818
819
820void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
821 const char *parameter)
822{
823 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700824 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
825 "status='%s' parameter='%s'",
826 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700827}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700828
829
830void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
831 struct wpa_ssid *ssid)
832{
833 if (wpa_s->current_ssid != ssid)
834 return;
835
836 wpa_dbg(wpa_s, MSG_DEBUG,
837 "Network bssid config changed for the current network - within-ESS roaming %s",
838 ssid->bssid_set ? "disabled" : "enabled");
839
840 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
841 ssid->bssid_set ? ssid->bssid : NULL);
842}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800843
844
845void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
846 struct wpa_ssid *ssid)
847{
848#ifdef CONFIG_P2P
849 if (ssid->disabled == 2) {
850 /* Changed from normal network profile to persistent group */
851 ssid->disabled = 0;
852 wpas_dbus_unregister_network(wpa_s, ssid->id);
853 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700854 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800855 wpas_dbus_register_persistent_group(wpa_s, ssid);
856 } else {
857 /* Changed from persistent group to normal network profile */
858 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700859 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800860 wpas_dbus_register_network(wpa_s, ssid);
861 }
862#endif /* CONFIG_P2P */
863}