nl80211: Fix WPA_VERSIONS attribute for Connect command

The previous code was trying to figure out which WPA version is
used based on the extra IEs requested for Association Request. That
did not work properly in cases where non-WPA networks are used with
some extra IEs. Fix this by using more robust mechanism for passing
the WPA versions from core wpa_supplicant to the driver_ops
associate().
This commit is contained in:
Jouni Malinen 2011-09-02 20:40:23 +03:00 committed by Jouni Malinen
parent bf9d5518d5
commit 64fa840a97
6 changed files with 22 additions and 11 deletions

View file

@ -350,6 +350,11 @@ struct wpa_driver_associate_params {
*/
size_t wpa_ie_len;
/**
* wpa_proto - Bitfield of WPA_PROTO_* values to indicate WPA/WPA2
*/
unsigned int wpa_proto;
/**
* pairwise_suite - Selected pairwise cipher suite
*

View file

@ -4957,16 +4957,15 @@ static int wpa_driver_nl80211_connect(
NLA_PUT_U32(msg, NL80211_ATTR_AUTH_TYPE, type);
skip_auth_type:
if (params->wpa_ie && params->wpa_ie_len &&
params->key_mgmt_suite != KEY_MGMT_WPS) {
enum nl80211_wpa_versions ver;
if (params->wpa_proto) {
enum nl80211_wpa_versions ver = 0;
if (params->wpa_ie[0] == WLAN_EID_RSN)
ver = NL80211_WPA_VERSION_2;
else
ver = NL80211_WPA_VERSION_1;
if (params->wpa_proto & WPA_PROTO_WPA)
ver |= NL80211_WPA_VERSION_1;
if (params->wpa_proto & WPA_PROTO_RSN)
ver |= NL80211_WPA_VERSION_2;
wpa_printf(MSG_DEBUG, " * WPA Version %d", ver);
wpa_printf(MSG_DEBUG, " * WPA Versions 0x%x", ver);
NLA_PUT_U32(msg, NL80211_ATTR_WPA_VERSIONS, ver);
}