]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Search through all hw_features sets in hw_get_channel_freq()
authorAnkita Bajaj <bankita@codeaurora.org>
Mon, 18 Nov 2019 06:30:06 +0000 (12:00 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 20 Dec 2019 10:21:45 +0000 (12:21 +0200)
The 5 GHz channels are stored in one hw_features set with mode
HOSTAPD_MODE_IEEE80211A while the 6 GHz channels will need to stored in
a separate hw_features set (but with same mode HOSTAPD_MODE_IEEE80211A)
due to possibility of different HE capabilities being available between
the 5 GHz and 6 GHz bands.

Search through all hw_features sets whose mode is same as the input mode
while finding channel corresponding to the input frequency in
hw_get_channel_freq().

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/ap/hw_features.c
src/common/hw_features_common.c
src/common/hw_features_common.h

index 8b1ed708335d87ee0199d50c71844e301d57c48f..d8accc51abac06513406727cdc5ec8634b85ab7f 100644 (file)
@@ -987,7 +987,9 @@ int hostapd_select_hw_mode(struct hostapd_iface *iface)
        for (i = 0; i < iface->num_hw_features; i++) {
                struct hostapd_hw_modes *mode = &iface->hw_features[i];
                if (mode->mode == iface->conf->hw_mode) {
-                       if (freq > 0 && !hw_get_chan(mode, freq))
+                       if (freq > 0 && !hw_get_chan(mode->mode, freq,
+                                                    iface->hw_features,
+                                                    iface->num_hw_features))
                                continue;
                        iface->current_mode = mode;
                        break;
@@ -1051,7 +1053,9 @@ int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq)
        struct hostapd_hw_modes *mode;
 
        if (hapd->iface->current_mode) {
-               channel = hw_get_chan(hapd->iface->current_mode, freq);
+               channel = hw_get_chan(hapd->iface->current_mode->mode, freq,
+                                     hapd->iface->hw_features,
+                                     hapd->iface->num_hw_features);
                if (channel)
                        return channel;
        }
@@ -1062,7 +1066,9 @@ int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq)
                return 0;
        for (i = 0; i < hapd->iface->num_hw_features; i++) {
                mode = &hapd->iface->hw_features[i];
-               channel = hw_get_chan(mode, freq);
+               channel = hw_get_chan(mode->mode, freq,
+                                     hapd->iface->hw_features,
+                                     hapd->iface->num_hw_features);
                if (channel)
                        return channel;
        }
index 1ad8d7c3e921bd044ba77d6b509005bd6d7a3a3f..706f204151d03c76f6c5168e505e99e4fedf208c 100644 (file)
@@ -40,23 +40,32 @@ struct hostapd_channel_data * hw_get_channel_chan(struct hostapd_hw_modes *mode,
 }
 
 
-struct hostapd_channel_data * hw_get_channel_freq(struct hostapd_hw_modes *mode,
-                                                 int freq, int *chan)
+struct hostapd_channel_data *
+hw_get_channel_freq(enum hostapd_hw_mode mode, int freq, int *chan,
+                   struct hostapd_hw_modes *hw_features, int num_hw_features)
 {
-       int i;
+       int i, j;
 
        if (chan)
                *chan = 0;
 
-       if (!mode)
+       if (!hw_features)
                return NULL;
 
-       for (i = 0; i < mode->num_channels; i++) {
-               struct hostapd_channel_data *ch = &mode->channels[i];
-               if (ch->freq == freq) {
-                       if (chan)
-                               *chan = ch->chan;
-                       return ch;
+       for (j = 0; j < num_hw_features; j++) {
+               struct hostapd_hw_modes *curr_mode = &hw_features[j];
+
+               if (curr_mode->mode != mode)
+                       continue;
+               for (i = 0; i < curr_mode->num_channels; i++) {
+                       struct hostapd_channel_data *ch =
+                               &curr_mode->channels[i];
+
+                       if (ch->freq == freq) {
+                               if (chan)
+                                       *chan = ch->chan;
+                               return ch;
+                       }
                }
        }
 
@@ -74,11 +83,12 @@ int hw_get_freq(struct hostapd_hw_modes *mode, int chan)
 }
 
 
-int hw_get_chan(struct hostapd_hw_modes *mode, int freq)
+int hw_get_chan(enum hostapd_hw_mode mode, int freq,
+               struct hostapd_hw_modes *hw_features, int num_hw_features)
 {
        int chan;
 
-       hw_get_channel_freq(mode, freq, &chan);
+       hw_get_channel_freq(mode, freq, &chan, hw_features, num_hw_features);
 
        return chan;
 }
index c86e195594693ac4196992a6fffe3aae53c0dd8a..7eb4ca1708234f7e7988d1ffb921f70da940dc15 100644 (file)
 
 struct hostapd_channel_data * hw_get_channel_chan(struct hostapd_hw_modes *mode,
                                                  int chan, int *freq);
-struct hostapd_channel_data * hw_get_channel_freq(struct hostapd_hw_modes *mode,
-                                                 int freq, int *chan);
+struct hostapd_channel_data *
+hw_get_channel_freq(enum hostapd_hw_mode mode, int freq, int *chan,
+                   struct hostapd_hw_modes *hw_features, int num_hw_features);
 
 int hw_get_freq(struct hostapd_hw_modes *mode, int chan);
-int hw_get_chan(struct hostapd_hw_modes *mode, int freq);
+int hw_get_chan(enum hostapd_hw_mode mode, int freq,
+               struct hostapd_hw_modes *hw_features, int num_hw_features);
 
 int allowed_ht40_channel_pair(struct hostapd_hw_modes *mode, int pri_chan,
                              int sec_chan);