3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 02:19:26 +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; return false;
} }
/* #define RETURN_AKM(data, oui, id) \
* 802.11, Section 8.4.2.27.2 memcpy((data), (oui), 3); \
* 802.11i, Section 7.3.2.25.2 and WPA_80211_v3_1 Section 2.1 (data)[3] = (id); \
*/ return true;
static bool ie_build_akm_suite(uint8_t *data, const uint8_t *oui,
enum ie_rsn_akm_suite suite) /* 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) { switch (suite) {
case IE_RSN_AKM_SUITE_8021X: case IE_RSN_AKM_SUITE_8021X:
memcpy(data, oui, 3); RETURN_AKM(data, ieee_oui, 1);
data[3] = 1;
return true;
case IE_RSN_AKM_SUITE_PSK: case IE_RSN_AKM_SUITE_PSK:
memcpy(data, oui, 3); RETURN_AKM(data, ieee_oui, 2);
data[3] = 2;
return true;
case IE_RSN_AKM_SUITE_FT_OVER_8021X: case IE_RSN_AKM_SUITE_FT_OVER_8021X:
memcpy(data, oui, 3); RETURN_AKM(data, ieee_oui, 3);
data[3] = 3;
return true;
case IE_RSN_AKM_SUITE_FT_USING_PSK: case IE_RSN_AKM_SUITE_FT_USING_PSK:
memcpy(data, oui, 3); RETURN_AKM(data, ieee_oui, 4);
data[3] = 4;
return true;
case IE_RSN_AKM_SUITE_8021X_SHA256: case IE_RSN_AKM_SUITE_8021X_SHA256:
memcpy(data, oui, 3); RETURN_AKM(data, ieee_oui, 5);
data[3] = 5;
return true;
case IE_RSN_AKM_SUITE_PSK_SHA256: case IE_RSN_AKM_SUITE_PSK_SHA256:
memcpy(data, oui, 3); RETURN_AKM(data, ieee_oui, 6);
data[3] = 6;
return true;
case IE_RSN_AKM_SUITE_TDLS: case IE_RSN_AKM_SUITE_TDLS:
memcpy(data, oui, 3); RETURN_AKM(data, ieee_oui, 7);
data[3] = 7;
return true;
case IE_RSN_AKM_SUITE_SAE_SHA256: case IE_RSN_AKM_SUITE_SAE_SHA256:
memcpy(data, oui, 3); RETURN_AKM(data, ieee_oui, 8);
data[3] = 8;
return true;
case IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256: case IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256:
memcpy(data, oui, 3); RETURN_AKM(data, ieee_oui, 9);
data[3] = 9; }
return true;
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; return false;
@ -876,7 +874,7 @@ bool ie_build_rsne(const struct ie_rsn_info *info, uint8_t *to)
if (pos + 4 > 248) if (pos + 4 > 248)
return false; 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; return false;
pos += 4; pos += 4;
@ -1287,7 +1285,7 @@ bool ie_build_wpa(const struct ie_rsn_info *info, uint8_t *to)
if (!(info->akm_suites & suite)) if (!(info->akm_suites & suite))
continue; continue;
if (!ie_build_akm_suite(to + pos, microsoft_oui, suite)) if (!ie_build_wpa_akm_suite(to + pos, suite))
return false; return false;
pos += 4; pos += 4;