diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 987d8de9e9..36d9c2fd72 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -122,9 +122,11 @@ static NmcOutputField nmc_fields_dev_show_wifi_prop[] = { {"CCMP", N_("CCMP"), 6}, /* 5 */ {"AP", N_("AP"), 6}, /* 6 */ {"ADHOC", N_("ADHOC"), 6}, /* 7 */ + {"2GHZ", N_("2GHZ"), 10}, /* 8 */ + {"5GHZ", N_("5GHZ"), 10}, /* 9 */ {NULL, NULL, 0} }; -#define NMC_FIELDS_DEV_SHOW_WIFI_PROP_ALL "NAME,WEP,WPA,WPA2,TKIP,CCMP,AP,ADHOC" +#define NMC_FIELDS_DEV_SHOW_WIFI_PROP_ALL "NAME,WEP,WPA,WPA2,TKIP,CCMP,AP,ADHOC,2GHZ,5GHZ" #define NMC_FIELDS_DEV_SHOW_WIFI_PROP_COMMON "NAME,WEP,WPA,WPA2,TKIP,CCMP,AP,ADHOC" /* Available fields for 'device show' - wimax properties part */ @@ -979,6 +981,10 @@ show_device_info (NMDevice *device, NmCli *nmc) set_val_strc (arr, 5, (wcaps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP) ? _("yes") : _("no")); set_val_strc (arr, 6, (wcaps & NM_WIFI_DEVICE_CAP_AP) ? _("yes") : _("no")); set_val_strc (arr, 7, (wcaps & NM_WIFI_DEVICE_CAP_ADHOC) ? _("yes") : _("no")); + set_val_strc (arr, 8, !(wcaps & NM_WIFI_DEVICE_CAP_FREQ_VALID) ? _("unknown") : + ((wcaps & NM_WIFI_DEVICE_CAP_FREQ_2GHZ) ? _("yes") : _("no"))); + set_val_strc (arr, 9, !(wcaps & NM_WIFI_DEVICE_CAP_FREQ_VALID) ? _("unknown") : + ((wcaps & NM_WIFI_DEVICE_CAP_FREQ_5GHZ) ? _("yes") : _("no"))); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ diff --git a/introspection/nm-device-wifi.xml b/introspection/nm-device-wifi.xml index 7d4d73c9db..d1c5313ed4 100644 --- a/introspection/nm-device-wifi.xml +++ b/introspection/nm-device-wifi.xml @@ -151,6 +151,23 @@ The device supports Ad-Hoc mode. + + + The device properly reports information about supported + frequencies and thus both NM_802_11_DEVICE_CAP_FREQ_2GHZ and + NM_802_11_DEVICE_CAP_FREQ_5GHZ are valid. + + + + + The device supports 2.4GHz frequencies. + + + + + The device supports 5GHz frequencies. + + diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index 04a822cb4c..9bab80f354 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -199,6 +199,9 @@ typedef enum { /*< flags >*/ * @NM_WIFI_DEVICE_CAP_RSN: device supports WPA2/RSN authentication * @NM_WIFI_DEVICE_CAP_AP: device supports Access Point mode * @NM_WIFI_DEVICE_CAP_ADHOC: device supports Ad-Hoc mode + * @NM_WIFI_DEVICE_CAP_FREQ_VALID: device reports frequency capabilities + * @NM_WIFI_DEVICE_CAP_FREQ_2GHZ: device supports 2.4GHz frequencies + * @NM_WIFI_DEVICE_CAP_FREQ_5GHZ: device supports 5GHz frequencies * * 802.11 specific device encryption and authentication capabilities. * @@ -213,7 +216,10 @@ typedef enum { /*< flags >*/ NM_WIFI_DEVICE_CAP_WPA = 0x00000010, NM_WIFI_DEVICE_CAP_RSN = 0x00000020, NM_WIFI_DEVICE_CAP_AP = 0x00000040, - NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080 + NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080, + NM_WIFI_DEVICE_CAP_FREQ_VALID = 0x00000100, + NM_WIFI_DEVICE_CAP_FREQ_2GHZ = 0x00000200, + NM_WIFI_DEVICE_CAP_FREQ_5GHZ = 0x00000400, } NMDeviceWifiCapabilities; diff --git a/libnm-util/NetworkManager.h b/libnm-util/NetworkManager.h index 4557a87c8f..5a98b8e496 100644 --- a/libnm-util/NetworkManager.h +++ b/libnm-util/NetworkManager.h @@ -204,6 +204,9 @@ typedef enum { * @NM_WIFI_DEVICE_CAP_RSN: device supports WPA2/RSN authentication * @NM_WIFI_DEVICE_CAP_AP: device supports Access Point mode * @NM_WIFI_DEVICE_CAP_ADHOC: device supports Ad-Hoc mode + * @NM_WIFI_DEVICE_CAP_FREQ_VALID: device reports frequency capabilities + * @NM_WIFI_DEVICE_CAP_FREQ_2GHZ: device supports 2.4GHz frequencies + * @NM_WIFI_DEVICE_CAP_FREQ_5GHZ: device supports 5GHz frequencies * * 802.11 specific device encryption and authentication capabilities. * @@ -218,7 +221,10 @@ typedef enum { NM_WIFI_DEVICE_CAP_WPA = 0x00000010, NM_WIFI_DEVICE_CAP_RSN = 0x00000020, NM_WIFI_DEVICE_CAP_AP = 0x00000040, - NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080 + NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080, + NM_WIFI_DEVICE_CAP_FREQ_VALID = 0x00000100, + NM_WIFI_DEVICE_CAP_FREQ_2GHZ = 0x00000200, + NM_WIFI_DEVICE_CAP_FREQ_5GHZ = 0x00000400, } NMDeviceWifiCapabilities; diff --git a/src/platform/wifi/wifi-utils-nl80211.c b/src/platform/wifi/wifi-utils-nl80211.c index fd69d17a71..8ca5dd1c79 100644 --- a/src/platform/wifi/wifi-utils-nl80211.c +++ b/src/platform/wifi/wifi-utils-nl80211.c @@ -756,6 +756,7 @@ static int nl80211_wiphy_info_handler (struct nl_msg *msg, void *arg) } } + /* Find number of supported frequencies */ info->num_freqs = 0; nla_for_each_nested (nl_band, tb[NL80211_ATTR_WIPHY_BANDS], rem_band) { @@ -775,6 +776,7 @@ static int nl80211_wiphy_info_handler (struct nl_msg *msg, void *arg) } } + /* Read supported frequencies */ info->freqs = g_malloc0 (sizeof (guint32) * info->num_freqs); freq_idx = 0; @@ -793,10 +795,19 @@ static int nl80211_wiphy_info_handler (struct nl_msg *msg, void *arg) info->freqs[freq_idx] = nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_FREQ]); + + info->caps |= NM_WIFI_DEVICE_CAP_FREQ_VALID; + + if (info->freqs[freq_idx] > 2400 && info->freqs[freq_idx] < 2500) + info->caps |= NM_WIFI_DEVICE_CAP_FREQ_2GHZ; + if (info->freqs[freq_idx] > 4900 && info->freqs[freq_idx] < 6000) + info->caps |= NM_WIFI_DEVICE_CAP_FREQ_5GHZ; + freq_idx++; } } + /* Read security/encryption support */ if (tb[NL80211_ATTR_CIPHER_SUITES]) { int num; int i; diff --git a/src/platform/wifi/wifi-utils-wext.c b/src/platform/wifi/wifi-utils-wext.c index 8be36770ef..f4301ef292 100644 --- a/src/platform/wifi/wifi-utils-wext.c +++ b/src/platform/wifi/wifi-utils-wext.c @@ -593,6 +593,7 @@ wifi_wext_init (const char *iface, int ifindex, gboolean check_scan) guint32 response_len = 0; struct iw_range_with_scan_capa *scan_capa_range; int i; + gboolean freq_valid = FALSE, has_5ghz = FALSE, has_2ghz = FALSE; wext = wifi_data_new (iface, ifindex, sizeof (*wext)); wext->parent.get_mode = wifi_wext_get_mode; @@ -634,8 +635,14 @@ wifi_wext_init (const char *iface, int ifindex, gboolean check_scan) wext->max_qual.updated = range.max_qual.updated; wext->num_freqs = MIN (range.num_frequency, IW_MAX_FREQUENCIES); - for (i = 0; i < wext->num_freqs; i++) + for (i = 0; i < wext->num_freqs; i++) { wext->freqs[i] = iw_freq_to_uint32 (&range.freq[i]); + freq_valid = TRUE; + if (wext->freqs[i] > 2400 && wext->freqs[i] < 2500) + has_2ghz = TRUE; + else if (wext->freqs[i] > 4900 && wext->freqs[i] < 6000) + has_5ghz = TRUE; + } /* Check for scanning capability; cards that can't scan are not supported */ if (check_scan && (wext_can_scan (wext) == FALSE)) { @@ -663,6 +670,12 @@ wifi_wext_init (const char *iface, int ifindex, gboolean check_scan) } wext->parent.caps = wext_get_caps (wext, &range); + if (freq_valid) + wext->parent.caps |= NM_WIFI_DEVICE_CAP_FREQ_VALID; + if (has_2ghz) + wext->parent.caps |= NM_WIFI_DEVICE_CAP_FREQ_2GHZ; + if (has_5ghz) + wext->parent.caps |= NM_WIFI_DEVICE_CAP_FREQ_5GHZ; nm_log_info (LOGD_HW | LOGD_WIFI, "(%s): using WEXT for WiFi device control", diff --git a/src/platform/wifi/wifi-utils.h b/src/platform/wifi/wifi-utils.h index ea58f89043..b25e70824a 100644 --- a/src/platform/wifi/wifi-utils.h +++ b/src/platform/wifi/wifi-utils.h @@ -44,7 +44,8 @@ gboolean wifi_utils_set_mode (WifiData *data, const NM80211Mode mode); /* Returns frequency in MHz */ guint32 wifi_utils_get_freq (WifiData *data); -/* Return the first supported frequency in the zero-terminated list */ +/* Return the first supported frequency in the zero-terminated list. + * Frequencies are specified in MHz. */ guint32 wifi_utils_find_freq (WifiData *data, const guint32 *freqs); /* Caller must free returned byte array */