diff options
Diffstat (limited to 'src/wifi')
-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 |
3 files changed, 22 insertions, 4 deletions
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 */ |