From 0a7c87ce4a44289e6d94489e3a800d3a63bf5fd8 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 12 Sep 2019 09:51:06 +0200 Subject: cli: add kill switch indication to "nmcli" output There is some guess work done on the client side. Perhaps the o.fd.NM.Device could be extended to indicate which kill switch is the device disabled by. This could be good enough for now though. --- clients/cli/general.c | 35 +++++++++++++++++++++++++++++++++++ clients/cli/nmcli.c | 2 ++ clients/common/nm-meta-setting-desc.h | 1 + man/nmcli.xml | 7 +++++++ 4 files changed, 45 insertions(+) diff --git a/clients/cli/general.c b/clients/cli/general.c index b70edf9217..a6230cc4de 100644 --- a/clients/cli/general.c +++ b/clients/cli/general.c @@ -1145,6 +1145,41 @@ device_overview (NmCli *nmc, NMDevice *device) g_string_append_printf (outbuf, "%s, ", tmp); g_free (tmp); } + + switch (nm_device_get_device_type (device)) { + case NM_DEVICE_TYPE_WIFI: + case NM_DEVICE_TYPE_OLPC_MESH: + case NM_DEVICE_TYPE_WIFI_P2P: + if (!nm_client_wireless_get_enabled (nmc->client)) { + tmp = nmc_colorize (&nmc->nmc_config, NM_META_COLOR_DEVICE_DISABLED, _("sw disabled")); + g_string_append_printf (outbuf, "%s, ", tmp); + g_free (tmp); + } + if (!nm_client_wireless_hardware_get_enabled (nmc->client)) { + tmp = nmc_colorize (&nmc->nmc_config, NM_META_COLOR_DEVICE_DISABLED, _("hw disabled")); + g_string_append_printf (outbuf, "%s, ", tmp); + g_free (tmp); + } + break; + case NM_DEVICE_TYPE_MODEM: + if ( nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)) + & (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) { + if (!nm_client_wwan_get_enabled (nmc->client)) { + tmp = nmc_colorize (&nmc->nmc_config, NM_META_COLOR_DEVICE_DISABLED, _("sw disabled")); + g_string_append_printf (outbuf, "%s, ", tmp); + g_free (tmp); + } + if (!nm_client_wwan_hardware_get_enabled (nmc->client)) { + tmp = nmc_colorize (&nmc->nmc_config, NM_META_COLOR_DEVICE_DISABLED, _("hw disabled")); + g_string_append_printf (outbuf, "%s, ", tmp); + g_free (tmp); + } + } + break; + default: + break; + } + if (nm_device_is_software (device)) g_string_append_printf (outbuf, "%s, ", _("sw")); else diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index 599369bf25..7eb9ef82dd 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -52,6 +52,7 @@ [NM_META_COLOR_DEVICE_FIRMWARE_MISSING] = "31", \ [NM_META_COLOR_DEVICE_PLUGIN_MISSING] = "31", \ [NM_META_COLOR_DEVICE_UNAVAILABLE] = "2", \ + [NM_META_COLOR_DEVICE_DISABLED] = "31", \ [NM_META_COLOR_MANAGER_RUNNING] = "32", \ [NM_META_COLOR_MANAGER_STARTING] = "33", \ [NM_META_COLOR_MANAGER_STOPPED] = "31", \ @@ -558,6 +559,7 @@ parse_color_scheme (char *palette_buffer, [NM_META_COLOR_DEVICE_FIRMWARE_MISSING] = "device-firmware-missing", [NM_META_COLOR_DEVICE_PLUGIN_MISSING] = "device-plugin-missing", [NM_META_COLOR_DEVICE_UNAVAILABLE] = "device-unavailable", + [NM_META_COLOR_DEVICE_DISABLED] = "device-disabled", [NM_META_COLOR_DEVICE_UNKNOWN] = "device-unknown", [NM_META_COLOR_MANAGER_RUNNING] = "manager-running", [NM_META_COLOR_MANAGER_STARTING] = "manager-starting", diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h index 44cfcdc427..2f184e4945 100644 --- a/clients/common/nm-meta-setting-desc.h +++ b/clients/common/nm-meta-setting-desc.h @@ -89,6 +89,7 @@ typedef enum { NM_META_COLOR_DEVICE_FIRMWARE_MISSING, NM_META_COLOR_DEVICE_PLUGIN_MISSING, NM_META_COLOR_DEVICE_UNAVAILABLE, + NM_META_COLOR_DEVICE_DISABLED, NM_META_COLOR_DEVICE_UNKNOWN, NM_META_COLOR_MANAGER_RUNNING, NM_META_COLOR_MANAGER_STARTING, diff --git a/man/nmcli.xml b/man/nmcli.xml index e9517456f3..203337693c 100644 --- a/man/nmcli.xml +++ b/man/nmcli.xml @@ -2192,6 +2192,13 @@ It's equivalent to the +bond.options 'option=value' syntax. + + + + Device is disabled by software or hardware kill switch. + + + -- cgit v1.2.1