Replace set_beacon() driver op with set_ap()

This change is a first step in better supporting different driver
architectures for AP mode operations with nl80211. This commit in
itself does not add new functionality, but it makes it easier to add
new AP mode parameters to address needs of drivers that have more of
the MLME/SME in firmware or kernel.
This commit is contained in:
Jouni Malinen 2011-08-10 13:22:37 +03:00 committed by Jouni Malinen
parent 5fb1a23252
commit 19c3b56685
6 changed files with 72 additions and 44 deletions

View file

@ -164,16 +164,12 @@ static inline int hostapd_drv_sta_clear_stats(struct hostapd_data *hapd,
return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
}
static inline int hostapd_drv_set_beacon(struct hostapd_data *hapd,
const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len,
int dtim_period, int beacon_int)
static inline int hostapd_drv_set_ap(struct hostapd_data *hapd,
struct wpa_driver_ap_params *params)
{
if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
if (hapd->driver == NULL || hapd->driver->set_ap == NULL)
return 0;
return hapd->driver->set_beacon(hapd->drv_priv,
head, head_len, tail, tail_len,
dtim_period, beacon_int);
return hapd->driver->set_ap(hapd->drv_priv, params);
}
static inline int hostapd_drv_set_radius_acl_auth(struct hostapd_data *hapd,

View file

@ -398,6 +398,7 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
u8 *pos, *tail, *tailpos;
u16 capab_info;
size_t head_len, tail_len;
struct wpa_driver_ap_params params;
#ifdef CONFIG_P2P
if ((hapd->conf->p2p & (P2P_ENABLED | P2P_GROUP_OWNER)) == P2P_ENABLED)
@ -510,11 +511,15 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
tail_len = tailpos > tail ? tailpos - tail : 0;
if (hostapd_drv_set_beacon(hapd, (u8 *) head, head_len,
tail, tail_len, hapd->conf->dtim_period,
hapd->iconf->beacon_int))
wpa_printf(MSG_ERROR, "Failed to set beacon head/tail or DTIM "
"period");
os_memset(&params, 0, sizeof(params));
params.head = (u8 *) head;
params.head_len = head_len;
params.tail = tail;
params.tail_len = tail_len;
params.dtim_period = hapd->conf->dtim_period;
params.beacon_int = hapd->iconf->beacon_int;
if (hostapd_drv_set_ap(hapd, &params))
wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
os_free(tail);
os_free(head);

View file

@ -500,6 +500,38 @@ struct wpa_driver_associate_params {
int uapsd;
};
struct wpa_driver_ap_params {
/**
* head - Beacon head from IEEE 802.11 header to IEs before TIM IE
*/
const u8 *head;
/**
* head_len - Length of the head buffer in octets
*/
size_t head_len;
/**
* tail - Beacon tail following TIM IE
*/
const u8 *tail;
/**
* tail_len - Length of the tail buffer in octets
*/
size_t tail_len;
/**
* dtim_period - DTIM period
*/
int dtim_period;
/**
* beacon_int - Beacon interval
*/
int beacon_int;
};
/**
* struct wpa_driver_capa - Driver capability information
*/
@ -1291,24 +1323,25 @@ struct wpa_driver_ops {
struct wpa_driver_auth_params *params);
/**
* set_beacon - Set Beacon frame template
* set_ap - Set Beacon and Probe Response information for AP mode
* @priv: Private driver interface data
* @head: Beacon head from IEEE 802.11 header to IEs before TIM IE
* @head_len: Length of the head buffer in octets
* @tail: Beacon tail following TIM IE
* @tail_len: Length of the tail buffer in octets
* @dtim_period: DTIM period
* @beacon_int: Beacon interval
* Returns: 0 on success, -1 on failure
* @params: Parameters to use in AP mode
*
* This function is used to configure Beacon template for the driver in
* This function is used to configure Beacon template and/or extra IEs
* to add for Beacon and Probe Response frames for the driver in
* AP mode. The driver is responsible for building the full Beacon
* frame by concatenating the head part with TIM IE generated by the
* driver/firmware and finishing with the tail part.
* driver/firmware and finishing with the tail part. Depending on the
* driver architectue, this can be done either by using the full
* template or the set of additional IEs (e.g., WPS and P2P IE).
* Similarly, Probe Response processing depends on the driver design.
* If the driver (or firmware) takes care of replying to Probe Request
* frames, the extra IEs provided here needs to be added to the Probe
* Response frames.
*
* Returns: 0 on success, -1 on failure
*/
int (*set_beacon)(void *priv, const u8 *head, size_t head_len,
const u8 *tail, size_t tail_len, int dtim_period,
int beacon_int);
int (*set_ap)(void *priv, struct wpa_driver_ap_params *params);
/**
* hapd_init - Initialize driver interface (hostapd only)

View file

@ -3253,7 +3253,7 @@ const struct wpa_driver_ops wpa_driver_ndis_ops = {
wpa_driver_ndis_get_interfaces,
wpa_driver_ndis_scan,
NULL /* authenticate */,
NULL /* set_beacon */,
NULL /* set_ap */,
NULL /* hapd_init */,
NULL /* hapd_deinit */,
NULL /* set_ieee8021x */,

View file

@ -3818,10 +3818,8 @@ static int wpa_driver_nl80211_send_mlme(void *priv, const u8 *data,
}
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, int beacon_int)
static int wpa_driver_nl80211_set_ap(void *priv,
struct wpa_driver_ap_params *params)
{
struct i802_bss *bss = priv;
struct wpa_driver_nl80211_data *drv = bss->drv;
@ -3844,11 +3842,11 @@ static int wpa_driver_nl80211_set_beacon(void *priv,
genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
0, cmd, 0);
NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, head_len, head);
NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, tail_len, tail);
NLA_PUT(msg, NL80211_ATTR_BEACON_HEAD, params->head_len, params->head);
NLA_PUT(msg, NL80211_ATTR_BEACON_TAIL, params->tail_len, params->tail);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, beacon_int);
NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, dtim_period);
NLA_PUT_U32(msg, NL80211_ATTR_BEACON_INTERVAL, params->beacon_int);
NLA_PUT_U32(msg, NL80211_ATTR_DTIM_PERIOD, params->dtim_period);
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
if (ret) {
@ -6858,7 +6856,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.set_operstate = wpa_driver_nl80211_set_operstate,
.set_supp_port = wpa_driver_nl80211_set_supp_port,
.set_country = wpa_driver_nl80211_set_country,
.set_beacon = wpa_driver_nl80211_set_beacon,
.set_ap = wpa_driver_nl80211_set_ap,
.if_add = wpa_driver_nl80211_if_add,
.if_remove = wpa_driver_nl80211_if_remove,
.send_mlme = wpa_driver_nl80211_send_mlme,

View file

@ -320,15 +320,11 @@ static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
return -1;
}
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 beacon_int)
static inline int wpa_drv_set_ap(struct wpa_supplicant *wpa_s,
struct wpa_driver_ap_params *params)
{
if (wpa_s->driver->set_beacon)
return wpa_s->driver->set_beacon(wpa_s->drv_priv, head,
head_len, tail, tail_len,
dtim_period, beacon_int);
if (wpa_s->driver->set_ap)
return wpa_s->driver->set_ap(wpa_s->drv_priv, params);
return -1;
}