blob: 67e36ae34cb879c7251ff6191a189f53ed92b635 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * wpa_supplicant - Event notifications
3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
4 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#include "utils/includes.h"
10
11#include "utils/common.h"
12#include "common/wpa_ctrl.h"
13#include "config.h"
14#include "wpa_supplicant_i.h"
15#include "wps_supplicant.h"
Dmitry Shmidte4663042016-04-04 10:07:49 -070016#include "binder/binder.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070017#include "dbus/dbus_common.h"
18#include "dbus/dbus_old.h"
19#include "dbus/dbus_new.h"
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080020#include "rsn_supp/wpa.h"
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080021#include "fst/fst.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070022#include "driver_i.h"
23#include "scan.h"
24#include "p2p_supplicant.h"
25#include "sme.h"
26#include "notify.h"
27
28int wpas_notify_supplicant_initialized(struct wpa_global *global)
29{
30#ifdef CONFIG_DBUS
31 if (global->params.dbus_ctrl_interface) {
32 global->dbus = wpas_dbus_init(global);
33 if (global->dbus == NULL)
34 return -1;
35 }
36#endif /* CONFIG_DBUS */
37
Dmitry Shmidte4663042016-04-04 10:07:49 -070038#ifdef CONFIG_BINDER
39 global->binder = wpas_binder_init(global);
40 if (!global->binder)
41 return -1;
42#endif /* CONFIG_BINDER */
43
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070044 return 0;
45}
46
47
48void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
49{
50#ifdef CONFIG_DBUS
51 if (global->dbus)
52 wpas_dbus_deinit(global->dbus);
53#endif /* CONFIG_DBUS */
Dmitry Shmidte4663042016-04-04 10:07:49 -070054
55#ifdef CONFIG_BINDER
56 if (global->binder)
57 wpas_binder_deinit(global->binder);
58#endif /* CONFIG_BINDER */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070059}
60
61
62int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
63{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080064 if (wpa_s->p2p_mgmt)
65 return 0;
66
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070067 if (wpas_dbus_register_iface(wpa_s))
68 return -1;
69
70 if (wpas_dbus_register_interface(wpa_s))
71 return -1;
72
73 return 0;
74}
75
76
77void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
78{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080079 if (wpa_s->p2p_mgmt)
80 return;
81
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070082 /* unregister interface in old DBus ctrl iface */
83 wpas_dbus_unregister_iface(wpa_s);
84
85 /* unregister interface in new DBus ctrl iface */
86 wpas_dbus_unregister_interface(wpa_s);
87}
88
89
90void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
91 enum wpa_states new_state,
92 enum wpa_states old_state)
93{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080094 if (wpa_s->p2p_mgmt)
95 return;
96
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070097 /* notify the old DBus API */
98 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
99 old_state);
100
101 /* notify the new DBus API */
102 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
103
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800104#ifdef CONFIG_FST
105 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
106 if (new_state == WPA_COMPLETED)
107 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
108 else if (old_state >= WPA_ASSOCIATED &&
109 new_state < WPA_ASSOCIATED)
110 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
111 }
112#endif /* CONFIG_FST */
113
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700114 if (new_state == WPA_COMPLETED)
115 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700116 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700117 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700118
119 sme_state_changed(wpa_s);
120
121#ifdef ANDROID
122 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700123 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700124 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700125 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700126 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700127 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
128 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800129 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700130#endif /* ANDROID */
131}
132
133
Dmitry Shmidt04949592012-07-19 12:16:46 -0700134void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
135{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800136 if (wpa_s->p2p_mgmt)
137 return;
138
Dmitry Shmidt04949592012-07-19 12:16:46 -0700139 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
140}
141
142
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800143void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
144{
145 if (wpa_s->p2p_mgmt)
146 return;
147
148 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
149}
150
151
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700152void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
153{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800154 if (wpa_s->p2p_mgmt)
155 return;
156
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700157 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
158}
159
160
161void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
162{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800163 if (wpa_s->p2p_mgmt)
164 return;
165
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700166 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
167}
168
169
170void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
171{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800172 if (wpa_s->p2p_mgmt)
173 return;
174
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700175 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
176}
177
178
179void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
180{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800181 if (wpa_s->p2p_mgmt)
182 return;
183
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700184 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
185}
186
187
188void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
189 struct wpa_ssid *ssid)
190{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800191 if (wpa_s->p2p_mgmt)
192 return;
193
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700194 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
195}
196
197
198void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
199 struct wpa_ssid *ssid)
200{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800201 if (wpa_s->p2p_mgmt)
202 return;
203
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700204 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
205}
206
207
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800208void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
209 struct wpa_ssid *ssid,
210 enum wpa_ctrl_req_type rtype,
211 const char *default_txt)
212{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800213 if (wpa_s->p2p_mgmt)
214 return;
215
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800216 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
217}
218
219
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700220void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
221{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800222 if (wpa_s->p2p_mgmt)
223 return;
224
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700225 /* notify the old DBus API */
226 wpa_supplicant_dbus_notify_scanning(wpa_s);
227
228 /* notify the new DBus API */
229 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
230}
231
232
233void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
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 wpas_dbus_signal_scan_done(wpa_s, success);
239}
240
241
242void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
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 /* notify the old DBus API */
248 wpa_supplicant_dbus_notify_scan_results(wpa_s);
249
250 wpas_wps_notify_scan_results(wpa_s);
251}
252
253
254void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
255 const struct wps_credential *cred)
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#ifdef CONFIG_WPS
261 /* notify the old DBus API */
262 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
263 /* notify the new DBus API */
264 wpas_dbus_signal_wps_cred(wpa_s, cred);
265#endif /* CONFIG_WPS */
266}
267
268
269void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
270 struct wps_event_m2d *m2d)
271{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800272 if (wpa_s->p2p_mgmt)
273 return;
274
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700275#ifdef CONFIG_WPS
276 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
277#endif /* CONFIG_WPS */
278}
279
280
281void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
282 struct wps_event_fail *fail)
283{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800284 if (wpa_s->p2p_mgmt)
285 return;
286
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700287#ifdef CONFIG_WPS
288 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
289#endif /* CONFIG_WPS */
290}
291
292
293void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
294{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800295 if (wpa_s->p2p_mgmt)
296 return;
297
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700298#ifdef CONFIG_WPS
299 wpas_dbus_signal_wps_event_success(wpa_s);
300#endif /* CONFIG_WPS */
301}
302
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700303void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
304{
305 if (wpa_s->p2p_mgmt)
306 return;
307
308#ifdef CONFIG_WPS
309 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
310#endif /* CONFIG_WPS */
311}
312
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700313
314void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
315 struct wpa_ssid *ssid)
316{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800317 if (wpa_s->p2p_mgmt)
318 return;
319
Jouni Malinen75ecf522011-06-27 15:19:46 -0700320 /*
321 * Networks objects created during any P2P activities should not be
322 * exposed out. They might/will confuse certain non-P2P aware
323 * applications since these network objects won't behave like
324 * regular ones.
325 */
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700326 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700327 wpas_dbus_register_network(wpa_s, ssid);
328}
329
330
331void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
332 struct wpa_ssid *ssid)
333{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700334#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700335 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700336#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700337}
338
339
340void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
341 struct wpa_ssid *ssid)
342{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700343#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700344 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700345#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700346}
347
348
349void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
350 struct wpa_ssid *ssid)
351{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800352 if (wpa_s->next_ssid == ssid)
353 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800354 if (wpa_s->wpa)
355 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700356 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
357 !wpa_s->p2p_mgmt)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700358 wpas_dbus_unregister_network(wpa_s, ssid->id);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800359 if (network_is_persistent_group(ssid))
360 wpas_notify_persistent_group_removed(wpa_s, ssid);
361
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800362 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700363}
364
365
366void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
367 u8 bssid[], unsigned int id)
368{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800369 if (wpa_s->p2p_mgmt)
370 return;
371
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700372 wpas_dbus_register_bss(wpa_s, bssid, id);
373 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
374 id, MAC2STR(bssid));
375}
376
377
378void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
379 u8 bssid[], unsigned int id)
380{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800381 if (wpa_s->p2p_mgmt)
382 return;
383
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700384 wpas_dbus_unregister_bss(wpa_s, bssid, id);
385 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
386 id, MAC2STR(bssid));
387}
388
389
390void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
391 unsigned int id)
392{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800393 if (wpa_s->p2p_mgmt)
394 return;
395
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700396 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
397}
398
399
400void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
401 unsigned int id)
402{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800403 if (wpa_s->p2p_mgmt)
404 return;
405
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700406 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
407 id);
408}
409
410
411void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
412 unsigned int id)
413{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800414 if (wpa_s->p2p_mgmt)
415 return;
416
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700417 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
418 id);
419}
420
421
422void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
423 unsigned int id)
424{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800425 if (wpa_s->p2p_mgmt)
426 return;
427
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700428 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
429}
430
431
432void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
433 unsigned int id)
434{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800435 if (wpa_s->p2p_mgmt)
436 return;
437
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700438 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
439}
440
441
442void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
443 unsigned int id)
444{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800445 if (wpa_s->p2p_mgmt)
446 return;
447
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700448 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
449}
450
451
452void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
453 unsigned int id)
454{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800455 if (wpa_s->p2p_mgmt)
456 return;
457
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800458#ifdef CONFIG_WPS
459 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
460#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700461}
462
463
464void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
465 unsigned int id)
466{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800467 if (wpa_s->p2p_mgmt)
468 return;
469
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700470 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
471}
472
473
474void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
475 unsigned int id)
476{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800477 if (wpa_s->p2p_mgmt)
478 return;
479
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700480 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
481}
482
483
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700484void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
485{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800486 if (wpa_s->p2p_mgmt)
487 return;
488
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700489 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
490}
491
492
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700493void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
494{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800495 if (wpa_s->p2p_mgmt)
496 return;
497
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700498 wpas_dbus_signal_blob_added(wpa_s, name);
499}
500
501
502void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
503{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800504 if (wpa_s->p2p_mgmt)
505 return;
506
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700507 wpas_dbus_signal_blob_removed(wpa_s, name);
508}
509
510
511void wpas_notify_debug_level_changed(struct wpa_global *global)
512{
513 wpas_dbus_signal_debug_level_changed(global);
514}
515
516
517void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
518{
519 wpas_dbus_signal_debug_timestamp_changed(global);
520}
521
522
523void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
524{
525 wpas_dbus_signal_debug_show_keys_changed(global);
526}
527
528
529void wpas_notify_suspend(struct wpa_global *global)
530{
531 struct wpa_supplicant *wpa_s;
532
533 os_get_time(&global->suspend_time);
534 wpa_printf(MSG_DEBUG, "System suspend notification");
535 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
536 wpa_drv_suspend(wpa_s);
537}
538
539
540void wpas_notify_resume(struct wpa_global *global)
541{
542 struct os_time now;
543 int slept;
544 struct wpa_supplicant *wpa_s;
545
546 if (global->suspend_time.sec == 0)
547 slept = -1;
548 else {
549 os_get_time(&now);
550 slept = now.sec - global->suspend_time.sec;
551 }
552 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
553 slept);
554
555 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
556 wpa_drv_resume(wpa_s);
557 if (wpa_s->wpa_state == WPA_DISCONNECTED)
558 wpa_supplicant_req_scan(wpa_s, 0, 100000);
559 }
560}
561
562
563#ifdef CONFIG_P2P
564
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700565void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
566{
567 /* Notify P2P find has stopped */
568 wpas_dbus_signal_p2p_find_stopped(wpa_s);
569}
570
571
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700572void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
573 const u8 *dev_addr, int new_device)
574{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700575 if (new_device) {
576 /* Create the new peer object */
577 wpas_dbus_register_peer(wpa_s, dev_addr);
578 }
579
580 /* Notify a new peer has been detected*/
581 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700582}
583
584
585void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
586 const u8 *dev_addr)
587{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700588 wpas_dbus_unregister_peer(wpa_s, dev_addr);
589
590 /* Create signal on interface object*/
591 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700592}
593
594
595void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
596 const struct wpa_ssid *ssid,
597 const char *role)
598{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700599 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700600
601 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700602}
603
604
605void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700606 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700607{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700608 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700609}
610
611
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800612void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
613 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700614{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800615 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700616}
617
618
619void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
620 int status, const u8 *bssid)
621{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700622 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700623}
624
625
626void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
627 int freq, const u8 *sa, u8 dialog_token,
628 u16 update_indic, const u8 *tlvs,
629 size_t tlvs_len)
630{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700631 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
632 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700633}
634
635
636void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
637 const u8 *sa, u16 update_indic,
638 const u8 *tlvs, size_t tlvs_len)
639{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700640 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
641 tlvs, tlvs_len);
642}
643
644
645/**
646 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
647 * @dev_addr: Who sent the request or responded to our request.
648 * @request: Will be 1 if request, 0 for response.
649 * @status: Valid only in case of response (0 in case of success)
650 * @config_methods: WPS config methods
651 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
652 *
653 * This can be used to notify:
654 * - Requests or responses
655 * - Various config methods
656 * - Failure condition in case of response
657 */
658void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
659 const u8 *dev_addr, int request,
660 enum p2p_prov_disc_status status,
661 u16 config_methods,
662 unsigned int generated_pin)
663{
664 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
665 status, config_methods,
666 generated_pin);
667}
668
669
670void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700671 struct wpa_ssid *ssid, int persistent,
Jouni Malinen75ecf522011-06-27 15:19:46 -0700672 int client)
673{
674 /* Notify a group has been started */
675 wpas_dbus_register_p2p_group(wpa_s, ssid);
676
Dmitry Shmidtd5ab1b52016-06-21 12:38:41 -0700677 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700678}
679
680
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800681void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
682 const char *reason)
683{
684 /* Notify a group formation failed */
685 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
686}
687
688
Jouni Malinen75ecf522011-06-27 15:19:46 -0700689void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
690 struct wps_event_fail *fail)
691{
692 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700693}
694
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800695
696void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
697 const u8 *sa, const u8 *go_dev_addr,
698 const u8 *bssid, int id, int op_freq)
699{
700 /* Notify a P2P Invitation Request */
701 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
702 id, op_freq);
703}
704
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700705#endif /* CONFIG_P2P */
706
707
708static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800709 const u8 *sta,
710 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700711{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700712#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800713 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
714
Jouni Malinen75ecf522011-06-27 15:19:46 -0700715 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700716 * Create 'peer-joined' signal on group object -- will also
717 * check P2P itself.
718 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800719 if (p2p_dev_addr)
720 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700721#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700722
723 /* Notify listeners a new station has been authorized */
724 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700725}
726
727
728static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700729 const u8 *sta,
730 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700731{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700732#ifdef CONFIG_P2P
733 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700734 * Create 'peer-disconnected' signal on group object if this
735 * is a P2P group.
736 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800737 if (p2p_dev_addr)
738 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700739#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700740
741 /* Notify listeners a station has been deauthorized */
742 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700743}
744
745
746void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800747 const u8 *mac_addr, int authorized,
748 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700749{
750 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800751 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700752 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700753 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700754}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700755
756
757void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800758 const char *subject, const char *altsubject[],
759 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700760 const struct wpabuf *cert)
761{
762 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
763 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800764 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700765 cert_hash ? cert_hash : "");
766
767 if (cert) {
768 char *cert_hex;
769 size_t len = wpabuf_len(cert) * 2 + 1;
770 cert_hex = os_malloc(len);
771 if (cert_hex) {
772 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
773 wpabuf_len(cert));
774 wpa_msg_ctrl(wpa_s, MSG_INFO,
775 WPA_EVENT_EAP_PEER_CERT
776 "depth=%d subject='%s' cert=%s",
777 depth, subject, cert_hex);
778 os_free(cert_hex);
779 }
780 }
781
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800782 if (altsubject) {
783 int i;
784
785 for (i = 0; i < num_altsubject; i++)
786 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
787 "depth=%d %s", depth, altsubject[i]);
788 }
789
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700790 /* notify the old DBus API */
791 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
792 cert_hash, cert);
793 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800794 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
795 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700796}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700797
798
799void wpas_notify_preq(struct wpa_supplicant *wpa_s,
800 const u8 *addr, const u8 *dst, const u8 *bssid,
801 const u8 *ie, size_t ie_len, u32 ssi_signal)
802{
803#ifdef CONFIG_AP
804 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
805#endif /* CONFIG_AP */
806}
807
808
809void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
810 const char *parameter)
811{
812 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700813 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
814 "status='%s' parameter='%s'",
815 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700816}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700817
818
819void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
820 struct wpa_ssid *ssid)
821{
822 if (wpa_s->current_ssid != ssid)
823 return;
824
825 wpa_dbg(wpa_s, MSG_DEBUG,
826 "Network bssid config changed for the current network - within-ESS roaming %s",
827 ssid->bssid_set ? "disabled" : "enabled");
828
829 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
830 ssid->bssid_set ? ssid->bssid : NULL);
831}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800832
833
834void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
835 struct wpa_ssid *ssid)
836{
837#ifdef CONFIG_P2P
838 if (ssid->disabled == 2) {
839 /* Changed from normal network profile to persistent group */
840 ssid->disabled = 0;
841 wpas_dbus_unregister_network(wpa_s, ssid->id);
842 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700843 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800844 wpas_dbus_register_persistent_group(wpa_s, ssid);
845 } else {
846 /* Changed from persistent group to normal network profile */
847 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700848 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800849 wpas_dbus_register_network(wpa_s, ssid);
850 }
851#endif /* CONFIG_P2P */
852}