Make hostapd_set_freq_params() common
Now this function can also be used from wpa_supplicant. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
This commit is contained in:
parent
98479dc95e
commit
ada157f3b0
6 changed files with 91 additions and 92 deletions
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "utils/common.h"
|
#include "utils/common.h"
|
||||||
#include "common/ieee802_11_defs.h"
|
#include "common/ieee802_11_defs.h"
|
||||||
|
#include "common/hw_features_common.h"
|
||||||
#include "wps/wps.h"
|
#include "wps/wps.h"
|
||||||
#include "p2p/p2p.h"
|
#include "p2p/p2p.h"
|
||||||
#include "hostapd.h"
|
#include "hostapd.h"
|
||||||
|
@ -477,92 +478,6 @@ int hostapd_flush(struct hostapd_data *hapd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int hostapd_set_freq_params(struct hostapd_freq_params *data,
|
|
||||||
enum hostapd_hw_mode mode,
|
|
||||||
int freq, int channel, int ht_enabled,
|
|
||||||
int vht_enabled, int sec_channel_offset,
|
|
||||||
int vht_oper_chwidth, int center_segment0,
|
|
||||||
int center_segment1, u32 vht_caps)
|
|
||||||
{
|
|
||||||
int tmp;
|
|
||||||
|
|
||||||
os_memset(data, 0, sizeof(*data));
|
|
||||||
data->mode = mode;
|
|
||||||
data->freq = freq;
|
|
||||||
data->channel = channel;
|
|
||||||
data->ht_enabled = ht_enabled;
|
|
||||||
data->vht_enabled = vht_enabled;
|
|
||||||
data->sec_channel_offset = sec_channel_offset;
|
|
||||||
data->center_freq1 = freq + sec_channel_offset * 10;
|
|
||||||
data->center_freq2 = 0;
|
|
||||||
data->bandwidth = sec_channel_offset ? 40 : 20;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This validation code is probably misplaced, maybe it should be
|
|
||||||
* in src/ap/hw_features.c and check the hardware support as well.
|
|
||||||
*/
|
|
||||||
if (data->vht_enabled) switch (vht_oper_chwidth) {
|
|
||||||
case VHT_CHANWIDTH_USE_HT:
|
|
||||||
if (center_segment1)
|
|
||||||
return -1;
|
|
||||||
if (center_segment0 != 0 &&
|
|
||||||
5000 + center_segment0 * 5 != data->center_freq1 &&
|
|
||||||
2407 + center_segment0 * 5 != data->center_freq1)
|
|
||||||
return -1;
|
|
||||||
break;
|
|
||||||
case VHT_CHANWIDTH_80P80MHZ:
|
|
||||||
if (!(vht_caps & VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)) {
|
|
||||||
wpa_printf(MSG_ERROR,
|
|
||||||
"80+80 channel width is not supported!");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (center_segment1 == center_segment0 + 4 ||
|
|
||||||
center_segment1 == center_segment0 - 4)
|
|
||||||
return -1;
|
|
||||||
data->center_freq2 = 5000 + center_segment1 * 5;
|
|
||||||
/* fall through */
|
|
||||||
case VHT_CHANWIDTH_80MHZ:
|
|
||||||
data->bandwidth = 80;
|
|
||||||
if (vht_oper_chwidth == 1 && center_segment1)
|
|
||||||
return -1;
|
|
||||||
if (vht_oper_chwidth == 3 && !center_segment1)
|
|
||||||
return -1;
|
|
||||||
if (!sec_channel_offset)
|
|
||||||
return -1;
|
|
||||||
/* primary 40 part must match the HT configuration */
|
|
||||||
tmp = (30 + freq - 5000 - center_segment0 * 5)/20;
|
|
||||||
tmp /= 2;
|
|
||||||
if (data->center_freq1 != 5000 +
|
|
||||||
center_segment0 * 5 - 20 + 40 * tmp)
|
|
||||||
return -1;
|
|
||||||
data->center_freq1 = 5000 + center_segment0 * 5;
|
|
||||||
break;
|
|
||||||
case VHT_CHANWIDTH_160MHZ:
|
|
||||||
data->bandwidth = 160;
|
|
||||||
if (!(vht_caps & (VHT_CAP_SUPP_CHAN_WIDTH_160MHZ |
|
|
||||||
VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ))) {
|
|
||||||
wpa_printf(MSG_ERROR,
|
|
||||||
"160MHZ channel width is not supported!");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (center_segment1)
|
|
||||||
return -1;
|
|
||||||
if (!sec_channel_offset)
|
|
||||||
return -1;
|
|
||||||
/* primary 40 part must match the HT configuration */
|
|
||||||
tmp = (70 + freq - 5000 - center_segment0 * 5)/20;
|
|
||||||
tmp /= 2;
|
|
||||||
if (data->center_freq1 != 5000 +
|
|
||||||
center_segment0 * 5 - 60 + 40 * tmp)
|
|
||||||
return -1;
|
|
||||||
data->center_freq1 = 5000 + center_segment0 * 5;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int hostapd_set_freq(struct hostapd_data *hapd, enum hostapd_hw_mode mode,
|
int hostapd_set_freq(struct hostapd_data *hapd, enum hostapd_hw_mode mode,
|
||||||
int freq, int channel, int ht_enabled, int vht_enabled,
|
int freq, int channel, int ht_enabled, int vht_enabled,
|
||||||
int sec_channel_offset, int vht_oper_chwidth,
|
int sec_channel_offset, int vht_oper_chwidth,
|
||||||
|
|
|
@ -107,12 +107,6 @@ int hostapd_start_dfs_cac(struct hostapd_iface *iface,
|
||||||
int channel, int ht_enabled, int vht_enabled,
|
int channel, int ht_enabled, int vht_enabled,
|
||||||
int sec_channel_offset, int vht_oper_chwidth,
|
int sec_channel_offset, int vht_oper_chwidth,
|
||||||
int center_segment0, int center_segment1);
|
int center_segment0, int center_segment1);
|
||||||
int hostapd_set_freq_params(struct hostapd_freq_params *data,
|
|
||||||
enum hostapd_hw_mode mode,
|
|
||||||
int freq, int channel, int ht_enabled,
|
|
||||||
int vht_enabled, int sec_channel_offset,
|
|
||||||
int vht_oper_chwidth, int center_segment0,
|
|
||||||
int center_segment1, u32 vht_caps);
|
|
||||||
int hostapd_drv_do_acs(struct hostapd_data *hapd);
|
int hostapd_drv_do_acs(struct hostapd_data *hapd);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "utils/common.h"
|
#include "utils/common.h"
|
||||||
#include "common/ieee802_11_defs.h"
|
#include "common/ieee802_11_defs.h"
|
||||||
#include "common/ieee802_11_common.h"
|
#include "common/ieee802_11_common.h"
|
||||||
|
#include "common/hw_features_common.h"
|
||||||
#include "wps/wps_defs.h"
|
#include "wps/wps_defs.h"
|
||||||
#include "p2p/p2p.h"
|
#include "p2p/p2p.h"
|
||||||
#include "hostapd.h"
|
#include "hostapd.h"
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "utils/common.h"
|
#include "utils/common.h"
|
||||||
#include "common/ieee802_11_defs.h"
|
#include "common/ieee802_11_defs.h"
|
||||||
|
#include "common/hw_features_common.h"
|
||||||
#include "common/wpa_ctrl.h"
|
#include "common/wpa_ctrl.h"
|
||||||
#include "hostapd.h"
|
#include "hostapd.h"
|
||||||
#include "ap_drv_ops.h"
|
#include "ap_drv_ops.h"
|
||||||
|
|
|
@ -354,3 +354,85 @@ int check_40mhz_2g4(struct hostapd_hw_modes *mode,
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int hostapd_set_freq_params(struct hostapd_freq_params *data,
|
||||||
|
enum hostapd_hw_mode mode,
|
||||||
|
int freq, int channel, int ht_enabled,
|
||||||
|
int vht_enabled, int sec_channel_offset,
|
||||||
|
int vht_oper_chwidth, int center_segment0,
|
||||||
|
int center_segment1, u32 vht_caps)
|
||||||
|
{
|
||||||
|
int tmp;
|
||||||
|
|
||||||
|
os_memset(data, 0, sizeof(*data));
|
||||||
|
data->mode = mode;
|
||||||
|
data->freq = freq;
|
||||||
|
data->channel = channel;
|
||||||
|
data->ht_enabled = ht_enabled;
|
||||||
|
data->vht_enabled = vht_enabled;
|
||||||
|
data->sec_channel_offset = sec_channel_offset;
|
||||||
|
data->center_freq1 = freq + sec_channel_offset * 10;
|
||||||
|
data->center_freq2 = 0;
|
||||||
|
data->bandwidth = sec_channel_offset ? 40 : 20;
|
||||||
|
|
||||||
|
if (data->vht_enabled) switch (vht_oper_chwidth) {
|
||||||
|
case VHT_CHANWIDTH_USE_HT:
|
||||||
|
if (center_segment1)
|
||||||
|
return -1;
|
||||||
|
if (center_segment0 != 0 &&
|
||||||
|
5000 + center_segment0 * 5 != data->center_freq1 &&
|
||||||
|
2407 + center_segment0 * 5 != data->center_freq1)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
case VHT_CHANWIDTH_80P80MHZ:
|
||||||
|
if (!(vht_caps & VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)) {
|
||||||
|
wpa_printf(MSG_ERROR,
|
||||||
|
"80+80 channel width is not supported!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (center_segment1 == center_segment0 + 4 ||
|
||||||
|
center_segment1 == center_segment0 - 4)
|
||||||
|
return -1;
|
||||||
|
data->center_freq2 = 5000 + center_segment1 * 5;
|
||||||
|
/* fall through */
|
||||||
|
case VHT_CHANWIDTH_80MHZ:
|
||||||
|
data->bandwidth = 80;
|
||||||
|
if (vht_oper_chwidth == 1 && center_segment1)
|
||||||
|
return -1;
|
||||||
|
if (vht_oper_chwidth == 3 && !center_segment1)
|
||||||
|
return -1;
|
||||||
|
if (!sec_channel_offset)
|
||||||
|
return -1;
|
||||||
|
/* primary 40 part must match the HT configuration */
|
||||||
|
tmp = (30 + freq - 5000 - center_segment0 * 5) / 20;
|
||||||
|
tmp /= 2;
|
||||||
|
if (data->center_freq1 != 5000 +
|
||||||
|
center_segment0 * 5 - 20 + 40 * tmp)
|
||||||
|
return -1;
|
||||||
|
data->center_freq1 = 5000 + center_segment0 * 5;
|
||||||
|
break;
|
||||||
|
case VHT_CHANWIDTH_160MHZ:
|
||||||
|
data->bandwidth = 160;
|
||||||
|
if (!(vht_caps & (VHT_CAP_SUPP_CHAN_WIDTH_160MHZ |
|
||||||
|
VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ))) {
|
||||||
|
wpa_printf(MSG_ERROR,
|
||||||
|
"160MHZ channel width is not supported!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (center_segment1)
|
||||||
|
return -1;
|
||||||
|
if (!sec_channel_offset)
|
||||||
|
return -1;
|
||||||
|
/* primary 40 part must match the HT configuration */
|
||||||
|
tmp = (70 + freq - 5000 - center_segment0 * 5) / 20;
|
||||||
|
tmp /= 2;
|
||||||
|
if (data->center_freq1 != 5000 +
|
||||||
|
center_segment0 * 5 - 60 + 40 * tmp)
|
||||||
|
return -1;
|
||||||
|
data->center_freq1 = 5000 + center_segment0 * 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -30,5 +30,11 @@ int check_20mhz_bss(struct wpa_scan_res *bss, int pri_freq, int start, int end);
|
||||||
int check_40mhz_2g4(struct hostapd_hw_modes *mode,
|
int check_40mhz_2g4(struct hostapd_hw_modes *mode,
|
||||||
struct wpa_scan_results *scan_res, int pri_chan,
|
struct wpa_scan_results *scan_res, int pri_chan,
|
||||||
int sec_chan);
|
int sec_chan);
|
||||||
|
int hostapd_set_freq_params(struct hostapd_freq_params *data,
|
||||||
|
enum hostapd_hw_mode mode,
|
||||||
|
int freq, int channel, int ht_enabled,
|
||||||
|
int vht_enabled, int sec_channel_offset,
|
||||||
|
int vht_oper_chwidth, int center_segment0,
|
||||||
|
int center_segment1, u32 vht_caps);
|
||||||
|
|
||||||
#endif /* HW_FEATURES_COMMON_H */
|
#endif /* HW_FEATURES_COMMON_H */
|
||||||
|
|
Loading…
Reference in a new issue