summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Kling <andreas.kling@peiker-cee.de>2019-02-20 13:23:26 +0100
committerLubomir Rintel <lkundrak@v3.sk>2019-07-29 11:00:24 +0200
commit4dc375a068e7d117968ffdea0b598c1c4fc88084 (patch)
tree40bb4d733fdab93e9f36c8942025d7b5dd9279dc
parented4dd32cb9910e5a20db17b1ffaa133971861f8c (diff)
downloadNetworkManager-4dc375a068e7d117968ffdea0b598c1c4fc88084.tar.gz
libnm-core: add nm_utils_wifi_freq_to_band
allow to retrieve wifi band from frequency. [lkundrak@v3.sk: formatting fixes, move the prototype to a private header]
-rw-r--r--libnm-core/nm-core-internal.h2
-rw-r--r--libnm-core/nm-utils.c19
2 files changed, 21 insertions, 0 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index 912ce1b46e..d263900d1a 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -866,4 +866,6 @@ void _nm_bridge_vlan_str_append_rest (const NMBridgeVlan *vlan,
gboolean nm_utils_connection_is_adhoc_wpa (NMConnection *connection);
+const char *nm_utils_wifi_freq_to_band (guint32 freq);
+
#endif
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 68da624818..55b004c816 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -3725,6 +3725,25 @@ nm_utils_wifi_freq_to_channel (guint32 freq)
}
/**
+ * nm_utils_wifi_freq_to_band:
+ * @freq: frequency
+ *
+ * Utility function to translate a Wi-Fi frequency to its corresponding band.
+ *
+ * Returns: the band containing the frequency or NULL if freq is invalid
+ **/
+const char *
+nm_utils_wifi_freq_to_band (guint32 freq)
+{
+ if (freq >= 4915 && freq <= 5825)
+ return "a";
+ else if (freq >= 2412 && freq <= 2484)
+ return "bg";
+
+ return NULL;
+}
+
+/**
* nm_utils_wifi_channel_to_freq:
* @channel: channel
* @band: frequency band for wireless ("a" or "bg")