]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ACS: Extend hostapd_get_mode_channel() to find from any mode
authorNeo Jou <neojou@gmail.com>
Mon, 13 Jan 2020 08:31:28 +0000 (16:31 +0800)
committerJouni Malinen <j@w1.fi>
Sat, 29 Feb 2020 09:23:03 +0000 (11:23 +0200)
This is preparation for being able to support hw_mode=any to select the
best channel from any supported mode.

Signed-off-by: Neo Jou <neojou@gmail.com>
src/ap/drv_callbacks.c
src/ap/hw_features.c
src/ap/hw_features.h

index 61e56b6e5a3e4da2829c73024053a39cca3dcdc0..bde2d9302d486582e6306f4147f4940620fdb7a9 100644 (file)
@@ -1429,15 +1429,33 @@ static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src,
 #endif /* HOSTAPD */
 
 
+static struct hostapd_channel_data *
+hostapd_get_mode_chan(struct hostapd_hw_modes *mode, unsigned int freq)
+{
+       int i;
+       struct hostapd_channel_data *chan;
+
+       for (i = 0; i < mode->num_channels; i++) {
+               chan = &mode->channels[i];
+               if ((unsigned int) chan->freq == freq)
+                       return chan;
+       }
+
+       return NULL;
+}
+
+
 static struct hostapd_channel_data * hostapd_get_mode_channel(
        struct hostapd_iface *iface, unsigned int freq)
 {
        int i;
        struct hostapd_channel_data *chan;
 
-       for (i = 0; i < iface->current_mode->num_channels; i++) {
-               chan = &iface->current_mode->channels[i];
-               if ((unsigned int) chan->freq == freq)
+       for (i = 0; i < iface->num_hw_features; i++) {
+               if (hostapd_hw_skip_mode(iface, &iface->hw_features[i]))
+                       continue;
+               chan = hostapd_get_mode_chan(&iface->hw_features[i], freq);
+               if (chan)
                        return chan;
        }
 
index 0b922b9c3fa641df46aa63449ba569087b53e4da..f550bfe5e4927dcc5408be2d4af0dde9955ffab7 100644 (file)
@@ -1085,3 +1085,20 @@ int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq)
        }
        return 0;
 }
+
+
+int hostapd_hw_skip_mode(struct hostapd_iface *iface,
+                        struct hostapd_hw_modes *mode)
+{
+       int i;
+
+       if (iface->current_mode)
+               return mode != iface->current_mode;
+       if (mode->mode != HOSTAPD_MODE_IEEE80211B)
+               return 0;
+       for (i = 0; i < iface->num_hw_features; i++) {
+               if (iface->hw_features[i].mode == HOSTAPD_MODE_IEEE80211G)
+                       return 1;
+       }
+       return 0;
+}
index 67493193aa21c7791dae41ef2243eb33b8f2baff..dd24f95b2ad82112c6ea5e51aba68fc02794ab61 100644 (file)
@@ -25,6 +25,8 @@ int hostapd_check_edmg_capab(struct hostapd_iface *iface);
 int hostapd_prepare_rates(struct hostapd_iface *iface,
                          struct hostapd_hw_modes *mode);
 void hostapd_stop_setup_timers(struct hostapd_iface *iface);
+int hostapd_hw_skip_mode(struct hostapd_iface *iface,
+                        struct hostapd_hw_modes *mode);
 #else /* NEED_AP_MLME */
 static inline void
 hostapd_free_hw_features(struct hostapd_hw_modes *hw_features,
@@ -77,6 +79,12 @@ static inline void hostapd_stop_setup_timers(struct hostapd_iface *iface)
 {
 }
 
+static inline int hostapd_hw_skip_mode(struct hostapd_iface *iface,
+                                      struct hostapd_hw_modes *mode)
+{
+       return 0;
+}
+
 #endif /* NEED_AP_MLME */
 
 #endif /* HW_FEATURES_H */