Skip to content

Commit

Permalink
Revert "Added support to show security info in Wi-Fi Advanced setting…
Browse files Browse the repository at this point in the history
…s. (#210)"

After benchmarking on multiple devices, we identified that this commit causes significant performance drops. (110 Mbps to 50 Mbps on the latest internal version)

This reverts commit fcbf4b9.
  • Loading branch information
williambj1 committed Jan 16, 2021
1 parent cd5889b commit 36d08e0
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 87 deletions.
86 changes: 7 additions & 79 deletions ClientKit/Api.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,6 @@

static pthread_mutex_t* api_mutex = NULL;

enum itl80211_security get_security_type(struct ioctl_network_info info) {
if ((info.supported_rsnprotos & ITL80211_PROTO_RSN) != 0) {
//wpa2
if ((info.rsn_akms & ITL80211_AKM_8021X) != 0) {
if ((info.supported_rsnprotos & ITL80211_PROTO_WPA) != 0) {
return ITL80211_SECURITY_WPA_ENTERPRISE_MIXED;
}
return ITL80211_SECURITY_WPA2_ENTERPRISE;
} else if ((info.rsn_akms & ITL80211_AKM_PSK) != 0) {
if ((info.supported_rsnprotos & ITL80211_PROTO_WPA) != 0) {
return ITL80211_SECURITY_WPA_PERSONAL_MIXED;
}
return ITL80211_SECURITY_WPA2_PERSONAL;
} else if ((info.rsn_akms & ITL80211_AKM_SHA256_8021X) != 0) {
return ITL80211_SECURITY_WPA2_ENTERPRISE;
} else if ((info.rsn_akms & ITL80211_AKM_SHA256_PSK) != 0) {
return ITL80211_SECURITY_PERSONAL;
}
} else if ((info.supported_rsnprotos & ITL80211_PROTO_WPA) != 0) {
//wpa
if ((info.rsn_akms & ITL80211_AKM_8021X) != 0) {
return ITL80211_SECURITY_WPA_ENTERPRISE;
} else if ((info.rsn_akms & ITL80211_AKM_PSK) != 0) {
return ITL80211_SECURITY_WPA_PERSONAL;
} else if ((info.rsn_akms & ITL80211_AKM_SHA256_8021X) != 0) {
return ITL80211_SECURITY_WPA_ENTERPRISE;
} else if ((info.rsn_akms & ITL80211_AKM_SHA256_PSK) != 0) {
return ITL80211_SECURITY_ENTERPRISE;
}
} else if (info.supported_rsnprotos == 0) {
return ITL80211_SECURITY_NONE;
}
//TODO wpa3
return ITL80211_SECURITY_UNKNOWN;
}

bool get_platform_info(platform_info_t *info) {
memset(info, 0, sizeof(platform_info_t));

Expand Down Expand Up @@ -101,14 +65,17 @@ bool get_80211_state(uint32_t *state) {
return false;
}

bool get_networks(network_info_list_t *list) {
bool get_network_list(network_info_list_t *list) {
memset(list, 0, sizeof(network_info_list_t));

struct ioctl_scan scan;
struct ioctl_network_info network_info_ret;
io_connect_t con;
struct ioctl_sta_info sta_info;
scan.version = IOCTL_VERSION;

get_station_info(&sta_info);

if (!open_adapter(&con)) {
goto error;
}
Expand All @@ -117,6 +84,9 @@ bool get_networks(network_info_list_t *list) {
if (list->count >= MAX_NETWORK_LIST_LENGTH) {
break;
}
if (strlen(sta_info.ssid) > 0 && memcmp(sta_info.bssid, network_info_ret.bssid, ETHER_ADDR_LEN) == 0) {
continue;
}
struct ioctl_network_info *info = &list->networks[list->count++];
memcpy(info, &network_info_ret, sizeof(struct ioctl_network_info));
}
Expand All @@ -131,48 +101,6 @@ bool get_networks(network_info_list_t *list) {
return false;
}

bool get_network_list(network_info_list_t *list) {
bool return_value = get_networks(list);

if (return_value) {
// Remove sta from list if available
struct ioctl_sta_info sta_info;
get_station_info(&sta_info);
for (int i = 0; i < list->count; i++) {
struct ioctl_network_info* info = &list->networks[i];
if (strlen(sta_info.ssid) > 0 && memcmp(sta_info.bssid, info->bssid, ETHER_ADDR_LEN) == 0) {
// Replace sta network with last element in list and replace the last element in array with zero.
memset(info, 0, sizeof(struct ioctl_network_info));
if (i + 1 < list->count) {
struct ioctl_network_info replaceWith = list->networks[list->count - 1];
list->networks[i] = replaceWith;
memset(&list->networks[list->count - 1], 0, sizeof(struct ioctl_network_info));
}
list->count--;
break;
}
}
}

return return_value;
}

enum itl80211_security get_security_info_sta(station_info_t *sta_info) {
enum itl80211_security security = ITL80211_SECURITY_UNKNOWN;
network_info_list_t *list = (network_info_list_t *) malloc(sizeof(network_info_list_t));
if (get_networks(list)) {
for (int i = 0; i < list->count; i++) {
struct ioctl_network_info info = list->networks[i];
if (strlen(sta_info->ssid) > 0 && memcmp(sta_info->bssid, info.bssid, ETHER_ADDR_LEN) == 0) {
security = get_security_type(info);
break;
}
}
}
free(list);
return security;
}

bool connect_network(const char *ssid, const char *pwd) {
if (associate_ssid(ssid, pwd) != KERN_SUCCESS) {
goto error;
Expand Down
4 changes: 0 additions & 4 deletions ClientKit/Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ typedef struct {

typedef struct ioctl_sta_info station_info_t;

enum itl80211_security get_security_info_sta(station_info_t *sta_info);

enum itl80211_security get_security_type(struct ioctl_network_info info);

bool open_adapter(io_connect_t *connection_t);

void close_adapter(io_connect_t connection);
Expand Down
5 changes: 3 additions & 2 deletions HeliPort/Appearance/StatusMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ final class StatusMenu: NSMenu, NSMenuDelegate {
enableLoggingItem,
diagnoseItem,

securityItem,
countryCodeItem,
nssItem,

Expand Down Expand Up @@ -505,7 +506,7 @@ final class StatusMenu: NSMenu, NSMenuDelegate {
ipAddr = ipAddress ?? .unknown
routerAddr = routerAddress ?? .unknown
internet = isReachable ? .reachable : .unreachable
security = "\(get_security_info_sta(&staInfo))"
security = .unknown
bssid = String(format: "%02x:%02x:%02x:%02x:%02x:%02x",
staInfo.bssid.0,
staInfo.bssid.1,
Expand All @@ -519,7 +520,7 @@ final class StatusMenu: NSMenu, NSMenuDelegate {
rssi = "\(staInfo.rssi) dBm"
noise = "\(staInfo.noise) dBm"
txRate = "\(staInfo.rate) Mbps"
phyMode = "\(staInfo.op_mode)"
phyMode = staInfo.op_mode.description
mcsIndex = "\(staInfo.cur_mcs)"
nss = .unknown
}
Expand Down
38 changes: 37 additions & 1 deletion HeliPort/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ final class NetworkManager {
ssid: ssid,
rssi: Int(network.rssi)
)
networkInfo.auth.security = get_security_type(network)
networkInfo.auth.security = getSecurityType(network)
result.insert(networkInfo)
}

Expand Down Expand Up @@ -253,4 +253,40 @@ final class NetworkManager {
// ipV4 has priority
return ipV4 ?? ipV6
}

class func getSecurityType(_ info: ioctl_network_info) -> itl80211_security {
if info.supported_rsnprotos & ITL80211_PROTO_RSN.rawValue != 0 {
//wpa2
if info.rsn_akms & ITL80211_AKM_8021X.rawValue != 0 {
if info.supported_rsnprotos & ITL80211_PROTO_WPA.rawValue != 0 {
return ITL80211_SECURITY_WPA_ENTERPRISE_MIXED
}
return ITL80211_SECURITY_WPA2_ENTERPRISE
} else if info.rsn_akms & ITL80211_AKM_PSK.rawValue != 0 {
if info.supported_rsnprotos & ITL80211_PROTO_WPA.rawValue != 0 {
return ITL80211_SECURITY_WPA_PERSONAL_MIXED
}
return ITL80211_SECURITY_WPA2_PERSONAL
} else if info.rsn_akms & ITL80211_AKM_SHA256_8021X.rawValue != 0 {
return ITL80211_SECURITY_WPA2_ENTERPRISE
} else if info.rsn_akms & ITL80211_AKM_SHA256_PSK.rawValue != 0 {
return ITL80211_SECURITY_PERSONAL
}
} else if info.supported_rsnprotos & ITL80211_PROTO_WPA.rawValue != 0 {
//wpa
if info.rsn_akms & ITL80211_AKM_8021X.rawValue != 0 {
return ITL80211_SECURITY_WPA_ENTERPRISE
} else if info.rsn_akms & ITL80211_AKM_PSK.rawValue != 0 {
return ITL80211_SECURITY_WPA_PERSONAL
} else if info.rsn_akms & ITL80211_AKM_SHA256_8021X.rawValue != 0 {
return ITL80211_SECURITY_WPA_ENTERPRISE
} else if info.rsn_akms & ITL80211_AKM_SHA256_PSK.rawValue != 0 {
return ITL80211_SECURITY_ENTERPRISE
}
} else if info.supported_rsnprotos == 0 {
return ITL80211_SECURITY_NONE
}
//TODO wpa3
return ITL80211_SECURITY_UNKNOWN
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension itl80211_security: CustomStringConvertible {
case ITL80211_SECURITY_WPA3_TRANSITION:
return "WPA3 Transition"
default:
return NSLocalizedString("Unknown")
return "Unknown"
}
}
}
Expand Down

0 comments on commit 36d08e0

Please sign in to comment.