1 /*
2 * wpa_supplicant - Event notifications
3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9 #include "utils/includes.h"
10
11 #include "utils/common.h"
12 #include "common/wpa_ctrl.h"
13 #include "config.h"
14 #include "wpa_supplicant_i.h"
15 #include "wps_supplicant.h"
16 #include "dbus/dbus_common.h"
17 #include "dbus/dbus_old.h"
18 #include "dbus/dbus_new.h"
19 #include "rsn_supp/wpa.h"
20 #include "fst/fst.h"
21 #include "driver_i.h"
22 #include "scan.h"
23 #include "p2p_supplicant.h"
24 #include "sme.h"
25 #include "notify.h"
26
wpas_notify_supplicant_initialized(struct wpa_global * global)27 int wpas_notify_supplicant_initialized(struct wpa_global *global)
28 {
29 #ifdef CONFIG_DBUS
30 if (global->params.dbus_ctrl_interface) {
31 global->dbus = wpas_dbus_init(global);
32 if (global->dbus == NULL)
33 return -1;
34 }
35 #endif /* CONFIG_DBUS */
36
37 return 0;
38 }
39
40
wpas_notify_supplicant_deinitialized(struct wpa_global * global)41 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
42 {
43 #ifdef CONFIG_DBUS
44 if (global->dbus)
45 wpas_dbus_deinit(global->dbus);
46 #endif /* CONFIG_DBUS */
47 }
48
49
wpas_notify_iface_added(struct wpa_supplicant * wpa_s)50 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
51 {
52 if (wpa_s->p2p_mgmt)
53 return 0;
54
55 if (wpas_dbus_register_iface(wpa_s))
56 return -1;
57
58 if (wpas_dbus_register_interface(wpa_s))
59 return -1;
60
61 return 0;
62 }
63
64
wpas_notify_iface_removed(struct wpa_supplicant * wpa_s)65 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
66 {
67 if (wpa_s->p2p_mgmt)
68 return;
69
70 /* unregister interface in old DBus ctrl iface */
71 wpas_dbus_unregister_iface(wpa_s);
72
73 /* unregister interface in new DBus ctrl iface */
74 wpas_dbus_unregister_interface(wpa_s);
75 }
76
77
wpas_notify_state_changed(struct wpa_supplicant * wpa_s,enum wpa_states new_state,enum wpa_states old_state)78 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
79 enum wpa_states new_state,
80 enum wpa_states old_state)
81 {
82 if (wpa_s->p2p_mgmt)
83 return;
84
85 /* notify the old DBus API */
86 wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
87 old_state);
88
89 /* notify the new DBus API */
90 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
91
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
102 if (new_state == WPA_COMPLETED)
103 wpas_p2p_notif_connected(wpa_s);
104 else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
105 wpas_p2p_notif_disconnected(wpa_s);
106
107 sme_state_changed(wpa_s);
108
109 #ifdef ANDROID
110 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
111 "id=%d state=%d BSSID=" MACSTR " SSID=%s",
112 wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
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) : "");
118 #endif /* ANDROID */
119 }
120
121
wpas_notify_disconnect_reason(struct wpa_supplicant * wpa_s)122 void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
123 {
124 if (wpa_s->p2p_mgmt)
125 return;
126
127 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
128 }
129
130
wpas_notify_network_changed(struct wpa_supplicant * wpa_s)131 void wpas_notify_network_changed(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_CURRENT_NETWORK);
137 }
138
139
wpas_notify_ap_scan_changed(struct wpa_supplicant * wpa_s)140 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
141 {
142 if (wpa_s->p2p_mgmt)
143 return;
144
145 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
146 }
147
148
wpas_notify_bssid_changed(struct wpa_supplicant * wpa_s)149 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
150 {
151 if (wpa_s->p2p_mgmt)
152 return;
153
154 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
155 }
156
157
wpas_notify_auth_changed(struct wpa_supplicant * wpa_s)158 void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
159 {
160 if (wpa_s->p2p_mgmt)
161 return;
162
163 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
164 }
165
166
wpas_notify_network_enabled_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)167 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
168 struct wpa_ssid *ssid)
169 {
170 if (wpa_s->p2p_mgmt)
171 return;
172
173 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
174 }
175
176
wpas_notify_network_selected(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)177 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
178 struct wpa_ssid *ssid)
179 {
180 if (wpa_s->p2p_mgmt)
181 return;
182
183 wpas_dbus_signal_network_selected(wpa_s, ssid->id);
184 }
185
186
wpas_notify_network_request(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,enum wpa_ctrl_req_type rtype,const char * default_txt)187 void 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 {
192 if (wpa_s->p2p_mgmt)
193 return;
194
195 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
196 }
197
198
wpas_notify_scanning(struct wpa_supplicant * wpa_s)199 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
200 {
201 if (wpa_s->p2p_mgmt)
202 return;
203
204 /* notify the old DBus API */
205 wpa_supplicant_dbus_notify_scanning(wpa_s);
206
207 /* notify the new DBus API */
208 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
209 }
210
211
wpas_notify_scan_done(struct wpa_supplicant * wpa_s,int success)212 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
213 {
214 if (wpa_s->p2p_mgmt)
215 return;
216
217 wpas_dbus_signal_scan_done(wpa_s, success);
218 }
219
220
wpas_notify_scan_results(struct wpa_supplicant * wpa_s)221 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
222 {
223 if (wpa_s->p2p_mgmt)
224 return;
225
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
wpas_notify_wps_credential(struct wpa_supplicant * wpa_s,const struct wps_credential * cred)233 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
234 const struct wps_credential *cred)
235 {
236 if (wpa_s->p2p_mgmt)
237 return;
238
239 #ifdef CONFIG_WPS
240 /* notify the old DBus API */
241 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
242 /* notify the new DBus API */
243 wpas_dbus_signal_wps_cred(wpa_s, cred);
244 #endif /* CONFIG_WPS */
245 }
246
247
wpas_notify_wps_event_m2d(struct wpa_supplicant * wpa_s,struct wps_event_m2d * m2d)248 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
249 struct wps_event_m2d *m2d)
250 {
251 if (wpa_s->p2p_mgmt)
252 return;
253
254 #ifdef CONFIG_WPS
255 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
256 #endif /* CONFIG_WPS */
257 }
258
259
wpas_notify_wps_event_fail(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)260 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
261 struct wps_event_fail *fail)
262 {
263 if (wpa_s->p2p_mgmt)
264 return;
265
266 #ifdef CONFIG_WPS
267 wpas_dbus_signal_wps_event_fail(wpa_s, fail);
268 #endif /* CONFIG_WPS */
269 }
270
271
wpas_notify_wps_event_success(struct wpa_supplicant * wpa_s)272 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
273 {
274 if (wpa_s->p2p_mgmt)
275 return;
276
277 #ifdef CONFIG_WPS
278 wpas_dbus_signal_wps_event_success(wpa_s);
279 #endif /* CONFIG_WPS */
280 }
281
wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant * wpa_s)282 void 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
292
wpas_notify_network_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)293 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
294 struct wpa_ssid *ssid)
295 {
296 if (wpa_s->p2p_mgmt)
297 return;
298
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 */
305 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
306 wpas_dbus_register_network(wpa_s, ssid);
307 }
308
309
wpas_notify_persistent_group_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)310 void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
311 struct wpa_ssid *ssid)
312 {
313 #ifdef CONFIG_P2P
314 wpas_dbus_register_persistent_group(wpa_s, ssid);
315 #endif /* CONFIG_P2P */
316 }
317
318
wpas_notify_persistent_group_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)319 void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
320 struct wpa_ssid *ssid)
321 {
322 #ifdef CONFIG_P2P
323 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
324 #endif /* CONFIG_P2P */
325 }
326
327
wpas_notify_network_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)328 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
329 struct wpa_ssid *ssid)
330 {
331 if (wpa_s->next_ssid == ssid)
332 wpa_s->next_ssid = NULL;
333 if (wpa_s->wpa)
334 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
335 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
336 !wpa_s->p2p_mgmt)
337 wpas_dbus_unregister_network(wpa_s, ssid->id);
338 if (network_is_persistent_group(ssid))
339 wpas_notify_persistent_group_removed(wpa_s, ssid);
340
341 wpas_p2p_network_removed(wpa_s, ssid);
342 }
343
344
wpas_notify_bss_added(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)345 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
346 u8 bssid[], unsigned int id)
347 {
348 if (wpa_s->p2p_mgmt)
349 return;
350
351 wpas_dbus_register_bss(wpa_s, bssid, id);
352 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
353 id, MAC2STR(bssid));
354 }
355
356
wpas_notify_bss_removed(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)357 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
358 u8 bssid[], unsigned int id)
359 {
360 if (wpa_s->p2p_mgmt)
361 return;
362
363 wpas_dbus_unregister_bss(wpa_s, bssid, id);
364 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
365 id, MAC2STR(bssid));
366 }
367
368
wpas_notify_bss_freq_changed(struct wpa_supplicant * wpa_s,unsigned int id)369 void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
370 unsigned int id)
371 {
372 if (wpa_s->p2p_mgmt)
373 return;
374
375 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
376 }
377
378
wpas_notify_bss_signal_changed(struct wpa_supplicant * wpa_s,unsigned int id)379 void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
380 unsigned int id)
381 {
382 if (wpa_s->p2p_mgmt)
383 return;
384
385 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
386 id);
387 }
388
389
wpas_notify_bss_privacy_changed(struct wpa_supplicant * wpa_s,unsigned int id)390 void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
391 unsigned int id)
392 {
393 if (wpa_s->p2p_mgmt)
394 return;
395
396 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
397 id);
398 }
399
400
wpas_notify_bss_mode_changed(struct wpa_supplicant * wpa_s,unsigned int id)401 void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
402 unsigned int id)
403 {
404 if (wpa_s->p2p_mgmt)
405 return;
406
407 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
408 }
409
410
wpas_notify_bss_wpaie_changed(struct wpa_supplicant * wpa_s,unsigned int id)411 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
412 unsigned int id)
413 {
414 if (wpa_s->p2p_mgmt)
415 return;
416
417 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
418 }
419
420
wpas_notify_bss_rsnie_changed(struct wpa_supplicant * wpa_s,unsigned int id)421 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
422 unsigned int id)
423 {
424 if (wpa_s->p2p_mgmt)
425 return;
426
427 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
428 }
429
430
wpas_notify_bss_wps_changed(struct wpa_supplicant * wpa_s,unsigned int id)431 void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
432 unsigned int id)
433 {
434 if (wpa_s->p2p_mgmt)
435 return;
436
437 #ifdef CONFIG_WPS
438 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
439 #endif /* CONFIG_WPS */
440 }
441
442
wpas_notify_bss_ies_changed(struct wpa_supplicant * wpa_s,unsigned int id)443 void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
444 unsigned int id)
445 {
446 if (wpa_s->p2p_mgmt)
447 return;
448
449 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
450 }
451
452
wpas_notify_bss_rates_changed(struct wpa_supplicant * wpa_s,unsigned int id)453 void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
454 unsigned int id)
455 {
456 if (wpa_s->p2p_mgmt)
457 return;
458
459 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
460 }
461
462
wpas_notify_bss_seen(struct wpa_supplicant * wpa_s,unsigned int id)463 void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
464 {
465 if (wpa_s->p2p_mgmt)
466 return;
467
468 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
469 }
470
471
wpas_notify_blob_added(struct wpa_supplicant * wpa_s,const char * name)472 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
473 {
474 if (wpa_s->p2p_mgmt)
475 return;
476
477 wpas_dbus_signal_blob_added(wpa_s, name);
478 }
479
480
wpas_notify_blob_removed(struct wpa_supplicant * wpa_s,const char * name)481 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
482 {
483 if (wpa_s->p2p_mgmt)
484 return;
485
486 wpas_dbus_signal_blob_removed(wpa_s, name);
487 }
488
489
wpas_notify_debug_level_changed(struct wpa_global * global)490 void wpas_notify_debug_level_changed(struct wpa_global *global)
491 {
492 wpas_dbus_signal_debug_level_changed(global);
493 }
494
495
wpas_notify_debug_timestamp_changed(struct wpa_global * global)496 void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
497 {
498 wpas_dbus_signal_debug_timestamp_changed(global);
499 }
500
501
wpas_notify_debug_show_keys_changed(struct wpa_global * global)502 void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
503 {
504 wpas_dbus_signal_debug_show_keys_changed(global);
505 }
506
507
wpas_notify_suspend(struct wpa_global * global)508 void 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
wpas_notify_resume(struct wpa_global * global)519 void 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 }
540
541
542 #ifdef CONFIG_P2P
543
wpas_notify_p2p_find_stopped(struct wpa_supplicant * wpa_s)544 void 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
wpas_notify_p2p_device_found(struct wpa_supplicant * wpa_s,const u8 * dev_addr,int new_device)551 void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
552 const u8 *dev_addr, int new_device)
553 {
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);
561 }
562
563
wpas_notify_p2p_device_lost(struct wpa_supplicant * wpa_s,const u8 * dev_addr)564 void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
565 const u8 *dev_addr)
566 {
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);
571 }
572
573
wpas_notify_p2p_group_removed(struct wpa_supplicant * wpa_s,const struct wpa_ssid * ssid,const char * role)574 void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
575 const struct wpa_ssid *ssid,
576 const char *role)
577 {
578 wpas_dbus_signal_p2p_group_removed(wpa_s, role);
579
580 wpas_dbus_unregister_p2p_group(wpa_s, ssid);
581 }
582
583
wpas_notify_p2p_go_neg_req(struct wpa_supplicant * wpa_s,const u8 * src,u16 dev_passwd_id,u8 go_intent)584 void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
585 const u8 *src, u16 dev_passwd_id, u8 go_intent)
586 {
587 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
588 }
589
590
wpas_notify_p2p_go_neg_completed(struct wpa_supplicant * wpa_s,struct p2p_go_neg_results * res)591 void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
592 struct p2p_go_neg_results *res)
593 {
594 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
595 }
596
597
wpas_notify_p2p_invitation_result(struct wpa_supplicant * wpa_s,int status,const u8 * bssid)598 void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
599 int status, const u8 *bssid)
600 {
601 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
602 }
603
604
wpas_notify_p2p_sd_request(struct wpa_supplicant * wpa_s,int freq,const u8 * sa,u8 dialog_token,u16 update_indic,const u8 * tlvs,size_t tlvs_len)605 void 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 {
610 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
611 update_indic, tlvs, tlvs_len);
612 }
613
614
wpas_notify_p2p_sd_response(struct wpa_supplicant * wpa_s,const u8 * sa,u16 update_indic,const u8 * tlvs,size_t tlvs_len)615 void 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 {
619 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
620 tlvs, tlvs_len);
621 }
622
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 */
wpas_notify_p2p_provision_discovery(struct wpa_supplicant * wpa_s,const u8 * dev_addr,int request,enum p2p_prov_disc_status status,u16 config_methods,unsigned int generated_pin)637 void 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 {
643 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
644 status, config_methods,
645 generated_pin);
646 }
647
648
wpas_notify_p2p_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,int network_id,int client)649 void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
650 struct wpa_ssid *ssid, int network_id,
651 int client)
652 {
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);
657 }
658
659
wpas_notify_p2p_group_formation_failure(struct wpa_supplicant * wpa_s,const char * reason)660 void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
661 const char *reason)
662 {
663 /* Notify a group formation failed */
664 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
665 }
666
667
wpas_notify_p2p_wps_failed(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)668 void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
669 struct wps_event_fail *fail)
670 {
671 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
672 }
673
674
wpas_notify_p2p_invitation_received(struct wpa_supplicant * wpa_s,const u8 * sa,const u8 * go_dev_addr,const u8 * bssid,int id,int op_freq)675 void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
676 const u8 *sa, const u8 *go_dev_addr,
677 const u8 *bssid, int id, int op_freq)
678 {
679 /* Notify a P2P Invitation Request */
680 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
681 id, op_freq);
682 }
683
684 #endif /* CONFIG_P2P */
685
686
wpas_notify_ap_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr)687 static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
688 const u8 *sta,
689 const u8 *p2p_dev_addr)
690 {
691 #ifdef CONFIG_P2P
692 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
693
694 /*
695 * Create 'peer-joined' signal on group object -- will also
696 * check P2P itself.
697 */
698 if (p2p_dev_addr)
699 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
700 #endif /* CONFIG_P2P */
701
702 /* Notify listeners a new station has been authorized */
703 wpas_dbus_signal_sta_authorized(wpa_s, sta);
704 }
705
706
wpas_notify_ap_sta_deauthorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr)707 static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
708 const u8 *sta,
709 const u8 *p2p_dev_addr)
710 {
711 #ifdef CONFIG_P2P
712 /*
713 * Create 'peer-disconnected' signal on group object if this
714 * is a P2P group.
715 */
716 if (p2p_dev_addr)
717 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
718 #endif /* CONFIG_P2P */
719
720 /* Notify listeners a station has been deauthorized */
721 wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
722 }
723
724
wpas_notify_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * mac_addr,int authorized,const u8 * p2p_dev_addr)725 void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
726 const u8 *mac_addr, int authorized,
727 const u8 *p2p_dev_addr)
728 {
729 if (authorized)
730 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
731 else
732 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
733 }
734
735
wpas_notify_certification(struct wpa_supplicant * wpa_s,int depth,const char * subject,const char * altsubject[],int num_altsubject,const char * cert_hash,const struct wpabuf * cert)736 void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
737 const char *subject, const char *altsubject[],
738 int num_altsubject, const char *cert_hash,
739 const struct wpabuf *cert)
740 {
741 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
742 "depth=%d subject='%s'%s%s",
743 depth, subject, cert_hash ? " hash=" : "",
744 cert_hash ? cert_hash : "");
745
746 if (cert) {
747 char *cert_hex;
748 size_t len = wpabuf_len(cert) * 2 + 1;
749 cert_hex = os_malloc(len);
750 if (cert_hex) {
751 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
752 wpabuf_len(cert));
753 wpa_msg_ctrl(wpa_s, MSG_INFO,
754 WPA_EVENT_EAP_PEER_CERT
755 "depth=%d subject='%s' cert=%s",
756 depth, subject, cert_hex);
757 os_free(cert_hex);
758 }
759 }
760
761 if (altsubject) {
762 int i;
763
764 for (i = 0; i < num_altsubject; i++)
765 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
766 "depth=%d %s", depth, altsubject[i]);
767 }
768
769 /* notify the old DBus API */
770 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
771 cert_hash, cert);
772 /* notify the new DBus API */
773 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
774 num_altsubject, cert_hash, cert);
775 }
776
777
wpas_notify_preq(struct wpa_supplicant * wpa_s,const u8 * addr,const u8 * dst,const u8 * bssid,const u8 * ie,size_t ie_len,u32 ssi_signal)778 void wpas_notify_preq(struct wpa_supplicant *wpa_s,
779 const u8 *addr, const u8 *dst, const u8 *bssid,
780 const u8 *ie, size_t ie_len, u32 ssi_signal)
781 {
782 #ifdef CONFIG_AP
783 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
784 #endif /* CONFIG_AP */
785 }
786
787
wpas_notify_eap_status(struct wpa_supplicant * wpa_s,const char * status,const char * parameter)788 void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
789 const char *parameter)
790 {
791 wpas_dbus_signal_eap_status(wpa_s, status, parameter);
792 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
793 "status='%s' parameter='%s'",
794 status, parameter);
795 }
796
797
wpas_notify_network_bssid_set_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)798 void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
799 struct wpa_ssid *ssid)
800 {
801 if (wpa_s->current_ssid != ssid)
802 return;
803
804 wpa_dbg(wpa_s, MSG_DEBUG,
805 "Network bssid config changed for the current network - within-ESS roaming %s",
806 ssid->bssid_set ? "disabled" : "enabled");
807
808 wpa_drv_roaming(wpa_s, !ssid->bssid_set,
809 ssid->bssid_set ? ssid->bssid : NULL);
810 }
811
812
wpas_notify_network_type_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)813 void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
814 struct wpa_ssid *ssid)
815 {
816 #ifdef CONFIG_P2P
817 if (ssid->disabled == 2) {
818 /* Changed from normal network profile to persistent group */
819 ssid->disabled = 0;
820 wpas_dbus_unregister_network(wpa_s, ssid->id);
821 ssid->disabled = 2;
822 ssid->p2p_persistent_group = 1;
823 wpas_dbus_register_persistent_group(wpa_s, ssid);
824 } else {
825 /* Changed from persistent group to normal network profile */
826 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
827 ssid->p2p_persistent_group = 0;
828 wpas_dbus_register_network(wpa_s, ssid);
829 }
830 #endif /* CONFIG_P2P */
831 }
832