aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/ap.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-04-27 18:27:15 (GMT)
committerJouni Malinen <j@w1.fi>2013-04-27 19:11:51 (GMT)
commite864c0aefedd1765b45ef7f211828318bbde36cc (patch)
treecd96e8b2b530c4c2f8cc0a83f6c7099fbb4878e9 /wpa_supplicant/ap.c
parent02db75b6c2563ba8b8870ff39f6ad75d32d7f0d7 (diff)
downloadhostap-e864c0aefedd1765b45ef7f211828318bbde36cc.zip
hostap-e864c0aefedd1765b45ef7f211828318bbde36cc.tar.gz
hostap-e864c0aefedd1765b45ef7f211828318bbde36cc.tar.bz2
Use a common frequency to channel conversion function
Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/ap.c')
-rw-r--r--wpa_supplicant/ap.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index 4033492..d9e1f82 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -55,21 +55,14 @@ static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
/* default channel 11 */
conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
conf->channel = 11;
- } else if (ssid->frequency >= 2412 && ssid->frequency <= 2472) {
- conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
- conf->channel = (ssid->frequency - 2407) / 5;
- } else if ((ssid->frequency >= 5180 && ssid->frequency <= 5240) ||
- (ssid->frequency >= 5745 && ssid->frequency <= 5825)) {
- conf->hw_mode = HOSTAPD_MODE_IEEE80211A;
- conf->channel = (ssid->frequency - 5000) / 5;
- } else if (ssid->frequency >= 56160 + 2160 * 1 &&
- ssid->frequency <= 56160 + 2160 * 4) {
- conf->hw_mode = HOSTAPD_MODE_IEEE80211AD;
- conf->channel = (ssid->frequency - 56160) / 2160;
} else {
- wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
- ssid->frequency);
- return -1;
+ 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;