]> git.ipfire.org Git - thirdparty/hostap.git/blame - wpa_supplicant/notify.c
Add attribute for dwell time in QCA vendor scan
[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"
6d59e14c 18#include "dbus/dbus_new.h"
d8a790b9 19#include "rsn_supp/wpa.h"
b36a3a65 20#include "fst/fst.h"
bc0634da 21#include "crypto/tls.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{
6a8dee76 30#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
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 }
6a8dee76 36#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
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{
6a8dee76 50#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
8ddef94b
JM
51 if (global->dbus)
52 wpas_dbus_deinit(global->dbus);
6a8dee76 53#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
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
52bdd880 67 if (wpas_dbus_register_interface(wpa_s))
8fc2fb56
WS
68 return -1;
69
dc461de4
WS
70 return 0;
71}
72
73
dc461de4
WS
74void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
75{
bb3df9a5
TB
76 if (wpa_s->p2p_mgmt)
77 return;
78
8fc2fb56 79 /* unregister interface in new DBus ctrl iface */
52bdd880 80 wpas_dbus_unregister_interface(wpa_s);
dc461de4
WS
81}
82
8bac466b
JM
83
84void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
71934751
JM
85 enum wpa_states new_state,
86 enum wpa_states old_state)
8bac466b 87{
bb3df9a5
TB
88 if (wpa_s->p2p_mgmt)
89 return;
90
8fc2fb56 91 /* notify the new DBus API */
27f43d8d 92 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
72044390 93
b36a3a65
AN
94#ifdef CONFIG_FST
95 if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
96 if (new_state == WPA_COMPLETED)
97 fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
98 else if (old_state >= WPA_ASSOCIATED &&
99 new_state < WPA_ASSOCIATED)
100 fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
101 }
102#endif /* CONFIG_FST */
103
72044390
JM
104 if (new_state == WPA_COMPLETED)
105 wpas_p2p_notif_connected(wpa_s);
dbe7aa22 106 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
72044390 107 wpas_p2p_notif_disconnected(wpa_s);
e29853bb
BG
108
109 sme_state_changed(wpa_s);
4e2ead7a
DS
110
111#ifdef ANDROID
112 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
6b499076 113 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
4e2ead7a 114 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
6b499076
DS
115 new_state,
116 MAC2STR(wpa_s->bssid),
117 wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
118 wpa_ssid_txt(wpa_s->current_ssid->ssid,
119 wpa_s->current_ssid->ssid_len) : "");
4e2ead7a 120#endif /* ANDROID */
8bac466b
JM
121}
122
123
0bb1e425
GM
124void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
125{
bb3df9a5
TB
126 if (wpa_s->p2p_mgmt)
127 return;
128
0bb1e425
GM
129 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
130}
131
132
38b405c8
AK
133void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
134{
135 if (wpa_s->p2p_mgmt)
136 return;
137
138 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
139}
140
141
c7fb678f
NS
142void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
143{
144 if (wpa_s->p2p_mgmt)
145 return;
146
147 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
148}
149
150
2bbad1c7
MW
151void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
152{
153 if (wpa_s->p2p_mgmt)
154 return;
155
156 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
157}
158
159
160void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
161{
162 if (wpa_s->p2p_mgmt)
163 return;
164
165 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
166}
167
168
169void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
170{
171 if (wpa_s->p2p_mgmt)
172 return;
173
174 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
175}
176
177
80d06d0c
MW
178void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
179{
180 if (wpa_s->p2p_mgmt)
181 return;
182
183 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
184}
185
186
8bac466b
JM
187void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
188{
bb3df9a5
TB
189 if (wpa_s->p2p_mgmt)
190 return;
191
52bdd880 192 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
8bac466b
JM
193}
194
195
196void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
197{
bb3df9a5
TB
198 if (wpa_s->p2p_mgmt)
199 return;
200
52bdd880 201 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
8bac466b
JM
202}
203
204
205void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
206{
bb3df9a5
TB
207 if (wpa_s->p2p_mgmt)
208 return;
209
52bdd880 210 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
8bac466b
JM
211}
212
213
5bbf9f10
PS
214void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
215{
bb3df9a5
TB
216 if (wpa_s->p2p_mgmt)
217 return;
218
5bbf9f10
PS
219 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
220}
221
222
8bac466b
JM
223void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
224 struct wpa_ssid *ssid)
225{
bb3df9a5
TB
226 if (wpa_s->p2p_mgmt)
227 return;
228
52bdd880 229 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
8bac466b
JM
230}
231
232
233void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
234 struct wpa_ssid *ssid)
235{
bb3df9a5
TB
236 if (wpa_s->p2p_mgmt)
237 return;
238
52bdd880 239 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
8bac466b
JM
240}
241
242
a9022616
DW
243void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
244 struct wpa_ssid *ssid,
245 enum wpa_ctrl_req_type rtype,
246 const char *default_txt)
247{
bb3df9a5
TB
248 if (wpa_s->p2p_mgmt)
249 return;
250
a9022616
DW
251 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
252}
253
254
8bac466b
JM
255void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
256{
bb3df9a5
TB
257 if (wpa_s->p2p_mgmt)
258 return;
259
8fc2fb56 260 /* notify the new DBus API */
52bdd880 261 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
8bac466b
JM
262}
263
264
265void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
266{
bb3df9a5
TB
267 if (wpa_s->p2p_mgmt)
268 return;
269
52bdd880 270 wpas_dbus_signal_scan_done(wpa_s, success);
8bac466b
JM
271}
272
273
274void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
275{
bb3df9a5
TB
276 if (wpa_s->p2p_mgmt)
277 return;
278
8bac466b
JM
279 wpas_wps_notify_scan_results(wpa_s);
280}
281
282
283void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
284 const struct wps_credential *cred)
285{
bb3df9a5
TB
286 if (wpa_s->p2p_mgmt)
287 return;
288
b99b8e15 289#ifdef CONFIG_WPS
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
bc0634da
JM
790void wpas_notify_certification(struct wpa_supplicant *wpa_s,
791 struct tls_cert_data *cert,
792 const char *cert_hash)
ade74830 793{
d3a03516
JM
794 int i;
795
4f525d8e 796 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
a647a0ad 797 "depth=%d subject='%s'%s%s%s%s",
bc0634da 798 cert->depth, cert->subject, cert_hash ? " hash=" : "",
21f1a1e6 799 cert_hash ? cert_hash : "",
a647a0ad
JM
800 cert->tod == 2 ? " tod=2" : "",
801 cert->tod == 1 ? " tod=1" : "");
4f525d8e 802
bc0634da 803 if (cert->cert) {
4f525d8e 804 char *cert_hex;
bc0634da 805 size_t len = wpabuf_len(cert->cert) * 2 + 1;
4f525d8e
JM
806 cert_hex = os_malloc(len);
807 if (cert_hex) {
bc0634da
JM
808 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
809 wpabuf_len(cert->cert));
4f525d8e
JM
810 wpa_msg_ctrl(wpa_s, MSG_INFO,
811 WPA_EVENT_EAP_PEER_CERT
812 "depth=%d subject='%s' cert=%s",
bc0634da 813 cert->depth, cert->subject, cert_hex);
4f525d8e
JM
814 os_free(cert_hex);
815 }
816 }
817
d3a03516
JM
818 for (i = 0; i < cert->num_altsubject; i++)
819 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
820 "depth=%d %s", cert->depth, cert->altsubject[i]);
d07d3fbd 821
ade74830 822 /* notify the new DBus API */
bc0634da
JM
823 wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
824 cert->altsubject, cert->num_altsubject,
825 cert_hash, cert->cert);
ade74830 826}
2d43d37f
JB
827
828
829void wpas_notify_preq(struct wpa_supplicant *wpa_s,
830 const u8 *addr, const u8 *dst, const u8 *bssid,
831 const u8 *ie, size_t ie_len, u32 ssi_signal)
832{
833#ifdef CONFIG_AP
834 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
835#endif /* CONFIG_AP */
836}
dd7fec1f
PS
837
838
839void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
840 const char *parameter)
841{
842 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
c7a39ba4
CH
843 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
844 "status='%s' parameter='%s'",
845 status, parameter);
dd7fec1f 846}
0ef023e4
JM
847
848
45f7574d
AE
849void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
850{
851 wpa_msg(wpa_s, MSG_ERROR, WPA_EVENT_EAP_ERROR_CODE "%d", error_code);
852}
853
854
0ef023e4
JM
855void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
856 struct wpa_ssid *ssid)
857{
858 if (wpa_s->current_ssid != ssid)
859 return;
860
861 wpa_dbg(wpa_s, MSG_DEBUG,
862 "Network bssid config changed for the current network - within-ESS roaming %s",
863 ssid->bssid_set ? "disabled" : "enabled");
864
865 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
866 ssid->bssid_set ? ssid->bssid : NULL);
867}
1e529832
JM
868
869
870void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
871 struct wpa_ssid *ssid)
872{
873#ifdef CONFIG_P2P
874 if (ssid->disabled == 2) {
875 /* Changed from normal network profile to persistent group */
876 ssid->disabled = 0;
877 wpas_dbus_unregister_network(wpa_s, ssid->id);
878 ssid->disabled = 2;
661888be 879 ssid->p2p_persistent_group = 1;
1e529832
JM
880 wpas_dbus_register_persistent_group(wpa_s, ssid);
881 } else {
882 /* Changed from persistent group to normal network profile */
883 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
661888be 884 ssid->p2p_persistent_group = 0;
1e529832
JM
885 wpas_dbus_register_network(wpa_s, ssid);
886 }
887#endif /* CONFIG_P2P */
888}
89e9cd25
SB
889
890
891#ifdef CONFIG_MESH
a39b040b 892
89e9cd25
SB
893void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
894 struct wpa_ssid *ssid)
895{
896 if (wpa_s->p2p_mgmt)
897 return;
898
899 wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
900}
a39b040b
SB
901
902
903void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
904 const u8 *meshid, u8 meshid_len,
4be17ffb 905 u16 reason_code)
a39b040b
SB
906{
907 if (wpa_s->p2p_mgmt)
908 return;
909
910 wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
911 reason_code);
912}
913
9b0701fb
SB
914
915void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
916 const u8 *peer_addr)
917{
918 if (wpa_s->p2p_mgmt)
919 return;
920
921 wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
922}
923
a9de99b1
SB
924
925void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
4be17ffb 926 const u8 *peer_addr, u16 reason_code)
a9de99b1
SB
927{
928 if (wpa_s->p2p_mgmt)
929 return;
930
931 wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
932}
933
89e9cd25 934#endif /* CONFIG_MESH */