]> git.ipfire.org Git - thirdparty/hostap.git/blame - wpa_supplicant/notify.c
dbus: Export roam time, roam complete, and session length
[thirdparty/hostap.git] / wpa_supplicant / notify.c
CommitLineData
8bac466b
JM
1/*
2 * wpa_supplicant - Event notifications
207ef3fb 3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
8bac466b 4 *
0f3d578e
JM
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
8bac466b
JM
7 */
8
f0d126d3 9#include "utils/includes.h"
8bac466b 10
f0d126d3
JM
11#include "utils/common.h"
12#include "common/wpa_ctrl.h"
8bac466b
JM
13#include "config.h"
14#include "wpa_supplicant_i.h"
15#include "wps_supplicant.h"
7b4bbb9f 16#include "binder/binder.h"
8ddef94b 17#include "dbus/dbus_common.h"
bacfd05f 18#include "dbus/dbus_old.h"
6d59e14c 19#include "dbus/dbus_new.h"
d8a790b9 20#include "rsn_supp/wpa.h"
b36a3a65 21#include "fst/fst.h"
207ef3fb
JM
22#include "driver_i.h"
23#include "scan.h"
72044390 24#include "p2p_supplicant.h"
e29853bb 25#include "sme.h"
8bac466b
JM
26#include "notify.h"
27
dc461de4
WS
28int wpas_notify_supplicant_initialized(struct wpa_global *global)
29{
8ddef94b 30#ifdef CONFIG_DBUS
dc461de4 31 if (global->params.dbus_ctrl_interface) {
8ddef94b
JM
32 global->dbus = wpas_dbus_init(global);
33 if (global->dbus == NULL)
85d3f273 34 return -1;
dc461de4 35 }
8ddef94b 36#endif /* CONFIG_DBUS */
dc461de4 37
7b4bbb9f
RP
38#ifdef CONFIG_BINDER
39 global->binder = wpas_binder_init(global);
40 if (!global->binder)
41 return -1;
42#endif /* CONFIG_BINDER */
43
dc461de4
WS
44 return 0;
45}
46
47
48void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
49{
8ddef94b
JM
50#ifdef CONFIG_DBUS
51 if (global->dbus)
52 wpas_dbus_deinit(global->dbus);
53#endif /* CONFIG_DBUS */
7b4bbb9f
RP
54
55#ifdef CONFIG_BINDER
56 if (global->binder)
57 wpas_binder_deinit(global->binder);
58#endif /* CONFIG_BINDER */
dc461de4
WS
59}
60
61
62int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
63{
bb3df9a5
TB
64 if (wpa_s->p2p_mgmt)
65 return 0;
66
dc461de4
WS
67 if (wpas_dbus_register_iface(wpa_s))
68 return -1;
69
52bdd880 70 if (wpas_dbus_register_interface(wpa_s))
8fc2fb56
WS
71 return -1;
72
dc461de4
WS
73 return 0;
74}
75
76
dc461de4
WS
77void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
78{
bb3df9a5
TB
79 if (wpa_s->p2p_mgmt)
80 return;
81
dc461de4
WS
82 /* unregister interface in old DBus ctrl iface */
83 wpas_dbus_unregister_iface(wpa_s);
8fc2fb56
WS
84
85 /* unregister interface in new DBus ctrl iface */
52bdd880 86 wpas_dbus_unregister_interface(wpa_s);
dc461de4
WS
87}
88
8bac466b
JM
89
90void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
71934751
JM
91 enum wpa_states new_state,
92 enum wpa_states old_state)
8bac466b 93{
bb3df9a5
TB
94 if (wpa_s->p2p_mgmt)
95 return;
96
8bac466b
JM
97 /* notify the old DBus API */
98 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
99 old_state);
8fc2fb56
WS
100
101 /* notify the new DBus API */
27f43d8d 102 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
72044390 103
b36a3a65
AN
104#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
72044390
JM
114 if (new_state == WPA_COMPLETED)
115 wpas_p2p_notif_connected(wpa_s);
dbe7aa22 116 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
72044390 117 wpas_p2p_notif_disconnected(wpa_s);
e29853bb
BG
118
119 sme_state_changed(wpa_s);
4e2ead7a
DS
120
121#ifdef ANDROID
122 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
6b499076 123 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
4e2ead7a 124 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
6b499076
DS
125 new_state,
126 MAC2STR(wpa_s->bssid),
127 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
128 wpa_ssid_txt(wpa_s->current_ssid->ssid,
129 wpa_s->current_ssid->ssid_len) : "");
4e2ead7a 130#endif /* ANDROID */
8bac466b
JM
131}
132
133
0bb1e425
GM
134void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
135{
bb3df9a5
TB
136 if (wpa_s->p2p_mgmt)
137 return;
138
0bb1e425
GM
139 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
140}
141
142
c7fb678f
NS
143void 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
2bbad1c7
MW
152void wpas_notify_roam_time(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_ROAM_TIME);
158}
159
160
161void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
162{
163 if (wpa_s->p2p_mgmt)
164 return;
165
166 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
167}
168
169
170void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
171{
172 if (wpa_s->p2p_mgmt)
173 return;
174
175 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
176}
177
178
8bac466b
JM
179void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
180{
bb3df9a5
TB
181 if (wpa_s->p2p_mgmt)
182 return;
183
52bdd880 184 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
8bac466b
JM
185}
186
187
188void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
189{
bb3df9a5
TB
190 if (wpa_s->p2p_mgmt)
191 return;
192
52bdd880 193 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
8bac466b
JM
194}
195
196
197void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
198{
bb3df9a5
TB
199 if (wpa_s->p2p_mgmt)
200 return;
201
52bdd880 202 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
8bac466b
JM
203}
204
205
5bbf9f10
PS
206void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
207{
bb3df9a5
TB
208 if (wpa_s->p2p_mgmt)
209 return;
210
5bbf9f10
PS
211 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
212}
213
214
8bac466b
JM
215void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
216 struct wpa_ssid *ssid)
217{
bb3df9a5
TB
218 if (wpa_s->p2p_mgmt)
219 return;
220
52bdd880 221 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
8bac466b
JM
222}
223
224
225void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
226 struct wpa_ssid *ssid)
227{
bb3df9a5
TB
228 if (wpa_s->p2p_mgmt)
229 return;
230
52bdd880 231 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
8bac466b
JM
232}
233
234
a9022616
DW
235void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
236 struct wpa_ssid *ssid,
237 enum wpa_ctrl_req_type rtype,
238 const char *default_txt)
239{
bb3df9a5
TB
240 if (wpa_s->p2p_mgmt)
241 return;
242
a9022616
DW
243 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
244}
245
246
8bac466b
JM
247void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
248{
bb3df9a5
TB
249 if (wpa_s->p2p_mgmt)
250 return;
251
8bac466b
JM
252 /* notify the old DBus API */
253 wpa_supplicant_dbus_notify_scanning(wpa_s);
27f43d8d 254
8fc2fb56 255 /* notify the new DBus API */
52bdd880 256 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
8bac466b
JM
257}
258
259
260void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
261{
bb3df9a5
TB
262 if (wpa_s->p2p_mgmt)
263 return;
264
52bdd880 265 wpas_dbus_signal_scan_done(wpa_s, success);
8bac466b
JM
266}
267
268
269void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
270{
bb3df9a5
TB
271 if (wpa_s->p2p_mgmt)
272 return;
273
8bac466b
JM
274 /* notify the old DBus API */
275 wpa_supplicant_dbus_notify_scan_results(wpa_s);
276
277 wpas_wps_notify_scan_results(wpa_s);
278}
279
280
281void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
282 const struct wps_credential *cred)
283{
bb3df9a5
TB
284 if (wpa_s->p2p_mgmt)
285 return;
286
b99b8e15 287#ifdef CONFIG_WPS
8bac466b
JM
288 /* notify the old DBus API */
289 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
8fc2fb56 290 /* notify the new DBus API */
52bdd880 291 wpas_dbus_signal_wps_cred(wpa_s, cred);
b99b8e15 292#endif /* CONFIG_WPS */
8bac466b
JM
293}
294
295
296void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
297 struct wps_event_m2d *m2d)
298{
bb3df9a5
TB
299 if (wpa_s->p2p_mgmt)
300 return;
301
b99b8e15 302#ifdef CONFIG_WPS
52bdd880 303 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
b99b8e15 304#endif /* CONFIG_WPS */
8bac466b
JM
305}
306
307
308void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
309 struct wps_event_fail *fail)
310{
bb3df9a5
TB
311 if (wpa_s->p2p_mgmt)
312 return;
313
b99b8e15 314#ifdef CONFIG_WPS
52bdd880 315 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
b99b8e15 316#endif /* CONFIG_WPS */
8bac466b
JM
317}
318
319
320void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
321{
bb3df9a5
TB
322 if (wpa_s->p2p_mgmt)
323 return;
324
b99b8e15 325#ifdef CONFIG_WPS
52bdd880 326 wpas_dbus_signal_wps_event_success(wpa_s);
b99b8e15 327#endif /* CONFIG_WPS */
8bac466b
JM
328}
329
1a2f7ca1
AA
330void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
331{
332 if (wpa_s->p2p_mgmt)
333 return;
334
335#ifdef CONFIG_WPS
336 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
337#endif /* CONFIG_WPS */
338}
339
8bac466b
JM
340
341void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
342 struct wpa_ssid *ssid)
343{
bb3df9a5
TB
344 if (wpa_s->p2p_mgmt)
345 return;
346
c2762e41
JS
347 /*
348 * Networks objects created during any P2P activities should not be
349 * exposed out. They might/will confuse certain non-P2P aware
350 * applications since these network objects won't behave like
351 * regular ones.
352 */
447969e0 353 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
c2762e41
JS
354 wpas_dbus_register_network(wpa_s, ssid);
355}
356
357
358void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
359 struct wpa_ssid *ssid)
360{
7a2b53b4 361#ifdef CONFIG_P2P
c2762e41 362 wpas_dbus_register_persistent_group(wpa_s, ssid);
7a2b53b4 363#endif /* CONFIG_P2P */
8bac466b
JM
364}
365
366
28550706
JS
367void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
368 struct wpa_ssid *ssid)
369{
7a2b53b4 370#ifdef CONFIG_P2P
28550706 371 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
7a2b53b4 372#endif /* CONFIG_P2P */
28550706
JS
373}
374
375
8bac466b
JM
376void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
377 struct wpa_ssid *ssid)
378{
3d910ef4
JM
379 if (wpa_s->next_ssid == ssid)
380 wpa_s->next_ssid = NULL;
8c0d3b4f
JM
381 if (wpa_s->wpa)
382 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
5441da2b
JM
383 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
384 !wpa_s->p2p_mgmt)
c2762e41 385 wpas_dbus_unregister_network(wpa_s, ssid->id);
5f136bc1
JM
386 if (network_is_persistent_group(ssid))
387 wpas_notify_persistent_group_removed(wpa_s, ssid);
388
502618f7 389 wpas_p2p_network_removed(wpa_s, ssid);
8bac466b
JM
390}
391
392
71f6e1f6 393void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
f0d126d3 394 u8 bssid[], unsigned int id)
71f6e1f6 395{
bb3df9a5
TB
396 if (wpa_s->p2p_mgmt)
397 return;
398
52bdd880 399 wpas_dbus_register_bss(wpa_s, bssid, id);
f0d126d3
JM
400 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
401 id, MAC2STR(bssid));
71f6e1f6
WS
402}
403
404
405void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
f0d126d3 406 u8 bssid[], unsigned int id)
71f6e1f6 407{
bb3df9a5
TB
408 if (wpa_s->p2p_mgmt)
409 return;
410
52bdd880 411 wpas_dbus_unregister_bss(wpa_s, bssid, id);
f0d126d3
JM
412 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
413 id, MAC2STR(bssid));
71f6e1f6
WS
414}
415
416
158c6c74
WS
417void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
418 unsigned int id)
419{
bb3df9a5
TB
420 if (wpa_s->p2p_mgmt)
421 return;
422
158c6c74
WS
423 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
424}
425
426
427void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
428 unsigned int id)
429{
bb3df9a5
TB
430 if (wpa_s->p2p_mgmt)
431 return;
432
158c6c74
WS
433 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
434 id);
435}
436
437
438void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
439 unsigned int id)
440{
bb3df9a5
TB
441 if (wpa_s->p2p_mgmt)
442 return;
443
158c6c74
WS
444 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
445 id);
446}
447
448
449void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
450 unsigned int id)
451{
bb3df9a5
TB
452 if (wpa_s->p2p_mgmt)
453 return;
454
158c6c74
WS
455 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
456}
457
458
459void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
460 unsigned int id)
461{
bb3df9a5
TB
462 if (wpa_s->p2p_mgmt)
463 return;
464
7899e2f4 465 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
158c6c74
WS
466}
467
468
469void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
470 unsigned int id)
471{
bb3df9a5
TB
472 if (wpa_s->p2p_mgmt)
473 return;
474
7899e2f4 475 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
158c6c74
WS
476}
477
478
479void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
7899e2f4
WS
480 unsigned int id)
481{
bb3df9a5
TB
482 if (wpa_s->p2p_mgmt)
483 return;
484
caff3992
SN
485#ifdef CONFIG_WPS
486 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
487#endif /* CONFIG_WPS */
7899e2f4
WS
488}
489
490
491void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
158c6c74
WS
492 unsigned int id)
493{
bb3df9a5
TB
494 if (wpa_s->p2p_mgmt)
495 return;
496
7899e2f4 497 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
158c6c74
WS
498}
499
500
501void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
502 unsigned int id)
503{
bb3df9a5
TB
504 if (wpa_s->p2p_mgmt)
505 return;
506
158c6c74
WS
507 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
508}
509
510
3bd3257a
DW
511void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
512{
bb3df9a5
TB
513 if (wpa_s->p2p_mgmt)
514 return;
515
3bd3257a
DW
516 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
517}
518
519
8bac466b
JM
520void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
521{
bb3df9a5
TB
522 if (wpa_s->p2p_mgmt)
523 return;
524
52bdd880 525 wpas_dbus_signal_blob_added(wpa_s, name);
8bac466b
JM
526}
527
528
529void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
530{
bb3df9a5
TB
531 if (wpa_s->p2p_mgmt)
532 return;
533
52bdd880 534 wpas_dbus_signal_blob_removed(wpa_s, name);
8bac466b
JM
535}
536
537
db9133ac 538void wpas_notify_debug_level_changed(struct wpa_global *global)
8bac466b 539{
52bdd880 540 wpas_dbus_signal_debug_level_changed(global);
db9133ac
WS
541}
542
543
544void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
545{
52bdd880 546 wpas_dbus_signal_debug_timestamp_changed(global);
db9133ac
WS
547}
548
549
550void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
551{
52bdd880 552 wpas_dbus_signal_debug_show_keys_changed(global);
8bac466b 553}
207ef3fb
JM
554
555
556void wpas_notify_suspend(struct wpa_global *global)
557{
558 struct wpa_supplicant *wpa_s;
559
560 os_get_time(&global->suspend_time);
561 wpa_printf(MSG_DEBUG, "System suspend notification");
562 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
563 wpa_drv_suspend(wpa_s);
564}
565
566
567void wpas_notify_resume(struct wpa_global *global)
568{
569 struct os_time now;
570 int slept;
571 struct wpa_supplicant *wpa_s;
572
573 if (global->suspend_time.sec == 0)
574 slept = -1;
575 else {
576 os_get_time(&now);
577 slept = now.sec - global->suspend_time.sec;
578 }
579 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
580 slept);
581
582 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
583 wpa_drv_resume(wpa_s);
584 if (wpa_s->wpa_state == WPA_DISCONNECTED)
585 wpa_supplicant_req_scan(wpa_s, 0, 100000);
586 }
587}
d642d2d2
JB
588
589
590#ifdef CONFIG_P2P
56eeb8f2 591
7b642dc8
NC
592void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
593{
594 /* Notify P2P find has stopped */
595 wpas_dbus_signal_p2p_find_stopped(wpa_s);
596}
597
598
d642d2d2
JB
599void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
600 const u8 *dev_addr, int new_device)
601{
9abafccc
JB
602 if (new_device) {
603 /* Create the new peer object */
604 wpas_dbus_register_peer(wpa_s, dev_addr);
605 }
606
607 /* Notify a new peer has been detected*/
608 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
d642d2d2 609}
56eeb8f2
JB
610
611
612void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
613 const u8 *dev_addr)
614{
9abafccc
JB
615 wpas_dbus_unregister_peer(wpa_s, dev_addr);
616
617 /* Create signal on interface object*/
618 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
56eeb8f2
JB
619}
620
408af93e
JB
621
622void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
623 const struct wpa_ssid *ssid,
624 const char *role)
625{
9abafccc 626 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
4a0693a4
TB
627
628 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
408af93e
JB
629}
630
32d1bce0
KRK
631
632void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
aa2b1256 633 const u8 *src, u16 dev_passwd_id, u8 go_intent)
32d1bce0 634{
aa2b1256 635 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
32d1bce0
KRK
636}
637
c2641bf7 638
e5a359cf
RC
639void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
640 struct p2p_go_neg_results *res)
c2641bf7 641{
e5a359cf 642 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
c2641bf7
JS
643}
644
5ccdf84f
JMB
645
646void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
647 int status, const u8 *bssid)
648{
9abafccc 649 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
5ccdf84f
JMB
650}
651
e1653cac
KRK
652
653void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
654 int freq, const u8 *sa, u8 dialog_token,
655 u16 update_indic, const u8 *tlvs,
656 size_t tlvs_len)
657{
9abafccc
JB
658 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
659 update_indic, tlvs, tlvs_len);
e1653cac
KRK
660}
661
43a26f60
KRK
662
663void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
664 const u8 *sa, u16 update_indic,
665 const u8 *tlvs, size_t tlvs_len)
666{
9abafccc
JB
667 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
668 tlvs, tlvs_len);
43a26f60
KRK
669}
670
dd8a7e05
JB
671
672/**
673 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
674 * @dev_addr: Who sent the request or responded to our request.
675 * @request: Will be 1 if request, 0 for response.
676 * @status: Valid only in case of response (0 in case of success)
677 * @config_methods: WPS config methods
678 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
679 *
680 * This can be used to notify:
681 * - Requests or responses
682 * - Various config methods
683 * - Failure condition in case of response
684 */
685void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
686 const u8 *dev_addr, int request,
687 enum p2p_prov_disc_status status,
688 u16 config_methods,
689 unsigned int generated_pin)
690{
9abafccc
JB
691 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
692 status, config_methods,
693 generated_pin);
dd8a7e05 694}
4b6baa2f
JMB
695
696
697void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
4fe50bbc 698 struct wpa_ssid *ssid, int persistent,
18f16117 699 int client, const u8 *ip)
4b6baa2f 700{
9abafccc
JB
701 /* Notify a group has been started */
702 wpas_dbus_register_p2p_group(wpa_s, ssid);
703
18f16117 704 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
4b6baa2f 705}
3734552f
JS
706
707
2a95fac9
NC
708void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
709 const char *reason)
710{
711 /* Notify a group formation failed */
712 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
713}
714
715
3734552f
JS
716void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
717 struct wps_event_fail *fail)
718{
719 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
720}
721
be5ab8d4
MJ
722
723void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
724 const u8 *sa, const u8 *go_dev_addr,
725 const u8 *bssid, int id, int op_freq)
726{
727 /* Notify a P2P Invitation Request */
728 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
729 id, op_freq);
730}
731
d642d2d2 732#endif /* CONFIG_P2P */
d8a43924
JB
733
734
735static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
fbdcfd57
JM
736 const u8 *sta,
737 const u8 *p2p_dev_addr)
d8a43924 738{
692cb226 739#ifdef CONFIG_P2P
fbdcfd57
JM
740 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
741
9abafccc
JB
742 /*
743 * Create 'peer-joined' signal on group object -- will also
744 * check P2P itself.
745 */
11973b26
JM
746 if (p2p_dev_addr)
747 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
692cb226 748#endif /* CONFIG_P2P */
8a901d75 749
c3f23ad6
AS
750 /* Register the station */
751 wpas_dbus_register_sta(wpa_s, sta);
752
8a901d75
CZ
753 /* Notify listeners a new station has been authorized */
754 wpas_dbus_signal_sta_authorized(wpa_s, sta);
d8a43924
JB
755}
756
757
758static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
bf035663
TB
759 const u8 *sta,
760 const u8 *p2p_dev_addr)
d8a43924 761{
692cb226 762#ifdef CONFIG_P2P
9abafccc
JB
763 /*
764 * Create 'peer-disconnected' signal on group object if this
765 * is a P2P group.
766 */
11973b26
JM
767 if (p2p_dev_addr)
768 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
692cb226 769#endif /* CONFIG_P2P */
8a901d75
CZ
770
771 /* Notify listeners a station has been deauthorized */
772 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
c3f23ad6
AS
773
774 /* Unregister the station */
775 wpas_dbus_unregister_sta(wpa_s, sta);
d8a43924
JB
776}
777
778
779void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
fbdcfd57
JM
780 const u8 *mac_addr, int authorized,
781 const u8 *p2p_dev_addr)
d8a43924
JB
782{
783 if (authorized)
fbdcfd57 784 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
d8a43924 785 else
bf035663 786 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
d8a43924 787}
ade74830
MC
788
789
790void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
d07d3fbd
JM
791 const char *subject, const char *altsubject[],
792 int num_altsubject, const char *cert_hash,
ade74830
MC
793 const struct wpabuf *cert)
794{
4f525d8e
JM
795 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
796 "depth=%d subject='%s'%s%s",
d07d3fbd 797 depth, subject, cert_hash ? " hash=" : "",
4f525d8e
JM
798 cert_hash ? cert_hash : "");
799
800 if (cert) {
801 char *cert_hex;
802 size_t len = wpabuf_len(cert) * 2 + 1;
803 cert_hex = os_malloc(len);
804 if (cert_hex) {
805 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
806 wpabuf_len(cert));
807 wpa_msg_ctrl(wpa_s, MSG_INFO,
808 WPA_EVENT_EAP_PEER_CERT
809 "depth=%d subject='%s' cert=%s",
810 depth, subject, cert_hex);
811 os_free(cert_hex);
812 }
813 }
814
d07d3fbd
JM
815 if (altsubject) {
816 int i;
817
818 for (i = 0; i < num_altsubject; i++)
819 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
820 "depth=%d %s", depth, altsubject[i]);
821 }
822
ade74830
MC
823 /* notify the old DBus API */
824 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
825 cert_hash, cert);
826 /* notify the new DBus API */
d07d3fbd
JM
827 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
828 num_altsubject, cert_hash, cert);
ade74830 829}
2d43d37f
JB
830
831
832void wpas_notify_preq(struct wpa_supplicant *wpa_s,
833 const u8 *addr, const u8 *dst, const u8 *bssid,
834 const u8 *ie, size_t ie_len, u32 ssi_signal)
835{
836#ifdef CONFIG_AP
837 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
838#endif /* CONFIG_AP */
839}
dd7fec1f
PS
840
841
842void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
843 const char *parameter)
844{
845 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
c7a39ba4
CH
846 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
847 "status='%s' parameter='%s'",
848 status, parameter);
dd7fec1f 849}
0ef023e4
JM
850
851
45f7574d
AE
852void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
853{
854 wpa_msg(wpa_s, MSG_ERROR, WPA_EVENT_EAP_ERROR_CODE "%d", error_code);
855}
856
857
0ef023e4
JM
858void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
859 struct wpa_ssid *ssid)
860{
861 if (wpa_s->current_ssid != ssid)
862 return;
863
864 wpa_dbg(wpa_s, MSG_DEBUG,
865 "Network bssid config changed for the current network - within-ESS roaming %s",
866 ssid->bssid_set ? "disabled" : "enabled");
867
868 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
869 ssid->bssid_set ? ssid->bssid : NULL);
870}
1e529832
JM
871
872
873void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
874 struct wpa_ssid *ssid)
875{
876#ifdef CONFIG_P2P
877 if (ssid->disabled == 2) {
878 /* Changed from normal network profile to persistent group */
879 ssid->disabled = 0;
880 wpas_dbus_unregister_network(wpa_s, ssid->id);
881 ssid->disabled = 2;
661888be 882 ssid->p2p_persistent_group = 1;
1e529832
JM
883 wpas_dbus_register_persistent_group(wpa_s, ssid);
884 } else {
885 /* Changed from persistent group to normal network profile */
886 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
661888be 887 ssid->p2p_persistent_group = 0;
1e529832
JM
888 wpas_dbus_register_network(wpa_s, ssid);
889 }
890#endif /* CONFIG_P2P */
891}
89e9cd25
SB
892
893
894#ifdef CONFIG_MESH
a39b040b 895
89e9cd25
SB
896void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
897 struct wpa_ssid *ssid)
898{
899 if (wpa_s->p2p_mgmt)
900 return;
901
902 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
903}
a39b040b
SB
904
905
906void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
907 const u8 *meshid, u8 meshid_len,
908 int reason_code)
909{
910 if (wpa_s->p2p_mgmt)
911 return;
912
913 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
914 reason_code);
915}
916
9b0701fb
SB
917
918void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
919 const u8 *peer_addr)
920{
921 if (wpa_s->p2p_mgmt)
922 return;
923
924 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
925}
926
a9de99b1
SB
927
928void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
929 const u8 *peer_addr, int reason_code)
930{
931 if (wpa_s->p2p_mgmt)
932 return;
933
934 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
935}
936
89e9cd25 937#endif /* CONFIG_MESH */