mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
Use a common frequency to channel conversion function
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
02db75b6c2
commit
e864c0aefe
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* IEEE 802.11 Common routines
|
* IEEE 802.11 Common routines
|
||||||
* Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi>
|
* Copyright (c) 2002-2013, Jouni Malinen <j@w1.fi>
|
||||||
*
|
*
|
||||||
* This software may be distributed under the terms of the BSD license.
|
* This software may be distributed under the terms of the BSD license.
|
||||||
* See README for more details.
|
* See README for more details.
|
||||||
@ -9,6 +9,7 @@
|
|||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "defs.h"
|
||||||
#include "ieee802_11_defs.h"
|
#include "ieee802_11_defs.h"
|
||||||
#include "ieee802_11_common.h"
|
#include "ieee802_11_common.h"
|
||||||
|
|
||||||
@ -486,3 +487,28 @@ int hostapd_config_wmm_ac(struct hostapd_wmm_ac_params wmm_ac_params[],
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum hostapd_hw_mode ieee80211_freq_to_chan(int freq, u8 *channel)
|
||||||
|
{
|
||||||
|
enum hostapd_hw_mode mode = NUM_HOSTAPD_MODES;
|
||||||
|
|
||||||
|
if (freq >= 2412 && freq <= 2472) {
|
||||||
|
mode = HOSTAPD_MODE_IEEE80211G;
|
||||||
|
*channel = (freq - 2407) / 5;
|
||||||
|
} else if (freq == 2484) {
|
||||||
|
mode = HOSTAPD_MODE_IEEE80211B;
|
||||||
|
*channel = 14;
|
||||||
|
} else if (freq >= 4900 && freq < 5000) {
|
||||||
|
mode = HOSTAPD_MODE_IEEE80211A;
|
||||||
|
*channel = (freq - 4000) / 5;
|
||||||
|
} else if (freq >= 5000 && freq < 5900) {
|
||||||
|
mode = HOSTAPD_MODE_IEEE80211A;
|
||||||
|
*channel = (freq - 5000) / 5;
|
||||||
|
} else if (freq >= 56160 + 2160 * 1 && freq <= 56160 + 2160 * 4) {
|
||||||
|
mode = HOSTAPD_MODE_IEEE80211AD;
|
||||||
|
*channel = (freq - 56160) / 2160;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
@ -99,5 +99,6 @@ struct hostapd_wmm_ac_params {
|
|||||||
|
|
||||||
int hostapd_config_wmm_ac(struct hostapd_wmm_ac_params wmm_ac_params[],
|
int hostapd_config_wmm_ac(struct hostapd_wmm_ac_params wmm_ac_params[],
|
||||||
const char *name, const char *val);
|
const char *name, const char *val);
|
||||||
|
enum hostapd_hw_mode ieee80211_freq_to_chan(int freq, u8 *channel);
|
||||||
|
|
||||||
#endif /* IEEE802_11_COMMON_H */
|
#endif /* IEEE802_11_COMMON_H */
|
||||||
|
@ -5103,35 +5103,11 @@ static void phy_info_freq(struct hostapd_hw_modes *mode,
|
|||||||
struct hostapd_channel_data *chan,
|
struct hostapd_channel_data *chan,
|
||||||
struct nlattr *tb_freq[])
|
struct nlattr *tb_freq[])
|
||||||
{
|
{
|
||||||
enum hostapd_hw_mode m;
|
u8 channel;
|
||||||
|
|
||||||
chan->freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
|
chan->freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
|
||||||
chan->flag = 0;
|
chan->flag = 0;
|
||||||
|
if (ieee80211_freq_to_chan(chan->freq, &channel) != NUM_HOSTAPD_MODES)
|
||||||
if (chan->freq < 4000)
|
chan->chan = channel;
|
||||||
m = HOSTAPD_MODE_IEEE80211B;
|
|
||||||
else if (chan->freq > 50000)
|
|
||||||
m = HOSTAPD_MODE_IEEE80211AD;
|
|
||||||
else
|
|
||||||
m = HOSTAPD_MODE_IEEE80211A;
|
|
||||||
|
|
||||||
switch (m) {
|
|
||||||
case HOSTAPD_MODE_IEEE80211AD:
|
|
||||||
chan->chan = (chan->freq - 56160) / 2160;
|
|
||||||
break;
|
|
||||||
case HOSTAPD_MODE_IEEE80211A:
|
|
||||||
chan->chan = chan->freq / 5 - 1000;
|
|
||||||
break;
|
|
||||||
case HOSTAPD_MODE_IEEE80211B:
|
|
||||||
case HOSTAPD_MODE_IEEE80211G:
|
|
||||||
if (chan->freq == 2484)
|
|
||||||
chan->chan = 14;
|
|
||||||
else
|
|
||||||
chan->chan = (chan->freq - 2407) / 5;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
|
if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
|
||||||
chan->flag |= HOSTAPD_CHAN_DISABLED;
|
chan->flag |= HOSTAPD_CHAN_DISABLED;
|
||||||
|
@ -55,21 +55,14 @@ static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
|
|||||||
/* default channel 11 */
|
/* default channel 11 */
|
||||||
conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
|
conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
|
||||||
conf->channel = 11;
|
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 {
|
} else {
|
||||||
wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
|
conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency,
|
||||||
ssid->frequency);
|
&conf->channel);
|
||||||
return -1;
|
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;
|
/* TODO: enable HT40 if driver supports it;
|
||||||
|
@ -942,39 +942,6 @@ static void sme_send_2040_bss_coex(struct wpa_supplicant *wpa_s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* enum wpas_band - Frequency band
|
|
||||||
* @WPAS_BAND_2GHZ: 2.4 GHz ISM band
|
|
||||||
* @WPAS_BAND_5GHZ: around 5 GHz band (4.9 - 5.7 GHz)
|
|
||||||
*/
|
|
||||||
enum wpas_band {
|
|
||||||
WPAS_BAND_2GHZ,
|
|
||||||
WPAS_BAND_5GHZ,
|
|
||||||
WPAS_BAND_INVALID
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* freq_to_channel - Convert frequency into channel info
|
|
||||||
* @channel: Buffer for returning channel number
|
|
||||||
* Returns: Band (2 or 5 GHz)
|
|
||||||
*/
|
|
||||||
static enum wpas_band freq_to_channel(int freq, u8 *channel)
|
|
||||||
{
|
|
||||||
enum wpas_band band = (freq <= 2484) ? WPAS_BAND_2GHZ : WPAS_BAND_5GHZ;
|
|
||||||
u8 chan = 0;
|
|
||||||
|
|
||||||
if (freq >= 2412 && freq <= 2472)
|
|
||||||
chan = (freq - 2407) / 5;
|
|
||||||
else if (freq == 2484)
|
|
||||||
chan = 14;
|
|
||||||
else if (freq >= 5180 && freq <= 5805)
|
|
||||||
chan = (freq - 5000) / 5;
|
|
||||||
|
|
||||||
*channel = chan;
|
|
||||||
return band;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int sme_proc_obss_scan(struct wpa_supplicant *wpa_s)
|
int sme_proc_obss_scan(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
struct wpa_bss *bss;
|
struct wpa_bss *bss;
|
||||||
@ -1011,7 +978,10 @@ int sme_proc_obss_scan(struct wpa_supplicant *wpa_s)
|
|||||||
|
|
||||||
dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
|
dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
|
||||||
/* Skip other band bss */
|
/* Skip other band bss */
|
||||||
if (freq_to_channel(bss->freq, &channel) != WPAS_BAND_2GHZ)
|
enum hostapd_hw_mode mode;
|
||||||
|
mode = ieee80211_freq_to_chan(bss->freq, &channel);
|
||||||
|
if (mode != HOSTAPD_MODE_IEEE80211G &&
|
||||||
|
mode != HOSTAPD_MODE_IEEE80211B)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ie = wpa_bss_get_ie(bss, WLAN_EID_HT_CAP);
|
ie = wpa_bss_get_ie(bss, WLAN_EID_HT_CAP);
|
||||||
|
Loading…
Reference in New Issue
Block a user