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