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.
This commit is contained in:
@@ -1216,6 +1216,21 @@ get_device(NmCli *nmc, int *argc, const char *const **argv, GError **error)
|
|||||||
return devices[i];
|
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
|
static int
|
||||||
compare_aps(gconstpointer a, gconstpointer b, gpointer user_data)
|
compare_aps(gconstpointer a, gconstpointer b, gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -1262,7 +1277,6 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
|
|||||||
{
|
{
|
||||||
NmcOutputField *arr;
|
NmcOutputField *arr;
|
||||||
gboolean active;
|
gboolean active;
|
||||||
NM80211ApFlags flags;
|
|
||||||
NM80211ApSecurityFlags wpa_flags, rsn_flags;
|
NM80211ApSecurityFlags wpa_flags, rsn_flags;
|
||||||
guint32 freq, bitrate;
|
guint32 freq, bitrate;
|
||||||
guint8 strength;
|
guint8 strength;
|
||||||
@@ -1285,7 +1299,6 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
|
|||||||
active = (info->active_ap == ap);
|
active = (info->active_ap == ap);
|
||||||
|
|
||||||
/* Get AP properties */
|
/* Get AP properties */
|
||||||
flags = nm_access_point_get_flags(ap);
|
|
||||||
wpa_flags = nm_access_point_get_wpa_flags(ap);
|
wpa_flags = nm_access_point_get_wpa_flags(ap);
|
||||||
rsn_flags = nm_access_point_get_rsn_flags(ap);
|
rsn_flags = nm_access_point_get_rsn_flags(ap);
|
||||||
ssid = nm_access_point_get_ssid(ap);
|
ssid = nm_access_point_get_ssid(ap);
|
||||||
@@ -1314,10 +1327,9 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
|
|||||||
|
|
||||||
security_str = g_string_new(NULL);
|
security_str = g_string_new(NULL);
|
||||||
|
|
||||||
if ((flags & NM_802_11_AP_FLAGS_PRIVACY) && (wpa_flags == NM_802_11_AP_SEC_NONE)
|
if (_ap_is_wep(ap)) {
|
||||||
&& (rsn_flags == NM_802_11_AP_SEC_NONE)) {
|
|
||||||
g_string_append(security_str, "WEP ");
|
g_string_append(security_str, "WEP ");
|
||||||
}
|
} else {
|
||||||
if (wpa_flags != NM_802_11_AP_SEC_NONE) {
|
if (wpa_flags != NM_802_11_AP_SEC_NONE) {
|
||||||
g_string_append(security_str, "WPA1 ");
|
g_string_append(security_str, "WPA1 ");
|
||||||
}
|
}
|
||||||
@@ -1328,13 +1340,15 @@ fill_output_access_point(NMAccessPoint *ap, const APInfo *info)
|
|||||||
if (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE) {
|
if (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE) {
|
||||||
g_string_append(security_str, "WPA3 ");
|
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)) {
|
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 ");
|
g_string_append(security_str, "OWE ");
|
||||||
}
|
}
|
||||||
if ((wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
|
if ((wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
|
||||||
|| (rsn_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 ");
|
g_string_append(security_str, "802.1X ");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (security_str->len > 0)
|
if (security_str->len > 0)
|
||||||
g_string_truncate(security_str, security_str->len - 1); /* Chop off last space */
|
g_string_truncate(security_str, security_str->len - 1); /* Chop off last space */
|
||||||
|
Reference in New Issue
Block a user