Merge set_dtim_period() into set_beacon()

No need for a separate driver_ops handler for setting DTIM period since
this is always set at the same time with the Beacon data. Beacon
interval is still set separately since it is consider per-radio
parameter (Beacon data and DTIM period are per-BSS parameters).
This commit is contained in:
Jouni Malinen 2009-04-02 16:05:21 +03:00 committed by Jouni Malinen
parent 2e24a366ea
commit 74f2ad326f
4 changed files with 11 additions and 63 deletions

View file

@ -428,16 +428,13 @@ 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))
wpa_printf(MSG_ERROR, "Failed to set beacon head/tail");
tail, tail_len, hapd->conf->dtim_period))
wpa_printf(MSG_ERROR, "Failed to set beacon head/tail or DTIM "
"period");
os_free(tail);
os_free(head);
if (hostapd_set_dtim_period(hapd, hapd->conf->dtim_period))
wpa_printf(MSG_ERROR, "Could not set DTIM period for kernel "
"driver");
if (hostapd_set_cts_protect(hapd, cts_protection))
wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
"driver");

View file

@ -144,8 +144,8 @@ struct hapd_driver_ops {
int (*set_country)(void *priv, const char *country);
int (*set_ieee80211d)(void *priv, int enabled);
int (*set_beacon)(const char *ifname, void *priv,
u8 *head, size_t head_len,
u8 *tail, size_t tail_len);
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
@ -154,7 +154,6 @@ struct hapd_driver_ops {
*/
int (*set_internal_bridge)(void *priv, int value);
int (*set_beacon_int)(void *priv, int value);
int (*set_dtim_period)(const char *ifname, void *priv, int value);
/* Configure broadcast SSID mode:
* 0 = include SSID in Beacon frames and reply to Probe Request frames
* that use broadcast SSID

View file

@ -357,13 +357,13 @@ hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
static inline int
hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
u8 *head, size_t head_len,
u8 *tail, size_t tail_len)
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len, int dtim_period)
{
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);
tail, tail_len, dtim_period);
}
static inline int
@ -382,15 +382,6 @@ hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
return hapd->driver->set_beacon_int(hapd->drv_priv, value);
}
static inline int
hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
{
if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
return 0;
return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->drv_priv,
value);
}
static inline int
hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
{

View file

@ -58,7 +58,6 @@ enum ieee80211_msg_type {
struct i802_bss {
struct i802_bss *next;
char iface[IFNAMSIZ + 1];
int dtim_period;
unsigned int beacon_set:1;
};
@ -1161,8 +1160,8 @@ static int i802_bss_remove(void *priv, const char *ifname)
static int i802_set_beacon(const char *iface, void *priv,
u8 *head, size_t head_len,
u8 *tail, size_t tail_len)
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len, int dtim_period)
{
struct i802_driver_data *drv = priv;
struct nl_msg *msg;
@ -1189,10 +1188,7 @@ static int i802_set_beacon(const char *iface, void *priv,
NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tail_len, tail);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(iface));
NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, drv->beacon_int);
if (!bss->dtim_period)
bss->dtim_period = 2;
NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, bss->dtim_period);
NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, dtim_period);
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
if (!ret)
@ -1285,40 +1281,6 @@ static int i802_set_beacon_int(void *priv, int value)
}
static int i802_set_dtim_period(const char *iface, void *priv, int value)
{
struct i802_driver_data *drv = priv;
struct nl_msg *msg;
int ret = -ENOBUFS;
struct i802_bss *bss;
bss = get_bss(drv, iface);
if (bss == NULL)
return -ENOENT;
msg = nlmsg_alloc();
if (!msg)
return -ENOMEM;
wpa_printf(MSG_DEBUG, "nl80211: Set beacon DTIM period %d (iface=%s "
"beacon_set=%d)", value, iface, bss->beacon_set);
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, if_nametoindex(iface));
bss->dtim_period = value;
NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, bss->dtim_period);
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
if (ret)
wpa_printf(MSG_DEBUG, "nl80211: NL80211_CMD_SET_BEACON(%s) "
"result: %d (%s)", iface, ret, strerror(-ret));
nla_put_failure:
return ret;
}
static int i802_set_bss(void *priv, int cts, int preamble, int slot)
{
struct i802_driver_data *drv = priv;
@ -3136,7 +3098,6 @@ const struct hapd_driver_ops wpa_driver_nl80211_ops = {
.set_beacon = i802_set_beacon,
.set_internal_bridge = i802_set_internal_bridge,
.set_beacon_int = i802_set_beacon_int,
.set_dtim_period = i802_set_dtim_period,
.set_cts_protect = i802_set_cts_protect,
.set_preamble = i802_set_preamble,
.set_short_slot_time = i802_set_short_slot_time,