blob: 3fdb36f93162adc6c4b87c1d99a3983f02936ad6 [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);
Roshan Pius0974e962016-12-12 17:05:51 -0800147
148 wpas_hidl_notify_assoc_reject(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700149}
150
151
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800152void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
153{
154 if (wpa_s->p2p_mgmt)
155 return;
156
157 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
Roshan Pius0974e962016-12-12 17:05:51 -0800158
159 wpas_hidl_notify_assoc_reject(wpa_s);
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800160}
161
162
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700163void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
164{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800165 if (wpa_s->p2p_mgmt)
166 return;
167
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700168 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
169}
170
171
172void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
173{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800174 if (wpa_s->p2p_mgmt)
175 return;
176
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700177 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
178}
179
180
181void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
182{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800183 if (wpa_s->p2p_mgmt)
184 return;
185
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700186 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
187}
188
189
190void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
191{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800192 if (wpa_s->p2p_mgmt)
193 return;
194
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700195 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
196}
197
198
199void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
200 struct wpa_ssid *ssid)
201{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800202 if (wpa_s->p2p_mgmt)
203 return;
204
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700205 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
206}
207
208
209void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
210 struct wpa_ssid *ssid)
211{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800212 if (wpa_s->p2p_mgmt)
213 return;
214
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700215 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
216}
217
218
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800219void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
220 struct wpa_ssid *ssid,
221 enum wpa_ctrl_req_type rtype,
222 const char *default_txt)
223{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800224 if (wpa_s->p2p_mgmt)
225 return;
226
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800227 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
Roshan Pius65628ce2016-08-17 13:10:23 -0700228
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700229 wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800230}
231
232
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700233void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
234{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800235 if (wpa_s->p2p_mgmt)
236 return;
237
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700238 /* notify the old DBus API */
239 wpa_supplicant_dbus_notify_scanning(wpa_s);
240
241 /* notify the new DBus API */
242 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
243}
244
245
246void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
247{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800248 if (wpa_s->p2p_mgmt)
249 return;
250
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700251 wpas_dbus_signal_scan_done(wpa_s, success);
252}
253
254
255void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
256{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800257 if (wpa_s->p2p_mgmt)
258 return;
259
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700260 /* notify the old DBus API */
261 wpa_supplicant_dbus_notify_scan_results(wpa_s);
262
263 wpas_wps_notify_scan_results(wpa_s);
264}
265
266
267void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
268 const struct wps_credential *cred)
269{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800270 if (wpa_s->p2p_mgmt)
271 return;
272
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700273#ifdef CONFIG_WPS
274 /* notify the old DBus API */
275 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
276 /* notify the new DBus API */
277 wpas_dbus_signal_wps_cred(wpa_s, cred);
278#endif /* CONFIG_WPS */
279}
280
281
282void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
283 struct wps_event_m2d *m2d)
284{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800285 if (wpa_s->p2p_mgmt)
286 return;
287
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700288#ifdef CONFIG_WPS
289 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
290#endif /* CONFIG_WPS */
291}
292
293
294void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
295 struct wps_event_fail *fail)
296{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800297 if (wpa_s->p2p_mgmt)
298 return;
299
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700300#ifdef CONFIG_WPS
301 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
Roshan Pius14932752017-01-11 09:48:58 -0800302
303 wpas_hidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
304 fail->config_error,
305 fail->error_indication);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700306#endif /* CONFIG_WPS */
307}
308
309
310void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
311{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800312 if (wpa_s->p2p_mgmt)
313 return;
314
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700315#ifdef CONFIG_WPS
316 wpas_dbus_signal_wps_event_success(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800317
318 wpas_hidl_notify_wps_event_success(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700319#endif /* CONFIG_WPS */
320}
321
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700322void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
323{
324 if (wpa_s->p2p_mgmt)
325 return;
326
327#ifdef CONFIG_WPS
328 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
Roshan Pius14932752017-01-11 09:48:58 -0800329
330 wpas_hidl_notify_wps_event_pbc_overlap(wpa_s);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700331#endif /* CONFIG_WPS */
332}
333
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700334
335void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
336 struct wpa_ssid *ssid)
337{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800338 if (wpa_s->p2p_mgmt)
339 return;
340
Jouni Malinen75ecf522011-06-27 15:19:46 -0700341 /*
342 * Networks objects created during any P2P activities should not be
343 * exposed out. They might/will confuse certain non-P2P aware
344 * applications since these network objects won't behave like
345 * regular ones.
346 */
Roshan Piusd3854452016-07-07 16:46:41 -0700347 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700348 wpas_dbus_register_network(wpa_s, ssid);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700349 wpas_hidl_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700350 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700351}
352
353
354void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
355 struct wpa_ssid *ssid)
356{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700357#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700358 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700359#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700360}
361
362
363void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
364 struct wpa_ssid *ssid)
365{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700366#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700367 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700368#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700369}
370
371
372void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
373 struct wpa_ssid *ssid)
374{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800375 if (wpa_s->next_ssid == ssid)
376 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800377 if (wpa_s->wpa)
378 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700379 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700380 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700381 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700382 wpas_hidl_unregister_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700383 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800384 if (network_is_persistent_group(ssid))
385 wpas_notify_persistent_group_removed(wpa_s, ssid);
386
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800387 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700388}
389
390
391void wpas_notify_bss_added(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_register_bss(wpa_s, bssid, id);
398 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
399 id, MAC2STR(bssid));
400}
401
402
403void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
404 u8 bssid[], 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_unregister_bss(wpa_s, bssid, id);
410 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
411 id, MAC2STR(bssid));
412}
413
414
415void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
416 unsigned int id)
417{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800418 if (wpa_s->p2p_mgmt)
419 return;
420
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700421 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
422}
423
424
425void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
426 unsigned int id)
427{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800428 if (wpa_s->p2p_mgmt)
429 return;
430
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700431 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
432 id);
433}
434
435
436void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
437 unsigned int id)
438{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800439 if (wpa_s->p2p_mgmt)
440 return;
441
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700442 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
443 id);
444}
445
446
447void wpas_notify_bss_mode_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_MODE, id);
454}
455
456
457void wpas_notify_bss_wpaie_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 Shmidt8d520ff2011-05-09 14:06:53 -0700463 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
464}
465
466
467void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
468 unsigned int id)
469{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800470 if (wpa_s->p2p_mgmt)
471 return;
472
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700473 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
474}
475
476
477void wpas_notify_bss_wps_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 Shmidtd5e49232012-12-03 15:08:10 -0800483#ifdef CONFIG_WPS
484 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
485#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700486}
487
488
489void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
490 unsigned int id)
491{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800492 if (wpa_s->p2p_mgmt)
493 return;
494
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700495 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
496}
497
498
499void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
500 unsigned int id)
501{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800502 if (wpa_s->p2p_mgmt)
503 return;
504
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700505 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
506}
507
508
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700509void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
510{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800511 if (wpa_s->p2p_mgmt)
512 return;
513
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700514 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
515}
516
517
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700518void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
519{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800520 if (wpa_s->p2p_mgmt)
521 return;
522
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700523 wpas_dbus_signal_blob_added(wpa_s, name);
524}
525
526
527void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
528{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800529 if (wpa_s->p2p_mgmt)
530 return;
531
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700532 wpas_dbus_signal_blob_removed(wpa_s, name);
533}
534
535
536void wpas_notify_debug_level_changed(struct wpa_global *global)
537{
538 wpas_dbus_signal_debug_level_changed(global);
539}
540
541
542void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
543{
544 wpas_dbus_signal_debug_timestamp_changed(global);
545}
546
547
548void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
549{
550 wpas_dbus_signal_debug_show_keys_changed(global);
551}
552
553
554void wpas_notify_suspend(struct wpa_global *global)
555{
556 struct wpa_supplicant *wpa_s;
557
558 os_get_time(&global->suspend_time);
559 wpa_printf(MSG_DEBUG, "System suspend notification");
560 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
561 wpa_drv_suspend(wpa_s);
562}
563
564
565void wpas_notify_resume(struct wpa_global *global)
566{
567 struct os_time now;
568 int slept;
569 struct wpa_supplicant *wpa_s;
570
571 if (global->suspend_time.sec == 0)
572 slept = -1;
573 else {
574 os_get_time(&now);
575 slept = now.sec - global->suspend_time.sec;
576 }
577 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
578 slept);
579
580 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
581 wpa_drv_resume(wpa_s);
582 if (wpa_s->wpa_state == WPA_DISCONNECTED)
583 wpa_supplicant_req_scan(wpa_s, 0, 100000);
584 }
585}
586
587
588#ifdef CONFIG_P2P
589
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700590void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
591{
592 /* Notify P2P find has stopped */
593 wpas_dbus_signal_p2p_find_stopped(wpa_s);
594}
595
596
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700597void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
598 const u8 *dev_addr, int new_device)
599{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700600 if (new_device) {
601 /* Create the new peer object */
602 wpas_dbus_register_peer(wpa_s, dev_addr);
603 }
604
605 /* Notify a new peer has been detected*/
606 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700607}
608
609
610void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
611 const u8 *dev_addr)
612{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700613 wpas_dbus_unregister_peer(wpa_s, dev_addr);
614
615 /* Create signal on interface object*/
616 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700617}
618
619
620void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
621 const struct wpa_ssid *ssid,
622 const char *role)
623{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700624 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700625
626 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700627}
628
629
630void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700631 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700632{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700633 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700634}
635
636
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800637void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
638 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700639{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800640 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700641}
642
643
644void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
645 int status, const u8 *bssid)
646{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700647 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700648}
649
650
651void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
652 int freq, const u8 *sa, u8 dialog_token,
653 u16 update_indic, const u8 *tlvs,
654 size_t tlvs_len)
655{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700656 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
657 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700658}
659
660
661void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
662 const u8 *sa, u16 update_indic,
663 const u8 *tlvs, size_t tlvs_len)
664{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700665 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
666 tlvs, tlvs_len);
667}
668
669
670/**
671 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
672 * @dev_addr: Who sent the request or responded to our request.
673 * @request: Will be 1 if request, 0 for response.
674 * @status: Valid only in case of response (0 in case of success)
675 * @config_methods: WPS config methods
676 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
677 *
678 * This can be used to notify:
679 * - Requests or responses
680 * - Various config methods
681 * - Failure condition in case of response
682 */
683void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
684 const u8 *dev_addr, int request,
685 enum p2p_prov_disc_status status,
686 u16 config_methods,
687 unsigned int generated_pin)
688{
689 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
690 status, config_methods,
691 generated_pin);
692}
693
694
695void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700696 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800697 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700698{
699 /* Notify a group has been started */
700 wpas_dbus_register_p2p_group(wpa_s, ssid);
701
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800702 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700703}
704
705
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800706void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
707 const char *reason)
708{
709 /* Notify a group formation failed */
710 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
711}
712
713
Jouni Malinen75ecf522011-06-27 15:19:46 -0700714void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
715 struct wps_event_fail *fail)
716{
717 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700718}
719
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800720
721void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
722 const u8 *sa, const u8 *go_dev_addr,
723 const u8 *bssid, int id, int op_freq)
724{
725 /* Notify a P2P Invitation Request */
726 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
727 id, op_freq);
728}
729
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700730#endif /* CONFIG_P2P */
731
732
733static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800734 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
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800738 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
739
Jouni Malinen75ecf522011-06-27 15:19:46 -0700740 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700741 * Create 'peer-joined' signal on group object -- will also
742 * check P2P itself.
743 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800744 if (p2p_dev_addr)
745 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700746#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700747
748 /* Notify listeners a new station has been authorized */
749 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700750}
751
752
753static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700754 const u8 *sta,
755 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700756{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700757#ifdef CONFIG_P2P
758 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700759 * Create 'peer-disconnected' signal on group object if this
760 * is a P2P group.
761 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800762 if (p2p_dev_addr)
763 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700764#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700765
766 /* Notify listeners a station has been deauthorized */
767 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700768}
769
770
771void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800772 const u8 *mac_addr, int authorized,
773 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700774{
775 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800776 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700777 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700778 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700779}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700780
781
782void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800783 const char *subject, const char *altsubject[],
784 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700785 const struct wpabuf *cert)
786{
787 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
788 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800789 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700790 cert_hash ? cert_hash : "");
791
792 if (cert) {
793 char *cert_hex;
794 size_t len = wpabuf_len(cert) * 2 + 1;
795 cert_hex = os_malloc(len);
796 if (cert_hex) {
797 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
798 wpabuf_len(cert));
799 wpa_msg_ctrl(wpa_s, MSG_INFO,
800 WPA_EVENT_EAP_PEER_CERT
801 "depth=%d subject='%s' cert=%s",
802 depth, subject, cert_hex);
803 os_free(cert_hex);
804 }
805 }
806
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800807 if (altsubject) {
808 int i;
809
810 for (i = 0; i < num_altsubject; i++)
811 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
812 "depth=%d %s", depth, altsubject[i]);
813 }
814
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700815 /* notify the old DBus API */
816 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
817 cert_hash, cert);
818 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800819 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
820 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700821}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700822
823
824void wpas_notify_preq(struct wpa_supplicant *wpa_s,
825 const u8 *addr, const u8 *dst, const u8 *bssid,
826 const u8 *ie, size_t ie_len, u32 ssi_signal)
827{
828#ifdef CONFIG_AP
829 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
830#endif /* CONFIG_AP */
831}
832
833
834void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
835 const char *parameter)
836{
837 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700838 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
839 "status='%s' parameter='%s'",
840 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700841}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700842
843
844void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
845 struct wpa_ssid *ssid)
846{
847 if (wpa_s->current_ssid != ssid)
848 return;
849
850 wpa_dbg(wpa_s, MSG_DEBUG,
851 "Network bssid config changed for the current network - within-ESS roaming %s",
852 ssid->bssid_set ? "disabled" : "enabled");
853
854 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
855 ssid->bssid_set ? ssid->bssid : NULL);
856}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800857
858
859void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
860 struct wpa_ssid *ssid)
861{
862#ifdef CONFIG_P2P
863 if (ssid->disabled == 2) {
864 /* Changed from normal network profile to persistent group */
865 ssid->disabled = 0;
866 wpas_dbus_unregister_network(wpa_s, ssid->id);
867 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700868 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800869 wpas_dbus_register_persistent_group(wpa_s, ssid);
870 } else {
871 /* Changed from persistent group to normal network profile */
872 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700873 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800874 wpas_dbus_register_network(wpa_s, ssid);
875 }
876#endif /* CONFIG_P2P */
877}
Roshan Pius04a9d742016-12-12 12:40:46 -0800878
879void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
880 const char *result,
881 const struct wpa_bss_anqp *anqp)
882{
883#ifdef CONFIG_INTERWORKING
884 if (!wpa_s || !bssid || !anqp)
885 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800886
887 wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Roshan Pius04a9d742016-12-12 12:40:46 -0800888#endif /* CONFIG_INTERWORKING */
889}
890
891void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
892 const char* file_name, const u8* image,
893 u32 image_length)
894{
895#ifdef CONFIG_HS20
896 if (!wpa_s || !bssid || !file_name || !image)
897 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800898
899 wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
900 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -0800901#endif /* CONFIG_HS20 */
902}
903
904void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
905 const char* url,
906 u8 osu_method)
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_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -0800913#endif /* CONFIG_HS20 */
914}
915
916void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
917 u8 code, u16 reauth_delay,
918 const char *url)
919{
920#ifdef CONFIG_HS20
921 if (!wpa_s || !url)
922 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800923
924 wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
925 url);
Roshan Pius04a9d742016-12-12 12:40:46 -0800926#endif /* CONFIG_HS20 */
927}