mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-21 03:32:42 +01:00
wiphy: Add utility to check if bss ciphers compatible
Move the BSS's supported ciphers checks from network_bss_select to a new function in wiphy.c so we can reuse it in device.c.
This commit is contained in:
parent
969441e48d
commit
99e58db152
@ -483,22 +483,15 @@ struct scan_bss *network_bss_select(struct network *network)
|
||||
|
||||
case SECURITY_PSK:
|
||||
case SECURITY_8021X:
|
||||
/* Pick the first bss that advertises any cipher we support. */
|
||||
/*
|
||||
* Pick the first bss that advertises ciphers compatible with
|
||||
* the wiphy.
|
||||
*/
|
||||
for (bss_entry = l_queue_get_entries(bss_list); bss_entry;
|
||||
bss_entry = bss_entry->next) {
|
||||
struct scan_bss *bss = bss_entry->data;
|
||||
struct ie_rsn_info rsn;
|
||||
|
||||
memset(&rsn, 0, sizeof(rsn));
|
||||
scan_bss_get_rsn_info(bss, &rsn);
|
||||
|
||||
if (rsn.mfpr && !wiphy_select_cipher(wiphy,
|
||||
rsn.group_management_cipher))
|
||||
continue;
|
||||
|
||||
if (wiphy_select_cipher(wiphy, rsn.pairwise_ciphers) &&
|
||||
wiphy_select_cipher(wiphy,
|
||||
rsn.group_cipher))
|
||||
if (wiphy_can_connect(wiphy, bss))
|
||||
return bss;
|
||||
}
|
||||
|
||||
|
24
src/wiphy.c
24
src/wiphy.c
@ -120,6 +120,30 @@ uint32_t wiphy_get_supported_bands(struct wiphy *wiphy)
|
||||
return scan_freq_set_get_bands(wiphy->supported_freqs);
|
||||
}
|
||||
|
||||
bool wiphy_can_connect(struct wiphy *wiphy, struct scan_bss *bss)
|
||||
{
|
||||
struct ie_rsn_info rsn_info;
|
||||
int r;
|
||||
|
||||
memset(&rsn_info, 0, sizeof(rsn_info));
|
||||
r = scan_bss_get_rsn_info(bss, &rsn_info);
|
||||
|
||||
if (r == 0) {
|
||||
if (!wiphy_select_cipher(wiphy, rsn_info.pairwise_ciphers))
|
||||
return false;
|
||||
|
||||
if (!wiphy_select_cipher(wiphy, rsn_info.group_cipher))
|
||||
return false;
|
||||
|
||||
if (rsn_info.mfpr && !wiphy_select_cipher(wiphy,
|
||||
rsn_info.group_management_cipher))
|
||||
return false;
|
||||
} else if (r != -ENOENT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void wiphy_print_basic_info(struct wiphy *wiphy)
|
||||
{
|
||||
uint32_t bands;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
struct wiphy;
|
||||
struct scan_bss;
|
||||
|
||||
enum ie_rsn_cipher_suite wiphy_select_cipher(struct wiphy *wiphy,
|
||||
uint16_t mask);
|
||||
@ -32,6 +33,7 @@ struct wiphy *wiphy_find(int wiphy_id);
|
||||
|
||||
const char *wiphy_get_path(struct wiphy *wiphy);
|
||||
uint32_t wiphy_get_supported_bands(struct wiphy *wiphy);
|
||||
bool wiphy_can_connect(struct wiphy *wiphy, struct scan_bss *bss);
|
||||
|
||||
bool wiphy_init(struct l_genl_family *in);
|
||||
bool wiphy_exit(void);
|
||||
|
Loading…
Reference in New Issue
Block a user