wpa_supplicant / hostapd 2.0

wpa_supplicant_i.h

Go to the documentation of this file.
00001 
00010 #ifndef WPA_SUPPLICANT_I_H
00011 #define WPA_SUPPLICANT_I_H
00012 
00013 #include "utils/list.h"
00014 #include "common/defs.h"
00015 #include "config_ssid.h"
00016 
00017 extern const char *wpa_supplicant_version;
00018 extern const char *wpa_supplicant_license;
00019 #ifndef CONFIG_NO_STDOUT_DEBUG
00020 extern const char *wpa_supplicant_full_license1;
00021 extern const char *wpa_supplicant_full_license2;
00022 extern const char *wpa_supplicant_full_license3;
00023 extern const char *wpa_supplicant_full_license4;
00024 extern const char *wpa_supplicant_full_license5;
00025 #endif /* CONFIG_NO_STDOUT_DEBUG */
00026 
00027 struct wpa_sm;
00028 struct wpa_supplicant;
00029 struct ibss_rsn;
00030 struct scan_info;
00031 struct wpa_bss;
00032 struct wpa_scan_results;
00033 struct hostapd_hw_modes;
00034 struct wpa_driver_associate_params;
00035 
00036 /*
00037  * Forward declarations of private structures used within the ctrl_iface
00038  * backends. Other parts of wpa_supplicant do not have access to data stored in
00039  * these structures.
00040  */
00041 struct ctrl_iface_priv;
00042 struct ctrl_iface_global_priv;
00043 struct wpas_dbus_priv;
00044 
00049 struct wpa_interface {
00058         const char *confname;
00059 
00070         const char *ctrl_interface;
00071 
00076         const char *driver;
00077 
00088         const char *driver_param;
00089 
00094         const char *ifname;
00095 
00105         const char *bridge_ifname;
00106 };
00107 
00112 struct wpa_params {
00117         int daemonize;
00118 
00123         int wait_for_monitor;
00124 
00132         char *pid_file;
00133 
00138         int wpa_debug_level;
00139 
00150         int wpa_debug_show_keys;
00151 
00156         int wpa_debug_timestamp;
00157 
00162         char *ctrl_interface;
00163 
00168         int dbus_ctrl_interface;
00169 
00174         const char *wpa_debug_file_path;
00175 
00180         int wpa_debug_syslog;
00181 
00186         int wpa_debug_tracing;
00187 
00196         char *override_driver;
00197 
00206         char *override_ctrl_interface;
00207 
00215         char *entropy_file;
00216 };
00217 
00218 struct p2p_srv_bonjour {
00219         struct dl_list list;
00220         struct wpabuf *query;
00221         struct wpabuf *resp;
00222 };
00223 
00224 struct p2p_srv_upnp {
00225         struct dl_list list;
00226         u8 version;
00227         char *service;
00228 };
00229 
00230 struct wpa_freq_range {
00231         unsigned int min;
00232         unsigned int max;
00233 };
00234 
00235 
00243 struct wpa_global {
00244         struct wpa_supplicant *ifaces;
00245         struct wpa_params params;
00246         struct ctrl_iface_global_priv *ctrl_iface;
00247         struct wpas_dbus_priv *dbus;
00248         void **drv_priv;
00249         size_t drv_count;
00250         struct os_time suspend_time;
00251         struct p2p_data *p2p;
00252         struct wpa_supplicant *p2p_group_formation;
00253         u8 p2p_dev_addr[ETH_ALEN];
00254         struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */
00255         struct dl_list p2p_srv_upnp; /* struct p2p_srv_upnp */
00256         int p2p_disabled;
00257         int cross_connection;
00258         struct wpa_freq_range *p2p_disallow_freq;
00259         unsigned int num_p2p_disallow_freq;
00260 };
00261 
00262 
00263 enum offchannel_send_action_result {
00264         OFFCHANNEL_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */,
00265         OFFCHANNEL_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged
00266                                        */,
00267         OFFCHANNEL_SEND_ACTION_FAILED /* Frame was not sent due to a failure */
00268 };
00269 
00279 struct wpa_supplicant {
00280         struct wpa_global *global;
00281         struct wpa_supplicant *parent;
00282         struct wpa_supplicant *next;
00283         struct l2_packet_data *l2;
00284         struct l2_packet_data *l2_br;
00285         unsigned char own_addr[ETH_ALEN];
00286         char ifname[100];
00287 #ifdef CONFIG_CTRL_IFACE_DBUS
00288         char *dbus_path;
00289 #endif /* CONFIG_CTRL_IFACE_DBUS */
00290 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
00291         char *dbus_new_path;
00292         char *dbus_groupobj_path;
00293 #ifdef CONFIG_AP
00294         char *preq_notify_peer;
00295 #endif /* CONFIG_AP */
00296 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
00297         char bridge_ifname[16];
00298 
00299         char *confname;
00300         struct wpa_config *conf;
00301         int countermeasures;
00302         os_time_t last_michael_mic_error;
00303         u8 bssid[ETH_ALEN];
00304         u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
00305                                      * field contains the target BSSID. */
00306         int reassociate; /* reassociation requested */
00307         int disconnected; /* all connections disabled; i.e., do no reassociate
00308                            * before this has been cleared */
00309         struct wpa_ssid *current_ssid;
00310         struct wpa_bss *current_bss;
00311         int ap_ies_from_associnfo;
00312         unsigned int assoc_freq;
00313 
00314         /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
00315         int pairwise_cipher;
00316         int group_cipher;
00317         int key_mgmt;
00318         int wpa_proto;
00319         int mgmt_group_cipher;
00320 
00321         void *drv_priv; /* private data used by driver_ops */
00322         void *global_drv_priv;
00323 
00324         u8 *bssid_filter;
00325         size_t bssid_filter_count;
00326 
00327         /* previous scan was wildcard when interleaving between
00328          * wildcard scans and specific SSID scan when max_ssids=1 */
00329         int prev_scan_wildcard;
00330         struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
00331                                           * NULL = not yet initialized (start
00332                                           * with wildcard SSID)
00333                                           * WILDCARD_SSID_SCAN = wildcard
00334                                           * SSID was used in the previous scan
00335                                           */
00336 #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
00337 
00338         struct wpa_ssid *prev_sched_ssid; /* last SSID used in sched scan */
00339         int sched_scan_timeout;
00340         int sched_scan_interval;
00341         int first_sched_scan;
00342         int sched_scan_timed_out;
00343 
00344         void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
00345                                  struct wpa_scan_results *scan_res);
00346         struct dl_list bss; /* struct wpa_bss::list */
00347         struct dl_list bss_id; /* struct wpa_bss::list_id */
00348         size_t num_bss;
00349         unsigned int bss_update_idx;
00350         unsigned int bss_next_id;
00351 
00352         struct wpa_driver_ops *driver;
00353         int interface_removed; /* whether the network interface has been
00354                                 * removed */
00355         struct wpa_sm *wpa;
00356         struct eapol_sm *eapol;
00357 
00358         struct ctrl_iface_priv *ctrl_iface;
00359 
00360         enum wpa_states wpa_state;
00361         int scanning;
00362         int sched_scanning;
00363         int new_connection;
00364         int reassociated_connection;
00365 
00366         int eapol_received; /* number of EAPOL packets received after the
00367                              * previous association event */
00368 
00369         struct scard_data *scard;
00370 #ifdef PCSC_FUNCS
00371         char imsi[20];
00372         int mnc_len;
00373 #endif /* PCSC_FUNCS */
00374 
00375         unsigned char last_eapol_src[ETH_ALEN];
00376 
00377         int keys_cleared;
00378 
00379         struct wpa_blacklist *blacklist;
00380 
00381         int scan_req; /* manual scan request; this forces a scan even if there
00382                        * are no enabled networks in the configuration */
00383         int scan_runs; /* number of scan runs since WPS was started */
00384         int *next_scan_freqs;
00385         int scan_interval; /* time in sec between scans to find suitable AP */
00386         int normal_scans; /* normal scans run before sched_scan */
00387 
00388         unsigned int drv_flags;
00389 
00390         /*
00391          * A bitmap of supported protocols for probe response offload. See
00392          * struct wpa_driver_capa in driver.h
00393          */
00394         unsigned int probe_resp_offloads;
00395 
00396         int max_scan_ssids;
00397         int max_sched_scan_ssids;
00398         int sched_scan_supported;
00399         unsigned int max_match_sets;
00400         unsigned int max_remain_on_chan;
00401         unsigned int max_stations;
00402 
00403         int pending_mic_error_report;
00404         int pending_mic_error_pairwise;
00405         int mic_errors_seen; /* Michael MIC errors with the current PTK */
00406 
00407         struct wps_context *wps;
00408         int wps_success; /* WPS success event received */
00409         struct wps_er *wps_er;
00410         int blacklist_cleared;
00411 
00412         struct wpabuf *pending_eapol_rx;
00413         struct os_time pending_eapol_rx_time;
00414         u8 pending_eapol_rx_src[ETH_ALEN];
00415 
00416         struct ibss_rsn *ibss_rsn;
00417 
00418         int set_sta_uapsd;
00419         int sta_uapsd;
00420         int set_ap_uapsd;
00421         int ap_uapsd;
00422 
00423 #ifdef CONFIG_SME
00424         struct {
00425                 u8 ssid[32];
00426                 size_t ssid_len;
00427                 int freq;
00428                 u8 assoc_req_ie[200];
00429                 size_t assoc_req_ie_len;
00430                 int mfp;
00431                 int ft_used;
00432                 u8 mobility_domain[2];
00433                 u8 *ft_ies;
00434                 size_t ft_ies_len;
00435                 u8 prev_bssid[ETH_ALEN];
00436                 int prev_bssid_set;
00437                 int auth_alg;
00438                 int proto;
00439 
00440                 int sa_query_count; /* number of pending SA Query requests;
00441                                      * 0 = no SA Query in progress */
00442                 int sa_query_timed_out;
00443                 u8 *sa_query_trans_id; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
00444                                         * sa_query_count octets of pending
00445                                         * SA Query transaction identifiers */
00446                 struct os_time sa_query_start;
00447         } sme;
00448 #endif /* CONFIG_SME */
00449 
00450 #ifdef CONFIG_AP
00451         struct hostapd_iface *ap_iface;
00452         void (*ap_configured_cb)(void *ctx, void *data);
00453         void *ap_configured_cb_ctx;
00454         void *ap_configured_cb_data;
00455 #endif /* CONFIG_AP */
00456 
00457         unsigned int off_channel_freq;
00458         struct wpabuf *pending_action_tx;
00459         u8 pending_action_src[ETH_ALEN];
00460         u8 pending_action_dst[ETH_ALEN];
00461         u8 pending_action_bssid[ETH_ALEN];
00462         unsigned int pending_action_freq;
00463         int pending_action_no_cck;
00464         int pending_action_without_roc;
00465         void (*pending_action_tx_status_cb)(struct wpa_supplicant *wpa_s,
00466                                             unsigned int freq, const u8 *dst,
00467                                             const u8 *src, const u8 *bssid,
00468                                             const u8 *data, size_t data_len,
00469                                             enum offchannel_send_action_result
00470                                             result);
00471         unsigned int roc_waiting_drv_freq;
00472         int action_tx_wait_time;
00473 
00474 #ifdef CONFIG_P2P
00475         struct p2p_go_neg_results *go_params;
00476         int create_p2p_iface;
00477         u8 pending_interface_addr[ETH_ALEN];
00478         char pending_interface_name[100];
00479         int pending_interface_type;
00480         int p2p_group_idx;
00481         unsigned int pending_listen_freq;
00482         unsigned int pending_listen_duration;
00483         enum {
00484                 NOT_P2P_GROUP_INTERFACE,
00485                 P2P_GROUP_INTERFACE_PENDING,
00486                 P2P_GROUP_INTERFACE_GO,
00487                 P2P_GROUP_INTERFACE_CLIENT
00488         } p2p_group_interface;
00489         struct p2p_group *p2p_group;
00490         int p2p_long_listen; /* remaining time in long Listen state in ms */
00491         char p2p_pin[10];
00492         int p2p_wps_method;
00493         u8 p2p_auth_invite[ETH_ALEN];
00494         int p2p_sd_over_ctrl_iface;
00495         int p2p_in_provisioning;
00496         int pending_invite_ssid_id;
00497         int show_group_started;
00498         u8 go_dev_addr[ETH_ALEN];
00499         int pending_pd_before_join;
00500         u8 pending_join_iface_addr[ETH_ALEN];
00501         u8 pending_join_dev_addr[ETH_ALEN];
00502         int pending_join_wps_method;
00503         int p2p_join_scan_count;
00504         int force_long_sd;
00505 
00506         /*
00507          * Whether cross connection is disallowed by the AP to which this
00508          * interface is associated (only valid if there is an association).
00509          */
00510         int cross_connect_disallowed;
00511 
00512         /*
00513          * Whether this P2P group is configured to use cross connection (only
00514          * valid if this is P2P GO interface). The actual cross connect packet
00515          * forwarding may not be configured depending on the uplink status.
00516          */
00517         int cross_connect_enabled;
00518 
00519         /* Whether cross connection forwarding is in use at the moment. */
00520         int cross_connect_in_use;
00521 
00522         /*
00523          * Uplink interface name for cross connection
00524          */
00525         char cross_connect_uplink[100];
00526 
00527         enum {
00528                 P2P_GROUP_REMOVAL_UNKNOWN,
00529                 P2P_GROUP_REMOVAL_REQUESTED,
00530                 P2P_GROUP_REMOVAL_IDLE_TIMEOUT,
00531                 P2P_GROUP_REMOVAL_UNAVAILABLE,
00532                 P2P_GROUP_REMOVAL_GO_ENDING_SESSION
00533         } removal_reason;
00534 
00535         unsigned int p2p_cb_on_scan_complete:1;
00536         unsigned int p2p_auto_join:1;
00537         unsigned int p2p_persistent_group:1;
00538         int p2p_go_intent;
00539         int p2p_connect_freq;
00540         struct os_time p2p_auto_started;
00541 #endif /* CONFIG_P2P */
00542 
00543         struct wpa_ssid *bgscan_ssid;
00544         const struct bgscan_ops *bgscan;
00545         void *bgscan_priv;
00546 
00547         struct wpa_ssid *connect_without_scan;
00548 
00549         int after_wps;
00550         int known_wps_freq;
00551         unsigned int wps_freq;
00552         int wps_fragment_size;
00553         int auto_reconnect_disabled;
00554 
00555          /* Channel preferences for AP/P2P GO use */
00556         int best_24_freq;
00557         int best_5_freq;
00558         int best_overall_freq;
00559 
00560         struct gas_query *gas;
00561 
00562 #ifdef CONFIG_INTERWORKING
00563         unsigned int fetch_anqp_in_progress:1;
00564         unsigned int network_select:1;
00565         unsigned int auto_select:1;
00566 #endif /* CONFIG_INTERWORKING */
00567         unsigned int drv_capa_known;
00568 
00569         struct {
00570                 struct hostapd_hw_modes *modes;
00571                 u16 num_modes;
00572                 u16 flags;
00573         } hw;
00574 
00575         int pno;
00576 };
00577 
00578 
00579 /* wpa_supplicant.c */
00580 void wpa_supplicant_apply_ht_overrides(
00581         struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
00582         struct wpa_driver_associate_params *params);
00583 
00584 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
00585 
00586 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
00587 
00588 const char * wpa_supplicant_state_txt(enum wpa_states state);
00589 int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s);
00590 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
00591 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
00592                               struct wpa_bss *bss, struct wpa_ssid *ssid,
00593                               u8 *wpa_ie, size_t *wpa_ie_len);
00594 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
00595                               struct wpa_bss *bss,
00596                               struct wpa_ssid *ssid);
00597 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
00598                                        struct wpa_ssid *ssid);
00599 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
00600 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
00601 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
00602                                      int sec, int usec);
00603 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
00604                               enum wpa_states state);
00605 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
00606 const char * wpa_supplicant_get_eap_mode(struct wpa_supplicant *wpa_s);
00607 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
00608 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
00609                                    int reason_code);
00610 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
00611                                  int reason_code);
00612 
00613 void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
00614                                    struct wpa_ssid *ssid);
00615 void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
00616                                     struct wpa_ssid *ssid);
00617 void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
00618                                    struct wpa_ssid *ssid);
00619 int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
00620                                int ap_scan);
00621 int wpa_supplicant_set_bss_expiration_age(struct wpa_supplicant *wpa_s,
00622                                           unsigned int expire_age);
00623 int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant *wpa_s,
00624                                             unsigned int expire_count);
00625 int wpa_supplicant_set_scan_interval(struct wpa_supplicant *wpa_s,
00626                                      int scan_interval);
00627 int wpa_supplicant_set_debug_params(struct wpa_global *global,
00628                                     int debug_level, int debug_timestamp,
00629                                     int debug_show_keys);
00630 void free_hw_features(struct wpa_supplicant *wpa_s);
00631 
00632 void wpa_show_license(void);
00633 
00634 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
00635                                                  struct wpa_interface *iface);
00636 int wpa_supplicant_remove_iface(struct wpa_global *global,
00637                                 struct wpa_supplicant *wpa_s,
00638                                 int terminate);
00639 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
00640                                                  const char *ifname);
00641 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
00642 int wpa_supplicant_run(struct wpa_global *global);
00643 void wpa_supplicant_deinit(struct wpa_global *global);
00644 
00645 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
00646                               struct wpa_ssid *ssid);
00647 void wpa_supplicant_terminate_proc(struct wpa_global *global);
00648 void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
00649                              const u8 *buf, size_t len);
00650 enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
00651 enum wpa_cipher cipher_suite2driver(int cipher);
00652 void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
00653 void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s);
00654 void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid);
00655 int wpas_driver_bss_selection(struct wpa_supplicant *wpa_s);
00656 
00657 /* events.c */
00658 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
00659 int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
00660                            struct wpa_bss *selected,
00661                            struct wpa_ssid *ssid);
00662 void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx);
00663 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx);
00664 
00665 /* eap_register.c */
00666 int eap_register_methods(void);
00667 
00673 static inline int network_is_persistent_group(struct wpa_ssid *ssid)
00674 {
00675         return ((ssid->disabled == 2) || ssid->p2p_persistent_group);
00676 }
00677 
00678 #endif /* WPA_SUPPLICANT_I_H */
00679 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines