2 * wpa_supplicant - Internal driver interface wrappers
3 * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
12 #include "drivers/driver.h"
15 static inline void * wpa_drv_init(struct wpa_supplicant
*wpa_s
,
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
);
27 static inline void wpa_drv_deinit(struct wpa_supplicant
*wpa_s
)
29 if (wpa_s
->driver
->deinit
)
30 wpa_s
->driver
->deinit(wpa_s
->drv_priv
);
33 static inline int wpa_drv_set_param(struct wpa_supplicant
*wpa_s
,
36 if (wpa_s
->driver
->set_param
)
37 return wpa_s
->driver
->set_param(wpa_s
->drv_priv
, param
);
41 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant
*wpa_s
,
44 if (wpa_s
->driver
->set_countermeasures
) {
45 return wpa_s
->driver
->set_countermeasures(wpa_s
->drv_priv
,
51 static inline int wpa_drv_authenticate(struct wpa_supplicant
*wpa_s
,
52 struct wpa_driver_auth_params
*params
)
54 if (wpa_s
->driver
->authenticate
)
55 return wpa_s
->driver
->authenticate(wpa_s
->drv_priv
, params
);
59 static inline int wpa_drv_associate(struct wpa_supplicant
*wpa_s
,
60 struct wpa_driver_associate_params
*params
)
62 if (wpa_s
->driver
->associate
) {
63 return wpa_s
->driver
->associate(wpa_s
->drv_priv
, params
);
68 static inline int wpa_drv_scan(struct wpa_supplicant
*wpa_s
,
69 struct wpa_driver_scan_params
*params
)
71 if (wpa_s
->driver
->scan2
)
72 return wpa_s
->driver
->scan2(wpa_s
->drv_priv
, params
);
76 static inline int wpa_drv_sched_scan(struct wpa_supplicant
*wpa_s
,
77 struct wpa_driver_scan_params
*params
,
80 if (wpa_s
->driver
->sched_scan
)
81 return wpa_s
->driver
->sched_scan(wpa_s
->drv_priv
,
86 static inline int wpa_drv_stop_sched_scan(struct wpa_supplicant
*wpa_s
)
88 if (wpa_s
->driver
->stop_sched_scan
)
89 return wpa_s
->driver
->stop_sched_scan(wpa_s
->drv_priv
);
93 static inline struct wpa_scan_results
* wpa_drv_get_scan_results2(
94 struct wpa_supplicant
*wpa_s
)
96 if (wpa_s
->driver
->get_scan_results2
)
97 return wpa_s
->driver
->get_scan_results2(wpa_s
->drv_priv
);
101 static inline int wpa_drv_get_bssid(struct wpa_supplicant
*wpa_s
, u8
*bssid
)
103 if (wpa_s
->driver
->get_bssid
) {
104 return wpa_s
->driver
->get_bssid(wpa_s
->drv_priv
, bssid
);
109 static inline int wpa_drv_get_ssid(struct wpa_supplicant
*wpa_s
, u8
*ssid
)
111 if (wpa_s
->driver
->get_ssid
) {
112 return wpa_s
->driver
->get_ssid(wpa_s
->drv_priv
, ssid
);
117 static inline int wpa_drv_set_key(struct wpa_supplicant
*wpa_s
,
118 enum wpa_alg alg
, const u8
*addr
,
119 int key_idx
, int set_tx
,
120 const u8
*seq
, size_t seq_len
,
121 const u8
*key
, size_t key_len
)
123 if (wpa_s
->driver
->set_key
) {
124 wpa_s
->keys_cleared
= 0;
125 return wpa_s
->driver
->set_key(wpa_s
->ifname
, wpa_s
->drv_priv
,
126 alg
, addr
, key_idx
, set_tx
,
127 seq
, seq_len
, key
, key_len
);
132 static inline int wpa_drv_deauthenticate(struct wpa_supplicant
*wpa_s
,
133 const u8
*addr
, int reason_code
)
135 if (wpa_s
->driver
->deauthenticate
) {
136 return wpa_s
->driver
->deauthenticate(wpa_s
->drv_priv
, addr
,
142 static inline int wpa_drv_disassociate(struct wpa_supplicant
*wpa_s
,
143 const u8
*addr
, int reason_code
)
145 if (wpa_s
->driver
->disassociate
) {
146 return wpa_s
->driver
->disassociate(wpa_s
->drv_priv
, addr
,
152 static inline int wpa_drv_add_pmkid(struct wpa_supplicant
*wpa_s
,
153 const u8
*bssid
, const u8
*pmkid
)
155 if (wpa_s
->driver
->add_pmkid
) {
156 return wpa_s
->driver
->add_pmkid(wpa_s
->drv_priv
, bssid
, pmkid
);
161 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant
*wpa_s
,
162 const u8
*bssid
, const u8
*pmkid
)
164 if (wpa_s
->driver
->remove_pmkid
) {
165 return wpa_s
->driver
->remove_pmkid(wpa_s
->drv_priv
, bssid
,
171 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant
*wpa_s
)
173 if (wpa_s
->driver
->flush_pmkid
) {
174 return wpa_s
->driver
->flush_pmkid(wpa_s
->drv_priv
);
179 static inline int wpa_drv_get_capa(struct wpa_supplicant
*wpa_s
,
180 struct wpa_driver_capa
*capa
)
182 if (wpa_s
->driver
->get_capa
) {
183 return wpa_s
->driver
->get_capa(wpa_s
->drv_priv
, capa
);
188 static inline void wpa_drv_poll(struct wpa_supplicant
*wpa_s
)
190 if (wpa_s
->driver
->poll
) {
191 wpa_s
->driver
->poll(wpa_s
->drv_priv
);
195 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant
*wpa_s
)
197 if (wpa_s
->driver
->get_ifname
) {
198 return wpa_s
->driver
->get_ifname(wpa_s
->drv_priv
);
203 static inline const u8
* wpa_drv_get_mac_addr(struct wpa_supplicant
*wpa_s
)
205 if (wpa_s
->driver
->get_mac_addr
) {
206 return wpa_s
->driver
->get_mac_addr(wpa_s
->drv_priv
);
211 static inline int wpa_drv_send_eapol(struct wpa_supplicant
*wpa_s
,
212 const u8
*dst
, u16 proto
,
213 const u8
*data
, size_t data_len
)
215 if (wpa_s
->driver
->send_eapol
)
216 return wpa_s
->driver
->send_eapol(wpa_s
->drv_priv
, dst
, proto
,
221 static inline int wpa_drv_set_operstate(struct wpa_supplicant
*wpa_s
,
224 if (wpa_s
->driver
->set_operstate
)
225 return wpa_s
->driver
->set_operstate(wpa_s
->drv_priv
, state
);
229 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant
*wpa_s
,
230 const u8
*addr
, int protect_type
,
233 if (wpa_s
->driver
->mlme_setprotection
)
234 return wpa_s
->driver
->mlme_setprotection(wpa_s
->drv_priv
, addr
,
240 static inline struct hostapd_hw_modes
*
241 wpa_drv_get_hw_feature_data(struct wpa_supplicant
*wpa_s
, u16
*num_modes
,
244 if (wpa_s
->driver
->get_hw_feature_data
)
245 return wpa_s
->driver
->get_hw_feature_data(wpa_s
->drv_priv
,
250 static inline int wpa_drv_set_country(struct wpa_supplicant
*wpa_s
,
253 if (wpa_s
->driver
->set_country
)
254 return wpa_s
->driver
->set_country(wpa_s
->drv_priv
, alpha2
);
258 static inline int wpa_drv_send_mlme(struct wpa_supplicant
*wpa_s
,
259 const u8
*data
, size_t data_len
, int noack
)
261 if (wpa_s
->driver
->send_mlme
)
262 return wpa_s
->driver
->send_mlme(wpa_s
->drv_priv
,
263 data
, data_len
, noack
);
267 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant
*wpa_s
,
269 const u8
*ies
, size_t ies_len
)
271 if (wpa_s
->driver
->update_ft_ies
)
272 return wpa_s
->driver
->update_ft_ies(wpa_s
->drv_priv
, md
,
277 static inline int wpa_drv_send_ft_action(struct wpa_supplicant
*wpa_s
,
278 u8 action
, const u8
*target_ap
,
279 const u8
*ies
, size_t ies_len
)
281 if (wpa_s
->driver
->send_ft_action
)
282 return wpa_s
->driver
->send_ft_action(wpa_s
->drv_priv
, action
,
283 target_ap
, ies
, ies_len
);
287 static inline int wpa_drv_set_ap(struct wpa_supplicant
*wpa_s
,
288 struct wpa_driver_ap_params
*params
)
290 if (wpa_s
->driver
->set_ap
)
291 return wpa_s
->driver
->set_ap(wpa_s
->drv_priv
, params
);
295 static inline int wpa_drv_sta_add(struct wpa_supplicant
*wpa_s
,
296 struct hostapd_sta_add_params
*params
)
298 if (wpa_s
->driver
->sta_add
)
299 return wpa_s
->driver
->sta_add(wpa_s
->drv_priv
, params
);
303 static inline int wpa_drv_sta_remove(struct wpa_supplicant
*wpa_s
,
306 if (wpa_s
->driver
->sta_remove
)
307 return wpa_s
->driver
->sta_remove(wpa_s
->drv_priv
, addr
);
311 static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant
*wpa_s
,
312 const u8
*addr
, const u8
*data
,
313 size_t data_len
, int encrypt
,
314 const u8
*own_addr
, u32 flags
)
316 if (wpa_s
->driver
->hapd_send_eapol
)
317 return wpa_s
->driver
->hapd_send_eapol(wpa_s
->drv_priv
, addr
,
318 data
, data_len
, encrypt
,
323 static inline int wpa_drv_sta_set_flags(struct wpa_supplicant
*wpa_s
,
324 const u8
*addr
, int total_flags
,
325 int flags_or
, int flags_and
)
327 if (wpa_s
->driver
->sta_set_flags
)
328 return wpa_s
->driver
->sta_set_flags(wpa_s
->drv_priv
, addr
,
329 total_flags
, flags_or
,
334 static inline int wpa_drv_set_supp_port(struct wpa_supplicant
*wpa_s
,
337 if (wpa_s
->driver
->set_supp_port
) {
338 return wpa_s
->driver
->set_supp_port(wpa_s
->drv_priv
,
344 static inline int wpa_drv_send_action(struct wpa_supplicant
*wpa_s
,
347 const u8
*dst
, const u8
*src
,
349 const u8
*data
, size_t data_len
,
352 if (wpa_s
->driver
->send_action
)
353 return wpa_s
->driver
->send_action(wpa_s
->drv_priv
, freq
,
354 wait
, dst
, src
, bssid
,
355 data
, data_len
, no_cck
);
359 static inline void wpa_drv_send_action_cancel_wait(struct wpa_supplicant
*wpa_s
)
361 if (wpa_s
->driver
->send_action_cancel_wait
)
362 wpa_s
->driver
->send_action_cancel_wait(wpa_s
->drv_priv
);
365 static inline int wpa_drv_set_freq(struct wpa_supplicant
*wpa_s
,
366 struct hostapd_freq_params
*freq
)
368 if (wpa_s
->driver
->set_freq
)
369 return wpa_s
->driver
->set_freq(wpa_s
->drv_priv
, freq
);
373 static inline int wpa_drv_if_add(struct wpa_supplicant
*wpa_s
,
374 enum wpa_driver_if_type type
,
375 const char *ifname
, const u8
*addr
,
376 void *bss_ctx
, char *force_ifname
,
377 u8
*if_addr
, const char *bridge
)
379 if (wpa_s
->driver
->if_add
)
380 return wpa_s
->driver
->if_add(wpa_s
->drv_priv
, type
, ifname
,
381 addr
, bss_ctx
, NULL
, force_ifname
,
386 static inline int wpa_drv_if_remove(struct wpa_supplicant
*wpa_s
,
387 enum wpa_driver_if_type type
,
390 if (wpa_s
->driver
->if_remove
)
391 return wpa_s
->driver
->if_remove(wpa_s
->drv_priv
, type
, ifname
);
395 static inline int wpa_drv_remain_on_channel(struct wpa_supplicant
*wpa_s
,
397 unsigned int duration
)
399 if (wpa_s
->driver
->remain_on_channel
)
400 return wpa_s
->driver
->remain_on_channel(wpa_s
->drv_priv
, freq
,
405 static inline int wpa_drv_cancel_remain_on_channel(
406 struct wpa_supplicant
*wpa_s
)
408 if (wpa_s
->driver
->cancel_remain_on_channel
)
409 return wpa_s
->driver
->cancel_remain_on_channel(
414 static inline int wpa_drv_probe_req_report(struct wpa_supplicant
*wpa_s
,
417 if (wpa_s
->driver
->probe_req_report
)
418 return wpa_s
->driver
->probe_req_report(wpa_s
->drv_priv
,
423 static inline int wpa_drv_deinit_ap(struct wpa_supplicant
*wpa_s
)
425 if (wpa_s
->driver
->deinit_ap
)
426 return wpa_s
->driver
->deinit_ap(wpa_s
->drv_priv
);
430 static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant
*wpa_s
)
432 if (wpa_s
->driver
->deinit_p2p_cli
)
433 return wpa_s
->driver
->deinit_p2p_cli(wpa_s
->drv_priv
);
437 static inline void wpa_drv_suspend(struct wpa_supplicant
*wpa_s
)
439 if (wpa_s
->driver
->suspend
)
440 wpa_s
->driver
->suspend(wpa_s
->drv_priv
);
443 static inline void wpa_drv_resume(struct wpa_supplicant
*wpa_s
)
445 if (wpa_s
->driver
->resume
)
446 wpa_s
->driver
->resume(wpa_s
->drv_priv
);
449 static inline int wpa_drv_signal_monitor(struct wpa_supplicant
*wpa_s
,
450 int threshold
, int hysteresis
)
452 if (wpa_s
->driver
->signal_monitor
)
453 return wpa_s
->driver
->signal_monitor(wpa_s
->drv_priv
,
454 threshold
, hysteresis
);
458 static inline int wpa_drv_signal_poll(struct wpa_supplicant
*wpa_s
,
459 struct wpa_signal_info
*si
)
461 if (wpa_s
->driver
->signal_poll
)
462 return wpa_s
->driver
->signal_poll(wpa_s
->drv_priv
, si
);
466 static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant
*wpa_s
,
467 struct hostap_sta_driver_data
*sta
)
469 if (wpa_s
->driver
->read_sta_data
)
470 return wpa_s
->driver
->read_sta_data(wpa_s
->drv_priv
, sta
,
475 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant
*wpa_s
,
476 const struct wpabuf
*beacon
,
477 const struct wpabuf
*proberesp
,
478 const struct wpabuf
*assocresp
)
480 if (!wpa_s
->driver
->set_ap_wps_ie
)
482 return wpa_s
->driver
->set_ap_wps_ie(wpa_s
->drv_priv
, beacon
,
483 proberesp
, assocresp
);
486 static inline int wpa_drv_shared_freq(struct wpa_supplicant
*wpa_s
)
488 if (!wpa_s
->driver
->shared_freq
)
490 return wpa_s
->driver
->shared_freq(wpa_s
->drv_priv
);
493 static inline int wpa_drv_get_noa(struct wpa_supplicant
*wpa_s
,
494 u8
*buf
, size_t buf_len
)
496 if (!wpa_s
->driver
->get_noa
)
498 return wpa_s
->driver
->get_noa(wpa_s
->drv_priv
, buf
, buf_len
);
501 static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant
*wpa_s
,
502 int legacy_ps
, int opp_ps
,
505 if (!wpa_s
->driver
->set_p2p_powersave
)
507 return wpa_s
->driver
->set_p2p_powersave(wpa_s
->drv_priv
, legacy_ps
,
511 static inline int wpa_drv_ampdu(struct wpa_supplicant
*wpa_s
, int ampdu
)
513 if (!wpa_s
->driver
->ampdu
)
515 return wpa_s
->driver
->ampdu(wpa_s
->drv_priv
, ampdu
);
518 static inline int wpa_drv_p2p_find(struct wpa_supplicant
*wpa_s
,
519 unsigned int timeout
, int type
)
521 if (!wpa_s
->driver
->p2p_find
)
523 return wpa_s
->driver
->p2p_find(wpa_s
->drv_priv
, timeout
, type
);
526 static inline int wpa_drv_p2p_stop_find(struct wpa_supplicant
*wpa_s
)
528 if (!wpa_s
->driver
->p2p_stop_find
)
530 return wpa_s
->driver
->p2p_stop_find(wpa_s
->drv_priv
);
533 static inline int wpa_drv_p2p_listen(struct wpa_supplicant
*wpa_s
,
534 unsigned int timeout
)
536 if (!wpa_s
->driver
->p2p_listen
)
538 return wpa_s
->driver
->p2p_listen(wpa_s
->drv_priv
, timeout
);
541 static inline int wpa_drv_p2p_connect(struct wpa_supplicant
*wpa_s
,
542 const u8
*peer_addr
, int wps_method
,
544 const u8
*own_interface_addr
,
545 unsigned int force_freq
,
546 int persistent_group
)
548 if (!wpa_s
->driver
->p2p_connect
)
550 return wpa_s
->driver
->p2p_connect(wpa_s
->drv_priv
, peer_addr
,
551 wps_method
, go_intent
,
552 own_interface_addr
, force_freq
,
556 static inline int wpa_drv_wps_success_cb(struct wpa_supplicant
*wpa_s
,
559 if (!wpa_s
->driver
->wps_success_cb
)
561 return wpa_s
->driver
->wps_success_cb(wpa_s
->drv_priv
, peer_addr
);
565 wpa_drv_p2p_group_formation_failed(struct wpa_supplicant
*wpa_s
)
567 if (!wpa_s
->driver
->p2p_group_formation_failed
)
569 return wpa_s
->driver
->p2p_group_formation_failed(wpa_s
->drv_priv
);
572 static inline int wpa_drv_p2p_set_params(struct wpa_supplicant
*wpa_s
,
573 const struct p2p_params
*params
)
575 if (!wpa_s
->driver
->p2p_set_params
)
577 return wpa_s
->driver
->p2p_set_params(wpa_s
->drv_priv
, params
);
580 static inline int wpa_drv_p2p_prov_disc_req(struct wpa_supplicant
*wpa_s
,
582 u16 config_methods
, int join
)
584 if (!wpa_s
->driver
->p2p_prov_disc_req
)
586 return wpa_s
->driver
->p2p_prov_disc_req(wpa_s
->drv_priv
, peer_addr
,
587 config_methods
, join
);
590 static inline u64
wpa_drv_p2p_sd_request(struct wpa_supplicant
*wpa_s
,
592 const struct wpabuf
*tlvs
)
594 if (!wpa_s
->driver
->p2p_sd_request
)
596 return wpa_s
->driver
->p2p_sd_request(wpa_s
->drv_priv
, dst
, tlvs
);
599 static inline int wpa_drv_p2p_sd_cancel_request(struct wpa_supplicant
*wpa_s
,
602 if (!wpa_s
->driver
->p2p_sd_cancel_request
)
604 return wpa_s
->driver
->p2p_sd_cancel_request(wpa_s
->drv_priv
, req
);
607 static inline int wpa_drv_p2p_sd_response(struct wpa_supplicant
*wpa_s
,
608 int freq
, const u8
*dst
,
610 const struct wpabuf
*resp_tlvs
)
612 if (!wpa_s
->driver
->p2p_sd_response
)
614 return wpa_s
->driver
->p2p_sd_response(wpa_s
->drv_priv
, freq
, dst
,
615 dialog_token
, resp_tlvs
);
618 static inline int wpa_drv_p2p_service_update(struct wpa_supplicant
*wpa_s
)
620 if (!wpa_s
->driver
->p2p_service_update
)
622 return wpa_s
->driver
->p2p_service_update(wpa_s
->drv_priv
);
625 static inline int wpa_drv_p2p_reject(struct wpa_supplicant
*wpa_s
,
628 if (!wpa_s
->driver
->p2p_reject
)
630 return wpa_s
->driver
->p2p_reject(wpa_s
->drv_priv
, addr
);
633 static inline int wpa_drv_p2p_invite(struct wpa_supplicant
*wpa_s
,
634 const u8
*peer
, int role
, const u8
*bssid
,
635 const u8
*ssid
, size_t ssid_len
,
636 const u8
*go_dev_addr
,
637 int persistent_group
)
639 if (!wpa_s
->driver
->p2p_invite
)
641 return wpa_s
->driver
->p2p_invite(wpa_s
->drv_priv
, peer
, role
, bssid
,
642 ssid
, ssid_len
, go_dev_addr
,
646 static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant
*wpa_s
,
647 const u8
*dst
, u8 action_code
,
648 u8 dialog_token
, u16 status_code
,
649 const u8
*buf
, size_t len
)
651 if (wpa_s
->driver
->send_tdls_mgmt
) {
652 return wpa_s
->driver
->send_tdls_mgmt(wpa_s
->drv_priv
, dst
,
653 action_code
, dialog_token
,
654 status_code
, buf
, len
);
659 static inline int wpa_drv_tdls_oper(struct wpa_supplicant
*wpa_s
,
660 enum tdls_oper oper
, const u8
*peer
)
662 if (!wpa_s
->driver
->tdls_oper
)
664 return wpa_s
->driver
->tdls_oper(wpa_s
->drv_priv
, oper
, peer
);
667 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant
*wpa_s
,
668 const u8
*kek
, const u8
*kck
,
669 const u8
*replay_ctr
)
671 if (!wpa_s
->driver
->set_rekey_info
)
673 wpa_s
->driver
->set_rekey_info(wpa_s
->drv_priv
, kek
, kck
, replay_ctr
);
676 static inline int wpa_drv_radio_disable(struct wpa_supplicant
*wpa_s
,
679 if (!wpa_s
->driver
->radio_disable
)
681 return wpa_s
->driver
->radio_disable(wpa_s
->drv_priv
, disabled
);
684 static inline int wpa_drv_switch_channel(struct wpa_supplicant
*wpa_s
,
687 if (!wpa_s
->driver
->switch_channel
)
689 return wpa_s
->driver
->switch_channel(wpa_s
->drv_priv
, freq
);
692 static inline int wpa_drv_wnm_oper(struct wpa_supplicant
*wpa_s
,
693 enum wnm_oper oper
, const u8
*peer
,
694 u8
*buf
, u16
*buf_len
)
696 if (!wpa_s
->driver
->wnm_oper
)
698 return wpa_s
->driver
->wnm_oper(wpa_s
->drv_priv
, oper
, peer
, buf
,
702 #endif /* DRIVER_I_H */