[PATCH 14/25] utils: Derive phy type by frequency and bandwidth

Ilan Peer ilan.peer at intel.com
Mon Feb 15 06:53:40 PST 2016


From: David Spinadel <david.spinadel at intel.com>

Add a function to derive phy type from frequency and bandwidth
as defined in IEEE Std 802.11ac-2013 Annex C.

Signed-off-by: David Spinadel <david.spinadel at intel.com>
---
 src/common/ieee802_11_common.c | 35 +++++++++++++++++++++++++++++++++++
 src/common/ieee802_11_common.h |  1 +
 src/common/ieee802_11_defs.h   | 15 +++++++++++++++
 3 files changed, 51 insertions(+)

diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
index b9abdd3..5f6e0a1 100644
--- a/src/common/ieee802_11_common.c
+++ b/src/common/ieee802_11_common.c
@@ -1211,6 +1211,41 @@ const struct oper_class_map op_class[] = {
 	{ -1, 0, 0, 0, 0, BW20, P2P_NOTSUPPORTED }
 };
 
+
+static inline enum phy_type ieee80211_phy_type_by_freq(int freq)
+{
+	enum hostapd_hw_mode hw_mode;
+	u8 channel;
+
+	hw_mode = ieee80211_freq_to_chan(freq, &channel);
+
+	switch (hw_mode) {
+	case HOSTAPD_MODE_IEEE80211A:
+		return PHY_TYPE_OFDM;
+	case HOSTAPD_MODE_IEEE80211B:
+		return PHY_TYPE_HRDSSS;
+	case HOSTAPD_MODE_IEEE80211G:
+		return PHY_TYPE_ERP;
+	case HOSTAPD_MODE_IEEE80211AD:
+		return PHY_TYPE_DMG;
+	default:
+		return PHY_TYPE_UNSPECIFIED;
+	};
+}
+
+
+/* get_phy_type - Derive the phy type by freq and bandwidth */
+enum phy_type ieee80211_get_phy_type(int freq, int ht, int vht)
+{
+	if (vht)
+		return PHY_TYPE_VHT;
+	if (ht)
+		return PHY_TYPE_HT;
+
+	return ieee80211_phy_type_by_freq(freq);
+}
+
+
 size_t op_class_size = ARRAY_SIZE(op_class);
 
 
diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h
index 6150469..3f54641 100644
--- a/src/common/ieee802_11_common.h
+++ b/src/common/ieee802_11_common.h
@@ -120,6 +120,7 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq,
 						   int sec_channel, int vht,
 						   u8 *op_class, u8 *channel);
 int ieee80211_is_dfs(int freq);
+enum phy_type ieee80211_get_phy_type(int freq, int ht, int vht);
 
 int supp_rates_11b_only(struct ieee802_11_elems *elems);
 int mb_ies_info_by_ies(struct mb_ies_info *info, const u8 *ies_buf,
diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index 37702db..9503bf5 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -1499,4 +1499,19 @@ enum fst_action {
 	FST_ACTION_ON_CHANNEL_TUNNEL = 5,
 };
 
+
+/* 802.11ac-2013, Annex C */
+enum phy_type {
+	PHY_TYPE_UNSPECIFIED = 0,
+	PHY_TYPE_FHSS = 1,
+	PHY_TYPE_DSSS = 2,
+	PHY_TYPE_IRBASEBAND = 3,
+	PHY_TYPE_OFDM = 4,
+	PHY_TYPE_HRDSSS = 5,
+	PHY_TYPE_ERP = 6,
+	PHY_TYPE_HT = 7,
+	PHY_TYPE_DMG = 8,
+	PHY_TYPE_VHT = 9,
+};
+
 #endif /* IEEE802_11_DEFS_H */
-- 
1.9.1




More information about the Hostap mailing list