notify.c revision d6d8b8ddebec155f165137ac6e9b5ef0c003f0c0
1/* 2 * wpa_supplicant - Event notifications 3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9#include "utils/includes.h" 10 11#include "utils/common.h" 12#include "common/wpa_ctrl.h" 13#include "config.h" 14#include "wpa_supplicant_i.h" 15#include "wps_supplicant.h" 16#include "hidl/hidl.h" 17#include "dbus/dbus_common.h" 18#include "dbus/dbus_old.h" 19#include "dbus/dbus_new.h" 20#include "rsn_supp/wpa.h" 21#include "fst/fst.h" 22#include "driver_i.h" 23#include "scan.h" 24#include "p2p_supplicant.h" 25#include "sme.h" 26#include "notify.h" 27 28int 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 48void 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 62int 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 80void 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 95void 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 141void 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 149 150void 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 158 159void wpas_notify_network_changed(struct wpa_supplicant *wpa_s) 160{ 161 if (wpa_s->p2p_mgmt) 162 return; 163 164 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK); 165} 166 167 168void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s) 169{ 170 if (wpa_s->p2p_mgmt) 171 return; 172 173 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN); 174} 175 176 177void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s) 178{ 179 if (wpa_s->p2p_mgmt) 180 return; 181 182 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS); 183} 184 185 186void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s) 187{ 188 if (wpa_s->p2p_mgmt) 189 return; 190 191 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE); 192} 193 194 195void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s, 196 struct wpa_ssid *ssid) 197{ 198 if (wpa_s->p2p_mgmt) 199 return; 200 201 wpas_dbus_signal_network_enabled_changed(wpa_s, ssid); 202} 203 204 205void wpas_notify_network_selected(struct wpa_supplicant *wpa_s, 206 struct wpa_ssid *ssid) 207{ 208 if (wpa_s->p2p_mgmt) 209 return; 210 211 wpas_dbus_signal_network_selected(wpa_s, ssid->id); 212} 213 214 215void wpas_notify_network_request(struct wpa_supplicant *wpa_s, 216 struct wpa_ssid *ssid, 217 enum wpa_ctrl_req_type rtype, 218 const char *default_txt) 219{ 220 if (wpa_s->p2p_mgmt) 221 return; 222 223 wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt); 224 225 wpas_hidl_notify_network_request(wpa_s, ssid, rtype, default_txt); 226} 227 228 229void wpas_notify_scanning(struct wpa_supplicant *wpa_s) 230{ 231 if (wpa_s->p2p_mgmt) 232 return; 233 234 /* notify the old DBus API */ 235 wpa_supplicant_dbus_notify_scanning(wpa_s); 236 237 /* notify the new DBus API */ 238 wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING); 239} 240 241 242void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) 243{ 244 if (wpa_s->p2p_mgmt) 245 return; 246 247 wpas_dbus_signal_scan_done(wpa_s, success); 248} 249 250 251void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) 252{ 253 if (wpa_s->p2p_mgmt) 254 return; 255 256 /* notify the old DBus API */ 257 wpa_supplicant_dbus_notify_scan_results(wpa_s); 258 259 wpas_wps_notify_scan_results(wpa_s); 260} 261 262 263void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, 264 const struct wps_credential *cred) 265{ 266 if (wpa_s->p2p_mgmt) 267 return; 268 269#ifdef CONFIG_WPS 270 /* notify the old DBus API */ 271 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred); 272 /* notify the new DBus API */ 273 wpas_dbus_signal_wps_cred(wpa_s, cred); 274#endif /* CONFIG_WPS */ 275} 276 277 278void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s, 279 struct wps_event_m2d *m2d) 280{ 281 if (wpa_s->p2p_mgmt) 282 return; 283 284#ifdef CONFIG_WPS 285 wpas_dbus_signal_wps_event_m2d(wpa_s, m2d); 286#endif /* CONFIG_WPS */ 287} 288 289 290void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s, 291 struct wps_event_fail *fail) 292{ 293 if (wpa_s->p2p_mgmt) 294 return; 295 296#ifdef CONFIG_WPS 297 wpas_dbus_signal_wps_event_fail(wpa_s, fail); 298#endif /* CONFIG_WPS */ 299} 300 301 302void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s) 303{ 304 if (wpa_s->p2p_mgmt) 305 return; 306 307#ifdef CONFIG_WPS 308 wpas_dbus_signal_wps_event_success(wpa_s); 309#endif /* CONFIG_WPS */ 310} 311 312void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s) 313{ 314 if (wpa_s->p2p_mgmt) 315 return; 316 317#ifdef CONFIG_WPS 318 wpas_dbus_signal_wps_event_pbc_overlap(wpa_s); 319#endif /* CONFIG_WPS */ 320} 321 322 323void wpas_notify_network_added(struct wpa_supplicant *wpa_s, 324 struct wpa_ssid *ssid) 325{ 326 if (wpa_s->p2p_mgmt) 327 return; 328 329 /* 330 * Networks objects created during any P2P activities should not be 331 * exposed out. They might/will confuse certain non-P2P aware 332 * applications since these network objects won't behave like 333 * regular ones. 334 */ 335 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) { 336 wpas_dbus_register_network(wpa_s, ssid); 337 wpas_hidl_register_network(wpa_s, ssid); 338 } 339} 340 341 342void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s, 343 struct wpa_ssid *ssid) 344{ 345#ifdef CONFIG_P2P 346 wpas_dbus_register_persistent_group(wpa_s, ssid); 347#endif /* CONFIG_P2P */ 348} 349 350 351void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s, 352 struct wpa_ssid *ssid) 353{ 354#ifdef CONFIG_P2P 355 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); 356#endif /* CONFIG_P2P */ 357} 358 359 360void wpas_notify_network_removed(struct wpa_supplicant *wpa_s, 361 struct wpa_ssid *ssid) 362{ 363 if (wpa_s->next_ssid == ssid) 364 wpa_s->next_ssid = NULL; 365 if (wpa_s->wpa) 366 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); 367 if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s && 368 !wpa_s->p2p_mgmt) { 369 wpas_dbus_unregister_network(wpa_s, ssid->id); 370 wpas_hidl_unregister_network(wpa_s, ssid); 371 } 372 if (network_is_persistent_group(ssid)) 373 wpas_notify_persistent_group_removed(wpa_s, ssid); 374 375 wpas_p2p_network_removed(wpa_s, ssid); 376} 377 378 379void wpas_notify_bss_added(struct wpa_supplicant *wpa_s, 380 u8 bssid[], unsigned int id) 381{ 382 if (wpa_s->p2p_mgmt) 383 return; 384 385 wpas_dbus_register_bss(wpa_s, bssid, id); 386 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR, 387 id, MAC2STR(bssid)); 388} 389 390 391void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s, 392 u8 bssid[], unsigned int id) 393{ 394 if (wpa_s->p2p_mgmt) 395 return; 396 397 wpas_dbus_unregister_bss(wpa_s, bssid, id); 398 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR, 399 id, MAC2STR(bssid)); 400} 401 402 403void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s, 404 unsigned int id) 405{ 406 if (wpa_s->p2p_mgmt) 407 return; 408 409 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id); 410} 411 412 413void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s, 414 unsigned int id) 415{ 416 if (wpa_s->p2p_mgmt) 417 return; 418 419 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL, 420 id); 421} 422 423 424void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s, 425 unsigned int id) 426{ 427 if (wpa_s->p2p_mgmt) 428 return; 429 430 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY, 431 id); 432} 433 434 435void wpas_notify_bss_mode_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_MODE, id); 442} 443 444 445void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s, 446 unsigned int id) 447{ 448 if (wpa_s->p2p_mgmt) 449 return; 450 451 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id); 452} 453 454 455void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s, 456 unsigned int id) 457{ 458 if (wpa_s->p2p_mgmt) 459 return; 460 461 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id); 462} 463 464 465void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s, 466 unsigned int id) 467{ 468 if (wpa_s->p2p_mgmt) 469 return; 470 471#ifdef CONFIG_WPS 472 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id); 473#endif /* CONFIG_WPS */ 474} 475 476 477void wpas_notify_bss_ies_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_IES, id); 484} 485 486 487void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s, 488 unsigned int id) 489{ 490 if (wpa_s->p2p_mgmt) 491 return; 492 493 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id); 494} 495 496 497void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id) 498{ 499 if (wpa_s->p2p_mgmt) 500 return; 501 502 wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id); 503} 504 505 506void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name) 507{ 508 if (wpa_s->p2p_mgmt) 509 return; 510 511 wpas_dbus_signal_blob_added(wpa_s, name); 512} 513 514 515void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name) 516{ 517 if (wpa_s->p2p_mgmt) 518 return; 519 520 wpas_dbus_signal_blob_removed(wpa_s, name); 521} 522 523 524void wpas_notify_debug_level_changed(struct wpa_global *global) 525{ 526 wpas_dbus_signal_debug_level_changed(global); 527} 528 529 530void wpas_notify_debug_timestamp_changed(struct wpa_global *global) 531{ 532 wpas_dbus_signal_debug_timestamp_changed(global); 533} 534 535 536void wpas_notify_debug_show_keys_changed(struct wpa_global *global) 537{ 538 wpas_dbus_signal_debug_show_keys_changed(global); 539} 540 541 542void wpas_notify_suspend(struct wpa_global *global) 543{ 544 struct wpa_supplicant *wpa_s; 545 546 os_get_time(&global->suspend_time); 547 wpa_printf(MSG_DEBUG, "System suspend notification"); 548 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) 549 wpa_drv_suspend(wpa_s); 550} 551 552 553void wpas_notify_resume(struct wpa_global *global) 554{ 555 struct os_time now; 556 int slept; 557 struct wpa_supplicant *wpa_s; 558 559 if (global->suspend_time.sec == 0) 560 slept = -1; 561 else { 562 os_get_time(&now); 563 slept = now.sec - global->suspend_time.sec; 564 } 565 wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)", 566 slept); 567 568 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { 569 wpa_drv_resume(wpa_s); 570 if (wpa_s->wpa_state == WPA_DISCONNECTED) 571 wpa_supplicant_req_scan(wpa_s, 0, 100000); 572 } 573} 574 575 576#ifdef CONFIG_P2P 577 578void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s) 579{ 580 /* Notify P2P find has stopped */ 581 wpas_dbus_signal_p2p_find_stopped(wpa_s); 582} 583 584 585void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s, 586 const u8 *dev_addr, int new_device) 587{ 588 if (new_device) { 589 /* Create the new peer object */ 590 wpas_dbus_register_peer(wpa_s, dev_addr); 591 } 592 593 /* Notify a new peer has been detected*/ 594 wpas_dbus_signal_peer_device_found(wpa_s, dev_addr); 595} 596 597 598void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s, 599 const u8 *dev_addr) 600{ 601 wpas_dbus_unregister_peer(wpa_s, dev_addr); 602 603 /* Create signal on interface object*/ 604 wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr); 605} 606 607 608void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s, 609 const struct wpa_ssid *ssid, 610 const char *role) 611{ 612 wpas_dbus_signal_p2p_group_removed(wpa_s, role); 613 614 wpas_dbus_unregister_p2p_group(wpa_s, ssid); 615} 616 617 618void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s, 619 const u8 *src, u16 dev_passwd_id, u8 go_intent) 620{ 621 wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent); 622} 623 624 625void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s, 626 struct p2p_go_neg_results *res) 627{ 628 wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res); 629} 630 631 632void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s, 633 int status, const u8 *bssid) 634{ 635 wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid); 636} 637 638 639void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s, 640 int freq, const u8 *sa, u8 dialog_token, 641 u16 update_indic, const u8 *tlvs, 642 size_t tlvs_len) 643{ 644 wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token, 645 update_indic, tlvs, tlvs_len); 646} 647 648 649void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s, 650 const u8 *sa, u16 update_indic, 651 const u8 *tlvs, size_t tlvs_len) 652{ 653 wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic, 654 tlvs, tlvs_len); 655} 656 657 658/** 659 * wpas_notify_p2p_provision_discovery - Notification of provision discovery 660 * @dev_addr: Who sent the request or responded to our request. 661 * @request: Will be 1 if request, 0 for response. 662 * @status: Valid only in case of response (0 in case of success) 663 * @config_methods: WPS config methods 664 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method 665 * 666 * This can be used to notify: 667 * - Requests or responses 668 * - Various config methods 669 * - Failure condition in case of response 670 */ 671void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s, 672 const u8 *dev_addr, int request, 673 enum p2p_prov_disc_status status, 674 u16 config_methods, 675 unsigned int generated_pin) 676{ 677 wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request, 678 status, config_methods, 679 generated_pin); 680} 681 682 683void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s, 684 struct wpa_ssid *ssid, int persistent, 685 int client) 686{ 687 /* Notify a group has been started */ 688 wpas_dbus_register_p2p_group(wpa_s, ssid); 689 690 wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent); 691} 692 693 694void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s, 695 const char *reason) 696{ 697 /* Notify a group formation failed */ 698 wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason); 699} 700 701 702void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s, 703 struct wps_event_fail *fail) 704{ 705 wpas_dbus_signal_p2p_wps_failed(wpa_s, fail); 706} 707 708 709void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s, 710 const u8 *sa, const u8 *go_dev_addr, 711 const u8 *bssid, int id, int op_freq) 712{ 713 /* Notify a P2P Invitation Request */ 714 wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid, 715 id, op_freq); 716} 717 718#endif /* CONFIG_P2P */ 719 720 721static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, 722 const u8 *sta, 723 const u8 *p2p_dev_addr) 724{ 725#ifdef CONFIG_P2P 726 wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr); 727 728 /* 729 * Create 'peer-joined' signal on group object -- will also 730 * check P2P itself. 731 */ 732 if (p2p_dev_addr) 733 wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr); 734#endif /* CONFIG_P2P */ 735 736 /* Notify listeners a new station has been authorized */ 737 wpas_dbus_signal_sta_authorized(wpa_s, sta); 738} 739 740 741static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, 742 const u8 *sta, 743 const u8 *p2p_dev_addr) 744{ 745#ifdef CONFIG_P2P 746 /* 747 * Create 'peer-disconnected' signal on group object if this 748 * is a P2P group. 749 */ 750 if (p2p_dev_addr) 751 wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr); 752#endif /* CONFIG_P2P */ 753 754 /* Notify listeners a station has been deauthorized */ 755 wpas_dbus_signal_sta_deauthorized(wpa_s, sta); 756} 757 758 759void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s, 760 const u8 *mac_addr, int authorized, 761 const u8 *p2p_dev_addr) 762{ 763 if (authorized) 764 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr); 765 else 766 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr); 767} 768 769 770void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth, 771 const char *subject, const char *altsubject[], 772 int num_altsubject, const char *cert_hash, 773 const struct wpabuf *cert) 774{ 775 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT 776 "depth=%d subject='%s'%s%s", 777 depth, subject, cert_hash ? " hash=" : "", 778 cert_hash ? cert_hash : ""); 779 780 if (cert) { 781 char *cert_hex; 782 size_t len = wpabuf_len(cert) * 2 + 1; 783 cert_hex = os_malloc(len); 784 if (cert_hex) { 785 wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert), 786 wpabuf_len(cert)); 787 wpa_msg_ctrl(wpa_s, MSG_INFO, 788 WPA_EVENT_EAP_PEER_CERT 789 "depth=%d subject='%s' cert=%s", 790 depth, subject, cert_hex); 791 os_free(cert_hex); 792 } 793 } 794 795 if (altsubject) { 796 int i; 797 798 for (i = 0; i < num_altsubject; i++) 799 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT 800 "depth=%d %s", depth, altsubject[i]); 801 } 802 803 /* notify the old DBus API */ 804 wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject, 805 cert_hash, cert); 806 /* notify the new DBus API */ 807 wpas_dbus_signal_certification(wpa_s, depth, subject, altsubject, 808 num_altsubject, cert_hash, cert); 809} 810 811 812void wpas_notify_preq(struct wpa_supplicant *wpa_s, 813 const u8 *addr, const u8 *dst, const u8 *bssid, 814 const u8 *ie, size_t ie_len, u32 ssi_signal) 815{ 816#ifdef CONFIG_AP 817 wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal); 818#endif /* CONFIG_AP */ 819} 820 821 822void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status, 823 const char *parameter) 824{ 825 wpas_dbus_signal_eap_status(wpa_s, status, parameter); 826 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS 827 "status='%s' parameter='%s'", 828 status, parameter); 829} 830 831 832void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s, 833 struct wpa_ssid *ssid) 834{ 835 if (wpa_s->current_ssid != ssid) 836 return; 837 838 wpa_dbg(wpa_s, MSG_DEBUG, 839 "Network bssid config changed for the current network - within-ESS roaming %s", 840 ssid->bssid_set ? "disabled" : "enabled"); 841 842 wpa_drv_roaming(wpa_s, !ssid->bssid_set, 843 ssid->bssid_set ? ssid->bssid : NULL); 844} 845 846 847void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s, 848 struct wpa_ssid *ssid) 849{ 850#ifdef CONFIG_P2P 851 if (ssid->disabled == 2) { 852 /* Changed from normal network profile to persistent group */ 853 ssid->disabled = 0; 854 wpas_dbus_unregister_network(wpa_s, ssid->id); 855 ssid->disabled = 2; 856 ssid->p2p_persistent_group = 1; 857 wpas_dbus_register_persistent_group(wpa_s, ssid); 858 } else { 859 /* Changed from persistent group to normal network profile */ 860 wpas_dbus_unregister_persistent_group(wpa_s, ssid->id); 861 ssid->p2p_persistent_group = 0; 862 wpas_dbus_register_network(wpa_s, ssid); 863 } 864#endif /* CONFIG_P2P */ 865} 866