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