summaryrefslogtreecommitdiff
path: root/src/nmcli
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2022-03-08 12:27:30 +0100
committerLubomir Rintel <lkundrak@v3.sk>2022-03-13 18:23:44 +0100
commit422ae6bea6f3dec49eb20f2aa969ab101441641f (patch)
tree310a06de4dec62ba0d81294b4c416c2f64130749 /src/nmcli
parentcd7687ff60b150a85391812191d114ec8a39e5b8 (diff)
downloadNetworkManager-422ae6bea6f3dec49eb20f2aa969ab101441641f.tar.gz
cli: device: factor out checking whether an AP is a WEP one
This is going to be useful elsewhere. We're going to mark WEP APs as deprecated.
Diffstat (limited to 'src/nmcli')
-rw-r--r--src/nmcli/devices.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c
index ded2a9eb8c..f3da212d31 100644
--- a/src/nmcli/devices.c
+++ b/src/nmcli/devices.c
@@ -1216,6 +1216,21 @@ get_device(NmCli *nmc, int *argc, const char *const **argv, GError **error)
return devices[i];
}
+static bool
+_ap_is_wep(NMAccessPoint *ap)
+{
+ NM80211ApFlags flags = nm_access_point_get_flags(ap);
+ NM80211ApSecurityFlags wpa_flags = nm_access_point_get_wpa_flags(ap);
+ NM80211ApSecurityFlags rsn_flags = nm_access_point_get_rsn_flags(ap);
+
+ if ((flags & NM_802_11_AP_FLAGS_PRIVACY) && (wpa_flags == NM_802_11_AP_SEC_NONE)
+ && (rsn_flags == NM_802_11_AP_SEC_NONE)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static int
compare_aps(gconstpointer a, gconstpointer b, gpointer user_data)
{
@@ -1262,7 +1277,6 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
{
NmcOutputField *arr;
gboolean active;
- NM80211ApFlags flags;
NM80211ApSecurityFlags wpa_flags, rsn_flags;
guint32 freq, bitrate;
guint8 strength;
@@ -1285,7 +1299,6 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
active = (info->active_ap == ap);
/* Get AP properties */
- flags = nm_access_point_get_flags(ap);
wpa_flags = nm_access_point_get_wpa_flags(ap);
rsn_flags = nm_access_point_get_rsn_flags(ap);
ssid = nm_access_point_get_ssid(ap);
@@ -1314,26 +1327,27 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
security_str = g_string_new(NULL);
- if ((flags & NM_802_11_AP_FLAGS_PRIVACY) && (wpa_flags == NM_802_11_AP_SEC_NONE)
- && (rsn_flags == NM_802_11_AP_SEC_NONE)) {
+ if (_ap_is_wep(ap)) {
g_string_append(security_str, "WEP ");
- }
- if (wpa_flags != NM_802_11_AP_SEC_NONE) {
- g_string_append(security_str, "WPA1 ");
- }
- if ((rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
- || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) {
- g_string_append(security_str, "WPA2 ");
- }
- if (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE) {
- g_string_append(security_str, "WPA3 ");
- }
- if (NM_FLAGS_ANY(rsn_flags, NM_802_11_AP_SEC_KEY_MGMT_OWE | NM_802_11_AP_SEC_KEY_MGMT_OWE_TM)) {
- g_string_append(security_str, "OWE ");
- }
- if ((wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
- || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) {
- g_string_append(security_str, "802.1X ");
+ } else {
+ if (wpa_flags != NM_802_11_AP_SEC_NONE) {
+ g_string_append(security_str, "WPA1 ");
+ }
+ if ((rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
+ || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) {
+ g_string_append(security_str, "WPA2 ");
+ }
+ if (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE) {
+ g_string_append(security_str, "WPA3 ");
+ }
+ if (NM_FLAGS_ANY(rsn_flags,
+ NM_802_11_AP_SEC_KEY_MGMT_OWE | NM_802_11_AP_SEC_KEY_MGMT_OWE_TM)) {
+ g_string_append(security_str, "OWE ");
+ }
+ if ((wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
+ || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) {
+ g_string_append(security_str, "802.1X ");
+ }
}
if (security_str->len > 0)