scan: Add utility to categorize BSS security type

Utility function gets the RSNE information element and
figures out whether the SSID is Open, WEP, PSK or 802.1X
network.
This commit is contained in:
Jukka Rissanen 2015-01-28 14:14:53 +02:00 committed by Denis Kenzior
parent 27b45f926b
commit 8f73bc825f
2 changed files with 29 additions and 0 deletions

View File

@ -35,6 +35,7 @@
#include "linux/nl80211.h"
#include "src/iwd.h"
#include "src/wiphy.h"
#include "src/ie.h"
#include "src/scan.h"
void scan_start(struct l_genl_family *nl80211, uint32_t ifindex,
@ -79,3 +80,21 @@ void scan_get_results(struct l_genl_family *nl80211, uint32_t ifindex,
l_genl_family_dump(nl80211, msg, callback, user_data, scan_done);
l_genl_msg_unref(msg);
}
enum scan_ssid_security scan_get_ssid_security(
enum ie_bss_capability bss_capability,
struct ie_rsn_info *info)
{
if (bss_capability & IE_BSS_CAP_PRIVACY)
return SCAN_SSID_SECURITY_WEP;
if (!info)
return SCAN_SSID_SECURITY_NONE;
if (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)
return SCAN_SSID_SECURITY_PSK;
return SCAN_SSID_SECURITY_8021X;
}

View File

@ -20,6 +20,13 @@
*
*/
enum scan_ssid_security {
SCAN_SSID_SECURITY_NONE,
SCAN_SSID_SECURITY_WEP,
SCAN_SSID_SECURITY_PSK,
SCAN_SSID_SECURITY_8021X,
};
typedef void (*scan_func_t)(struct l_genl_msg *msg, void *user_data);
typedef void (*scan_done_func_t)(void *user_data);
@ -33,3 +40,6 @@ void scan_sched_start(struct l_genl_family *nl80211, uint32_t ifindex,
void scan_get_results(struct l_genl_family *nl80211, uint32_t ifindex,
scan_func_t callback, scan_done_func_t scan_done,
void *user_data);
enum scan_ssid_security scan_get_ssid_security(enum ie_bss_capability bss_cap,
struct ie_rsn_info *info);