Gabriel Biren | 57ededa | 2021-09-03 16:08:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * WPA Supplicant - Aidl entry point to wpa_supplicant core |
| 3 | * Copyright (c) 2021, Google Inc. All rights reserved. |
| 4 | * |
| 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
| 7 | */ |
| 8 | |
| 9 | #include <android/binder_process.h> |
| 10 | #include <android/binder_manager.h> |
| 11 | |
| 12 | #include "aidl_manager.h" |
| 13 | |
| 14 | extern "C" |
| 15 | { |
| 16 | #include "aidl.h" |
| 17 | #include "aidl_i.h" |
| 18 | #include "utils/common.h" |
| 19 | #include "utils/eloop.h" |
| 20 | #include "utils/includes.h" |
| 21 | #include "dpp.h" |
| 22 | } |
| 23 | |
| 24 | using aidl::android::hardware::wifi::supplicant::AidlManager; |
Gabriel Biren | 3a2ec2c | 2022-03-07 17:59:41 +0000 | [diff] [blame] | 25 | using aidl::android::hardware::wifi::supplicant::AuxiliarySupplicantEventCode; |
Gabriel Biren | 57ededa | 2021-09-03 16:08:50 +0000 | [diff] [blame] | 26 | using aidl::android::hardware::wifi::supplicant::DppEventType; |
| 27 | using aidl::android::hardware::wifi::supplicant::DppFailureCode; |
| 28 | using aidl::android::hardware::wifi::supplicant::DppProgressCode; |
| 29 | |
| 30 | static void wpas_aidl_notify_dpp_failure(struct wpa_supplicant *wpa_s, DppFailureCode code); |
| 31 | static void wpas_aidl_notify_dpp_progress(struct wpa_supplicant *wpa_s, DppProgressCode code); |
| 32 | static void wpas_aidl_notify_dpp_success(struct wpa_supplicant *wpa_s, DppEventType code); |
| 33 | |
| 34 | void wpas_aidl_sock_handler( |
| 35 | int /* sock */, void * /* eloop_ctx */, void * /* sock_ctx */) |
| 36 | { |
| 37 | ABinderProcess_handlePolledCommands(); |
| 38 | } |
| 39 | |
| 40 | struct wpas_aidl_priv *wpas_aidl_init(struct wpa_global *global) |
| 41 | { |
| 42 | struct wpas_aidl_priv *priv; |
| 43 | AidlManager *aidl_manager; |
| 44 | |
| 45 | priv = (wpas_aidl_priv *)os_zalloc(sizeof(*priv)); |
| 46 | if (!priv) |
| 47 | return NULL; |
| 48 | priv->global = global; |
| 49 | |
| 50 | wpa_printf(MSG_DEBUG, "Initing aidl control"); |
| 51 | |
| 52 | ABinderProcess_setupPolling(&priv->aidl_fd); |
| 53 | if (priv->aidl_fd < 0) |
| 54 | goto err; |
| 55 | |
| 56 | wpa_printf(MSG_INFO, "Processing aidl events on FD %d", priv->aidl_fd); |
| 57 | // Look for read events from the aidl socket in the eloop. |
| 58 | if (eloop_register_read_sock( |
| 59 | priv->aidl_fd, wpas_aidl_sock_handler, global, priv) < 0) |
| 60 | goto err; |
| 61 | |
| 62 | aidl_manager = AidlManager::getInstance(); |
| 63 | if (!aidl_manager) |
| 64 | goto err; |
| 65 | if (aidl_manager->registerAidlService(global)) { |
| 66 | goto err; |
| 67 | } |
| 68 | // We may not need to store this aidl manager reference in the |
| 69 | // global data strucure because we've made it a singleton class. |
| 70 | priv->aidl_manager = (void *)aidl_manager; |
| 71 | |
| 72 | return priv; |
| 73 | err: |
| 74 | wpas_aidl_deinit(priv); |
| 75 | return NULL; |
| 76 | } |
| 77 | |
| 78 | void wpas_aidl_deinit(struct wpas_aidl_priv *priv) |
| 79 | { |
| 80 | if (!priv) |
| 81 | return; |
| 82 | |
| 83 | wpa_printf(MSG_DEBUG, "Deiniting aidl control"); |
| 84 | |
| 85 | AidlManager::destroyInstance(); |
| 86 | eloop_unregister_read_sock(priv->aidl_fd); |
| 87 | os_free(priv); |
| 88 | } |
| 89 | |
| 90 | int wpas_aidl_register_interface(struct wpa_supplicant *wpa_s) |
| 91 | { |
| 92 | if (!wpa_s || !wpa_s->global->aidl) |
| 93 | return 1; |
| 94 | |
| 95 | wpa_printf( |
| 96 | MSG_DEBUG, "Registering interface to aidl control: %s", |
| 97 | wpa_s->ifname); |
| 98 | |
| 99 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 100 | if (!aidl_manager) |
| 101 | return 1; |
| 102 | |
| 103 | return aidl_manager->registerInterface(wpa_s); |
| 104 | } |
| 105 | |
| 106 | int wpas_aidl_unregister_interface(struct wpa_supplicant *wpa_s) |
| 107 | { |
| 108 | if (!wpa_s || !wpa_s->global->aidl) |
| 109 | return 1; |
| 110 | |
| 111 | wpa_printf( |
| 112 | MSG_DEBUG, "Deregistering interface from aidl control: %s", |
| 113 | wpa_s->ifname); |
| 114 | |
| 115 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 116 | if (!aidl_manager) |
| 117 | return 1; |
| 118 | |
| 119 | return aidl_manager->unregisterInterface(wpa_s); |
| 120 | } |
| 121 | |
| 122 | int wpas_aidl_register_network( |
| 123 | struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) |
| 124 | { |
| 125 | if (!wpa_s || !wpa_s->global->aidl || !ssid) |
| 126 | return 1; |
| 127 | |
| 128 | wpa_printf( |
| 129 | MSG_DEBUG, "Registering network to aidl control: %d", ssid->id); |
| 130 | |
| 131 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 132 | if (!aidl_manager) |
| 133 | return 1; |
| 134 | |
| 135 | return aidl_manager->registerNetwork(wpa_s, ssid); |
| 136 | } |
| 137 | |
| 138 | int wpas_aidl_unregister_network( |
| 139 | struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) |
| 140 | { |
| 141 | if (!wpa_s || !wpa_s->global->aidl || !ssid) |
| 142 | return 1; |
| 143 | |
| 144 | wpa_printf( |
| 145 | MSG_DEBUG, "Deregistering network from aidl control: %d", ssid->id); |
| 146 | |
| 147 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 148 | if (!aidl_manager) |
| 149 | return 1; |
| 150 | |
| 151 | return aidl_manager->unregisterNetwork(wpa_s, ssid); |
| 152 | } |
| 153 | |
| 154 | int wpas_aidl_notify_state_changed(struct wpa_supplicant *wpa_s) |
| 155 | { |
| 156 | if (!wpa_s || !wpa_s->global->aidl) |
| 157 | return 1; |
| 158 | |
| 159 | wpa_printf( |
| 160 | MSG_DEBUG, "Notifying state change event to aidl control: %d", |
| 161 | wpa_s->wpa_state); |
| 162 | |
| 163 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 164 | if (!aidl_manager) |
| 165 | return 1; |
| 166 | |
| 167 | return aidl_manager->notifyStateChange(wpa_s); |
| 168 | } |
| 169 | |
| 170 | int wpas_aidl_notify_network_request( |
| 171 | struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, |
| 172 | enum wpa_ctrl_req_type rtype, const char *default_txt) |
| 173 | { |
| 174 | if (!wpa_s || !wpa_s->global->aidl || !ssid) |
| 175 | return 1; |
| 176 | |
| 177 | wpa_printf( |
| 178 | MSG_DEBUG, "Notifying network request to aidl control: %d", |
| 179 | ssid->id); |
| 180 | |
| 181 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 182 | if (!aidl_manager) |
| 183 | return 1; |
| 184 | |
| 185 | return aidl_manager->notifyNetworkRequest( |
| 186 | wpa_s, ssid, rtype, default_txt); |
| 187 | } |
| 188 | |
| 189 | void wpas_aidl_notify_anqp_query_done( |
| 190 | struct wpa_supplicant *wpa_s, const u8 *bssid, const char *result, |
| 191 | const struct wpa_bss_anqp *anqp) |
| 192 | { |
| 193 | if (!wpa_s || !wpa_s->global->aidl || !bssid || !result || !anqp) |
| 194 | return; |
| 195 | |
| 196 | wpa_printf( |
| 197 | MSG_DEBUG, |
| 198 | "Notifying ANQP query done to aidl control: " MACSTR "result: %s", |
| 199 | MAC2STR(bssid), result); |
| 200 | |
| 201 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 202 | if (!aidl_manager) |
| 203 | return; |
| 204 | |
| 205 | aidl_manager->notifyAnqpQueryDone(wpa_s, bssid, result, anqp); |
| 206 | } |
| 207 | |
| 208 | void wpas_aidl_notify_hs20_icon_query_done( |
| 209 | struct wpa_supplicant *wpa_s, const u8 *bssid, const char *file_name, |
| 210 | const u8 *image, u32 image_length) |
| 211 | { |
| 212 | if (!wpa_s || !wpa_s->global->aidl || !bssid || !file_name || !image) |
| 213 | return; |
| 214 | |
| 215 | wpa_printf( |
| 216 | MSG_DEBUG, |
| 217 | "Notifying HS20 icon query done to aidl control: " MACSTR |
| 218 | "file_name: %s", |
| 219 | MAC2STR(bssid), file_name); |
| 220 | |
| 221 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 222 | if (!aidl_manager) |
| 223 | return; |
| 224 | |
| 225 | aidl_manager->notifyHs20IconQueryDone( |
| 226 | wpa_s, bssid, file_name, image, image_length); |
| 227 | } |
| 228 | |
| 229 | void wpas_aidl_notify_hs20_rx_subscription_remediation( |
| 230 | struct wpa_supplicant *wpa_s, const char *url, u8 osu_method) |
| 231 | { |
| 232 | if (!wpa_s || !wpa_s->global->aidl || !url) |
| 233 | return; |
| 234 | |
| 235 | wpa_printf( |
| 236 | MSG_DEBUG, |
| 237 | "Notifying HS20 subscription remediation rx to aidl control: %s", |
| 238 | url); |
| 239 | |
| 240 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 241 | if (!aidl_manager) |
| 242 | return; |
| 243 | |
| 244 | aidl_manager->notifyHs20RxSubscriptionRemediation( |
| 245 | wpa_s, url, osu_method); |
| 246 | } |
| 247 | |
| 248 | void wpas_aidl_notify_hs20_rx_deauth_imminent_notice( |
| 249 | struct wpa_supplicant *wpa_s, u8 code, u16 reauth_delay, const char *url) |
| 250 | { |
| 251 | if (!wpa_s || !wpa_s->global->aidl) |
| 252 | return; |
| 253 | |
| 254 | wpa_printf( |
| 255 | MSG_DEBUG, |
| 256 | "Notifying HS20 deauth imminent notice rx to aidl control: %s", |
| 257 | url ? url : "<no URL>"); |
| 258 | |
| 259 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 260 | if (!aidl_manager) |
| 261 | return; |
| 262 | |
| 263 | aidl_manager->notifyHs20RxDeauthImminentNotice( |
| 264 | wpa_s, code, reauth_delay, url); |
| 265 | } |
| 266 | |
| 267 | void wpas_aidl_notify_hs20_rx_terms_and_conditions_acceptance( |
| 268 | struct wpa_supplicant *wpa_s, const char *url) |
| 269 | { |
| 270 | if (!wpa_s || !wpa_s->global->aidl || !url) |
| 271 | return; |
| 272 | |
| 273 | wpa_printf(MSG_DEBUG, |
| 274 | "Notifying HS20 terms and conditions acceptance rx to aidl control: %s", |
| 275 | url); |
| 276 | |
| 277 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 278 | if (!aidl_manager) |
| 279 | return; |
| 280 | |
| 281 | aidl_manager->notifyHs20RxTermsAndConditionsAcceptance(wpa_s, url); |
| 282 | } |
| 283 | |
| 284 | void wpas_aidl_notify_disconnect_reason(struct wpa_supplicant *wpa_s) |
| 285 | { |
| 286 | if (!wpa_s) |
| 287 | return; |
| 288 | |
| 289 | wpa_printf( |
| 290 | MSG_DEBUG, "Notifying disconnect reason to aidl control: %d", |
| 291 | wpa_s->disconnect_reason); |
| 292 | |
| 293 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 294 | if (!aidl_manager) |
| 295 | return; |
| 296 | |
| 297 | aidl_manager->notifyDisconnectReason(wpa_s); |
| 298 | } |
| 299 | |
| 300 | void wpas_aidl_notify_assoc_reject(struct wpa_supplicant *wpa_s, |
| 301 | const u8 *bssid, u8 timed_out, const u8 *assoc_resp_ie, size_t assoc_resp_ie_len) |
| 302 | { |
| 303 | if (!wpa_s) |
| 304 | return; |
| 305 | |
| 306 | wpa_printf( |
| 307 | MSG_DEBUG, "Notifying assoc reject to aidl control: %d", |
| 308 | wpa_s->assoc_status_code); |
| 309 | |
| 310 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 311 | if (!aidl_manager) |
| 312 | return; |
| 313 | |
| 314 | aidl_manager->notifyAssocReject(wpa_s, bssid, timed_out, assoc_resp_ie, assoc_resp_ie_len); |
| 315 | } |
| 316 | |
| 317 | void wpas_aidl_notify_auth_timeout(struct wpa_supplicant *wpa_s) |
| 318 | { |
| 319 | if (!wpa_s) |
| 320 | return; |
| 321 | |
| 322 | wpa_printf(MSG_DEBUG, "Notifying auth timeout to aidl control"); |
| 323 | |
| 324 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 325 | if (!aidl_manager) |
| 326 | return; |
| 327 | |
| 328 | aidl_manager->notifyAuthTimeout(wpa_s); |
| 329 | } |
| 330 | |
| 331 | void wpas_aidl_notify_bssid_changed(struct wpa_supplicant *wpa_s) |
| 332 | { |
| 333 | if (!wpa_s) |
| 334 | return; |
| 335 | |
| 336 | wpa_printf(MSG_DEBUG, "Notifying bssid changed to aidl control"); |
| 337 | |
| 338 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 339 | if (!aidl_manager) |
| 340 | return; |
| 341 | |
| 342 | aidl_manager->notifyBssidChanged(wpa_s); |
| 343 | } |
| 344 | |
| 345 | void wpas_aidl_notify_wps_event_fail( |
| 346 | struct wpa_supplicant *wpa_s, uint8_t *peer_macaddr, uint16_t config_error, |
| 347 | uint16_t error_indication) |
| 348 | { |
| 349 | if (!wpa_s || !peer_macaddr) |
| 350 | return; |
| 351 | |
| 352 | wpa_printf( |
| 353 | MSG_DEBUG, "Notifying Wps event fail to aidl control: %d, %d", |
| 354 | config_error, error_indication); |
| 355 | |
| 356 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 357 | if (!aidl_manager) |
| 358 | return; |
| 359 | |
| 360 | aidl_manager->notifyWpsEventFail( |
| 361 | wpa_s, peer_macaddr, config_error, error_indication); |
| 362 | } |
| 363 | |
| 364 | void wpas_aidl_notify_wps_event_success(struct wpa_supplicant *wpa_s) |
| 365 | { |
| 366 | if (!wpa_s) |
| 367 | return; |
| 368 | |
| 369 | wpa_printf(MSG_DEBUG, "Notifying Wps event success to aidl control"); |
| 370 | |
| 371 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 372 | if (!aidl_manager) |
| 373 | return; |
| 374 | |
| 375 | aidl_manager->notifyWpsEventSuccess(wpa_s); |
| 376 | } |
| 377 | |
| 378 | void wpas_aidl_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s) |
| 379 | { |
| 380 | if (!wpa_s) |
| 381 | return; |
| 382 | |
| 383 | wpa_printf( |
| 384 | MSG_DEBUG, "Notifying Wps event PBC overlap to aidl control"); |
| 385 | |
| 386 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 387 | if (!aidl_manager) |
| 388 | return; |
| 389 | |
| 390 | aidl_manager->notifyWpsEventPbcOverlap(wpa_s); |
| 391 | } |
| 392 | |
| 393 | void wpas_aidl_notify_p2p_device_found( |
| 394 | struct wpa_supplicant *wpa_s, const u8 *addr, |
| 395 | const struct p2p_peer_info *info, const u8 *peer_wfd_device_info, |
| 396 | u8 peer_wfd_device_info_len, const u8 *peer_wfd_r2_device_info, |
| 397 | u8 peer_wfd_r2_device_info_len) |
| 398 | { |
| 399 | if (!wpa_s || !addr || !info) |
| 400 | return; |
| 401 | |
| 402 | wpa_printf( |
| 403 | MSG_DEBUG, "Notifying P2P device found to aidl control " MACSTR, |
| 404 | MAC2STR(info->p2p_device_addr)); |
| 405 | |
| 406 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 407 | if (!aidl_manager) |
| 408 | return; |
| 409 | |
| 410 | aidl_manager->notifyP2pDeviceFound( |
| 411 | wpa_s, addr, info, peer_wfd_device_info, |
| 412 | peer_wfd_device_info_len, peer_wfd_r2_device_info, |
| 413 | peer_wfd_r2_device_info_len); |
| 414 | } |
| 415 | |
| 416 | void wpas_aidl_notify_p2p_device_lost( |
| 417 | struct wpa_supplicant *wpa_s, const u8 *p2p_device_addr) |
| 418 | { |
| 419 | if (!wpa_s || !p2p_device_addr) |
| 420 | return; |
| 421 | |
| 422 | wpa_printf( |
| 423 | MSG_DEBUG, "Notifying P2P device lost to aidl control " MACSTR, |
| 424 | MAC2STR(p2p_device_addr)); |
| 425 | |
| 426 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 427 | if (!aidl_manager) |
| 428 | return; |
| 429 | |
| 430 | aidl_manager->notifyP2pDeviceLost(wpa_s, p2p_device_addr); |
| 431 | } |
| 432 | |
| 433 | void wpas_aidl_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s) |
| 434 | { |
| 435 | if (!wpa_s) |
| 436 | return; |
| 437 | |
| 438 | wpa_printf(MSG_DEBUG, "Notifying P2P find stop to aidl control"); |
| 439 | |
| 440 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 441 | if (!aidl_manager) |
| 442 | return; |
| 443 | |
| 444 | aidl_manager->notifyP2pFindStopped(wpa_s); |
| 445 | } |
| 446 | |
| 447 | void wpas_aidl_notify_p2p_go_neg_req( |
| 448 | struct wpa_supplicant *wpa_s, const u8 *src_addr, u16 dev_passwd_id, |
| 449 | u8 go_intent) |
| 450 | { |
| 451 | if (!wpa_s || !src_addr) |
| 452 | return; |
| 453 | |
| 454 | wpa_printf( |
| 455 | MSG_DEBUG, |
| 456 | "Notifying P2P GO negotiation request to aidl control " MACSTR, |
| 457 | MAC2STR(src_addr)); |
| 458 | |
| 459 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 460 | if (!aidl_manager) |
| 461 | return; |
| 462 | |
| 463 | aidl_manager->notifyP2pGoNegReq( |
| 464 | wpa_s, src_addr, dev_passwd_id, go_intent); |
| 465 | } |
| 466 | |
| 467 | void wpas_aidl_notify_p2p_go_neg_completed( |
| 468 | struct wpa_supplicant *wpa_s, const struct p2p_go_neg_results *res) |
| 469 | { |
| 470 | if (!wpa_s || !res) |
| 471 | return; |
| 472 | |
| 473 | wpa_printf( |
| 474 | MSG_DEBUG, |
| 475 | "Notifying P2P GO negotiation completed to aidl control: %d", |
| 476 | res->status); |
| 477 | |
| 478 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 479 | if (!aidl_manager) |
| 480 | return; |
| 481 | |
| 482 | aidl_manager->notifyP2pGoNegCompleted(wpa_s, res); |
| 483 | } |
| 484 | |
| 485 | void wpas_aidl_notify_p2p_group_formation_failure( |
| 486 | struct wpa_supplicant *wpa_s, const char *reason) |
| 487 | { |
| 488 | if (!wpa_s || !reason) |
| 489 | return; |
| 490 | |
| 491 | wpa_printf( |
| 492 | MSG_DEBUG, |
| 493 | "Notifying P2P Group formation failure to aidl control: %s", |
| 494 | reason); |
| 495 | |
| 496 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 497 | if (!aidl_manager) |
| 498 | return; |
| 499 | |
| 500 | aidl_manager->notifyP2pGroupFormationFailure(wpa_s, reason); |
| 501 | } |
| 502 | |
| 503 | void wpas_aidl_notify_p2p_group_started( |
| 504 | struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int persistent, |
| 505 | int client) |
| 506 | { |
| 507 | if (!wpa_s || !ssid) |
| 508 | return; |
| 509 | |
| 510 | wpa_printf( |
| 511 | MSG_DEBUG, "Notifying P2P Group start to aidl control: %d", |
| 512 | ssid->id); |
| 513 | |
| 514 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 515 | if (!aidl_manager) |
| 516 | return; |
| 517 | |
| 518 | aidl_manager->notifyP2pGroupStarted(wpa_s, ssid, persistent, client); |
| 519 | } |
| 520 | |
| 521 | void wpas_aidl_notify_p2p_group_removed( |
| 522 | struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, const char *role) |
| 523 | { |
| 524 | if (!wpa_s || !ssid || !role) |
| 525 | return; |
| 526 | |
| 527 | wpa_printf( |
| 528 | MSG_DEBUG, "Notifying P2P Group removed to aidl control: %d", |
| 529 | ssid->id); |
| 530 | |
| 531 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 532 | if (!aidl_manager) |
| 533 | return; |
| 534 | |
| 535 | aidl_manager->notifyP2pGroupRemoved(wpa_s, ssid, role); |
| 536 | } |
| 537 | |
| 538 | void wpas_aidl_notify_p2p_invitation_received( |
| 539 | struct wpa_supplicant *wpa_s, const u8 *sa, const u8 *go_dev_addr, |
| 540 | const u8 *bssid, int id, int op_freq) |
| 541 | { |
| 542 | if (!wpa_s || !sa || !go_dev_addr || !bssid) |
| 543 | return; |
| 544 | |
| 545 | wpa_printf( |
| 546 | MSG_DEBUG, |
| 547 | "Notifying P2P invitation received to aidl control: %d " MACSTR, id, |
| 548 | MAC2STR(bssid)); |
| 549 | |
| 550 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 551 | if (!aidl_manager) |
| 552 | return; |
| 553 | |
| 554 | aidl_manager->notifyP2pInvitationReceived( |
| 555 | wpa_s, sa, go_dev_addr, bssid, id, op_freq); |
| 556 | } |
| 557 | |
| 558 | void wpas_aidl_notify_p2p_invitation_result( |
| 559 | struct wpa_supplicant *wpa_s, int status, const u8 *bssid) |
| 560 | { |
| 561 | if (!wpa_s) |
| 562 | return; |
| 563 | if (bssid) { |
| 564 | wpa_printf( |
| 565 | MSG_DEBUG, |
| 566 | "Notifying P2P invitation result to aidl control: " MACSTR, |
| 567 | MAC2STR(bssid)); |
| 568 | } else { |
| 569 | wpa_printf( |
| 570 | MSG_DEBUG, |
| 571 | "Notifying P2P invitation result to aidl control: NULL " |
| 572 | "bssid"); |
| 573 | } |
| 574 | |
| 575 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 576 | if (!aidl_manager) |
| 577 | return; |
| 578 | |
| 579 | aidl_manager->notifyP2pInvitationResult(wpa_s, status, bssid); |
| 580 | } |
| 581 | |
| 582 | void wpas_aidl_notify_p2p_provision_discovery( |
| 583 | struct wpa_supplicant *wpa_s, const u8 *dev_addr, int request, |
| 584 | enum p2p_prov_disc_status status, u16 config_methods, |
| 585 | unsigned int generated_pin) |
| 586 | { |
| 587 | if (!wpa_s || !dev_addr) |
| 588 | return; |
| 589 | |
| 590 | wpa_printf( |
| 591 | MSG_DEBUG, |
| 592 | "Notifying P2P provision discovery to aidl control " MACSTR, |
| 593 | MAC2STR(dev_addr)); |
| 594 | |
| 595 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 596 | if (!aidl_manager) |
| 597 | return; |
| 598 | |
| 599 | aidl_manager->notifyP2pProvisionDiscovery( |
| 600 | wpa_s, dev_addr, request, status, config_methods, generated_pin); |
| 601 | } |
| 602 | |
| 603 | void wpas_aidl_notify_p2p_sd_response( |
| 604 | struct wpa_supplicant *wpa_s, const u8 *sa, u16 update_indic, |
| 605 | const u8 *tlvs, size_t tlvs_len) |
| 606 | { |
| 607 | if (!wpa_s || !sa || !tlvs) |
| 608 | return; |
| 609 | |
| 610 | wpa_printf( |
| 611 | MSG_DEBUG, |
| 612 | "Notifying P2P service discovery response to aidl control " MACSTR, |
| 613 | MAC2STR(sa)); |
| 614 | |
| 615 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 616 | if (!aidl_manager) |
| 617 | return; |
| 618 | |
| 619 | aidl_manager->notifyP2pSdResponse( |
| 620 | wpa_s, sa, update_indic, tlvs, tlvs_len); |
| 621 | } |
| 622 | |
| 623 | void wpas_aidl_notify_ap_sta_authorized( |
| 624 | struct wpa_supplicant *wpa_s, const u8 *sta, const u8 *p2p_dev_addr) |
| 625 | { |
| 626 | if (!wpa_s || !sta) |
| 627 | return; |
| 628 | |
| 629 | wpa_printf( |
| 630 | MSG_DEBUG, |
| 631 | "Notifying P2P AP STA authorized to aidl control " MACSTR, |
| 632 | MAC2STR(sta)); |
| 633 | |
| 634 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 635 | if (!aidl_manager) |
| 636 | return; |
| 637 | |
| 638 | aidl_manager->notifyApStaAuthorized(wpa_s, sta, p2p_dev_addr); |
| 639 | } |
| 640 | |
| 641 | void wpas_aidl_notify_ap_sta_deauthorized( |
| 642 | struct wpa_supplicant *wpa_s, const u8 *sta, const u8 *p2p_dev_addr) |
| 643 | { |
| 644 | if (!wpa_s || !sta) |
| 645 | return; |
| 646 | |
| 647 | wpa_printf( |
| 648 | MSG_DEBUG, |
| 649 | "Notifying P2P AP STA deauthorized to aidl control " MACSTR, |
| 650 | MAC2STR(sta)); |
| 651 | |
| 652 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 653 | if (!aidl_manager) |
| 654 | return; |
| 655 | |
| 656 | aidl_manager->notifyApStaDeauthorized(wpa_s, sta, p2p_dev_addr); |
| 657 | } |
| 658 | |
| 659 | void wpas_aidl_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code) |
| 660 | { |
| 661 | if (!wpa_s) |
| 662 | return; |
| 663 | |
| 664 | wpa_printf(MSG_DEBUG, "Notifying EAP Error: %d ", error_code); |
| 665 | |
| 666 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 667 | if (!aidl_manager) |
| 668 | return; |
| 669 | |
| 670 | aidl_manager->notifyEapError(wpa_s, error_code); |
| 671 | } |
| 672 | |
| 673 | void wpas_aidl_notify_dpp_config_received(struct wpa_supplicant *wpa_s, |
| 674 | struct wpa_ssid *ssid) |
| 675 | { |
| 676 | if (!wpa_s || !ssid) |
| 677 | return; |
| 678 | |
| 679 | wpa_printf( |
| 680 | MSG_DEBUG, |
| 681 | "Notifying DPP configuration received for SSID %d", ssid->id); |
| 682 | |
| 683 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 684 | if (!aidl_manager) |
| 685 | return; |
| 686 | |
| 687 | aidl_manager->notifyDppConfigReceived(wpa_s, ssid); |
| 688 | } |
| 689 | |
| 690 | void wpas_aidl_notify_dpp_config_sent(struct wpa_supplicant *wpa_s) |
| 691 | { |
| 692 | wpas_aidl_notify_dpp_success(wpa_s, DppEventType::CONFIGURATION_SENT); |
| 693 | } |
| 694 | |
| 695 | /* DPP Progress notifications */ |
| 696 | void wpas_aidl_notify_dpp_auth_success(struct wpa_supplicant *wpa_s) |
| 697 | { |
| 698 | wpas_aidl_notify_dpp_progress(wpa_s, DppProgressCode::AUTHENTICATION_SUCCESS); |
| 699 | } |
| 700 | |
| 701 | void wpas_aidl_notify_dpp_resp_pending(struct wpa_supplicant *wpa_s) |
| 702 | { |
| 703 | wpas_aidl_notify_dpp_progress(wpa_s, DppProgressCode::RESPONSE_PENDING); |
| 704 | } |
| 705 | |
| 706 | /* DPP Failure notifications */ |
| 707 | void wpas_aidl_notify_dpp_not_compatible(struct wpa_supplicant *wpa_s) |
| 708 | { |
| 709 | wpas_aidl_notify_dpp_failure(wpa_s, DppFailureCode::NOT_COMPATIBLE); |
| 710 | } |
| 711 | |
| 712 | void wpas_aidl_notify_dpp_missing_auth(struct wpa_supplicant *wpa_s) |
| 713 | { |
| 714 | wpas_aidl_notify_dpp_failure(wpa_s, DppFailureCode::AUTHENTICATION); |
| 715 | } |
| 716 | |
| 717 | void wpas_aidl_notify_dpp_configuration_failure(struct wpa_supplicant *wpa_s) |
| 718 | { |
| 719 | wpas_aidl_notify_dpp_failure(wpa_s, DppFailureCode::CONFIGURATION); |
| 720 | } |
| 721 | |
| 722 | void wpas_aidl_notify_dpp_timeout(struct wpa_supplicant *wpa_s) |
| 723 | { |
| 724 | wpas_aidl_notify_dpp_failure(wpa_s, DppFailureCode::TIMEOUT); |
| 725 | } |
| 726 | |
| 727 | void wpas_aidl_notify_dpp_auth_failure(struct wpa_supplicant *wpa_s) |
| 728 | { |
| 729 | wpas_aidl_notify_dpp_failure(wpa_s, DppFailureCode::AUTHENTICATION); |
| 730 | } |
| 731 | |
| 732 | void wpas_aidl_notify_dpp_fail(struct wpa_supplicant *wpa_s) |
| 733 | { |
| 734 | wpas_aidl_notify_dpp_failure(wpa_s, DppFailureCode::FAILURE); |
| 735 | } |
| 736 | |
| 737 | void wpas_aidl_notify_dpp_config_sent_wait_response(struct wpa_supplicant *wpa_s) |
| 738 | { |
| 739 | wpas_aidl_notify_dpp_progress(wpa_s, DppProgressCode::CONFIGURATION_SENT_WAITING_RESPONSE); |
| 740 | } |
| 741 | |
| 742 | /* DPP notification helper functions */ |
| 743 | static void wpas_aidl_notify_dpp_failure(struct wpa_supplicant *wpa_s, DppFailureCode code) |
| 744 | { |
| 745 | if (!wpa_s) |
| 746 | return; |
| 747 | |
| 748 | wpa_printf( |
| 749 | MSG_DEBUG, |
| 750 | "Notifying DPP failure event %d", code); |
| 751 | |
| 752 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 753 | if (!aidl_manager) |
| 754 | return; |
| 755 | |
| 756 | aidl_manager->notifyDppFailure(wpa_s, code); |
| 757 | } |
| 758 | |
| 759 | static void wpas_aidl_notify_dpp_progress(struct wpa_supplicant *wpa_s, DppProgressCode code) |
| 760 | { |
| 761 | if (!wpa_s) |
| 762 | return; |
| 763 | |
| 764 | wpa_printf( |
| 765 | MSG_DEBUG, |
| 766 | "Notifying DPP progress event %d", code); |
| 767 | |
| 768 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 769 | if (!aidl_manager) |
| 770 | return; |
| 771 | |
| 772 | aidl_manager->notifyDppProgress(wpa_s, code); |
| 773 | } |
| 774 | |
| 775 | void wpas_aidl_notify_dpp_config_accepted(struct wpa_supplicant *wpa_s) |
| 776 | { |
| 777 | wpas_aidl_notify_dpp_progress(wpa_s, DppProgressCode::CONFIGURATION_ACCEPTED); |
| 778 | } |
| 779 | |
| 780 | static void wpas_aidl_notify_dpp_config_applied(struct wpa_supplicant *wpa_s) |
| 781 | { |
| 782 | wpas_aidl_notify_dpp_success(wpa_s, DppEventType::CONFIGURATION_APPLIED); |
| 783 | } |
| 784 | |
| 785 | static void wpas_aidl_notify_dpp_success(struct wpa_supplicant *wpa_s, DppEventType code) |
| 786 | { |
| 787 | if (!wpa_s) |
| 788 | return; |
| 789 | |
| 790 | wpa_printf( |
| 791 | MSG_DEBUG, |
| 792 | "Notifying DPP progress event %d", code); |
| 793 | |
| 794 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 795 | if (!aidl_manager) |
| 796 | return; |
| 797 | |
| 798 | aidl_manager->notifyDppSuccess(wpa_s, code); |
| 799 | } |
| 800 | |
| 801 | void wpas_aidl_notify_dpp_config_rejected(struct wpa_supplicant *wpa_s) |
| 802 | { |
| 803 | wpas_aidl_notify_dpp_failure(wpa_s, DppFailureCode::CONFIGURATION_REJECTED); |
| 804 | } |
| 805 | |
| 806 | static void wpas_aidl_notify_dpp_no_ap_failure(struct wpa_supplicant *wpa_s, |
| 807 | const char *ssid, const char *channel_list, unsigned short band_list[], |
| 808 | int size) |
| 809 | { |
| 810 | if (!wpa_s) |
| 811 | return; |
| 812 | |
| 813 | wpa_printf(MSG_DEBUG, |
| 814 | "Notifying DPP NO AP event for SSID %s\nTried channels: %s", |
| 815 | ssid ? ssid : "N/A", channel_list ? channel_list : "N/A"); |
| 816 | |
| 817 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 818 | if (!aidl_manager) |
| 819 | return; |
| 820 | |
| 821 | aidl_manager->notifyDppFailure(wpa_s, DppFailureCode::CANNOT_FIND_NETWORK, |
| 822 | ssid, channel_list, band_list, size); |
| 823 | } |
| 824 | |
| 825 | void wpas_aidl_notify_dpp_enrollee_auth_failure(struct wpa_supplicant *wpa_s, |
| 826 | const char *ssid, unsigned short band_list[], int size) |
| 827 | { |
| 828 | if (!wpa_s) |
| 829 | return; |
| 830 | |
| 831 | wpa_printf(MSG_DEBUG, |
| 832 | "Notifying DPP Enrollee authentication failure, SSID %s", |
| 833 | ssid ? ssid : "N/A"); |
| 834 | |
| 835 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 836 | if (!aidl_manager) |
| 837 | return; |
| 838 | |
| 839 | aidl_manager->notifyDppFailure(wpa_s, DppFailureCode::ENROLLEE_AUTHENTICATION, |
| 840 | ssid, NULL, band_list, size); |
| 841 | } |
| 842 | |
| 843 | |
| 844 | void wpas_aidl_notify_dpp_conn_status(struct wpa_supplicant *wpa_s, enum dpp_status_error status, |
| 845 | const char *ssid, const char *channel_list, unsigned short band_list[], int size) |
| 846 | { |
| 847 | switch (status) |
| 848 | { |
| 849 | case DPP_STATUS_OK: |
| 850 | wpas_aidl_notify_dpp_config_applied(wpa_s); |
| 851 | break; |
| 852 | |
| 853 | case DPP_STATUS_NO_AP: |
| 854 | wpas_aidl_notify_dpp_no_ap_failure(wpa_s, ssid, channel_list, band_list, size); |
| 855 | break; |
| 856 | |
| 857 | case DPP_STATUS_AUTH_FAILURE: |
| 858 | wpas_aidl_notify_dpp_enrollee_auth_failure(wpa_s, ssid, band_list, size); |
| 859 | break; |
| 860 | |
| 861 | default: |
| 862 | break; |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | void wpas_aidl_notify_pmk_cache_added( |
| 867 | struct wpa_supplicant *wpa_s, |
| 868 | struct rsn_pmksa_cache_entry *pmksa_entry) |
| 869 | { |
| 870 | if (!wpa_s || !pmksa_entry) |
| 871 | return; |
| 872 | |
| 873 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 874 | if (!aidl_manager) |
| 875 | return; |
| 876 | |
| 877 | wpa_printf( |
| 878 | MSG_DEBUG, |
| 879 | "Notifying PMK cache added event"); |
| 880 | |
| 881 | aidl_manager->notifyPmkCacheAdded(wpa_s, pmksa_entry); |
| 882 | } |
| 883 | |
| 884 | void wpas_aidl_notify_bss_tm_status(struct wpa_supplicant *wpa_s) |
| 885 | { |
| 886 | if (!wpa_s) |
| 887 | return; |
| 888 | |
| 889 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 890 | if (!aidl_manager) |
| 891 | return; |
| 892 | |
| 893 | wpa_printf(MSG_DEBUG, "Notifying BSS transition status"); |
| 894 | |
| 895 | aidl_manager->notifyBssTmStatus(wpa_s); |
| 896 | } |
| 897 | |
| 898 | void wpas_aidl_notify_transition_disable(struct wpa_supplicant *wpa_s, |
| 899 | struct wpa_ssid *ssid, |
| 900 | u8 bitmap) |
| 901 | { |
| 902 | if (!wpa_s || !ssid) |
| 903 | return; |
| 904 | |
| 905 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 906 | if (!aidl_manager) |
| 907 | return; |
| 908 | |
| 909 | aidl_manager->notifyTransitionDisable(wpa_s, ssid, bitmap); |
| 910 | } |
| 911 | |
| 912 | void wpas_aidl_notify_network_not_found(struct wpa_supplicant *wpa_s) |
| 913 | { |
| 914 | if (!wpa_s) |
| 915 | return; |
| 916 | |
| 917 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 918 | if (!aidl_manager) |
| 919 | return; |
| 920 | |
| 921 | wpa_printf(MSG_DEBUG, "Notify network not found"); |
| 922 | |
| 923 | aidl_manager->notifyNetworkNotFound(wpa_s); |
| 924 | } |
Sunil Ravi | 23087aa | 2021-12-08 19:01:44 -0800 | [diff] [blame] | 925 | |
| 926 | void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s) |
| 927 | { |
| 928 | if (!wpa_s) |
| 929 | return; |
| 930 | |
| 931 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 932 | if (!aidl_manager) |
| 933 | return; |
| 934 | |
| 935 | wpa_printf(MSG_DEBUG, "Notify %s frequency changed to %d", |
| 936 | wpa_s->ifname, wpa_s->assoc_freq); |
| 937 | |
| 938 | aidl_manager->notifyBssFreqChanged(wpa_s); |
| 939 | } |
Jimmy Chen | 429daf9 | 2021-10-20 13:27:23 +0800 | [diff] [blame] | 940 | |
| 941 | void wpas_aidl_notify_ceritification(struct wpa_supplicant *wpa_s, |
| 942 | int depth, const char *subject, |
| 943 | const char *altsubject[], |
| 944 | int num_altsubject, |
| 945 | const char *cert_hash, |
| 946 | const struct wpabuf *cert) |
| 947 | { |
| 948 | if (!wpa_s) |
| 949 | return; |
| 950 | |
| 951 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 952 | if (!aidl_manager) |
| 953 | return; |
| 954 | |
| 955 | wpa_printf(MSG_DEBUG, "Notify certification"); |
| 956 | |
| 957 | aidl_manager->notifyCertification(wpa_s, |
| 958 | depth, |
| 959 | subject, |
| 960 | altsubject, |
| 961 | num_altsubject, |
| 962 | cert_hash, |
| 963 | cert); |
| 964 | } |
Gabriel Biren | 3a2ec2c | 2022-03-07 17:59:41 +0000 | [diff] [blame] | 965 | |
| 966 | void wpas_aidl_notify_auxiliary_event(struct wpa_supplicant *wpa_s, |
| 967 | AuxiliarySupplicantEventCode event_code, const char *reason_string) |
| 968 | { |
| 969 | if (!wpa_s) |
| 970 | return; |
| 971 | |
| 972 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 973 | if (!aidl_manager) |
| 974 | return; |
| 975 | |
| 976 | wpa_printf(MSG_DEBUG, "Notify auxiliary event, code=%d", |
| 977 | static_cast<int>(event_code)); |
| 978 | aidl_manager->notifyAuxiliaryEvent(wpa_s, event_code, reason_string); |
| 979 | } |
| 980 | |
| 981 | void wpas_aidl_notify_eap_method_selected(struct wpa_supplicant *wpa_s, |
| 982 | const char *reason_string) |
| 983 | { |
| 984 | wpas_aidl_notify_auxiliary_event(wpa_s, |
| 985 | AuxiliarySupplicantEventCode::EAP_METHOD_SELECTED, |
| 986 | reason_string); |
| 987 | } |
| 988 | |
| 989 | void wpas_aidl_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s, |
| 990 | const char *reason_string) |
| 991 | { |
| 992 | wpas_aidl_notify_auxiliary_event(wpa_s, |
| 993 | AuxiliarySupplicantEventCode::SSID_TEMP_DISABLED, |
| 994 | reason_string); |
| 995 | } |
| 996 | |
| 997 | void wpas_aidl_notify_open_ssl_failure(struct wpa_supplicant *wpa_s, |
| 998 | const char *reason_string) |
| 999 | { |
| 1000 | wpas_aidl_notify_auxiliary_event(wpa_s, |
| 1001 | AuxiliarySupplicantEventCode::OPEN_SSL_FAILURE, |
| 1002 | reason_string); |
| 1003 | } |
Shivani Baranwal | 84940f8 | 2022-02-02 10:21:47 +0530 | [diff] [blame^] | 1004 | |
| 1005 | void wpas_aidl_notify_qos_policy_reset( |
| 1006 | struct wpa_supplicant *wpa_s) |
| 1007 | { |
| 1008 | if (!wpa_s) |
| 1009 | return; |
| 1010 | wpa_printf( |
| 1011 | MSG_DEBUG, "Notifying Qos Policy Reset"); |
| 1012 | |
| 1013 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 1014 | if (!aidl_manager) |
| 1015 | return; |
| 1016 | |
| 1017 | aidl_manager->notifyQosPolicyReset(wpa_s); |
| 1018 | } |
| 1019 | |
| 1020 | void wpas_aidl_notify_qos_policy_request(struct wpa_supplicant *wpa_s, |
| 1021 | struct dscp_policy_data *policies, int num_policies) |
| 1022 | { |
| 1023 | if (!wpa_s || !policies) |
| 1024 | return; |
| 1025 | |
| 1026 | wpa_printf( |
| 1027 | MSG_DEBUG, "Notifying Qos Policy Request"); |
| 1028 | |
| 1029 | AidlManager *aidl_manager = AidlManager::getInstance(); |
| 1030 | if (!aidl_manager) |
| 1031 | return; |
| 1032 | |
| 1033 | aidl_manager->notifyQosPolicyRequest(wpa_s, policies, num_policies); |
| 1034 | } |
| 1035 | |