3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 17:59:25 +01:00

nl80211util: Move nl80211_append_rsn_attributes

This commit is contained in:
Denis Kenzior 2023-11-26 22:38:42 -06:00 committed by Marcel Holtmann
parent 5a4fc931e7
commit b10ef09186
4 changed files with 47 additions and 41 deletions

View File

@ -407,6 +407,7 @@ tools_hwsim_SOURCES = tools/hwsim.c src/mpdu.h \
src/storage.h src/storage.c \ src/storage.h src/storage.c \
src/common.h src/common.c \ src/common.h src/common.c \
src/band.h src/band.c \ src/band.h src/band.c \
src/ie.h src/ie.c \
src/crypto.h src/crypto.c src/crypto.h src/crypto.c
tools_hwsim_LDADD = $(ell_ldadd) tools_hwsim_LDADD = $(ell_ldadd)

View File

@ -2445,45 +2445,6 @@ static void netdev_driver_connected(struct netdev *netdev)
eapol_register(netdev->sm); eapol_register(netdev->sm);
} }
static void netdev_append_nl80211_rsn_attributes(struct l_genl_msg *msg,
struct handshake_state *hs)
{
uint32_t nl_cipher;
uint32_t nl_akm;
uint32_t wpa_version;
nl_cipher = ie_rsn_cipher_suite_to_cipher(hs->pairwise_cipher);
L_WARN_ON(!nl_cipher);
l_genl_msg_append_attr(msg, NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
4, &nl_cipher);
nl_cipher = ie_rsn_cipher_suite_to_cipher(hs->group_cipher);
L_WARN_ON(!nl_cipher);
l_genl_msg_append_attr(msg, NL80211_ATTR_CIPHER_SUITE_GROUP,
4, &nl_cipher);
if (hs->mfp) {
uint32_t use_mfp = NL80211_MFP_REQUIRED;
l_genl_msg_append_attr(msg, NL80211_ATTR_USE_MFP, 4, &use_mfp);
}
nl_akm = ie_rsn_akm_suite_to_akm(hs->akm_suite);
L_WARN_ON(!nl_akm);
l_genl_msg_append_attr(msg, NL80211_ATTR_AKM_SUITES, 4, &nl_akm);
if (IE_AKM_IS_SAE(hs->akm_suite))
wpa_version = NL80211_WPA_VERSION_3;
else if (hs->wpa_ie)
wpa_version = NL80211_WPA_VERSION_1;
else
wpa_version = NL80211_WPA_VERSION_2;
l_genl_msg_append_attr(msg, NL80211_ATTR_WPA_VERSIONS,
4, &wpa_version);
}
static struct l_genl_msg *netdev_build_cmd_connect(struct netdev *netdev, static struct l_genl_msg *netdev_build_cmd_connect(struct netdev *netdev,
struct handshake_state *hs, struct handshake_state *hs,
const uint8_t *prev_bssid, const uint8_t *prev_bssid,
@ -2540,7 +2501,7 @@ static struct l_genl_msg *netdev_build_cmd_connect(struct netdev *netdev,
l_genl_msg_append_attr(msg, NL80211_ATTR_SOCKET_OWNER, 0, NULL); l_genl_msg_append_attr(msg, NL80211_ATTR_SOCKET_OWNER, 0, NULL);
if (is_rsn) { if (is_rsn) {
netdev_append_nl80211_rsn_attributes(msg, hs); nl80211_append_rsn_attributes(msg, hs);
c_iov = iov_ie_append(iov, n_iov, c_iov, hs->supplicant_ie); c_iov = iov_ie_append(iov, n_iov, c_iov, hs->supplicant_ie);
} }
@ -2888,7 +2849,7 @@ static struct l_genl_msg *netdev_build_cmd_associate_common(
l_genl_msg_append_attr(msg, NL80211_ATTR_SOCKET_OWNER, 0, NULL); l_genl_msg_append_attr(msg, NL80211_ATTR_SOCKET_OWNER, 0, NULL);
if (is_rsn) if (is_rsn)
netdev_append_nl80211_rsn_attributes(msg, hs); nl80211_append_rsn_attributes(msg, hs);
if (is_rsn || hs->settings_8021x) { if (is_rsn || hs->settings_8021x) {
l_genl_msg_append_attr(msg, NL80211_ATTR_CONTROL_PORT, l_genl_msg_append_attr(msg, NL80211_ATTR_CONTROL_PORT,

View File

@ -32,6 +32,8 @@
#include "src/nl80211util.h" #include "src/nl80211util.h"
#include "src/band.h" #include "src/band.h"
#include "src/ie.h"
#include "src/handshake.h"
#include "src/util.h" #include "src/util.h"
typedef bool (*attr_handler)(const void *data, uint16_t len, void *o); typedef bool (*attr_handler)(const void *data, uint16_t len, void *o);
@ -687,3 +689,41 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs,
return 0; return 0;
} }
void nl80211_append_rsn_attributes(struct l_genl_msg *msg,
struct handshake_state *hs)
{
uint32_t nl_cipher;
uint32_t nl_akm;
uint32_t wpa_version;
nl_cipher = ie_rsn_cipher_suite_to_cipher(hs->pairwise_cipher);
L_WARN_ON(!nl_cipher);
l_genl_msg_append_attr(msg, NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
4, &nl_cipher);
nl_cipher = ie_rsn_cipher_suite_to_cipher(hs->group_cipher);
L_WARN_ON(!nl_cipher);
l_genl_msg_append_attr(msg, NL80211_ATTR_CIPHER_SUITE_GROUP,
4, &nl_cipher);
if (hs->mfp) {
uint32_t use_mfp = NL80211_MFP_REQUIRED;
l_genl_msg_append_attr(msg, NL80211_ATTR_USE_MFP, 4, &use_mfp);
}
nl_akm = ie_rsn_akm_suite_to_akm(hs->akm_suite);
L_WARN_ON(!nl_akm);
l_genl_msg_append_attr(msg, NL80211_ATTR_AKM_SUITES, 4, &nl_akm);
if (IE_AKM_IS_SAE(hs->akm_suite))
wpa_version = NL80211_WPA_VERSION_3;
else if (hs->wpa_ie)
wpa_version = NL80211_WPA_VERSION_1;
else
wpa_version = NL80211_WPA_VERSION_2;
l_genl_msg_append_attr(msg, NL80211_ATTR_WPA_VERSIONS,
4, &wpa_version);
}

View File

@ -25,6 +25,7 @@
struct band_chandef; struct band_chandef;
struct scan_freq_set; struct scan_freq_set;
struct band_freq_attrs; struct band_freq_attrs;
struct handshake_state;
int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...); int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...);
@ -90,3 +91,6 @@ int nl80211_parse_supported_frequencies(struct l_genl_attr *band_freqs,
struct scan_freq_set *supported_list, struct scan_freq_set *supported_list,
struct band_freq_attrs *list, struct band_freq_attrs *list,
size_t num_channels); size_t num_channels);
void nl80211_append_rsn_attributes(struct l_genl_msg *msg,
struct handshake_state *hs);