summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-08-18 09:41:50 +0200
committerJiří Klimeš <jklimes@redhat.com>2015-08-21 09:32:09 +0200
commit3c122235dc537362c80cc4a6c279a869330fdcaf (patch)
tree64ca2dc8d1160fdb41bba5974e27f92336d44c34
parent1a6b631690481bb195130c44810ca9d55e7da025 (diff)
downloadNetworkManager-3c122235dc537362c80cc4a6c279a869330fdcaf.tar.gz
supplicant: use util functions for Wi-Fi frequencies
-rw-r--r--src/supplicant-manager/nm-supplicant-config.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/supplicant-manager/nm-supplicant-config.c b/src/supplicant-manager/nm-supplicant-config.c
index 0fb9b9dbb2..4c7cff4f8b 100644
--- a/src/supplicant-manager/nm-supplicant-config.c
+++ b/src/supplicant-manager/nm-supplicant-config.c
@@ -306,12 +306,32 @@ nm_supplicant_config_get_blobs (NMSupplicantConfig * self)
return NM_SUPPLICANT_CONFIG_GET_PRIVATE (self)->blobs;
}
-#define TWO_GHZ_FREQS "2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484"
-#define FIVE_GHZ_FREQS "4915 4920 4925 4935 4940 4945 4960 4980 5035 5040 5045 5055 5060 5080 " \
- "5170 5180 5190 5200 5210 5220 5230 5240 5260 5280 5300 5320 5500 " \
- "5520 5540 5560 5580 5600 5620 5640 5660 5680 5700 5745 5765 5785 " \
- "5805 5825"
-
+static const char *
+wifi_freqs_to_string (gboolean bg_band)
+{
+ static const char *str_2ghz = NULL;
+ static const char *str_5ghz = NULL;
+ const char *str;
+
+ str = bg_band ? str_2ghz : str_5ghz;
+
+ if (G_UNLIKELY (str == NULL)) {
+ GString *tmp;
+ const guint *freqs;
+ int i;
+
+ freqs = bg_band ? nm_utils_wifi_2ghz_freqs () : nm_utils_wifi_5ghz_freqs ();
+ tmp = g_string_sized_new (bg_band ? 70 : 225);
+ for (i = 0; freqs[i]; i++)
+ g_string_append_printf (tmp, i == 0 ? "%d" : " %d", freqs[i]);
+ str = g_string_free (tmp, FALSE);
+ if (bg_band)
+ str_2ghz = str;
+ else
+ str_5ghz = str;
+ }
+ return str;
+}
gboolean
nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
@@ -395,9 +415,9 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
const char *freqs = NULL;
if (!strcmp (band, "a"))
- freqs = FIVE_GHZ_FREQS;
+ freqs = wifi_freqs_to_string (FALSE);
else if (!strcmp (band, "bg"))
- freqs = TWO_GHZ_FREQS;
+ freqs = wifi_freqs_to_string (TRUE);
if (freqs && !nm_supplicant_config_add_option (self, "freq_list", freqs, strlen (freqs), FALSE)) {
nm_log_warn (LOGD_SUPPLICANT, "Error adding frequency list/band to supplicant config.");