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