• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hostapd / IEEE 802.11n HT
3  * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2007-2008, Intel Corporation
5  *
6  * This software may be distributed under the terms of the BSD license.
7  * See README for more details.
8  */
9 
10 #include "utils/includes.h"
11 
12 #include "utils/common.h"
13 #include "utils/eloop.h"
14 #include "common/ieee802_11_defs.h"
15 #include "hostapd.h"
16 #include "ap_config.h"
17 #include "sta_info.h"
18 #include "beacon.h"
19 #include "ieee802_11.h"
20 #include "hw_features.h"
21 #include "ap_drv_ops.h"
22 
23 
hostapd_eid_ht_capabilities(struct hostapd_data * hapd,u8 * eid)24 u8 * hostapd_eid_ht_capabilities(struct hostapd_data *hapd, u8 *eid)
25 {
26 	struct ieee80211_ht_capabilities *cap;
27 	u8 *pos = eid;
28 
29 	if (!hapd->iconf->ieee80211n || !hapd->iface->current_mode ||
30 	    hapd->conf->disable_11n || is_6ghz_op_class(hapd->iconf->op_class))
31 		return eid;
32 
33 	*pos++ = WLAN_EID_HT_CAP;
34 	*pos++ = sizeof(*cap);
35 
36 	cap = (struct ieee80211_ht_capabilities *) pos;
37 	os_memset(cap, 0, sizeof(*cap));
38 	cap->ht_capabilities_info = host_to_le16(hapd->iconf->ht_capab);
39 #ifndef LOS_CONFIG_EXT_DRIVER_NOT_SUPPORT
40 	cap->a_mpdu_params = hapd->iface->current_mode->a_mpdu_params;
41 	os_memcpy(cap->supported_mcs_set, hapd->iface->current_mode->mcs_set,
42 		  16);
43 #endif /* LOS_CONFIG_EXT_DRIVER_NOT_SUPPORT */
44 
45 	/* TODO: ht_extended_capabilities (now fully disabled) */
46 	/* TODO: tx_bf_capability_info (now fully disabled) */
47 	/* TODO: asel_capabilities (now fully disabled) */
48 
49  	pos += sizeof(*cap);
50 
51 #ifndef EXT_CODE_CROP
52 	if (hapd->iconf->obss_interval) {
53 		struct ieee80211_obss_scan_parameters *scan_params;
54 
55 		*pos++ = WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS;
56 		*pos++ = sizeof(*scan_params);
57 
58 		scan_params = (struct ieee80211_obss_scan_parameters *) pos;
59 		os_memset(scan_params, 0, sizeof(*scan_params));
60 		scan_params->width_trigger_scan_interval =
61 			host_to_le16(hapd->iconf->obss_interval);
62 
63 		/* Fill in default values for remaining parameters
64 		 * (IEEE Std 802.11-2012, 8.4.2.61 and MIB defval) */
65 		scan_params->scan_passive_dwell =
66 			host_to_le16(20);
67 		scan_params->scan_active_dwell =
68 			host_to_le16(10);
69 		scan_params->scan_passive_total_per_channel =
70 			host_to_le16(200);
71 		scan_params->scan_active_total_per_channel =
72 			host_to_le16(20);
73 		scan_params->channel_transition_delay_factor =
74 			host_to_le16(5);
75 		scan_params->scan_activity_threshold =
76 			host_to_le16(25);
77 
78 		pos += sizeof(*scan_params);
79 	}
80 #endif /* EXT_CODE_CROP */
81 
82 	return pos;
83 }
84 
85 
hostapd_eid_ht_operation(struct hostapd_data * hapd,u8 * eid)86 u8 * hostapd_eid_ht_operation(struct hostapd_data *hapd, u8 *eid)
87 {
88 	struct ieee80211_ht_operation *oper;
89 	u8 *pos = eid;
90 
91 	if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n ||
92 	    is_6ghz_op_class(hapd->iconf->op_class))
93 		return eid;
94 
95 	*pos++ = WLAN_EID_HT_OPERATION;
96 	*pos++ = sizeof(*oper);
97 
98 	oper = (struct ieee80211_ht_operation *) pos;
99 	os_memset(oper, 0, sizeof(*oper));
100 
101 	oper->primary_chan = hapd->iconf->channel;
102 	oper->operation_mode = host_to_le16(hapd->iface->ht_op_mode);
103 #ifndef EXT_CODE_CROP
104 	if (hapd->iconf->secondary_channel == 1)
105 		oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE |
106 			HT_INFO_HT_PARAM_STA_CHNL_WIDTH;
107 	if (hapd->iconf->secondary_channel == -1)
108 		oper->ht_param |= HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW |
109 			HT_INFO_HT_PARAM_STA_CHNL_WIDTH;
110 #endif /* EXT_CODE_CROP */
111 
112 	pos += sizeof(*oper);
113 
114 	return pos;
115 }
116 
117 
118 #ifndef EXT_CODE_CROP
119 /*
120 op_mode
121 Set to 0 (HT pure) under the following conditions
122 	- all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
123 	- all STAs in the BSS are 20 MHz HT in 20 MHz BSS
124 Set to 1 (HT non-member protection) if there may be non-HT STAs
125 	in both the primary and the secondary channel
126 Set to 2 if only HT STAs are associated in BSS,
127 	however and at least one 20 MHz HT STA is associated
128 Set to 3 (HT mixed mode) when one or more non-HT STAs are associated
129 */
hostapd_ht_operation_update(struct hostapd_iface * iface)130 int hostapd_ht_operation_update(struct hostapd_iface *iface)
131 {
132 	u16 cur_op_mode, new_op_mode;
133 	int op_mode_changes = 0;
134 
135 	if (!iface->conf->ieee80211n || iface->conf->ht_op_mode_fixed)
136 		return 0;
137 
138 	wpa_printf(MSG_DEBUG, "%s current operation mode=0x%X",
139 		   __func__, iface->ht_op_mode);
140 
141 	if (!(iface->ht_op_mode & HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT)
142 	    && iface->num_sta_ht_no_gf) {
143 		iface->ht_op_mode |= HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT;
144 		op_mode_changes++;
145 	} else if ((iface->ht_op_mode &
146 		    HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT) &&
147 		   iface->num_sta_ht_no_gf == 0) {
148 		iface->ht_op_mode &= ~HT_OPER_OP_MODE_NON_GF_HT_STAS_PRESENT;
149 		op_mode_changes++;
150 	}
151 
152 	if (!(iface->ht_op_mode & HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT) &&
153 	    (iface->num_sta_no_ht || iface->olbc_ht)) {
154 		iface->ht_op_mode |= HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT;
155 		op_mode_changes++;
156 	} else if ((iface->ht_op_mode &
157 		    HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT) &&
158 		   (iface->num_sta_no_ht == 0 && !iface->olbc_ht)) {
159 		iface->ht_op_mode &= ~HT_OPER_OP_MODE_OBSS_NON_HT_STAS_PRESENT;
160 		op_mode_changes++;
161 	}
162 
163 	if (iface->num_sta_no_ht)
164 		new_op_mode = HT_PROT_NON_HT_MIXED;
165 	else if (iface->conf->secondary_channel && iface->num_sta_ht_20mhz)
166 		new_op_mode = HT_PROT_20MHZ_PROTECTION;
167 	else if (iface->olbc_ht)
168 		new_op_mode = HT_PROT_NONMEMBER_PROTECTION;
169 	else
170 		new_op_mode = HT_PROT_NO_PROTECTION;
171 
172 	cur_op_mode = iface->ht_op_mode & HT_OPER_OP_MODE_HT_PROT_MASK;
173 	if (cur_op_mode != new_op_mode) {
174 		iface->ht_op_mode &= ~HT_OPER_OP_MODE_HT_PROT_MASK;
175 		iface->ht_op_mode |= new_op_mode;
176 		op_mode_changes++;
177 	}
178 
179 	wpa_printf(MSG_DEBUG, "%s new operation mode=0x%X changes=%d",
180 		   __func__, iface->ht_op_mode, op_mode_changes);
181 
182 	return op_mode_changes;
183 }
184 
185 
is_40_allowed(struct hostapd_iface * iface,int channel)186 static int is_40_allowed(struct hostapd_iface *iface, int channel)
187 {
188 	int pri_freq, sec_freq;
189 	int affected_start, affected_end;
190 	int pri = 2407 + 5 * channel;
191 
192 	if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
193 		return 1;
194 
195 	pri_freq = hostapd_hw_get_freq(iface->bss[0], iface->conf->channel);
196 
197 	if (iface->conf->secondary_channel > 0)
198 		sec_freq = pri_freq + 20;
199 	else
200 		sec_freq = pri_freq - 20;
201 
202 	affected_start = (pri_freq + sec_freq) / 2 - 25;
203 	affected_end = (pri_freq + sec_freq) / 2 + 25;
204 	if ((pri < affected_start || pri > affected_end))
205 		return 1; /* not within affected channel range */
206 
207 	wpa_printf(MSG_ERROR, "40 MHz affected channel range: [%d,%d] MHz",
208 		   affected_start, affected_end);
209 	wpa_printf(MSG_ERROR, "Neighboring BSS: freq=%d", pri);
210 	return 0;
211 }
212 
213 
hostapd_2040_coex_action(struct hostapd_data * hapd,const struct ieee80211_mgmt * mgmt,size_t len)214 void hostapd_2040_coex_action(struct hostapd_data *hapd,
215 			      const struct ieee80211_mgmt *mgmt, size_t len)
216 {
217 	struct hostapd_iface *iface = hapd->iface;
218 	struct ieee80211_2040_bss_coex_ie *bc_ie;
219 	struct ieee80211_2040_intol_chan_report *ic_report;
220 	int is_ht40_allowed = 1;
221 	int i;
222 	const u8 *start = (const u8 *) mgmt;
223 	const u8 *data = start + IEEE80211_HDRLEN + 2;
224 	struct sta_info *sta;
225 
226 	wpa_printf(MSG_DEBUG,
227 		   "HT: Received 20/40 BSS Coexistence Management frame from "
228 		   MACSTR, MAC2STR(mgmt->sa));
229 
230 	hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
231 		       HOSTAPD_LEVEL_DEBUG, "hostapd_public_action - action=%d",
232 		       mgmt->u.action.u.public_action.action);
233 
234 	if (!(iface->conf->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) {
235 		wpa_printf(MSG_DEBUG,
236 			   "Ignore 20/40 BSS Coexistence Management frame since 40 MHz capability is not enabled");
237 		return;
238 	}
239 
240 	if (len < IEEE80211_HDRLEN + 2 + sizeof(*bc_ie)) {
241 		wpa_printf(MSG_DEBUG,
242 			   "Ignore too short 20/40 BSS Coexistence Management frame");
243 		return;
244 	}
245 
246 	/* 20/40 BSS Coexistence element */
247 	bc_ie = (struct ieee80211_2040_bss_coex_ie *) data;
248 	if (bc_ie->element_id != WLAN_EID_20_40_BSS_COEXISTENCE ||
249 	    bc_ie->length < 1) {
250 		wpa_printf(MSG_DEBUG, "Unexpected IE (%u,%u) in coex report",
251 			   bc_ie->element_id, bc_ie->length);
252 		return;
253 	}
254 	if (len < IEEE80211_HDRLEN + 2 + 2 + bc_ie->length) {
255 		wpa_printf(MSG_DEBUG,
256 			   "Truncated 20/40 BSS Coexistence element");
257 		return;
258 	}
259 	data += 2 + bc_ie->length;
260 
261 	wpa_printf(MSG_DEBUG,
262 		   "20/40 BSS Coexistence Information field: 0x%x (%s%s%s%s%s%s)",
263 		   bc_ie->coex_param,
264 		   (bc_ie->coex_param & BIT(0)) ? "[InfoReq]" : "",
265 		   (bc_ie->coex_param & BIT(1)) ? "[40MHzIntolerant]" : "",
266 		   (bc_ie->coex_param & BIT(2)) ? "[20MHzBSSWidthReq]" : "",
267 		   (bc_ie->coex_param & BIT(3)) ? "[OBSSScanExemptionReq]" : "",
268 		   (bc_ie->coex_param & BIT(4)) ?
269 		   "[OBSSScanExemptionGrant]" : "",
270 		   (bc_ie->coex_param & (BIT(5) | BIT(6) | BIT(7))) ?
271 		   "[Reserved]" : "");
272 
273 	if (bc_ie->coex_param & WLAN_20_40_BSS_COEX_20MHZ_WIDTH_REQ) {
274 		/* Intra-BSS communication prohibiting 20/40 MHz BSS operation
275 		 */
276 		sta = ap_get_sta(hapd, mgmt->sa);
277 		if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
278 			wpa_printf(MSG_DEBUG,
279 				   "Ignore intra-BSS 20/40 BSS Coexistence Management frame from not-associated STA");
280 			return;
281 		}
282 
283 		hostapd_logger(hapd, mgmt->sa,
284 			       HOSTAPD_MODULE_IEEE80211,
285 			       HOSTAPD_LEVEL_DEBUG,
286 			       "20 MHz BSS width request bit is set in BSS coexistence information field");
287 		is_ht40_allowed = 0;
288 	}
289 
290 	if (bc_ie->coex_param & WLAN_20_40_BSS_COEX_40MHZ_INTOL) {
291 		/* Inter-BSS communication prohibiting 20/40 MHz BSS operation
292 		 */
293 		hostapd_logger(hapd, mgmt->sa,
294 			       HOSTAPD_MODULE_IEEE80211,
295 			       HOSTAPD_LEVEL_DEBUG,
296 			       "40 MHz intolerant bit is set in BSS coexistence information field");
297 		is_ht40_allowed = 0;
298 	}
299 
300 	/* 20/40 BSS Intolerant Channel Report element (zero or more times) */
301 	while (start + len - data >= 3 &&
302 	       data[0] == WLAN_EID_20_40_BSS_INTOLERANT && data[1] >= 1) {
303 		u8 ielen = data[1];
304 
305 		if (ielen > start + len - data - 2) {
306 			wpa_printf(MSG_DEBUG,
307 				   "Truncated 20/40 BSS Intolerant Channel Report element");
308 			return;
309 		}
310 		ic_report = (struct ieee80211_2040_intol_chan_report *) data;
311 		wpa_printf(MSG_DEBUG,
312 			   "20/40 BSS Intolerant Channel Report: Operating Class %u",
313 			   ic_report->op_class);
314 
315 		/* Go through the channel report to find any BSS there in the
316 		 * affected channel range */
317 		for (i = 0; i < ielen - 1; i++) {
318 			u8 chan = ic_report->variable[i];
319 
320 			if (chan == iface->conf->channel)
321 				continue; /* matching own primary channel */
322 			if (is_40_allowed(iface, chan))
323 				continue; /* not within affected channels */
324 			hostapd_logger(hapd, mgmt->sa,
325 				       HOSTAPD_MODULE_IEEE80211,
326 				       HOSTAPD_LEVEL_DEBUG,
327 				       "20_40_INTOLERANT channel %d reported",
328 				       chan);
329 			is_ht40_allowed = 0;
330 		}
331 
332 		data += 2 + ielen;
333 	}
334 	wpa_printf(MSG_DEBUG, "is_ht40_allowed=%d num_sta_ht40_intolerant=%d",
335 		   is_ht40_allowed, iface->num_sta_ht40_intolerant);
336 
337 	if (!is_ht40_allowed &&
338 	    (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX)) {
339 		if (iface->conf->secondary_channel) {
340 			hostapd_logger(hapd, mgmt->sa,
341 				       HOSTAPD_MODULE_IEEE80211,
342 				       HOSTAPD_LEVEL_INFO,
343 				       "Switching to 20 MHz operation");
344 			iface->conf->secondary_channel = 0;
345 			ieee802_11_set_beacons(iface);
346 		}
347 		if (!iface->num_sta_ht40_intolerant &&
348 		    iface->conf->obss_interval) {
349 			unsigned int delay_time;
350 			delay_time = OVERLAPPING_BSS_TRANS_DELAY_FACTOR *
351 				iface->conf->obss_interval;
352 			eloop_cancel_timeout(ap_ht2040_timeout, hapd->iface,
353 					     NULL);
354 			eloop_register_timeout(delay_time, 0, ap_ht2040_timeout,
355 					       hapd->iface, NULL);
356 			wpa_printf(MSG_DEBUG,
357 				   "Reschedule HT 20/40 timeout to occur in %u seconds",
358 				   delay_time);
359 		}
360 	}
361 }
362 
363 
copy_sta_ht_capab(struct hostapd_data * hapd,struct sta_info * sta,const u8 * ht_capab)364 u16 copy_sta_ht_capab(struct hostapd_data *hapd, struct sta_info *sta,
365 		      const u8 *ht_capab)
366 {
367 	/*
368 	 * Disable HT caps for STAs associated to no-HT BSSes, or for stations
369 	 * that did not specify a valid WMM IE in the (Re)Association Request
370 	 * frame.
371 	 */
372 	if (!ht_capab || !(sta->flags & WLAN_STA_WMM) ||
373 	    !hapd->iconf->ieee80211n || hapd->conf->disable_11n) {
374 		sta->flags &= ~WLAN_STA_HT;
375 		os_free(sta->ht_capabilities);
376 		sta->ht_capabilities = NULL;
377 		return WLAN_STATUS_SUCCESS;
378 	}
379 
380 	if (sta->ht_capabilities == NULL) {
381 		sta->ht_capabilities =
382 			os_zalloc(sizeof(struct ieee80211_ht_capabilities));
383 		if (sta->ht_capabilities == NULL)
384 			return WLAN_STATUS_UNSPECIFIED_FAILURE;
385 	}
386 
387 	sta->flags |= WLAN_STA_HT;
388 	os_memcpy(sta->ht_capabilities, ht_capab,
389 		  sizeof(struct ieee80211_ht_capabilities));
390 
391 	return WLAN_STATUS_SUCCESS;
392 }
393 
394 
ht40_intolerant_add(struct hostapd_iface * iface,struct sta_info * sta)395 void ht40_intolerant_add(struct hostapd_iface *iface, struct sta_info *sta)
396 {
397 	if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
398 		return;
399 
400 	wpa_printf(MSG_INFO, "HT: Forty MHz Intolerant is set by STA " MACSTR
401 		   " in Association Request", MAC2STR(sta->addr));
402 
403 	if (sta->ht40_intolerant_set)
404 		return;
405 
406 	sta->ht40_intolerant_set = 1;
407 	iface->num_sta_ht40_intolerant++;
408 	eloop_cancel_timeout(ap_ht2040_timeout, iface, NULL);
409 
410 	if (iface->conf->secondary_channel &&
411 	    (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX)) {
412 		iface->conf->secondary_channel = 0;
413 		ieee802_11_set_beacons(iface);
414 	}
415 }
416 
417 
ht40_intolerant_remove(struct hostapd_iface * iface,struct sta_info * sta)418 void ht40_intolerant_remove(struct hostapd_iface *iface, struct sta_info *sta)
419 {
420 	if (!sta->ht40_intolerant_set)
421 		return;
422 
423 	sta->ht40_intolerant_set = 0;
424 	iface->num_sta_ht40_intolerant--;
425 
426 	if (iface->num_sta_ht40_intolerant == 0 &&
427 	    (iface->conf->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
428 	    (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX)) {
429 		unsigned int delay_time = OVERLAPPING_BSS_TRANS_DELAY_FACTOR *
430 			iface->conf->obss_interval;
431 		wpa_printf(MSG_DEBUG,
432 			   "HT: Start 20->40 MHz transition timer (%d seconds)",
433 			   delay_time);
434 		eloop_cancel_timeout(ap_ht2040_timeout, iface, NULL);
435 		eloop_register_timeout(delay_time, 0, ap_ht2040_timeout,
436 				       iface, NULL);
437 	}
438 }
439 
440 
update_sta_ht(struct hostapd_data * hapd,struct sta_info * sta)441 static void update_sta_ht(struct hostapd_data *hapd, struct sta_info *sta)
442 {
443 	u16 ht_capab;
444 
445 	ht_capab = le_to_host16(sta->ht_capabilities->ht_capabilities_info);
446 	wpa_printf(MSG_DEBUG, "HT: STA " MACSTR " HT Capabilities Info: "
447 		   "0x%04x", MAC2STR(sta->addr), ht_capab);
448 	if ((ht_capab & HT_CAP_INFO_GREEN_FIELD) == 0) {
449 		if (!sta->no_ht_gf_set) {
450 			sta->no_ht_gf_set = 1;
451 			hapd->iface->num_sta_ht_no_gf++;
452 		}
453 		wpa_printf(MSG_DEBUG, "%s STA " MACSTR " - no greenfield, num "
454 			   "of non-gf stations %d",
455 			   __func__, MAC2STR(sta->addr),
456 			   hapd->iface->num_sta_ht_no_gf);
457 	}
458 	if ((ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) == 0) {
459 		if (!sta->ht_20mhz_set) {
460 			sta->ht_20mhz_set = 1;
461 			hapd->iface->num_sta_ht_20mhz++;
462 		}
463 		wpa_printf(MSG_DEBUG, "%s STA " MACSTR " - 20 MHz HT, num of "
464 			   "20MHz HT STAs %d",
465 			   __func__, MAC2STR(sta->addr),
466 			   hapd->iface->num_sta_ht_20mhz);
467 	}
468 
469 	if (ht_capab & HT_CAP_INFO_40MHZ_INTOLERANT)
470 		ht40_intolerant_add(hapd->iface, sta);
471 }
472 
473 
update_sta_no_ht(struct hostapd_data * hapd,struct sta_info * sta)474 static void update_sta_no_ht(struct hostapd_data *hapd, struct sta_info *sta)
475 {
476 	if (!sta->no_ht_set) {
477 		sta->no_ht_set = 1;
478 		hapd->iface->num_sta_no_ht++;
479 	}
480 	if (hapd->iconf->ieee80211n) {
481 		wpa_printf(MSG_DEBUG, "%s STA " MACSTR " - no HT, num of "
482 			   "non-HT stations %d",
483 			   __func__, MAC2STR(sta->addr),
484 			   hapd->iface->num_sta_no_ht);
485 	}
486 }
487 
488 
update_ht_state(struct hostapd_data * hapd,struct sta_info * sta)489 void update_ht_state(struct hostapd_data *hapd, struct sta_info *sta)
490 {
491 	if ((sta->flags & WLAN_STA_HT) && sta->ht_capabilities)
492 		update_sta_ht(hapd, sta);
493 	else
494 		update_sta_no_ht(hapd, sta);
495 
496 	if (hostapd_ht_operation_update(hapd->iface) > 0)
497 		ieee802_11_set_beacons(hapd->iface);
498 }
499 
500 
hostapd_get_ht_capab(struct hostapd_data * hapd,struct ieee80211_ht_capabilities * ht_cap,struct ieee80211_ht_capabilities * neg_ht_cap)501 void hostapd_get_ht_capab(struct hostapd_data *hapd,
502 			  struct ieee80211_ht_capabilities *ht_cap,
503 			  struct ieee80211_ht_capabilities *neg_ht_cap)
504 {
505 	u16 cap;
506 
507 	if (ht_cap == NULL)
508 		return;
509 	os_memcpy(neg_ht_cap, ht_cap, sizeof(*neg_ht_cap));
510 	cap = le_to_host16(neg_ht_cap->ht_capabilities_info);
511 
512 	/*
513 	 * Mask out HT features we don't support, but don't overwrite
514 	 * non-symmetric features like STBC and SMPS. Just because
515 	 * we're not in dynamic SMPS mode the STA might still be.
516 	 */
517 	cap &= (hapd->iconf->ht_capab | HT_CAP_INFO_RX_STBC_MASK |
518 		HT_CAP_INFO_TX_STBC | HT_CAP_INFO_SMPS_MASK);
519 
520 	/*
521 	 * STBC needs to be handled specially
522 	 * if we don't support RX STBC, mask out TX STBC in the STA's HT caps
523 	 * if we don't support TX STBC, mask out RX STBC in the STA's HT caps
524 	 */
525 	if (!(hapd->iconf->ht_capab & HT_CAP_INFO_RX_STBC_MASK))
526 		cap &= ~HT_CAP_INFO_TX_STBC;
527 	if (!(hapd->iconf->ht_capab & HT_CAP_INFO_TX_STBC))
528 		cap &= ~HT_CAP_INFO_RX_STBC_MASK;
529 
530 	neg_ht_cap->ht_capabilities_info = host_to_le16(cap);
531 }
532 
533 
ap_ht2040_timeout(void * eloop_data,void * user_data)534 void ap_ht2040_timeout(void *eloop_data, void *user_data)
535 {
536 	struct hostapd_iface *iface = eloop_data;
537 
538 	wpa_printf(MSG_INFO, "Switching to 40 MHz operation");
539 
540 	iface->conf->secondary_channel = iface->secondary_ch;
541 	ieee802_11_set_beacons(iface);
542 }
543 #endif /* EXT_CODE_CROP */
544