hostapd: Add config option chanlist for DFS channels

Different channels allow different transmission power, at least in ETSI
countries. Also, ETSI requires a "channel plan" for DFS operation, and
channels should be randomly choosen from these channels.

Add a channel list configuration option for users to add channels
hostapd may pick from.

Signed-hostap: Simon Wunderlich <sw@simonwunderlich.de>
This commit is contained in:
Simon Wunderlich 2014-02-06 19:30:37 +01:00 committed by Jouni Malinen
parent 2ca47da4f7
commit 70ee1be248
5 changed files with 36 additions and 0 deletions

View file

@ -2486,6 +2486,13 @@ static int hostapd_config_fill(struct hostapd_config *conf,
conf->channel = 0; conf->channel = 0;
} else } else
conf->channel = atoi(pos); conf->channel = atoi(pos);
} else if (os_strcmp(buf, "chanlist") == 0) {
if (hostapd_parse_intlist(&conf->chanlist, pos)) {
wpa_printf(MSG_ERROR,
"Line %d: invalid channel list",
line);
errors++;
}
} else if (os_strcmp(buf, "beacon_int") == 0) { } else if (os_strcmp(buf, "beacon_int") == 0) {
int val = atoi(pos); int val = atoi(pos);
/* MIB defines range as 1..65535, but very small values /* MIB defines range as 1..65535, but very small values

View file

@ -154,6 +154,14 @@ channel=1
# Defaults: # Defaults:
#acs_num_scans=5 #acs_num_scans=5
# Channel list restriction. This option allows hostapd to select one of the
# provided channels when a channel should be automatically selected. This
# is currently only used for DFS when the current channels becomes unavailable
# due to radar interference, and is currently only useful when ieee80211h=1 is
# set.
# Default: not set (allow any enabled channel to be selected)
#chanlist=100 104 108 112 116
# Beacon interval in kus (1.024 ms) (default: 100; range 15..65535) # Beacon interval in kus (1.024 ms) (default: 100; range 15..65535)
beacon_int=100 beacon_int=100

View file

@ -562,6 +562,7 @@ void hostapd_config_free(struct hostapd_config *conf)
os_free(conf->bss); os_free(conf->bss);
os_free(conf->supported_rates); os_free(conf->supported_rates);
os_free(conf->basic_rates); os_free(conf->basic_rates);
os_free(conf->chanlist);
os_free(conf); os_free(conf);
} }

View file

@ -525,6 +525,7 @@ struct hostapd_config {
int fragm_threshold; int fragm_threshold;
u8 send_probe_response; u8 send_probe_response;
u8 channel; u8 channel;
int *chanlist;
enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */ enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
enum { enum {
LONG_PREAMBLE = 0, LONG_PREAMBLE = 0,

View file

@ -139,6 +139,22 @@ static int dfs_chan_range_available(struct hostapd_hw_modes *mode,
} }
static int is_in_chanlist(struct hostapd_iface *iface,
struct hostapd_channel_data *chan)
{
int *entry;
if (!iface->conf->chanlist)
return 1;
for (entry = iface->conf->chanlist; *entry != -1; entry++) {
if (*entry == chan->chan)
return 1;
}
return 0;
}
/* /*
* The function assumes HT40+ operation. * The function assumes HT40+ operation.
* Make sure to adjust the following variables after calling this: * Make sure to adjust the following variables after calling this:
@ -171,6 +187,9 @@ static int dfs_find_channel(struct hostapd_iface *iface,
if (!dfs_chan_range_available(mode, i, n_chans, skip_radar)) if (!dfs_chan_range_available(mode, i, n_chans, skip_radar))
continue; continue;
if (!is_in_chanlist(iface, chan))
continue;
if (ret_chan && idx == channel_idx) { if (ret_chan && idx == channel_idx) {
wpa_printf(MSG_DEBUG, "Selected ch. #%d", chan->chan); wpa_printf(MSG_DEBUG, "Selected ch. #%d", chan->chan);
*ret_chan = chan; *ret_chan = chan;