Merge set_beacon driver_ops into a single one

Clean up driver interface by merging hostapd and wpa_supplicant
specific set_beacon driver_ops into a single one. In addition,
merge set_beacon_int into to the same operation.
This commit is contained in:
Jouni Malinen 2009-11-23 15:26:05 +02:00 committed by Jouni Malinen
parent 224f7bda79
commit 5d67487244
8 changed files with 28 additions and 125 deletions

View file

@ -428,7 +428,8 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
tail_len = tailpos > tail ? tailpos - tail : 0;
if (hostapd_set_beacon(hapd->conf->iface, hapd, (u8 *) head, head_len,
tail, tail_len, hapd->conf->dtim_period))
tail, tail_len, hapd->conf->dtim_period,
hapd->iconf->beacon_int))
wpa_printf(MSG_ERROR, "Failed to set beacon head/tail or DTIM "
"period");

View file

@ -320,13 +320,14 @@ hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
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)
const u8 *tail, size_t tail_len, int dtim_period,
int beacon_int)
{
if (hapd->driver == NULL || hapd->driver->hapd_set_beacon == NULL)
if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
return 0;
return hapd->driver->hapd_set_beacon(ifname, hapd->drv_priv,
head, head_len,
tail, tail_len, dtim_period);
return hapd->driver->set_beacon(ifname, hapd->drv_priv,
head, head_len, tail, tail_len,
dtim_period, beacon_int);
}
static inline int
@ -337,14 +338,6 @@ hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
}
static inline int
hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
{
if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
return 0;
return hapd->driver->set_beacon_int(hapd->drv_priv, value);
}
static inline int
hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
{

View file

@ -1411,8 +1411,6 @@ int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
}
}
hostapd_set_beacon_int(hapd, hapd->iconf->beacon_int);
if (hapd->iconf->rts_threshold > -1 &&
hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) {
wpa_printf(MSG_ERROR, "Could not set RTS threshold for "

View file

@ -1213,10 +1213,10 @@ struct wpa_driver_ops {
int (*authenticate)(void *priv,
struct wpa_driver_auth_params *params);
int (*set_beacon)(void *priv, const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len, int dtim_period);
int (*set_beacon_int)(void *priv, int value);
int (*set_beacon)(const char *ifname, void *priv,
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len, int dtim_period,
int beacon_int);
void * (*hapd_init)(struct hostapd_data *hapd,
struct wpa_init_params *params);
@ -1285,10 +1285,6 @@ struct wpa_driver_ops {
int total_flags, int flags_or, int flags_and);
int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
int mode);
int (*hapd_set_beacon)(const char *ifname, void *priv,
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len,
int dtim_period);
/* Configure internal bridge:
* 0 = disabled, i.e., client separation is enabled (no bridging of

View file

@ -3217,7 +3217,6 @@ const struct wpa_driver_ops wpa_driver_ndis_ops = {
NULL /* scan2 */,
NULL /* authenticate */,
NULL /* set_beacon */,
NULL /* set_beacon_int */,
NULL /* hapd_init */,
NULL /* hapd_deinit */,
NULL /* set_ieee8021x */,
@ -3243,7 +3242,6 @@ const struct wpa_driver_ops wpa_driver_ndis_ops = {
NULL /* set_frag */,
NULL /* sta_set_flags */,
NULL /* set_rate_sets */,
NULL /* hapd_set_beacon */,
NULL /* set_internal_bridge */,
NULL /* set_cts_protect */,
NULL /* set_preamble */,

View file

@ -103,13 +103,10 @@ struct wpa_driver_nl80211_data {
int nlmode;
int ap_scan_as_station;
int beacon_int;
int monitor_sock;
int monitor_ifidx;
#ifdef CONFIG_AP
unsigned int beacon_set:1;
#endif /* CONFIG_AP */
#ifdef HOSTAPD
int eapol_sock; /* socket for EAPOL frames */
@ -2506,17 +2503,20 @@ static int wpa_driver_nl80211_send_mlme(void *priv, const u8 *data,
return wpa_driver_nl80211_send_frame(drv, data, data_len, encrypt);
}
#endif /* CONFIG_AP || HOSTAPD */
static int wpa_driver_nl80211_set_beacon_iface(int ifindex, void *priv,
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len,
int dtim_period)
static int wpa_driver_nl80211_set_beacon(const char *ifname, void *priv,
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len,
int dtim_period, int beacon_int)
{
struct wpa_driver_nl80211_data *drv = priv;
struct nl_msg *msg;
u8 cmd = NL80211_CMD_NEW_BEACON;
int ret;
int beacon_set;
int ifindex = if_nametoindex(ifname);
#ifdef HOSTAPD
struct i802_bss *bss;
@ -2542,9 +2542,7 @@ static int wpa_driver_nl80211_set_beacon_iface(int ifindex, void *priv,
NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, head_len, head);
NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tail_len, tail);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
if (!drv->beacon_int)
drv->beacon_int = 100;
NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, drv->beacon_int);
NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, beacon_int);
NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, dtim_period);
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
@ -2564,37 +2562,7 @@ static int wpa_driver_nl80211_set_beacon_iface(int ifindex, void *priv,
}
static int wpa_driver_nl80211_set_beacon_int(void *priv, int value)
{
struct wpa_driver_nl80211_data *drv = priv;
struct nl_msg *msg;
drv->beacon_int = value;
#ifdef HOSTAPD
if (!drv->bss.beacon_set)
return 0;
#else /* HOSTAPD */
if (!drv->beacon_set)
return 0;
#endif /* HOSTAPD */
msg = nlmsg_alloc();
if (!msg)
return -ENOMEM;
wpa_printf(MSG_DEBUG, "nl80211: Set beacon interval %d", value);
genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
0, NL80211_CMD_SET_BEACON, 0);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, value);
return send_and_recv_msgs(drv, msg, NULL, NULL);
nla_put_failure:
return -ENOBUFS;
}
#if defined(CONFIG_AP) || defined(HOSTAPD)
static int wpa_driver_nl80211_set_freq(struct wpa_driver_nl80211_data *drv,
int freq, int ht_enabled,
@ -2705,26 +2673,6 @@ static int wpa_driver_nl80211_sta_remove(void *priv, const u8 *addr)
return -ENOBUFS;
}
#endif /* CONFIG_AP || HOSTAPD */
#ifdef CONFIG_AP
static int wpa_driver_nl80211_set_beacon(void *priv,
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len,
int dtim_period)
{
struct wpa_driver_nl80211_data *drv = priv;
return wpa_driver_nl80211_set_beacon_iface(drv->ifindex, priv,
head, head_len,
tail, tail_len,
dtim_period);
}
#endif /* CONFIG_AP */
#if defined(CONFIG_AP) || defined(HOSTAPD)
static void nl80211_remove_iface(struct wpa_driver_nl80211_data *drv,
int ifidx)
@ -4200,17 +4148,6 @@ static int i802_bss_remove(void *priv, const char *ifname)
}
static int i802_set_beacon(const char *iface, void *priv,
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len, int dtim_period)
{
return wpa_driver_nl80211_set_beacon_iface(if_nametoindex(iface), priv,
head, head_len,
tail, tail_len,
dtim_period);
}
static int i802_set_bss(void *priv, int cts, int preamble, int slot)
{
struct wpa_driver_nl80211_data *drv = priv;
@ -4505,12 +4442,9 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
#endif /* HOSTAPD */
.set_country = wpa_driver_nl80211_set_country,
.set_mode = wpa_driver_nl80211_set_mode,
#ifdef CONFIG_AP
.set_beacon = wpa_driver_nl80211_set_beacon,
#endif /* CONFIG_AP */
#if defined(CONFIG_AP) || defined(HOSTAPD)
.send_mlme = wpa_driver_nl80211_send_mlme,
.set_beacon_int = wpa_driver_nl80211_set_beacon_int,
.get_hw_feature_data = wpa_driver_nl80211_get_hw_feature_data,
.sta_add = wpa_driver_nl80211_sta_add,
.sta_remove = wpa_driver_nl80211_sta_remove,
@ -4532,7 +4466,6 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.set_rts = i802_set_rts,
.set_frag = i802_set_frag,
.set_rate_sets = i802_set_rate_sets,
.hapd_set_beacon = i802_set_beacon,
.set_cts_protect = i802_set_cts_protect,
.set_preamble = i802_set_preamble,
.set_short_slot_time = i802_set_short_slot_time,

View file

@ -196,20 +196,12 @@ static int ap_driver_set_freq(void *priv, struct hostapd_freq_params *freq)
static int ap_driver_set_beacon(const char *iface, void *priv,
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len,
int dtim_period)
int dtim_period, int beacon_int)
{
struct ap_driver_data *drv = priv;
struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
return wpa_drv_set_beacon(wpa_s, head, head_len, tail, tail_len,
dtim_period);
}
static int ap_driver_set_beacon_int(void *priv, int value)
{
struct ap_driver_data *drv = priv;
struct wpa_supplicant *wpa_s = drv->hapd->iface->owner;
return wpa_drv_set_beacon_int(wpa_s, value);
dtim_period, beacon_int);
}
@ -282,8 +274,7 @@ struct wpa_driver_ops ap_driver_ops =
.sta_add = ap_driver_sta_add,
.get_inact_sec = ap_driver_get_inact_sec,
.set_freq = ap_driver_set_freq,
.hapd_set_beacon = ap_driver_set_beacon,
.set_beacon_int = ap_driver_set_beacon_int,
.set_beacon = ap_driver_set_beacon,
.set_cts_protect = ap_driver_set_cts_protect,
.set_preamble = ap_driver_set_preamble,
.set_short_slot_time = ap_driver_set_short_slot_time,

View file

@ -381,20 +381,13 @@ static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant *wpa_s,
static inline int wpa_drv_set_beacon(struct wpa_supplicant *wpa_s,
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len,
int dtim_period)
int dtim_period, int beacon_int)
{
if (wpa_s->driver->set_beacon)
return wpa_s->driver->set_beacon(wpa_s->drv_priv, head,
return wpa_s->driver->set_beacon(wpa_s->ifname,
wpa_s->drv_priv, head,
head_len, tail, tail_len,
dtim_period);
return -1;
}
static inline int wpa_drv_set_beacon_int(struct wpa_supplicant *wpa_s,
int value)
{
if (wpa_s->driver->set_beacon_int)
return wpa_s->driver->set_beacon_int(wpa_s->drv_priv, value);
dtim_period, beacon_int);
return -1;
}