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