diff options
author | Dan Williams <dcbw@redhat.com> | 2014-01-20 10:19:57 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-01-29 09:01:22 -0600 |
commit | 28a01762f52b6d0d0ae45f8ac2399b209c2487df (patch) | |
tree | 4edd07b6f045b6a550c5c0a1aa8eeb128386f583 | |
parent | fbdca67baa0fadc6cba9788032c7363d11bc9e23 (diff) | |
download | NetworkManager-dcbw/5ghz-caps.tar.gz |
wifi: add capability bit for 5GHz frequency support (bgo #722550)dcbw/5ghz-caps
-rw-r--r-- | cli/src/devices.c | 6 | ||||
-rw-r--r-- | include/NetworkManager.h | 10 | ||||
-rw-r--r-- | introspection/nm-device-wifi.xml | 14 | ||||
-rw-r--r-- | src/wifi/wifi-utils-nl80211.c | 11 | ||||
-rw-r--r-- | src/wifi/wifi-utils-wext.c | 12 | ||||
-rw-r--r-- | src/wifi/wifi-utils.h | 3 |
6 files changed, 50 insertions, 6 deletions
diff --git a/cli/src/devices.c b/cli/src/devices.c index 61717bdd7b..685745dcc0 100644 --- a/cli/src/devices.c +++ b/cli/src/devices.c @@ -148,9 +148,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"), 6}, /* 8 */ + {"5GHZ", N_("5GHZ"), 6}, /* 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 */ @@ -866,6 +868,8 @@ 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_2GHZ) ? _("yes") : _("no")); + set_val_strc (arr, 9, (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/include/NetworkManager.h b/include/NetworkManager.h index 46747a6529..860a2d7ae0 100644 --- a/include/NetworkManager.h +++ b/include/NetworkManager.h @@ -190,6 +190,12 @@ 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_2GHZ: device supports 2.4GHz frequencies. If + * neither this capability nor %NM_WIFI_DEVICE_CAP_FREQ_2GHZ is set the + * frequency capabilties are unknown. + * @NM_WIFI_DEVICE_CAP_FREQ_5GHZ: device supports 5GHz frequencies. If + * neither this capability nor %NM_WIFI_DEVICE_CAP_FREQ_5GHZ is set the + * frequency capabilties are unknown. * * 802.11 specific device encryption and authentication capabilities. **/ @@ -202,7 +208,9 @@ 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_2GHZ = 0x00000100, + NM_WIFI_DEVICE_CAP_FREQ_5GHZ = 0x00000200, } NMDeviceWifiCapabilities; diff --git a/introspection/nm-device-wifi.xml b/introspection/nm-device-wifi.xml index 65c7b71dce..49aa5b2263 100644 --- a/introspection/nm-device-wifi.xml +++ b/introspection/nm-device-wifi.xml @@ -149,6 +149,20 @@ <tp:flag suffix="ADHOC" value="0x80"> <tp:docstring>The device supports Ad-Hoc mode.</tp:docstring> </tp:flag> + <tp:flag suffix="FREQ_2GHZ" value="0x100"> + <tp:docstring> + The device supports 2.4GHz frequencies. If neither this capability + nor NM_802_11_DEVICE_CAP_FREQ_5GHZ is set the frequency capabilties + are unknown. + </tp:docstring> + </tp:flag> + <tp:flag suffix="FREQ_5GHZ" value="0x200"> + <tp:docstring> + The device supports 5GHz frequencies. If neither this capability + nor NM_802_11_DEVICE_CAP_FREQ_2GHZ is set the frequency capabilties + are unknown. + </tp:docstring> + </tp:flag> </tp:flags> </interface> </node> diff --git a/src/wifi/wifi-utils-nl80211.c b/src/wifi/wifi-utils-nl80211.c index eb2534a22c..0a5f79698a 100644 --- a/src/wifi/wifi-utils-nl80211.c +++ b/src/wifi/wifi-utils-nl80211.c @@ -635,8 +635,8 @@ 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) { if (nla_parse_nested (tb_band, NL80211_BAND_ATTR_MAX, nl_band, NULL) < 0) @@ -654,8 +654,8 @@ 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; nla_for_each_nested (nl_band, tb[NL80211_ATTR_WIPHY_BANDS], rem_band) { if (nla_parse_nested (tb_band, NL80211_BAND_ATTR_MAX, nl_band, @@ -672,10 +672,17 @@ 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]); + + 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/wifi/wifi-utils-wext.c b/src/wifi/wifi-utils-wext.c index 5022550339..20dead8640 100644 --- a/src/wifi/wifi-utils-wext.c +++ b/src/wifi/wifi-utils-wext.c @@ -573,6 +573,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 has_5ghz = FALSE, has_2ghz = FALSE; wext = wifi_data_new (iface, ifindex, sizeof (*wext)); wext->parent.get_mode = wifi_wext_get_mode; @@ -613,8 +614,13 @@ 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]); + 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)) { @@ -642,6 +648,10 @@ wifi_wext_init (const char *iface, int ifindex, gboolean check_scan) } wext->parent.caps = wext_get_caps (wext, &range); + 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/wifi/wifi-utils.h b/src/wifi/wifi-utils.h index b917ef2f9d..40e03509fd 100644 --- a/src/wifi/wifi-utils.h +++ b/src/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 */ |