Home | History | Annotate | Download | only in wpa_supplicant
      1 /*
      2  * wpa_supplicant - Event notifications
      3  * Copyright (c) 2009-2010, Jouni Malinen <j (at) w1.fi>
      4  *
      5  * This software may be distributed under the terms of the BSD license.
      6  * See README for more details.
      7  */
      8 
      9 #include "utils/includes.h"
     10 
     11 #include "utils/common.h"
     12 #include "common/wpa_ctrl.h"
     13 #include "config.h"
     14 #include "wpa_supplicant_i.h"
     15 #include "wps_supplicant.h"
     16 #include "dbus/dbus_common.h"
     17 #include "dbus/dbus_old.h"
     18 #include "dbus/dbus_new.h"
     19 #include "rsn_supp/wpa.h"
     20 #include "fst/fst.h"
     21 #include "driver_i.h"
     22 #include "scan.h"
     23 #include "p2p_supplicant.h"
     24 #include "sme.h"
     25 #include "notify.h"
     26 #include "hidl.h"
     27 
     28 int wpas_notify_supplicant_initialized(struct wpa_global *global)
     29 {
     30 #ifdef CONFIG_DBUS
     31 	if (global->params.dbus_ctrl_interface) {
     32 		global->dbus = wpas_dbus_init(global);
     33 		if (global->dbus == NULL)
     34 			return -1;
     35 	}
     36 #endif /* CONFIG_DBUS */
     37 
     38 #ifdef CONFIG_HIDL
     39 	global->hidl = wpas_hidl_init(global);
     40 	if (!global->hidl)
     41 		return -1;
     42 #endif /* CONFIG_HIDL */
     43 
     44 	return 0;
     45 }
     46 
     47 
     48 void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
     49 {
     50 #ifdef CONFIG_DBUS
     51 	if (global->dbus)
     52 		wpas_dbus_deinit(global->dbus);
     53 #endif /* CONFIG_DBUS */
     54 
     55 #ifdef CONFIG_HIDL
     56 	if (global->hidl)
     57 		wpas_hidl_deinit(global->hidl);
     58 #endif /* CONFIG_HIDL */
     59 }
     60 
     61 
     62 int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
     63 {
     64 	if (!wpa_s->p2p_mgmt) {
     65 		if (wpas_dbus_register_iface(wpa_s))
     66 			return -1;
     67 
     68 		if (wpas_dbus_register_interface(wpa_s))
     69 			return -1;
     70 	}
     71 
     72 	/* HIDL interface wants to keep track of the P2P mgmt iface. */
     73 	if (wpas_hidl_register_interface(wpa_s))
     74 		return -1;
     75 
     76 	return 0;
     77 }
     78 
     79 
     80 void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
     81 {
     82 	if (!wpa_s->p2p_mgmt) {
     83 		/* unregister interface in old DBus ctrl iface */
     84 		wpas_dbus_unregister_iface(wpa_s);
     85 
     86 		/* unregister interface in new DBus ctrl iface */
     87 		wpas_dbus_unregister_interface(wpa_s);
     88 	}
     89 
     90 	/* HIDL interface wants to keep track of the P2P mgmt iface. */
     91 	wpas_hidl_unregister_interface(wpa_s);
     92 }
     93 
     94 
     95 void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
     96 			       enum wpa_states new_state,
     97 			       enum wpa_states old_state)
     98 {
     99 	if (wpa_s->p2p_mgmt)
    100 		return;
    101 
    102 	/* notify the old DBus API */
    103 	wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
    104 						old_state);
    105 
    106 	/* notify the new DBus API */
    107 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
    108 
    109 #ifdef CONFIG_FST
    110 	if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
    111 		if (new_state == WPA_COMPLETED)
    112 			fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
    113 		else if (old_state >= WPA_ASSOCIATED &&
    114 			 new_state < WPA_ASSOCIATED)
    115 			fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
    116 	}
    117 #endif /* CONFIG_FST */
    118 
    119 	if (new_state == WPA_COMPLETED)
    120 		wpas_p2p_notif_connected(wpa_s);
    121 	else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
    122 		wpas_p2p_notif_disconnected(wpa_s);
    123 
    124 	sme_state_changed(wpa_s);
    125 
    126 #ifdef ANDROID
    127 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
    128 		     "id=%d state=%d BSSID=" MACSTR " SSID=%s",
    129 		     wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
    130 		     new_state,
    131 		     MAC2STR(wpa_s->bssid),
    132 		     wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
    133 		     wpa_ssid_txt(wpa_s->current_ssid->ssid,
    134 				  wpa_s->current_ssid->ssid_len) : "");
    135 #endif /* ANDROID */
    136 
    137 	wpas_hidl_notify_state_changed(wpa_s);
    138 }
    139 
    140 
    141 void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
    142 {
    143 	if (wpa_s->p2p_mgmt)
    144 		return;
    145 
    146 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
    147 
    148 	wpas_hidl_notify_disconnect_reason(wpa_s);
    149 }
    150 
    151 
    152 void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
    153 {
    154 	if (wpa_s->p2p_mgmt)
    155 		return;
    156 
    157 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
    158 
    159 	wpas_hidl_notify_assoc_reject(wpa_s);
    160 }
    161 
    162 void wpas_notify_auth_timeout(struct wpa_supplicant *wpa_s) {
    163 	if (wpa_s->p2p_mgmt)
    164 		return;
    165 
    166 	wpas_hidl_notify_auth_timeout(wpa_s);
    167 }
    168 
    169 void wpas_notify_network_changed(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_CURRENT_NETWORK);
    175 }
    176 
    177 
    178 void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
    179 {
    180 	if (wpa_s->p2p_mgmt)
    181 		return;
    182 
    183 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
    184 }
    185 
    186 
    187 void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
    188 {
    189 	if (wpa_s->p2p_mgmt)
    190 		return;
    191 
    192 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
    193 
    194 	wpas_hidl_notify_bssid_changed(wpa_s);
    195 }
    196 
    197 
    198 void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
    199 {
    200 	if (wpa_s->p2p_mgmt)
    201 		return;
    202 
    203 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
    204 }
    205 
    206 
    207 void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
    208 					 struct wpa_ssid *ssid)
    209 {
    210 	if (wpa_s->p2p_mgmt)
    211 		return;
    212 
    213 	wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
    214 }
    215 
    216 
    217 void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
    218 				  struct wpa_ssid *ssid)
    219 {
    220 	if (wpa_s->p2p_mgmt)
    221 		return;
    222 
    223 	wpas_dbus_signal_network_selected(wpa_s, ssid->id);
    224 }
    225 
    226 
    227 void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
    228 				 struct wpa_ssid *ssid,
    229 				 enum wpa_ctrl_req_type rtype,
    230 				 const char *default_txt)
    231 {
    232 	if (wpa_s->p2p_mgmt)
    233 		return;
    234 
    235 	wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
    236 
    237 	wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt);
    238 }
    239 
    240 
    241 void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
    242 {
    243 	if (wpa_s->p2p_mgmt)
    244 		return;
    245 
    246 	/* notify the old DBus API */
    247 	wpa_supplicant_dbus_notify_scanning(wpa_s);
    248 
    249 	/* notify the new DBus API */
    250 	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
    251 }
    252 
    253 
    254 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
    255 {
    256 	if (wpa_s->p2p_mgmt)
    257 		return;
    258 
    259 	wpas_dbus_signal_scan_done(wpa_s, success);
    260 }
    261 
    262 
    263 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
    264 {
    265 	if (wpa_s->p2p_mgmt)
    266 		return;
    267 
    268 	/* notify the old DBus API */
    269 	wpa_supplicant_dbus_notify_scan_results(wpa_s);
    270 
    271 	wpas_wps_notify_scan_results(wpa_s);
    272 }
    273 
    274 
    275 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
    276 				const struct wps_credential *cred)
    277 {
    278 	if (wpa_s->p2p_mgmt)
    279 		return;
    280 
    281 #ifdef CONFIG_WPS
    282 	/* notify the old DBus API */
    283 	wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
    284 	/* notify the new DBus API */
    285 	wpas_dbus_signal_wps_cred(wpa_s, cred);
    286 #endif /* CONFIG_WPS */
    287 }
    288 
    289 
    290 void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
    291 			       struct wps_event_m2d *m2d)
    292 {
    293 	if (wpa_s->p2p_mgmt)
    294 		return;
    295 
    296 #ifdef CONFIG_WPS
    297 	wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
    298 #endif /* CONFIG_WPS */
    299 }
    300 
    301 
    302 void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
    303 				struct wps_event_fail *fail)
    304 {
    305 	if (wpa_s->p2p_mgmt)
    306 		return;
    307 
    308 #ifdef CONFIG_WPS
    309 	wpas_dbus_signal_wps_event_fail(wpa_s, fail);
    310 
    311 	wpas_hidl_notify_wps_event_fail(wpa_s, fail->peer_macaddr,
    312 					fail->config_error,
    313 					fail->error_indication);
    314 #endif /* CONFIG_WPS */
    315 }
    316 
    317 
    318 void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
    319 {
    320 	if (wpa_s->p2p_mgmt)
    321 		return;
    322 
    323 #ifdef CONFIG_WPS
    324 	wpas_dbus_signal_wps_event_success(wpa_s);
    325 
    326 	wpas_hidl_notify_wps_event_success(wpa_s);
    327 #endif /* CONFIG_WPS */
    328 }
    329 
    330 void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
    331 {
    332 	if (wpa_s->p2p_mgmt)
    333 		return;
    334 
    335 #ifdef CONFIG_WPS
    336 	wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
    337 
    338 	wpas_hidl_notify_wps_event_pbc_overlap(wpa_s);
    339 #endif /* CONFIG_WPS */
    340 }
    341 
    342 
    343 void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
    344 			       struct wpa_ssid *ssid)
    345 {
    346 	if (wpa_s->p2p_mgmt)
    347 		return;
    348 
    349 	/*
    350 	 * Networks objects created during any P2P activities should not be
    351 	 * exposed out. They might/will confuse certain non-P2P aware
    352 	 * applications since these network objects won't behave like
    353 	 * regular ones.
    354 	 */
    355 	if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
    356 		wpas_dbus_register_network(wpa_s, ssid);
    357 		wpas_hidl_register_network(wpa_s, ssid);
    358 	}
    359 }
    360 
    361 
    362 void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
    363 					struct wpa_ssid *ssid)
    364 {
    365 #ifdef CONFIG_P2P
    366 	wpas_dbus_register_persistent_group(wpa_s, ssid);
    367 	wpas_hidl_register_network(wpa_s, ssid);
    368 #endif /* CONFIG_P2P */
    369 }
    370 
    371 
    372 void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
    373 					  struct wpa_ssid *ssid)
    374 {
    375 #ifdef CONFIG_P2P
    376 	wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
    377 	wpas_hidl_unregister_network(wpa_s, ssid);
    378 #endif /* CONFIG_P2P */
    379 }
    380 
    381 
    382 void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
    383 				 struct wpa_ssid *ssid)
    384 {
    385 	if (wpa_s->next_ssid == ssid)
    386 		wpa_s->next_ssid = NULL;
    387 	if (wpa_s->wpa)
    388 		wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
    389 	if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
    390 	    !wpa_s->p2p_mgmt) {
    391 		wpas_dbus_unregister_network(wpa_s, ssid->id);
    392 		wpas_hidl_unregister_network(wpa_s, ssid);
    393 	}
    394 	if (network_is_persistent_group(ssid))
    395 		wpas_notify_persistent_group_removed(wpa_s, ssid);
    396 
    397 	wpas_p2p_network_removed(wpa_s, ssid);
    398 }
    399 
    400 
    401 void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
    402 			   u8 bssid[], unsigned int id)
    403 {
    404 	if (wpa_s->p2p_mgmt)
    405 		return;
    406 
    407 	wpas_dbus_register_bss(wpa_s, bssid, id);
    408 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
    409 		     id, MAC2STR(bssid));
    410 }
    411 
    412 
    413 void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
    414 			     u8 bssid[], unsigned int id)
    415 {
    416 	if (wpa_s->p2p_mgmt)
    417 		return;
    418 
    419 	wpas_dbus_unregister_bss(wpa_s, bssid, id);
    420 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
    421 		     id, MAC2STR(bssid));
    422 }
    423 
    424 
    425 void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
    426 				  unsigned int id)
    427 {
    428 	if (wpa_s->p2p_mgmt)
    429 		return;
    430 
    431 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
    432 }
    433 
    434 
    435 void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
    436 				    unsigned int id)
    437 {
    438 	if (wpa_s->p2p_mgmt)
    439 		return;
    440 
    441 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
    442 					  id);
    443 }
    444 
    445 
    446 void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
    447 				     unsigned int id)
    448 {
    449 	if (wpa_s->p2p_mgmt)
    450 		return;
    451 
    452 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
    453 					  id);
    454 }
    455 
    456 
    457 void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
    458 				  unsigned int id)
    459 {
    460 	if (wpa_s->p2p_mgmt)
    461 		return;
    462 
    463 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
    464 }
    465 
    466 
    467 void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
    468 				   unsigned int id)
    469 {
    470 	if (wpa_s->p2p_mgmt)
    471 		return;
    472 
    473 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
    474 }
    475 
    476 
    477 void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
    478 				   unsigned int id)
    479 {
    480 	if (wpa_s->p2p_mgmt)
    481 		return;
    482 
    483 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
    484 }
    485 
    486 
    487 void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
    488 				 unsigned int id)
    489 {
    490 	if (wpa_s->p2p_mgmt)
    491 		return;
    492 
    493 #ifdef CONFIG_WPS
    494 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
    495 #endif /* CONFIG_WPS */
    496 }
    497 
    498 
    499 void wpas_notify_bss_ies_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_IES, id);
    506 }
    507 
    508 
    509 void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
    510 				   unsigned int id)
    511 {
    512 	if (wpa_s->p2p_mgmt)
    513 		return;
    514 
    515 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
    516 }
    517 
    518 
    519 void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
    520 {
    521 	if (wpa_s->p2p_mgmt)
    522 		return;
    523 
    524 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
    525 }
    526 
    527 
    528 void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
    529 {
    530 	if (wpa_s->p2p_mgmt)
    531 		return;
    532 
    533 	wpas_dbus_signal_blob_added(wpa_s, name);
    534 }
    535 
    536 
    537 void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
    538 {
    539 	if (wpa_s->p2p_mgmt)
    540 		return;
    541 
    542 	wpas_dbus_signal_blob_removed(wpa_s, name);
    543 }
    544 
    545 
    546 void wpas_notify_debug_level_changed(struct wpa_global *global)
    547 {
    548 	wpas_dbus_signal_debug_level_changed(global);
    549 }
    550 
    551 
    552 void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
    553 {
    554 	wpas_dbus_signal_debug_timestamp_changed(global);
    555 }
    556 
    557 
    558 void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
    559 {
    560 	wpas_dbus_signal_debug_show_keys_changed(global);
    561 }
    562 
    563 
    564 void wpas_notify_suspend(struct wpa_global *global)
    565 {
    566 	struct wpa_supplicant *wpa_s;
    567 
    568 	os_get_time(&global->suspend_time);
    569 	wpa_printf(MSG_DEBUG, "System suspend notification");
    570 	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
    571 		wpa_drv_suspend(wpa_s);
    572 }
    573 
    574 
    575 void wpas_notify_resume(struct wpa_global *global)
    576 {
    577 	struct os_time now;
    578 	int slept;
    579 	struct wpa_supplicant *wpa_s;
    580 
    581 	if (global->suspend_time.sec == 0)
    582 		slept = -1;
    583 	else {
    584 		os_get_time(&now);
    585 		slept = now.sec - global->suspend_time.sec;
    586 	}
    587 	wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
    588 		   slept);
    589 
    590 	for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
    591 		wpa_drv_resume(wpa_s);
    592 		if (wpa_s->wpa_state == WPA_DISCONNECTED)
    593 			wpa_supplicant_req_scan(wpa_s, 0, 100000);
    594 	}
    595 }
    596 
    597 
    598 #ifdef CONFIG_P2P
    599 
    600 void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
    601 {
    602 	/* Notify P2P find has stopped */
    603 	wpas_dbus_signal_p2p_find_stopped(wpa_s);
    604 
    605 	wpas_hidl_notify_p2p_find_stopped(wpa_s);
    606 }
    607 
    608 
    609 void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
    610 				  const u8 *addr, const struct p2p_peer_info *info,
    611 				  const u8* peer_wfd_device_info, u8 peer_wfd_device_info_len,
    612 				  int new_device)
    613 {
    614 	if (new_device) {
    615 		/* Create the new peer object */
    616 		wpas_dbus_register_peer(wpa_s, info->p2p_device_addr);
    617 	}
    618 
    619 	/* Notify a new peer has been detected*/
    620 	wpas_dbus_signal_peer_device_found(wpa_s, info->p2p_device_addr);
    621 
    622 	wpas_hidl_notify_p2p_device_found(wpa_s, addr, info,
    623 					  peer_wfd_device_info,
    624 					  peer_wfd_device_info_len);
    625 }
    626 
    627 
    628 void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
    629 				 const u8 *dev_addr)
    630 {
    631 	wpas_dbus_unregister_peer(wpa_s, dev_addr);
    632 
    633 	/* Create signal on interface object*/
    634 	wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
    635 
    636 	wpas_hidl_notify_p2p_device_lost(wpa_s, dev_addr);
    637 }
    638 
    639 
    640 void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
    641 				   const struct wpa_ssid *ssid,
    642 				   const char *role)
    643 {
    644 	wpas_dbus_signal_p2p_group_removed(wpa_s, role);
    645 
    646 	wpas_dbus_unregister_p2p_group(wpa_s, ssid);
    647 
    648 	wpas_hidl_notify_p2p_group_removed(wpa_s, ssid, role);
    649 }
    650 
    651 
    652 void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
    653 				const u8 *src, u16 dev_passwd_id, u8 go_intent)
    654 {
    655 	wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
    656 
    657 	wpas_hidl_notify_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
    658 }
    659 
    660 
    661 void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
    662 				      struct p2p_go_neg_results *res)
    663 {
    664 	wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
    665 
    666 	wpas_hidl_notify_p2p_go_neg_completed(wpa_s, res);
    667 }
    668 
    669 
    670 void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
    671 				       int status, const u8 *bssid)
    672 {
    673 	wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
    674 
    675 	wpas_hidl_notify_p2p_invitation_result(wpa_s, status, bssid);
    676 }
    677 
    678 
    679 void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
    680 				int freq, const u8 *sa, u8 dialog_token,
    681 				u16 update_indic, const u8 *tlvs,
    682 				size_t tlvs_len)
    683 {
    684 	wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
    685 					update_indic, tlvs, tlvs_len);
    686 }
    687 
    688 
    689 void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
    690 				 const u8 *sa, u16 update_indic,
    691 				 const u8 *tlvs, size_t tlvs_len)
    692 {
    693 	wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
    694 					 tlvs, tlvs_len);
    695 
    696 	wpas_hidl_notify_p2p_sd_response(wpa_s, sa, update_indic,
    697 					 tlvs, tlvs_len);
    698 }
    699 
    700 
    701 /**
    702  * wpas_notify_p2p_provision_discovery - Notification of provision discovery
    703  * @dev_addr: Who sent the request or responded to our request.
    704  * @request: Will be 1 if request, 0 for response.
    705  * @status: Valid only in case of response (0 in case of success)
    706  * @config_methods: WPS config methods
    707  * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
    708  *
    709  * This can be used to notify:
    710  * - Requests or responses
    711  * - Various config methods
    712  * - Failure condition in case of response
    713  */
    714 void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
    715 					 const u8 *dev_addr, int request,
    716 					 enum p2p_prov_disc_status status,
    717 					 u16 config_methods,
    718 					 unsigned int generated_pin)
    719 {
    720 	wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
    721 						 status, config_methods,
    722 						 generated_pin);
    723 
    724 	wpas_hidl_notify_p2p_provision_discovery(wpa_s, dev_addr, request,
    725 						 status, config_methods,
    726 						 generated_pin);
    727 
    728 }
    729 
    730 
    731 void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
    732 				   struct wpa_ssid *ssid, int persistent,
    733 				   int client, const u8 *ip)
    734 {
    735 	/* Notify a group has been started */
    736 	wpas_dbus_register_p2p_group(wpa_s, ssid);
    737 
    738 	wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
    739 
    740 	wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client);
    741 }
    742 
    743 
    744 void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
    745 					     const char *reason)
    746 {
    747 	/* Notify a group formation failed */
    748 	wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
    749 
    750 	wpas_hidl_notify_p2p_group_formation_failure(wpa_s, reason);
    751 }
    752 
    753 
    754 void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
    755 				struct wps_event_fail *fail)
    756 {
    757 	wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
    758 }
    759 
    760 
    761 void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
    762 					 const u8 *sa, const u8 *go_dev_addr,
    763 					 const u8 *bssid, int id, int op_freq)
    764 {
    765 	/* Notify a P2P Invitation Request */
    766 	wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
    767 						 id, op_freq);
    768 
    769 	wpas_hidl_notify_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
    770 						 id, op_freq);
    771 }
    772 
    773 #endif /* CONFIG_P2P */
    774 
    775 
    776 static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
    777 					  const u8 *sta,
    778 					  const u8 *p2p_dev_addr)
    779 {
    780 #ifdef CONFIG_P2P
    781 	wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
    782 
    783 	/*
    784 	 * Create 'peer-joined' signal on group object -- will also
    785 	 * check P2P itself.
    786 	 */
    787 	if (p2p_dev_addr)
    788 		wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
    789 #endif /* CONFIG_P2P */
    790 
    791 	/* Notify listeners a new station has been authorized */
    792 	wpas_dbus_signal_sta_authorized(wpa_s, sta);
    793 
    794 	wpas_hidl_notify_ap_sta_authorized(wpa_s, sta, p2p_dev_addr);
    795 }
    796 
    797 
    798 static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
    799 					    const u8 *sta,
    800 					    const u8 *p2p_dev_addr)
    801 {
    802 #ifdef CONFIG_P2P
    803 	/*
    804 	 * Create 'peer-disconnected' signal on group object if this
    805 	 * is a P2P group.
    806 	 */
    807 	if (p2p_dev_addr)
    808 		wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
    809 #endif /* CONFIG_P2P */
    810 
    811 	/* Notify listeners a station has been deauthorized */
    812 	wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
    813 
    814 	wpas_hidl_notify_ap_sta_deauthorized(wpa_s, sta, p2p_dev_addr);
    815 }
    816 
    817 
    818 void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
    819 				const u8 *mac_addr, int authorized,
    820 				const u8 *p2p_dev_addr)
    821 {
    822 	if (authorized)
    823 		wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
    824 	else
    825 		wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
    826 }
    827 
    828 
    829 void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
    830 			       const char *subject, const char *altsubject[],
    831 			       int num_altsubject, const char *cert_hash,
    832 			       const struct wpabuf *cert)
    833 {
    834 	wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
    835 		"depth=%d subject='%s'%s%s",
    836 		depth, subject, cert_hash ? " hash=" : "",
    837 		cert_hash ? cert_hash : "");
    838 
    839 	if (cert) {
    840 		char *cert_hex;
    841 		size_t len = wpabuf_len(cert) * 2 + 1;
    842 		cert_hex = os_malloc(len);
    843 		if (cert_hex) {
    844 			wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
    845 					 wpabuf_len(cert));
    846 			wpa_msg_ctrl(wpa_s, MSG_INFO,
    847 				     WPA_EVENT_EAP_PEER_CERT
    848 				     "depth=%d subject='%s' cert=%s",
    849 				     depth, subject, cert_hex);
    850 			os_free(cert_hex);
    851 		}
    852 	}
    853 
    854 	if (altsubject) {
    855 		int i;
    856 
    857 		for (i = 0; i < num_altsubject; i++)
    858 			wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
    859 				"depth=%d %s", depth, altsubject[i]);
    860 	}
    861 
    862 	/* notify the old DBus API */
    863 	wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
    864 						 cert_hash, cert);
    865 	/* notify the new DBus API */
    866 	wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject,
    867 				       num_altsubject, cert_hash, cert);
    868 }
    869 
    870 
    871 void wpas_notify_preq(struct wpa_supplicant *wpa_s,
    872 		      const u8 *addr, const u8 *dst, const u8 *bssid,
    873 		      const u8 *ie, size_t ie_len, u32 ssi_signal)
    874 {
    875 #ifdef CONFIG_AP
    876 	wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
    877 #endif /* CONFIG_AP */
    878 }
    879 
    880 
    881 void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
    882 			    const char *parameter)
    883 {
    884 	wpas_dbus_signal_eap_status(wpa_s, status, parameter);
    885 	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
    886 		     "status='%s' parameter='%s'",
    887 		     status, parameter);
    888 }
    889 
    890 void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
    891 {
    892 	wpa_dbg(wpa_s, MSG_ERROR,
    893 		"EAP Error code = %d", error_code);
    894 	wpas_hidl_notify_eap_error(wpa_s, error_code);
    895 }
    896 
    897 void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
    898 					   struct wpa_ssid *ssid)
    899 {
    900 	if (wpa_s->current_ssid != ssid)
    901 		return;
    902 
    903 	wpa_dbg(wpa_s, MSG_DEBUG,
    904 		"Network bssid config changed for the current network - within-ESS roaming %s",
    905 		ssid->bssid_set ? "disabled" : "enabled");
    906 
    907 	wpa_drv_roaming(wpa_s, !ssid->bssid_set,
    908 			ssid->bssid_set ? ssid->bssid : NULL);
    909 }
    910 
    911 
    912 void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
    913 				      struct wpa_ssid *ssid)
    914 {
    915 #ifdef CONFIG_P2P
    916 	if (ssid->disabled == 2) {
    917 		/* Changed from normal network profile to persistent group */
    918 		ssid->disabled = 0;
    919 		wpas_dbus_unregister_network(wpa_s, ssid->id);
    920 		ssid->disabled = 2;
    921 		ssid->p2p_persistent_group = 1;
    922 		wpas_dbus_register_persistent_group(wpa_s, ssid);
    923 	} else {
    924 		/* Changed from persistent group to normal network profile */
    925 		wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
    926 		ssid->p2p_persistent_group = 0;
    927 		wpas_dbus_register_network(wpa_s, ssid);
    928 	}
    929 #endif /* CONFIG_P2P */
    930 }
    931 
    932 void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
    933 				 const char *result,
    934 				 const struct wpa_bss_anqp *anqp)
    935 {
    936 #ifdef CONFIG_INTERWORKING
    937 	if (!wpa_s || !bssid || !anqp)
    938 		return;
    939 
    940 	wpas_hidl_notify_anqp_query_done(wpa_s, bssid, result, anqp);
    941 #endif /* CONFIG_INTERWORKING */
    942 }
    943 
    944 void wpas_notify_hs20_icon_query_done(struct wpa_supplicant *wpa_s, const u8* bssid,
    945 				      const char* file_name, const u8* image,
    946 				      u32 image_length)
    947 {
    948 #ifdef CONFIG_HS20
    949 	if (!wpa_s || !bssid || !file_name || !image)
    950 		return;
    951 
    952 	wpas_hidl_notify_hs20_icon_query_done(wpa_s, bssid, file_name, image,
    953 					      image_length);
    954 #endif /* CONFIG_HS20 */
    955 }
    956 
    957 void wpas_notify_hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
    958 						  const char* url,
    959 						  u8 osu_method)
    960 {
    961 #ifdef CONFIG_HS20
    962 	if (!wpa_s || !url)
    963 		return;
    964 
    965 	wpas_hidl_notify_hs20_rx_subscription_remediation(wpa_s, url, osu_method);
    966 #endif /* CONFIG_HS20 */
    967 }
    968 
    969 void wpas_notify_hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s,
    970 						u8 code, u16 reauth_delay,
    971 						const char *url)
    972 {
    973 #ifdef CONFIG_HS20
    974 	if (!wpa_s || !url)
    975 		return;
    976 
    977 	wpas_hidl_notify_hs20_rx_deauth_imminent_notice(wpa_s, code, reauth_delay,
    978 							url);
    979 #endif /* CONFIG_HS20 */
    980 }
    981 
    982 
    983 #ifdef CONFIG_MESH
    984 
    985 void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
    986 				    struct wpa_ssid *ssid)
    987 {
    988 	if (wpa_s->p2p_mgmt)
    989 		return;
    990 
    991 	wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
    992 }
    993 
    994 
    995 void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
    996 				    const u8 *meshid, u8 meshid_len,
    997 				    int reason_code)
    998 {
    999 	if (wpa_s->p2p_mgmt)
   1000 		return;
   1001 
   1002 	wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
   1003 					    reason_code);
   1004 }
   1005 
   1006 
   1007 void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
   1008 				     const u8 *peer_addr)
   1009 {
   1010 	if (wpa_s->p2p_mgmt)
   1011 		return;
   1012 
   1013 	wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
   1014 }
   1015 
   1016 
   1017 void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
   1018 					const u8 *peer_addr, int reason_code)
   1019 {
   1020 	if (wpa_s->p2p_mgmt)
   1021 		return;
   1022 
   1023 	wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
   1024 }
   1025 
   1026 #endif /* CONFIG_MESH */
   1027