diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h index 6f947f95d..a9406bdca 100644 --- a/src/ap/ap_drv_ops.h +++ b/src/ap/ap_drv_ops.h @@ -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, diff --git a/src/ap/beacon.c b/src/ap/beacon.c index ce06d0b5c..136856c43 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -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(¶ms, 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, ¶ms)) + wpa_printf(MSG_ERROR, "Failed to set beacon parameters"); os_free(tail); os_free(head); diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 92951ae13..36e6ca905 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -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) diff --git a/src/drivers/driver_ndis.c b/src/drivers/driver_ndis.c index aeb730413..da39429da 100644 --- a/src/drivers/driver_ndis.c +++ b/src/drivers/driver_ndis.c @@ -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 */, diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index d44f50c70..9726cbf18 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -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, diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h index 8637754fb..79fdddd76 100644 --- a/wpa_supplicant/driver_i.h +++ b/wpa_supplicant/driver_i.h @@ -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; }