mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 08:48:31 -05:00
Move AP BSS configuration parameters into set_ap()
Remove the separate driver_ops functions set_cts_protect(), set_preamble(), set_short_slot_time(), and set_ht_params(). These belong into same set of operations as set_ap(), so there is no need to maintain separate functions that just make the driver wrapper more complex. Since these have only been used with driver_nl80211.c, the driver_ops can be removed immediately instead of maintaining backwards compatibility period with the old functions.
This commit is contained in:
parent
fd13a54180
commit
31357268e5
@ -474,30 +474,6 @@ int hostapd_set_country(struct hostapd_data *hapd, const char *country)
|
||||
}
|
||||
|
||||
|
||||
int hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
|
||||
{
|
||||
if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
|
||||
return 0;
|
||||
return hapd->driver->set_cts_protect(hapd->drv_priv, value);
|
||||
}
|
||||
|
||||
|
||||
int hostapd_set_preamble(struct hostapd_data *hapd, int value)
|
||||
{
|
||||
if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
|
||||
return 0;
|
||||
return hapd->driver->set_preamble(hapd->drv_priv, value);
|
||||
}
|
||||
|
||||
|
||||
int hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
|
||||
{
|
||||
if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
|
||||
return 0;
|
||||
return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
|
||||
}
|
||||
|
||||
|
||||
int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
|
||||
int cw_min, int cw_max, int burst_time)
|
||||
{
|
||||
@ -537,19 +513,6 @@ int hostapd_driver_commit(struct hostapd_data *hapd)
|
||||
}
|
||||
|
||||
|
||||
int hostapd_set_ht_params(struct hostapd_data *hapd,
|
||||
const u8 *ht_capab, size_t ht_capab_len,
|
||||
const u8 *ht_oper, size_t ht_oper_len)
|
||||
{
|
||||
if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
|
||||
ht_capab == NULL || ht_oper == NULL)
|
||||
return 0;
|
||||
return hapd->driver->set_ht_params(hapd->drv_priv,
|
||||
ht_capab, ht_capab_len,
|
||||
ht_oper, ht_oper_len);
|
||||
}
|
||||
|
||||
|
||||
int hostapd_drv_none(struct hostapd_data *hapd)
|
||||
{
|
||||
return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
|
||||
|
@ -69,9 +69,6 @@ int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
|
||||
int hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
|
||||
int *basic_rates, int mode);
|
||||
int hostapd_set_country(struct hostapd_data *hapd, const char *country);
|
||||
int hostapd_set_cts_protect(struct hostapd_data *hapd, int value);
|
||||
int hostapd_set_preamble(struct hostapd_data *hapd, int value);
|
||||
int hostapd_set_short_slot_time(struct hostapd_data *hapd, int value);
|
||||
int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
|
||||
int cw_min, int cw_max, int burst_time);
|
||||
int hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
|
||||
@ -80,9 +77,6 @@ struct hostapd_hw_modes *
|
||||
hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
|
||||
u16 *flags);
|
||||
int hostapd_driver_commit(struct hostapd_data *hapd);
|
||||
int hostapd_set_ht_params(struct hostapd_data *hapd,
|
||||
const u8 *ht_capab, size_t ht_capab_len,
|
||||
const u8 *ht_oper, size_t ht_oper_len);
|
||||
int hostapd_drv_none(struct hostapd_data *hapd);
|
||||
int hostapd_driver_scan(struct hostapd_data *hapd,
|
||||
struct wpa_driver_scan_params *params);
|
||||
|
@ -435,60 +435,6 @@ void handle_probe_req(struct hostapd_data *hapd,
|
||||
elems.ssid_len == 0 ? "broadcast" : "our");
|
||||
}
|
||||
|
||||
|
||||
static int hostapd_set_bss_params(struct hostapd_data *hapd,
|
||||
int use_protection)
|
||||
{
|
||||
int ret = 0;
|
||||
int preamble;
|
||||
#ifdef CONFIG_IEEE80211N
|
||||
u8 buf[60], *ht_capab, *ht_oper, *pos;
|
||||
|
||||
pos = buf;
|
||||
ht_capab = pos;
|
||||
pos = hostapd_eid_ht_capabilities(hapd, pos);
|
||||
ht_oper = pos;
|
||||
pos = hostapd_eid_ht_operation(hapd, pos);
|
||||
if (pos > ht_oper && ht_oper > ht_capab &&
|
||||
hostapd_set_ht_params(hapd, ht_capab + 2, ht_capab[1],
|
||||
ht_oper + 2, ht_oper[1])) {
|
||||
wpa_printf(MSG_ERROR, "Could not set HT capabilities "
|
||||
"for kernel driver");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_IEEE80211N */
|
||||
|
||||
if (hostapd_set_cts_protect(hapd, use_protection)) {
|
||||
wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
|
||||
"driver");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (hapd->iface->current_mode &&
|
||||
hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
|
||||
hostapd_set_short_slot_time(hapd,
|
||||
hapd->iface->num_sta_no_short_slot_time
|
||||
> 0 ? 0 : 1)) {
|
||||
wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
|
||||
"in kernel driver");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (hapd->iface->num_sta_no_short_preamble == 0 &&
|
||||
hapd->iconf->preamble == SHORT_PREAMBLE)
|
||||
preamble = SHORT_PREAMBLE;
|
||||
else
|
||||
preamble = LONG_PREAMBLE;
|
||||
if (hostapd_set_preamble(hapd, preamble)) {
|
||||
wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
|
||||
"driver");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* NEED_AP_MLME */
|
||||
|
||||
|
||||
@ -652,17 +598,28 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
|
||||
params.proberesp_ies = proberesp;
|
||||
params.assocresp_ies = assocresp;
|
||||
params.isolate = hapd->conf->isolate;
|
||||
#ifdef NEED_AP_MLME
|
||||
params.cts_protect = !!(ieee802_11_erp_info(hapd) &
|
||||
ERP_INFO_USE_PROTECTION);
|
||||
params.preamble = hapd->iface->num_sta_no_short_preamble == 0 &&
|
||||
hapd->iconf->preamble == SHORT_PREAMBLE;
|
||||
if (hapd->iface->current_mode &&
|
||||
hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
|
||||
params.short_slot_time =
|
||||
hapd->iface->num_sta_no_short_slot_time > 0 ? 0 : 1;
|
||||
else
|
||||
params.short_slot_time = -1;
|
||||
if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n)
|
||||
params.ht_opmode = -1;
|
||||
else
|
||||
params.ht_opmode = hapd->iface->ht_op_mode;
|
||||
#endif /* NEED_AP_MLME */
|
||||
if (hostapd_drv_set_ap(hapd, ¶ms))
|
||||
wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
|
||||
hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
|
||||
|
||||
os_free(tail);
|
||||
os_free(head);
|
||||
|
||||
#ifdef NEED_AP_MLME
|
||||
hostapd_set_bss_params(hapd, !!(ieee802_11_erp_info(hapd) &
|
||||
ERP_INFO_USE_PROTECTION));
|
||||
#endif /* NEED_AP_MLME */
|
||||
}
|
||||
|
||||
|
||||
|
@ -627,6 +627,29 @@ struct wpa_driver_ap_params {
|
||||
* frames between association stations.
|
||||
*/
|
||||
int isolate;
|
||||
|
||||
/**
|
||||
* cts_protect - Whether CTS protection is enabled
|
||||
*/
|
||||
int cts_protect;
|
||||
|
||||
/**
|
||||
* preamble - Whether short preamble is enabled
|
||||
*/
|
||||
int preamble;
|
||||
|
||||
/**
|
||||
* short_slot_time - Whether short slot time is enabled
|
||||
*
|
||||
* 0 = short slot time disable, 1 = short slot time enabled, -1 = do
|
||||
* not set (e.g., when 802.11g mode is not in use)
|
||||
*/
|
||||
int short_slot_time;
|
||||
|
||||
/**
|
||||
* ht_opmode - HT operation mode or -1 if HT not in use
|
||||
*/
|
||||
int ht_opmode;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1710,30 +1733,6 @@ struct wpa_driver_ops {
|
||||
int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
|
||||
int mode);
|
||||
|
||||
/**
|
||||
* set_cts_protect - Set CTS protection mode (AP only)
|
||||
* @priv: Private driver interface data
|
||||
* @value: Whether CTS protection is enabled
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int (*set_cts_protect)(void *priv, int value);
|
||||
|
||||
/**
|
||||
* set_preamble - Set preamble mode (AP only)
|
||||
* @priv: Private driver interface data
|
||||
* @value: Whether short preamble is enabled
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int (*set_preamble)(void *priv, int value);
|
||||
|
||||
/**
|
||||
* set_short_slot_time - Set short slot time (AP only)
|
||||
* @priv: Private driver interface data
|
||||
* @value: Whether short slot time is enabled
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int (*set_short_slot_time)(void *priv, int value);
|
||||
|
||||
/**
|
||||
* set_tx_queue_params - Set TX queue parameters
|
||||
* @priv: Private driver interface data
|
||||
@ -1851,19 +1850,6 @@ struct wpa_driver_ops {
|
||||
*/
|
||||
int (*set_radius_acl_expire)(void *priv, const u8 *mac);
|
||||
|
||||
/**
|
||||
* set_ht_params - Set HT parameters (AP only)
|
||||
* @priv: Private driver interface data
|
||||
* @ht_capab: HT Capabilities IE
|
||||
* @ht_capab_len: Length of ht_capab in octets
|
||||
* @ht_oper: HT Operation IE
|
||||
* @ht_oper_len: Length of ht_oper in octets
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int (*set_ht_params)(void *priv,
|
||||
const u8 *ht_capab, size_t ht_capab_len,
|
||||
const u8 *ht_oper, size_t ht_oper_len);
|
||||
|
||||
/**
|
||||
* set_ap_wps_ie - Add WPS IE(s) into Beacon/Probe Response frames (AP)
|
||||
* @priv: Private driver interface data
|
||||
|
@ -3277,9 +3277,6 @@ const struct wpa_driver_ops wpa_driver_ndis_ops = {
|
||||
NULL /* set_frag */,
|
||||
NULL /* sta_set_flags */,
|
||||
NULL /* set_rate_sets */,
|
||||
NULL /* set_cts_protect */,
|
||||
NULL /* set_preamble */,
|
||||
NULL /* set_short_slot_time */,
|
||||
NULL /* set_tx_queue_params */,
|
||||
NULL /* valid_bss_mask */,
|
||||
NULL /* if_add */,
|
||||
@ -3289,7 +3286,6 @@ const struct wpa_driver_ops wpa_driver_ndis_ops = {
|
||||
NULL /* send_ether */,
|
||||
NULL /* set_radius_acl_auth */,
|
||||
NULL /* set_radius_acl_expire */,
|
||||
NULL /* set_ht_params */,
|
||||
NULL /* set_ap_wps_ie */,
|
||||
NULL /* set_supp_port */,
|
||||
NULL /* set_wds_sta */,
|
||||
|
@ -4182,6 +4182,35 @@ static int nl80211_set_ap_isolate(struct i802_bss *bss, int enabled)
|
||||
}
|
||||
|
||||
|
||||
static int nl80211_set_bss(struct i802_bss *bss, int cts, int preamble,
|
||||
int slot, int ht_opmode)
|
||||
{
|
||||
struct wpa_driver_nl80211_data *drv = bss->drv;
|
||||
struct nl_msg *msg;
|
||||
|
||||
msg = nlmsg_alloc();
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
|
||||
NL80211_CMD_SET_BSS, 0);
|
||||
|
||||
if (cts >= 0)
|
||||
NLA_PUT_U8(msg, NL80211_ATTR_BSS_CTS_PROT, cts);
|
||||
if (preamble >= 0)
|
||||
NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_PREAMBLE, preamble);
|
||||
if (slot >= 0)
|
||||
NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_SLOT_TIME, slot);
|
||||
if (ht_opmode >= 0)
|
||||
NLA_PUT_U16(msg, NL80211_ATTR_BSS_HT_OPMODE, ht_opmode);
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(bss->ifname));
|
||||
|
||||
return send_and_recv_msgs(drv, msg, NULL, NULL);
|
||||
nla_put_failure:
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
||||
static int wpa_driver_nl80211_set_ap(void *priv,
|
||||
struct wpa_driver_ap_params *params)
|
||||
{
|
||||
@ -4321,6 +4350,9 @@ static int wpa_driver_nl80211_set_ap(void *priv,
|
||||
"not used");
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
nl80211_set_bss(bss, params->cts_protect, params->preamble,
|
||||
params->short_slot_time, params->ht_opmode);
|
||||
}
|
||||
return ret;
|
||||
nla_put_failure:
|
||||
@ -6104,54 +6136,6 @@ static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
|
||||
}
|
||||
|
||||
|
||||
static int i802_set_bss(void *priv, int cts, int preamble, int slot,
|
||||
int ht_opmode)
|
||||
{
|
||||
struct i802_bss *bss = priv;
|
||||
struct wpa_driver_nl80211_data *drv = bss->drv;
|
||||
struct nl_msg *msg;
|
||||
|
||||
msg = nlmsg_alloc();
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
|
||||
NL80211_CMD_SET_BSS, 0);
|
||||
|
||||
if (cts >= 0)
|
||||
NLA_PUT_U8(msg, NL80211_ATTR_BSS_CTS_PROT, cts);
|
||||
if (preamble >= 0)
|
||||
NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_PREAMBLE, preamble);
|
||||
if (slot >= 0)
|
||||
NLA_PUT_U8(msg, NL80211_ATTR_BSS_SHORT_SLOT_TIME, slot);
|
||||
if (ht_opmode >= 0)
|
||||
NLA_PUT_U16(msg, NL80211_ATTR_BSS_HT_OPMODE, ht_opmode);
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(bss->ifname));
|
||||
|
||||
return send_and_recv_msgs(drv, msg, NULL, NULL);
|
||||
nla_put_failure:
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
||||
static int i802_set_cts_protect(void *priv, int value)
|
||||
{
|
||||
return i802_set_bss(priv, value, -1, -1, -1);
|
||||
}
|
||||
|
||||
|
||||
static int i802_set_preamble(void *priv, int value)
|
||||
{
|
||||
return i802_set_bss(priv, -1, value, -1, -1);
|
||||
}
|
||||
|
||||
|
||||
static int i802_set_short_slot_time(void *priv, int value)
|
||||
{
|
||||
return i802_set_bss(priv, -1, -1, value, -1);
|
||||
}
|
||||
|
||||
|
||||
static int i802_set_sta_vlan(void *priv, const u8 *addr,
|
||||
const char *ifname, int vlan_id)
|
||||
{
|
||||
@ -6185,19 +6169,6 @@ static int i802_set_sta_vlan(void *priv, const u8 *addr,
|
||||
}
|
||||
|
||||
|
||||
static int i802_set_ht_params(void *priv, const u8 *ht_capab,
|
||||
size_t ht_capab_len, const u8 *ht_oper,
|
||||
size_t ht_oper_len)
|
||||
{
|
||||
if (ht_oper_len >= 6) {
|
||||
/* ht opmode uses 16bit in octet 5 & 6 */
|
||||
u16 ht_opmode = le_to_host16(((u16 *) ht_oper)[2]);
|
||||
return i802_set_bss(priv, -1, -1, -1, ht_opmode);
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int i802_get_inact_sec(void *priv, const u8 *addr)
|
||||
{
|
||||
struct hostap_sta_driver_data data;
|
||||
@ -7402,12 +7373,8 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
|
||||
.sta_clear_stats = i802_sta_clear_stats,
|
||||
.set_rts = i802_set_rts,
|
||||
.set_frag = i802_set_frag,
|
||||
.set_cts_protect = i802_set_cts_protect,
|
||||
.set_preamble = i802_set_preamble,
|
||||
.set_short_slot_time = i802_set_short_slot_time,
|
||||
.set_tx_queue_params = i802_set_tx_queue_params,
|
||||
.set_sta_vlan = i802_set_sta_vlan,
|
||||
.set_ht_params = i802_set_ht_params,
|
||||
.set_rate_sets = i802_set_rate_sets,
|
||||
.sta_deauth = i802_sta_deauth,
|
||||
.sta_disassoc = i802_sta_disassoc,
|
||||
|
Loading…
Reference in New Issue
Block a user