]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Make get_pri_sec_chan() common
authorJanusz Dziedzic <janusz.dziedzic@tieto.com>
Thu, 8 Jan 2015 11:48:32 +0000 (12:48 +0100)
committerJouni Malinen <j@w1.fi>
Sat, 10 Jan 2015 15:35:53 +0000 (17:35 +0200)
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
src/ap/hw_features.c
src/common/hw_features_common.c
src/common/hw_features_common.h

index a76e6376723e048538e9b44f3561c8d75a89b093..72f919e28bc1ceea849f5783372113d5059db9c5 100644 (file)
@@ -252,25 +252,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);
 }
 
 
index 28ee164727b30009234f3d741d790bae2e0e6b79..2343d1fb4f1cce288998cc10b2b1f18931a5fe78 100644 (file)
@@ -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"
 
 
@@ -140,3 +142,27 @@ int allowed_ht40_channel_pair(struct hostapd_hw_modes *mode, int pri_chan,
 
        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;
+               }
+       }
+}
index f4e86323ebda22f5563bf5ed3566e23ab265ebec..adba7d85bf806ff58958c9864992518ed6d7e5fd 100644 (file)
@@ -22,5 +22,6 @@ 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 */