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