]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DFS: Add new hostapd_is_dfs_overlap() helper
authorSergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Tue, 28 Jan 2020 15:09:52 +0000 (15:09 +0000)
committerJouni Malinen <j@w1.fi>
Sun, 29 Mar 2020 18:15:16 +0000 (21:15 +0300)
Add a new hostapd_is_dfs_overlap() helper function to DFS module. This
function tells whether the selected frequency range overlaps with DFS
channels in the current hostapd configuration. Selected frequency reange
is specified by its center frequency and bandwidth.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
src/ap/dfs.c
src/ap/dfs.h

index 2e350ff086b6b2705d0e6f0878e1e48f5e848c31..3c078b9cbf020e1a509d719a41cf8a0615c26dbb 100644 (file)
@@ -1290,3 +1290,56 @@ int hostapd_handle_dfs_offload(struct hostapd_iface *iface)
                   __func__, iface->freq);
        return 2;
 }
+
+
+int hostapd_is_dfs_overlap(struct hostapd_iface *iface, enum chan_width width,
+                          int center_freq)
+{
+       struct hostapd_channel_data *chan;
+       struct hostapd_hw_modes *mode = iface->current_mode;
+       int half_width;
+       int res = 0;
+       int i;
+
+       if (!iface->conf->ieee80211h || !mode ||
+           mode->mode != HOSTAPD_MODE_IEEE80211A)
+               return 0;
+
+       switch (width) {
+       case CHAN_WIDTH_20_NOHT:
+       case CHAN_WIDTH_20:
+               half_width = 10;
+               break;
+       case CHAN_WIDTH_40:
+               half_width = 20;
+               break;
+       case CHAN_WIDTH_80:
+       case CHAN_WIDTH_80P80:
+               half_width = 40;
+               break;
+       case CHAN_WIDTH_160:
+               half_width = 80;
+               break;
+       default:
+               wpa_printf(MSG_WARNING, "DFS chanwidth %d not supported",
+                          width);
+               return 0;
+       }
+
+       for (i = 0; i < mode->num_channels; i++) {
+               chan = &mode->channels[i];
+
+               if (!(chan->flag & HOSTAPD_CHAN_RADAR))
+                       continue;
+
+               if (center_freq - chan->freq < half_width &&
+                   chan->freq - center_freq < half_width)
+                       res++;
+       }
+
+       wpa_printf(MSG_DEBUG, "DFS: (%d, %d): in range: %s",
+                  center_freq - half_width, center_freq + half_width,
+                  res ? "yes" : "no");
+
+       return res;
+}
index b73c4ece1704e74b89cc10ebe24c41450b37b41b..606c1b39399fa21441b600e92b31c9a0ee10f090 100644 (file)
@@ -30,5 +30,7 @@ int hostapd_dfs_start_cac(struct hostapd_iface *iface, int freq,
                          int ht_enabled, int chan_offset, int chan_width,
                          int cf1, int cf2);
 int hostapd_handle_dfs_offload(struct hostapd_iface *iface);
+int hostapd_is_dfs_overlap(struct hostapd_iface *iface, enum chan_width width,
+                          int center_freq);
 
 #endif /* DFS_H */