$search
00001 /* 00002 * wpa_supplicant - Internal driver interface wrappers 00003 * Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation. 00008 * 00009 * Alternatively, this software may be distributed under the terms of BSD 00010 * license. 00011 * 00012 * See README and COPYING for more details. 00013 */ 00014 00015 #ifndef DRIVER_I_H 00016 #define DRIVER_I_H 00017 00018 #include "drivers/driver.h" 00019 00020 /* driver_ops */ 00021 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s, 00022 const char *ifname) 00023 { 00024 if (wpa_s->driver->init2) 00025 return wpa_s->driver->init2(wpa_s, ifname, 00026 wpa_s->global_drv_priv); 00027 if (wpa_s->driver->init) { 00028 return wpa_s->driver->init(wpa_s, ifname); 00029 } 00030 return NULL; 00031 } 00032 00033 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s) 00034 { 00035 if (wpa_s->driver->deinit) 00036 wpa_s->driver->deinit(wpa_s->drv_priv); 00037 } 00038 00039 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s, 00040 const char *param) 00041 { 00042 if (wpa_s->driver->set_param) 00043 return wpa_s->driver->set_param(wpa_s->drv_priv, param); 00044 return 0; 00045 } 00046 00047 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s, 00048 int enabled) 00049 { 00050 if (wpa_s->driver->set_countermeasures) { 00051 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv, 00052 enabled); 00053 } 00054 return -1; 00055 } 00056 00057 static inline int wpa_drv_authenticate(struct wpa_supplicant *wpa_s, 00058 struct wpa_driver_auth_params *params) 00059 { 00060 if (wpa_s->driver->authenticate) 00061 return wpa_s->driver->authenticate(wpa_s->drv_priv, params); 00062 return -1; 00063 } 00064 00065 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s, 00066 struct wpa_driver_associate_params *params) 00067 { 00068 if (wpa_s->driver->associate) { 00069 return wpa_s->driver->associate(wpa_s->drv_priv, params); 00070 } 00071 return -1; 00072 } 00073 00074 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, 00075 struct wpa_driver_scan_params *params) 00076 { 00077 if (wpa_s->driver->scan2) 00078 return wpa_s->driver->scan2(wpa_s->drv_priv, params); 00079 return -1; 00080 } 00081 00082 static inline struct wpa_scan_results * wpa_drv_get_scan_results2( 00083 struct wpa_supplicant *wpa_s) 00084 { 00085 if (wpa_s->driver->get_scan_results2) 00086 return wpa_s->driver->get_scan_results2(wpa_s->drv_priv); 00087 return NULL; 00088 } 00089 00090 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid) 00091 { 00092 if (wpa_s->driver->get_bssid) { 00093 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid); 00094 } 00095 return -1; 00096 } 00097 00098 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid) 00099 { 00100 if (wpa_s->driver->get_ssid) { 00101 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid); 00102 } 00103 return -1; 00104 } 00105 00106 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, 00107 enum wpa_alg alg, const u8 *addr, 00108 int key_idx, int set_tx, 00109 const u8 *seq, size_t seq_len, 00110 const u8 *key, size_t key_len) 00111 { 00112 if (wpa_s->driver->set_key) { 00113 wpa_s->keys_cleared = 0; 00114 return wpa_s->driver->set_key(wpa_s->ifname, wpa_s->drv_priv, 00115 alg, addr, key_idx, set_tx, 00116 seq, seq_len, key, key_len); 00117 } 00118 return -1; 00119 } 00120 00121 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s, 00122 const u8 *addr, int reason_code) 00123 { 00124 if (wpa_s->driver->deauthenticate) { 00125 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr, 00126 reason_code); 00127 } 00128 return -1; 00129 } 00130 00131 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s, 00132 const u8 *addr, int reason_code) 00133 { 00134 if (wpa_s->driver->disassociate) { 00135 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr, 00136 reason_code); 00137 } 00138 return -1; 00139 } 00140 00141 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s, 00142 const u8 *bssid, const u8 *pmkid) 00143 { 00144 if (wpa_s->driver->add_pmkid) { 00145 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid); 00146 } 00147 return -1; 00148 } 00149 00150 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s, 00151 const u8 *bssid, const u8 *pmkid) 00152 { 00153 if (wpa_s->driver->remove_pmkid) { 00154 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid, 00155 pmkid); 00156 } 00157 return -1; 00158 } 00159 00160 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s) 00161 { 00162 if (wpa_s->driver->flush_pmkid) { 00163 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv); 00164 } 00165 return -1; 00166 } 00167 00168 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s, 00169 struct wpa_driver_capa *capa) 00170 { 00171 if (wpa_s->driver->get_capa) { 00172 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa); 00173 } 00174 return -1; 00175 } 00176 00177 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s) 00178 { 00179 if (wpa_s->driver->poll) { 00180 wpa_s->driver->poll(wpa_s->drv_priv); 00181 } 00182 } 00183 00184 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s) 00185 { 00186 if (wpa_s->driver->get_ifname) { 00187 return wpa_s->driver->get_ifname(wpa_s->drv_priv); 00188 } 00189 return NULL; 00190 } 00191 00192 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s) 00193 { 00194 if (wpa_s->driver->get_mac_addr) { 00195 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv); 00196 } 00197 return NULL; 00198 } 00199 00200 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s, 00201 const u8 *dst, u16 proto, 00202 const u8 *data, size_t data_len) 00203 { 00204 if (wpa_s->driver->send_eapol) 00205 return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto, 00206 data, data_len); 00207 return -1; 00208 } 00209 00210 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s, 00211 int state) 00212 { 00213 if (wpa_s->driver->set_operstate) 00214 return wpa_s->driver->set_operstate(wpa_s->drv_priv, state); 00215 return 0; 00216 } 00217 00218 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s, 00219 const u8 *addr, int protect_type, 00220 int key_type) 00221 { 00222 if (wpa_s->driver->mlme_setprotection) 00223 return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr, 00224 protect_type, 00225 key_type); 00226 return 0; 00227 } 00228 00229 static inline struct hostapd_hw_modes * 00230 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes, 00231 u16 *flags) 00232 { 00233 if (wpa_s->driver->get_hw_feature_data) 00234 return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv, 00235 num_modes, flags); 00236 return NULL; 00237 } 00238 00239 static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s, 00240 enum hostapd_hw_mode phymode, int chan, 00241 int freq) 00242 { 00243 if (wpa_s->driver->set_channel) 00244 return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode, 00245 chan, freq); 00246 return -1; 00247 } 00248 00249 static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s, 00250 const u8 *ssid, size_t ssid_len) 00251 { 00252 if (wpa_s->driver->set_ssid) { 00253 return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid, 00254 ssid_len); 00255 } 00256 return -1; 00257 } 00258 00259 static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s, 00260 const u8 *bssid) 00261 { 00262 if (wpa_s->driver->set_bssid) { 00263 return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid); 00264 } 00265 return -1; 00266 } 00267 00268 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s, 00269 const char *alpha2) 00270 { 00271 if (wpa_s->driver->set_country) 00272 return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2); 00273 return 0; 00274 } 00275 00276 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s, 00277 const u8 *data, size_t data_len) 00278 { 00279 if (wpa_s->driver->send_mlme) 00280 return wpa_s->driver->send_mlme(wpa_s->drv_priv, 00281 data, data_len); 00282 return -1; 00283 } 00284 00285 static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s, 00286 const u8 *addr, const u8 *supp_rates, 00287 size_t supp_rates_len) 00288 { 00289 if (wpa_s->driver->mlme_add_sta) 00290 return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr, 00291 supp_rates, supp_rates_len); 00292 return -1; 00293 } 00294 00295 static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s, 00296 const u8 *addr) 00297 { 00298 if (wpa_s->driver->mlme_remove_sta) 00299 return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr); 00300 return -1; 00301 } 00302 00303 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s, 00304 const u8 *md, 00305 const u8 *ies, size_t ies_len) 00306 { 00307 if (wpa_s->driver->update_ft_ies) 00308 return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md, 00309 ies, ies_len); 00310 return -1; 00311 } 00312 00313 static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s, 00314 u8 action, const u8 *target_ap, 00315 const u8 *ies, size_t ies_len) 00316 { 00317 if (wpa_s->driver->send_ft_action) 00318 return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action, 00319 target_ap, ies, ies_len); 00320 return -1; 00321 } 00322 00323 static inline int wpa_drv_set_beacon(struct wpa_supplicant *wpa_s, 00324 const u8 *head, size_t head_len, 00325 const u8 *tail, size_t tail_len, 00326 int dtim_period, int beacon_int) 00327 { 00328 if (wpa_s->driver->set_beacon) 00329 return wpa_s->driver->set_beacon(wpa_s->drv_priv, head, 00330 head_len, tail, tail_len, 00331 dtim_period, beacon_int); 00332 return -1; 00333 } 00334 00335 static inline int wpa_drv_sta_add(struct wpa_supplicant *wpa_s, 00336 struct hostapd_sta_add_params *params) 00337 { 00338 if (wpa_s->driver->sta_add) 00339 return wpa_s->driver->sta_add(wpa_s->drv_priv, params); 00340 return -1; 00341 } 00342 00343 static inline int wpa_drv_sta_remove(struct wpa_supplicant *wpa_s, 00344 const u8 *addr) 00345 { 00346 if (wpa_s->driver->sta_remove) 00347 return wpa_s->driver->sta_remove(wpa_s->drv_priv, addr); 00348 return -1; 00349 } 00350 00351 static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant *wpa_s, 00352 const u8 *addr, const u8 *data, 00353 size_t data_len, int encrypt, 00354 const u8 *own_addr) 00355 { 00356 if (wpa_s->driver->hapd_send_eapol) 00357 return wpa_s->driver->hapd_send_eapol(wpa_s->drv_priv, addr, 00358 data, data_len, encrypt, 00359 own_addr); 00360 return -1; 00361 } 00362 00363 static inline int wpa_drv_sta_set_flags(struct wpa_supplicant *wpa_s, 00364 const u8 *addr, int total_flags, 00365 int flags_or, int flags_and) 00366 { 00367 if (wpa_s->driver->sta_set_flags) 00368 return wpa_s->driver->sta_set_flags(wpa_s->drv_priv, addr, 00369 total_flags, flags_or, 00370 flags_and); 00371 return -1; 00372 } 00373 00374 static inline int wpa_drv_set_supp_port(struct wpa_supplicant *wpa_s, 00375 int authorized) 00376 { 00377 if (wpa_s->driver->set_supp_port) { 00378 return wpa_s->driver->set_supp_port(wpa_s->drv_priv, 00379 authorized); 00380 } 00381 return 0; 00382 } 00383 00384 static inline int wpa_drv_send_action(struct wpa_supplicant *wpa_s, 00385 unsigned int freq, 00386 const u8 *dst, const u8 *src, 00387 const u8 *bssid, 00388 const u8 *data, size_t data_len) 00389 { 00390 if (wpa_s->driver->send_action) 00391 return wpa_s->driver->send_action(wpa_s->drv_priv, freq, 00392 dst, src, bssid, data, 00393 data_len); 00394 return -1; 00395 } 00396 00397 static inline int wpa_drv_if_add(struct wpa_supplicant *wpa_s, 00398 enum wpa_driver_if_type type, 00399 const char *ifname, const u8 *addr, 00400 void *bss_ctx, char *force_ifname, 00401 u8 *if_addr) 00402 { 00403 if (wpa_s->driver->if_add) 00404 return wpa_s->driver->if_add(wpa_s->drv_priv, type, ifname, 00405 addr, bss_ctx, NULL, force_ifname, 00406 if_addr); 00407 return -1; 00408 } 00409 00410 static inline int wpa_drv_if_remove(struct wpa_supplicant *wpa_s, 00411 enum wpa_driver_if_type type, 00412 const char *ifname) 00413 { 00414 if (wpa_s->driver->if_remove) 00415 return wpa_s->driver->if_remove(wpa_s->drv_priv, type, ifname); 00416 return -1; 00417 } 00418 00419 static inline int wpa_drv_remain_on_channel(struct wpa_supplicant *wpa_s, 00420 unsigned int freq, 00421 unsigned int duration) 00422 { 00423 if (wpa_s->driver->remain_on_channel) 00424 return wpa_s->driver->remain_on_channel(wpa_s->drv_priv, freq, 00425 duration); 00426 return -1; 00427 } 00428 00429 static inline int wpa_drv_cancel_remain_on_channel( 00430 struct wpa_supplicant *wpa_s) 00431 { 00432 if (wpa_s->driver->cancel_remain_on_channel) 00433 return wpa_s->driver->cancel_remain_on_channel( 00434 wpa_s->drv_priv); 00435 return -1; 00436 } 00437 00438 static inline int wpa_drv_probe_req_report(struct wpa_supplicant *wpa_s, 00439 int report) 00440 { 00441 if (wpa_s->driver->probe_req_report) 00442 return wpa_s->driver->probe_req_report(wpa_s->drv_priv, 00443 report); 00444 return -1; 00445 } 00446 00447 static inline int wpa_drv_disable_11b_rates(struct wpa_supplicant *wpa_s, 00448 int disabled) 00449 { 00450 if (wpa_s->driver->disable_11b_rates) 00451 return wpa_s->driver->disable_11b_rates(wpa_s->drv_priv, 00452 disabled); 00453 return -1; 00454 } 00455 00456 static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s) 00457 { 00458 if (wpa_s->driver->deinit_ap) 00459 return wpa_s->driver->deinit_ap(wpa_s->drv_priv); 00460 return 0; 00461 } 00462 00463 static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s) 00464 { 00465 if (wpa_s->driver->suspend) 00466 wpa_s->driver->suspend(wpa_s->drv_priv); 00467 } 00468 00469 static inline void wpa_drv_resume(struct wpa_supplicant *wpa_s) 00470 { 00471 if (wpa_s->driver->resume) 00472 wpa_s->driver->resume(wpa_s->drv_priv); 00473 } 00474 00475 static inline int wpa_drv_signal_monitor(struct wpa_supplicant *wpa_s, 00476 int threshold, int hysteresis) 00477 { 00478 if (wpa_s->driver->signal_monitor) 00479 return wpa_s->driver->signal_monitor(wpa_s->drv_priv, 00480 threshold, hysteresis); 00481 return -1; 00482 } 00483 00484 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s, 00485 const struct wpabuf *beacon, 00486 const struct wpabuf *proberesp) 00487 { 00488 if (!wpa_s->driver->set_ap_wps_ie) 00489 return -1; 00490 return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon, 00491 proberesp); 00492 } 00493 00494 #endif /* DRIVER_I_H */