3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-20 10:52:33 +01:00

wiphy: Store RSN IE inside struct bss

This commit is contained in:
Denis Kenzior 2015-02-24 23:11:48 -06:00
parent c9bab96237
commit 975953dd89

View File

@ -58,6 +58,7 @@ struct bss {
uint32_t frequency; uint32_t frequency;
int32_t signal_strength; int32_t signal_strength;
uint16_t capability; uint16_t capability;
uint8_t rsne[256];
}; };
struct netdev { struct netdev {
@ -766,7 +767,6 @@ error:
} }
static bool parse_ie(struct bss *bss, const uint8_t **ssid, int *ssid_len, static bool parse_ie(struct bss *bss, const uint8_t **ssid, int *ssid_len,
struct ie_rsn_info *rsne,
const void *data, uint16_t len) const void *data, uint16_t len)
{ {
struct ie_tlv_iter iter; struct ie_tlv_iter iter;
@ -775,7 +775,6 @@ static bool parse_ie(struct bss *bss, const uint8_t **ssid, int *ssid_len,
while (ie_tlv_iter_next(&iter)) { while (ie_tlv_iter_next(&iter)) {
uint8_t tag = ie_tlv_iter_get_tag(&iter); uint8_t tag = ie_tlv_iter_get_tag(&iter);
int ret;
switch (tag) { switch (tag) {
case IE_TYPE_SSID: case IE_TYPE_SSID:
@ -788,13 +787,7 @@ static bool parse_ie(struct bss *bss, const uint8_t **ssid, int *ssid_len,
*ssid = iter.data; *ssid = iter.data;
break; break;
case IE_TYPE_RSN: case IE_TYPE_RSN:
ret = ie_parse_rsne_from_data(iter.data - 2, memcpy(bss->rsne, iter.data - 2, iter.len + 2);
iter.len + 2, rsne);
if (ret < 0) {
l_debug("Cannot parse RSN field (%d, %s)",
ret, strerror(-ret));
return false;
}
break; break;
default: default:
break; break;
@ -823,9 +816,10 @@ static void parse_bss(struct netdev *netdev, struct l_genl_attr *attr)
const uint8_t *ssid = NULL; const uint8_t *ssid = NULL;
int ssid_len; int ssid_len;
struct network *network = NULL; struct network *network = NULL;
struct ie_rsn_info rsne = { 0 }; struct ie_rsn_info rsne;
enum scan_ssid_security ssid_security; enum scan_ssid_security ssid_security;
const char *id; const char *id;
int res;
bss = l_new(struct bss, 1); bss = l_new(struct bss, 1);
@ -864,8 +858,7 @@ static void parse_bss(struct netdev *netdev, struct l_genl_attr *attr)
bss->signal_strength = *((int32_t *) data); bss->signal_strength = *((int32_t *) data);
break; break;
case NL80211_BSS_INFORMATION_ELEMENTS: case NL80211_BSS_INFORMATION_ELEMENTS:
if (!parse_ie(bss, &ssid, &ssid_len, &rsne, data, if (!parse_ie(bss, &ssid, &ssid_len, data, len)) {
len)) {
l_warn("Could not parse BSS IEs"); l_warn("Could not parse BSS IEs");
goto fail; goto fail;
} }
@ -879,6 +872,16 @@ static void parse_bss(struct netdev *netdev, struct l_genl_attr *attr)
goto fail; goto fail;
} }
/*
* Length was already validated by parse_ie, so use the one from the
* IE directly.
*/
res = ie_parse_rsne_from_data(bss->rsne, bss->rsne[1] + 2, &rsne);
if (res < 0) {
l_debug("Cannot parse RSN field (%d, %s)", res, strerror(-res));
goto fail;
}
ssid_security = scan_get_ssid_security(bss->capability, &rsne); ssid_security = scan_get_ssid_security(bss->capability, &rsne);
id = iwd_network_get_id(ssid, ssid_len, ssid_security); id = iwd_network_get_id(ssid, ssid_len, ssid_security);