scan: Implement scan_channel_to_freq

This function does the inverse of scan_freq_to_channel
This commit is contained in:
Andrew Zaborowski 2016-10-04 05:47:52 +02:00 committed by Denis Kenzior
parent 911aebc844
commit c4941a82a4
2 changed files with 22 additions and 0 deletions

View File

@ -1092,6 +1092,27 @@ uint8_t scan_freq_to_channel(uint32_t freq, enum scan_band *out_band)
return 0;
}
uint32_t scan_channel_to_freq(uint8_t channel, enum scan_band band)
{
if (band == SCAN_BAND_2_4_GHZ) {
if (channel >= 1 && channel <= 13)
return 2407 + 5 * channel;
if (channel == 14)
return 2484;
}
if (band == SCAN_BAND_5_GHZ) {
if (channel >= 1 && channel <= 179)
return 5000 + 5 * channel;
if (channel >= 181 && channel <= 199)
return 4000 + 5 * channel;
}
return 0;
}
struct scan_freq_set {
uint16_t channels_2ghz;
struct l_uintset *channels_5ghz;

View File

@ -86,6 +86,7 @@ void bss_get_supported_ciphers(struct scan_bss *bss,
uint16_t *group_ciphers);
uint8_t scan_freq_to_channel(uint32_t freq, enum scan_band *out_band);
uint32_t scan_channel_to_freq(uint8_t channel, enum scan_band band);
struct scan_freq_set *scan_freq_set_new(void);
void scan_freq_set_free(struct scan_freq_set *freqs);