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