DFS: Introduce dfs_set_valid_channel() utility routine
This is a preliminary change to introduce radar/CAC background detection support. Tested-by: Owen Peng <owen.peng@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
This commit is contained in:
parent
d001b301ba
commit
f39765369a
1 changed files with 24 additions and 14 deletions
38
src/ap/dfs.c
38
src/ap/dfs.c
|
@ -568,6 +568,29 @@ dfs_get_valid_channel(struct hostapd_iface *iface,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int dfs_set_valid_channel(struct hostapd_iface *iface, int skip_radar)
|
||||||
|
{
|
||||||
|
struct hostapd_channel_data *channel;
|
||||||
|
u8 cf1 = 0, cf2 = 0;
|
||||||
|
int sec = 0;
|
||||||
|
|
||||||
|
channel = dfs_get_valid_channel(iface, &sec, &cf1, &cf2,
|
||||||
|
skip_radar);
|
||||||
|
if (!channel) {
|
||||||
|
wpa_printf(MSG_ERROR, "could not get valid channel");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
iface->freq = channel->freq;
|
||||||
|
iface->conf->channel = channel->chan;
|
||||||
|
iface->conf->secondary_channel = sec;
|
||||||
|
hostapd_set_oper_centr_freq_seg0_idx(iface->conf, cf1);
|
||||||
|
hostapd_set_oper_centr_freq_seg1_idx(iface->conf, cf2);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int set_dfs_state_freq(struct hostapd_iface *iface, int freq, u32 state)
|
static int set_dfs_state_freq(struct hostapd_iface *iface, int freq, u32 state)
|
||||||
{
|
{
|
||||||
struct hostapd_hw_modes *mode;
|
struct hostapd_hw_modes *mode;
|
||||||
|
@ -755,7 +778,6 @@ static unsigned int dfs_get_cac_time(struct hostapd_iface *iface,
|
||||||
*/
|
*/
|
||||||
int hostapd_handle_dfs(struct hostapd_iface *iface)
|
int hostapd_handle_dfs(struct hostapd_iface *iface)
|
||||||
{
|
{
|
||||||
struct hostapd_channel_data *channel;
|
|
||||||
int res, n_chans, n_chans1, start_chan_idx, start_chan_idx1;
|
int res, n_chans, n_chans1, start_chan_idx, start_chan_idx1;
|
||||||
int skip_radar = 0;
|
int skip_radar = 0;
|
||||||
|
|
||||||
|
@ -810,22 +832,10 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
|
||||||
wpa_printf(MSG_DEBUG, "DFS %d chans unavailable - choose other channel: %s",
|
wpa_printf(MSG_DEBUG, "DFS %d chans unavailable - choose other channel: %s",
|
||||||
res, res ? "yes": "no");
|
res, res ? "yes": "no");
|
||||||
if (res) {
|
if (res) {
|
||||||
int sec = 0;
|
if (dfs_set_valid_channel(iface, skip_radar) < 0) {
|
||||||
u8 cf1 = 0, cf2 = 0;
|
|
||||||
|
|
||||||
channel = dfs_get_valid_channel(iface, &sec, &cf1, &cf2,
|
|
||||||
skip_radar);
|
|
||||||
if (!channel) {
|
|
||||||
wpa_printf(MSG_ERROR, "could not get valid channel");
|
|
||||||
hostapd_set_state(iface, HAPD_IFACE_DFS);
|
hostapd_set_state(iface, HAPD_IFACE_DFS);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
iface->freq = channel->freq;
|
|
||||||
iface->conf->channel = channel->chan;
|
|
||||||
iface->conf->secondary_channel = sec;
|
|
||||||
hostapd_set_oper_centr_freq_seg0_idx(iface->conf, cf1);
|
|
||||||
hostapd_set_oper_centr_freq_seg1_idx(iface->conf, cf2);
|
|
||||||
}
|
}
|
||||||
} while (res);
|
} while (res);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue