Changed channel flags configuration to read the information from the driver

(e.g., via driver_nl80211 when using mac80211) instead of using hostapd as
the source of the regulatory information (i.e., information from CRDA is
now used with mac80211); this allows 5 GHz channels to be used with hostapd
(if allowed in the current regulatory domain).
This commit is contained in:
Jouni Malinen 2008-11-18 14:51:43 +02:00 committed by Jouni Malinen
parent 0cf03892a4
commit 10b83bd712
7 changed files with 46 additions and 58 deletions

View file

@ -8,6 +8,12 @@ ChangeLog for hostapd
session ticket overriding API that was included into the upstream session ticket overriding API that was included into the upstream
OpenSSL 0.9.9 tree on 2008-11-15 (no additional OpenSSL patch is OpenSSL 0.9.9 tree on 2008-11-15 (no additional OpenSSL patch is
needed with that version anymore) needed with that version anymore)
* changed channel flags configuration to read the information from
the driver (e.g., via driver_nl80211 when using mac80211) instead of
using hostapd as the source of the regulatory information (i.e.,
information from CRDA is now used with mac80211); this allows 5 GHz
channels to be used with hostapd (if allowed in the current
regulatory domain)
2008-11-01 - v0.6.5 2008-11-01 - v0.6.5
* added support for SHA-256 as X.509 certificate digest when using the * added support for SHA-256 as X.509 certificate digest when using the

View file

@ -111,9 +111,6 @@ struct wpa_driver_ops {
int total_flags, int flags_or, int flags_and); int total_flags, int flags_or, int flags_and);
int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates, int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
int mode); int mode);
int (*set_channel_flag)(void *priv, int mode, int chan, int flag,
unsigned char power_level,
unsigned char antenna_max);
int (*set_regulatory_domain)(void *priv, unsigned int rd); int (*set_regulatory_domain)(void *priv, unsigned int rd);
int (*set_country)(void *priv, const char *country); int (*set_country)(void *priv, const char *country);
int (*set_ieee80211d)(void *priv, int enabled); int (*set_ieee80211d)(void *priv, int enabled);
@ -497,17 +494,6 @@ hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
basic_rates, mode); basic_rates, mode);
} }
static inline int
hostapd_set_channel_flag(struct hostapd_data *hapd, int mode, int chan,
int flag, unsigned char power_level,
unsigned char antenna_max)
{
if (hapd->driver == NULL || hapd->driver->set_channel_flag == NULL)
return 0;
return hapd->driver->set_channel_flag(hapd->drv_priv, mode, chan, flag,
power_level, antenna_max);
}
static inline int static inline int
hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd) hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
{ {

View file

@ -1203,6 +1203,9 @@ static struct hostapd_hw_modes * hostap_get_hw_feature_data(void *priv,
for (i = 0; i < 14; i++) { for (i = 0; i < 14; i++) {
mode->channels[i].chan = i + 1; mode->channels[i].chan = i + 1;
mode->channels[i].freq = chan2freq[i]; mode->channels[i].freq = chan2freq[i];
/* TODO: Get allowed channel list from the driver */
if (i >= 11)
mode->channels[i].flag = HOSTAPD_CHAN_DISABLED;
} }
mode->rates[0].rate = 10; mode->rates[0].rate = 10;

View file

@ -881,14 +881,6 @@ static int i802_sta_set_flags(void *priv, const u8 *addr,
} }
static int i802_set_channel_flag(void *priv, int mode, int chan, int flag,
unsigned char power_level,
unsigned char antenna_max)
{
return -1;
}
static int i802_set_regulatory_domain(void *priv, unsigned int rd) static int i802_set_regulatory_domain(void *priv, unsigned int rd)
{ {
return -1; return -1;
@ -1381,9 +1373,7 @@ static int phy_info_handler(struct nl_msg *msg, void *arg)
continue; continue;
mode->channels[idx].freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]); mode->channels[idx].freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
mode->channels[idx].flag |= HOSTAPD_CHAN_W_SCAN | mode->channels[idx].flag = 0;
HOSTAPD_CHAN_W_ACTIVE_SCAN |
HOSTAPD_CHAN_W_IBSS;
if (!mode_is_set) { if (!mode_is_set) {
/* crude heuristic */ /* crude heuristic */
@ -1404,11 +1394,17 @@ static int phy_info_handler(struct nl_msg *msg, void *arg)
mode->channels[idx].chan = mode->channels[idx].freq/5 - 1000; mode->channels[idx].chan = mode->channels[idx].freq/5 - 1000;
if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
mode->channels[idx].flag &= ~HOSTAPD_CHAN_W_SCAN; mode->channels[idx].flag |=
HOSTAPD_CHAN_DISABLED;
if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN]) if (tb_freq[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN])
mode->channels[idx].flag &= ~HOSTAPD_CHAN_W_ACTIVE_SCAN; mode->channels[idx].flag |=
HOSTAPD_CHAN_PASSIVE_SCAN;
if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS]) if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IBSS])
mode->channels[idx].flag &= ~HOSTAPD_CHAN_W_IBSS; mode->channels[idx].flag |=
HOSTAPD_CHAN_NO_IBSS;
if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
mode->channels[idx].flag |=
HOSTAPD_CHAN_RADAR;
idx++; idx++;
} }
@ -2375,7 +2371,6 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.set_retry = i802_set_retry, .set_retry = i802_set_retry,
.get_retry = i802_get_retry, .get_retry = i802_get_retry,
.set_rate_sets = i802_set_rate_sets, .set_rate_sets = i802_set_rate_sets,
.set_channel_flag = i802_set_channel_flag,
.set_regulatory_domain = i802_set_regulatory_domain, .set_regulatory_domain = i802_set_regulatory_domain,
.set_beacon = i802_set_beacon, .set_beacon = i802_set_beacon,
.set_internal_bridge = i802_set_internal_bridge, .set_internal_bridge = i802_set_internal_bridge,

View file

@ -785,8 +785,7 @@ test_driver_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags)
} }
modes[0].channels[0].chan = 1; modes[0].channels[0].chan = 1;
modes[0].channels[0].freq = 2412; modes[0].channels[0].freq = 2412;
modes[0].channels[0].flag = HOSTAPD_CHAN_W_SCAN | modes[0].channels[0].flag = 0;
HOSTAPD_CHAN_W_ACTIVE_SCAN;
modes[0].rates[0].rate = 10; modes[0].rates[0].rate = 10;
modes[0].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED | modes[0].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
HOSTAPD_RATE_CCK | HOSTAPD_RATE_MANDATORY; HOSTAPD_RATE_CCK | HOSTAPD_RATE_MANDATORY;
@ -802,8 +801,7 @@ test_driver_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags)
} }
modes[1].channels[0].chan = 1; modes[1].channels[0].chan = 1;
modes[1].channels[0].freq = 2412; modes[1].channels[0].freq = 2412;
modes[1].channels[0].flag = HOSTAPD_CHAN_W_SCAN | modes[1].channels[0].flag = 0;
HOSTAPD_CHAN_W_ACTIVE_SCAN;
modes[1].rates[0].rate = 10; modes[1].rates[0].rate = 10;
modes[1].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED | modes[1].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
HOSTAPD_RATE_CCK | HOSTAPD_RATE_MANDATORY; HOSTAPD_RATE_CCK | HOSTAPD_RATE_MANDATORY;
@ -819,8 +817,7 @@ test_driver_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags)
} }
modes[2].channels[0].chan = 60; modes[2].channels[0].chan = 60;
modes[2].channels[0].freq = 5300; modes[2].channels[0].freq = 5300;
modes[2].channels[0].flag = HOSTAPD_CHAN_W_SCAN | modes[2].channels[0].flag = 0;
HOSTAPD_CHAN_W_ACTIVE_SCAN;
modes[2].rates[0].rate = 60; modes[2].rates[0].rate = 60;
modes[2].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED | modes[2].rates[0].flags = HOSTAPD_RATE_BASIC | HOSTAPD_RATE_SUPPORTED |
HOSTAPD_RATE_MANDATORY; HOSTAPD_RATE_MANDATORY;

View file

@ -68,26 +68,26 @@ int hostapd_get_hw_features(struct hostapd_iface *iface)
/* set flag for channels we can use in current regulatory /* set flag for channels we can use in current regulatory
* domain */ * domain */
for (j = 0; j < feature->num_channels; j++) { for (j = 0; j < feature->num_channels; j++) {
/* TODO: add regulatory domain lookup */ /*
unsigned char power_level = 0; * Disable all channels that are marked not to allow
unsigned char antenna_max = 0; * IBSS operation or active scanning. In addition,
* disable all channels that require radar detection,
if ((feature->mode == HOSTAPD_MODE_IEEE80211G || * since that (in addition to full DFS) is not yet
feature->mode == HOSTAPD_MODE_IEEE80211B) && * supported.
feature->channels[j].chan >= 1 && */
feature->channels[j].chan <= 11) { if (feature->channels[j].flag &
power_level = 20; (HOSTAPD_CHAN_NO_IBSS |
HOSTAPD_CHAN_PASSIVE_SCAN |
HOSTAPD_CHAN_RADAR))
feature->channels[j].flag |= feature->channels[j].flag |=
HOSTAPD_CHAN_W_SCAN; HOSTAPD_CHAN_DISABLED;
} else if (feature->channels[j].flag & HOSTAPD_CHAN_DISABLED)
feature->channels[j].flag &= continue;
~HOSTAPD_CHAN_W_SCAN; wpa_printf(MSG_MSGDUMP, "Allowed channel: mode=%d "
"chan=%d freq=%d MHz",
hostapd_set_channel_flag(hapd, feature->mode, feature->mode,
feature->channels[j].chan, feature->channels[j].chan,
feature->channels[j].flag, feature->channels[j].freq);
power_level,
antenna_max);
} }
} }
@ -296,7 +296,7 @@ static int select_hw_mode1(struct hostapd_iface *iface)
for (j = 0; j < iface->current_mode->num_channels; j++) { for (j = 0; j < iface->current_mode->num_channels; j++) {
struct hostapd_channel_data *chan = struct hostapd_channel_data *chan =
&iface->current_mode->channels[j]; &iface->current_mode->channels[j];
if ((chan->flag & HOSTAPD_CHAN_W_SCAN) && if (!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
(chan->chan == iface->conf->channel)) { (chan->chan == iface->conf->channel)) {
ok = 1; ok = 1;
break; break;

View file

@ -16,9 +16,10 @@
#ifndef HW_FEATURES_H #ifndef HW_FEATURES_H
#define HW_FEATURES_H #define HW_FEATURES_H
#define HOSTAPD_CHAN_W_SCAN 0x00000001 #define HOSTAPD_CHAN_DISABLED 0x00000001
#define HOSTAPD_CHAN_W_ACTIVE_SCAN 0x00000002 #define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002
#define HOSTAPD_CHAN_W_IBSS 0x00000004 #define HOSTAPD_CHAN_NO_IBSS 0x00000004
#define HOSTAPD_CHAN_RADAR 0x00000008
struct hostapd_channel_data { struct hostapd_channel_data {
short chan; /* channel number (IEEE 802.11) */ short chan; /* channel number (IEEE 802.11) */