mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-20 00:21:29 +00:00
libnm: add utility functions for getting 2.4 GHz and 5 GHz Wi-Fi frequencies
nm_utils_wifi_2ghz_freqs()
nm_utils_wifi_5ghz_freqs()
(cherry picked from commit 1a6b631690
)
This commit is contained in:
parent
c8b5b5eb1c
commit
77bf69c3dc
|
@ -2692,6 +2692,61 @@ nm_utils_wifi_is_channel_valid (guint32 channel, const char *band)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static const guint *
|
||||
_wifi_freqs (gboolean bg_band)
|
||||
{
|
||||
static guint *freqs_2ghz = NULL;
|
||||
static guint *freqs_5ghz = NULL;
|
||||
guint *freqs;
|
||||
|
||||
freqs = bg_band ? freqs_2ghz : freqs_5ghz;
|
||||
if (G_UNLIKELY (freqs == NULL)) {
|
||||
struct cf_pair *table;
|
||||
int i;
|
||||
|
||||
table = bg_band ? bg_table : a_table;
|
||||
freqs = g_new0 (guint, bg_band ? G_N_ELEMENTS (bg_table) : G_N_ELEMENTS (a_table));
|
||||
for (i = 0; table[i].chan; i++)
|
||||
freqs[i] = table[i].freq;
|
||||
freqs[i] = 0;
|
||||
if (bg_band)
|
||||
freqs_2ghz = freqs;
|
||||
else
|
||||
freqs_5ghz = freqs;
|
||||
}
|
||||
return freqs;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_wifi_2ghz_freqs:
|
||||
*
|
||||
* Utility function to return 2.4 GHz Wi-Fi frequencies (802.11bg band).
|
||||
*
|
||||
* Returns: zero-terminated array of frequencies numbers (in MHz)
|
||||
*
|
||||
* Since: 1.0.6
|
||||
**/
|
||||
const guint *
|
||||
nm_utils_wifi_2ghz_freqs (void)
|
||||
{
|
||||
return _wifi_freqs (TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_wifi_5ghz_freqs:
|
||||
*
|
||||
* Utility function to return 5 GHz Wi-Fi frequencies (802.11a band).
|
||||
*
|
||||
* Returns: zero-terminated array of frequencies numbers (in MHz)
|
||||
*
|
||||
* Since: 1.0.6
|
||||
**/
|
||||
const guint *
|
||||
nm_utils_wifi_5ghz_freqs (void)
|
||||
{
|
||||
return _wifi_freqs (FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_wifi_strength_bars:
|
||||
* @strength: the access point strength, from 0 to 100
|
||||
|
|
|
@ -140,6 +140,10 @@ guint32 nm_utils_wifi_freq_to_channel (guint32 freq);
|
|||
guint32 nm_utils_wifi_channel_to_freq (guint32 channel, const char *band);
|
||||
guint32 nm_utils_wifi_find_next_channel (guint32 channel, int direction, char *band);
|
||||
gboolean nm_utils_wifi_is_channel_valid (guint32 channel, const char *band);
|
||||
NM_AVAILABLE_IN_1_0_6
|
||||
const guint *nm_utils_wifi_2ghz_freqs (void);
|
||||
NM_AVAILABLE_IN_1_0_6
|
||||
const guint *nm_utils_wifi_5ghz_freqs (void);
|
||||
|
||||
const char *nm_utils_wifi_strength_bars (guint8 strength);
|
||||
|
||||
|
|
|
@ -859,5 +859,7 @@ global:
|
|||
nm_device_wifi_request_scan_options_async;
|
||||
nm_metered_get_type;
|
||||
nm_setting_connection_get_metered;
|
||||
nm_utils_wifi_2ghz_freqs;
|
||||
nm_utils_wifi_5ghz_freqs;
|
||||
} libnm_1_0_4;
|
||||
|
||||
|
|
Loading…
Reference in a new issue