/** * select_hw_mode2 - Select the hardware mode (part 2) * @iface: Pointer to interface data. * @status: Status of auto chanel selection. * * Setup the rates and passive scanning based on the configuration. */ static void select_hw_mode2(struct hostapd_iface *iface, int status) { #if 0 int ret = status; if (ret) goto fail; if (iface->current_mode == NULL) { hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "Hardware does not support configured channel"); ret = -1; goto fail; } if (hostapd_prepare_rates(iface->bss[0], iface->current_mode)) { printf("Failed to prepare rates table.\n"); hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "Failed to prepare rates table."); ret = -1; goto fail; } ret = hostapd_passive_scan(iface->bss[0], 0, iface->conf->passive_scan_mode, iface->conf->passive_scan_interval, iface->conf->passive_scan_listen, NULL, NULL); if (ret) { printf("Could not set passive scanning: %s\n", strerror(ret)); ret = 0; } fail: select_hw_mode_finalize(iface, ret); #endif printf("%s, null function, iface->bss[0] may be not init.\n", __func__) ; }
/** * hostapd_select_hw_mode - Select the hardware mode * @iface: Pointer to interface data. * Returns: 0 on success, -1 on failure * * Sets up the hardware mode, channel, rates, and passive scanning * based on the configuration. */ int hostapd_select_hw_mode(struct hostapd_iface *iface) { int i, j, ok, ret; if (iface->num_hw_features < 1) return -1; iface->current_mode = NULL; for (i = 0; i < iface->num_hw_features; i++) { struct hostapd_hw_modes *mode = &iface->hw_features[i]; if (mode->mode == (int) iface->conf->hw_mode) { iface->current_mode = mode; break; } } if (iface->current_mode == NULL) { wpa_printf(MSG_ERROR, "Hardware does not support configured " "mode"); hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "Hardware does not support configured mode " "(%d)", (int) iface->conf->hw_mode); return -1; } ok = 0; for (j = 0; j < iface->current_mode->num_channels; j++) { struct hostapd_channel_data *chan = &iface->current_mode->channels[j]; if (!(chan->flag & HOSTAPD_CHAN_DISABLED) && (chan->chan == iface->conf->channel)) { ok = 1; break; } } if (ok == 0 && iface->conf->channel != 0) { hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "Configured channel (%d) not found from the " "channel list of current mode (%d) %s", iface->conf->channel, iface->current_mode->mode, hostapd_hw_mode_txt(iface->current_mode->mode)); iface->current_mode = NULL; } if (iface->current_mode == NULL) { hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "Hardware does not support configured channel"); return -1; } if (hostapd_prepare_rates(iface->bss[0], iface->current_mode)) { wpa_printf(MSG_ERROR, "Failed to prepare rates table."); hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "Failed to prepare rates table."); return -1; } ret = hostapd_passive_scan(iface->bss[0], 0, iface->conf->passive_scan_mode, iface->conf->passive_scan_interval, iface->conf->passive_scan_listen, NULL, NULL); if (ret) { if (ret == -1) { wpa_printf(MSG_DEBUG, "Passive scanning not " "supported"); } else { wpa_printf(MSG_ERROR, "Could not set passive " "scanning: %s", strerror(ret)); } ret = 0; } return ret; }