blob: 5dac8064759b34d5e79f5191bd710a43cee227e2 [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);
302#endif /* CONFIG_WPS */
303}
304
305
306void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
307{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800308 if (wpa_s->p2p_mgmt)
309 return;
310
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700311#ifdef CONFIG_WPS
312 wpas_dbus_signal_wps_event_success(wpa_s);
313#endif /* CONFIG_WPS */
314}
315
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700316void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
317{
318 if (wpa_s->p2p_mgmt)
319 return;
320
321#ifdef CONFIG_WPS
322 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
323#endif /* CONFIG_WPS */
324}
325
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700326
327void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
328 struct wpa_ssid *ssid)
329{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800330 if (wpa_s->p2p_mgmt)
331 return;
332
Jouni Malinen75ecf522011-06-27 15:19:46 -0700333 /*
334 * Networks objects created during any P2P activities should not be
335 * exposed out. They might/will confuse certain non-P2P aware
336 * applications since these network objects won't behave like
337 * regular ones.
338 */
Roshan Piusd3854452016-07-07 16:46:41 -0700339 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700340 wpas_dbus_register_network(wpa_s, ssid);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700341 wpas_hidl_register_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700342 }
Jouni Malinen75ecf522011-06-27 15:19:46 -0700343}
344
345
346void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
347 struct wpa_ssid *ssid)
348{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700349#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700350 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700351#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700352}
353
354
355void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
356 struct wpa_ssid *ssid)
357{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700358#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700359 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700360#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700361}
362
363
364void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
365 struct wpa_ssid *ssid)
366{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800367 if (wpa_s->next_ssid == ssid)
368 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800369 if (wpa_s->wpa)
370 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700371 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
Roshan Piusd3854452016-07-07 16:46:41 -0700372 !wpa_s->p2p_mgmt) {
Jouni Malinen75ecf522011-06-27 15:19:46 -0700373 wpas_dbus_unregister_network(wpa_s, ssid->id);
Roshan Pius57ffbcf2016-09-27 09:12:46 -0700374 wpas_hidl_unregister_network(wpa_s, ssid);
Roshan Piusd3854452016-07-07 16:46:41 -0700375 }
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800376 if (network_is_persistent_group(ssid))
377 wpas_notify_persistent_group_removed(wpa_s, ssid);
378
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800379 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700380}
381
382
383void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
384 u8 bssid[], unsigned int id)
385{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800386 if (wpa_s->p2p_mgmt)
387 return;
388
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700389 wpas_dbus_register_bss(wpa_s, bssid, id);
390 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
391 id, MAC2STR(bssid));
392}
393
394
395void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
396 u8 bssid[], unsigned int id)
397{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800398 if (wpa_s->p2p_mgmt)
399 return;
400
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700401 wpas_dbus_unregister_bss(wpa_s, bssid, id);
402 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
403 id, MAC2STR(bssid));
404}
405
406
407void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
408 unsigned int id)
409{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800410 if (wpa_s->p2p_mgmt)
411 return;
412
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700413 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
414}
415
416
417void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
418 unsigned int id)
419{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800420 if (wpa_s->p2p_mgmt)
421 return;
422
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700423 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
424 id);
425}
426
427
428void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
429 unsigned int id)
430{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800431 if (wpa_s->p2p_mgmt)
432 return;
433
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700434 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
435 id);
436}
437
438
439void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
440 unsigned int id)
441{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800442 if (wpa_s->p2p_mgmt)
443 return;
444
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700445 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
446}
447
448
449void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
450 unsigned int id)
451{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800452 if (wpa_s->p2p_mgmt)
453 return;
454
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700455 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
456}
457
458
459void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
460 unsigned int id)
461{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800462 if (wpa_s->p2p_mgmt)
463 return;
464
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700465 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
466}
467
468
469void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
470 unsigned int id)
471{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800472 if (wpa_s->p2p_mgmt)
473 return;
474
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800475#ifdef CONFIG_WPS
476 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
477#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700478}
479
480
481void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
482 unsigned int id)
483{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800484 if (wpa_s->p2p_mgmt)
485 return;
486
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700487 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
488}
489
490
491void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
492 unsigned int id)
493{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800494 if (wpa_s->p2p_mgmt)
495 return;
496
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700497 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
498}
499
500
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700501void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
502{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800503 if (wpa_s->p2p_mgmt)
504 return;
505
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700506 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
507}
508
509
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700510void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
511{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800512 if (wpa_s->p2p_mgmt)
513 return;
514
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700515 wpas_dbus_signal_blob_added(wpa_s, name);
516}
517
518
519void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
520{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800521 if (wpa_s->p2p_mgmt)
522 return;
523
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700524 wpas_dbus_signal_blob_removed(wpa_s, name);
525}
526
527
528void wpas_notify_debug_level_changed(struct wpa_global *global)
529{
530 wpas_dbus_signal_debug_level_changed(global);
531}
532
533
534void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
535{
536 wpas_dbus_signal_debug_timestamp_changed(global);
537}
538
539
540void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
541{
542 wpas_dbus_signal_debug_show_keys_changed(global);
543}
544
545
546void wpas_notify_suspend(struct wpa_global *global)
547{
548 struct wpa_supplicant *wpa_s;
549
550 os_get_time(&global->suspend_time);
551 wpa_printf(MSG_DEBUG, "System suspend notification");
552 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
553 wpa_drv_suspend(wpa_s);
554}
555
556
557void wpas_notify_resume(struct wpa_global *global)
558{
559 struct os_time now;
560 int slept;
561 struct wpa_supplicant *wpa_s;
562
563 if (global->suspend_time.sec == 0)
564 slept = -1;
565 else {
566 os_get_time(&now);
567 slept = now.sec - global->suspend_time.sec;
568 }
569 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
570 slept);
571
572 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
573 wpa_drv_resume(wpa_s);
574 if (wpa_s->wpa_state == WPA_DISCONNECTED)
575 wpa_supplicant_req_scan(wpa_s, 0, 100000);
576 }
577}
578
579
580#ifdef CONFIG_P2P
581
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700582void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
583{
584 /* Notify P2P find has stopped */
585 wpas_dbus_signal_p2p_find_stopped(wpa_s);
586}
587
588
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700589void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
590 const u8 *dev_addr, int new_device)
591{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700592 if (new_device) {
593 /* Create the new peer object */
594 wpas_dbus_register_peer(wpa_s, dev_addr);
595 }
596
597 /* Notify a new peer has been detected*/
598 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700599}
600
601
602void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
603 const u8 *dev_addr)
604{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700605 wpas_dbus_unregister_peer(wpa_s, dev_addr);
606
607 /* Create signal on interface object*/
608 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700609}
610
611
612void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
613 const struct wpa_ssid *ssid,
614 const char *role)
615{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700616 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700617
618 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700619}
620
621
622void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700623 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700624{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700625 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700626}
627
628
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800629void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
630 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700631{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800632 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700633}
634
635
636void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
637 int status, const u8 *bssid)
638{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700639 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700640}
641
642
643void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
644 int freq, const u8 *sa, u8 dialog_token,
645 u16 update_indic, const u8 *tlvs,
646 size_t tlvs_len)
647{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700648 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
649 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700650}
651
652
653void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
654 const u8 *sa, u16 update_indic,
655 const u8 *tlvs, size_t tlvs_len)
656{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700657 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
658 tlvs, tlvs_len);
659}
660
661
662/**
663 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
664 * @dev_addr: Who sent the request or responded to our request.
665 * @request: Will be 1 if request, 0 for response.
666 * @status: Valid only in case of response (0 in case of success)
667 * @config_methods: WPS config methods
668 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
669 *
670 * This can be used to notify:
671 * - Requests or responses
672 * - Various config methods
673 * - Failure condition in case of response
674 */
675void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
676 const u8 *dev_addr, int request,
677 enum p2p_prov_disc_status status,
678 u16 config_methods,
679 unsigned int generated_pin)
680{
681 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
682 status, config_methods,
683 generated_pin);
684}
685
686
687void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700688 struct wpa_ssid *ssid, int persistent,
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800689 int client, const u8 *ip)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700690{
691 /* Notify a group has been started */
692 wpas_dbus_register_p2p_group(wpa_s, ssid);
693
Dmitry Shmidtabb90a32016-12-05 15:34:39 -0800694 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700695}
696
697
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800698void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
699 const char *reason)
700{
701 /* Notify a group formation failed */
702 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
703}
704
705
Jouni Malinen75ecf522011-06-27 15:19:46 -0700706void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
707 struct wps_event_fail *fail)
708{
709 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700710}
711
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800712
713void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
714 const u8 *sa, const u8 *go_dev_addr,
715 const u8 *bssid, int id, int op_freq)
716{
717 /* Notify a P2P Invitation Request */
718 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
719 id, op_freq);
720}
721
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700722#endif /* CONFIG_P2P */
723
724
725static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800726 const u8 *sta,
727 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700728{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700729#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800730 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
731
Jouni Malinen75ecf522011-06-27 15:19:46 -0700732 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700733 * Create 'peer-joined' signal on group object -- will also
734 * check P2P itself.
735 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800736 if (p2p_dev_addr)
737 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700738#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700739
740 /* Notify listeners a new station has been authorized */
741 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700742}
743
744
745static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700746 const u8 *sta,
747 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700748{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700749#ifdef CONFIG_P2P
750 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700751 * Create 'peer-disconnected' signal on group object if this
752 * is a P2P group.
753 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800754 if (p2p_dev_addr)
755 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700756#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700757
758 /* Notify listeners a station has been deauthorized */
759 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700760}
761
762
763void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800764 const u8 *mac_addr, int authorized,
765 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700766{
767 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800768 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700769 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700770 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700771}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700772
773
774void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800775 const char *subject, const char *altsubject[],
776 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700777 const struct wpabuf *cert)
778{
779 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
780 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800781 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700782 cert_hash ? cert_hash : "");
783
784 if (cert) {
785 char *cert_hex;
786 size_t len = wpabuf_len(cert) * 2 + 1;
787 cert_hex = os_malloc(len);
788 if (cert_hex) {
789 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
790 wpabuf_len(cert));
791 wpa_msg_ctrl(wpa_s, MSG_INFO,
792 WPA_EVENT_EAP_PEER_CERT
793 "depth=%d subject='%s' cert=%s",
794 depth, subject, cert_hex);
795 os_free(cert_hex);
796 }
797 }
798
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800799 if (altsubject) {
800 int i;
801
802 for (i = 0; i < num_altsubject; i++)
803 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
804 "depth=%d %s", depth, altsubject[i]);
805 }
806
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700807 /* notify the old DBus API */
808 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
809 cert_hash, cert);
810 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800811 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
812 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700813}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700814
815
816void wpas_notify_preq(struct wpa_supplicant *wpa_s,
817 const u8 *addr, const u8 *dst, const u8 *bssid,
818 const u8 *ie, size_t ie_len, u32 ssi_signal)
819{
820#ifdef CONFIG_AP
821 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
822#endif /* CONFIG_AP */
823}
824
825
826void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
827 const char *parameter)
828{
829 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700830 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
831 "status='%s' parameter='%s'",
832 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700833}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700834
835
836void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
837 struct wpa_ssid *ssid)
838{
839 if (wpa_s->current_ssid != ssid)
840 return;
841
842 wpa_dbg(wpa_s, MSG_DEBUG,
843 "Network bssid config changed for the current network - within-ESS roaming %s",
844 ssid->bssid_set ? "disabled" : "enabled");
845
846 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
847 ssid->bssid_set ? ssid->bssid : NULL);
848}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800849
850
851void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
852 struct wpa_ssid *ssid)
853{
854#ifdef CONFIG_P2P
855 if (ssid->disabled == 2) {
856 /* Changed from normal network profile to persistent group */
857 ssid->disabled = 0;
858 wpas_dbus_unregister_network(wpa_s, ssid->id);
859 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700860 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800861 wpas_dbus_register_persistent_group(wpa_s, ssid);
862 } else {
863 /* Changed from persistent group to normal network profile */
864 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700865 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800866 wpas_dbus_register_network(wpa_s, ssid);
867 }
868#endif /* CONFIG_P2P */
869}
Roshan Pius04a9d742016-12-12 12:40:46 -0800870
871void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
872 const char *result,
873 const struct wpa_bss_anqp *anqp)
874{
875#ifdef CONFIG_INTERWORKING
876 if (!wpa_s || !bssid || !anqp)
877 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800878
879 wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
Roshan Pius04a9d742016-12-12 12:40:46 -0800880#endif /* CONFIG_INTERWORKING */
881}
882
883void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
884 const char* file_name, const u8* image,
885 u32 image_length)
886{
887#ifdef CONFIG_HS20
888 if (!wpa_s || !bssid || !file_name || !image)
889 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800890
891 wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
892 image_length);
Roshan Pius04a9d742016-12-12 12:40:46 -0800893#endif /* CONFIG_HS20 */
894}
895
896void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
897 const char* url,
898 u8 osu_method)
899{
900#ifdef CONFIG_HS20
901 if (!wpa_s || !url)
902 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800903
904 wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
Roshan Pius04a9d742016-12-12 12:40:46 -0800905#endif /* CONFIG_HS20 */
906}
907
908void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
909 u8 code, u16 reauth_delay,
910 const char *url)
911{
912#ifdef CONFIG_HS20
913 if (!wpa_s || !url)
914 return;
Roshan Pius9322a342016-12-12 14:45:02 -0800915
916 wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
917 url);
Roshan Pius04a9d742016-12-12 12:40:46 -0800918#endif /* CONFIG_HS20 */
919}