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 "common/nan_de.h"
14  #include "config.h"
15  #include "wpa_supplicant_i.h"
16  #include "wps_supplicant.h"
17  #include "binder/binder.h"
18  #include "dbus/dbus_common.h"
19  #include "dbus/dbus_new.h"
20  #include "rsn_supp/wpa.h"
21  #include "rsn_supp/pmksa_cache.h"
22  #include "fst/fst.h"
23  #include "crypto/tls.h"
24  #include "bss.h"
25  #include "driver_i.h"
26  #include "scan.h"
27  #include "p2p_supplicant.h"
28  #include "sme.h"
29  #include "notify.h"
30  
wpas_notify_supplicant_initialized(struct wpa_global * global)31  int wpas_notify_supplicant_initialized(struct wpa_global *global)
32  {
33  #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
34  	if (global->params.dbus_ctrl_interface) {
35  		global->dbus = wpas_dbus_init(global);
36  		if (global->dbus == NULL)
37  			return -1;
38  	}
39  #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
40  
41  #ifdef CONFIG_BINDER
42  	global->binder = wpas_binder_init(global);
43  	if (!global->binder)
44  		return -1;
45  #endif /* CONFIG_BINDER */
46  
47  	return 0;
48  }
49  
50  
wpas_notify_supplicant_deinitialized(struct wpa_global * global)51  void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
52  {
53  #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
54  	if (global->dbus)
55  		wpas_dbus_deinit(global->dbus);
56  #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
57  
58  #ifdef CONFIG_BINDER
59  	if (global->binder)
60  		wpas_binder_deinit(global->binder);
61  #endif /* CONFIG_BINDER */
62  }
63  
64  
wpas_notify_iface_added(struct wpa_supplicant * wpa_s)65  int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
66  {
67  	if (wpa_s->p2p_mgmt)
68  		return 0;
69  
70  	if (wpas_dbus_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  		return;
81  
82  	/* unregister interface in new DBus ctrl iface */
83  	wpas_dbus_unregister_interface(wpa_s);
84  }
85  
86  
wpas_notify_state_changed(struct wpa_supplicant * wpa_s,enum wpa_states new_state,enum wpa_states old_state)87  void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
88  			       enum wpa_states new_state,
89  			       enum wpa_states old_state)
90  {
91  	struct wpa_ssid *ssid = wpa_s->current_ssid;
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  		if (ssid)
112  			wpa_drv_roaming(wpa_s, !ssid->bssid_set,
113  					ssid->bssid_set ? ssid->bssid : NULL);
114  	} else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED) {
115  		wpas_p2p_notif_disconnected(wpa_s);
116  	}
117  
118  	sme_state_changed(wpa_s);
119  
120  #ifdef ANDROID
121  	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
122  		     "id=%d state=%d BSSID=" MACSTR " SSID=%s",
123  		     wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
124  		     new_state,
125  		     MAC2STR(wpa_s->bssid),
126  		     wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
127  		     wpa_ssid_txt(wpa_s->current_ssid->ssid,
128  				  wpa_s->current_ssid->ssid_len) : "");
129  #endif /* ANDROID */
130  }
131  
132  
wpas_notify_disconnect_reason(struct wpa_supplicant * wpa_s)133  void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
134  {
135  	if (wpa_s->p2p_mgmt)
136  		return;
137  
138  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
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)151  void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
152  {
153  	if (wpa_s->p2p_mgmt)
154  		return;
155  
156  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
157  }
158  
159  
wpas_notify_roam_time(struct wpa_supplicant * wpa_s)160  void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
161  {
162  	if (wpa_s->p2p_mgmt)
163  		return;
164  
165  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
166  }
167  
168  
wpas_notify_roam_complete(struct wpa_supplicant * wpa_s)169  void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
170  {
171  	if (wpa_s->p2p_mgmt)
172  		return;
173  
174  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
175  }
176  
177  
wpas_notify_scan_in_progress_6ghz(struct wpa_supplicant * wpa_s)178  void wpas_notify_scan_in_progress_6ghz(struct wpa_supplicant *wpa_s)
179  {
180  	if (wpa_s->p2p_mgmt)
181  		return;
182  
183  	wpas_dbus_signal_prop_changed(wpa_s,
184  				      WPAS_DBUS_PROP_SCAN_IN_PROGRESS_6GHZ);
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  
205  
wpas_notify_network_changed(struct wpa_supplicant * wpa_s)206  void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
207  {
208  	if (wpa_s->p2p_mgmt)
209  		return;
210  
211  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
212  }
213  
214  
wpas_notify_ap_scan_changed(struct wpa_supplicant * wpa_s)215  void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
216  {
217  	if (wpa_s->p2p_mgmt)
218  		return;
219  
220  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
221  }
222  
223  
wpas_notify_bssid_changed(struct wpa_supplicant * wpa_s)224  void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
225  {
226  	if (wpa_s->p2p_mgmt)
227  		return;
228  
229  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
230  }
231  
232  
wpas_notify_mac_address_changed(struct wpa_supplicant * wpa_s)233  void wpas_notify_mac_address_changed(struct wpa_supplicant *wpa_s)
234  {
235  	if (wpa_s->p2p_mgmt)
236  		return;
237  
238  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_MAC_ADDRESS);
239  }
240  
241  
wpas_notify_auth_changed(struct wpa_supplicant * wpa_s)242  void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
243  {
244  	if (wpa_s->p2p_mgmt)
245  		return;
246  
247  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
248  }
249  
250  
wpas_notify_network_enabled_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)251  void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
252  					 struct wpa_ssid *ssid)
253  {
254  	if (wpa_s->p2p_mgmt)
255  		return;
256  
257  	wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
258  }
259  
260  
wpas_notify_network_selected(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)261  void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
262  				  struct wpa_ssid *ssid)
263  {
264  	if (wpa_s->p2p_mgmt)
265  		return;
266  
267  	wpas_dbus_signal_network_selected(wpa_s, ssid->id);
268  }
269  
270  
wpas_notify_network_request(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,enum wpa_ctrl_req_type rtype,const char * default_txt)271  void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
272  				 struct wpa_ssid *ssid,
273  				 enum wpa_ctrl_req_type rtype,
274  				 const char *default_txt)
275  {
276  	if (wpa_s->p2p_mgmt)
277  		return;
278  
279  	wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
280  }
281  
282  
wpas_notify_scanning(struct wpa_supplicant * wpa_s)283  void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
284  {
285  	if (wpa_s->p2p_mgmt)
286  		return;
287  
288  	/* notify the new DBus API */
289  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
290  }
291  
292  
wpas_notify_scan_done(struct wpa_supplicant * wpa_s,int success)293  void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
294  {
295  	if (wpa_s->p2p_mgmt)
296  		return;
297  
298  	wpas_dbus_signal_scan_done(wpa_s, success);
299  }
300  
301  
wpas_notify_scan_results(struct wpa_supplicant * wpa_s)302  void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
303  {
304  	if (wpa_s->p2p_mgmt)
305  		return;
306  
307  	wpas_wps_notify_scan_results(wpa_s);
308  }
309  
310  
wpas_notify_wps_credential(struct wpa_supplicant * wpa_s,const struct wps_credential * cred)311  void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
312  				const struct wps_credential *cred)
313  {
314  	if (wpa_s->p2p_mgmt)
315  		return;
316  
317  #ifdef CONFIG_WPS
318  	/* notify the new DBus API */
319  	wpas_dbus_signal_wps_cred(wpa_s, cred);
320  #endif /* CONFIG_WPS */
321  }
322  
323  
wpas_notify_wps_event_m2d(struct wpa_supplicant * wpa_s,struct wps_event_m2d * m2d)324  void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
325  			       struct wps_event_m2d *m2d)
326  {
327  	if (wpa_s->p2p_mgmt)
328  		return;
329  
330  #ifdef CONFIG_WPS
331  	wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
332  #endif /* CONFIG_WPS */
333  }
334  
335  
wpas_notify_wps_event_fail(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)336  void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
337  				struct wps_event_fail *fail)
338  {
339  	if (wpa_s->p2p_mgmt)
340  		return;
341  
342  #ifdef CONFIG_WPS
343  	wpas_dbus_signal_wps_event_fail(wpa_s, fail);
344  #endif /* CONFIG_WPS */
345  }
346  
347  
wpas_notify_wps_event_success(struct wpa_supplicant * wpa_s)348  void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
349  {
350  	if (wpa_s->p2p_mgmt)
351  		return;
352  
353  #ifdef CONFIG_WPS
354  	wpas_dbus_signal_wps_event_success(wpa_s);
355  #endif /* CONFIG_WPS */
356  }
357  
wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant * wpa_s)358  void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
359  {
360  	if (wpa_s->p2p_mgmt)
361  		return;
362  
363  #ifdef CONFIG_WPS
364  	wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
365  #endif /* CONFIG_WPS */
366  }
367  
368  
wpas_notify_network_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)369  void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
370  			       struct wpa_ssid *ssid)
371  {
372  	if (wpa_s->p2p_mgmt)
373  		return;
374  
375  	/*
376  	 * Networks objects created during any P2P activities should not be
377  	 * exposed out. They might/will confuse certain non-P2P aware
378  	 * applications since these network objects won't behave like
379  	 * regular ones.
380  	 */
381  	if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
382  		wpas_dbus_register_network(wpa_s, ssid);
383  		wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_ADDED "%d",
384  			     ssid->id);
385  	}
386  }
387  
388  
wpas_notify_persistent_group_added(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)389  void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
390  					struct wpa_ssid *ssid)
391  {
392  #ifdef CONFIG_P2P
393  	wpas_dbus_register_persistent_group(wpa_s, ssid);
394  #endif /* CONFIG_P2P */
395  }
396  
397  
wpas_notify_persistent_group_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)398  void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
399  					  struct wpa_ssid *ssid)
400  {
401  #ifdef CONFIG_P2P
402  	wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
403  #endif /* CONFIG_P2P */
404  }
405  
406  
wpas_notify_network_removed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)407  void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
408  				 struct wpa_ssid *ssid)
409  {
410  	if (wpa_s->next_ssid == ssid)
411  		wpa_s->next_ssid = NULL;
412  	if (wpa_s->last_ssid == ssid)
413  		wpa_s->last_ssid = NULL;
414  	if (wpa_s->current_ssid == ssid)
415  		wpa_s->current_ssid = NULL;
416  	if (wpa_s->ml_connect_probe_ssid == ssid) {
417  		wpa_s->ml_connect_probe_ssid = NULL;
418  		wpa_s->ml_connect_probe_bss = NULL;
419  	}
420  	if (wpa_s->connect_without_scan == ssid)
421  		wpa_s->connect_without_scan = NULL;
422  #if defined(CONFIG_SME) && defined(CONFIG_SAE)
423  	if (wpa_s->sme.ext_auth_wpa_ssid == ssid)
424  		wpa_s->sme.ext_auth_wpa_ssid = NULL;
425  #endif /* CONFIG_SME && CONFIG_SAE */
426  	if (wpa_s->wpa) {
427  		if ((wpa_key_mgmt_sae(ssid->key_mgmt) &&
428  		     (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SAE_OFFLOAD_STA)) ||
429  		    ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) &&
430  		     (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA))) {
431  			/* For cases when PMK is generated at the driver */
432  			struct wpa_pmkid_params params;
433  
434  			os_memset(&params, 0, sizeof(params));
435  			params.ssid = ssid->ssid;
436  			params.ssid_len = ssid->ssid_len;
437  			wpa_drv_remove_pmkid(wpa_s, &params);
438  		}
439  		wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
440  	}
441  	if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
442  	    !wpa_s->p2p_mgmt) {
443  		wpas_dbus_unregister_network(wpa_s, ssid->id);
444  		wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_REMOVED "%d",
445  			     ssid->id);
446  	}
447  	if (network_is_persistent_group(ssid))
448  		wpas_notify_persistent_group_removed(wpa_s, ssid);
449  
450  	wpas_p2p_network_removed(wpa_s, ssid);
451  }
452  
453  
wpas_notify_bss_added(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)454  void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
455  			   u8 bssid[], unsigned int id)
456  {
457  	if (wpa_s->p2p_mgmt)
458  		return;
459  
460  	wpas_dbus_register_bss(wpa_s, bssid, id);
461  	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
462  		     id, MAC2STR(bssid));
463  }
464  
465  
wpas_notify_bss_removed(struct wpa_supplicant * wpa_s,u8 bssid[],unsigned int id)466  void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
467  			     u8 bssid[], unsigned int id)
468  {
469  	if (wpa_s->p2p_mgmt)
470  		return;
471  
472  	wpas_dbus_unregister_bss(wpa_s, bssid, id);
473  	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
474  		     id, MAC2STR(bssid));
475  }
476  
477  
wpas_notify_bss_freq_changed(struct wpa_supplicant * wpa_s,unsigned int id)478  void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
479  				  unsigned int id)
480  {
481  	if (wpa_s->p2p_mgmt)
482  		return;
483  
484  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
485  }
486  
487  
wpas_notify_bss_signal_changed(struct wpa_supplicant * wpa_s,unsigned int id)488  void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
489  				    unsigned int id)
490  {
491  	if (wpa_s->p2p_mgmt)
492  		return;
493  
494  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
495  					  id);
496  }
497  
498  
wpas_notify_bss_privacy_changed(struct wpa_supplicant * wpa_s,unsigned int id)499  void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
500  				     unsigned int id)
501  {
502  	if (wpa_s->p2p_mgmt)
503  		return;
504  
505  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
506  					  id);
507  }
508  
509  
wpas_notify_bss_mode_changed(struct wpa_supplicant * wpa_s,unsigned int id)510  void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
511  				  unsigned int id)
512  {
513  	if (wpa_s->p2p_mgmt)
514  		return;
515  
516  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
517  }
518  
519  
wpas_notify_bss_wpaie_changed(struct wpa_supplicant * wpa_s,unsigned int id)520  void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
521  				   unsigned int id)
522  {
523  	if (wpa_s->p2p_mgmt)
524  		return;
525  
526  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
527  }
528  
529  
wpas_notify_bss_rsnie_changed(struct wpa_supplicant * wpa_s,unsigned int id)530  void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
531  				   unsigned int id)
532  {
533  	if (wpa_s->p2p_mgmt)
534  		return;
535  
536  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
537  }
538  
539  
wpas_notify_bss_wps_changed(struct wpa_supplicant * wpa_s,unsigned int id)540  void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
541  				 unsigned int id)
542  {
543  	if (wpa_s->p2p_mgmt)
544  		return;
545  
546  #ifdef CONFIG_WPS
547  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
548  #endif /* CONFIG_WPS */
549  }
550  
551  
wpas_notify_bss_ies_changed(struct wpa_supplicant * wpa_s,unsigned int id)552  void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
553  				   unsigned int id)
554  {
555  	if (wpa_s->p2p_mgmt)
556  		return;
557  
558  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
559  }
560  
561  
wpas_notify_bss_rates_changed(struct wpa_supplicant * wpa_s,unsigned int id)562  void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
563  				   unsigned int id)
564  {
565  	if (wpa_s->p2p_mgmt)
566  		return;
567  
568  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
569  }
570  
571  
wpas_notify_bss_seen(struct wpa_supplicant * wpa_s,unsigned int id)572  void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
573  {
574  	if (wpa_s->p2p_mgmt)
575  		return;
576  
577  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
578  }
579  
580  
wpas_notify_bss_anqp_changed(struct wpa_supplicant * wpa_s,unsigned int id)581  void wpas_notify_bss_anqp_changed(struct wpa_supplicant *wpa_s, unsigned int id)
582  {
583  	if (wpa_s->p2p_mgmt)
584  		return;
585  
586  	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_ANQP, id);
587  }
588  
589  
wpas_notify_blob_added(struct wpa_supplicant * wpa_s,const char * name)590  void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
591  {
592  	if (wpa_s->p2p_mgmt)
593  		return;
594  
595  	wpas_dbus_signal_blob_added(wpa_s, name);
596  }
597  
598  
wpas_notify_blob_removed(struct wpa_supplicant * wpa_s,const char * name)599  void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
600  {
601  	if (wpa_s->p2p_mgmt)
602  		return;
603  
604  	wpas_dbus_signal_blob_removed(wpa_s, name);
605  }
606  
607  
wpas_notify_debug_level_changed(struct wpa_global * global)608  void wpas_notify_debug_level_changed(struct wpa_global *global)
609  {
610  	wpas_dbus_signal_debug_level_changed(global);
611  }
612  
613  
wpas_notify_debug_timestamp_changed(struct wpa_global * global)614  void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
615  {
616  	wpas_dbus_signal_debug_timestamp_changed(global);
617  }
618  
619  
wpas_notify_debug_show_keys_changed(struct wpa_global * global)620  void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
621  {
622  	wpas_dbus_signal_debug_show_keys_changed(global);
623  }
624  
625  
wpas_notify_suspend(struct wpa_global * global)626  void wpas_notify_suspend(struct wpa_global *global)
627  {
628  	struct wpa_supplicant *wpa_s;
629  
630  	os_get_time(&global->suspend_time);
631  	wpa_printf(MSG_DEBUG, "System suspend notification");
632  	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
633  		wpa_drv_suspend(wpa_s);
634  }
635  
636  
wpas_notify_resume(struct wpa_global * global)637  void wpas_notify_resume(struct wpa_global *global)
638  {
639  	struct os_time now;
640  	int slept;
641  	struct wpa_supplicant *wpa_s;
642  
643  	if (global->suspend_time.sec == 0)
644  		slept = -1;
645  	else {
646  		os_get_time(&now);
647  		slept = now.sec - global->suspend_time.sec;
648  	}
649  	wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
650  		   slept);
651  
652  	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
653  		wpa_drv_resume(wpa_s);
654  		if (wpa_s->wpa_state == WPA_DISCONNECTED)
655  			wpa_supplicant_req_scan(wpa_s, 0, 100000);
656  	}
657  }
658  
659  
660  #ifdef CONFIG_P2P
661  
wpas_notify_p2p_find_stopped(struct wpa_supplicant * wpa_s)662  void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
663  {
664  	/* Notify P2P find has stopped */
665  	wpas_dbus_signal_p2p_find_stopped(wpa_s);
666  }
667  
668  
wpas_notify_p2p_device_found(struct wpa_supplicant * wpa_s,const u8 * dev_addr,int new_device)669  void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
670  				  const u8 *dev_addr, int new_device)
671  {
672  	if (new_device) {
673  		/* Create the new peer object */
674  		wpas_dbus_register_peer(wpa_s, dev_addr);
675  	}
676  
677  	/* Notify a new peer has been detected*/
678  	wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
679  }
680  
681  
wpas_notify_p2p_device_lost(struct wpa_supplicant * wpa_s,const u8 * dev_addr)682  void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
683  				 const u8 *dev_addr)
684  {
685  	wpas_dbus_unregister_peer(wpa_s, dev_addr);
686  
687  	/* Create signal on interface object*/
688  	wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
689  }
690  
691  
wpas_notify_p2p_group_removed(struct wpa_supplicant * wpa_s,const struct wpa_ssid * ssid,const char * role)692  void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
693  				   const struct wpa_ssid *ssid,
694  				   const char *role)
695  {
696  	wpas_dbus_signal_p2p_group_removed(wpa_s, role);
697  
698  	wpas_dbus_unregister_p2p_group(wpa_s, ssid);
699  }
700  
701  
wpas_notify_p2p_go_neg_req(struct wpa_supplicant * wpa_s,const u8 * src,u16 dev_passwd_id,u8 go_intent)702  void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
703  				const u8 *src, u16 dev_passwd_id, u8 go_intent)
704  {
705  	wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
706  }
707  
708  
wpas_notify_p2p_go_neg_completed(struct wpa_supplicant * wpa_s,struct p2p_go_neg_results * res)709  void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
710  				      struct p2p_go_neg_results *res)
711  {
712  	wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
713  }
714  
715  
wpas_notify_p2p_invitation_result(struct wpa_supplicant * wpa_s,int status,const u8 * bssid)716  void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
717  				       int status, const u8 *bssid)
718  {
719  	wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
720  }
721  
722  
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)723  void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
724  				int freq, const u8 *sa, u8 dialog_token,
725  				u16 update_indic, const u8 *tlvs,
726  				size_t tlvs_len)
727  {
728  	wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
729  					update_indic, tlvs, tlvs_len);
730  }
731  
732  
wpas_notify_p2p_sd_response(struct wpa_supplicant * wpa_s,const u8 * sa,u16 update_indic,const u8 * tlvs,size_t tlvs_len)733  void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
734  				 const u8 *sa, u16 update_indic,
735  				 const u8 *tlvs, size_t tlvs_len)
736  {
737  	wpas_dbus_signal_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  
766  
wpas_notify_p2p_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid,int persistent,int client,const u8 * ip)767  void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
768  				   struct wpa_ssid *ssid, int persistent,
769  				   int client, const u8 *ip)
770  {
771  	/* Notify a group has been started */
772  	wpas_dbus_register_p2p_group(wpa_s, ssid);
773  
774  	wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
775  }
776  
777  
wpas_notify_p2p_group_formation_failure(struct wpa_supplicant * wpa_s,const char * reason)778  void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
779  					     const char *reason)
780  {
781  	/* Notify a group formation failed */
782  	wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
783  }
784  
785  
wpas_notify_p2p_wps_failed(struct wpa_supplicant * wpa_s,struct wps_event_fail * fail)786  void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
787  				struct wps_event_fail *fail)
788  {
789  	wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
790  }
791  
792  
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)793  void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
794  					 const u8 *sa, const u8 *go_dev_addr,
795  					 const u8 *bssid, int id, int op_freq)
796  {
797  	/* Notify a P2P Invitation Request */
798  	wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
799  						 id, op_freq);
800  }
801  
wpas_notify_p2p_bootstrap_req(struct wpa_supplicant * wpa_s,const u8 * src,u16 bootstrap_method)802  void wpas_notify_p2p_bootstrap_req(struct wpa_supplicant *wpa_s,
803  				   const u8 *src, u16 bootstrap_method)
804  {
805  	wpas_dbus_signal_p2p_bootstrap_req(wpa_s, src, bootstrap_method);
806  }
807  
wpas_notify_p2p_bootstrap_rsp(struct wpa_supplicant * wpa_s,const u8 * src,int status,u16 bootstrap_method)808  void wpas_notify_p2p_bootstrap_rsp(struct wpa_supplicant *wpa_s,
809  				   const u8 *src, int status,
810  				   u16 bootstrap_method)
811  {
812  	wpas_dbus_signal_p2p_bootstrap_rsp(wpa_s, src, status,
813  					   bootstrap_method);
814  }
815  
816  #endif /* CONFIG_P2P */
817  
818  
wpas_notify_ap_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * sta,const u8 * p2p_dev_addr,const u8 * ip)819  static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
820  					  const u8 *sta,
821  					  const u8 *p2p_dev_addr, const u8 *ip)
822  {
823  #ifdef CONFIG_P2P
824  	wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
825  
826  	/*
827  	 * Create 'peer-joined' signal on group object -- will also
828  	 * check P2P itself.
829  	 */
830  	if (p2p_dev_addr)
831  		wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
832  #endif /* CONFIG_P2P */
833  
834  	/* Register the station */
835  	wpas_dbus_register_sta(wpa_s, sta);
836  
837  	/* Notify listeners a new station has been authorized */
838  	wpas_dbus_signal_sta_authorized(wpa_s, sta);
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  	/* Unregister the station */
859  	wpas_dbus_unregister_sta(wpa_s, sta);
860  }
861  
862  
wpas_notify_sta_authorized(struct wpa_supplicant * wpa_s,const u8 * mac_addr,int authorized,const u8 * p2p_dev_addr,const u8 * ip)863  void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
864  				const u8 *mac_addr, int authorized,
865  				const u8 *p2p_dev_addr, const u8 *ip)
866  {
867  	if (authorized)
868  		wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr,
869  					      ip);
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_msg(wpa_s, MSG_ERROR, WPA_EVENT_EAP_ERROR_CODE "%d", error_code);
937  }
938  
939  
wpas_notify_psk_mismatch(struct wpa_supplicant * wpa_s)940  void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s)
941  {
942  	wpas_dbus_signal_psk_mismatch(wpa_s);
943  }
944  
945  
wpas_notify_network_bssid_set_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)946  void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
947  					   struct wpa_ssid *ssid)
948  {
949  	if (wpa_s->current_ssid != ssid)
950  		return;
951  
952  	wpa_dbg(wpa_s, MSG_DEBUG,
953  		"Network bssid config changed for the current network - within-ESS roaming %s",
954  		ssid->bssid_set ? "disabled" : "enabled");
955  
956  	wpa_drv_roaming(wpa_s, !ssid->bssid_set,
957  			ssid->bssid_set ? ssid->bssid : NULL);
958  }
959  
960  
wpas_notify_network_type_changed(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)961  void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
962  				      struct wpa_ssid *ssid)
963  {
964  #ifdef CONFIG_P2P
965  	if (ssid->disabled == 2) {
966  		/* Changed from normal network profile to persistent group */
967  		ssid->disabled = 0;
968  		wpas_dbus_unregister_network(wpa_s, ssid->id);
969  		ssid->disabled = 2;
970  		ssid->p2p_persistent_group = 1;
971  		wpas_dbus_register_persistent_group(wpa_s, ssid);
972  	} else {
973  		/* Changed from persistent group to normal network profile */
974  		wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
975  		ssid->p2p_persistent_group = 0;
976  		wpas_dbus_register_network(wpa_s, ssid);
977  	}
978  #endif /* CONFIG_P2P */
979  }
980  
981  
982  #ifdef CONFIG_MESH
983  
wpas_notify_mesh_group_started(struct wpa_supplicant * wpa_s,struct wpa_ssid * ssid)984  void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
985  				    struct wpa_ssid *ssid)
986  {
987  	if (wpa_s->p2p_mgmt)
988  		return;
989  
990  	wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
991  }
992  
993  
wpas_notify_mesh_group_removed(struct wpa_supplicant * wpa_s,const u8 * meshid,u8 meshid_len,u16 reason_code)994  void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
995  				    const u8 *meshid, u8 meshid_len,
996  				    u16 reason_code)
997  {
998  	if (wpa_s->p2p_mgmt)
999  		return;
1000  
1001  	wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1002  					    reason_code);
1003  }
1004  
1005  
wpas_notify_mesh_peer_connected(struct wpa_supplicant * wpa_s,const u8 * peer_addr)1006  void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1007  				     const u8 *peer_addr)
1008  {
1009  	if (wpa_s->p2p_mgmt)
1010  		return;
1011  
1012  	wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR,
1013  		MAC2STR(peer_addr));
1014  	wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1015  }
1016  
1017  
wpas_notify_mesh_peer_disconnected(struct wpa_supplicant * wpa_s,const u8 * peer_addr,u16 reason_code)1018  void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
1019  					const u8 *peer_addr, u16 reason_code)
1020  {
1021  	if (wpa_s->p2p_mgmt)
1022  		return;
1023  
1024  	wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
1025  		MAC2STR(peer_addr));
1026  	wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1027  }
1028  
1029  #endif /* CONFIG_MESH */
1030  
1031  
1032  #ifdef CONFIG_INTERWORKING
1033  
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)1034  void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
1035  				       struct wpa_bss *bss,
1036  				       struct wpa_cred *cred, int excluded,
1037  				       const char *type, int bh, int bss_load,
1038  				       int conn_capab)
1039  {
1040  	wpa_msg(wpa_s, MSG_INFO, "%s" MACSTR " type=%s%s%s%s id=%d priority=%d sp_priority=%d",
1041  		excluded ? INTERWORKING_EXCLUDED : INTERWORKING_AP,
1042  		MAC2STR(bss->bssid), type,
1043  		bh ? " below_min_backhaul=1" : "",
1044  		bss_load ? " over_max_bss_load=1" : "",
1045  		conn_capab ? " conn_capab_missing=1" : "",
1046  		cred->id, cred->priority, cred->sp_priority);
1047  
1048  	wpas_dbus_signal_interworking_ap_added(wpa_s, bss, cred, type, excluded,
1049  					       bh, bss_load, conn_capab);
1050  }
1051  
1052  
wpas_notify_interworking_select_done(struct wpa_supplicant * wpa_s)1053  void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
1054  {
1055  	wpas_dbus_signal_interworking_select_done(wpa_s);
1056  }
1057  
1058  
wpas_notify_anqp_query_done(struct wpa_supplicant * wpa_s,const u8 * dst,const char * result)1059  void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s,
1060  				 const u8 *dst, const char *result)
1061  {
1062  	wpa_msg(wpa_s, MSG_INFO, ANQP_QUERY_DONE "addr=" MACSTR " result=%s",
1063  		MAC2STR(dst), result);
1064  
1065  	wpas_dbus_signal_anqp_query_done(wpa_s, dst, result);
1066  }
1067  
1068  #endif /* CONFIG_INTERWORKING */
1069  
1070  
wpas_notify_pmk_cache_added(struct wpa_supplicant * wpa_s,struct rsn_pmksa_cache_entry * entry)1071  void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1072  				 struct rsn_pmksa_cache_entry *entry)
1073  {
1074  	/* TODO: Notify external entities of the added PMKSA cache entry */
1075  }
1076  
1077  
wpas_notify_signal_change(struct wpa_supplicant * wpa_s)1078  void wpas_notify_signal_change(struct wpa_supplicant *wpa_s)
1079  {
1080  	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE);
1081  }
1082  
1083  
1084  #ifdef CONFIG_HS20
wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant * wpa_s,const char * url)1085  void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
1086  				     const char *url)
1087  {
1088  	wpa_msg(wpa_s, MSG_INFO, HS20_T_C_ACCEPTANCE "%s", url);
1089  	wpas_dbus_signal_hs20_t_c_acceptance(wpa_s, url);
1090  }
1091  #endif /* CONFIG_HS20 */
1092  
1093  
1094  #ifdef CONFIG_NAN_USD
1095  
wpas_notify_nan_discovery_result(struct wpa_supplicant * wpa_s,enum nan_service_protocol_type srv_proto_type,int subscribe_id,int peer_publish_id,const u8 * peer_addr,bool fsd,bool fsd_gas,const u8 * ssi,size_t ssi_len)1096  void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
1097  				      enum nan_service_protocol_type
1098  				      srv_proto_type,
1099  				      int subscribe_id, int peer_publish_id,
1100  				      const u8 *peer_addr,
1101  				      bool fsd, bool fsd_gas,
1102  				      const u8 *ssi, size_t ssi_len)
1103  {
1104  	char *ssi_hex;
1105  
1106  	ssi_hex = os_zalloc(2 * ssi_len + 1);
1107  	if (!ssi_hex)
1108  		return;
1109  	if (ssi)
1110  		wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1111  	wpa_msg_global(wpa_s, MSG_INFO, NAN_DISCOVERY_RESULT
1112  		       "subscribe_id=%d publish_id=%d address=" MACSTR
1113  		       " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s",
1114  		       subscribe_id, peer_publish_id, MAC2STR(peer_addr),
1115  		       fsd, fsd_gas, srv_proto_type, ssi_hex);
1116  	os_free(ssi_hex);
1117  
1118  	wpas_dbus_signal_nan_discovery_result(wpa_s, srv_proto_type,
1119  					      subscribe_id, peer_publish_id,
1120  					      peer_addr, fsd, fsd_gas,
1121  					      ssi, ssi_len);
1122  }
1123  
1124  
wpas_notify_nan_replied(struct wpa_supplicant * wpa_s,enum nan_service_protocol_type srv_proto_type,int publish_id,int peer_subscribe_id,const u8 * peer_addr,const u8 * ssi,size_t ssi_len)1125  void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s,
1126  			     enum nan_service_protocol_type srv_proto_type,
1127  			     int publish_id, int peer_subscribe_id,
1128  			     const u8 *peer_addr,
1129  			     const u8 *ssi, size_t ssi_len)
1130  {
1131  	char *ssi_hex;
1132  
1133  	ssi_hex = os_zalloc(2 * ssi_len + 1);
1134  	if (!ssi_hex)
1135  		return;
1136  	if (ssi)
1137  		wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1138  	wpa_msg_global(wpa_s, MSG_INFO, NAN_REPLIED
1139  		       "publish_id=%d address=" MACSTR
1140  		       " subscribe_id=%d srv_proto_type=%u ssi=%s",
1141  		       publish_id, MAC2STR(peer_addr), peer_subscribe_id,
1142  		       srv_proto_type, ssi_hex);
1143  	os_free(ssi_hex);
1144  
1145  	wpas_dbus_signal_nan_replied(wpa_s, srv_proto_type, publish_id,
1146  				     peer_subscribe_id, peer_addr,
1147  				     ssi, ssi_len);
1148  }
1149  
1150  
wpas_notify_nan_receive(struct wpa_supplicant * wpa_s,int id,int peer_instance_id,const u8 * peer_addr,const u8 * ssi,size_t ssi_len)1151  void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id,
1152  			     int peer_instance_id, const u8 *peer_addr,
1153  			     const u8 *ssi, size_t ssi_len)
1154  {
1155  	char *ssi_hex;
1156  
1157  	ssi_hex = os_zalloc(2 * ssi_len + 1);
1158  	if (!ssi_hex)
1159  		return;
1160  	if (ssi)
1161  		wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1162  	wpa_msg_global(wpa_s, MSG_INFO, NAN_RECEIVE
1163  		       "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s",
1164  		       id, peer_instance_id, MAC2STR(peer_addr), ssi_hex);
1165  	os_free(ssi_hex);
1166  
1167  	wpas_dbus_signal_nan_receive(wpa_s, id, peer_instance_id, peer_addr,
1168  				     ssi, ssi_len);
1169  }
1170  
1171  
nan_reason_txt(enum nan_de_reason reason)1172  static const char * nan_reason_txt(enum nan_de_reason reason)
1173  {
1174  	switch (reason) {
1175  	case NAN_DE_REASON_TIMEOUT:
1176  		return "timeout";
1177  	case NAN_DE_REASON_USER_REQUEST:
1178  		return "user-request";
1179  	case NAN_DE_REASON_FAILURE:
1180  		return "failure";
1181  	}
1182  
1183  	return "unknown";
1184  }
1185  
1186  
wpas_notify_nan_publish_terminated(struct wpa_supplicant * wpa_s,int publish_id,enum nan_de_reason reason)1187  void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s,
1188  					int publish_id,
1189  					enum nan_de_reason reason)
1190  {
1191  	wpa_msg_global(wpa_s, MSG_INFO, NAN_PUBLISH_TERMINATED
1192  		       "publish_id=%d reason=%s",
1193  		       publish_id, nan_reason_txt(reason));
1194  	wpas_dbus_signal_nan_publish_terminated(wpa_s, publish_id,
1195  						nan_reason_txt(reason));
1196  }
1197  
1198  
wpas_notify_nan_subscribe_terminated(struct wpa_supplicant * wpa_s,int subscribe_id,enum nan_de_reason reason)1199  void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s,
1200  					  int subscribe_id,
1201  					  enum nan_de_reason reason)
1202  {
1203  	wpa_msg_global(wpa_s, MSG_INFO, NAN_SUBSCRIBE_TERMINATED
1204  		       "subscribe_id=%d reason=%s",
1205  		       subscribe_id, nan_reason_txt(reason));
1206  	wpas_dbus_signal_nan_subscribe_terminated(wpa_s, subscribe_id,
1207  						  nan_reason_txt(reason));
1208  }
1209  
1210  #endif /* CONFIG_NAN_USD */
1211