blob: 325883dd97285a14e16fd7606760f97f8314c891 [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"
26
27int wpas_notify_supplicant_initialized(struct wpa_global *global)
28{
29#ifdef CONFIG_DBUS
30 if (global->params.dbus_ctrl_interface) {
31 global->dbus = wpas_dbus_init(global);
32 if (global->dbus == NULL)
33 return -1;
34 }
35#endif /* CONFIG_DBUS */
36
37 return 0;
38}
39
40
41void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
42{
43#ifdef CONFIG_DBUS
44 if (global->dbus)
45 wpas_dbus_deinit(global->dbus);
46#endif /* CONFIG_DBUS */
47}
48
49
50int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
51{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080052 if (wpa_s->p2p_mgmt)
53 return 0;
54
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070055 if (wpas_dbus_register_iface(wpa_s))
56 return -1;
57
58 if (wpas_dbus_register_interface(wpa_s))
59 return -1;
60
61 return 0;
62}
63
64
65void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
66{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080067 if (wpa_s->p2p_mgmt)
68 return;
69
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070070 /* unregister interface in old DBus ctrl iface */
71 wpas_dbus_unregister_iface(wpa_s);
72
73 /* unregister interface in new DBus ctrl iface */
74 wpas_dbus_unregister_interface(wpa_s);
75}
76
77
78void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
79 enum wpa_states new_state,
80 enum wpa_states old_state)
81{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080082 if (wpa_s->p2p_mgmt)
83 return;
84
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070085 /* notify the old DBus API */
86 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
87 old_state);
88
89 /* notify the new DBus API */
90 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
91
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080092#ifdef CONFIG_FST
93 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
94 if (new_state == WPA_COMPLETED)
95 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
96 else if (old_state >= WPA_ASSOCIATED &&
97 new_state < WPA_ASSOCIATED)
98 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
99 }
100#endif /* CONFIG_FST */
101
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700102 if (new_state == WPA_COMPLETED)
103 wpas_p2p_notif_connected(wpa_s);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700104 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700105 wpas_p2p_notif_disconnected(wpa_s);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700106
107 sme_state_changed(wpa_s);
108
109#ifdef ANDROID
110 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
Irfan Sherifff20a4432012-04-16 16:48:34 -0700111 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700112 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
Irfan Sherifff20a4432012-04-16 16:48:34 -0700113 new_state,
Irfan Sheriffe78e7672012-08-01 11:10:15 -0700114 MAC2STR(wpa_s->bssid),
andy2_kuo5b5fb022012-05-22 11:53:07 -0700115 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
116 wpa_ssid_txt(wpa_s->current_ssid->ssid,
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800117 wpa_s->current_ssid->ssid_len) : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700118#endif /* ANDROID */
119}
120
121
Dmitry Shmidt04949592012-07-19 12:16:46 -0700122void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
123{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800124 if (wpa_s->p2p_mgmt)
125 return;
126
Dmitry Shmidt04949592012-07-19 12:16:46 -0700127 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
128}
129
130
Dmitry Shmidt31a29cc2016-03-09 15:58:17 -0800131void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
132{
133 if (wpa_s->p2p_mgmt)
134 return;
135
136 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
137}
138
139
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700140void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
141{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800142 if (wpa_s->p2p_mgmt)
143 return;
144
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700145 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
146}
147
148
149void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
150{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800151 if (wpa_s->p2p_mgmt)
152 return;
153
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700154 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
155}
156
157
158void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
159{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800160 if (wpa_s->p2p_mgmt)
161 return;
162
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700163 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
164}
165
166
167void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
168{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800169 if (wpa_s->p2p_mgmt)
170 return;
171
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700172 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
173}
174
175
176void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
177 struct wpa_ssid *ssid)
178{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800179 if (wpa_s->p2p_mgmt)
180 return;
181
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700182 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
183}
184
185
186void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
187 struct wpa_ssid *ssid)
188{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800189 if (wpa_s->p2p_mgmt)
190 return;
191
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700192 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
193}
194
195
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800196void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
197 struct wpa_ssid *ssid,
198 enum wpa_ctrl_req_type rtype,
199 const char *default_txt)
200{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800201 if (wpa_s->p2p_mgmt)
202 return;
203
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800204 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
205}
206
207
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700208void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
209{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800210 if (wpa_s->p2p_mgmt)
211 return;
212
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700213 /* notify the old DBus API */
214 wpa_supplicant_dbus_notify_scanning(wpa_s);
215
216 /* notify the new DBus API */
217 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
218}
219
220
221void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
222{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800223 if (wpa_s->p2p_mgmt)
224 return;
225
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700226 wpas_dbus_signal_scan_done(wpa_s, success);
227}
228
229
230void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
231{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800232 if (wpa_s->p2p_mgmt)
233 return;
234
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700235 /* notify the old DBus API */
236 wpa_supplicant_dbus_notify_scan_results(wpa_s);
237
238 wpas_wps_notify_scan_results(wpa_s);
239}
240
241
242void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
243 const struct wps_credential *cred)
244{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800245 if (wpa_s->p2p_mgmt)
246 return;
247
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700248#ifdef CONFIG_WPS
249 /* notify the old DBus API */
250 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
251 /* notify the new DBus API */
252 wpas_dbus_signal_wps_cred(wpa_s, cred);
253#endif /* CONFIG_WPS */
254}
255
256
257void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
258 struct wps_event_m2d *m2d)
259{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800260 if (wpa_s->p2p_mgmt)
261 return;
262
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700263#ifdef CONFIG_WPS
264 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
265#endif /* CONFIG_WPS */
266}
267
268
269void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
270 struct wps_event_fail *fail)
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_fail(wpa_s, fail);
277#endif /* CONFIG_WPS */
278}
279
280
281void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
282{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800283 if (wpa_s->p2p_mgmt)
284 return;
285
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700286#ifdef CONFIG_WPS
287 wpas_dbus_signal_wps_event_success(wpa_s);
288#endif /* CONFIG_WPS */
289}
290
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700291void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
292{
293 if (wpa_s->p2p_mgmt)
294 return;
295
296#ifdef CONFIG_WPS
297 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
298#endif /* CONFIG_WPS */
299}
300
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700301
302void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
303 struct wpa_ssid *ssid)
304{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800305 if (wpa_s->p2p_mgmt)
306 return;
307
Jouni Malinen75ecf522011-06-27 15:19:46 -0700308 /*
309 * Networks objects created during any P2P activities should not be
310 * exposed out. They might/will confuse certain non-P2P aware
311 * applications since these network objects won't behave like
312 * regular ones.
313 */
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700314 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700315 wpas_dbus_register_network(wpa_s, ssid);
316}
317
318
319void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
320 struct wpa_ssid *ssid)
321{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700322#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700323 wpas_dbus_register_persistent_group(wpa_s, ssid);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700324#endif /* CONFIG_P2P */
Jouni Malinen75ecf522011-06-27 15:19:46 -0700325}
326
327
328void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
329 struct wpa_ssid *ssid)
330{
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700331#ifdef CONFIG_P2P
Jouni Malinen75ecf522011-06-27 15:19:46 -0700332 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700333#endif /* CONFIG_P2P */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700334}
335
336
337void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
338 struct wpa_ssid *ssid)
339{
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800340 if (wpa_s->next_ssid == ssid)
341 wpa_s->next_ssid = NULL;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800342 if (wpa_s->wpa)
343 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
Dmitry Shmidtcc00d5d2015-05-04 10:34:12 -0700344 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
345 !wpa_s->p2p_mgmt)
Jouni Malinen75ecf522011-06-27 15:19:46 -0700346 wpas_dbus_unregister_network(wpa_s, ssid->id);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800347 if (network_is_persistent_group(ssid))
348 wpas_notify_persistent_group_removed(wpa_s, ssid);
349
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800350 wpas_p2p_network_removed(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700351}
352
353
354void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
355 u8 bssid[], unsigned int id)
356{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800357 if (wpa_s->p2p_mgmt)
358 return;
359
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700360 wpas_dbus_register_bss(wpa_s, bssid, id);
361 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
362 id, MAC2STR(bssid));
363}
364
365
366void wpas_notify_bss_removed(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_unregister_bss(wpa_s, bssid, id);
373 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
374 id, MAC2STR(bssid));
375}
376
377
378void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
379 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_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
385}
386
387
388void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
389 unsigned int id)
390{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800391 if (wpa_s->p2p_mgmt)
392 return;
393
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700394 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
395 id);
396}
397
398
399void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
400 unsigned int id)
401{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800402 if (wpa_s->p2p_mgmt)
403 return;
404
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700405 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
406 id);
407}
408
409
410void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
411 unsigned int id)
412{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800413 if (wpa_s->p2p_mgmt)
414 return;
415
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700416 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
417}
418
419
420void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
421 unsigned int id)
422{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800423 if (wpa_s->p2p_mgmt)
424 return;
425
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700426 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
427}
428
429
430void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
431 unsigned int id)
432{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800433 if (wpa_s->p2p_mgmt)
434 return;
435
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700436 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
437}
438
439
440void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
441 unsigned int id)
442{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800443 if (wpa_s->p2p_mgmt)
444 return;
445
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800446#ifdef CONFIG_WPS
447 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
448#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700449}
450
451
452void wpas_notify_bss_ies_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 Shmidt8d520ff2011-05-09 14:06:53 -0700458 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
459}
460
461
462void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
463 unsigned int id)
464{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800465 if (wpa_s->p2p_mgmt)
466 return;
467
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700468 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
469}
470
471
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700472void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
473{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800474 if (wpa_s->p2p_mgmt)
475 return;
476
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700477 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
478}
479
480
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700481void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
482{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800483 if (wpa_s->p2p_mgmt)
484 return;
485
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700486 wpas_dbus_signal_blob_added(wpa_s, name);
487}
488
489
490void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
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_signal_blob_removed(wpa_s, name);
496}
497
498
499void wpas_notify_debug_level_changed(struct wpa_global *global)
500{
501 wpas_dbus_signal_debug_level_changed(global);
502}
503
504
505void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
506{
507 wpas_dbus_signal_debug_timestamp_changed(global);
508}
509
510
511void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
512{
513 wpas_dbus_signal_debug_show_keys_changed(global);
514}
515
516
517void wpas_notify_suspend(struct wpa_global *global)
518{
519 struct wpa_supplicant *wpa_s;
520
521 os_get_time(&global->suspend_time);
522 wpa_printf(MSG_DEBUG, "System suspend notification");
523 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
524 wpa_drv_suspend(wpa_s);
525}
526
527
528void wpas_notify_resume(struct wpa_global *global)
529{
530 struct os_time now;
531 int slept;
532 struct wpa_supplicant *wpa_s;
533
534 if (global->suspend_time.sec == 0)
535 slept = -1;
536 else {
537 os_get_time(&now);
538 slept = now.sec - global->suspend_time.sec;
539 }
540 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
541 slept);
542
543 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
544 wpa_drv_resume(wpa_s);
545 if (wpa_s->wpa_state == WPA_DISCONNECTED)
546 wpa_supplicant_req_scan(wpa_s, 0, 100000);
547 }
548}
549
550
551#ifdef CONFIG_P2P
552
Dmitry Shmidt8bd70b72015-05-26 16:02:19 -0700553void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
554{
555 /* Notify P2P find has stopped */
556 wpas_dbus_signal_p2p_find_stopped(wpa_s);
557}
558
559
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700560void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
561 const u8 *dev_addr, int new_device)
562{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700563 if (new_device) {
564 /* Create the new peer object */
565 wpas_dbus_register_peer(wpa_s, dev_addr);
566 }
567
568 /* Notify a new peer has been detected*/
569 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700570}
571
572
573void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
574 const u8 *dev_addr)
575{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700576 wpas_dbus_unregister_peer(wpa_s, dev_addr);
577
578 /* Create signal on interface object*/
579 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700580}
581
582
583void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
584 const struct wpa_ssid *ssid,
585 const char *role)
586{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700587 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
Dmitry Shmidt03658832014-08-13 11:03:49 -0700588
589 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700590}
591
592
593void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700594 const u8 *src, u16 dev_passwd_id, u8 go_intent)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700595{
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700596 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700597}
598
599
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800600void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
601 struct p2p_go_neg_results *res)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700602{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800603 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700604}
605
606
607void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
608 int status, const u8 *bssid)
609{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700610 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700611}
612
613
614void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
615 int freq, const u8 *sa, u8 dialog_token,
616 u16 update_indic, const u8 *tlvs,
617 size_t tlvs_len)
618{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700619 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
620 update_indic, tlvs, tlvs_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700621}
622
623
624void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
625 const u8 *sa, u16 update_indic,
626 const u8 *tlvs, size_t tlvs_len)
627{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700628 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
629 tlvs, tlvs_len);
630}
631
632
633/**
634 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
635 * @dev_addr: Who sent the request or responded to our request.
636 * @request: Will be 1 if request, 0 for response.
637 * @status: Valid only in case of response (0 in case of success)
638 * @config_methods: WPS config methods
639 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
640 *
641 * This can be used to notify:
642 * - Requests or responses
643 * - Various config methods
644 * - Failure condition in case of response
645 */
646void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
647 const u8 *dev_addr, int request,
648 enum p2p_prov_disc_status status,
649 u16 config_methods,
650 unsigned int generated_pin)
651{
652 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
653 status, config_methods,
654 generated_pin);
655}
656
657
658void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
659 struct wpa_ssid *ssid, int network_id,
660 int client)
661{
662 /* Notify a group has been started */
663 wpas_dbus_register_p2p_group(wpa_s, ssid);
664
665 wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id);
666}
667
668
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800669void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
670 const char *reason)
671{
672 /* Notify a group formation failed */
673 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
674}
675
676
Jouni Malinen75ecf522011-06-27 15:19:46 -0700677void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
678 struct wps_event_fail *fail)
679{
680 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700681}
682
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800683
684void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
685 const u8 *sa, const u8 *go_dev_addr,
686 const u8 *bssid, int id, int op_freq)
687{
688 /* Notify a P2P Invitation Request */
689 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
690 id, op_freq);
691}
692
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700693#endif /* CONFIG_P2P */
694
695
696static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800697 const u8 *sta,
698 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700699{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700700#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800701 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
702
Jouni Malinen75ecf522011-06-27 15:19:46 -0700703 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700704 * Create 'peer-joined' signal on group object -- will also
705 * check P2P itself.
706 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800707 if (p2p_dev_addr)
708 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700709#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700710
711 /* Notify listeners a new station has been authorized */
712 wpas_dbus_signal_sta_authorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700713}
714
715
716static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700717 const u8 *sta,
718 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700719{
Jouni Malinen75ecf522011-06-27 15:19:46 -0700720#ifdef CONFIG_P2P
721 /*
Jouni Malinen75ecf522011-06-27 15:19:46 -0700722 * Create 'peer-disconnected' signal on group object if this
723 * is a P2P group.
724 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800725 if (p2p_dev_addr)
726 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
Jouni Malinen75ecf522011-06-27 15:19:46 -0700727#endif /* CONFIG_P2P */
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700728
729 /* Notify listeners a station has been deauthorized */
730 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700731}
732
733
734void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800735 const u8 *mac_addr, int authorized,
736 const u8 *p2p_dev_addr)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700737{
738 if (authorized)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800739 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700740 else
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700741 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700742}
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700743
744
745void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800746 const char *subject, const char *altsubject[],
747 int num_altsubject, const char *cert_hash,
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700748 const struct wpabuf *cert)
749{
750 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
751 "depth=%d subject='%s'%s%s",
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800752 depth, subject, cert_hash ? " hash=" : "",
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700753 cert_hash ? cert_hash : "");
754
755 if (cert) {
756 char *cert_hex;
757 size_t len = wpabuf_len(cert) * 2 + 1;
758 cert_hex = os_malloc(len);
759 if (cert_hex) {
760 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
761 wpabuf_len(cert));
762 wpa_msg_ctrl(wpa_s, MSG_INFO,
763 WPA_EVENT_EAP_PEER_CERT
764 "depth=%d subject='%s' cert=%s",
765 depth, subject, cert_hex);
766 os_free(cert_hex);
767 }
768 }
769
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800770 if (altsubject) {
771 int i;
772
773 for (i = 0; i < num_altsubject; i++)
774 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
775 "depth=%d %s", depth, altsubject[i]);
776 }
777
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700778 /* notify the old DBus API */
779 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
780 cert_hash, cert);
781 /* notify the new DBus API */
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800782 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
783 num_altsubject, cert_hash, cert);
Dmitry Shmidtc55524a2011-07-07 11:18:38 -0700784}
Dmitry Shmidt04949592012-07-19 12:16:46 -0700785
786
787void wpas_notify_preq(struct wpa_supplicant *wpa_s,
788 const u8 *addr, const u8 *dst, const u8 *bssid,
789 const u8 *ie, size_t ie_len, u32 ssi_signal)
790{
791#ifdef CONFIG_AP
792 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
793#endif /* CONFIG_AP */
794}
795
796
797void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
798 const char *parameter)
799{
800 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700801 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
802 "status='%s' parameter='%s'",
803 status, parameter);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700804}
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700805
806
807void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
808 struct wpa_ssid *ssid)
809{
810 if (wpa_s->current_ssid != ssid)
811 return;
812
813 wpa_dbg(wpa_s, MSG_DEBUG,
814 "Network bssid config changed for the current network - within-ESS roaming %s",
815 ssid->bssid_set ? "disabled" : "enabled");
816
817 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
818 ssid->bssid_set ? ssid->bssid : NULL);
819}
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800820
821
822void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
823 struct wpa_ssid *ssid)
824{
825#ifdef CONFIG_P2P
826 if (ssid->disabled == 2) {
827 /* Changed from normal network profile to persistent group */
828 ssid->disabled = 0;
829 wpas_dbus_unregister_network(wpa_s, ssid->id);
830 ssid->disabled = 2;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700831 ssid->p2p_persistent_group = 1;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800832 wpas_dbus_register_persistent_group(wpa_s, ssid);
833 } else {
834 /* Changed from persistent group to normal network profile */
835 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -0700836 ssid->p2p_persistent_group = 0;
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800837 wpas_dbus_register_network(wpa_s, ssid);
838 }
839#endif /* CONFIG_P2P */
840}