コード例 #1
0
ファイル: ap.c プロジェクト: cococorp/hostap-upstream
int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
			      struct wpa_ssid *ssid,
			      struct hostapd_config *conf)
{
	conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency,
					       &conf->channel);

	if (conf->hw_mode == NUM_HOSTAPD_MODES) {
		wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
			   ssid->frequency);
		return -1;
	}

	/* TODO: enable HT40 if driver supports it;
	 * drop to 11b if driver does not support 11g */

#ifdef CONFIG_IEEE80211N
	/*
	 * Enable HT20 if the driver supports it, by setting conf->ieee80211n
	 * and a mask of allowed capabilities within conf->ht_capab.
	 * Using default config settings for: conf->ht_op_mode_fixed,
	 * conf->secondary_channel, conf->require_ht
	 */
	if (wpa_s->hw.modes) {
		struct hostapd_hw_modes *mode = NULL;
		int i, no_ht = 0;
		for (i = 0; i < wpa_s->hw.num_modes; i++) {
			if (wpa_s->hw.modes[i].mode == conf->hw_mode) {
				mode = &wpa_s->hw.modes[i];
				break;
			}
		}

#ifdef CONFIG_HT_OVERRIDES
		if (ssid->disable_ht) {
			conf->ieee80211n = 0;
			conf->ht_capab = 0;
			no_ht = 1;
		}
#endif /* CONFIG_HT_OVERRIDES */

		if (!no_ht && mode && mode->ht_capab) {
			conf->ieee80211n = 1;
#ifdef CONFIG_P2P
			if (conf->hw_mode == HOSTAPD_MODE_IEEE80211A &&
			    (mode->ht_capab &
			     HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
			    ssid->ht40)
				conf->secondary_channel =
					wpas_p2p_get_ht40_mode(wpa_s, mode,
							       conf->channel);
			if (conf->secondary_channel)
				conf->ht_capab |=
					HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
#endif /* CONFIG_P2P */

			/*
			 * white-list capabilities that won't cause issues
			 * to connecting stations, while leaving the current
			 * capabilities intact (currently disabled SMPS).
			 */
			conf->ht_capab |= mode->ht_capab &
				(HT_CAP_INFO_GREEN_FIELD |
				 HT_CAP_INFO_SHORT_GI20MHZ |
				 HT_CAP_INFO_SHORT_GI40MHZ |
				 HT_CAP_INFO_RX_STBC_MASK |
				 HT_CAP_INFO_TX_STBC |
				 HT_CAP_INFO_MAX_AMSDU_SIZE);

			if (mode->vht_capab && ssid->vht) {
				conf->ieee80211ac = 1;
				wpas_conf_ap_vht(wpa_s, conf, mode);
			}
		}
	}

	if (conf->secondary_channel) {
		struct wpa_supplicant *iface;

		for (iface = wpa_s->global->ifaces; iface; iface = iface->next)
		{
			if (iface == wpa_s ||
			    iface->wpa_state < WPA_AUTHENTICATING ||
			    (int) iface->assoc_freq != ssid->frequency)
				continue;

			/*
			 * Do not allow 40 MHz co-ex PRI/SEC switch to force us
			 * to change our PRI channel since we have an existing,
			 * concurrent connection on that channel and doing
			 * multi-channel concurrency is likely to cause more
			 * harm than using different PRI/SEC selection in
			 * environment with multiple BSSes on these two channels
			 * with mixed 20 MHz or PRI channel selection.
			 */
			conf->no_pri_sec_switch = 1;
		}
	}
#endif /* CONFIG_IEEE80211N */

	return 0;
}
コード例 #2
0
ファイル: ap.c プロジェクト: priyaanna/wpa_supplicant_8
void wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
			       struct wpa_ssid *ssid,
			       struct hostapd_config *conf)
{
	/* TODO: enable HT40 if driver supports it;
	 * drop to 11b if driver does not support 11g */

#ifdef CONFIG_IEEE80211N
	/*
	 * Enable HT20 if the driver supports it, by setting conf->ieee80211n
	 * and a mask of allowed capabilities within conf->ht_capab.
	 * Using default config settings for: conf->ht_op_mode_fixed,
	 * conf->secondary_channel, conf->require_ht
	 */
	if (wpa_s->hw.modes) {
		struct hostapd_hw_modes *mode = NULL;
		int i, no_ht = 0;
		for (i = 0; i < wpa_s->hw.num_modes; i++) {
			if (wpa_s->hw.modes[i].mode == conf->hw_mode) {
				mode = &wpa_s->hw.modes[i];
				break;
			}
		}

#ifdef CONFIG_HT_OVERRIDES
		if (ssid->disable_ht) {
			conf->ieee80211n = 0;
			conf->ht_capab = 0;
			no_ht = 1;
		}
#endif /* CONFIG_HT_OVERRIDES */

		if (!no_ht && mode && mode->ht_capab) {
			conf->ieee80211n = 1;
#ifdef CONFIG_P2P
			if (conf->hw_mode == HOSTAPD_MODE_IEEE80211A &&
			    (mode->ht_capab &
			     HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
			    ssid->ht40)
				conf->secondary_channel =
					wpas_p2p_get_ht40_mode(wpa_s, mode,
							       conf->channel);
			if (conf->secondary_channel)
				conf->ht_capab |=
					HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
#endif /* CONFIG_P2P */

			/*
			 * white-list capabilities that won't cause issues
			 * to connecting stations, while leaving the current
			 * capabilities intact (currently disabled SMPS).
			 */
			conf->ht_capab |= mode->ht_capab &
				(HT_CAP_INFO_GREEN_FIELD |
				 HT_CAP_INFO_SHORT_GI20MHZ |
				 HT_CAP_INFO_SHORT_GI40MHZ |
				 HT_CAP_INFO_RX_STBC_MASK |
				 HT_CAP_INFO_TX_STBC |
				 HT_CAP_INFO_MAX_AMSDU_SIZE);

			if (mode->vht_capab && ssid->vht) {
				conf->ieee80211ac = 1;
				wpas_conf_ap_vht(wpa_s, conf, mode);
			}
		}
	}
#endif /* CONFIG_IEEE80211N */
}