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, wpa_s->bssid);
474 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
475 const struct wpabuf *beacon,
476 const struct wpabuf *proberesp,
477 const struct wpabuf *assocresp)
479 if (!wpa_s->driver->set_ap_wps_ie)
481 return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon,
482 proberesp, assocresp);
485 static inline int wpa_drv_shared_freq(struct wpa_supplicant *wpa_s)
487 if (!wpa_s->driver->shared_freq)
489 return wpa_s->driver->shared_freq(wpa_s->drv_priv);
492 static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
493 u8 *buf, size_t buf_len)
495 if (!wpa_s->driver->get_noa)
497 return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len);
500 static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,
501 int legacy_ps, int opp_ps,
504 if (!wpa_s->driver->set_p2p_powersave)
506 return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,
510 static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu)
512 if (!wpa_s->driver->ampdu)
514 return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu);
517 static inline int wpa_drv_p2p_find(struct wpa_supplicant *wpa_s,
518 unsigned int timeout, int type)
520 if (!wpa_s->driver->p2p_find)
522 return wpa_s->driver->p2p_find(wpa_s->drv_priv, timeout, type);
525 static inline int wpa_drv_p2p_stop_find(struct wpa_supplicant *wpa_s)
527 if (!wpa_s->driver->p2p_stop_find)
529 return wpa_s->driver->p2p_stop_find(wpa_s->drv_priv);
532 static inline int wpa_drv_p2p_listen(struct wpa_supplicant *wpa_s,
533 unsigned int timeout)
535 if (!wpa_s->driver->p2p_listen)
537 return wpa_s->driver->p2p_listen(wpa_s->drv_priv, timeout);
540 static inline int wpa_drv_p2p_connect(struct wpa_supplicant *wpa_s,
541 const u8 *peer_addr, int wps_method,
543 const u8 *own_interface_addr,
544 unsigned int force_freq,
545 int persistent_group)
547 if (!wpa_s->driver->p2p_connect)
549 return wpa_s->driver->p2p_connect(wpa_s->drv_priv, peer_addr,
550 wps_method, go_intent,
551 own_interface_addr, force_freq,
555 static inline int wpa_drv_wps_success_cb(struct wpa_supplicant *wpa_s,
558 if (!wpa_s->driver->wps_success_cb)
560 return wpa_s->driver->wps_success_cb(wpa_s->drv_priv, peer_addr);
564 wpa_drv_p2p_group_formation_failed(struct wpa_supplicant *wpa_s)
566 if (!wpa_s->driver->p2p_group_formation_failed)
568 return wpa_s->driver->p2p_group_formation_failed(wpa_s->drv_priv);
571 static inline int wpa_drv_p2p_set_params(struct wpa_supplicant *wpa_s,
572 const struct p2p_params *params)
574 if (!wpa_s->driver->p2p_set_params)
576 return wpa_s->driver->p2p_set_params(wpa_s->drv_priv, params);
579 static inline int wpa_drv_p2p_prov_disc_req(struct wpa_supplicant *wpa_s,
581 u16 config_methods, int join)
583 if (!wpa_s->driver->p2p_prov_disc_req)
585 return wpa_s->driver->p2p_prov_disc_req(wpa_s->drv_priv, peer_addr,
586 config_methods, join);
589 static inline u64 wpa_drv_p2p_sd_request(struct wpa_supplicant *wpa_s,
591 const struct wpabuf *tlvs)
593 if (!wpa_s->driver->p2p_sd_request)
595 return wpa_s->driver->p2p_sd_request(wpa_s->drv_priv, dst, tlvs);
598 static inline int wpa_drv_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s,
601 if (!wpa_s->driver->p2p_sd_cancel_request)
603 return wpa_s->driver->p2p_sd_cancel_request(wpa_s->drv_priv, req);
606 static inline int wpa_drv_p2p_sd_response(struct wpa_supplicant *wpa_s,
607 int freq, const u8 *dst,
609 const struct wpabuf *resp_tlvs)
611 if (!wpa_s->driver->p2p_sd_response)
613 return wpa_s->driver->p2p_sd_response(wpa_s->drv_priv, freq, dst,
614 dialog_token, resp_tlvs);
617 static inline int wpa_drv_p2p_service_update(struct wpa_supplicant *wpa_s)
619 if (!wpa_s->driver->p2p_service_update)
621 return wpa_s->driver->p2p_service_update(wpa_s->drv_priv);
624 static inline int wpa_drv_p2p_reject(struct wpa_supplicant *wpa_s,
627 if (!wpa_s->driver->p2p_reject)
629 return wpa_s->driver->p2p_reject(wpa_s->drv_priv, addr);
632 static inline int wpa_drv_p2p_invite(struct wpa_supplicant *wpa_s,
633 const u8 *peer, int role, const u8 *bssid,
634 const u8 *ssid, size_t ssid_len,
635 const u8 *go_dev_addr,
636 int persistent_group)
638 if (!wpa_s->driver->p2p_invite)
640 return wpa_s->driver->p2p_invite(wpa_s->drv_priv, peer, role, bssid,
641 ssid, ssid_len, go_dev_addr,
645 static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s,
646 const u8 *dst, u8 action_code,
647 u8 dialog_token, u16 status_code,
648 const u8 *buf, size_t len)
650 if (wpa_s->driver->send_tdls_mgmt) {
651 return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst,
652 action_code, dialog_token,
653 status_code, buf, len);
658 static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
659 enum tdls_oper oper, const u8 *peer)
661 if (!wpa_s->driver->tdls_oper)
663 return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
667 static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
668 char *cmd, char *buf, size_t buf_len)
670 if (!wpa_s->driver->driver_cmd)
672 return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
676 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
677 const u8 *kek, const u8 *kck,
678 const u8 *replay_ctr)
680 if (!wpa_s->driver->set_rekey_info)
682 wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kck, replay_ctr);
685 static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s,
688 if (!wpa_s->driver->radio_disable)
690 return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled);
693 static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s,
696 if (!wpa_s->driver->switch_channel)
698 return wpa_s->driver->switch_channel(wpa_s->drv_priv, freq);
701 #endif /* DRIVER_I_H */