概述
二、几种重要的结构体:
1、wpa_interface 用于描述一个无线网络设备(/external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant_i.h)
struct wpa_interface {
/**
* confname - Configuration name (file or profile) name
*
* This can also be %NULL when a configuration file is not used. In
* that case, ctrl_interface must be set to allow the interface to be
* configured.
*/
const char *confname;
/**
* ctrl_interface - Control interface parameter
*
* If a configuration file is not used, this variable can be used to
* set the ctrl_interface parameter that would have otherwise been read
* from the configuration file. If both confname and ctrl_interface are
* set, ctrl_interface is used to override the value from configuration
* file.
*/
const char *ctrl_interface;
/**
* driver - Driver interface name, or %NULL to use the default driver
*/
const char *driver;
/**
* driver_param - Driver interface parameters
*
* If a configuration file is not used, this variable can be used to
* set the driver_param parameters that would have otherwise been read
* from the configuration file. If both confname and driver_param are
* set, driver_param is used to override the value from configuration
* file.
*/
const char *driver_param;
/**
* ifname - Interface name
*/
const char *ifname;
/**
* bridge_ifname - Optional bridge interface name
*
* If the driver interface (ifname) is included in a Linux bridge
* device, the bridge interface may need to be used for receiving EAPOL
* frames. This can be enabled by setting this variable to enable
* receiving of EAPOL frames from an additional interface.
*/
const char *bridge_ifname;
};
2、wpa_global 是一个全局性质的上下文信息(/external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant_i.h )
struct wpa_global {
struct wpa_supplicant *ifaces; //ifaces 变量指向一个 wpa_supplicant 对象。
//系统中所有的 wpa_supplicant 对象将通过单项链表连接在一起,所以 ifaces 变量指向一个
wpa_supplicant 对象链表。
struct wpa_params params;
struct ctrl_iface_global_priv *ctrl_iface; //全局控制接口,如果设置该接口,其他 wpa_supplicant 设置的控制接口将被取代!!!
struct wpas_dbus_priv *dbus;
void **drv_priv; //drv_priv 包含 driver wrapper 所需要的全局上下文信息。
size_t drv_count; //代表当前编译到系统中的 driver wrapper 个数。
struct os_time suspend_time;
struct p2p_data *p2p;
struct wpa_supplicant *p2p_init_wpa_s;
struct wpa_supplicant *p2p_group_formation;
u8 p2p_dev_addr[ETH_ALEN];
struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */
struct dl_list p2p_srv_upnp; /* struct p2p_srv_upnp */
int p2p_disabled;
int cross_connection;
struct wpa_freq_range *p2p_disallow_freq;
unsigned int num_p2p_disallow_freq;
enum wpa_conc_pref {
WPA_CONC_PREF_NOT_SET,
WPA_CONC_PREF_STA,
WPA_CONC_PREF_P2P
} conc_pref;
unsigned int p2p_cb_on_scan_complete:1;
#ifdef CONFIG_WIFI_DISPLAY
int wifi_display;
#define MAX_WFD_SUBELEMS 10
struct wpabuf *wfd_subelem[MAX_WFD_SUBELEMS];
#endif /* CONFIG_WIFI_DISPLAY */
};
3、wpa_supplicant 是WPAS的核心数据结构!!!一个 Interface 对应有一个 wpa_supplicant 对象!!!
(/external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant_i.h)
struct wpa_supplicant {
struct wpa_global *global;
struct wpa_supplicant *parent;
struct wpa_supplicant *next; //系统中所有 wpa_supplicant 对象都通过 next 变量链接在一起
struct l2_packet_data *l2;
struct l2_packet_data *l2_br;
unsigned char own_addr[ETH_ALEN];
char ifname[100];
#ifdef CONFIG_CTRL_IFACE_DBUS
char *dbus_path;
#endif /* CONFIG_CTRL_IFACE_DBUS */
#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
char *dbus_new_path;
char *dbus_groupobj_path;
#ifdef CONFIG_AP
char *preq_notify_peer;
#endif /* CONFIG_AP */
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
char bridge_ifname[16];
char *confname;
struct wpa_config *conf;
int countermeasures;
os_time_t last_michael_mic_error;
u8 bssid[ETH_ALEN];
u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
* field contains the target BSSID. */
int reassociate; /* reassociation requested */
int disconnected; /* all connections disabled; i.e., do no reassociate
* before this has been cleared */
struct wpa_ssid *current_ssid;
struct wpa_bss *current_bss;
int ap_ies_from_associnfo;
unsigned int assoc_freq;
/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
int pairwise_cipher;
int group_cipher;
int key_mgmt;
int wpa_proto;
int mgmt_group_cipher;
void *drv_priv; /* private data used by driver_ops */
void *global_drv_priv;
u8 *bssid_filter;
size_t bssid_filter_count;
/* previous scan was wildcard when interleaving between
* wildcard scans and specific SSID scan when max_ssids=1 */
int prev_scan_wildcard;
struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
* NULL = not yet initialized (start
* with wildcard SSID)
* WILDCARD_SSID_SCAN = wildcard
* SSID was used in the previous scan
*/
#define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
struct wpa_ssid *prev_sched_ssid; /* last SSID used in sched scan */
int sched_scan_timeout;
int sched_scan_interval;
int first_sched_scan;
int sched_scan_timed_out;
void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
struct wpa_scan_results *scan_res);
struct dl_list bss; /* struct wpa_bss::list */
struct dl_list bss_id; /* struct wpa_bss::list_id */
size_t num_bss;
unsigned int bss_update_idx;
unsigned int bss_next_id;
/*
* Pointers to BSS entries in the order they were in the last scan
* results.
*/
struct wpa_bss **last_scan_res;
unsigned int last_scan_res_used;
unsigned int last_scan_res_size;
int last_scan_full;
struct os_time last_scan;
struct wpa_driver_ops *driver;
int interface_removed; /* whether the network interface has been
* removed */
struct wpa_sm *wpa;
struct eapol_sm *eapol;
struct ctrl_iface_priv *ctrl_iface;
enum wpa_states wpa_state;
int scanning;
int sched_scanning;
int new_connection;
int reassociated_connection;
int eapol_received; /* number of EAPOL packets received after the
* previous association event */
struct scard_data *scard;
#ifdef PCSC_FUNCS
char imsi[20];
int mnc_len;
#endif /* PCSC_FUNCS */
unsigned char last_eapol_src[ETH_ALEN];
int keys_cleared;
struct wpa_blacklist *blacklist;
int scan_req; /* manual scan request; this forces a scan even if there
* are no enabled networks in the configuration */
int scan_runs; /* number of scan runs since WPS was started */
int *next_scan_freqs;
int scan_interval; /* time in sec between scans to find suitable AP */
int normal_scans; /* normal scans run before sched_scan */
unsigned int drv_flags;
unsigned int drv_enc;
/*
* A bitmap of supported protocols for probe response offload. See
* struct wpa_driver_capa in driver.h
*/
unsigned int probe_resp_offloads;
int max_scan_ssids;
int max_sched_scan_ssids;
int sched_scan_supported;
unsigned int max_match_sets;
unsigned int max_remain_on_chan;
unsigned int max_stations;
int pending_mic_error_report;
int pending_mic_error_pairwise;
int mic_errors_seen; /* Michael MIC errors with the current PTK */
struct wps_context *wps;
int wps_success; /* WPS success event received */
struct wps_er *wps_er;
int blacklist_cleared;
struct wpabuf *pending_eapol_rx;
struct os_time pending_eapol_rx_time;
u8 pending_eapol_rx_src[ETH_ALEN];
struct ibss_rsn *ibss_rsn;
int set_sta_uapsd;
int sta_uapsd;
int set_ap_uapsd;
int ap_uapsd;
#ifdef CONFIG_SME
struct {
u8 ssid[32];
size_t ssid_len;
int freq;
u8 assoc_req_ie[200];
size_t assoc_req_ie_len;
int mfp;
int ft_used;
u8 mobility_domain[2];
u8 *ft_ies;
size_t ft_ies_len;
u8 prev_bssid[ETH_ALEN];
int prev_bssid_set;
int auth_alg;
int proto;
int sa_query_count; /* number of pending SA Query requests;
* 0 = no SA Query in progress */
int sa_query_timed_out;
u8 *sa_query_trans_id; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
* sa_query_count octets of pending
* SA Query transaction identifiers */
struct os_time sa_query_start;
u8 sched_obss_scan;
u16 obss_scan_int;
u16 bss_max_idle_period;
} sme;
#endif /* CONFIG_SME */
#ifdef CONFIG_AP
struct hostapd_iface *ap_iface;
void (*ap_configured_cb)(void *ctx, void *data);
void *ap_configured_cb_ctx;
void *ap_configured_cb_data;
#endif /* CONFIG_AP */
unsigned int off_channel_freq;
struct wpabuf *pending_action_tx;
u8 pending_action_src[ETH_ALEN];
u8 pending_action_dst[ETH_ALEN];
u8 pending_action_bssid[ETH_ALEN];
unsigned int pending_action_freq;
int pending_action_no_cck;
int pending_action_without_roc;
void (*pending_action_tx_status_cb)(struct wpa_supplicant *wpa_s,
unsigned int freq, const u8 *dst,
const u8 *src, const u8 *bssid,
const u8 *data, size_t data_len,
enum offchannel_send_action_result
result);
unsigned int roc_waiting_drv_freq;
int action_tx_wait_time;
#ifdef CONFIG_P2P
struct p2p_go_neg_results *go_params;
int create_p2p_iface;
u8 pending_interface_addr[ETH_ALEN];
char pending_interface_name[100];
int pending_interface_type;
int p2p_group_idx;
unsigned int pending_listen_freq;
unsigned int pending_listen_duration;
enum {
NOT_P2P_GROUP_INTERFACE,
P2P_GROUP_INTERFACE_PENDING,
P2P_GROUP_INTERFACE_GO,
P2P_GROUP_INTERFACE_CLIENT
} p2p_group_interface;
struct p2p_group *p2p_group;
int p2p_long_listen; /* remaining time in long Listen state in ms */
char p2p_pin[10];
int p2p_wps_method;
u8 p2p_auth_invite[ETH_ALEN];
int p2p_sd_over_ctrl_iface;
int p2p_in_provisioning;
int pending_invite_ssid_id;
int show_group_started;
u8 go_dev_addr[ETH_ALEN];
int pending_pd_before_join;
u8 pending_join_iface_addr[ETH_ALEN];
u8 pending_join_dev_addr[ETH_ALEN];
int pending_join_wps_method;
int p2p_join_scan_count;
int auto_pd_scan_retry;
int force_long_sd;
u16 pending_pd_config_methods;
enum {
NORMAL_PD, AUTO_PD_GO_NEG, AUTO_PD_JOIN
} pending_pd_use;
/*
* Whether cross connection is disallowed by the AP to which this
* interface is associated (only valid if there is an association).
*/
int cross_connect_disallowed;
/*
* Whether this P2P group is configured to use cross connection (only
* valid if this is P2P GO interface). The actual cross connect packet
* forwarding may not be configured depending on the uplink status.
*/
int cross_connect_enabled;
/* Whether cross connection forwarding is in use at the moment. */
int cross_connect_in_use;
/*
* Uplink interface name for cross connection
*/
char cross_connect_uplink[100];
unsigned int sta_scan_pending:1;
unsigned int p2p_auto_join:1;
unsigned int p2p_auto_pd:1;
unsigned int p2p_persistent_group:1;
unsigned int p2p_fallback_to_go_neg:1;
unsigned int p2p_pd_before_go_neg:1;
unsigned int p2p_go_ht40:1;
int p2p_persistent_go_freq;
int p2p_persistent_id;
int p2p_go_intent;
int p2p_connect_freq;
struct os_time p2p_auto_started;
#endif /* CONFIG_P2P */
struct wpa_ssid *bgscan_ssid;
const struct bgscan_ops *bgscan;
void *bgscan_priv;
const struct autoscan_ops *autoscan;
struct wpa_driver_scan_params *autoscan_params;
void *autoscan_priv;
struct wpa_ssid *connect_without_scan;
struct wps_ap_info *wps_ap;
size_t num_wps_ap;
int wps_ap_iter;
int after_wps;
int known_wps_freq;
unsigned int wps_freq;
int wps_fragment_size;
int auto_reconnect_disabled;
/* Channel preferences for AP/P2P GO use */
int best_24_freq;
int best_5_freq;
int best_overall_freq;
struct gas_query *gas;
#ifdef CONFIG_INTERWORKING
unsigned int fetch_anqp_in_progress:1;
unsigned int network_select:1;
unsigned int auto_select:1;
unsigned int auto_network_select:1;
unsigned int fetch_all_anqp:1;
#endif /* CONFIG_INTERWORKING */
unsigned int drv_capa_known;
struct {
struct hostapd_hw_modes *modes;
u16 num_modes;
u16 flags;
} hw;
int pno;
/* WLAN_REASON_* reason codes. Negative if locally generated. */
int disconnect_reason;
struct ext_password_data *ext_pw;
struct wpabuf *last_gas_resp;
u8 last_gas_addr[ETH_ALEN];
u8 last_gas_dialog_token;
};
4、全局控制接口(定义的地方有三处!)
1.(/external/wpa_supplicant_8/wpa_supplicant/ctrl_iface_udp.c)
struct ctrl_iface_global_priv {
int sock; //用于通信的 socket 句柄
struct wpa_ctrl_dst *ctrl_dst;
u8 cookie[COOKIE_LEN];
};
2.(/external/wpa_supplicant_8/wpa_supplicant/ctrl_iface_named_pipe.c)
struct ctrl_iface_global_priv {
struct wpa_global *global;
struct wpa_global_dst *ctrl_dst;
};
3.(/external/wpa_supplicant_8/wpa_supplicant/ctrl_iface_unix.c)
struct ctrl_iface_global_priv {
struct wpa_global *global;
int sock; //用于通信的 socket 句柄
struct dl_list ctrl_dst;
int android_control_socket;
struct dl_list msg_queue;
unsigned int throttle_count;
};
最后
以上就是动人鸵鸟为你收集整理的android wifi-wpa_supplicant_源码分析(二)的全部内容,希望文章能够帮你解决android wifi-wpa_supplicant_源码分析(二)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复