diff options
-rw-r--r-- | libnm-core/nm-core-internal.h | 2 | ||||
-rw-r--r-- | libnm-core/nm-utils.c | 19 |
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") |