From 8f73bc825f7e1c8c4237e62b54f76251948f3d8b Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Wed, 28 Jan 2015 14:14:53 +0200 Subject: [PATCH] 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. --- src/scan.c | 19 +++++++++++++++++++ src/scan.h | 10 ++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/scan.c b/src/scan.c index 68356b62..8c052640 100644 --- a/src/scan.c +++ b/src/scan.c @@ -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; +} diff --git a/src/scan.h b/src/scan.h index 4a10d491..0ec95c6a 100644 --- a/src/scan.h +++ b/src/scan.h @@ -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);