diff mbox

[18/26] ap: Advertise supported operating classes IE

Message ID 1441705593-1184-19-git-send-email-ilan.peer@intel.com
State Accepted
Headers show

Commit Message

Ilan Peer Sept. 8, 2015, 9:46 a.m. UTC
From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>

Advertise current operating class in beacons and probe responses. This IE is
required by the spec when extended channel switch is supported. However, since
this IE doesn't reflect correctly the sub-band spectrum breakdown and can't be
effectively used by clients, publish only the minimal required part which
is the current op. class.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 src/ap/beacon.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
diff mbox

Patch

diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 32e054e..3887f4a 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -328,6 +328,34 @@  static u8 *hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid)
 }
 
 
+static u8 *hostapd_eid_supported_op_classes(struct hostapd_data *hapd, u8 *eid)
+{
+	u8 op_class, channel;
+
+	if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA) ||
+	    !hapd->iface->freq)
+		return eid;
+
+	if (ieee80211_freq_to_channel_ext(hapd->iface->freq,
+					  hapd->iconf->secondary_channel,
+					  hapd->iconf->vht_oper_chwidth,
+					  &op_class, &channel) ==
+	    NUM_HOSTAPD_MODES)
+		return eid;
+
+	*eid++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES;
+	*eid++ = 2;
+
+	/* Current op. class must be first */
+	*eid++ = op_class;
+
+	/* TODO: advertise all the supported op. classes */
+	*eid++ = 0;
+
+	return eid;
+}
+
+
 static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
 				   const struct ieee80211_mgmt *req,
 				   int is_p2p, size_t *resp_len)
@@ -419,6 +447,7 @@  static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
 		hapd->cs_c_off_ecsa_proberesp = csa_pos - (u8 *)resp - 1;
 
 	pos = csa_pos;
+	pos = hostapd_eid_supported_op_classes(hapd, pos);
 
 #ifdef CONFIG_IEEE80211N
 	/* Secondary channel IE */
@@ -1005,6 +1034,8 @@  int ieee802_11_build_ap_params(struct hostapd_data *hapd,
 
 	tailpos = csa_pos;
 
+	tailpos = hostapd_eid_supported_op_classes(hapd, tailpos);
+
 #ifdef CONFIG_IEEE80211N
 	/* Secondary Channel IE */
 	/* TODO: The spec doesn't specify secondary channel IE position */