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_new.h"
18 #include "rsn_supp/wpa.h"
19 #include "fst/fst.h"
20 #include "crypto/tls.h"
21 #include "driver_i.h"
22 #include "scan.h"
23 #include "p2p_supplicant.h"
24 #include "sme.h"
25 #include "notify.h"
26 #include "hidl.h"
27 
wpas_notify_supplicant_initialized(struct wpa_global * global)28 int wpas_notify_supplicant_initialized(struct wpa_global *global)
29 {
30 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
31 	if (global->params.dbus_ctrl_interface) {
32 		global->dbus = wpas_dbus_init(global);
33 		if (global->dbus == NULL)
34 			return -1;
35 	}
36 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
37 
38 #ifdef CONFIG_HIDL
39 	global->hidl = wpas_hidl_init(global);
40 	if (!global->hidl)
41 		return -1;
42 #endif /* CONFIG_HIDL */
43 
44 	return 0;
45 }
46 
47 
wpas_notify_supplicant_deinitialized(struct wpa_global * global)48 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
49 {
50 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
51 	if (global->dbus)
52 		wpas_dbus_deinit(global->dbus);
53 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
54 
55 #ifdef CONFIG_HIDL
56 	if (global->hidl)
57 		wpas_hidl_deinit(global->hidl);
58 #endif /* CONFIG_HIDL */
59 }
60 
61 
wpas_notify_iface_added(struct wpa_supplicant * wpa_s)62 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
63 {
64 	if (!wpa_s->p2p_mgmt) {
65 		if (wpas_dbus_register_interface(wpa_s))
66 			return -1;
67 	}
68 
69 	/* HIDL interface wants to keep track of the P2P mgmt iface. */
70 	if (wpas_hidl_register_interface(wpa_s))
71 		return -1;
72 
73 	return 0;
74 }
75 
76 
wpas_notify_iface_removed(struct wpa_supplicant * wpa_s)77 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
78 {
79 	if (!wpa_s->p2p_mgmt) {
80 		/* unregister interface in new DBus ctrl iface */
81 		wpas_dbus_unregister_interface(wpa_s);
82 	}
83 
84 	/* HIDL interface wants to keep track of the P2P mgmt iface. */
85 	wpas_hidl_unregister_interface(wpa_s);
86 }
87 
88 
wpas_notify_state_changed(struct wpa_supplicant * wpa_s,enum wpa_states new_state,enum wpa_states old_state)89 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
90 			       enum wpa_states new_state,
91 			       enum wpa_states old_state)
92 {
93 	if (wpa_s->p2p_mgmt)
94 		return;
95 
96 	/* notify the new DBus API */
97 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
98 
99 #ifdef CONFIG_FST
100 	if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
101 		if (new_state == WPA_COMPLETED)
102 			fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
103 		else if (old_state >= WPA_ASSOCIATED &&
104 			 new_state < WPA_ASSOCIATED)
105 			fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
106 	}
107 #endif /* CONFIG_FST */
108 
109 	if (new_state == WPA_COMPLETED)
110 		wpas_p2p_notif_connected(wpa_s);
111 	else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
112 		wpas_p2p_notif_disconnected(wpa_s);
113 
114 	sme_state_changed(wpa_s);
115 
116 #ifdef ANDROID
117 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
118 		     "id=%d state=%d BSSID=" MACSTR " SSID=%s",
119 		     wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
120 		     new_state,
121 		     MAC2STR(wpa_s->bssid),
122 		     wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
123 		     wpa_ssid_txt(wpa_s->current_ssid->ssid,
124 				  wpa_s->current_ssid->ssid_len) : "");
125 #endif /* ANDROID */
126 
127 	wpas_hidl_notify_state_changed(wpa_s);
128 }
129 
130 
wpas_notify_disconnect_reason(struct wpa_supplicant * wpa_s)131 void wpas_notify_disconnect_reason(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_DISCONNECT_REASON);
137 
138 	wpas_hidl_notify_disconnect_reason(wpa_s);
139 }
140 
141 
wpas_notify_auth_status_code(struct wpa_supplicant * wpa_s)142 void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
143 {
144 	if (wpa_s->p2p_mgmt)
145 		return;
146 
147 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
148 }
149 
150 
wpas_notify_assoc_status_code(struct wpa_supplicant * wpa_s,const u8 * bssid,u8 timed_out,const u8 * assoc_resp_ie,size_t assoc_resp_ie_len)151 void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s,
152 				   const u8 *bssid, u8 timed_out,
153 				   const u8 *assoc_resp_ie, size_t assoc_resp_ie_len)
154 {
155 	if (wpa_s->p2p_mgmt)
156 		return;
157 
158 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
159 
160 	wpas_hidl_notify_assoc_reject(wpa_s, bssid, timed_out, assoc_resp_ie, assoc_resp_ie_len);
161 }
162 
wpas_notify_auth_timeout(struct wpa_supplicant * wpa_s)163 void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
164 	if (wpa_s->p2p_mgmt)
165 		return;
166 
167 	wpas_hidl_notify_auth_timeout(wpa_s);
168 }
169 
wpas_notify_roam_time(struct wpa_supplicant * wpa_s)170 void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
171 {
172 	if (wpa_s->p2p_mgmt)
173 		return;
174 
175 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
176 }
177 
178 
wpas_notify_roam_complete(struct wpa_supplicant * wpa_s)179 void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
180 {
181 	if (wpa_s->p2p_mgmt)
182 		return;
183 
184 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
185 }
186 
187 
wpas_notify_session_length(struct wpa_supplicant * wpa_s)188 void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
189 {
190 	if (wpa_s->p2p_mgmt)
191 		return;
192 
193 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
194 }
195 
196 
wpas_notify_bss_tm_status(struct wpa_supplicant * wpa_s)197 void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
198 {
199 	if (wpa_s->p2p_mgmt)
200 		return;
201 
202 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
203 
204 #ifdef CONFIG_WNM
205 	wpas_hidl_notify_bss_tm_status(wpa_s);
206 #endif
207 }
208 
209 
wpas_notify_network_changed(struct wpa_supplicant * wpa_s)210 void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
211 {
212 	if (wpa_s->p2p_mgmt)
213 		return;
214 
215 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
216 }
217 
218 
wpas_notify_ap_scan_changed(struct wpa_supplicant * wpa_s)219 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
220 {
221 	if (wpa_s->p2p_mgmt)
222 		return;
223 
224 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
225 }
226 
227 
wpas_notify_bssid_changed(struct wpa_supplicant * wpa_s)228 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
229 {
230 	if (wpa_s->p2p_mgmt)
231 		return;
232 
233 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
234 
235 	wpas_hidl_notify_bssid_changed(wpa_s);
236 }
237 
238 
wpas_notify_auth_changed(struct wpa_supplicant * wpa_s)239 void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
240 {
241 	if (wpa_s->p2p_mgmt)
242 		return;
243 
244 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
245 }
246 
247 
wpas_notify_network_enabled_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)248 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
249 					 struct wpa_ssid *ssid)
250 {
251 	if (wpa_s->p2p_mgmt)
252 		return;
253 
254 	wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
255 }
256 
257 
wpas_notify_network_selected(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)258 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
259 				  struct wpa_ssid *ssid)
260 {
261 	if (wpa_s->p2p_mgmt)
262 		return;
263 
264 	wpas_dbus_signal_network_selected(wpa_s, ssid->id);
265 }
266 
267 
wpas_notify_network_request(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,enum wpa_ctrl_req_type rtype,const char * default_txt)268 void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
269 				 struct wpa_ssid *ssid,
270 				 enum wpa_ctrl_req_type rtype,
271 				 const char *default_txt)
272 {
273 	if (wpa_s->p2p_mgmt)
274 		return;
275 
276 	wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
277 
278 	wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
279 }
280 
281 
wpas_notify_scanning(struct wpa_supplicant * wpa_s)282 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
283 {
284 	if (wpa_s->p2p_mgmt)
285 		return;
286 
287 	/* notify the new DBus API */
288 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
289 }
290 
291 
wpas_notify_scan_done(struct wpa_supplicant * wpa_s,int success)292 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
293 {
294 	if (wpa_s->p2p_mgmt)
295 		return;
296 
297 	wpas_dbus_signal_scan_done(wpa_s, success);
298 }
299 
300 
wpas_notify_scan_results(struct wpa_supplicant * wpa_s)301 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
302 {
303 	if (wpa_s->p2p_mgmt)
304 		return;
305 
306 	wpas_wps_notify_scan_results(wpa_s);
307 }
308 
309 
wpas_notify_wps_credential(struct wpa_supplicant * wpa_s,const struct wps_credential * cred)310 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
311 				const struct wps_credential *cred)
312 {
313 	if (wpa_s->p2p_mgmt)
314 		return;
315 
316 #ifdef CONFIG_WPS
317 	/* notify the new DBus API */
318 	wpas_dbus_signal_wps_cred(wpa_s, cred);
319 #endif /* CONFIG_WPS */
320 }
321 
322 
wpas_notify_wps_event_m2d(struct wpa_supplicant * wpa_s,struct wps_event_m2d * m2d)323 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
324 			       struct wps_event_m2d *m2d)
325 {
326 	if (wpa_s->p2p_mgmt)
327 		return;
328 
329 #ifdef CONFIG_WPS
330 	wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
331 #endif /* CONFIG_WPS */
332 }
333 
334 
wpas_notify_wps_event_fail(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)335 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
336 				struct wps_event_fail *fail)
337 {
338 	if (wpa_s->p2p_mgmt)
339 		return;
340 
341 #ifdef CONFIG_WPS
342 	wpas_dbus_signal_wps_event_fail(wpa_s, fail);
343 
344 	wpas_hidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
345 					fail->config_error,
346 					fail->error_indication);
347 #endif /* CONFIG_WPS */
348 }
349 
350 
wpas_notify_wps_event_success(struct wpa_supplicant * wpa_s)351 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
352 {
353 	if (wpa_s->p2p_mgmt)
354 		return;
355 
356 #ifdef CONFIG_WPS
357 	wpas_dbus_signal_wps_event_success(wpa_s);
358 
359 	wpas_hidl_notify_wps_event_success(wpa_s);
360 #endif /* CONFIG_WPS */
361 }
362 
wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant * wpa_s)363 void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
364 {
365 	if (wpa_s->p2p_mgmt)
366 		return;
367 
368 #ifdef CONFIG_WPS
369 	wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
370 
371 	wpas_hidl_notify_wps_event_pbc_overlap(wpa_s);
372 #endif /* CONFIG_WPS */
373 }
374 
375 
wpas_notify_network_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)376 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
377 			       struct wpa_ssid *ssid)
378 {
379 	if (wpa_s->p2p_mgmt)
380 		return;
381 
382 	/*
383 	 * Networks objects created during any P2P activities should not be
384 	 * exposed out. They might/will confuse certain non-P2P aware
385 	 * applications since these network objects won't behave like
386 	 * regular ones.
387 	 */
388 	if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
389 		wpas_dbus_register_network(wpa_s, ssid);
390 		wpas_hidl_register_network(wpa_s, ssid);
391 	}
392 }
393 
394 
wpas_notify_persistent_group_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)395 void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
396 					struct wpa_ssid *ssid)
397 {
398 #ifdef CONFIG_P2P
399 	wpas_dbus_register_persistent_group(wpa_s, ssid);
400 	wpas_hidl_register_network(wpa_s, ssid);
401 #endif /* CONFIG_P2P */
402 }
403 
404 
wpas_notify_persistent_group_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)405 void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
406 					  struct wpa_ssid *ssid)
407 {
408 #ifdef CONFIG_P2P
409 	wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
410 	wpas_hidl_unregister_network(wpa_s, ssid);
411 #endif /* CONFIG_P2P */
412 }
413 
414 
wpas_notify_network_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)415 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
416 				 struct wpa_ssid *ssid)
417 {
418 	if (wpa_s->next_ssid == ssid)
419 		wpa_s->next_ssid = NULL;
420 	if (wpa_s->wpa)
421 		wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
422 	if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
423 	    !wpa_s->p2p_mgmt) {
424 		wpas_dbus_unregister_network(wpa_s, ssid->id);
425 		wpas_hidl_unregister_network(wpa_s, ssid);
426 	}
427 	if (network_is_persistent_group(ssid))
428 		wpas_notify_persistent_group_removed(wpa_s, ssid);
429 
430 	wpas_p2p_network_removed(wpa_s, ssid);
431 
432 #ifdef CONFIG_PASN
433 	if (wpa_s->pasn.ssid == ssid)
434 		wpa_s->pasn.ssid = NULL;
435 #endif /* CONFIG_PASN */
436 }
437 
438 
wpas_notify_bss_added(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)439 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
440 			   u8 bssid[], unsigned int id)
441 {
442 	if (wpa_s->p2p_mgmt)
443 		return;
444 
445 	wpas_dbus_register_bss(wpa_s, bssid, id);
446 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
447 		     id, MAC2STR(bssid));
448 }
449 
450 
wpas_notify_bss_removed(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)451 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
452 			     u8 bssid[], unsigned int id)
453 {
454 	if (wpa_s->p2p_mgmt)
455 		return;
456 
457 	wpas_dbus_unregister_bss(wpa_s, bssid, id);
458 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
459 		     id, MAC2STR(bssid));
460 }
461 
462 
wpas_notify_bss_freq_changed(struct wpa_supplicant * wpa_s,unsigned int id)463 void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
464 				  unsigned int id)
465 {
466 	if (wpa_s->p2p_mgmt)
467 		return;
468 
469 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
470 }
471 
472 
wpas_notify_bss_signal_changed(struct wpa_supplicant * wpa_s,unsigned int id)473 void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
474 				    unsigned int id)
475 {
476 	if (wpa_s->p2p_mgmt)
477 		return;
478 
479 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
480 					  id);
481 }
482 
483 
wpas_notify_bss_privacy_changed(struct wpa_supplicant * wpa_s,unsigned int id)484 void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
485 				     unsigned int id)
486 {
487 	if (wpa_s->p2p_mgmt)
488 		return;
489 
490 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
491 					  id);
492 }
493 
494 
wpas_notify_bss_mode_changed(struct wpa_supplicant * wpa_s,unsigned int id)495 void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
496 				  unsigned int id)
497 {
498 	if (wpa_s->p2p_mgmt)
499 		return;
500 
501 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
502 }
503 
504 
wpas_notify_bss_wpaie_changed(struct wpa_supplicant * wpa_s,unsigned int id)505 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
506 				   unsigned int id)
507 {
508 	if (wpa_s->p2p_mgmt)
509 		return;
510 
511 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
512 }
513 
514 
wpas_notify_bss_rsnie_changed(struct wpa_supplicant * wpa_s,unsigned int id)515 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
516 				   unsigned int id)
517 {
518 	if (wpa_s->p2p_mgmt)
519 		return;
520 
521 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
522 }
523 
524 
wpas_notify_bss_wps_changed(struct wpa_supplicant * wpa_s,unsigned int id)525 void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
526 				 unsigned int id)
527 {
528 	if (wpa_s->p2p_mgmt)
529 		return;
530 
531 #ifdef CONFIG_WPS
532 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
533 #endif /* CONFIG_WPS */
534 }
535 
536 
wpas_notify_bss_ies_changed(struct wpa_supplicant * wpa_s,unsigned int id)537 void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
538 				   unsigned int id)
539 {
540 	if (wpa_s->p2p_mgmt)
541 		return;
542 
543 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
544 }
545 
546 
wpas_notify_bss_rates_changed(struct wpa_supplicant * wpa_s,unsigned int id)547 void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
548 				   unsigned int id)
549 {
550 	if (wpa_s->p2p_mgmt)
551 		return;
552 
553 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
554 }
555 
556 
wpas_notify_bss_seen(struct wpa_supplicant * wpa_s,unsigned int id)557 void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
558 {
559 	if (wpa_s->p2p_mgmt)
560 		return;
561 
562 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
563 }
564 
565 
wpas_notify_blob_added(struct wpa_supplicant * wpa_s,const char * name)566 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
567 {
568 	if (wpa_s->p2p_mgmt)
569 		return;
570 
571 	wpas_dbus_signal_blob_added(wpa_s, name);
572 }
573 
574 
wpas_notify_blob_removed(struct wpa_supplicant * wpa_s,const char * name)575 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
576 {
577 	if (wpa_s->p2p_mgmt)
578 		return;
579 
580 	wpas_dbus_signal_blob_removed(wpa_s, name);
581 }
582 
583 
wpas_notify_debug_level_changed(struct wpa_global * global)584 void wpas_notify_debug_level_changed(struct wpa_global *global)
585 {
586 	wpas_dbus_signal_debug_level_changed(global);
587 }
588 
589 
wpas_notify_debug_timestamp_changed(struct wpa_global * global)590 void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
591 {
592 	wpas_dbus_signal_debug_timestamp_changed(global);
593 }
594 
595 
wpas_notify_debug_show_keys_changed(struct wpa_global * global)596 void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
597 {
598 	wpas_dbus_signal_debug_show_keys_changed(global);
599 }
600 
601 
wpas_notify_suspend(struct wpa_global * global)602 void wpas_notify_suspend(struct wpa_global *global)
603 {
604 	struct wpa_supplicant *wpa_s;
605 
606 	os_get_time(&global->suspend_time);
607 	wpa_printf(MSG_DEBUG, "System suspend notification");
608 	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
609 		wpa_drv_suspend(wpa_s);
610 }
611 
612 
wpas_notify_resume(struct wpa_global * global)613 void wpas_notify_resume(struct wpa_global *global)
614 {
615 	struct os_time now;
616 	int slept;
617 	struct wpa_supplicant *wpa_s;
618 
619 	if (global->suspend_time.sec == 0)
620 		slept = -1;
621 	else {
622 		os_get_time(&now);
623 		slept = now.sec - global->suspend_time.sec;
624 	}
625 	wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
626 		   slept);
627 
628 	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
629 		wpa_drv_resume(wpa_s);
630 		if (wpa_s->wpa_state == WPA_DISCONNECTED)
631 			wpa_supplicant_req_scan(wpa_s, 0, 100000);
632 	}
633 }
634 
635 
636 #ifdef CONFIG_P2P
637 
wpas_notify_p2p_find_stopped(struct wpa_supplicant * wpa_s)638 void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
639 {
640 	/* Notify P2P find has stopped */
641 	wpas_dbus_signal_p2p_find_stopped(wpa_s);
642 
643 	wpas_hidl_notify_p2p_find_stopped(wpa_s);
644 }
645 
646 
wpas_notify_p2p_device_found(struct wpa_supplicant * wpa_s,const u8 * addr,const struct p2p_peer_info * info,const u8 * peer_wfd_device_info,u8 peer_wfd_device_info_len,const u8 * peer_wfd_r2_device_info,u8 peer_wfd_r2_device_info_len,int new_device)647 void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
648 				  const u8 *addr, const struct p2p_peer_info *info,
649 				  const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
650 				  const u8* peer_wfd_r2_device_info, u8 peer_wfd_r2_device_info_len,
651 				  int new_device)
652 {
653 	if (new_device) {
654 		/* Create the new peer object */
655 		wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
656 	}
657 
658 	/* Notify a new peer has been detected*/
659 	wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
660 
661 	wpas_hidl_notify_p2p_device_found(wpa_s, addr, info,
662 					  peer_wfd_device_info,
663 					  peer_wfd_device_info_len,
664 					  peer_wfd_r2_device_info,
665 					  peer_wfd_r2_device_info_len);
666 }
667 
668 
wpas_notify_p2p_device_lost(struct wpa_supplicant * wpa_s,const u8 * dev_addr)669 void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
670 				 const u8 *dev_addr)
671 {
672 	wpas_dbus_unregister_peer(wpa_s, dev_addr);
673 
674 	/* Create signal on interface object*/
675 	wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
676 
677 	wpas_hidl_notify_p2p_device_lost(wpa_s, dev_addr);
678 }
679 
680 
wpas_notify_p2p_group_removed(struct wpa_supplicant * wpa_s,const struct wpa_ssid * ssid,const char * role)681 void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
682 				   const struct wpa_ssid *ssid,
683 				   const char *role)
684 {
685 	wpas_dbus_signal_p2p_group_removed(wpa_s, role);
686 
687 	wpas_dbus_unregister_p2p_group(wpa_s, ssid);
688 
689 	wpas_hidl_notify_p2p_group_removed(wpa_s, ssid, role);
690 }
691 
692 
wpas_notify_p2p_go_neg_req(struct wpa_supplicant * wpa_s,const u8 * src,u16 dev_passwd_id,u8 go_intent)693 void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
694 				const u8 *src, u16 dev_passwd_id, u8 go_intent)
695 {
696 	wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
697 
698 	wpas_hidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
699 }
700 
701 
wpas_notify_p2p_go_neg_completed(struct wpa_supplicant * wpa_s,struct p2p_go_neg_results * res)702 void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
703 				      struct p2p_go_neg_results *res)
704 {
705 	wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
706 
707 	wpas_hidl_notify_p2p_go_neg_completed(wpa_s, res);
708 }
709 
710 
wpas_notify_p2p_invitation_result(struct wpa_supplicant * wpa_s,int status,const u8 * bssid)711 void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
712 				       int status, const u8 *bssid)
713 {
714 	wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
715 
716 	wpas_hidl_notify_p2p_invitation_result(wpa_s, status, bssid);
717 }
718 
719 
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)720 void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
721 				int freq, const u8 *sa, u8 dialog_token,
722 				u16 update_indic, const u8 *tlvs,
723 				size_t tlvs_len)
724 {
725 	wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
726 					update_indic, tlvs, tlvs_len);
727 }
728 
729 
wpas_notify_p2p_sd_response(struct wpa_supplicant * wpa_s,const u8 * sa,u16 update_indic,const u8 * tlvs,size_t tlvs_len)730 void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
731 				 const u8 *sa, u16 update_indic,
732 				 const u8 *tlvs, size_t tlvs_len)
733 {
734 	wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
735 					 tlvs, tlvs_len);
736 
737 	wpas_hidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
738 					 tlvs, tlvs_len);
739 }
740 
741 
742 /**
743  * wpas_notify_p2p_provision_discovery - Notification of provision discovery
744  * @dev_addr: Who sent the request or responded to our request.
745  * @request: Will be 1 if request, 0 for response.
746  * @status: Valid only in case of response (0 in case of success)
747  * @config_methods: WPS config methods
748  * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
749  *
750  * This can be used to notify:
751  * - Requests or responses
752  * - Various config methods
753  * - Failure condition in case of response
754  */
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)755 void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
756 					 const u8 *dev_addr, int request,
757 					 enum p2p_prov_disc_status status,
758 					 u16 config_methods,
759 					 unsigned int generated_pin)
760 {
761 	wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
762 						 status, config_methods,
763 						 generated_pin);
764 
765 	wpas_hidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
766 						 status, config_methods,
767 						 generated_pin);
768 
769 }
770 
771 
wpas_notify_p2p_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,int persistent,int client,const u8 * ip)772 void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
773 				   struct wpa_ssid *ssid, int persistent,
774 				   int client, const u8 *ip)
775 {
776 	/* Notify a group has been started */
777 	wpas_dbus_register_p2p_group(wpa_s, ssid);
778 
779 	wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
780 
781 	wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client);
782 }
783 
784 
wpas_notify_p2p_group_formation_failure(struct wpa_supplicant * wpa_s,const char * reason)785 void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
786 					     const char *reason)
787 {
788 	/* Notify a group formation failed */
789 	wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
790 
791 	wpas_hidl_notify_p2p_group_formation_failure(wpa_s, reason);
792 }
793 
794 
wpas_notify_p2p_wps_failed(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)795 void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
796 				struct wps_event_fail *fail)
797 {
798 	wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
799 }
800 
801 
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)802 void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
803 					 const u8 *sa, const u8 *go_dev_addr,
804 					 const u8 *bssid, int id, int op_freq)
805 {
806 	/* Notify a P2P Invitation Request */
807 	wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
808 						 id, op_freq);
809 
810 	wpas_hidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
811 						 id, op_freq);
812 }
813 
814 #endif /* CONFIG_P2P */
815 
816 
wpas_notify_ap_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr)817 static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
818 					  const u8 *sta,
819 					  const u8 *p2p_dev_addr)
820 {
821 #ifdef CONFIG_P2P
822 	wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
823 
824 	/*
825 	 * Create 'peer-joined' signal on group object -- will also
826 	 * check P2P itself.
827 	 */
828 	if (p2p_dev_addr)
829 		wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
830 #endif /* CONFIG_P2P */
831 
832 	/* Register the station */
833 	wpas_dbus_register_sta(wpa_s, sta);
834 
835 	/* Notify listeners a new station has been authorized */
836 	wpas_dbus_signal_sta_authorized(wpa_s, sta);
837 
838 	wpas_hidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr);
839 }
840 
841 
wpas_notify_ap_sta_deauthorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr)842 static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
843 					    const u8 *sta,
844 					    const u8 *p2p_dev_addr)
845 {
846 #ifdef CONFIG_P2P
847 	/*
848 	 * Create 'peer-disconnected' signal on group object if this
849 	 * is a P2P group.
850 	 */
851 	if (p2p_dev_addr)
852 		wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
853 #endif /* CONFIG_P2P */
854 
855 	/* Notify listeners a station has been deauthorized */
856 	wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
857 
858         wpas_hidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
859 	/* Unregister the station */
860 	wpas_dbus_unregister_sta(wpa_s, sta);
861 }
862 
863 
wpas_notify_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * mac_addr,int authorized,const u8 * p2p_dev_addr)864 void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
865 				const u8 *mac_addr, int authorized,
866 				const u8 *p2p_dev_addr)
867 {
868 	if (authorized)
869 		wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
870 	else
871 		wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
872 }
873 
874 
wpas_notify_certification(struct wpa_supplicant * wpa_s,struct tls_cert_data * cert,const char * cert_hash)875 void wpas_notify_certification(struct wpa_supplicant *wpa_s,
876 			       struct tls_cert_data *cert,
877 			       const char *cert_hash)
878 {
879 	int i;
880 
881 	wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
882 		"depth=%d subject='%s'%s%s%s%s",
883 		cert->depth, cert->subject, cert_hash ? " hash=" : "",
884 		cert_hash ? cert_hash : "",
885 		cert->tod == 2 ? " tod=2" : "",
886 		cert->tod == 1 ? " tod=1" : "");
887 
888 	if (cert->cert) {
889 		char *cert_hex;
890 		size_t len = wpabuf_len(cert->cert) * 2 + 1;
891 		cert_hex = os_malloc(len);
892 		if (cert_hex) {
893 			wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
894 					 wpabuf_len(cert->cert));
895 			wpa_msg_ctrl(wpa_s, MSG_INFO,
896 				     WPA_EVENT_EAP_PEER_CERT
897 				     "depth=%d subject='%s' cert=%s",
898 				     cert->depth, cert->subject, cert_hex);
899 			os_free(cert_hex);
900 		}
901 	}
902 
903 	for (i = 0; i < cert->num_altsubject; i++)
904 		wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
905 			"depth=%d %s", cert->depth, cert->altsubject[i]);
906 
907 	/* notify the new DBus API */
908 	wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
909 				       cert->altsubject, cert->num_altsubject,
910 				       cert_hash, cert->cert);
911 }
912 
913 
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)914 void wpas_notify_preq(struct wpa_supplicant *wpa_s,
915 		      const u8 *addr, const u8 *dst, const u8 *bssid,
916 		      const u8 *ie, size_t ie_len, u32 ssi_signal)
917 {
918 #ifdef CONFIG_AP
919 	wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
920 #endif /* CONFIG_AP */
921 }
922 
923 
wpas_notify_eap_status(struct wpa_supplicant * wpa_s,const char * status,const char * parameter)924 void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
925 			    const char *parameter)
926 {
927 	wpas_dbus_signal_eap_status(wpa_s, status, parameter);
928 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
929 		     "status='%s' parameter='%s'",
930 		     status, parameter);
931 }
932 
933 
wpas_notify_eap_error(struct wpa_supplicant * wpa_s,int error_code)934 void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
935 {
936 	wpa_dbg(wpa_s, MSG_ERROR,
937 		"EAP Error code = %d", error_code);
938 	wpas_hidl_notify_eap_error(wpa_s, error_code);
939 }
940 
941 
wpas_notify_network_bssid_set_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)942 void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
943 					   struct wpa_ssid *ssid)
944 {
945 	if (wpa_s->current_ssid != ssid)
946 		return;
947 
948 	wpa_dbg(wpa_s, MSG_DEBUG,
949 		"Network bssid config changed for the current network - within-ESS roaming %s",
950 		ssid->bssid_set ? "disabled" : "enabled");
951 
952 	wpa_drv_roaming(wpa_s, !ssid->bssid_set,
953 			ssid->bssid_set ? ssid->bssid : NULL);
954 }
955 
956 
wpas_notify_network_type_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)957 void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
958 				      struct wpa_ssid *ssid)
959 {
960 #ifdef CONFIG_P2P
961 	if (ssid->disabled == 2) {
962 		/* Changed from normal network profile to persistent group */
963 		ssid->disabled = 0;
964 		wpas_dbus_unregister_network(wpa_s, ssid->id);
965 		ssid->disabled = 2;
966 		ssid->p2p_persistent_group = 1;
967 		wpas_dbus_register_persistent_group(wpa_s, ssid);
968 	} else {
969 		/* Changed from persistent group to normal network profile */
970 		wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
971 		ssid->p2p_persistent_group = 0;
972 		wpas_dbus_register_network(wpa_s, ssid);
973 	}
974 #endif /* CONFIG_P2P */
975 }
976 
wpas_notify_anqp_query_done(struct wpa_supplicant * wpa_s,const u8 * bssid,const char * result,const struct wpa_bss_anqp * anqp)977 void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
978 				 const char *result,
979 				 const struct wpa_bss_anqp *anqp)
980 {
981 #ifdef CONFIG_INTERWORKING
982 	if (!wpa_s || !bssid || !anqp)
983 		return;
984 
985 	wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
986 #endif /* CONFIG_INTERWORKING */
987 }
988 
wpas_notify_hs20_icon_query_done(struct wpa_supplicant * wpa_s,const u8 * bssid,const char * file_name,const u8 * image,u32 image_length)989 void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
990 				      const char* file_name, const u8* image,
991 				      u32 image_length)
992 {
993 #ifdef CONFIG_HS20
994 	if (!wpa_s || !bssid || !file_name || !image)
995 		return;
996 
997 	wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
998 					      image_length);
999 #endif /* CONFIG_HS20 */
1000 }
1001 
wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant * wpa_s,const char * url,u8 osu_method)1002 void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
1003 						  const char* url,
1004 						  u8 osu_method)
1005 {
1006 #ifdef CONFIG_HS20
1007 	if (!wpa_s || !url)
1008 		return;
1009 
1010 	wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
1011 #endif /* CONFIG_HS20 */
1012 }
1013 
wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant * wpa_s,u8 code,u16 reauth_delay,const char * url)1014 void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1015 						u8 code, u16 reauth_delay,
1016 						const char *url)
1017 {
1018 #ifdef CONFIG_HS20
1019 	if (!wpa_s)
1020 		return;
1021 
1022 	wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
1023 			url);
1024 #endif /* CONFIG_HS20 */
1025 }
1026 
wpas_notify_hs20_rx_terms_and_conditions_acceptance(struct wpa_supplicant * wpa_s,const char * url)1027 void wpas_notify_hs20_rx_terms_and_conditions_acceptance(
1028 		struct wpa_supplicant *wpa_s, const char *url) {
1029 #ifdef CONFIG_HS20
1030 	if (!wpa_s || !url)
1031 		return;
1032 
1033 	wpas_hidl_notify_hs20_rx_terms_and_conditions_acceptance(wpa_s, url);
1034 #endif /* CONFIG_HS20 */
1035 }
1036 
1037 #ifdef CONFIG_MESH
1038 
wpas_notify_mesh_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)1039 void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1040 				    struct wpa_ssid *ssid)
1041 {
1042 	if (wpa_s->p2p_mgmt)
1043 		return;
1044 
1045 	wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1046 }
1047 
1048 
wpas_notify_mesh_group_removed(struct wpa_supplicant * wpa_s,const u8 * meshid,u8 meshid_len,u16 reason_code)1049 void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1050 				    const u8 *meshid, u8 meshid_len,
1051 				    u16 reason_code)
1052 {
1053 	if (wpa_s->p2p_mgmt)
1054 		return;
1055 
1056 	wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1057 					    reason_code);
1058 }
1059 
1060 
wpas_notify_mesh_peer_connected(struct wpa_supplicant * wpa_s,const u8 * peer_addr)1061 void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1062 				     const u8 *peer_addr)
1063 {
1064 	if (wpa_s->p2p_mgmt)
1065 		return;
1066 
1067 	wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1068 }
1069 
1070 
wpas_notify_mesh_peer_disconnected(struct wpa_supplicant * wpa_s,const u8 * peer_addr,u16 reason_code)1071 void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
1072 					const u8 *peer_addr, u16 reason_code)
1073 {
1074 	if (wpa_s->p2p_mgmt)
1075 		return;
1076 
1077 	wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1078 }
1079 
1080 #endif /* CONFIG_MESH */
1081 
1082 /*
1083  * DPP Notifications
1084  */
1085 
1086 /* DPP Success notifications */
1087 
wpas_notify_dpp_config_received(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)1088 void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
1089 	    struct wpa_ssid *ssid)
1090 {
1091 #ifdef CONFIG_DPP
1092 	if (!wpa_s)
1093 		return;
1094 
1095 	wpas_hidl_notify_dpp_config_received(wpa_s, ssid);
1096 #endif /* CONFIG_DPP */
1097 }
1098 
wpas_notify_dpp_config_sent(struct wpa_supplicant * wpa_s)1099 void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
1100 {
1101 #ifdef CONFIG_DPP
1102 	if (!wpa_s)
1103 		return;
1104 
1105 	wpas_hidl_notify_dpp_config_sent(wpa_s);
1106 #endif /* CONFIG_DPP */
1107 }
1108 
1109 /* DPP Progress notifications */
wpas_notify_dpp_auth_success(struct wpa_supplicant * wpa_s)1110 void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
1111 {
1112 #ifdef CONFIG_DPP
1113 	if (!wpa_s)
1114 		return;
1115 
1116 	wpas_hidl_notify_dpp_auth_success(wpa_s);
1117 #endif /* CONFIG_DPP */
1118 }
1119 
wpas_notify_dpp_resp_pending(struct wpa_supplicant * wpa_s)1120 void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
1121 {
1122 #ifdef CONFIG_DPP
1123 	if (!wpa_s)
1124 		return;
1125 
1126 	wpas_hidl_notify_dpp_resp_pending(wpa_s);
1127 #endif /* CONFIG_DPP */
1128 }
1129 
1130 /* DPP Failure notifications */
wpas_notify_dpp_not_compatible(struct wpa_supplicant * wpa_s)1131 void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
1132 {
1133 #ifdef CONFIG_DPP
1134 	if (!wpa_s)
1135 		return;
1136 
1137 	wpas_hidl_notify_dpp_not_compatible(wpa_s);
1138 #endif /* CONFIG_DPP */
1139 }
1140 
wpas_notify_dpp_missing_auth(struct wpa_supplicant * wpa_s)1141 void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
1142 {
1143 #ifdef CONFIG_DPP
1144 	if (!wpa_s)
1145 		return;
1146 
1147 	wpas_hidl_notify_dpp_missing_auth(wpa_s);
1148 #endif /* CONFIG_DPP */
1149 }
1150 
wpas_notify_dpp_configuration_failure(struct wpa_supplicant * wpa_s)1151 void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
1152 {
1153 #ifdef CONFIG_DPP
1154 	if (!wpa_s)
1155 		return;
1156 
1157 	wpas_hidl_notify_dpp_configuration_failure(wpa_s);
1158 #endif /* CONFIG_DPP */
1159 }
1160 
wpas_notify_dpp_timeout(struct wpa_supplicant * wpa_s)1161 void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
1162 {
1163 #ifdef CONFIG_DPP
1164 	if (!wpa_s)
1165 		return;
1166 
1167 	wpas_hidl_notify_dpp_timeout(wpa_s);
1168 #endif /* CONFIG_DPP */
1169 }
1170 
wpas_notify_dpp_auth_failure(struct wpa_supplicant * wpa_s)1171 void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
1172 {
1173 #ifdef CONFIG_DPP
1174 	if (!wpa_s)
1175 		return;
1176 
1177 	wpas_hidl_notify_dpp_auth_failure(wpa_s);
1178 #endif /* CONFIG_DPP */
1179 }
1180 
wpas_notify_dpp_failure(struct wpa_supplicant * wpa_s)1181 void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
1182 {
1183 #ifdef CONFIG_DPP
1184 	if (!wpa_s)
1185 		return;
1186 
1187 	wpas_hidl_notify_dpp_fail(wpa_s);
1188 #endif /* CONFIG_DPP */
1189 }
1190 
wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant * wpa_s)1191 void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
1192 {
1193 #ifdef CONFIG_DPP2
1194 	wpas_hidl_notify_dpp_config_sent_wait_response(wpa_s);
1195 #endif /* CONFIG_DPP2 */
1196 }
1197 
wpas_notify_dpp_config_accepted(struct wpa_supplicant * wpa_s)1198 void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
1199 {
1200 #ifdef CONFIG_DPP2
1201 	wpas_hidl_notify_dpp_config_accepted(wpa_s);
1202 #endif /* CONFIG_DPP2 */
1203 }
1204 
wpas_notify_dpp_conn_status(struct wpa_supplicant * wpa_s,enum dpp_status_error status,const char * ssid,const char * channel_list,unsigned short band_list[],int size)1205 void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
1206 		enum dpp_status_error status, const char *ssid,
1207 		const char *channel_list, unsigned short band_list[], int size)
1208 {
1209 #ifdef CONFIG_DPP2
1210 	wpas_hidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
1211 #endif /* CONFIG_DPP2 */
1212 }
1213 
wpas_notify_dpp_config_rejected(struct wpa_supplicant * wpa_s)1214 void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
1215 {
1216 #ifdef CONFIG_DPP2
1217 	wpas_hidl_notify_dpp_config_rejected(wpa_s);
1218 #endif /* CONFIG_DPP2 */
1219 }
1220 
wpas_notify_pmk_cache_added(struct wpa_supplicant * wpa_s,struct rsn_pmksa_cache_entry * entry)1221 void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1222 				 struct rsn_pmksa_cache_entry *entry)
1223 {
1224 	if (!wpa_s)
1225 		return;
1226 
1227 	wpas_hidl_notify_pmk_cache_added(wpa_s, entry);
1228 }
1229 
wpas_notify_transition_disable(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,u8 bitmap)1230 void wpas_notify_transition_disable(struct wpa_supplicant *wpa_s,
1231 				    struct wpa_ssid *ssid,
1232 				    u8 bitmap)
1233 {
1234 	if (!wpa_s)
1235 		return;
1236 
1237 	if (!ssid)
1238 		return;
1239 
1240 	wpas_hidl_notify_transition_disable(wpa_s, ssid, bitmap);
1241 }
1242 
wpas_notify_network_not_found(struct wpa_supplicant * wpa_s)1243 void wpas_notify_network_not_found(struct wpa_supplicant *wpa_s)
1244 {
1245 	if (!wpa_s)
1246 		return;
1247 
1248 	wpas_hidl_notify_network_not_found(wpa_s);
1249 }
1250