3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-18 10:19:24 +01:00

scan: Add scan_freq_to_channel

This commit is contained in:
Denis Kenzior 2015-06-10 15:31:13 -05:00
parent f24b550196
commit 5ae63817b9
2 changed files with 56 additions and 0 deletions

View File

@ -615,6 +615,55 @@ static void scan_notify(struct l_genl_msg *msg, void *user_data)
}
}
uint8_t scan_freq_to_channel(uint32_t freq, enum scan_band *out_band)
{
uint32_t channel = 0;
if (freq >= 2412 && freq <= 2484) {
if (freq == 2484)
channel = 14;
else {
channel = freq - 2407;
if (channel % 5)
return 0;
channel /= 5;
}
if (out_band)
*out_band = SCAN_BAND_2_4_GHZ;
return channel;
}
if (freq >= 5005 && freq < 5900) {
if (channel % 5)
return 0;
channel = (freq - 5000) / 5;
if (out_band)
*out_band = SCAN_BAND_5_GHZ;
return channel;
}
if (freq >= 4905 && freq < 5000) {
if (channel % 5)
return 0;
channel = (freq - 4000) / 5;
if (out_band)
*out_band = SCAN_BAND_5_GHZ;
return channel;
}
return 0;
}
bool scan_init(struct l_genl_family *in, scan_notify_func_t func)
{
nl80211 = in;

View File

@ -27,6 +27,11 @@ enum scan_ssid_security {
SCAN_SSID_SECURITY_8021X,
};
enum scan_band {
SCAN_BAND_2_4_GHZ,
SCAN_BAND_5_GHZ,
};
typedef void (*scan_func_t)(struct l_genl_msg *msg, void *user_data);
typedef bool (*scan_notify_func_t)(uint32_t wiphy, uint32_t ifindex,
struct l_queue *bss_list);
@ -63,5 +68,7 @@ void bss_get_supported_ciphers(struct scan_bss *bss,
uint16_t *pairwise_ciphers,
uint16_t *group_ciphers);
uint8_t scan_freq_to_channel(uint32_t freq, enum scan_band *out_band);
bool scan_init(struct l_genl_family *in, scan_notify_func_t func);
bool scan_free();