blob: abe6353ad4498dea3e5c3e481e2e6bce7b4f0793 [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"
16#include "dbus/dbus_common.h"
17#include "dbus/dbus_old.h"
18#include "dbus/dbus_new.h"
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080019#include "rsn_supp/wpa.h"
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080020#include "fst/fst.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070021#include "driver_i.h"
22#include "scan.h"
23#include "p2p_supplicant.h"
24#include "sme.h"
25#include "notify.h"
Roshan Pius9322a342016-12-12 14:45:02 -080026#include "hidl/hidl.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070027
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
Roshan Pius57ffbcf2016-09-27 09:12:46 -070038#ifdef CONFIG_HIDL
39 global->hidl = wpas_hidl_init(global);
40 if (!global->hidl)
Dmitry Shmidte4663042016-04-04 10:07:49 -070041 return -1;
Roshan Pius57ffbcf2016-09-27 09:12:46 -070042#endif /* CONFIG_HIDL */
Dmitry Shmidte4663042016-04-04 10:07:49 -070043
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
Roshan Pius57ffbcf2016-09-27 09:12:46 -070055#ifdef CONFIG_HIDL
56 if (global->hidl)
57 wpas_hidl_deinit(global->hidl);
58#endif /* CONFIG_HIDL */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070059}
60
61
62int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
63{
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080064 if (!wpa_s->p2p_mgmt) {
65 if (wpas_dbus_register_iface(wpa_s))
66 return -1;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080067
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080068 if (wpas_dbus_register_interface(wpa_s))
69 return -1;
70 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070071
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080072 /* HIDL interface wants to keep track of the P2P mgmt iface. */
Roshan Pius57ffbcf2016-09-27 09:12:46 -070073 if (wpas_hidl_register_interface(wpa_s))
Roshan Pius54e763a2016-07-06 15:41:53 -070074 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{
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080082 if (!wpa_s->p2p_mgmt) {
83 /* unregister interface in old DBus ctrl iface */
84 wpas_dbus_unregister_iface(wpa_s);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080085
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080086 /* unregister interface in new DBus ctrl iface */
87 wpas_dbus_unregister_interface(wpa_s);
88 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070089
Roshan Piusd6d8b8d2016-11-08 14:45:26 -080090 /* HIDL interface wants to keep track of the P2P mgmt iface. */
Roshan Pius57ffbcf2016-09-27 09:12:46 -070091 wpas_hidl_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
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700137 wpas_hidl_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);
Roshan Pius65628ce2016-08-17 13:10:23 -0700224
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700225 wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800226}
227
228
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700229void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
230{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800231 if (wpa_s->p2p_mgmt)
232 return;
233
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700234 /* notify the old DBus API */
235 wpa_supplicant_dbus_notify_scanning(wpa_s);
236
237 /* notify the new DBus API */
238 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
239}
240
241
242void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
243{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800244 if (wpa_s->p2p_mgmt)
245 return;
246
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700247 wpas_dbus_signal_scan_done(wpa_s, success);
248}
249
250
251void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
252{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800253 if (wpa_s->p2p_mgmt)
254 return;
255
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700256 /* notify the old DBus API */
257 wpa_supplicant_dbus_notify_scan_results(wpa_s);
258
259 wpas_wps_notify_scan_results(wpa_s);
260}
261
262
263void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
264 const struct wps_credential *cred)
265{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800266 if (wpa_s->p2p_mgmt)
267 return;
268
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700269#ifdef CONFIG_WPS
270 /* notify the old DBus API */
271 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
272 /* notify the new DBus API */
273 wpas_dbus_signal_wps_cred(wpa_s, cred);
274#endif /* CONFIG_WPS */
275}
276
277
278void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
279 struct wps_event_m2d *m2d)
280{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800281 if (wpa_s->p2p_mgmt)
282 return;
283
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700284#ifdef CONFIG_WPS
285 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
286#endif /* CONFIG_WPS */
287}
288
289
290void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
291 struct wps_event_fail *fail)
292{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800293 if (wpa_s->p2p_mgmt)
294 return;
295
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700296#ifdef CONFIG_WPS
297 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
298#endif /* CONFIG_WPS */
299}
300
301
302void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
303{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800304 if (wpa_s->p2p_mgmt)
305 return;
306
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700307#ifdef CONFIG_WPS
308 wpas_dbus_signal_wps_event_success(wpa_s);
309#endif /* CONFIG_WPS */
310}
311
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700312void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
313{
314 if (wpa_s->p2p_mgmt)
315 return;
316
317#ifdef CONFIG_WPS
318 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
319#endif /* CONFIG_WPS */
320}
321
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700322
323void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
324 struct wpa_ssid *ssid)
325{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800326 if (wpa_s->p2p_mgmt)
327 return;
328
Jouni Malinen75ecf522011-06-27 15:19:46 -0700329 /*
330 * Networks objects created during any P2P activities should not be
331 * exposed out. They might/will confuse certain non-P2P aware
332 * applications since these network objects won't behave like
333 * regular ones.
334 */
Roshan Piusd3854452016-07-07 16:46:41 -0700335 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700336 wpas_dbus_register_network(wpa_s, ssid);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700337 wpas_hidl_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700338 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700339}
340
341
342void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
343 struct wpa_ssid *ssid)
344{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700345#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700346 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700347#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700348}
349
350
351void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
352 struct wpa_ssid *ssid)
353{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700354#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700355 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700356#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700357}
358
359
360void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
361 struct wpa_ssid *ssid)
362{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800363 if (wpa_s->next_ssid == ssid)
364 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800365 if (wpa_s->wpa)
366 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700367 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700368 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700369 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700370 wpas_hidl_unregister_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700371 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800372 if (network_is_persistent_group(ssid))
373 wpas_notify_persistent_group_removed(wpa_s, ssid);
374
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800375 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700376}
377
378
379void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
380 u8 bssid[], unsigned int id)
381{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800382 if (wpa_s->p2p_mgmt)
383 return;
384
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700385 wpas_dbus_register_bss(wpa_s, bssid, id);
386 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
387 id, MAC2STR(bssid));
388}
389
390
391void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
392 u8 bssid[], unsigned int id)
393{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800394 if (wpa_s->p2p_mgmt)
395 return;
396
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700397 wpas_dbus_unregister_bss(wpa_s, bssid, id);
398 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
399 id, MAC2STR(bssid));
400}
401
402
403void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
404 unsigned int id)
405{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800406 if (wpa_s->p2p_mgmt)
407 return;
408
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700409 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
410}
411
412
413void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
414 unsigned int id)
415{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800416 if (wpa_s->p2p_mgmt)
417 return;
418
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700419 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
420 id);
421}
422
423
424void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
425 unsigned int id)
426{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800427 if (wpa_s->p2p_mgmt)
428 return;
429
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700430 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
431 id);
432}
433
434
435void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
436 unsigned int id)
437{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800438 if (wpa_s->p2p_mgmt)
439 return;
440
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700441 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
442}
443
444
445void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
446 unsigned int id)
447{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800448 if (wpa_s->p2p_mgmt)
449 return;
450
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700451 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
452}
453
454
455void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
456 unsigned int id)
457{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800458 if (wpa_s->p2p_mgmt)
459 return;
460
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700461 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
462}
463
464
465void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
466 unsigned int id)
467{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800468 if (wpa_s->p2p_mgmt)
469 return;
470
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800471#ifdef CONFIG_WPS
472 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
473#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700474}
475
476
477void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
478 unsigned int id)
479{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800480 if (wpa_s->p2p_mgmt)
481 return;
482
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700483 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
484}
485
486
487void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
488 unsigned int id)
489{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800490 if (wpa_s->p2p_mgmt)
491 return;
492
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700493 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
494}
495
496
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700497void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
498{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800499 if (wpa_s->p2p_mgmt)
500 return;
501
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700502 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
503}
504
505
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700506void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
507{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800508 if (wpa_s->p2p_mgmt)
509 return;
510
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700511 wpas_dbus_signal_blob_added(wpa_s, name);
512}
513
514
515void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
516{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800517 if (wpa_s->p2p_mgmt)
518 return;
519
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700520 wpas_dbus_signal_blob_removed(wpa_s, name);
521}
522
523
524void wpas_notify_debug_level_changed(struct wpa_global *global)
525{
526 wpas_dbus_signal_debug_level_changed(global);
527}
528
529
530void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
531{
532 wpas_dbus_signal_debug_timestamp_changed(global);
533}
534
535
536void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
537{
538 wpas_dbus_signal_debug_show_keys_changed(global);
539}
540
541
542void wpas_notify_suspend(struct wpa_global *global)
543{
544 struct wpa_supplicant *wpa_s;
545
546 os_get_time(&global->suspend_time);
547 wpa_printf(MSG_DEBUG, "System suspend notification");
548 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
549 wpa_drv_suspend(wpa_s);
550}
551
552
553void wpas_notify_resume(struct wpa_global *global)
554{
555 struct os_time now;
556 int slept;
557 struct wpa_supplicant *wpa_s;
558
559 if (global->suspend_time.sec == 0)
560 slept = -1;
561 else {
562 os_get_time(&now);
563 slept = now.sec - global->suspend_time.sec;
564 }
565 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
566 slept);
567
568 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
569 wpa_drv_resume(wpa_s);
570 if (wpa_s->wpa_state == WPA_DISCONNECTED)
571 wpa_supplicant_req_scan(wpa_s, 0, 100000);
572 }
573}
574
575
576#ifdef CONFIG_P2P
577
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700578void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
579{
580 /* Notify P2P find has stopped */
581 wpas_dbus_signal_p2p_find_stopped(wpa_s);
582}
583
584
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700585void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
586 const u8 *dev_addr, int new_device)
587{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700588 if (new_device) {
589 /* Create the new peer object */
590 wpas_dbus_register_peer(wpa_s, dev_addr);
591 }
592
593 /* Notify a new peer has been detected*/
594 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700595}
596
597
598void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
599 const u8 *dev_addr)
600{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700601 wpas_dbus_unregister_peer(wpa_s, dev_addr);
602
603 /* Create signal on interface object*/
604 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700605}
606
607
608void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
609 const struct wpa_ssid *ssid,
610 const char *role)
611{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700612 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700613
614 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700615}
616
617
618void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700619 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700620{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700621 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700622}
623
624
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800625void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
626 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700627{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800628 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700629}
630
631
632void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
633 int status, const u8 *bssid)
634{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700635 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700636}
637
638
639void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
640 int freq, const u8 *sa, u8 dialog_token,
641 u16 update_indic, const u8 *tlvs,
642 size_t tlvs_len)
643{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700644 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
645 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700646}
647
648
649void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
650 const u8 *sa, u16 update_indic,
651 const u8 *tlvs, size_t tlvs_len)
652{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700653 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
654 tlvs, tlvs_len);
655}
656
657
658/**
659 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
660 * @dev_addr: Who sent the request or responded to our request.
661 * @request: Will be 1 if request, 0 for response.
662 * @status: Valid only in case of response (0 in case of success)
663 * @config_methods: WPS config methods
664 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
665 *
666 * This can be used to notify:
667 * - Requests or responses
668 * - Various config methods
669 * - Failure condition in case of response
670 */
671void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
672 const u8 *dev_addr, int request,
673 enum p2p_prov_disc_status status,
674 u16 config_methods,
675 unsigned int generated_pin)
676{
677 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
678 status, config_methods,
679 generated_pin);
680}
681
682
683void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700684 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800685 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700686{
687 /* Notify a group has been started */
688 wpas_dbus_register_p2p_group(wpa_s, ssid);
689
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800690 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700691}
692
693
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800694void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
695 const char *reason)
696{
697 /* Notify a group formation failed */
698 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
699}
700
701
Jouni Malinen75ecf522011-06-27 15:19:46 -0700702void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
703 struct wps_event_fail *fail)
704{
705 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700706}
707
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800708
709void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
710 const u8 *sa, const u8 *go_dev_addr,
711 const u8 *bssid, int id, int op_freq)
712{
713 /* Notify a P2P Invitation Request */
714 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
715 id, op_freq);
716}
717
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700718#endif /* CONFIG_P2P */
719
720
721static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800722 const u8 *sta,
723 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700724{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700725#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800726 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
727
Jouni Malinen75ecf522011-06-27 15:19:46 -0700728 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700729 * Create 'peer-joined' signal on group object -- will also
730 * check P2P itself.
731 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800732 if (p2p_dev_addr)
733 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700734#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700735
736 /* Notify listeners a new station has been authorized */
737 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700738}
739
740
741static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700742 const u8 *sta,
743 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700744{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700745#ifdef CONFIG_P2P
746 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700747 * Create 'peer-disconnected' signal on group object if this
748 * is a P2P group.
749 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800750 if (p2p_dev_addr)
751 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700752#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700753
754 /* Notify listeners a station has been deauthorized */
755 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700756}
757
758
759void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800760 const u8 *mac_addr, int authorized,
761 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700762{
763 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800764 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700765 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700766 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700767}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700768
769
770void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800771 const char *subject, const char *altsubject[],
772 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700773 const struct wpabuf *cert)
774{
775 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
776 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800777 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700778 cert_hash ? cert_hash : "");
779
780 if (cert) {
781 char *cert_hex;
782 size_t len = wpabuf_len(cert) * 2 + 1;
783 cert_hex = os_malloc(len);
784 if (cert_hex) {
785 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
786 wpabuf_len(cert));
787 wpa_msg_ctrl(wpa_s, MSG_INFO,
788 WPA_EVENT_EAP_PEER_CERT
789 "depth=%d subject='%s' cert=%s",
790 depth, subject, cert_hex);
791 os_free(cert_hex);
792 }
793 }
794
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800795 if (altsubject) {
796 int i;
797
798 for (i = 0; i < num_altsubject; i++)
799 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
800 "depth=%d %s", depth, altsubject[i]);
801 }
802
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700803 /* notify the old DBus API */
804 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
805 cert_hash, cert);
806 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800807 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
808 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700809}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700810
811
812void wpas_notify_preq(struct wpa_supplicant *wpa_s,
813 const u8 *addr, const u8 *dst, const u8 *bssid,
814 const u8 *ie, size_t ie_len, u32 ssi_signal)
815{
816#ifdef CONFIG_AP
817 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
818#endif /* CONFIG_AP */
819}
820
821
822void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
823 const char *parameter)
824{
825 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700826 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
827 "status='%s' parameter='%s'",
828 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700829}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700830
831
832void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
833 struct wpa_ssid *ssid)
834{
835 if (wpa_s->current_ssid != ssid)
836 return;
837
838 wpa_dbg(wpa_s, MSG_DEBUG,
839 "Network bssid config changed for the current network - within-ESS roaming %s",
840 ssid->bssid_set ? "disabled" : "enabled");
841
842 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
843 ssid->bssid_set ? ssid->bssid : NULL);
844}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800845
846
847void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
848 struct wpa_ssid *ssid)
849{
850#ifdef CONFIG_P2P
851 if (ssid->disabled == 2) {
852 /* Changed from normal network profile to persistent group */
853 ssid->disabled = 0;
854 wpas_dbus_unregister_network(wpa_s, ssid->id);
855 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700856 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800857 wpas_dbus_register_persistent_group(wpa_s, ssid);
858 } else {
859 /* Changed from persistent group to normal network profile */
860 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700861 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800862 wpas_dbus_register_network(wpa_s, ssid);
863 }
864#endif /* CONFIG_P2P */
865}
Roshan Pius04a9d742016-12-12 12:40:46 -0800866
867void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
868 const char *result,
869 const struct wpa_bss_anqp *anqp)
870{
871#ifdef CONFIG_INTERWORKING
872 if (!wpa_s || !bssid || !anqp)
873 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800874
875 wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Roshan Pius04a9d742016-12-12 12:40:46 -0800876#endif /* CONFIG_INTERWORKING */
877}
878
879void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
880 const char* file_name, const u8* image,
881 u32 image_length)
882{
883#ifdef CONFIG_HS20
884 if (!wpa_s || !bssid || !file_name || !image)
885 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800886
887 wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
888 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -0800889#endif /* CONFIG_HS20 */
890}
891
892void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
893 const char* url,
894 u8 osu_method)
895{
896#ifdef CONFIG_HS20
897 if (!wpa_s || !url)
898 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800899
900 wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -0800901#endif /* CONFIG_HS20 */
902}
903
904void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
905 u8 code, u16 reauth_delay,
906 const char *url)
907{
908#ifdef CONFIG_HS20
909 if (!wpa_s || !url)
910 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800911
912 wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
913 url);
Roshan Pius04a9d742016-12-12 12:40:46 -0800914#endif /* CONFIG_HS20 */
915}