1 /* 2 * wpa_supplicant - Internal driver interface wrappers 3 * Copyright (c) 2003-2015, 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 #ifndef DRIVER_I_H 10 #define DRIVER_I_H 11 12 #include "drivers/driver.h" 13 14 /* driver_ops */ 15 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s, 16 const char *ifname) 17 { 18 if (wpa_s->driver->init2) 19 return wpa_s->driver->init2(wpa_s, ifname, 20 wpa_s->global_drv_priv); 21 if (wpa_s->driver->init) { 22 return wpa_s->driver->init(wpa_s, ifname); 23 } 24 return NULL; 25 } 26 27 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s) 28 { 29 if (wpa_s->driver->deinit) 30 wpa_s->driver->deinit(wpa_s->drv_priv); 31 } 32 33 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s, 34 const char *param) 35 { 36 if (wpa_s->driver->set_param) 37 return wpa_s->driver->set_param(wpa_s->drv_priv, param); 38 return 0; 39 } 40 41 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s, 42 int enabled) 43 { 44 if (wpa_s->driver->set_countermeasures) { 45 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv, 46 enabled); 47 } 48 return -1; 49 } 50 51 static inline int wpa_drv_authenticate(struct wpa_supplicant *wpa_s, 52 struct wpa_driver_auth_params *params) 53 { 54 if (wpa_s->driver->authenticate) 55 return wpa_s->driver->authenticate(wpa_s->drv_priv, params); 56 return -1; 57 } 58 59 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s, 60 struct wpa_driver_associate_params *params) 61 { 62 if (wpa_s->driver->associate) { 63 if (params) 64 params->freq.link_id = -1; 65 66 return wpa_s->driver->associate(wpa_s->drv_priv, params); 67 } 68 return -1; 69 } 70 71 static inline int wpa_drv_init_mesh(struct wpa_supplicant *wpa_s) 72 { 73 if (wpa_s->driver->init_mesh) 74 return wpa_s->driver->init_mesh(wpa_s->drv_priv); 75 return -1; 76 } 77 78 static inline int wpa_drv_join_mesh(struct wpa_supplicant *wpa_s, 79 struct wpa_driver_mesh_join_params *params) 80 { 81 if (wpa_s->driver->join_mesh) 82 return wpa_s->driver->join_mesh(wpa_s->drv_priv, params); 83 return -1; 84 } 85 86 static inline int wpa_drv_leave_mesh(struct wpa_supplicant *wpa_s) 87 { 88 if (wpa_s->driver->leave_mesh) 89 return wpa_s->driver->leave_mesh(wpa_s->drv_priv); 90 return -1; 91 } 92 93 static inline int wpa_drv_mesh_link_probe(struct wpa_supplicant *wpa_s, 94 const u8 *addr, 95 const u8 *eth, size_t len) 96 { 97 if (wpa_s->driver->probe_mesh_link) 98 return wpa_s->driver->probe_mesh_link(wpa_s->drv_priv, addr, 99 eth, len); 100 return -1; 101 } 102 103 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, 104 struct wpa_driver_scan_params *params) 105 { 106 #ifdef CONFIG_TESTING_OPTIONS 107 if (wpa_s->test_failure == WPAS_TEST_FAILURE_SCAN_TRIGGER) 108 return -EBUSY; 109 #endif /* CONFIG_TESTING_OPTIONS */ 110 if (wpa_s->driver->scan2) 111 return wpa_s->driver->scan2(wpa_s->drv_priv, params); 112 return -1; 113 } 114 115 static inline int wpa_drv_sched_scan(struct wpa_supplicant *wpa_s, 116 struct wpa_driver_scan_params *params) 117 { 118 if (wpa_s->driver->sched_scan) 119 return wpa_s->driver->sched_scan(wpa_s->drv_priv, params); 120 return -1; 121 } 122 123 static inline int wpa_drv_stop_sched_scan(struct wpa_supplicant *wpa_s) 124 { 125 if (wpa_s->driver->stop_sched_scan) 126 return wpa_s->driver->stop_sched_scan(wpa_s->drv_priv); 127 return -1; 128 } 129 130 struct wpa_scan_results * 131 wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s, const u8 *bssid); 132 133 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid) 134 { 135 if (wpa_s->driver->get_bssid) { 136 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid); 137 } 138 return -1; 139 } 140 141 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid) 142 { 143 if (wpa_s->driver->get_ssid) { 144 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid); 145 } 146 return -1; 147 } 148 149 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, int link_id, 150 enum wpa_alg alg, const u8 *addr, 151 int key_idx, int set_tx, 152 const u8 *seq, size_t seq_len, 153 const u8 *key, size_t key_len, 154 enum key_flag key_flag) 155 { 156 struct wpa_driver_set_key_params params; 157 158 os_memset(¶ms, 0, sizeof(params)); 159 params.ifname = wpa_s->ifname; 160 params.alg = alg; 161 params.addr = addr; 162 params.key_idx = key_idx; 163 params.set_tx = set_tx; 164 params.seq = seq; 165 params.seq_len = seq_len; 166 params.key = key; 167 params.key_len = key_len; 168 params.key_flag = key_flag; 169 params.link_id = link_id; 170 171 if (alg != WPA_ALG_NONE) { 172 /* keyidx = 1 can be either a broadcast or--with 173 * Extended Key ID--a unicast key. Use bit 15 for 174 * the pairwise keyidx 1 which is hopefully high enough 175 * to not clash with future extensions. 176 */ 177 if (key_idx == 1 && (key_flag & KEY_FLAG_PAIRWISE)) 178 wpa_s->keys_cleared &= ~BIT(15); 179 else if (key_idx >= 0 && key_idx <= 5) 180 wpa_s->keys_cleared &= ~BIT(key_idx); 181 else 182 wpa_s->keys_cleared = 0; 183 } 184 if (wpa_s->driver->set_key) { 185 return wpa_s->driver->set_key(wpa_s->drv_priv, ¶ms); 186 } 187 return -1; 188 } 189 190 static inline int wpa_drv_get_seqnum(struct wpa_supplicant *wpa_s, 191 const u8 *addr, int idx, u8 *seq) 192 { 193 if (wpa_s->driver->get_seqnum) 194 return wpa_s->driver->get_seqnum(wpa_s->ifname, wpa_s->drv_priv, 195 addr, idx, -1, seq); 196 return -1; 197 } 198 199 static inline int wpa_drv_sta_deauth(struct wpa_supplicant *wpa_s, 200 const u8 *addr, u16 reason_code) 201 { 202 if (wpa_s->driver->sta_deauth) { 203 return wpa_s->driver->sta_deauth(wpa_s->drv_priv, 204 wpa_s->own_addr, addr, 205 reason_code, -1); 206 } 207 return -1; 208 } 209 210 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s, 211 const u8 *addr, u16 reason_code) 212 { 213 if (wpa_s->driver->deauthenticate) { 214 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr, 215 reason_code); 216 } 217 return -1; 218 } 219 220 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s, 221 struct wpa_pmkid_params *params) 222 { 223 if (wpa_s->driver->add_pmkid) { 224 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, params); 225 } 226 return -1; 227 } 228 229 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s, 230 struct wpa_pmkid_params *params) 231 { 232 if (wpa_s->driver->remove_pmkid) { 233 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, params); 234 } 235 return -1; 236 } 237 238 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s) 239 { 240 if (wpa_s->driver->flush_pmkid) { 241 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv); 242 } 243 return -1; 244 } 245 246 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s, 247 struct wpa_driver_capa *capa) 248 { 249 if (wpa_s->driver->get_capa) { 250 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa); 251 } 252 return -1; 253 } 254 255 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s) 256 { 257 if (wpa_s->driver->poll) { 258 wpa_s->driver->poll(wpa_s->drv_priv); 259 } 260 } 261 262 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s) 263 { 264 if (wpa_s->driver->get_ifname) { 265 return wpa_s->driver->get_ifname(wpa_s->drv_priv); 266 } 267 return NULL; 268 } 269 270 static inline const char * 271 wpa_driver_get_radio_name(struct wpa_supplicant *wpa_s) 272 { 273 if (wpa_s->driver->get_radio_name) 274 return wpa_s->driver->get_radio_name(wpa_s->drv_priv); 275 return NULL; 276 } 277 278 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s) 279 { 280 if (wpa_s->driver->get_mac_addr) { 281 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv); 282 } 283 return NULL; 284 } 285 286 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s, 287 int state) 288 { 289 if (wpa_s->driver->set_operstate) 290 return wpa_s->driver->set_operstate(wpa_s->drv_priv, state); 291 return 0; 292 } 293 294 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s, 295 const u8 *addr, int protect_type, 296 int key_type) 297 { 298 if (wpa_s->driver->mlme_setprotection) 299 return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr, 300 protect_type, 301 key_type); 302 return 0; 303 } 304 305 static inline struct hostapd_hw_modes * 306 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes, 307 u16 *flags, u8 *dfs_domain) 308 { 309 if (wpa_s->driver->get_hw_feature_data) 310 return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv, 311 num_modes, flags, 312 dfs_domain); 313 return NULL; 314 } 315 316 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s, 317 const char *alpha2) 318 { 319 if (wpa_s->driver->set_country) 320 return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2); 321 return 0; 322 } 323 324 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s, 325 const u8 *data, size_t data_len, int noack, 326 unsigned int freq, unsigned int wait) 327 { 328 if (wpa_s->driver->send_mlme) 329 return wpa_s->driver->send_mlme(wpa_s->drv_priv, 330 data, data_len, noack, 331 freq, NULL, 0, 0, wait, -1); 332 return -1; 333 } 334 335 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s, 336 const u8 *md, 337 const u8 *ies, size_t ies_len) 338 { 339 if (wpa_s->driver->update_ft_ies) 340 return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md, 341 ies, ies_len); 342 return -1; 343 } 344 345 static inline int wpa_drv_sta_add(struct wpa_supplicant *wpa_s, 346 struct hostapd_sta_add_params *params) 347 { 348 if (wpa_s->driver->sta_add) { 349 /* Set link_id to -1 for non-TDLS peers */ 350 if (!(params->flags & WPA_STA_TDLS_PEER)) 351 params->mld_link_id = -1; 352 return wpa_s->driver->sta_add(wpa_s->drv_priv, params); 353 } 354 return -1; 355 } 356 357 static inline int wpa_drv_sta_remove(struct wpa_supplicant *wpa_s, 358 const u8 *addr) 359 { 360 if (wpa_s->driver->sta_remove) 361 return wpa_s->driver->sta_remove(wpa_s->drv_priv, addr); 362 return -1; 363 } 364 365 static inline int wpa_drv_tx_control_port(struct wpa_supplicant *wpa_s, 366 const u8 *dest, u16 proto, 367 const u8 *buf, size_t len, 368 int no_encrypt) 369 { 370 if (!wpa_s->driver->tx_control_port) 371 return -1; 372 return wpa_s->driver->tx_control_port(wpa_s->drv_priv, dest, proto, 373 buf, len, no_encrypt, -1); 374 } 375 376 static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant *wpa_s, 377 const u8 *addr, const u8 *data, 378 size_t data_len, int encrypt, 379 const u8 *own_addr, u32 flags) 380 { 381 if (wpa_s->driver->hapd_send_eapol) 382 return wpa_s->driver->hapd_send_eapol(wpa_s->drv_priv, addr, 383 data, data_len, encrypt, 384 own_addr, flags, -1); 385 return -1; 386 } 387 388 static inline int wpa_drv_sta_set_flags(struct wpa_supplicant *wpa_s, 389 const u8 *addr, int total_flags, 390 int flags_or, int flags_and) 391 { 392 if (wpa_s->driver->sta_set_flags) 393 return wpa_s->driver->sta_set_flags(wpa_s->drv_priv, addr, 394 total_flags, flags_or, 395 flags_and); 396 return -1; 397 } 398 399 static inline int wpa_drv_set_supp_port(struct wpa_supplicant *wpa_s, 400 int authorized) 401 { 402 if (wpa_s->driver->set_supp_port) { 403 return wpa_s->driver->set_supp_port(wpa_s->drv_priv, 404 authorized); 405 } 406 return 0; 407 } 408 409 int wpa_drv_send_action(struct wpa_supplicant *wpa_s, unsigned int freq, 410 unsigned int wait, const u8 *dst, const u8 *src, 411 const u8 *bssid, const u8 *data, size_t data_len, 412 int no_cck); 413 414 static inline void wpa_drv_send_action_cancel_wait(struct wpa_supplicant *wpa_s) 415 { 416 if (wpa_s->driver->send_action_cancel_wait) 417 wpa_s->driver->send_action_cancel_wait(wpa_s->drv_priv); 418 } 419 420 static inline int wpa_drv_set_freq(struct wpa_supplicant *wpa_s, 421 struct hostapd_freq_params *freq) 422 { 423 if (wpa_s->driver->set_freq) 424 return wpa_s->driver->set_freq(wpa_s->drv_priv, freq); 425 return -1; 426 } 427 428 static inline int wpa_drv_if_add(struct wpa_supplicant *wpa_s, 429 enum wpa_driver_if_type type, 430 const char *ifname, const u8 *addr, 431 void *bss_ctx, char *force_ifname, 432 u8 *if_addr, const char *bridge) 433 { 434 if (wpa_s->driver->if_add) 435 return wpa_s->driver->if_add(wpa_s->drv_priv, type, ifname, 436 addr, bss_ctx, NULL, force_ifname, 437 if_addr, bridge, 0, 0); 438 return -1; 439 } 440 441 static inline int wpa_drv_if_remove(struct wpa_supplicant *wpa_s, 442 enum wpa_driver_if_type type, 443 const char *ifname) 444 { 445 if (wpa_s->driver->if_remove) 446 return wpa_s->driver->if_remove(wpa_s->drv_priv, type, ifname); 447 return -1; 448 } 449 450 static inline int wpa_drv_remain_on_channel(struct wpa_supplicant *wpa_s, 451 unsigned int freq, 452 unsigned int duration) 453 { 454 if (wpa_s->driver->remain_on_channel) 455 return wpa_s->driver->remain_on_channel(wpa_s->drv_priv, freq, 456 duration); 457 return -1; 458 } 459 460 static inline int wpa_drv_cancel_remain_on_channel( 461 struct wpa_supplicant *wpa_s) 462 { 463 if (wpa_s->driver->cancel_remain_on_channel) 464 return wpa_s->driver->cancel_remain_on_channel( 465 wpa_s->drv_priv); 466 return -1; 467 } 468 469 static inline int wpa_drv_probe_req_report(struct wpa_supplicant *wpa_s, 470 int report) 471 { 472 if (wpa_s->driver->probe_req_report) 473 return wpa_s->driver->probe_req_report(wpa_s->drv_priv, 474 report); 475 return -1; 476 } 477 478 static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s) 479 { 480 if (wpa_s->driver->deinit_ap) 481 return wpa_s->driver->deinit_ap(wpa_s->drv_priv); 482 return 0; 483 } 484 485 static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant *wpa_s) 486 { 487 if (wpa_s->driver->deinit_p2p_cli) 488 return wpa_s->driver->deinit_p2p_cli(wpa_s->drv_priv); 489 return 0; 490 } 491 492 static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s) 493 { 494 if (wpa_s->driver->suspend) 495 wpa_s->driver->suspend(wpa_s->drv_priv); 496 } 497 498 static inline void wpa_drv_resume(struct wpa_supplicant *wpa_s) 499 { 500 if (wpa_s->driver->resume) 501 wpa_s->driver->resume(wpa_s->drv_priv); 502 } 503 504 static inline int wpa_drv_signal_monitor(struct wpa_supplicant *wpa_s, 505 int threshold, int hysteresis) 506 { 507 if (wpa_s->driver->signal_monitor) 508 return wpa_s->driver->signal_monitor(wpa_s->drv_priv, 509 threshold, hysteresis); 510 return -1; 511 } 512 513 int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s, 514 struct wpa_signal_info *si); 515 516 static inline int wpa_drv_mlo_signal_poll(struct wpa_supplicant *wpa_s, 517 struct wpa_mlo_signal_info *mlo_si) 518 { 519 if (wpa_s->driver->mlo_signal_poll) 520 return wpa_s->driver->mlo_signal_poll(wpa_s->drv_priv, mlo_si); 521 return -1; 522 } 523 524 static inline int wpa_drv_channel_info(struct wpa_supplicant *wpa_s, 525 struct wpa_channel_info *ci) 526 { 527 if (wpa_s->driver->channel_info) 528 return wpa_s->driver->channel_info(wpa_s->drv_priv, ci); 529 return -1; 530 } 531 532 static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant *wpa_s, 533 struct hostap_sta_driver_data *sta) 534 { 535 if (wpa_s->driver->read_sta_data) 536 return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta, 537 wpa_s->bssid); 538 return -1; 539 } 540 541 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s, 542 const struct wpabuf *beacon, 543 const struct wpabuf *proberesp, 544 const struct wpabuf *assocresp) 545 { 546 if (!wpa_s->driver->set_ap_wps_ie) 547 return -1; 548 return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon, 549 proberesp, assocresp); 550 } 551 552 static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s, 553 u8 *buf, size_t buf_len) 554 { 555 if (!wpa_s->driver->get_noa) 556 return -1; 557 return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len); 558 } 559 560 static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s, 561 int legacy_ps, int opp_ps, 562 int ctwindow) 563 { 564 if (!wpa_s->driver->set_p2p_powersave) 565 return -1; 566 return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps, 567 opp_ps, ctwindow); 568 } 569 570 static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu) 571 { 572 if (!wpa_s->driver->ampdu) 573 return -1; 574 return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu); 575 } 576 577 static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s, 578 const u8 *dst, u8 action_code, 579 u8 dialog_token, u16 status_code, 580 u32 peer_capab, int initiator, 581 const u8 *buf, size_t len, int link_id) 582 { 583 if (wpa_s->driver->send_tdls_mgmt) { 584 return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst, 585 action_code, dialog_token, 586 status_code, peer_capab, 587 initiator, buf, len, 588 link_id); 589 } 590 return -1; 591 } 592 593 static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s, 594 enum tdls_oper oper, const u8 *peer) 595 { 596 if (!wpa_s->driver->tdls_oper) 597 return -1; 598 return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer); 599 } 600 601 #ifdef ANDROID 602 static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s, 603 char *cmd, char *buf, size_t buf_len) 604 { 605 if (!wpa_s->driver->driver_cmd) 606 return -1; 607 return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len); 608 } 609 #endif /* ANDROID */ 610 611 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s, 612 const u8 *kek, size_t kek_len, 613 const u8 *kck, size_t kck_len, 614 const u8 *replay_ctr) 615 { 616 if (!wpa_s->driver->set_rekey_info) 617 return; 618 wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kek_len, 619 kck, kck_len, replay_ctr); 620 } 621 622 static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s, 623 int disabled) 624 { 625 if (!wpa_s->driver->radio_disable) 626 return -1; 627 return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled); 628 } 629 630 static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s, 631 struct csa_settings *settings) 632 { 633 if (!wpa_s->driver->switch_channel) 634 return -1; 635 return wpa_s->driver->switch_channel(wpa_s->drv_priv, settings); 636 } 637 638 static inline int wpa_drv_add_ts(struct wpa_supplicant *wpa_s, u8 tsid, 639 const u8 *address, u8 user_priority, 640 u16 admitted_time) 641 { 642 if (!wpa_s->driver->add_tx_ts) 643 return -1; 644 return wpa_s->driver->add_tx_ts(wpa_s->drv_priv, tsid, address, 645 user_priority, admitted_time); 646 } 647 648 static inline int wpa_drv_del_ts(struct wpa_supplicant *wpa_s, u8 tid, 649 const u8 *address) 650 { 651 if (!wpa_s->driver->del_tx_ts) 652 return -1; 653 return wpa_s->driver->del_tx_ts(wpa_s->drv_priv, tid, address); 654 } 655 656 static inline int wpa_drv_tdls_enable_channel_switch( 657 struct wpa_supplicant *wpa_s, const u8 *addr, u8 oper_class, 658 const struct hostapd_freq_params *freq_params) 659 { 660 if (!wpa_s->driver->tdls_enable_channel_switch) 661 return -1; 662 return wpa_s->driver->tdls_enable_channel_switch(wpa_s->drv_priv, addr, 663 oper_class, 664 freq_params); 665 } 666 667 static inline int 668 wpa_drv_tdls_disable_channel_switch(struct wpa_supplicant *wpa_s, 669 const u8 *addr) 670 { 671 if (!wpa_s->driver->tdls_disable_channel_switch) 672 return -1; 673 return wpa_s->driver->tdls_disable_channel_switch(wpa_s->drv_priv, 674 addr); 675 } 676 677 static inline int wpa_drv_wnm_oper(struct wpa_supplicant *wpa_s, 678 enum wnm_oper oper, const u8 *peer, 679 u8 *buf, u16 *buf_len) 680 { 681 if (!wpa_s->driver->wnm_oper) 682 return -1; 683 return wpa_s->driver->wnm_oper(wpa_s->drv_priv, oper, peer, buf, 684 buf_len); 685 } 686 687 static inline int wpa_drv_status(struct wpa_supplicant *wpa_s, 688 char *buf, size_t buflen) 689 { 690 if (!wpa_s->driver->status) 691 return -1; 692 return wpa_s->driver->status(wpa_s->drv_priv, buf, buflen); 693 } 694 695 static inline int wpa_drv_set_qos_map(struct wpa_supplicant *wpa_s, 696 const u8 *qos_map_set, u8 qos_map_set_len) 697 { 698 if (!wpa_s->driver->set_qos_map) 699 return -1; 700 return wpa_s->driver->set_qos_map(wpa_s->drv_priv, qos_map_set, 701 qos_map_set_len); 702 } 703 704 static inline int wpa_drv_get_wowlan(struct wpa_supplicant *wpa_s) 705 { 706 if (!wpa_s->driver->get_wowlan) 707 return 0; 708 return wpa_s->driver->get_wowlan(wpa_s->drv_priv); 709 } 710 711 static inline int wpa_drv_wowlan(struct wpa_supplicant *wpa_s, 712 const struct wowlan_triggers *triggers) 713 { 714 if (!wpa_s->driver->set_wowlan) 715 return -1; 716 return wpa_s->driver->set_wowlan(wpa_s->drv_priv, triggers); 717 } 718 719 static inline int wpa_drv_vendor_cmd(struct wpa_supplicant *wpa_s, 720 int vendor_id, int subcmd, const u8 *data, 721 size_t data_len, 722 enum nested_attr nested_attr_flag, 723 struct wpabuf *buf) 724 { 725 if (!wpa_s->driver->vendor_cmd) 726 return -1; 727 return wpa_s->driver->vendor_cmd(wpa_s->drv_priv, vendor_id, subcmd, 728 data, data_len, nested_attr_flag, buf); 729 } 730 731 static inline int wpa_drv_roaming(struct wpa_supplicant *wpa_s, int allowed, 732 const u8 *bssid) 733 { 734 if (!wpa_s->driver->roaming) 735 return -1; 736 return wpa_s->driver->roaming(wpa_s->drv_priv, allowed, bssid); 737 } 738 739 static inline int wpa_drv_disable_fils(struct wpa_supplicant *wpa_s, 740 int disable) 741 { 742 if (!wpa_s->driver->disable_fils) 743 return -1; 744 return wpa_s->driver->disable_fils(wpa_s->drv_priv, disable); 745 } 746 747 static inline int wpa_drv_set_mac_addr(struct wpa_supplicant *wpa_s, 748 const u8 *addr) 749 { 750 if (!wpa_s->driver->set_mac_addr) 751 return -1; 752 return wpa_s->driver->set_mac_addr(wpa_s->drv_priv, addr); 753 } 754 755 756 #ifdef CONFIG_MACSEC 757 758 static inline int wpa_drv_macsec_init(struct wpa_supplicant *wpa_s, 759 struct macsec_init_params *params) 760 { 761 if (!wpa_s->driver->macsec_init) 762 return -1; 763 return wpa_s->driver->macsec_init(wpa_s->drv_priv, params); 764 } 765 766 static inline int wpa_drv_macsec_deinit(struct wpa_supplicant *wpa_s) 767 { 768 if (!wpa_s->driver->macsec_deinit) 769 return -1; 770 return wpa_s->driver->macsec_deinit(wpa_s->drv_priv); 771 } 772 773 static inline int wpa_drv_macsec_get_capability(struct wpa_supplicant *wpa_s, 774 enum macsec_cap *cap) 775 { 776 if (!wpa_s->driver->macsec_get_capability) 777 return -1; 778 return wpa_s->driver->macsec_get_capability(wpa_s->drv_priv, cap); 779 } 780 781 static inline int wpa_drv_enable_protect_frames(struct wpa_supplicant *wpa_s, 782 bool enabled) 783 { 784 if (!wpa_s->driver->enable_protect_frames) 785 return -1; 786 return wpa_s->driver->enable_protect_frames(wpa_s->drv_priv, enabled); 787 } 788 789 static inline int wpa_drv_enable_encrypt(struct wpa_supplicant *wpa_s, 790 bool enabled) 791 { 792 if (!wpa_s->driver->enable_encrypt) 793 return -1; 794 return wpa_s->driver->enable_encrypt(wpa_s->drv_priv, enabled); 795 } 796 797 static inline int wpa_drv_set_replay_protect(struct wpa_supplicant *wpa_s, 798 bool enabled, u32 window) 799 { 800 if (!wpa_s->driver->set_replay_protect) 801 return -1; 802 return wpa_s->driver->set_replay_protect(wpa_s->drv_priv, enabled, 803 window); 804 } 805 806 static inline int wpa_drv_set_offload(struct wpa_supplicant *wpa_s, u8 offload) 807 { 808 if (!wpa_s->driver->set_offload) 809 return -1; 810 return wpa_s->driver->set_offload(wpa_s->drv_priv, offload); 811 812 } 813 814 static inline int wpa_drv_set_current_cipher_suite(struct wpa_supplicant *wpa_s, 815 u64 cs) 816 { 817 if (!wpa_s->driver->set_current_cipher_suite) 818 return -1; 819 return wpa_s->driver->set_current_cipher_suite(wpa_s->drv_priv, cs); 820 } 821 822 static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s, 823 bool enabled) 824 { 825 if (!wpa_s->driver->enable_controlled_port) 826 return -1; 827 return wpa_s->driver->enable_controlled_port(wpa_s->drv_priv, enabled); 828 } 829 830 static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s, 831 struct receive_sa *sa) 832 { 833 if (!wpa_s->driver->get_receive_lowest_pn) 834 return -1; 835 return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, sa); 836 } 837 838 static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s, 839 struct transmit_sa *sa) 840 { 841 if (!wpa_s->driver->get_transmit_next_pn) 842 return -1; 843 return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, sa); 844 } 845 846 static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s, 847 struct transmit_sa *sa) 848 { 849 if (!wpa_s->driver->set_transmit_next_pn) 850 return -1; 851 return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, sa); 852 } 853 854 static inline int wpa_drv_set_receive_lowest_pn(struct wpa_supplicant *wpa_s, 855 struct receive_sa *sa) 856 { 857 if (!wpa_s->driver->set_receive_lowest_pn) 858 return -1; 859 return wpa_s->driver->set_receive_lowest_pn(wpa_s->drv_priv, sa); 860 } 861 862 static inline int 863 wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, struct receive_sc *sc, 864 unsigned int conf_offset, int validation) 865 { 866 if (!wpa_s->driver->create_receive_sc) 867 return -1; 868 return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, sc, 869 conf_offset, validation); 870 } 871 872 static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s, 873 struct receive_sc *sc) 874 { 875 if (!wpa_s->driver->delete_receive_sc) 876 return -1; 877 return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, sc); 878 } 879 880 static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s, 881 struct receive_sa *sa) 882 { 883 if (!wpa_s->driver->create_receive_sa) 884 return -1; 885 return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, sa); 886 } 887 888 static inline int wpa_drv_delete_receive_sa(struct wpa_supplicant *wpa_s, 889 struct receive_sa *sa) 890 { 891 if (!wpa_s->driver->delete_receive_sa) 892 return -1; 893 return wpa_s->driver->delete_receive_sa(wpa_s->drv_priv, sa); 894 } 895 896 static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s, 897 struct receive_sa *sa) 898 { 899 if (!wpa_s->driver->enable_receive_sa) 900 return -1; 901 return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, sa); 902 } 903 904 static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s, 905 struct receive_sa *sa) 906 { 907 if (!wpa_s->driver->disable_receive_sa) 908 return -1; 909 return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, sa); 910 } 911 912 static inline int 913 wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, struct transmit_sc *sc, 914 unsigned int conf_offset) 915 { 916 if (!wpa_s->driver->create_transmit_sc) 917 return -1; 918 return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, sc, 919 conf_offset); 920 } 921 922 static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s, 923 struct transmit_sc *sc) 924 { 925 if (!wpa_s->driver->delete_transmit_sc) 926 return -1; 927 return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, sc); 928 } 929 930 static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s, 931 struct transmit_sa *sa) 932 { 933 if (!wpa_s->driver->create_transmit_sa) 934 return -1; 935 return wpa_s->driver->create_transmit_sa(wpa_s->drv_priv, sa); 936 } 937 938 static inline int wpa_drv_delete_transmit_sa(struct wpa_supplicant *wpa_s, 939 struct transmit_sa *sa) 940 { 941 if (!wpa_s->driver->delete_transmit_sa) 942 return -1; 943 return wpa_s->driver->delete_transmit_sa(wpa_s->drv_priv, sa); 944 } 945 946 static inline int wpa_drv_enable_transmit_sa(struct wpa_supplicant *wpa_s, 947 struct transmit_sa *sa) 948 { 949 if (!wpa_s->driver->enable_transmit_sa) 950 return -1; 951 return wpa_s->driver->enable_transmit_sa(wpa_s->drv_priv, sa); 952 } 953 954 static inline int wpa_drv_disable_transmit_sa(struct wpa_supplicant *wpa_s, 955 struct transmit_sa *sa) 956 { 957 if (!wpa_s->driver->disable_transmit_sa) 958 return -1; 959 return wpa_s->driver->disable_transmit_sa(wpa_s->drv_priv, sa); 960 } 961 #endif /* CONFIG_MACSEC */ 962 963 static inline int wpa_drv_setband(struct wpa_supplicant *wpa_s, 964 u32 band_mask) 965 { 966 if (!wpa_s->driver->set_band) 967 return -1; 968 return wpa_s->driver->set_band(wpa_s->drv_priv, band_mask); 969 } 970 971 static inline int wpa_drv_get_pref_freq_list(struct wpa_supplicant *wpa_s, 972 enum wpa_driver_if_type if_type, 973 unsigned int *num, 974 struct weighted_pcl *freq_list) 975 { 976 #ifdef CONFIG_TESTING_OPTIONS 977 if (wpa_s->get_pref_freq_list_override) 978 return wpas_ctrl_iface_get_pref_freq_list_override( 979 wpa_s, if_type, num, freq_list); 980 #endif /* CONFIG_TESTING_OPTIONS */ 981 if (!wpa_s->driver->get_pref_freq_list) 982 return -1; 983 return wpa_s->driver->get_pref_freq_list(wpa_s->drv_priv, if_type, 984 num, freq_list); 985 } 986 987 static inline int wpa_drv_set_prob_oper_freq(struct wpa_supplicant *wpa_s, 988 unsigned int freq) 989 { 990 if (!wpa_s->driver->set_prob_oper_freq) 991 return 0; 992 return wpa_s->driver->set_prob_oper_freq(wpa_s->drv_priv, freq); 993 } 994 995 static inline int wpa_drv_abort_scan(struct wpa_supplicant *wpa_s, 996 u64 scan_cookie) 997 { 998 if (!wpa_s->driver->abort_scan) 999 return -1; 1000 return wpa_s->driver->abort_scan(wpa_s->drv_priv, scan_cookie); 1001 } 1002 1003 static inline int wpa_drv_configure_frame_filters(struct wpa_supplicant *wpa_s, 1004 u32 filters) 1005 { 1006 if (!wpa_s->driver->configure_data_frame_filters) 1007 return -1; 1008 return wpa_s->driver->configure_data_frame_filters(wpa_s->drv_priv, 1009 filters); 1010 } 1011 1012 static inline int wpa_drv_get_ext_capa(struct wpa_supplicant *wpa_s, 1013 enum wpa_driver_if_type type) 1014 { 1015 if (!wpa_s->driver->get_ext_capab) 1016 return -1; 1017 return wpa_s->driver->get_ext_capab(wpa_s->drv_priv, type, 1018 &wpa_s->extended_capa, 1019 &wpa_s->extended_capa_mask, 1020 &wpa_s->extended_capa_len); 1021 } 1022 1023 static inline int wpa_drv_p2p_lo_start(struct wpa_supplicant *wpa_s, 1024 unsigned int channel, 1025 unsigned int period, 1026 unsigned int interval, 1027 unsigned int count, 1028 const u8 *device_types, 1029 size_t dev_types_len, 1030 const u8 *ies, size_t ies_len) 1031 { 1032 if (!wpa_s->driver->p2p_lo_start) 1033 return -1; 1034 return wpa_s->driver->p2p_lo_start(wpa_s->drv_priv, channel, period, 1035 interval, count, device_types, 1036 dev_types_len, ies, ies_len); 1037 } 1038 1039 static inline int wpa_drv_p2p_lo_stop(struct wpa_supplicant *wpa_s) 1040 { 1041 if (!wpa_s->driver->p2p_lo_stop) 1042 return -1; 1043 return wpa_s->driver->p2p_lo_stop(wpa_s->drv_priv); 1044 } 1045 1046 static inline int wpa_drv_set_default_scan_ies(struct wpa_supplicant *wpa_s, 1047 const u8 *ies, size_t len) 1048 { 1049 if (!wpa_s->driver->set_default_scan_ies) 1050 return -1; 1051 return wpa_s->driver->set_default_scan_ies(wpa_s->drv_priv, ies, len); 1052 } 1053 1054 static inline int wpa_drv_set_tdls_mode(struct wpa_supplicant *wpa_s, 1055 int tdls_external_control) 1056 { 1057 if (!wpa_s->driver->set_tdls_mode) 1058 return -1; 1059 return wpa_s->driver->set_tdls_mode(wpa_s->drv_priv, 1060 tdls_external_control); 1061 } 1062 1063 static inline struct wpa_bss_candidate_info * 1064 wpa_drv_get_bss_trans_status(struct wpa_supplicant *wpa_s, 1065 struct wpa_bss_trans_info *params) 1066 { 1067 if (!wpa_s->driver->get_bss_transition_status) 1068 return NULL; 1069 return wpa_s->driver->get_bss_transition_status(wpa_s->drv_priv, 1070 params); 1071 } 1072 1073 static inline int wpa_drv_ignore_assoc_disallow(struct wpa_supplicant *wpa_s, 1074 int val) 1075 { 1076 if (!wpa_s->driver->ignore_assoc_disallow) 1077 return -1; 1078 return wpa_s->driver->ignore_assoc_disallow(wpa_s->drv_priv, val); 1079 } 1080 1081 static inline int wpa_drv_set_bssid_tmp_disallow(struct wpa_supplicant *wpa_s, 1082 unsigned int num_bssid, 1083 const u8 *bssids) 1084 { 1085 if (!wpa_s->driver->set_bssid_tmp_disallow) 1086 return -1; 1087 return wpa_s->driver->set_bssid_tmp_disallow(wpa_s->drv_priv, num_bssid, 1088 bssids); 1089 } 1090 1091 static inline int wpa_drv_update_connect_params( 1092 struct wpa_supplicant *wpa_s, 1093 struct wpa_driver_associate_params *params, 1094 enum wpa_drv_update_connect_params_mask mask) 1095 { 1096 if (!wpa_s->driver->update_connect_params) 1097 return -1; 1098 1099 if (params) 1100 params->freq.link_id = -1; 1101 1102 return wpa_s->driver->update_connect_params(wpa_s->drv_priv, params, 1103 mask); 1104 } 1105 1106 static inline int 1107 wpa_drv_send_external_auth_status(struct wpa_supplicant *wpa_s, 1108 struct external_auth *params) 1109 { 1110 if (!wpa_s->driver->send_external_auth_status) 1111 return -1; 1112 return wpa_s->driver->send_external_auth_status(wpa_s->drv_priv, 1113 params); 1114 } 1115 1116 static inline int wpa_drv_set_4addr_mode(struct wpa_supplicant *wpa_s, int val) 1117 { 1118 if (!wpa_s->driver->set_4addr_mode) 1119 return -1; 1120 return wpa_s->driver->set_4addr_mode(wpa_s->drv_priv, 1121 wpa_s->bridge_ifname, val); 1122 } 1123 1124 static inline int wpa_drv_dpp_listen(struct wpa_supplicant *wpa_s, bool enable) 1125 { 1126 if (!wpa_s->driver->dpp_listen) 1127 return 0; 1128 return wpa_s->driver->dpp_listen(wpa_s->drv_priv, enable); 1129 } 1130 1131 static inline int wpa_drv_send_pasn_resp(struct wpa_supplicant *wpa_s, 1132 struct pasn_auth *params) 1133 { 1134 if (!wpa_s->driver->send_pasn_resp) 1135 return -1; 1136 return wpa_s->driver->send_pasn_resp(wpa_s->drv_priv, params); 1137 } 1138 1139 static inline int wpa_drv_set_secure_ranging_ctx(struct wpa_supplicant *wpa_s, 1140 const u8 *own_addr, 1141 const u8 *peer_addr, 1142 u32 cipher, u8 tk_len, 1143 const u8 *tk, 1144 u8 ltf_keyseed_len, 1145 const u8 *ltf_keyseed, 1146 u32 action) 1147 { 1148 struct secure_ranging_params params; 1149 1150 /* Configure secure ranging context only to the drivers that support it. 1151 */ 1152 if (!wpa_s->driver->set_secure_ranging_ctx) 1153 return 0; 1154 1155 os_memset(¶ms, 0, sizeof(params)); 1156 params.action = action; 1157 params.own_addr = own_addr; 1158 params.peer_addr = peer_addr; 1159 params.cipher = cipher; 1160 params.tk_len = tk_len; 1161 params.tk = tk; 1162 params.ltf_keyseed_len = ltf_keyseed_len; 1163 params.ltf_keyseed = ltf_keyseed; 1164 1165 return wpa_s->driver->set_secure_ranging_ctx(wpa_s->drv_priv, ¶ms); 1166 } 1167 1168 static inline int 1169 wpas_drv_get_sta_mlo_info(struct wpa_supplicant *wpa_s, 1170 struct driver_sta_mlo_info *mlo_info) 1171 { 1172 if (!wpa_s->driver->get_sta_mlo_info) 1173 return 0; 1174 1175 return wpa_s->driver->get_sta_mlo_info(wpa_s->drv_priv, mlo_info); 1176 } 1177 1178 #endif /* DRIVER_I_H */ 1179