P2P: Move channel validation into a separate function

Signed-hostap: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
This commit is contained in:
Rajkumar Manoharan 2012-08-15 22:44:34 +03:00 committed by Jouni Malinen
parent 87c7ba8423
commit 931228aa10

View File

@ -2246,12 +2246,7 @@ struct p2p_oper_class_map {
enum { BW20, BW40PLUS, BW40MINUS } bw;
};
static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
struct p2p_channels *chan)
{
struct hostapd_hw_modes *mode;
int cla, op;
struct p2p_oper_class_map op_class[] = {
static struct p2p_oper_class_map op_class[] = {
{ HOSTAPD_MODE_IEEE80211G, 81, 1, 13, 1, BW20 },
{ HOSTAPD_MODE_IEEE80211G, 82, 14, 14, 1, BW20 },
#if 0 /* Do not enable HT40 on 2 GHz for now */
@ -2267,6 +2262,33 @@ static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
{ -1, 0, 0, 0, 0, BW20 }
};
static int wpas_p2p_verify_channel(struct wpa_supplicant *wpa_s,
struct hostapd_hw_modes *mode,
u8 channel, u8 bw)
{
int flag;
if (!has_channel(wpa_s->global, mode, channel, &flag))
return -1;
if (bw == BW40MINUS &&
(!(flag & HOSTAPD_CHAN_HT40MINUS) ||
!has_channel(wpa_s->global, mode, channel - 4, NULL)))
return 0;
if (bw == BW40PLUS &&
(!(flag & HOSTAPD_CHAN_HT40PLUS) ||
!has_channel(wpa_s->global, mode, channel + 4, NULL)))
return 0;
return 1;
}
static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
struct p2p_channels *chan)
{
struct hostapd_hw_modes *mode;
int cla, op;
if (wpa_s->hw.modes == NULL) {
wpa_printf(MSG_DEBUG, "P2P: Driver did not support fetching "
"of all supported channels; assume dualband "
@ -2285,16 +2307,7 @@ static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
if (mode == NULL)
continue;
for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) {
int flag;
if (!has_channel(wpa_s->global, mode, ch, &flag))
continue;
if (o->bw == BW40MINUS &&
(!(flag & HOSTAPD_CHAN_HT40MINUS) ||
!has_channel(wpa_s->global, mode, ch - 4, NULL)))
continue;
if (o->bw == BW40PLUS &&
(!(flag & HOSTAPD_CHAN_HT40PLUS) ||
!has_channel(wpa_s->global, mode, ch + 4, NULL)))
if (wpas_p2p_verify_channel(wpa_s, mode, ch, o->bw) < 1)
continue;
if (reg == NULL) {
wpa_printf(MSG_DEBUG, "P2P: Add operating "