Remove direct driver calls from beacon.c
This commit is contained in:
parent
2f3e0bd4d4
commit
677449b97e
4 changed files with 86 additions and 57 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "hostapd.h"
|
#include "hostapd.h"
|
||||||
|
#include "ieee802_11.h"
|
||||||
#include "sta_info.h"
|
#include "sta_info.h"
|
||||||
#include "driver_i.h"
|
#include "driver_i.h"
|
||||||
|
|
||||||
|
@ -169,6 +170,74 @@ static int hostapd_set_radius_acl_expire(struct hostapd_data *hapd,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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->conf->iface, 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
|
||||||
|
const u8 *head, size_t head_len,
|
||||||
|
const u8 *tail, size_t tail_len, int dtim_period,
|
||||||
|
int beacon_int)
|
||||||
|
{
|
||||||
|
if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
|
||||||
|
return 0;
|
||||||
|
return hapd->driver->set_beacon(ifname, hapd->drv_priv,
|
||||||
|
head, head_len, tail, tail_len,
|
||||||
|
dtim_period, beacon_int);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
|
void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
|
||||||
{
|
{
|
||||||
ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
|
ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
|
||||||
|
@ -182,4 +251,6 @@ void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
|
||||||
ops->set_drv_ieee8021x = hostapd_set_drv_ieee8021x;
|
ops->set_drv_ieee8021x = hostapd_set_drv_ieee8021x;
|
||||||
ops->set_radius_acl_auth = hostapd_set_radius_acl_auth;
|
ops->set_radius_acl_auth = hostapd_set_radius_acl_auth;
|
||||||
ops->set_radius_acl_expire = hostapd_set_radius_acl_expire;
|
ops->set_radius_acl_expire = hostapd_set_radius_acl_expire;
|
||||||
|
ops->set_bss_params = hostapd_set_bss_params;
|
||||||
|
ops->set_beacon = hostapd_set_beacon;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
#include "wme.h"
|
#include "wme.h"
|
||||||
#include "beacon.h"
|
#include "beacon.h"
|
||||||
#include "hw_features.h"
|
#include "hw_features.h"
|
||||||
#include "driver_i.h"
|
#include "drivers/driver.h"
|
||||||
|
#include "config.h"
|
||||||
#include "sta_info.h"
|
#include "sta_info.h"
|
||||||
#include "wps_hostapd.h"
|
|
||||||
|
|
||||||
|
|
||||||
static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
|
static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
|
||||||
|
@ -333,11 +333,8 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
|
||||||
{
|
{
|
||||||
struct ieee80211_mgmt *head;
|
struct ieee80211_mgmt *head;
|
||||||
u8 *pos, *tail, *tailpos;
|
u8 *pos, *tail, *tailpos;
|
||||||
int preamble;
|
|
||||||
u16 capab_info;
|
u16 capab_info;
|
||||||
size_t head_len, tail_len;
|
size_t head_len, tail_len;
|
||||||
int cts_protection = ((ieee802_11_erp_info(hapd) &
|
|
||||||
ERP_INFO_USE_PROTECTION) ? 1 : 0);
|
|
||||||
|
|
||||||
#define BEACON_HEAD_BUF_SIZE 256
|
#define BEACON_HEAD_BUF_SIZE 256
|
||||||
#define BEACON_TAIL_BUF_SIZE 512
|
#define BEACON_TAIL_BUF_SIZE 512
|
||||||
|
@ -405,22 +402,8 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
|
||||||
tailpos = hostapd_eid_wmm(hapd, tailpos);
|
tailpos = hostapd_eid_wmm(hapd, tailpos);
|
||||||
|
|
||||||
#ifdef CONFIG_IEEE80211N
|
#ifdef CONFIG_IEEE80211N
|
||||||
if (hapd->iconf->ieee80211n) {
|
tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
|
||||||
u8 *ht_capab, *ht_oper;
|
tailpos = hostapd_eid_ht_operation(hapd, tailpos);
|
||||||
ht_capab = tailpos;
|
|
||||||
tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
|
|
||||||
|
|
||||||
ht_oper = tailpos;
|
|
||||||
tailpos = hostapd_eid_ht_operation(hapd, tailpos);
|
|
||||||
|
|
||||||
if (tailpos > ht_oper && ht_oper > ht_capab &&
|
|
||||||
hostapd_set_ht_params(hapd->conf->iface, 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_IEEE80211N */
|
#endif /* CONFIG_IEEE80211N */
|
||||||
|
|
||||||
#ifdef CONFIG_WPS
|
#ifdef CONFIG_WPS
|
||||||
|
@ -433,35 +416,18 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
|
||||||
|
|
||||||
tail_len = tailpos > tail ? tailpos - tail : 0;
|
tail_len = tailpos > tail ? tailpos - tail : 0;
|
||||||
|
|
||||||
if (hostapd_set_beacon(hapd->conf->iface, hapd, (u8 *) head, head_len,
|
if (hapd->drv.set_beacon(hapd->conf->iface, hapd,
|
||||||
tail, tail_len, hapd->conf->dtim_period,
|
(u8 *) head, head_len,
|
||||||
hapd->iconf->beacon_int))
|
tail, tail_len, hapd->conf->dtim_period,
|
||||||
|
hapd->iconf->beacon_int))
|
||||||
wpa_printf(MSG_ERROR, "Failed to set beacon head/tail or DTIM "
|
wpa_printf(MSG_ERROR, "Failed to set beacon head/tail or DTIM "
|
||||||
"period");
|
"period");
|
||||||
|
|
||||||
os_free(tail);
|
os_free(tail);
|
||||||
os_free(head);
|
os_free(head);
|
||||||
|
|
||||||
if (hostapd_set_cts_protect(hapd, cts_protection))
|
hapd->drv.set_bss_params(hapd, !!(ieee802_11_erp_info(hapd) &
|
||||||
wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
|
ERP_INFO_USE_PROTECTION));
|
||||||
"driver");
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -255,19 +255,6 @@ hostapd_set_country(struct hostapd_data *hapd, const char *country)
|
||||||
return hapd->driver->set_country(hapd->drv_priv, country);
|
return hapd->driver->set_country(hapd->drv_priv, country);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
|
||||||
hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
|
|
||||||
const u8 *head, size_t head_len,
|
|
||||||
const u8 *tail, size_t tail_len, int dtim_period,
|
|
||||||
int beacon_int)
|
|
||||||
{
|
|
||||||
if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
|
|
||||||
return 0;
|
|
||||||
return hapd->driver->set_beacon(ifname, hapd->drv_priv,
|
|
||||||
head, head_len, tail, tail_len,
|
|
||||||
dtim_period, beacon_int);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
|
hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,6 +69,11 @@ struct hostapd_driver_ops {
|
||||||
u32 session_timeout);
|
u32 session_timeout);
|
||||||
int (*set_radius_acl_expire)(struct hostapd_data *hapd,
|
int (*set_radius_acl_expire)(struct hostapd_data *hapd,
|
||||||
const u8 *mac);
|
const u8 *mac);
|
||||||
|
int (*set_bss_params)(struct hostapd_data *hapd, int use_protection);
|
||||||
|
int (*set_beacon)(const char *ifname, struct hostapd_data *hapd,
|
||||||
|
const u8 *head, size_t head_len,
|
||||||
|
const u8 *tail, size_t tail_len, int dtim_period,
|
||||||
|
int beacon_int);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue