关联事件处理流程分析
WPAS中的driver wrapper将收到来自wlan driver的 NL80211_CMD_CONNECT 命令
case NL80211_CMD_CONNECT:
case NL80211_CMD_ROAM:
/*
调用mlme_event_connect进行处理
NL80211_ATTR_STATUS_CODE 保存AP的处理结果
NL80211_ATTR_REQ_IE 保存Association Request请求时包含的IE
NL80211_ATTR_RESP_IE 保存Association Response请求时包含的IE
*/
mlme_event_connect(drv, cmd,
tb[NL80211_ATTR_STATUS_CODE],
tb[NL80211_ATTR_MAC],
tb[NL80211_ATTR_REQ_IE],
tb[NL80211_ATTR_RESP_IE],
tb[NL80211_ATTR_TIMED_OUT],
tb[NL80211_ATTR_TIMEOUT_REASON],
NULL, NULL, NULL,
tb[NL80211_ATTR_FILS_KEK],
NULL,
tb[NL80211_ATTR_FILS_ERP_NEXT_SEQ_NUM],
tb[NL80211_ATTR_PMK],
tb[NL80211_ATTR_PMKID]);
break;
static void mlme_event_connect(struct wpa_driver_nl80211_data *drv,
enum nl80211_commands cmd, struct nlattr *status,
struct nlattr *addr, struct nlattr *req_ie,
struct nlattr *resp_ie,
struct nlattr *timed_out,
struct nlattr *timeout_reason,
struct nlattr *authorized,
struct nlattr *key_replay_ctr,
struct nlattr *ptk_kck,
struct nlattr *ptk_kek,
struct nlattr *subnet_status,
struct nlattr *fils_erp_next_seq_num,
struct nlattr *fils_pmk,
struct nlattr *fils_pmkid)
{
union wpa_event_data event;
const u8 *ssid = NULL;
u16 status_code;
int ssid_len;
//wlan driver支持SME时的处理
if (drv->capa.flags & WPA_DRIVER_FLAGS_SME) {
/*
* Avoid reporting two association events that would confuse
* the core code.
*/
wpa_printf(MSG_DEBUG, "nl80211: Ignore connect event (cmd=%d) "
"when using userspace SME", cmd);
return;
}
drv->connect_reassoc = 0;
status_code = status ? nla_get_u16(status) : WLAN_STATUS_SUCCESS;
if (cmd == NL80211_CMD_CONNECT) {
wpa_printf(MSG_DEBUG,
"nl80211: Connect event (status=%u ignore_next_local_disconnect=%d)",
status_code, drv->ignore_next_local_disconnect);
} else if (cmd == NL80211_CMD_ROAM) {
wpa_printf(MSG_DEBUG, "nl80211: Roam event");
}
os_memset(&event, 0, sizeof(event));
if (cmd == NL80211_CMD_CONNECT && status_code != WLAN_STATUS_SUCCESS) {
//关联AP失败时的处理
if (addr)
event.assoc_reject.bssid = nla_data(addr);
if (drv->ignore_next_local_disconnect) {
drv->ignore_next_local_disconnect = 0;
if (!event.assoc_reject.bssid ||
(os_memcmp(event.assoc_reject.bssid,
drv->auth_attempt_bssid,
ETH_ALEN) != 0)) {
/*
* Ignore the event that came without a BSSID or
* for the old connection since this is likely
* not relevant to the new Connect command.
*/
wpa_printf(MSG_DEBUG,
"nl80211: Ignore connection failure event triggered during reassociation");
return;
}
}
if (resp_ie) {
event.assoc_reject.resp_ies = nla_data(resp_ie);
event.assoc_reject.resp_ies_len = nla_len(resp_ie);
}
event.assoc_reject.status_code = status_code;
event.assoc_reject.timed_out = timed_out != NULL;
if (timed_out && timeout_reason) {
enum nl80211_timeout_reason reason;
reason = nla_get_u32(timeout_reason);
switch (reason) {
case NL80211_TIMEOUT_SCAN:
event.assoc_reject.timeout_reason = "scan";
break;
case NL80211_TIMEOUT_AUTH:
event.assoc_reject.timeout_reason = "auth";
break;
case NL80211_TIMEOUT_ASSOC:
event.assoc_reject.timeout_reason = "assoc";
break;
default:</

本文详细解析了WPAS中driverwrapper处理NL80211_CMD_CONNECT和NL80211_CMD_ROAM事件的过程,涉及连接成功与失败的响应、SSID设置、关键参数传递及后续的身份验证和加密流程,重点介绍了4-Way Handshake和Group Key Handshake的准备阶段。
最低0.47元/天 解锁文章
431

被折叠的 条评论
为什么被折叠?



