00001
00016 #ifndef WPA_SUPPLICANT_I_H
00017 #define WPA_SUPPLICANT_I_H
00018
00019 #include "driver.h"
00020
00021 struct wpa_blacklist {
00022 struct wpa_blacklist *next;
00023 u8 bssid[ETH_ALEN];
00024 int count;
00025 };
00026
00027
00028 struct wpa_scan_result;
00029 struct wpa_sm;
00030 struct wpa_supplicant;
00031
00032
00033
00034
00035
00036
00037 struct ctrl_iface_priv;
00038 struct ctrl_iface_global_priv;
00039 struct ctrl_iface_dbus_priv;
00040
00045 struct wpa_interface {
00054 const char *confname;
00055
00066 const char *ctrl_interface;
00067
00072 const char *driver;
00073
00084 const char *driver_param;
00085
00090 const char *ifname;
00091
00101 const char *bridge_ifname;
00102 };
00103
00108 struct wpa_params {
00113 int daemonize;
00114
00125 int wait_for_interface;
00126
00131 int wait_for_monitor;
00132
00140 char *pid_file;
00141
00146 int wpa_debug_level;
00147
00158 int wpa_debug_show_keys;
00159
00164 int wpa_debug_timestamp;
00165
00170 char *ctrl_interface;
00171
00176 int dbus_ctrl_interface;
00177
00182 int wpa_debug_use_file;
00183 };
00184
00192 struct wpa_global {
00193 struct wpa_supplicant *ifaces;
00194 struct wpa_params params;
00195 struct ctrl_iface_global_priv *ctrl_iface;
00196 struct ctrl_iface_dbus_priv *dbus_ctrl_iface;
00197 };
00198
00199
00200 struct wpa_client_mlme {
00201 #ifdef CONFIG_CLIENT_MLME
00202 enum {
00203 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
00204 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
00205 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
00206 } state;
00207 u8 prev_bssid[ETH_ALEN];
00208 u8 ssid[32];
00209 size_t ssid_len;
00210 u16 aid;
00211 u16 ap_capab, capab;
00212 u8 *extra_ie;
00213 size_t extra_ie_len;
00214 wpa_key_mgmt key_mgmt;
00215
00216
00217 u8 *assocreq_ies, *assocresp_ies;
00218 size_t assocreq_ies_len, assocresp_ies_len;
00219
00220 int auth_tries, assoc_tries;
00221
00222 int ssid_set:1;
00223 int bssid_set:1;
00224 int prev_bssid_set:1;
00225 int authenticated:1;
00226 int associated:1;
00227 int probereq_poll:1;
00228 int use_protection:1;
00229 int create_ibss:1;
00230 int mixed_cell:1;
00231 int wmm_enabled:1;
00232
00233 struct os_time last_probe;
00234
00235 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
00236 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
00237 #define IEEE80211_AUTH_ALG_LEAP BIT(2)
00238 unsigned int auth_algs;
00239 int auth_alg;
00240 int auth_transaction;
00241
00242 struct os_time ibss_join_req;
00243 u8 *probe_resp;
00244 size_t probe_resp_len;
00245 u32 supp_rates_bits;
00246
00247 int wmm_last_param_set;
00248
00249 int sta_scanning;
00250 int scan_hw_mode_idx;
00251 int scan_channel_idx;
00252 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
00253 struct os_time last_scan_completed;
00254 int scan_oper_channel;
00255 int scan_oper_freq;
00256 int scan_oper_phymode;
00257 u8 scan_ssid[32];
00258 size_t scan_ssid_len;
00259 int scan_skip_11b;
00260
00261 struct ieee80211_sta_bss *sta_bss_list;
00262 #define STA_HASH_SIZE 256
00263 #define STA_HASH(sta) (sta[5])
00264 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
00265
00266 int cts_protect_erp_frames;
00267
00268 int phymode;
00269 struct wpa_hw_modes *modes;
00270 size_t num_modes;
00271 unsigned int hw_modes;
00272
00273 int num_curr_rates;
00274 struct wpa_rate_data *curr_rates;
00275 int freq;
00276 int channel;
00277 #else
00278 int dummy;
00279 #endif
00280 };
00281
00291 struct wpa_supplicant {
00292 struct wpa_global *global;
00293 struct wpa_supplicant *next;
00294 struct l2_packet_data *l2;
00295 struct l2_packet_data *l2_br;
00296 unsigned char own_addr[ETH_ALEN];
00297 char ifname[100];
00298 #ifdef CONFIG_CTRL_IFACE_DBUS
00299 char *dbus_path;
00300 #endif
00301 char bridge_ifname[16];
00302
00303 char *confname;
00304 struct wpa_config *conf;
00305 int countermeasures;
00306 os_time_t last_michael_mic_error;
00307 u8 bssid[ETH_ALEN];
00308 u8 pending_bssid[ETH_ALEN];
00309
00310 int reassociate;
00311 int disconnected;
00312
00313 struct wpa_ssid *current_ssid;
00314
00315
00316 int pairwise_cipher;
00317 int group_cipher;
00318 int key_mgmt;
00319 int mgmt_group_cipher;
00320
00321 void *drv_priv;
00322
00323 struct wpa_ssid *prev_scan_ssid;
00324
00325
00326
00327
00328
00329 #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
00330
00331 struct wpa_scan_result *scan_results;
00332 int num_scan_results;
00333
00334 struct wpa_driver_ops *driver;
00335 int interface_removed;
00336
00337 struct wpa_sm *wpa;
00338 struct eapol_sm *eapol;
00339
00340 struct ctrl_iface_priv *ctrl_iface;
00341
00342 wpa_states wpa_state;
00343 int new_connection;
00344 int reassociated_connection;
00345
00346 int eapol_received;
00347
00348
00349 struct scard_data *scard;
00350
00351 unsigned char last_eapol_src[ETH_ALEN];
00352
00353 int keys_cleared;
00354
00355 struct wpa_blacklist *blacklist;
00356
00357 int scan_req;
00358
00359 int scan_res_tried;
00360
00361
00362
00363
00364 struct wpa_client_mlme mlme;
00365 int use_client_mlme;
00366 };
00367
00368
00369
00370 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
00371
00372 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
00373
00374 const char * wpa_supplicant_state_txt(int state);
00375 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s,
00376 int wait_for_interface);
00377 struct wpa_blacklist * wpa_blacklist_get(struct wpa_supplicant *wpa_s,
00378 const u8 *bssid);
00379 int wpa_blacklist_add(struct wpa_supplicant *wpa_s, const u8 *bssid);
00380 void wpa_blacklist_clear(struct wpa_supplicant *wpa_s);
00381 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
00382 struct wpa_scan_result *bss,
00383 struct wpa_ssid *ssid,
00384 u8 *wpa_ie, size_t *wpa_ie_len);
00385 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
00386 struct wpa_scan_result *bss,
00387 struct wpa_ssid *ssid);
00388 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
00389 struct wpa_ssid *ssid);
00390 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
00391 int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
00392 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
00393 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
00394 int sec, int usec);
00395 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
00396 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
00397 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
00398 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
00399 int reason_code);
00400 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
00401 int reason_code);
00402 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
00403
00404 void wpa_show_license(void);
00405
00406 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
00407 struct wpa_interface *iface);
00408 int wpa_supplicant_remove_iface(struct wpa_global *global,
00409 struct wpa_supplicant *wpa_s);
00410 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
00411 const char *ifname);
00412 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
00413 int wpa_supplicant_run(struct wpa_global *global);
00414 void wpa_supplicant_deinit(struct wpa_global *global);
00415
00416 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
00417 struct wpa_ssid *ssid);
00418
00419
00420
00421 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
00422 const char *ifname)
00423 {
00424 if (wpa_s->driver->init) {
00425 return wpa_s->driver->init(wpa_s, ifname);
00426 }
00427 return NULL;
00428 }
00429
00430 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
00431 {
00432 if (wpa_s->driver->deinit)
00433 wpa_s->driver->deinit(wpa_s->drv_priv);
00434 }
00435
00436 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
00437 const char *param)
00438 {
00439 if (wpa_s->driver->set_param)
00440 return wpa_s->driver->set_param(wpa_s->drv_priv, param);
00441 return 0;
00442 }
00443
00444 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
00445 int enabled)
00446 {
00447 if (wpa_s->driver->set_drop_unencrypted) {
00448 return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
00449 enabled);
00450 }
00451 return -1;
00452 }
00453
00454 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
00455 int enabled)
00456 {
00457 if (wpa_s->driver->set_countermeasures) {
00458 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
00459 enabled);
00460 }
00461 return -1;
00462 }
00463
00464 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
00465 int auth_alg)
00466 {
00467 if (wpa_s->driver->set_auth_alg) {
00468 return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
00469 auth_alg);
00470 }
00471 return -1;
00472 }
00473
00474 static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
00475 {
00476 if (wpa_s->driver->set_wpa) {
00477 return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
00478 }
00479 return 0;
00480 }
00481
00482 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
00483 struct wpa_driver_associate_params *params)
00484 {
00485 if (wpa_s->driver->associate) {
00486 return wpa_s->driver->associate(wpa_s->drv_priv, params);
00487 }
00488 return -1;
00489 }
00490
00491 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
00492 size_t ssid_len)
00493 {
00494 if (wpa_s->driver->scan) {
00495 return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
00496 }
00497 return -1;
00498 }
00499
00500 static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
00501 struct wpa_scan_result *results,
00502 size_t max_size)
00503 {
00504 if (wpa_s->driver->get_scan_results) {
00505 return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
00506 results, max_size);
00507 }
00508 return -1;
00509 }
00510
00511 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
00512 {
00513 if (wpa_s->driver->get_bssid) {
00514 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
00515 }
00516 return -1;
00517 }
00518
00519 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
00520 {
00521 if (wpa_s->driver->get_ssid) {
00522 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
00523 }
00524 return -1;
00525 }
00526
00527 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
00528 const u8 *addr, int key_idx, int set_tx,
00529 const u8 *seq, size_t seq_len,
00530 const u8 *key, size_t key_len)
00531 {
00532 if (wpa_s->driver->set_key) {
00533 wpa_s->keys_cleared = 0;
00534 return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
00535 key_idx, set_tx, seq, seq_len,
00536 key, key_len);
00537 }
00538 return -1;
00539 }
00540
00541 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
00542 const u8 *addr, int reason_code)
00543 {
00544 if (wpa_s->driver->deauthenticate) {
00545 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
00546 reason_code);
00547 }
00548 return -1;
00549 }
00550
00551 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
00552 const u8 *addr, int reason_code)
00553 {
00554 if (wpa_s->driver->disassociate) {
00555 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
00556 reason_code);
00557 }
00558 return -1;
00559 }
00560
00561 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
00562 const u8 *bssid, const u8 *pmkid)
00563 {
00564 if (wpa_s->driver->add_pmkid) {
00565 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
00566 }
00567 return -1;
00568 }
00569
00570 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
00571 const u8 *bssid, const u8 *pmkid)
00572 {
00573 if (wpa_s->driver->remove_pmkid) {
00574 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
00575 pmkid);
00576 }
00577 return -1;
00578 }
00579
00580 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
00581 {
00582 if (wpa_s->driver->flush_pmkid) {
00583 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
00584 }
00585 return -1;
00586 }
00587
00588 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
00589 struct wpa_driver_capa *capa)
00590 {
00591 if (wpa_s->driver->get_capa) {
00592 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
00593 }
00594 return -1;
00595 }
00596
00597 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
00598 {
00599 if (wpa_s->driver->poll) {
00600 wpa_s->driver->poll(wpa_s->drv_priv);
00601 }
00602 }
00603
00604 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
00605 {
00606 if (wpa_s->driver->get_ifname) {
00607 return wpa_s->driver->get_ifname(wpa_s->drv_priv);
00608 }
00609 return NULL;
00610 }
00611
00612 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
00613 {
00614 if (wpa_s->driver->get_mac_addr) {
00615 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
00616 }
00617 return NULL;
00618 }
00619
00620 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
00621 const u8 *dst, u16 proto,
00622 const u8 *data, size_t data_len)
00623 {
00624 if (wpa_s->driver->send_eapol)
00625 return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
00626 data, data_len);
00627 return -1;
00628 }
00629
00630 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
00631 int state)
00632 {
00633 if (wpa_s->driver->set_operstate)
00634 return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
00635 return 0;
00636 }
00637
00638 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
00639 const u8 *addr, int protect_type,
00640 int key_type)
00641 {
00642 if (wpa_s->driver->mlme_setprotection)
00643 return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
00644 protect_type,
00645 key_type);
00646 return 0;
00647 }
00648
00649 static inline struct wpa_hw_modes *
00650 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
00651 u16 *flags)
00652 {
00653 if (wpa_s->driver->get_hw_feature_data)
00654 return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
00655 num_modes, flags);
00656 return NULL;
00657 }
00658
00659 static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
00660 wpa_hw_mode phymode, int chan,
00661 int freq)
00662 {
00663 if (wpa_s->driver->set_channel)
00664 return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode,
00665 chan, freq);
00666 return -1;
00667 }
00668
00669 static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s,
00670 const u8 *ssid, size_t ssid_len)
00671 {
00672 if (wpa_s->driver->set_ssid) {
00673 return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid,
00674 ssid_len);
00675 }
00676 return -1;
00677 }
00678
00679 static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
00680 const u8 *bssid)
00681 {
00682 if (wpa_s->driver->set_bssid) {
00683 return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid);
00684 }
00685 return -1;
00686 }
00687
00688 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
00689 const u8 *data, size_t data_len)
00690 {
00691 if (wpa_s->driver->send_mlme)
00692 return wpa_s->driver->send_mlme(wpa_s->drv_priv,
00693 data, data_len);
00694 return -1;
00695 }
00696
00697 static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s,
00698 const u8 *addr, const u8 *supp_rates,
00699 size_t supp_rates_len)
00700 {
00701 if (wpa_s->driver->mlme_add_sta)
00702 return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr,
00703 supp_rates, supp_rates_len);
00704 return -1;
00705 }
00706
00707 static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s,
00708 const u8 *addr)
00709 {
00710 if (wpa_s->driver->mlme_remove_sta)
00711 return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr);
00712 return -1;
00713 }
00714
00715 #endif
00716