3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-26 09:32:34 +01:00

ie: Split RSN & WPA akm suite builders

This commit is contained in:
Denis Kenzior 2018-07-19 10:56:46 -05:00
parent 438af4aebc
commit c4a2654703

View File

@ -752,50 +752,48 @@ static bool ie_build_cipher_suite(uint8_t *data, const uint8_t *oui,
return false;
}
/*
* 802.11, Section 8.4.2.27.2
* 802.11i, Section 7.3.2.25.2 and WPA_80211_v3_1 Section 2.1
*/
static bool ie_build_akm_suite(uint8_t *data, const uint8_t *oui,
enum ie_rsn_akm_suite suite)
#define RETURN_AKM(data, oui, id) \
memcpy((data), (oui), 3); \
(data)[3] = (id); \
return true;
/* 802.11-2016, Section 9.4.2.25.3 */
static bool ie_build_rsn_akm_suite(uint8_t *data, enum ie_rsn_akm_suite suite)
{
switch (suite) {
case IE_RSN_AKM_SUITE_8021X:
memcpy(data, oui, 3);
data[3] = 1;
return true;
RETURN_AKM(data, ieee_oui, 1);
case IE_RSN_AKM_SUITE_PSK:
memcpy(data, oui, 3);
data[3] = 2;
return true;
RETURN_AKM(data, ieee_oui, 2);
case IE_RSN_AKM_SUITE_FT_OVER_8021X:
memcpy(data, oui, 3);
data[3] = 3;
return true;
RETURN_AKM(data, ieee_oui, 3);
case IE_RSN_AKM_SUITE_FT_USING_PSK:
memcpy(data, oui, 3);
data[3] = 4;
return true;
RETURN_AKM(data, ieee_oui, 4);
case IE_RSN_AKM_SUITE_8021X_SHA256:
memcpy(data, oui, 3);
data[3] = 5;
return true;
RETURN_AKM(data, ieee_oui, 5);
case IE_RSN_AKM_SUITE_PSK_SHA256:
memcpy(data, oui, 3);
data[3] = 6;
return true;
RETURN_AKM(data, ieee_oui, 6);
case IE_RSN_AKM_SUITE_TDLS:
memcpy(data, oui, 3);
data[3] = 7;
return true;
RETURN_AKM(data, ieee_oui, 7);
case IE_RSN_AKM_SUITE_SAE_SHA256:
memcpy(data, oui, 3);
data[3] = 8;
return true;
RETURN_AKM(data, ieee_oui, 8);
case IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256:
memcpy(data, oui, 3);
data[3] = 9;
return true;
RETURN_AKM(data, ieee_oui, 9);
}
return false;
}
/* 802.11i, Section 7.3.2.25.2 and WPA_80211_v3_1 Section 2.1 */
static bool ie_build_wpa_akm_suite(uint8_t *data, enum ie_rsn_akm_suite suite)
{
switch (suite) {
case IE_RSN_AKM_SUITE_8021X:
RETURN_AKM(data, microsoft_oui, 1);
case IE_RSN_AKM_SUITE_PSK:
RETURN_AKM(data, microsoft_oui, 2);
default:
break;
}
return false;
@ -876,7 +874,7 @@ bool ie_build_rsne(const struct ie_rsn_info *info, uint8_t *to)
if (pos + 4 > 248)
return false;
if (!ie_build_akm_suite(to + pos, ieee_oui, akm_suite))
if (!ie_build_rsn_akm_suite(to + pos, akm_suite))
return false;
pos += 4;
@ -1287,7 +1285,7 @@ bool ie_build_wpa(const struct ie_rsn_info *info, uint8_t *to)
if (!(info->akm_suites & suite))
continue;
if (!ie_build_akm_suite(to + pos, microsoft_oui, suite))
if (!ie_build_wpa_akm_suite(to + pos, suite))
return false;
pos += 4;