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
,
26 wpa_s
->global_drv_priv
);
27 if (wpa_s
->driver
->init
) {
28 return wpa_s
->driver
->init(wpa_s
, ifname
);
33 static inline void wpa_drv_deinit(struct wpa_supplicant
*wpa_s
)
35 if (wpa_s
->driver
->deinit
)
36 wpa_s
->driver
->deinit(wpa_s
->drv_priv
);
39 static inline int wpa_drv_set_param(struct wpa_supplicant
*wpa_s
,
42 if (wpa_s
->driver
->set_param
)
43 return wpa_s
->driver
->set_param(wpa_s
->drv_priv
, param
);
47 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant
*wpa_s
,
50 if (wpa_s
->driver
->set_countermeasures
) {
51 return wpa_s
->driver
->set_countermeasures(wpa_s
->drv_priv
,
57 static inline int wpa_drv_authenticate(struct wpa_supplicant
*wpa_s
,
58 struct wpa_driver_auth_params
*params
)
60 if (wpa_s
->driver
->authenticate
)
61 return wpa_s
->driver
->authenticate(wpa_s
->drv_priv
, params
);
65 static inline int wpa_drv_associate(struct wpa_supplicant
*wpa_s
,
66 struct wpa_driver_associate_params
*params
)
68 if (wpa_s
->driver
->associate
) {
69 return wpa_s
->driver
->associate(wpa_s
->drv_priv
, params
);
74 static inline int wpa_drv_scan(struct wpa_supplicant
*wpa_s
,
75 struct wpa_driver_scan_params
*params
)
77 if (wpa_s
->driver
->scan2
)
78 return wpa_s
->driver
->scan2(wpa_s
->drv_priv
, params
);
82 static inline struct wpa_scan_results
* wpa_drv_get_scan_results2(
83 struct wpa_supplicant
*wpa_s
)
85 if (wpa_s
->driver
->get_scan_results2
)
86 return wpa_s
->driver
->get_scan_results2(wpa_s
->drv_priv
);
90 static inline int wpa_drv_get_bssid(struct wpa_supplicant
*wpa_s
, u8
*bssid
)
92 if (wpa_s
->driver
->get_bssid
) {
93 return wpa_s
->driver
->get_bssid(wpa_s
->drv_priv
, bssid
);
98 static inline int wpa_drv_get_ssid(struct wpa_supplicant
*wpa_s
, u8
*ssid
)
100 if (wpa_s
->driver
->get_ssid
) {
101 return wpa_s
->driver
->get_ssid(wpa_s
->drv_priv
, ssid
);
106 static inline int wpa_drv_set_key(struct wpa_supplicant
*wpa_s
,
107 enum wpa_alg alg
, const u8
*addr
,
108 int key_idx
, int set_tx
,
109 const u8
*seq
, size_t seq_len
,
110 const u8
*key
, size_t key_len
)
112 if (wpa_s
->driver
->set_key
) {
113 wpa_s
->keys_cleared
= 0;
114 return wpa_s
->driver
->set_key(wpa_s
->ifname
, wpa_s
->drv_priv
,
115 alg
, addr
, key_idx
, set_tx
,
116 seq
, seq_len
, key
, key_len
);
121 static inline int wpa_drv_deauthenticate(struct wpa_supplicant
*wpa_s
,
122 const u8
*addr
, int reason_code
)
124 if (wpa_s
->driver
->deauthenticate
) {
125 return wpa_s
->driver
->deauthenticate(wpa_s
->drv_priv
, addr
,
131 static inline int wpa_drv_disassociate(struct wpa_supplicant
*wpa_s
,
132 const u8
*addr
, int reason_code
)
134 if (wpa_s
->driver
->disassociate
) {
135 return wpa_s
->driver
->disassociate(wpa_s
->drv_priv
, addr
,
141 static inline int wpa_drv_add_pmkid(struct wpa_supplicant
*wpa_s
,
142 const u8
*bssid
, const u8
*pmkid
)
144 if (wpa_s
->driver
->add_pmkid
) {
145 return wpa_s
->driver
->add_pmkid(wpa_s
->drv_priv
, bssid
, pmkid
);
150 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant
*wpa_s
,
151 const u8
*bssid
, const u8
*pmkid
)
153 if (wpa_s
->driver
->remove_pmkid
) {
154 return wpa_s
->driver
->remove_pmkid(wpa_s
->drv_priv
, bssid
,
160 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant
*wpa_s
)
162 if (wpa_s
->driver
->flush_pmkid
) {
163 return wpa_s
->driver
->flush_pmkid(wpa_s
->drv_priv
);
168 static inline int wpa_drv_get_capa(struct wpa_supplicant
*wpa_s
,
169 struct wpa_driver_capa
*capa
)
171 if (wpa_s
->driver
->get_capa
) {
172 return wpa_s
->driver
->get_capa(wpa_s
->drv_priv
, capa
);
177 static inline void wpa_drv_poll(struct wpa_supplicant
*wpa_s
)
179 if (wpa_s
->driver
->poll
) {
180 wpa_s
->driver
->poll(wpa_s
->drv_priv
);
184 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant
*wpa_s
)
186 if (wpa_s
->driver
->get_ifname
) {
187 return wpa_s
->driver
->get_ifname(wpa_s
->drv_priv
);
192 static inline const u8
* wpa_drv_get_mac_addr(struct wpa_supplicant
*wpa_s
)
194 if (wpa_s
->driver
->get_mac_addr
) {
195 return wpa_s
->driver
->get_mac_addr(wpa_s
->drv_priv
);
200 static inline int wpa_drv_send_eapol(struct wpa_supplicant
*wpa_s
,
201 const u8
*dst
, u16 proto
,
202 const u8
*data
, size_t data_len
)
204 if (wpa_s
->driver
->send_eapol
)
205 return wpa_s
->driver
->send_eapol(wpa_s
->drv_priv
, dst
, proto
,
210 static inline int wpa_drv_set_operstate(struct wpa_supplicant
*wpa_s
,
213 if (wpa_s
->driver
->set_operstate
)
214 return wpa_s
->driver
->set_operstate(wpa_s
->drv_priv
, state
);
218 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant
*wpa_s
,
219 const u8
*addr
, int protect_type
,
222 if (wpa_s
->driver
->mlme_setprotection
)
223 return wpa_s
->driver
->mlme_setprotection(wpa_s
->drv_priv
, addr
,
229 static inline struct hostapd_hw_modes
*
230 wpa_drv_get_hw_feature_data(struct wpa_supplicant
*wpa_s
, u16
*num_modes
,
233 if (wpa_s
->driver
->get_hw_feature_data
)
234 return wpa_s
->driver
->get_hw_feature_data(wpa_s
->drv_priv
,
239 static inline int wpa_drv_set_channel(struct wpa_supplicant
*wpa_s
,
240 enum hostapd_hw_mode phymode
, int chan
,
243 if (wpa_s
->driver
->set_channel
)
244 return wpa_s
->driver
->set_channel(wpa_s
->drv_priv
, phymode
,
249 static inline int wpa_drv_set_ssid(struct wpa_supplicant
*wpa_s
,
250 const u8
*ssid
, size_t ssid_len
)
252 if (wpa_s
->driver
->set_ssid
) {
253 return wpa_s
->driver
->set_ssid(wpa_s
->drv_priv
, ssid
,
259 static inline int wpa_drv_set_bssid(struct wpa_supplicant
*wpa_s
,
262 if (wpa_s
->driver
->set_bssid
) {
263 return wpa_s
->driver
->set_bssid(wpa_s
->drv_priv
, bssid
);
268 static inline int wpa_drv_set_country(struct wpa_supplicant
*wpa_s
,
271 if (wpa_s
->driver
->set_country
)
272 return wpa_s
->driver
->set_country(wpa_s
->drv_priv
, alpha2
);
276 static inline int wpa_drv_send_mlme(struct wpa_supplicant
*wpa_s
,
277 const u8
*data
, size_t data_len
)
279 if (wpa_s
->driver
->send_mlme
)
280 return wpa_s
->driver
->send_mlme(wpa_s
->drv_priv
,
285 static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant
*wpa_s
,
286 const u8
*addr
, const u8
*supp_rates
,
287 size_t supp_rates_len
)
289 if (wpa_s
->driver
->mlme_add_sta
)
290 return wpa_s
->driver
->mlme_add_sta(wpa_s
->drv_priv
, addr
,
291 supp_rates
, supp_rates_len
);
295 static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant
*wpa_s
,
298 if (wpa_s
->driver
->mlme_remove_sta
)
299 return wpa_s
->driver
->mlme_remove_sta(wpa_s
->drv_priv
, addr
);
303 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant
*wpa_s
,
305 const u8
*ies
, size_t ies_len
)
307 if (wpa_s
->driver
->update_ft_ies
)
308 return wpa_s
->driver
->update_ft_ies(wpa_s
->drv_priv
, md
,
313 static inline int wpa_drv_send_ft_action(struct wpa_supplicant
*wpa_s
,
314 u8 action
, const u8
*target_ap
,
315 const u8
*ies
, size_t ies_len
)
317 if (wpa_s
->driver
->send_ft_action
)
318 return wpa_s
->driver
->send_ft_action(wpa_s
->drv_priv
, action
,
319 target_ap
, ies
, ies_len
);
323 static inline int wpa_drv_set_beacon(struct wpa_supplicant
*wpa_s
,
324 const u8
*head
, size_t head_len
,
325 const u8
*tail
, size_t tail_len
,
326 int dtim_period
, int beacon_int
)
328 if (wpa_s
->driver
->set_beacon
)
329 return wpa_s
->driver
->set_beacon(wpa_s
->ifname
,
330 wpa_s
->drv_priv
, head
,
331 head_len
, tail
, tail_len
,
332 dtim_period
, beacon_int
);
336 static inline int wpa_drv_sta_add(struct wpa_supplicant
*wpa_s
,
337 struct hostapd_sta_add_params
*params
)
339 if (wpa_s
->driver
->sta_add
)
340 return wpa_s
->driver
->sta_add(wpa_s
->ifname
, wpa_s
->drv_priv
,
345 static inline int wpa_drv_sta_remove(struct wpa_supplicant
*wpa_s
,
348 if (wpa_s
->driver
->sta_remove
)
349 return wpa_s
->driver
->sta_remove(wpa_s
->drv_priv
, addr
);
353 static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant
*wpa_s
,
354 const u8
*addr
, const u8
*data
,
355 size_t data_len
, int encrypt
,
358 if (wpa_s
->driver
->hapd_send_eapol
)
359 return wpa_s
->driver
->hapd_send_eapol(wpa_s
->drv_priv
, addr
,
360 data
, data_len
, encrypt
,
365 static inline int wpa_drv_sta_set_flags(struct wpa_supplicant
*wpa_s
,
366 const u8
*addr
, int total_flags
,
367 int flags_or
, int flags_and
)
369 if (wpa_s
->driver
->sta_set_flags
)
370 return wpa_s
->driver
->sta_set_flags(wpa_s
->drv_priv
, addr
,
371 total_flags
, flags_or
,
376 static inline int wpa_drv_set_supp_port(struct wpa_supplicant
*wpa_s
,
379 if (wpa_s
->driver
->set_supp_port
) {
380 return wpa_s
->driver
->set_supp_port(wpa_s
->drv_priv
,
386 static inline int wpa_drv_send_action(struct wpa_supplicant
*wpa_s
,
388 const u8
*dst
, const u8
*src
,
389 const u8
*data
, size_t data_len
)
391 if (wpa_s
->driver
->send_action
)
392 return wpa_s
->driver
->send_action(wpa_s
->drv_priv
, freq
,
393 dst
, src
, data
, data_len
);
397 static inline int wpa_drv_alloc_interface_addr(struct wpa_supplicant
*wpa_s
,
400 if (wpa_s
->driver
->alloc_interface_addr
)
401 return wpa_s
->driver
->alloc_interface_addr(wpa_s
->drv_priv
,
406 static inline void wpa_drv_release_interface_addr(struct wpa_supplicant
*wpa_s
,
409 if (wpa_s
->driver
->release_interface_addr
)
410 wpa_s
->driver
->release_interface_addr(wpa_s
->drv_priv
, addr
);
413 static inline int wpa_drv_remain_on_channel(struct wpa_supplicant
*wpa_s
,
415 unsigned int duration
)
417 if (wpa_s
->driver
->remain_on_channel
)
418 return wpa_s
->driver
->remain_on_channel(wpa_s
->drv_priv
, freq
,
423 static inline int wpa_drv_cancel_remain_on_channel(
424 struct wpa_supplicant
*wpa_s
)
426 if (wpa_s
->driver
->cancel_remain_on_channel
)
427 return wpa_s
->driver
->cancel_remain_on_channel(
432 static inline int wpa_drv_probe_req_report(struct wpa_supplicant
*wpa_s
,
435 if (wpa_s
->driver
->probe_req_report
)
436 return wpa_s
->driver
->probe_req_report(wpa_s
->drv_priv
,
441 #endif /* DRIVER_I_H */