2 * wpa_supplicant - Internal driver interface wrappers
3 * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #include "drivers/driver.h"
21 static inline void * wpa_drv_init(struct wpa_supplicant
*wpa_s
,
24 if (wpa_s
->driver
->init2
)
25 return wpa_s
->driver
->init2(wpa_s
, ifname
, wpa_s
->global
);
26 if (wpa_s
->driver
->init
) {
27 return wpa_s
->driver
->init(wpa_s
, ifname
);
32 static inline void wpa_drv_deinit(struct wpa_supplicant
*wpa_s
)
34 if (wpa_s
->driver
->deinit
)
35 wpa_s
->driver
->deinit(wpa_s
->drv_priv
);
38 static inline int wpa_drv_set_param(struct wpa_supplicant
*wpa_s
,
41 if (wpa_s
->driver
->set_param
)
42 return wpa_s
->driver
->set_param(wpa_s
->drv_priv
, param
);
46 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant
*wpa_s
,
49 if (wpa_s
->driver
->set_drop_unencrypted
) {
50 return wpa_s
->driver
->set_drop_unencrypted(wpa_s
->drv_priv
,
56 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant
*wpa_s
,
59 if (wpa_s
->driver
->set_countermeasures
) {
60 return wpa_s
->driver
->set_countermeasures(wpa_s
->drv_priv
,
66 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant
*wpa_s
,
69 if (wpa_s
->driver
->set_auth_alg
) {
70 return wpa_s
->driver
->set_auth_alg(wpa_s
->drv_priv
,
76 static inline int wpa_drv_set_wpa(struct wpa_supplicant
*wpa_s
, int enabled
)
78 if (wpa_s
->driver
->set_wpa
) {
79 return wpa_s
->driver
->set_wpa(wpa_s
->drv_priv
, enabled
);
84 static inline int wpa_drv_set_mode(struct wpa_supplicant
*wpa_s
, int mode
)
86 if (wpa_s
->driver
->set_mode
) {
87 return wpa_s
->driver
->set_mode(wpa_s
->drv_priv
, mode
);
92 static inline int wpa_drv_authenticate(struct wpa_supplicant
*wpa_s
,
93 struct wpa_driver_auth_params
*params
)
95 if (wpa_s
->driver
->authenticate
)
96 return wpa_s
->driver
->authenticate(wpa_s
->drv_priv
, params
);
100 static inline int wpa_drv_associate(struct wpa_supplicant
*wpa_s
,
101 struct wpa_driver_associate_params
*params
)
103 if (wpa_s
->driver
->associate
) {
104 return wpa_s
->driver
->associate(wpa_s
->drv_priv
, params
);
109 static inline int wpa_drv_scan(struct wpa_supplicant
*wpa_s
,
110 struct wpa_driver_scan_params
*params
)
112 if (wpa_s
->driver
->scan2
)
113 return wpa_s
->driver
->scan2(wpa_s
->drv_priv
, params
);
114 if (wpa_s
->driver
->scan
)
115 return wpa_s
->driver
->scan(wpa_s
->drv_priv
,
116 params
->ssids
[0].ssid
,
117 params
->ssids
[0].ssid_len
);
121 static inline int wpa_drv_get_scan_results(struct wpa_supplicant
*wpa_s
,
122 struct wpa_scan_result
*results
,
125 if (wpa_s
->driver
->get_scan_results
) {
126 return wpa_s
->driver
->get_scan_results(wpa_s
->drv_priv
,
132 static inline struct wpa_scan_results
* wpa_drv_get_scan_results2(
133 struct wpa_supplicant
*wpa_s
)
135 if (wpa_s
->driver
->get_scan_results2
)
136 return wpa_s
->driver
->get_scan_results2(wpa_s
->drv_priv
);
140 static inline int wpa_drv_get_bssid(struct wpa_supplicant
*wpa_s
, u8
*bssid
)
142 if (wpa_s
->driver
->get_bssid
) {
143 return wpa_s
->driver
->get_bssid(wpa_s
->drv_priv
, bssid
);
148 static inline int wpa_drv_get_ssid(struct wpa_supplicant
*wpa_s
, u8
*ssid
)
150 if (wpa_s
->driver
->get_ssid
) {
151 return wpa_s
->driver
->get_ssid(wpa_s
->drv_priv
, ssid
);
156 static inline int wpa_drv_set_key(struct wpa_supplicant
*wpa_s
, wpa_alg alg
,
157 const u8
*addr
, int key_idx
, int set_tx
,
158 const u8
*seq
, size_t seq_len
,
159 const u8
*key
, size_t key_len
)
161 if (wpa_s
->driver
->set_key
) {
162 wpa_s
->keys_cleared
= 0;
163 return wpa_s
->driver
->set_key(wpa_s
->drv_priv
, alg
, addr
,
164 key_idx
, set_tx
, seq
, seq_len
,
170 static inline int wpa_drv_deauthenticate(struct wpa_supplicant
*wpa_s
,
171 const u8
*addr
, int reason_code
)
173 if (wpa_s
->driver
->deauthenticate
) {
174 return wpa_s
->driver
->deauthenticate(wpa_s
->drv_priv
, addr
,
180 static inline int wpa_drv_disassociate(struct wpa_supplicant
*wpa_s
,
181 const u8
*addr
, int reason_code
)
183 if (wpa_s
->driver
->disassociate
) {
184 return wpa_s
->driver
->disassociate(wpa_s
->drv_priv
, addr
,
190 static inline int wpa_drv_add_pmkid(struct wpa_supplicant
*wpa_s
,
191 const u8
*bssid
, const u8
*pmkid
)
193 if (wpa_s
->driver
->add_pmkid
) {
194 return wpa_s
->driver
->add_pmkid(wpa_s
->drv_priv
, bssid
, pmkid
);
199 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant
*wpa_s
,
200 const u8
*bssid
, const u8
*pmkid
)
202 if (wpa_s
->driver
->remove_pmkid
) {
203 return wpa_s
->driver
->remove_pmkid(wpa_s
->drv_priv
, bssid
,
209 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant
*wpa_s
)
211 if (wpa_s
->driver
->flush_pmkid
) {
212 return wpa_s
->driver
->flush_pmkid(wpa_s
->drv_priv
);
217 static inline int wpa_drv_get_capa(struct wpa_supplicant
*wpa_s
,
218 struct wpa_driver_capa
*capa
)
220 if (wpa_s
->driver
->get_capa
) {
221 return wpa_s
->driver
->get_capa(wpa_s
->drv_priv
, capa
);
226 static inline void wpa_drv_poll(struct wpa_supplicant
*wpa_s
)
228 if (wpa_s
->driver
->poll
) {
229 wpa_s
->driver
->poll(wpa_s
->drv_priv
);
233 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant
*wpa_s
)
235 if (wpa_s
->driver
->get_ifname
) {
236 return wpa_s
->driver
->get_ifname(wpa_s
->drv_priv
);
241 static inline const u8
* wpa_drv_get_mac_addr(struct wpa_supplicant
*wpa_s
)
243 if (wpa_s
->driver
->get_mac_addr
) {
244 return wpa_s
->driver
->get_mac_addr(wpa_s
->drv_priv
);
249 static inline int wpa_drv_send_eapol(struct wpa_supplicant
*wpa_s
,
250 const u8
*dst
, u16 proto
,
251 const u8
*data
, size_t data_len
)
253 if (wpa_s
->driver
->send_eapol
)
254 return wpa_s
->driver
->send_eapol(wpa_s
->drv_priv
, dst
, proto
,
259 static inline int wpa_drv_set_operstate(struct wpa_supplicant
*wpa_s
,
262 if (wpa_s
->driver
->set_operstate
)
263 return wpa_s
->driver
->set_operstate(wpa_s
->drv_priv
, state
);
267 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant
*wpa_s
,
268 const u8
*addr
, int protect_type
,
271 if (wpa_s
->driver
->mlme_setprotection
)
272 return wpa_s
->driver
->mlme_setprotection(wpa_s
->drv_priv
, addr
,
278 static inline struct hostapd_hw_modes
*
279 wpa_drv_get_hw_feature_data(struct wpa_supplicant
*wpa_s
, u16
*num_modes
,
282 if (wpa_s
->driver
->get_hw_feature_data
)
283 return wpa_s
->driver
->get_hw_feature_data(wpa_s
->drv_priv
,
288 static inline int wpa_drv_set_channel(struct wpa_supplicant
*wpa_s
,
289 hostapd_hw_mode phymode
, int chan
,
292 if (wpa_s
->driver
->set_channel
)
293 return wpa_s
->driver
->set_channel(wpa_s
->drv_priv
, phymode
,
298 static inline int wpa_drv_set_ssid(struct wpa_supplicant
*wpa_s
,
299 const u8
*ssid
, size_t ssid_len
)
301 if (wpa_s
->driver
->set_ssid
) {
302 return wpa_s
->driver
->set_ssid(wpa_s
->drv_priv
, ssid
,
308 static inline int wpa_drv_set_bssid(struct wpa_supplicant
*wpa_s
,
311 if (wpa_s
->driver
->set_bssid
) {
312 return wpa_s
->driver
->set_bssid(wpa_s
->drv_priv
, bssid
);
317 static inline int wpa_drv_set_country(struct wpa_supplicant
*wpa_s
,
320 if (wpa_s
->driver
->set_country
)
321 return wpa_s
->driver
->set_country(wpa_s
->drv_priv
, alpha2
);
325 static inline int wpa_drv_send_mlme(struct wpa_supplicant
*wpa_s
,
326 const u8
*data
, size_t data_len
)
328 if (wpa_s
->driver
->send_mlme
)
329 return wpa_s
->driver
->send_mlme(wpa_s
->drv_priv
,
334 static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant
*wpa_s
,
335 const u8
*addr
, const u8
*supp_rates
,
336 size_t supp_rates_len
)
338 if (wpa_s
->driver
->mlme_add_sta
)
339 return wpa_s
->driver
->mlme_add_sta(wpa_s
->drv_priv
, addr
,
340 supp_rates
, supp_rates_len
);
344 static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant
*wpa_s
,
347 if (wpa_s
->driver
->mlme_remove_sta
)
348 return wpa_s
->driver
->mlme_remove_sta(wpa_s
->drv_priv
, addr
);
352 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant
*wpa_s
,
354 const u8
*ies
, size_t ies_len
)
356 if (wpa_s
->driver
->update_ft_ies
)
357 return wpa_s
->driver
->update_ft_ies(wpa_s
->drv_priv
, md
,
362 static inline int wpa_drv_send_ft_action(struct wpa_supplicant
*wpa_s
,
363 u8 action
, const u8
*target_ap
,
364 const u8
*ies
, size_t ies_len
)
366 if (wpa_s
->driver
->send_ft_action
)
367 return wpa_s
->driver
->send_ft_action(wpa_s
->drv_priv
, action
,
368 target_ap
, ies
, ies_len
);
372 static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant
*wpa_s
,
373 const u8
*ies
, size_t ies_len
)
375 if (wpa_s
->driver
->set_probe_req_ie
)
376 return wpa_s
->driver
->set_probe_req_ie(wpa_s
->drv_priv
, ies
,
381 static inline int wpa_drv_set_beacon(struct wpa_supplicant
*wpa_s
,
382 const u8
*head
, size_t head_len
,
383 const u8
*tail
, size_t tail_len
,
386 if (wpa_s
->driver
->set_beacon
)
387 return wpa_s
->driver
->set_beacon(wpa_s
->drv_priv
, head
,
388 head_len
, tail
, tail_len
,
393 static inline int wpa_drv_set_beacon_int(struct wpa_supplicant
*wpa_s
,
396 if (wpa_s
->driver
->set_beacon_int
)
397 return wpa_s
->driver
->set_beacon_int(wpa_s
->drv_priv
, value
);
401 #endif /* DRIVER_I_H */