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