mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 11:00:09 +01:00
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:
parent
cd7687ff60
commit
422ae6bea6
1 changed files with 35 additions and 21 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue