[RFC 4/8] make get_pri_sec_chan() common

Janusz Dziedzic janusz.dziedzic at tieto.com
Thu Jan 8 06:48:32 EST 2015


Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
 src/ap/hw_features.c            | 20 +-------------------
 src/common/hw_features_common.c | 25 +++++++++++++++++++++++++
 src/common/hw_features_common.h |  2 ++
 3 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c
index 2f969c6..7be3c09 100644
--- a/src/ap/hw_features.c
+++ b/src/ap/hw_features.c
@@ -251,25 +251,7 @@ static void ieee80211n_switch_pri_sec(struct hostapd_iface *iface)
 static void ieee80211n_get_pri_sec_chan(struct wpa_scan_res *bss,
 					int *pri_chan, int *sec_chan)
 {
-	struct ieee80211_ht_operation *oper;
-	struct ieee802_11_elems elems;
-
-	*pri_chan = *sec_chan = 0;
-
-	ieee802_11_parse_elems((u8 *) (bss + 1), bss->ie_len, &elems, 0);
-	if (elems.ht_operation &&
-	    elems.ht_operation_len >= sizeof(*oper)) {
-		oper = (struct ieee80211_ht_operation *) elems.ht_operation;
-		*pri_chan = oper->primary_chan;
-		if (oper->ht_param & HT_INFO_HT_PARAM_STA_CHNL_WIDTH) {
-			int sec = oper->ht_param &
-				HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK;
-			if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE)
-				*sec_chan = *pri_chan + 4;
-			else if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW)
-				*sec_chan = *pri_chan - 4;
-		}
-	}
+	return get_pri_sec_chan(bss, pri_chan, sec_chan);
 }
 
 
diff --git a/src/common/hw_features_common.c b/src/common/hw_features_common.c
index 2b9e914..56bdaa1 100644
--- a/src/common/hw_features_common.c
+++ b/src/common/hw_features_common.c
@@ -11,6 +11,8 @@
 
 #include "common.h"
 #include "defs.h"
+#include "ieee802_11_defs.h"
+#include "ieee802_11_common.h"
 #include "hw_features_common.h"
 
 struct hostapd_channel_data *hw_get_channel_chan(struct hostapd_hw_modes *mode, int chan, int *freq)
@@ -133,3 +135,26 @@ int allowed_ht40_channel_pair(struct hostapd_hw_modes *mode, int pri_chan, int s
 
 	return 1;
 }
+
+void get_pri_sec_chan(struct wpa_scan_res *bss, int *pri_chan, int *sec_chan)
+{
+	struct ieee80211_ht_operation *oper;
+	struct ieee802_11_elems elems;
+
+	*pri_chan = *sec_chan = 0;
+
+	ieee802_11_parse_elems((u8 *) (bss + 1), bss->ie_len, &elems, 0);
+	if (elems.ht_operation &&
+	    elems.ht_operation_len >= sizeof(*oper)) {
+		oper = (struct ieee80211_ht_operation *) elems.ht_operation;
+		*pri_chan = oper->primary_chan;
+		if (oper->ht_param & HT_INFO_HT_PARAM_STA_CHNL_WIDTH) {
+			int sec = oper->ht_param &
+				HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK;
+			if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE)
+				*sec_chan = *pri_chan + 4;
+			else if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW)
+				*sec_chan = *pri_chan - 4;
+		}
+	}
+}
diff --git a/src/common/hw_features_common.h b/src/common/hw_features_common.h
index bb52fb5..0a1ddea 100644
--- a/src/common/hw_features_common.h
+++ b/src/common/hw_features_common.h
@@ -19,4 +19,6 @@ int hw_get_freq(struct hostapd_hw_modes *mode, int chan);
 int hw_get_chan(struct hostapd_hw_modes *mode, int freq);
 
 int allowed_ht40_channel_pair(struct hostapd_hw_modes *mode, int pri_chan, int sec_chan);
+void get_pri_sec_chan(struct wpa_scan_res *bss, int *pri_chan, int *sec_chan);
+
 #endif /* HW_FEATURES_COMMON_H */
-- 
1.9.1



More information about the HostAP mailing list