Search Linux Wireless

[PATCH 4/5] cfg80211: introduce strict bandwidth regulatory flag

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

 



Introduce NL80211_RRF_STRICT_BW regulatory rule flag.
This mean we will check only banwidth defined in
regulatory database and not check contiguous rules.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@xxxxxxxxx>
---
 include/uapi/linux/nl80211.h |    2 ++
 net/wireless/reg.c           |   18 ++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 91054fd..6a4fa90 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2475,6 +2475,7 @@ enum nl80211_sched_scan_match_attr {
  * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
  * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
  * @NL80211_RRF_NO_IR: no mechanisms that initiate radiation are allowed,
+ * @NL80211_RRF_STRICT_BW: strict BW setting
  * 	this includes probe requests or modes of operation that require
  * 	beaconing.
  */
@@ -2488,6 +2489,7 @@ enum nl80211_reg_rule_flags {
 	NL80211_RRF_PTMP_ONLY		= 1<<6,
 	NL80211_RRF_NO_IR		= 1<<7,
 	__NL80211_RRF_NO_IBSS		= 1<<8,
+	NL80211_RRF_STRICT_BW		= 1<<9,
 };
 
 #define NL80211_RRF_PASSIVE_SCAN	NL80211_RRF_NO_IR
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 8165303..8c337f2 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -549,6 +549,11 @@ static unsigned int reg_get_max_bandwidth(const struct ieee80211_regdomain *rd,
 	const struct ieee80211_reg_rule *tmp;
 	u32 start_freq, end_freq, idx, no;
 
+	/* First check if STRICT_BW flag */
+	if (rule->flags & NL80211_RRF_STRICT_BW)
+		return freq_range->max_bandwidth_khz;
+
+	/* Next check contiguous rules */
 	for (idx = 0; idx < rd->n_reg_rules; idx++)
 		if (rule == &rd->reg_rules[idx])
 			break;
@@ -566,6 +571,9 @@ static unsigned int reg_get_max_bandwidth(const struct ieee80211_regdomain *rd,
 		if (freq_range_tmp->end_freq_khz < freq_range->start_freq_khz)
 			break;
 
+		if (tmp->flags & NL80211_RRF_STRICT_BW)
+			break;
+
 		freq_range = freq_range_tmp;
 	};
 
@@ -582,6 +590,9 @@ static unsigned int reg_get_max_bandwidth(const struct ieee80211_regdomain *rd,
 		if (freq_range_tmp->start_freq_khz > freq_range->end_freq_khz)
 			break;
 
+		if (tmp->flags & NL80211_RRF_STRICT_BW)
+			break;
+
 		freq_range = freq_range_tmp;
 	}
 
@@ -594,6 +605,7 @@ static unsigned int reg_get_max_bandwidth(const struct ieee80211_regdomain *rd,
 static bool is_valid_reg_rule(const struct ieee80211_reg_rule *rule)
 {
 	const struct ieee80211_freq_range *freq_range = &rule->freq_range;
+	u32 freq_diff;
 
 	if (freq_range->start_freq_khz <= 0 || freq_range->end_freq_khz <= 0)
 		return false;
@@ -604,6 +616,12 @@ static bool is_valid_reg_rule(const struct ieee80211_reg_rule *rule)
 	if (freq_range->end_freq_khz <= freq_range->start_freq_khz)
 		return false;
 
+	freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
+
+	if ((rule->flags & NL80211_RRF_STRICT_BW) &&
+	    freq_range->max_bandwidth_khz > freq_diff)
+		return false;
+
 	return true;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux