Lines Matching defs:iface

75 int hostapd_get_hw_features(struct hostapd_iface *iface)
77 struct hostapd_data *hapd = iface->bss[0];
93 iface->hw_flags = flags;
95 hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
96 iface->hw_features = modes;
97 iface->num_hw_features = num_modes;
102 (iface->drv_flags & WPA_DRIVER_FLAGS_RADAR);
120 !(iface->drv_flags &
145 int hostapd_prepare_rates(struct hostapd_iface *iface,
154 if (iface->conf->basic_rates)
155 basic_rates = iface->conf->basic_rates;
177 os_free(iface->basic_rates);
178 iface->basic_rates = os_malloc(i * sizeof(int));
179 if (iface->basic_rates)
180 os_memcpy(iface->basic_rates, basic_rates, i * sizeof(int));
182 os_free(iface->current_rates);
183 iface->num_rates = 0;
185 iface->current_rates =
187 if (!iface->current_rates) {
196 if (iface->conf->supported_rates &&
197 !hostapd_rate_found(iface->conf->supported_rates,
201 rate = &iface->current_rates[iface->num_rates];
208 iface->num_rates, rate->rate, rate->flags);
209 iface->num_rates++;
212 if ((iface->num_rates == 0 || num_basic_rates == 0) &&
213 (!iface->conf->ieee80211n || !iface->conf->require_ht)) {
216 iface->num_rates, num_basic_rates);
225 static int ieee80211n_allowed_ht40_channel_pair(struct hostapd_iface *iface)
229 if (!iface->conf->secondary_channel)
232 pri_chan = iface->conf->channel;
233 sec_chan = pri_chan + iface->conf->secondary_channel * 4;
235 return allowed_ht40_channel_pair(iface->current_mode, pri_chan,
240 static void ieee80211n_switch_pri_sec(struct hostapd_iface *iface)
242 if (iface->conf->secondary_channel > 0) {
243 iface->conf->channel += 4;
244 iface->conf->secondary_channel = -1;
246 iface->conf->channel -= 4;
247 iface->conf->secondary_channel = 1;
252 static int ieee80211n_check_40mhz_5g(struct hostapd_iface *iface,
258 pri_chan = iface->conf->channel;
259 sec_chan = pri_chan + iface->conf->secondary_channel * 4;
261 res = check_40mhz_5g(iface->current_mode, scan_res, pri_chan, sec_chan);
264 if (iface->conf->no_pri_sec_switch) {
268 ieee80211n_switch_pri_sec(iface);
276 static int ieee80211n_check_40mhz_2g4(struct hostapd_iface *iface,
281 pri_chan = iface->conf->channel;
282 sec_chan = pri_chan + iface->conf->secondary_channel * 4;
284 return check_40mhz_2g4(iface->current_mode, scan_res, pri_chan,
289 static void ieee80211n_check_scan(struct hostapd_iface *iface)
298 iface->scan_cb = NULL;
300 scan_res = hostapd_driver_get_scan_results(iface->bss[0]);
302 hostapd_setup_interface_complete(iface, 1);
306 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A)
307 oper40 = ieee80211n_check_40mhz_5g(iface, scan_res);
309 oper40 = ieee80211n_check_40mhz_2g4(iface, scan_res);
312 iface->secondary_ch = iface->conf->secondary_channel;
316 iface->conf->channel,
317 iface->conf->channel +
318 iface->conf->secondary_channel * 4);
319 iface->conf->secondary_channel = 0;
320 if (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX) {
329 res = ieee80211n_allowed_ht40_channel_pair(iface);
331 iface->conf->secondary_channel = 0;
335 hostapd_setup_interface_complete(iface, !res);
339 static void ieee80211n_scan_channels_2g4(struct hostapd_iface *iface,
348 if (iface->current_mode == NULL)
351 pri_freq = hostapd_hw_get_freq(iface->bss[0], iface->conf->channel);
352 if (iface->conf->secondary_channel > 0)
366 mode = iface->current_mode;
384 static void ieee80211n_scan_channels_5g(struct hostapd_iface *iface,
393 if (iface->current_mode == NULL)
396 pri_freq = hostapd_hw_get_freq(iface->bss[0], iface->conf->channel);
397 if (iface->conf->secondary_channel > 0) {
407 mode = iface->current_mode;
428 struct hostapd_iface *iface = eloop_data;
433 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
434 ieee80211n_scan_channels_2g4(iface, &params);
436 ieee80211n_scan_channels_5g(iface, &params);
438 ret = hostapd_driver_scan(iface->bss[0], &params);
439 iface->num_ht40_scan_tries++;
443 iface->num_ht40_scan_tries < HT2040_COEX_SCAN_RETRY) {
446 ret, strerror(-ret), iface->num_ht40_scan_tries);
447 eloop_register_timeout(1, 0, ap_ht40_scan_retry, iface, NULL);
452 iface->scan_cb = ieee80211n_check_scan;
458 iface->conf->secondary_channel = 0;
459 iface->conf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
460 hostapd_setup_interface_complete(iface, 0);
464 void hostapd_stop_setup_timers(struct hostapd_iface *iface)
466 eloop_cancel_timeout(ap_ht40_scan_retry, iface, NULL);
470 static int ieee80211n_check_40mhz(struct hostapd_iface *iface)
475 if (!iface->conf->secondary_channel)
478 hostapd_set_state(iface, HAPD_IFACE_HT_SCAN);
482 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
483 ieee80211n_scan_channels_2g4(iface, &params);
485 ieee80211n_scan_channels_5g(iface, &params);
487 ret = hostapd_driver_scan(iface->bss[0], &params);
494 iface->num_ht40_scan_tries = 1;
495 eloop_cancel_timeout(ap_ht40_scan_retry, iface, NULL);
496 eloop_register_timeout(1, 0, ap_ht40_scan_retry, iface, NULL);
507 iface->scan_cb = ieee80211n_check_scan;
512 static int ieee80211n_supported_ht_capab(struct hostapd_iface *iface)
514 u16 hw = iface->current_mode->ht_capab;
515 u16 conf = iface->conf->ht_capab;
528 if (!iface->conf->acs && (conf & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
537 if (!(iface->smps_modes & WPA_DRIVER_SMPS_MODE_STATIC)) {
544 if (!(iface->smps_modes & WPA_DRIVER_SMPS_MODE_DYNAMIC)) {
657 static int ieee80211ac_supported_vht_capab(struct hostapd_iface *iface)
659 struct hostapd_hw_modes *mode = iface->current_mode;
661 u32 conf = iface->conf->vht_capab;
667 iface->conf->bss[0]->vendor_vht &&
668 mode->vht_capab == 0 && iface->hw_features) {
671 for (i = 0; i < iface->num_hw_features; i++) {
672 if (iface->hw_features[i].mode ==
674 mode = &iface->hw_features[i];
729 int hostapd_check_ht_capab(struct hostapd_iface *iface)
733 if (!iface->conf->ieee80211n)
736 if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211B &&
737 iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G &&
738 (iface->conf->ht_capab & HT_CAP_INFO_DSSS_CCK40MHZ)) {
741 iface->conf->ht_capab &= ~HT_CAP_INFO_DSSS_CCK40MHZ;
744 if (!ieee80211n_supported_ht_capab(iface))
747 if (!ieee80211ac_supported_vht_capab(iface))
750 ret = ieee80211n_check_40mhz(iface);
753 if (!ieee80211n_allowed_ht40_channel_pair(iface))
761 static int hostapd_is_usable_chan(struct hostapd_iface *iface,
767 if (!iface->current_mode)
770 for (i = 0; i < iface->current_mode->num_channels; i++) {
771 chan = &iface->current_mode->channels[i];
790 static int hostapd_is_usable_chans(struct hostapd_iface *iface)
792 if (!hostapd_is_usable_chan(iface, iface->conf->channel, 1))
795 if (!iface->conf->secondary_channel)
798 return hostapd_is_usable_chan(iface, iface->conf->channel +
799 iface->conf->secondary_channel * 4, 0);
804 hostapd_check_chans(struct hostapd_iface *iface)
806 if (iface->conf->channel) {
807 if (hostapd_is_usable_chans(iface))
818 switch (acs_init(iface)) {
829 static void hostapd_notify_bad_chans(struct hostapd_iface *iface)
831 if (!iface->current_mode) {
832 hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211,
837 hostapd_logger(iface->bss[0], NULL,
842 iface->conf->channel,
843 iface->current_mode->mode,
844 hostapd_hw_mode_txt(iface->current_mode->mode));
845 hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211,
851 int hostapd_acs_completed(struct hostapd_iface *iface, int err)
858 switch (hostapd_check_chans(iface)) {
860 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO,
862 hostapd_hw_get_freq(iface->bss[0],
863 iface->conf->channel),
864 iface->conf->channel);
868 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED);
869 hostapd_notify_bad_chans(iface);
874 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED);
875 hostapd_notify_bad_chans(iface);
879 ret = hostapd_check_ht_capab(iface);
889 return hostapd_setup_interface_complete(iface, ret);
895 * @iface: Pointer to interface data.
901 int hostapd_select_hw_mode(struct hostapd_iface *iface)
905 if (iface->num_hw_features < 1)
908 if ((iface->conf->hw_mode == HOSTAPD_MODE_IEEE80211G ||
909 iface->conf->ieee80211n || iface->conf->ieee80211ac) &&
910 iface->conf->channel == 14) {
912 iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
913 iface->conf->ieee80211n = 0;
914 iface->conf->ieee80211ac = 0;
917 iface->current_mode = NULL;
918 for (i = 0; i < iface->num_hw_features; i++) {
919 struct hostapd_hw_modes *mode = &iface->hw_features[i];
920 if (mode->mode == iface->conf->hw_mode) {
921 iface->current_mode = mode;
926 if (iface->current_mode == NULL) {
927 if (!(iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) ||
928 !(iface->drv_flags & WPA_DRIVER_FLAGS_SUPPORT_HW_MODE_ANY))
932 hostapd_logger(iface->bss[0], NULL,
936 (int) iface->conf->hw_mode);
941 switch (hostapd_check_chans(iface)) {
948 hostapd_notify_bad_chans(iface);
973 return hw_get_freq(hapd->iface->current_mode, chan);
979 return hw_get_chan(hapd->iface->current_mode, freq);