• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "rsn_supp/pmksa_cache.h"
20 #include "fst/fst.h"
21 #include "crypto/tls.h"
22 #include "bss.h"
23 #include "driver_i.h"
24 #include "scan.h"
25 #include "p2p_supplicant.h"
26 #include "sme.h"
27 #include "notify.h"
28 #include "aidl/aidl.h"
29 
wpas_notify_supplicant_initialized(struct wpa_global * global)30 int wpas_notify_supplicant_initialized(struct wpa_global *global)
31 {
32 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
33 	if (global->params.dbus_ctrl_interface) {
34 		global->dbus = wpas_dbus_init(global);
35 		if (global->dbus == NULL)
36 			return -1;
37 	}
38 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
39 
40 #ifdef CONFIG_AIDL
41 	// Initialize AIDL here if daemonize is disabled.
42 	// Otherwise initialize it later.
43 	if (!global->params.daemonize) {
44 		global->aidl = wpas_aidl_init(global);
45 		if (!global->aidl)
46 			return -1;
47 	}
48 #endif /* CONFIG_AIDL */
49 
50 	return 0;
51 }
52 
53 
wpas_notify_supplicant_deinitialized(struct wpa_global * global)54 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
55 {
56 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
57 	if (global->dbus)
58 		wpas_dbus_deinit(global->dbus);
59 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
60 
61 #ifdef CONFIG_AIDL
62 	if (global->aidl)
63 		wpas_aidl_deinit(global->aidl);
64 #endif /* CONFIG_AIDL */
65 }
66 
67 
wpas_notify_iface_added(struct wpa_supplicant * wpa_s)68 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
69 {
70 	if (!wpa_s->p2p_mgmt) {
71 		if (wpas_dbus_register_interface(wpa_s))
72 			return -1;
73 	}
74 
75 #ifdef CONFIG_AIDL
76 	/*
77 	 * AIDL initialization may not be complete here if daemonize is enabled.
78 	 * Initialization is done after daemonizing in order to avoid
79 	 * issues with the file descriptor.
80 	 */
81 	if (!wpa_s->global->aidl)
82 		return 0;
83 	/* AIDL interface wants to keep track of the P2P mgmt iface. */
84 	if (wpas_aidl_register_interface(wpa_s))
85 		return -1;
86 #endif
87 
88 	return 0;
89 }
90 
91 
wpas_notify_iface_removed(struct wpa_supplicant * wpa_s)92 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
93 {
94 	if (!wpa_s->p2p_mgmt) {
95 		/* unregister interface in new DBus ctrl iface */
96 		wpas_dbus_unregister_interface(wpa_s);
97 	}
98 
99 	/* AIDL interface wants to keep track of the P2P mgmt iface. */
100 	wpas_aidl_unregister_interface(wpa_s);
101 }
102 
103 
wpas_notify_state_changed(struct wpa_supplicant * wpa_s,enum wpa_states new_state,enum wpa_states old_state)104 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
105 			       enum wpa_states new_state,
106 			       enum wpa_states old_state)
107 {
108 	if (wpa_s->p2p_mgmt)
109 		return;
110 
111 	/* notify the new DBus API */
112 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
113 
114 #ifdef CONFIG_FST
115 	if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
116 		if (new_state == WPA_COMPLETED)
117 			fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
118 		else if (old_state >= WPA_ASSOCIATED &&
119 			 new_state < WPA_ASSOCIATED)
120 			fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
121 	}
122 #endif /* CONFIG_FST */
123 
124 	if (new_state == WPA_COMPLETED)
125 		wpas_p2p_notif_connected(wpa_s);
126 	else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
127 		wpas_p2p_notif_disconnected(wpa_s);
128 
129 	sme_state_changed(wpa_s);
130 
131 #ifdef ANDROID
132 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
133 		     "id=%d state=%d BSSID=" MACSTR " SSID=%s",
134 		     wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
135 		     new_state,
136 		     MAC2STR(wpa_s->bssid),
137 		     wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
138 		     wpa_ssid_txt(wpa_s->current_ssid->ssid,
139 				  wpa_s->current_ssid->ssid_len) : "");
140 #endif /* ANDROID */
141 
142 	wpas_aidl_notify_state_changed(wpa_s);
143 }
144 
145 
wpas_notify_disconnect_reason(struct wpa_supplicant * wpa_s)146 void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
147 {
148 	if (wpa_s->p2p_mgmt)
149 		return;
150 
151 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
152 
153 	wpas_aidl_notify_disconnect_reason(wpa_s);
154 }
155 
156 
wpas_notify_mlo_info_change_reason(struct wpa_supplicant * wpa_s,enum mlo_info_change_reason reason)157 void wpas_notify_mlo_info_change_reason(struct wpa_supplicant *wpa_s,
158 					enum mlo_info_change_reason reason)
159 {
160 	if (wpa_s->p2p_mgmt)
161 		return;
162 
163 	wpas_aidl_notify_mlo_info_change_reason(wpa_s, reason);
164 }
165 
166 
wpas_notify_auth_status_code(struct wpa_supplicant * wpa_s)167 void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
168 {
169 	if (wpa_s->p2p_mgmt)
170 		return;
171 
172 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
173 }
174 
175 
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)176 void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s,
177 				   const u8 *bssid, u8 timed_out,
178 				   const u8 *assoc_resp_ie, size_t assoc_resp_ie_len)
179 {
180 	if (wpa_s->p2p_mgmt)
181 		return;
182 
183 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
184 
185 	wpas_aidl_notify_assoc_reject(wpa_s, bssid, timed_out, assoc_resp_ie, assoc_resp_ie_len);
186 }
187 
wpas_notify_auth_timeout(struct wpa_supplicant * wpa_s)188 void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
189 	if (wpa_s->p2p_mgmt)
190 		return;
191 
192 	wpas_aidl_notify_auth_timeout(wpa_s);
193 }
194 
wpas_notify_roam_time(struct wpa_supplicant * wpa_s)195 void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
196 {
197 	if (wpa_s->p2p_mgmt)
198 		return;
199 
200 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
201 }
202 
203 
wpas_notify_roam_complete(struct wpa_supplicant * wpa_s)204 void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
205 {
206 	if (wpa_s->p2p_mgmt)
207 		return;
208 
209 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
210 }
211 
212 
wpas_notify_session_length(struct wpa_supplicant * wpa_s)213 void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
214 {
215 	if (wpa_s->p2p_mgmt)
216 		return;
217 
218 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
219 }
220 
221 
wpas_notify_bss_tm_status(struct wpa_supplicant * wpa_s)222 void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
223 {
224 	if (wpa_s->p2p_mgmt)
225 		return;
226 
227 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
228 
229 #ifdef CONFIG_WNM
230 	wpas_aidl_notify_bss_tm_status(wpa_s);
231 #endif
232 }
233 
234 
wpas_notify_network_changed(struct wpa_supplicant * wpa_s)235 void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
236 {
237 	if (wpa_s->p2p_mgmt)
238 		return;
239 
240 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
241 }
242 
243 
wpas_notify_ap_scan_changed(struct wpa_supplicant * wpa_s)244 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
245 {
246 	if (wpa_s->p2p_mgmt)
247 		return;
248 
249 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
250 }
251 
252 
wpas_notify_bssid_changed(struct wpa_supplicant * wpa_s)253 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
254 {
255 	if (wpa_s->p2p_mgmt)
256 		return;
257 
258 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
259 
260 	wpas_aidl_notify_bssid_changed(wpa_s);
261 }
262 
263 
wpas_notify_mac_address_changed(struct wpa_supplicant * wpa_s)264 void wpas_notify_mac_address_changed(struct wpa_supplicant *wpa_s)
265 {
266 	if (wpa_s->p2p_mgmt)
267 		return;
268 
269 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_MAC_ADDRESS);
270 }
271 
272 
wpas_notify_auth_changed(struct wpa_supplicant * wpa_s)273 void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
274 {
275 	if (wpa_s->p2p_mgmt)
276 		return;
277 
278 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
279 }
280 
281 
wpas_notify_network_enabled_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)282 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
283 					 struct wpa_ssid *ssid)
284 {
285 	if (wpa_s->p2p_mgmt)
286 		return;
287 
288 	wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
289 }
290 
291 
wpas_notify_network_selected(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)292 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
293 				  struct wpa_ssid *ssid)
294 {
295 	if (wpa_s->p2p_mgmt)
296 		return;
297 
298 	wpas_dbus_signal_network_selected(wpa_s, ssid->id);
299 }
300 
301 
wpas_notify_network_request(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,enum wpa_ctrl_req_type rtype,const char * default_txt)302 void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
303 				 struct wpa_ssid *ssid,
304 				 enum wpa_ctrl_req_type rtype,
305 				 const char *default_txt)
306 {
307 	if (wpa_s->p2p_mgmt)
308 		return;
309 
310 	wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
311 
312 	wpas_aidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
313 }
314 
315 
wpas_notify_permanent_id_req_denied(struct wpa_supplicant * wpa_s)316 void wpas_notify_permanent_id_req_denied(struct wpa_supplicant *wpa_s)
317 {
318 	wpas_aidl_notify_permanent_id_req_denied(wpa_s);
319 }
320 
321 
wpas_notify_scanning(struct wpa_supplicant * wpa_s)322 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
323 {
324 	if (wpa_s->p2p_mgmt)
325 		return;
326 
327 	/* notify the new DBus API */
328 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
329 }
330 
331 
wpas_notify_scan_done(struct wpa_supplicant * wpa_s,int success)332 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
333 {
334 	if (wpa_s->p2p_mgmt)
335 		return;
336 
337 	wpas_dbus_signal_scan_done(wpa_s, success);
338 }
339 
340 
wpas_notify_scan_results(struct wpa_supplicant * wpa_s)341 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
342 {
343 	if (wpa_s->p2p_mgmt)
344 		return;
345 
346 	wpas_wps_notify_scan_results(wpa_s);
347 }
348 
349 
wpas_notify_wps_credential(struct wpa_supplicant * wpa_s,const struct wps_credential * cred)350 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
351 				const struct wps_credential *cred)
352 {
353 	if (wpa_s->p2p_mgmt)
354 		return;
355 
356 #ifdef CONFIG_WPS
357 	/* notify the new DBus API */
358 	wpas_dbus_signal_wps_cred(wpa_s, cred);
359 #endif /* CONFIG_WPS */
360 }
361 
362 
wpas_notify_wps_event_m2d(struct wpa_supplicant * wpa_s,struct wps_event_m2d * m2d)363 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
364 			       struct wps_event_m2d *m2d)
365 {
366 	if (wpa_s->p2p_mgmt)
367 		return;
368 
369 #ifdef CONFIG_WPS
370 	wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
371 #endif /* CONFIG_WPS */
372 }
373 
374 
wpas_notify_wps_event_fail(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)375 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
376 				struct wps_event_fail *fail)
377 {
378 	if (wpa_s->p2p_mgmt)
379 		return;
380 
381 #ifdef CONFIG_WPS
382 	wpas_dbus_signal_wps_event_fail(wpa_s, fail);
383 
384 	wpas_aidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
385 					fail->config_error,
386 					fail->error_indication);
387 #endif /* CONFIG_WPS */
388 }
389 
390 
wpas_notify_wps_event_success(struct wpa_supplicant * wpa_s)391 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
392 {
393 	if (wpa_s->p2p_mgmt)
394 		return;
395 
396 #ifdef CONFIG_WPS
397 	wpas_dbus_signal_wps_event_success(wpa_s);
398 
399 	wpas_aidl_notify_wps_event_success(wpa_s);
400 #endif /* CONFIG_WPS */
401 }
402 
wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant * wpa_s)403 void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
404 {
405 	if (wpa_s->p2p_mgmt)
406 		return;
407 
408 #ifdef CONFIG_WPS
409 	wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
410 
411 	wpas_aidl_notify_wps_event_pbc_overlap(wpa_s);
412 #endif /* CONFIG_WPS */
413 }
414 
415 
wpas_notify_network_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)416 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
417 			       struct wpa_ssid *ssid)
418 {
419 	if (wpa_s->p2p_mgmt)
420 		return;
421 
422 	/*
423 	 * Networks objects created during any P2P activities should not be
424 	 * exposed out. They might/will confuse certain non-P2P aware
425 	 * applications since these network objects won't behave like
426 	 * regular ones.
427 	 */
428 	if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
429 		wpas_dbus_register_network(wpa_s, ssid);
430 		wpas_aidl_register_network(wpa_s, ssid);
431 		wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_ADDED "%d",
432 			     ssid->id);
433 	}
434 }
435 
436 
wpas_notify_persistent_group_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)437 void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
438 					struct wpa_ssid *ssid)
439 {
440 #ifdef CONFIG_P2P
441 	wpas_dbus_register_persistent_group(wpa_s, ssid);
442 	wpas_aidl_register_network(wpa_s, ssid);
443 #endif /* CONFIG_P2P */
444 }
445 
446 
wpas_notify_persistent_group_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)447 void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
448 					  struct wpa_ssid *ssid)
449 {
450 #ifdef CONFIG_P2P
451 	wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
452 	wpas_aidl_unregister_network(wpa_s, ssid);
453 #endif /* CONFIG_P2P */
454 }
455 
456 
wpas_notify_network_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)457 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
458 				 struct wpa_ssid *ssid)
459 {
460 	if (wpa_s->next_ssid == ssid)
461 		wpa_s->next_ssid = NULL;
462 	if (wpa_s->last_ssid == ssid)
463 		wpa_s->last_ssid = NULL;
464 	if (wpa_s->current_ssid == ssid)
465 		wpa_s->current_ssid = NULL;
466 	if (wpa_s->ml_connect_probe_ssid == ssid) {
467 		wpa_s->ml_connect_probe_ssid = NULL;
468 		wpa_s->ml_connect_probe_bss = NULL;
469 	}
470 #if defined(CONFIG_SME) && defined(CONFIG_SAE)
471 	if (wpa_s->sme.ext_auth_wpa_ssid == ssid)
472 		wpa_s->sme.ext_auth_wpa_ssid = NULL;
473 #endif /* CONFIG_SME && CONFIG_SAE */
474 	if (wpa_s->wpa) {
475 		if ((wpa_key_mgmt_sae(ssid->key_mgmt) &&
476 		     (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SAE_OFFLOAD_STA)) ||
477 		    ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) &&
478 		     (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA))) {
479 			/* For cases when PMK is generated at the driver */
480 			struct wpa_pmkid_params params;
481 
482 			os_memset(&params, 0, sizeof(params));
483 			params.ssid = ssid->ssid;
484 			params.ssid_len = ssid->ssid_len;
485 			wpa_drv_remove_pmkid(wpa_s, &params);
486 		}
487 		wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
488 	}
489 	if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
490 	    !wpa_s->p2p_mgmt) {
491 		wpas_dbus_unregister_network(wpa_s, ssid->id);
492 		wpas_aidl_unregister_network(wpa_s, ssid);
493 		wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_REMOVED "%d",
494 			     ssid->id);
495 	}
496 	if (network_is_persistent_group(ssid))
497 		wpas_notify_persistent_group_removed(wpa_s, ssid);
498 
499 	wpas_p2p_network_removed(wpa_s, ssid);
500 }
501 
502 
wpas_notify_bss_added(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)503 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
504 			   u8 bssid[], unsigned int id)
505 {
506 	if (wpa_s->p2p_mgmt)
507 		return;
508 
509 	wpas_dbus_register_bss(wpa_s, bssid, id);
510 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
511 		     id, MAC2STR(bssid));
512 }
513 
514 
wpas_notify_bss_removed(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)515 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
516 			     u8 bssid[], unsigned int id)
517 {
518 	if (wpa_s->p2p_mgmt)
519 		return;
520 
521 	wpas_dbus_unregister_bss(wpa_s, bssid, id);
522 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
523 		     id, MAC2STR(bssid));
524 }
525 
526 
wpas_notify_bss_freq_changed(struct wpa_supplicant * wpa_s,unsigned int id)527 void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
528 				  unsigned int id)
529 {
530 	if (wpa_s->p2p_mgmt)
531 		return;
532 
533 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
534 }
535 
536 
wpas_notify_bss_signal_changed(struct wpa_supplicant * wpa_s,unsigned int id)537 void wpas_notify_bss_signal_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_SIGNAL,
544 					  id);
545 }
546 
547 
wpas_notify_bss_privacy_changed(struct wpa_supplicant * wpa_s,unsigned int id)548 void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
549 				     unsigned int id)
550 {
551 	if (wpa_s->p2p_mgmt)
552 		return;
553 
554 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
555 					  id);
556 }
557 
558 
wpas_notify_bss_mode_changed(struct wpa_supplicant * wpa_s,unsigned int id)559 void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
560 				  unsigned int id)
561 {
562 	if (wpa_s->p2p_mgmt)
563 		return;
564 
565 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
566 }
567 
568 
wpas_notify_bss_wpaie_changed(struct wpa_supplicant * wpa_s,unsigned int id)569 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
570 				   unsigned int id)
571 {
572 	if (wpa_s->p2p_mgmt)
573 		return;
574 
575 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
576 }
577 
578 
wpas_notify_bss_rsnie_changed(struct wpa_supplicant * wpa_s,unsigned int id)579 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
580 				   unsigned int id)
581 {
582 	if (wpa_s->p2p_mgmt)
583 		return;
584 
585 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
586 }
587 
588 
wpas_notify_bss_wps_changed(struct wpa_supplicant * wpa_s,unsigned int id)589 void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
590 				 unsigned int id)
591 {
592 	if (wpa_s->p2p_mgmt)
593 		return;
594 
595 #ifdef CONFIG_WPS
596 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
597 #endif /* CONFIG_WPS */
598 }
599 
600 
wpas_notify_bss_ies_changed(struct wpa_supplicant * wpa_s,unsigned int id)601 void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
602 				   unsigned int id)
603 {
604 	if (wpa_s->p2p_mgmt)
605 		return;
606 
607 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
608 }
609 
610 
wpas_notify_bss_rates_changed(struct wpa_supplicant * wpa_s,unsigned int id)611 void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
612 				   unsigned int id)
613 {
614 	if (wpa_s->p2p_mgmt)
615 		return;
616 
617 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
618 }
619 
620 
wpas_notify_bss_seen(struct wpa_supplicant * wpa_s,unsigned int id)621 void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
622 {
623 	if (wpa_s->p2p_mgmt)
624 		return;
625 
626 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
627 }
628 
629 
wpas_notify_blob_added(struct wpa_supplicant * wpa_s,const char * name)630 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
631 {
632 	if (wpa_s->p2p_mgmt)
633 		return;
634 
635 	wpas_dbus_signal_blob_added(wpa_s, name);
636 }
637 
638 
wpas_notify_blob_removed(struct wpa_supplicant * wpa_s,const char * name)639 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
640 {
641 	if (wpa_s->p2p_mgmt)
642 		return;
643 
644 	wpas_dbus_signal_blob_removed(wpa_s, name);
645 }
646 
647 
wpas_notify_debug_level_changed(struct wpa_global * global)648 void wpas_notify_debug_level_changed(struct wpa_global *global)
649 {
650 	wpas_dbus_signal_debug_level_changed(global);
651 }
652 
653 
wpas_notify_debug_timestamp_changed(struct wpa_global * global)654 void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
655 {
656 	wpas_dbus_signal_debug_timestamp_changed(global);
657 }
658 
659 
wpas_notify_debug_show_keys_changed(struct wpa_global * global)660 void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
661 {
662 	wpas_dbus_signal_debug_show_keys_changed(global);
663 }
664 
665 
wpas_notify_suspend(struct wpa_global * global)666 void wpas_notify_suspend(struct wpa_global *global)
667 {
668 	struct wpa_supplicant *wpa_s;
669 
670 	os_get_time(&global->suspend_time);
671 	wpa_printf(MSG_DEBUG, "System suspend notification");
672 	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
673 		wpa_drv_suspend(wpa_s);
674 }
675 
676 
wpas_notify_resume(struct wpa_global * global)677 void wpas_notify_resume(struct wpa_global *global)
678 {
679 	struct os_time now;
680 	int slept;
681 	struct wpa_supplicant *wpa_s;
682 
683 	if (global->suspend_time.sec == 0)
684 		slept = -1;
685 	else {
686 		os_get_time(&now);
687 		slept = now.sec - global->suspend_time.sec;
688 	}
689 	wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
690 		   slept);
691 
692 	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
693 		wpa_drv_resume(wpa_s);
694 		if (wpa_s->wpa_state == WPA_DISCONNECTED)
695 			wpa_supplicant_req_scan(wpa_s, 0, 100000);
696 	}
697 }
698 
699 
700 #ifdef CONFIG_P2P
701 
wpas_notify_p2p_find_stopped(struct wpa_supplicant * wpa_s)702 void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
703 {
704 	/* Notify P2P find has stopped */
705 	wpas_dbus_signal_p2p_find_stopped(wpa_s);
706 
707 	wpas_aidl_notify_p2p_find_stopped(wpa_s);
708 }
709 
710 
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)711 void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
712 				  const u8 *addr, const struct p2p_peer_info *info,
713 				  const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
714 				  const u8* peer_wfd_r2_device_info, u8 peer_wfd_r2_device_info_len,
715 				  int new_device)
716 {
717 	if (new_device) {
718 		/* Create the new peer object */
719 		wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
720 	}
721 
722 	/* Notify a new peer has been detected*/
723 	wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
724 
725 	wpas_aidl_notify_p2p_device_found(wpa_s, addr, info,
726 					  peer_wfd_device_info,
727 					  peer_wfd_device_info_len,
728 					  peer_wfd_r2_device_info,
729 					  peer_wfd_r2_device_info_len);
730 }
731 
732 
wpas_notify_p2p_device_lost(struct wpa_supplicant * wpa_s,const u8 * dev_addr)733 void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
734 				 const u8 *dev_addr)
735 {
736 	wpas_dbus_unregister_peer(wpa_s, dev_addr);
737 
738 	/* Create signal on interface object*/
739 	wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
740 
741 	wpas_aidl_notify_p2p_device_lost(wpa_s, dev_addr);
742 }
743 
744 
wpas_notify_p2p_group_removed(struct wpa_supplicant * wpa_s,const struct wpa_ssid * ssid,const char * role)745 void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
746 				   const struct wpa_ssid *ssid,
747 				   const char *role)
748 {
749 	wpas_dbus_signal_p2p_group_removed(wpa_s, role);
750 
751 	wpas_dbus_unregister_p2p_group(wpa_s, ssid);
752 
753 	wpas_aidl_notify_p2p_group_removed(wpa_s, ssid, role);
754 }
755 
756 
wpas_notify_p2p_go_neg_req(struct wpa_supplicant * wpa_s,const u8 * src,u16 dev_passwd_id,u8 go_intent)757 void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
758 				const u8 *src, u16 dev_passwd_id, u8 go_intent)
759 {
760 	wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
761 
762 	wpas_aidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
763 }
764 
765 
wpas_notify_p2p_go_neg_completed(struct wpa_supplicant * wpa_s,struct p2p_go_neg_results * res)766 void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
767 				      struct p2p_go_neg_results *res)
768 {
769 	wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
770 
771 	wpas_aidl_notify_p2p_go_neg_completed(wpa_s, res);
772 }
773 
774 
wpas_notify_p2p_invitation_result(struct wpa_supplicant * wpa_s,int status,const u8 * bssid)775 void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
776 				       int status, const u8 *bssid)
777 {
778 	wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
779 
780 	wpas_aidl_notify_p2p_invitation_result(wpa_s, status, bssid);
781 }
782 
783 
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)784 void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
785 				int freq, const u8 *sa, u8 dialog_token,
786 				u16 update_indic, const u8 *tlvs,
787 				size_t tlvs_len)
788 {
789 	wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
790 					update_indic, tlvs, tlvs_len);
791 }
792 
793 
wpas_notify_p2p_sd_response(struct wpa_supplicant * wpa_s,const u8 * sa,u16 update_indic,const u8 * tlvs,size_t tlvs_len)794 void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
795 				 const u8 *sa, u16 update_indic,
796 				 const u8 *tlvs, size_t tlvs_len)
797 {
798 	wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
799 					 tlvs, tlvs_len);
800 
801 	wpas_aidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
802 					 tlvs, tlvs_len);
803 }
804 
805 
806 /**
807  * wpas_notify_p2p_provision_discovery - Notification of provision discovery
808  * @dev_addr: Who sent the request or responded to our request.
809  * @request: Will be 1 if request, 0 for response.
810  * @status: Valid only in case of response (0 in case of success)
811  * @config_methods: WPS config methods
812  * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
813  * @group_ifname: Group interface name of the group owner in case the provision
814  *                discovery request is received with P2P Group ID attribute.
815  *                i.e., valid only when the peer device is joining an
816  *                operating P2P group.
817  *
818  * This can be used to notify:
819  * - Requests or responses
820  * - Various config methods
821  * - Failure condition in case of response
822  */
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,const char * group_ifname)823 void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
824 					 const u8 *dev_addr, int request,
825 					 enum p2p_prov_disc_status status,
826 					 u16 config_methods,
827 					 unsigned int generated_pin,
828 					 const char *group_ifname)
829 {
830 	wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
831 						 status, config_methods,
832 						 generated_pin);
833 
834 	wpas_aidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
835 						 status, config_methods,
836 						 generated_pin, group_ifname);
837 
838 }
839 
840 
wpas_notify_p2p_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,int persistent,int client,const u8 * ip)841 void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
842 				   struct wpa_ssid *ssid, int persistent,
843 				   int client, const u8 *ip)
844 {
845 	/* Notify a group has been started */
846 	wpas_dbus_register_p2p_group(wpa_s, ssid);
847 
848 	wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
849 
850 	wpas_aidl_notify_p2p_group_started(wpa_s, ssid, persistent, client, ip);
851 }
852 
853 
wpas_notify_p2p_group_formation_failure(struct wpa_supplicant * wpa_s,const char * reason)854 void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
855 					     const char *reason)
856 {
857 	/* Notify a group formation failed */
858 	wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
859 
860 	wpas_aidl_notify_p2p_group_formation_failure(wpa_s, reason);
861 }
862 
863 
wpas_notify_p2p_wps_failed(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)864 void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
865 				struct wps_event_fail *fail)
866 {
867 	wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
868 }
869 
870 
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)871 void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
872 					 const u8 *sa, const u8 *go_dev_addr,
873 					 const u8 *bssid, int id, int op_freq)
874 {
875 	/* Notify a P2P Invitation Request */
876 	wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
877 						 id, op_freq);
878 
879 	wpas_aidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
880 						 id, op_freq);
881 }
882 
883 #endif /* CONFIG_P2P */
884 
885 
wpas_notify_ap_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr,const u8 * ip)886 static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
887 					  const u8 *sta,
888 					  const u8 *p2p_dev_addr, const u8 *ip)
889 {
890 #ifdef CONFIG_P2P
891 	wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
892 
893 	/*
894 	 * Create 'peer-joined' signal on group object -- will also
895 	 * check P2P itself.
896 	 */
897 	if (p2p_dev_addr)
898 		wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
899 #endif /* CONFIG_P2P */
900 
901 	/* Register the station */
902 	wpas_dbus_register_sta(wpa_s, sta);
903 
904 	/* Notify listeners a new station has been authorized */
905 	wpas_dbus_signal_sta_authorized(wpa_s, sta);
906 
907 	wpas_aidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr, ip);
908 }
909 
910 
wpas_notify_ap_sta_deauthorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr)911 static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
912 					    const u8 *sta,
913 					    const u8 *p2p_dev_addr)
914 {
915 #ifdef CONFIG_P2P
916 	/*
917 	 * Create 'peer-disconnected' signal on group object if this
918 	 * is a P2P group.
919 	 */
920 	if (p2p_dev_addr)
921 		wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
922 #endif /* CONFIG_P2P */
923 
924 	/* Notify listeners a station has been deauthorized */
925 	wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
926 
927 	wpas_aidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
928 	/* Unregister the station */
929 	wpas_dbus_unregister_sta(wpa_s, sta);
930 }
931 
932 
wpas_notify_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * mac_addr,int authorized,const u8 * p2p_dev_addr,const u8 * ip)933 void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
934 				const u8 *mac_addr, int authorized,
935 				const u8 *p2p_dev_addr, const u8 *ip)
936 {
937 	if (authorized)
938 		wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr, ip);
939 	else
940 		wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
941 }
942 
943 
wpas_notify_certification(struct wpa_supplicant * wpa_s,struct tls_cert_data * cert,const char * cert_hash)944 void wpas_notify_certification(struct wpa_supplicant *wpa_s,
945 			       struct tls_cert_data *cert,
946 			       const char *cert_hash)
947 {
948 	int i;
949 
950 	wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
951 		"depth=%d subject='%s'%s%s%s%s",
952 		cert->depth, cert->subject, cert_hash ? " hash=" : "",
953 		cert_hash ? cert_hash : "",
954 		cert->tod == 2 ? " tod=2" : "",
955 		cert->tod == 1 ? " tod=1" : "");
956 
957 	if (cert->cert) {
958 		char *cert_hex;
959 		size_t len = wpabuf_len(cert->cert) * 2 + 1;
960 		cert_hex = os_malloc(len);
961 		if (cert_hex) {
962 			wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
963 					 wpabuf_len(cert->cert));
964 			wpa_msg_ctrl(wpa_s, MSG_INFO,
965 				     WPA_EVENT_EAP_PEER_CERT
966 				     "depth=%d subject='%s' cert=%s",
967 				     cert->depth, cert->subject, cert_hex);
968 			os_free(cert_hex);
969 		}
970 	}
971 
972 	for (i = 0; i < cert->num_altsubject; i++)
973 		wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
974 			"depth=%d %s", cert->depth, cert->altsubject[i]);
975 
976 	wpas_aidl_notify_ceritification(wpa_s, cert->depth, cert->subject,
977 				       cert->altsubject, cert->num_altsubject,
978 				       cert_hash, cert->cert);
979 
980 	/* notify the new DBus API */
981 	wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
982 				       cert->altsubject, cert->num_altsubject,
983 				       cert_hash, cert->cert);
984 }
985 
986 
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)987 void wpas_notify_preq(struct wpa_supplicant *wpa_s,
988 		      const u8 *addr, const u8 *dst, const u8 *bssid,
989 		      const u8 *ie, size_t ie_len, u32 ssi_signal)
990 {
991 #ifdef CONFIG_AP
992 	wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
993 #endif /* CONFIG_AP */
994 }
995 
996 
wpas_notify_eap_status(struct wpa_supplicant * wpa_s,const char * status,const char * parameter)997 void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
998 			    const char *parameter)
999 {
1000 	wpas_dbus_signal_eap_status(wpa_s, status, parameter);
1001 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
1002 		     "status='%s' parameter='%s'",
1003 		     status, parameter);
1004 }
1005 
1006 
wpas_notify_eap_error(struct wpa_supplicant * wpa_s,int error_code)1007 void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
1008 {
1009 	wpa_dbg(wpa_s, MSG_ERROR,
1010 		"EAP Error code = %d", error_code);
1011 	wpas_aidl_notify_eap_error(wpa_s, error_code);
1012 }
1013 
1014 
wpas_notify_psk_mismatch(struct wpa_supplicant * wpa_s)1015 void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s)
1016 {
1017 	wpas_dbus_signal_psk_mismatch(wpa_s);
1018 }
1019 
1020 
wpas_notify_network_bssid_set_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)1021 void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
1022 					   struct wpa_ssid *ssid)
1023 {
1024 	if (wpa_s->current_ssid != ssid)
1025 		return;
1026 
1027 	wpa_dbg(wpa_s, MSG_DEBUG,
1028 		"Network bssid config changed for the current network - within-ESS roaming %s",
1029 		ssid->bssid_set ? "disabled" : "enabled");
1030 
1031 	wpa_drv_roaming(wpa_s, !ssid->bssid_set,
1032 			ssid->bssid_set ? ssid->bssid : NULL);
1033 }
1034 
1035 
wpas_notify_network_type_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)1036 void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
1037 				      struct wpa_ssid *ssid)
1038 {
1039 #ifdef CONFIG_P2P
1040 	if (ssid->disabled == 2) {
1041 		/* Changed from normal network profile to persistent group */
1042 		ssid->disabled = 0;
1043 		wpas_dbus_unregister_network(wpa_s, ssid->id);
1044 		ssid->disabled = 2;
1045 		ssid->p2p_persistent_group = 1;
1046 		wpas_dbus_register_persistent_group(wpa_s, ssid);
1047 	} else {
1048 		/* Changed from persistent group to normal network profile */
1049 		wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
1050 		ssid->p2p_persistent_group = 0;
1051 		wpas_dbus_register_network(wpa_s, ssid);
1052 	}
1053 #endif /* CONFIG_P2P */
1054 }
1055 
wpas_notify_anqp_query_done(struct wpa_supplicant * wpa_s,const u8 * bssid,const char * result,const struct wpa_bss_anqp * anqp)1056 void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1057 				 const char *result,
1058 				 const struct wpa_bss_anqp *anqp)
1059 {
1060 #ifdef CONFIG_INTERWORKING
1061 	if (!wpa_s || !bssid || !anqp)
1062 		return;
1063 
1064 	wpas_aidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
1065 #endif /* CONFIG_INTERWORKING */
1066 }
1067 
wpas_notify_hs20_icon_query_done(struct wpa_supplicant * wpa_s,const u8 * bssid,const char * file_name,const u8 * image,u32 image_length)1068 void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
1069 				      const char* file_name, const u8* image,
1070 				      u32 image_length)
1071 {
1072 #ifdef CONFIG_HS20
1073 	if (!wpa_s || !bssid || !file_name || !image)
1074 		return;
1075 
1076 	wpas_aidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
1077 					      image_length);
1078 #endif /* CONFIG_HS20 */
1079 }
1080 
wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant * wpa_s,const char * url,u8 osu_method)1081 void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
1082 						  const char* url,
1083 						  u8 osu_method)
1084 {
1085 #ifdef CONFIG_HS20
1086 	if (!wpa_s || !url)
1087 		return;
1088 
1089 	wpas_aidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
1090 #endif /* CONFIG_HS20 */
1091 }
1092 
wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant * wpa_s,u8 code,u16 reauth_delay,const char * url)1093 void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
1094 						u8 code, u16 reauth_delay,
1095 						const char *url)
1096 {
1097 #ifdef CONFIG_HS20
1098 	if (!wpa_s)
1099 		return;
1100 
1101 	wpas_aidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
1102 			url);
1103 #endif /* CONFIG_HS20 */
1104 }
1105 
wpas_notify_hs20_rx_terms_and_conditions_acceptance(struct wpa_supplicant * wpa_s,const char * url)1106 void wpas_notify_hs20_rx_terms_and_conditions_acceptance(
1107 		struct wpa_supplicant *wpa_s, const char *url) {
1108 #ifdef CONFIG_HS20
1109 	if (!wpa_s || !url)
1110 		return;
1111 
1112 	wpas_aidl_notify_hs20_rx_terms_and_conditions_acceptance(wpa_s, url);
1113 #endif /* CONFIG_HS20 */
1114 }
1115 
1116 #ifdef CONFIG_MESH
1117 
wpas_notify_mesh_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)1118 void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
1119 				    struct wpa_ssid *ssid)
1120 {
1121 	if (wpa_s->p2p_mgmt)
1122 		return;
1123 
1124 	wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
1125 }
1126 
1127 
wpas_notify_mesh_group_removed(struct wpa_supplicant * wpa_s,const u8 * meshid,u8 meshid_len,u16 reason_code)1128 void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
1129 				    const u8 *meshid, u8 meshid_len,
1130 				    u16 reason_code)
1131 {
1132 	if (wpa_s->p2p_mgmt)
1133 		return;
1134 
1135 	wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1136 					    reason_code);
1137 }
1138 
1139 
wpas_notify_mesh_peer_connected(struct wpa_supplicant * wpa_s,const u8 * peer_addr)1140 void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1141 				     const u8 *peer_addr)
1142 {
1143 	if (wpa_s->p2p_mgmt)
1144 		return;
1145 
1146 	wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR,
1147 		MAC2STR(peer_addr));
1148 	wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1149 }
1150 
1151 
wpas_notify_mesh_peer_disconnected(struct wpa_supplicant * wpa_s,const u8 * peer_addr,u16 reason_code)1152 void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
1153 					const u8 *peer_addr, u16 reason_code)
1154 {
1155 	if (wpa_s->p2p_mgmt)
1156 		return;
1157 
1158 	wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
1159 		MAC2STR(peer_addr));
1160 	wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1161 }
1162 
1163 #endif /* CONFIG_MESH */
1164 
1165 /*
1166  * DPP Notifications
1167  */
1168 
1169 /* DPP Success notifications */
1170 
wpas_notify_dpp_config_received(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,bool conn_status_requested)1171 void wpas_notify_dpp_config_received(struct wpa_supplicant *wpa_s,
1172 	    struct wpa_ssid *ssid, bool conn_status_requested)
1173 {
1174 #ifdef CONFIG_DPP
1175 	if (!wpa_s)
1176 		return;
1177 
1178 	wpas_aidl_notify_dpp_config_received(wpa_s, ssid, conn_status_requested);
1179 #endif /* CONFIG_DPP */
1180 }
1181 
wpas_notify_dpp_config_sent(struct wpa_supplicant * wpa_s)1182 void wpas_notify_dpp_config_sent(struct wpa_supplicant *wpa_s)
1183 {
1184 #ifdef CONFIG_DPP
1185 	if (!wpa_s)
1186 		return;
1187 
1188 	wpas_aidl_notify_dpp_config_sent(wpa_s);
1189 #endif /* CONFIG_DPP */
1190 }
1191 
wpas_notify_dpp_connection_status_sent(struct wpa_supplicant * wpa_s,enum dpp_status_error result)1192 void wpas_notify_dpp_connection_status_sent(struct wpa_supplicant *wpa_s,
1193 	    enum dpp_status_error result)
1194 {
1195 #ifdef CONFIG_DPP2
1196 	if (!wpa_s)
1197 		return;
1198 
1199 	wpas_aidl_notify_dpp_connection_status_sent(wpa_s, result);
1200 #endif /* CONFIG_DPP2 */
1201 }
1202 
1203 /* DPP Progress notifications */
wpas_notify_dpp_auth_success(struct wpa_supplicant * wpa_s)1204 void wpas_notify_dpp_auth_success(struct wpa_supplicant *wpa_s)
1205 {
1206 #ifdef CONFIG_DPP
1207 	if (!wpa_s)
1208 		return;
1209 
1210 	wpas_aidl_notify_dpp_auth_success(wpa_s);
1211 #endif /* CONFIG_DPP */
1212 }
1213 
wpas_notify_dpp_resp_pending(struct wpa_supplicant * wpa_s)1214 void wpas_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s)
1215 {
1216 #ifdef CONFIG_DPP
1217 	if (!wpa_s)
1218 		return;
1219 
1220 	wpas_aidl_notify_dpp_resp_pending(wpa_s);
1221 #endif /* CONFIG_DPP */
1222 }
1223 
1224 /* DPP Failure notifications */
wpas_notify_dpp_not_compatible(struct wpa_supplicant * wpa_s)1225 void wpas_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s)
1226 {
1227 #ifdef CONFIG_DPP
1228 	if (!wpa_s)
1229 		return;
1230 
1231 	wpas_aidl_notify_dpp_not_compatible(wpa_s);
1232 #endif /* CONFIG_DPP */
1233 }
1234 
wpas_notify_dpp_missing_auth(struct wpa_supplicant * wpa_s)1235 void wpas_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s)
1236 {
1237 #ifdef CONFIG_DPP
1238 	if (!wpa_s)
1239 		return;
1240 
1241 	wpas_aidl_notify_dpp_missing_auth(wpa_s);
1242 #endif /* CONFIG_DPP */
1243 }
1244 
wpas_notify_dpp_configuration_failure(struct wpa_supplicant * wpa_s)1245 void wpas_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s)
1246 {
1247 #ifdef CONFIG_DPP
1248 	if (!wpa_s)
1249 		return;
1250 
1251 	wpas_aidl_notify_dpp_configuration_failure(wpa_s);
1252 #endif /* CONFIG_DPP */
1253 }
1254 
wpas_notify_dpp_timeout(struct wpa_supplicant * wpa_s)1255 void wpas_notify_dpp_timeout(struct wpa_supplicant *wpa_s)
1256 {
1257 #ifdef CONFIG_DPP
1258 	if (!wpa_s)
1259 		return;
1260 
1261 	wpas_aidl_notify_dpp_timeout(wpa_s);
1262 #endif /* CONFIG_DPP */
1263 }
1264 
wpas_notify_dpp_auth_failure(struct wpa_supplicant * wpa_s)1265 void wpas_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s)
1266 {
1267 #ifdef CONFIG_DPP
1268 	if (!wpa_s)
1269 		return;
1270 
1271 	wpas_aidl_notify_dpp_auth_failure(wpa_s);
1272 #endif /* CONFIG_DPP */
1273 }
1274 
wpas_notify_dpp_failure(struct wpa_supplicant * wpa_s)1275 void wpas_notify_dpp_failure(struct wpa_supplicant *wpa_s)
1276 {
1277 #ifdef CONFIG_DPP
1278 	if (!wpa_s)
1279 		return;
1280 
1281 	wpas_aidl_notify_dpp_fail(wpa_s);
1282 #endif /* CONFIG_DPP */
1283 }
1284 
wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant * wpa_s)1285 void wpas_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s)
1286 {
1287 #ifdef CONFIG_DPP2
1288 	wpas_aidl_notify_dpp_config_sent_wait_response(wpa_s);
1289 #endif /* CONFIG_DPP2 */
1290 }
1291 
wpas_notify_dpp_config_accepted(struct wpa_supplicant * wpa_s)1292 void wpas_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s)
1293 {
1294 #ifdef CONFIG_DPP2
1295 	wpas_aidl_notify_dpp_config_accepted(wpa_s);
1296 #endif /* CONFIG_DPP2 */
1297 }
1298 
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)1299 void wpas_notify_dpp_conn_status(struct wpa_supplicant *wpa_s,
1300 		enum dpp_status_error status, const char *ssid,
1301 		const char *channel_list, unsigned short band_list[], int size)
1302 {
1303 #ifdef CONFIG_DPP2
1304 	wpas_aidl_notify_dpp_conn_status(wpa_s, status, ssid, channel_list, band_list, size);
1305 #endif /* CONFIG_DPP2 */
1306 }
1307 
wpas_notify_dpp_config_rejected(struct wpa_supplicant * wpa_s)1308 void wpas_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s)
1309 {
1310 #ifdef CONFIG_DPP2
1311 	wpas_aidl_notify_dpp_config_rejected(wpa_s);
1312 #endif /* CONFIG_DPP2 */
1313 }
1314 
wpas_notify_pmk_cache_added(struct wpa_supplicant * wpa_s,struct rsn_pmksa_cache_entry * entry)1315 void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1316 				 struct rsn_pmksa_cache_entry *entry)
1317 {
1318 	if (!wpa_s)
1319 		return;
1320 
1321 	wpas_aidl_notify_pmk_cache_added(wpa_s, entry);
1322 }
1323 
wpas_notify_transition_disable(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,u8 bitmap)1324 void wpas_notify_transition_disable(struct wpa_supplicant *wpa_s,
1325 				    struct wpa_ssid *ssid,
1326 				    u8 bitmap)
1327 {
1328 	if (!wpa_s)
1329 		return;
1330 
1331 	if (!ssid)
1332 		return;
1333 
1334 	wpas_aidl_notify_transition_disable(wpa_s, ssid, bitmap);
1335 }
1336 
wpas_notify_network_not_found(struct wpa_supplicant * wpa_s)1337 void wpas_notify_network_not_found(struct wpa_supplicant *wpa_s)
1338 {
1339 	if (!wpa_s)
1340 		return;
1341 
1342 	wpas_aidl_notify_network_not_found(wpa_s);
1343 }
1344 
1345 #ifdef CONFIG_INTERWORKING
1346 
wpas_notify_interworking_ap_added(struct wpa_supplicant * wpa_s,struct wpa_bss * bss,struct wpa_cred * cred,int excluded,const char * type,int bh,int bss_load,int conn_capab)1347 void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
1348 				       struct wpa_bss *bss,
1349 				       struct wpa_cred *cred, int excluded,
1350 				       const char *type, int bh, int bss_load,
1351 				       int conn_capab)
1352 {
1353 	wpa_msg(wpa_s, MSG_INFO, "%s" MACSTR " type=%s%s%s%s id=%d priority=%d sp_priority=%d",
1354 		excluded ? INTERWORKING_EXCLUDED : INTERWORKING_AP,
1355 		MAC2STR(bss->bssid), type,
1356 		bh ? " below_min_backhaul=1" : "",
1357 		bss_load ? " over_max_bss_load=1" : "",
1358 		conn_capab ? " conn_capab_missing=1" : "",
1359 		cred->id, cred->priority, cred->sp_priority);
1360 
1361 	wpas_dbus_signal_interworking_ap_added(wpa_s, bss, cred, type, excluded,
1362 					       bh, bss_load, conn_capab);
1363 }
1364 
1365 
wpas_notify_interworking_select_done(struct wpa_supplicant * wpa_s)1366 void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
1367 {
1368 	wpas_dbus_signal_interworking_select_done(wpa_s);
1369 }
1370 
1371 #endif /* CONFIG_INTERWORKING */
1372 
wpas_notify_eap_method_selected(struct wpa_supplicant * wpa_s,const char * reason_string)1373 void wpas_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
1374 			const char* reason_string)
1375 {
1376 	wpas_aidl_notify_eap_method_selected(wpa_s, reason_string);
1377 }
1378 
wpas_notify_ssid_temp_disabled(struct wpa_supplicant * wpa_s,const char * reason_string)1379 void wpas_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
1380 			const char *reason_string)
1381 {
1382 	wpas_aidl_notify_ssid_temp_disabled(wpa_s, reason_string);
1383 }
1384 
wpas_notify_open_ssl_failure(struct wpa_supplicant * wpa_s,const char * reason_string)1385 void wpas_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
1386 			const char *reason_string)
1387 {
1388 	wpas_aidl_notify_open_ssl_failure(wpa_s, reason_string);
1389 }
1390 
wpas_notify_qos_policy_reset(struct wpa_supplicant * wpa_s)1391 void wpas_notify_qos_policy_reset(struct wpa_supplicant *wpa_s)
1392 {
1393 	if (!wpa_s)
1394 		return;
1395 
1396 	wpas_aidl_notify_qos_policy_reset(wpa_s);
1397 }
1398 
wpas_notify_qos_policy_request(struct wpa_supplicant * wpa_s,struct dscp_policy_data * policies,int num_policies)1399 void wpas_notify_qos_policy_request(struct wpa_supplicant *wpa_s,
1400 	struct dscp_policy_data *policies, int num_policies)
1401 {
1402 	if (!wpa_s || !policies)
1403 		return;
1404 
1405 	wpas_aidl_notify_qos_policy_request(wpa_s, policies, num_policies);
1406 }
1407 
wpas_notify_frequency_changed(struct wpa_supplicant * wpa_s,int frequency)1408 void wpas_notify_frequency_changed(struct wpa_supplicant *wpa_s, int frequency)
1409 {
1410 	if (!wpa_s)
1411 		return;
1412 
1413 	wpas_aidl_notify_frequency_changed(wpa_s, frequency);
1414 }
1415 
wpas_get_certificate(const char * alias,uint8_t ** value)1416 ssize_t wpas_get_certificate(const char *alias, uint8_t** value)
1417 {
1418 	wpa_printf(MSG_INFO, "wpas_get_certificate");
1419 	return wpas_aidl_get_certificate(alias, value);
1420 }
1421 
wpas_list_aliases(const char * prefix,char *** aliases)1422 ssize_t wpas_list_aliases(const char *prefix, char ***aliases)
1423 {
1424 	return wpas_aidl_list_aliases(prefix, aliases);
1425 }
1426 
wpas_notify_signal_change(struct wpa_supplicant * wpa_s)1427 void wpas_notify_signal_change(struct wpa_supplicant *wpa_s)
1428 {
1429 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE);
1430 }
1431 
wpas_notify_qos_policy_scs_response(struct wpa_supplicant * wpa_s,unsigned int num_scs_resp,int ** scs_resp)1432 void wpas_notify_qos_policy_scs_response(struct wpa_supplicant *wpa_s,
1433 		unsigned int num_scs_resp, int **scs_resp)
1434 {
1435 	if (!wpa_s || !num_scs_resp || !scs_resp)
1436 		return;
1437 
1438 	wpas_aidl_notify_qos_policy_scs_response(wpa_s, num_scs_resp, scs_resp);
1439 }
1440