[RFC PATCH 3/5] DFS: add new hostapd_is_dfs_overlap helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add new hostapd_is_dfs_overlap helper function to DFS module. This
function is supposed to tell whether the selected frequency range
overlaps with DFS channels in current hostapd configuration. Selected
frequency reange is specified by its center frequency and bandwidth

Signed-off-by: Sergey Matyukevich <sergey.matyukevich.os@xxxxxxxxxxxxx>
---
 src/ap/dfs.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/ap/dfs.h |  4 +++-
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index f5c6722b4..ab14a7588 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -1161,3 +1161,58 @@ 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;
+	int half_width;
+	int res = 0;
+	int i;
+
+	if (!iface->conf->ieee80211h || !iface->current_mode ||
+	    iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A)
+		return 0;
+
+	mode = iface->current_mode;
+
+	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, "(%d, %d): dfs range: %s",
+		   center_freq - half_width,
+		   center_freq + half_width,
+		   res ? "yes" : "no");
+
+	return res;
+}
diff --git a/src/ap/dfs.h b/src/ap/dfs.h
index b73c4ece1..b1c7bd73a 100644
--- a/src/ap/dfs.h
+++ b/src/ap/dfs.h
@@ -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 */
-- 
2.11.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux