mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 13:02:44 +01:00
scan: Move scan_get_security to common.c
This commit is contained in:
parent
7c18e3cdfe
commit
4c59569f0c
22
src/common.c
22
src/common.c
@ -29,6 +29,7 @@
|
||||
|
||||
#include "src/iwd.h"
|
||||
#include "src/common.h"
|
||||
#include "src/ie.h"
|
||||
|
||||
const char *security_to_str(enum security security)
|
||||
{
|
||||
@ -61,3 +62,24 @@ bool security_from_str(const char *str, enum security *security)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum security security_determine(uint16_t bss_capability,
|
||||
const struct ie_rsn_info *info)
|
||||
{
|
||||
if (info && (info->akm_suites & IE_RSN_AKM_SUITE_PSK ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_PSK_SHA256 ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_FT_USING_PSK ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_SAE_SHA256 ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256))
|
||||
return SECURITY_PSK;
|
||||
|
||||
if (info && (info->akm_suites & IE_RSN_AKM_SUITE_8021X ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_8021X_SHA256 ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_FT_OVER_8021X))
|
||||
return SECURITY_8021X;
|
||||
|
||||
if (bss_capability & IE_BSS_CAP_PRIVACY)
|
||||
return SECURITY_WEP;
|
||||
|
||||
return SECURITY_NONE;
|
||||
}
|
||||
|
12
src/common.h
12
src/common.h
@ -20,9 +20,19 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
enum security;
|
||||
struct ie_rsn_info;
|
||||
|
||||
enum security {
|
||||
SECURITY_NONE,
|
||||
SECURITY_WEP,
|
||||
SECURITY_PSK,
|
||||
SECURITY_8021X,
|
||||
};
|
||||
|
||||
const char *security_to_str(enum security security);
|
||||
bool security_from_str(const char *str, enum security *security);
|
||||
enum security security_determine(uint16_t bss_capability,
|
||||
const struct ie_rsn_info *info);
|
||||
|
@ -278,9 +278,9 @@ static void process_bss(struct device *device, struct scan_bss *bss,
|
||||
if (r != -ENOENT)
|
||||
return;
|
||||
|
||||
security = scan_get_security(bss->capability, NULL);
|
||||
security = security_determine(bss->capability, NULL);
|
||||
} else
|
||||
security = scan_get_security(bss->capability, &info);
|
||||
security = security_determine(bss->capability, &info);
|
||||
|
||||
path = iwd_network_get_path(device, ssid, security);
|
||||
|
||||
@ -1092,9 +1092,9 @@ static bool device_roam_scan_notify(uint32_t wiphy_id, uint32_t ifindex,
|
||||
if (r != -ENOENT)
|
||||
goto next;
|
||||
|
||||
security = scan_get_security(bss->capability, NULL);
|
||||
security = security_determine(bss->capability, NULL);
|
||||
} else
|
||||
security = scan_get_security(bss->capability, &info);
|
||||
security = security_determine(bss->capability, &info);
|
||||
|
||||
if (security != orig_security)
|
||||
goto next;
|
||||
|
@ -24,13 +24,6 @@
|
||||
|
||||
struct device;
|
||||
|
||||
enum security {
|
||||
SECURITY_NONE,
|
||||
SECURITY_WEP,
|
||||
SECURITY_PSK,
|
||||
SECURITY_8021X,
|
||||
};
|
||||
|
||||
typedef void (*iwd_device_foreach_func)(struct device *, void *data);
|
||||
|
||||
void __iwd_device_foreach(iwd_device_foreach_func func, void *user_data);
|
||||
|
21
src/scan.c
21
src/scan.c
@ -633,27 +633,6 @@ static bool start_next_scan_request(struct scan_context *sc)
|
||||
return false;
|
||||
}
|
||||
|
||||
enum security scan_get_security(enum ie_bss_capability bss_capability,
|
||||
const struct ie_rsn_info *info)
|
||||
{
|
||||
if (info && (info->akm_suites & IE_RSN_AKM_SUITE_PSK ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_PSK_SHA256 ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_FT_USING_PSK ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_SAE_SHA256 ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256))
|
||||
return SECURITY_PSK;
|
||||
|
||||
if (info && (info->akm_suites & IE_RSN_AKM_SUITE_8021X ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_8021X_SHA256 ||
|
||||
info->akm_suites & IE_RSN_AKM_SUITE_FT_OVER_8021X))
|
||||
return SECURITY_8021X;
|
||||
|
||||
if (bss_capability & IE_BSS_CAP_PRIVACY)
|
||||
return SECURITY_WEP;
|
||||
|
||||
return SECURITY_NONE;
|
||||
}
|
||||
|
||||
static bool scan_parse_bss_information_elements(struct scan_bss *bss,
|
||||
const void *data, uint16_t len)
|
||||
{
|
||||
|
@ -92,8 +92,6 @@ void scan_sched_start(struct l_genl_family *nl80211, uint32_t ifindex,
|
||||
uint32_t scan_interval, scan_func_t callback,
|
||||
void *user_data);
|
||||
|
||||
enum security scan_get_security(enum ie_bss_capability bss_cap,
|
||||
const struct ie_rsn_info *info);
|
||||
void scan_bss_free(struct scan_bss *bss);
|
||||
int scan_bss_rank_compare(const void *a, const void *b, void *user);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user