]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Get channel number from frequency based on other modes as well
authorPeng Xu <pxu@qca.qualcomm.com>
Wed, 22 Feb 2017 22:05:35 +0000 (14:05 -0800)
committerJouni Malinen <j@w1.fi>
Sun, 26 Feb 2017 10:24:03 +0000 (12:24 +0200)
When getting the channel number from a frequency, all supported modes
should be checked rather than just the current mode. This is needed when
hostapd switches to a channel in different band.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/hw_features.c

index 2d6cef1afda337c0b635ba7eaf0218ed2fa5edaf..93d923af51970dd8ae36f702e1a02547c2fd6b5b 100644 (file)
@@ -909,5 +909,19 @@ int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan)
 
 int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq)
 {
-       return hw_get_chan(hapd->iface->current_mode, freq);
+       int i, channel;
+       struct hostapd_hw_modes *mode;
+
+       channel = hw_get_chan(hapd->iface->current_mode, freq);
+       if (channel)
+               return channel;
+       /* Check other available modes since the channel list for the current
+        * mode did not include the specified frequency. */
+       for (i = 0; i < hapd->iface->num_hw_features; i++) {
+               mode = &hapd->iface->hw_features[i];
+               channel = hw_get_chan(mode, freq);
+               if (channel)
+                       return channel;
+       }
+       return 0;
 }