Verify that beacon setup succeeds before proceeding
There is no point in starting the AP operations unless the driver can be successfully configured to beacon. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
7d7f7be2e5
commit
bad5cdf491
3 changed files with 33 additions and 17 deletions
|
@ -878,20 +878,21 @@ void ieee802_11_free_ap_params(struct wpa_driver_ap_params *params)
|
|||
}
|
||||
|
||||
|
||||
void ieee802_11_set_beacon(struct hostapd_data *hapd)
|
||||
int ieee802_11_set_beacon(struct hostapd_data *hapd)
|
||||
{
|
||||
struct wpa_driver_ap_params params;
|
||||
struct wpabuf *beacon, *proberesp, *assocresp;
|
||||
int res, ret = -1;
|
||||
|
||||
if (hapd->iface->csa_in_progress) {
|
||||
wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
hapd->beacon_set_done = 1;
|
||||
|
||||
if (ieee802_11_build_ap_params(hapd, ¶ms) < 0)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) <
|
||||
0)
|
||||
|
@ -901,31 +902,46 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
|
|||
params.proberesp_ies = proberesp;
|
||||
params.assocresp_ies = assocresp;
|
||||
|
||||
if (hostapd_drv_set_ap(hapd, ¶ms))
|
||||
wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
|
||||
res = hostapd_drv_set_ap(hapd, ¶ms);
|
||||
hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
|
||||
if (res)
|
||||
wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
|
||||
else
|
||||
ret = 0;
|
||||
fail:
|
||||
ieee802_11_free_ap_params(¶ms);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void ieee802_11_set_beacons(struct hostapd_iface *iface)
|
||||
int ieee802_11_set_beacons(struct hostapd_iface *iface)
|
||||
{
|
||||
size_t i;
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < iface->num_bss; i++) {
|
||||
if (iface->bss[i]->started)
|
||||
ieee802_11_set_beacon(iface->bss[i]);
|
||||
if (iface->bss[i]->started &&
|
||||
ieee802_11_set_beacon(iface->bss[i]) < 0)
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* only update beacons if started */
|
||||
void ieee802_11_update_beacons(struct hostapd_iface *iface)
|
||||
int ieee802_11_update_beacons(struct hostapd_iface *iface)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < iface->num_bss; i++)
|
||||
if (iface->bss[i]->beacon_set_done && iface->bss[i]->started)
|
||||
ieee802_11_set_beacon(iface->bss[i]);
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < iface->num_bss; i++) {
|
||||
if (iface->bss[i]->beacon_set_done && iface->bss[i]->started &&
|
||||
ieee802_11_set_beacon(iface->bss[i]) < 0)
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||
|
|
|
@ -21,9 +21,9 @@ struct ieee80211_mgmt;
|
|||
void handle_probe_req(struct hostapd_data *hapd,
|
||||
const struct ieee80211_mgmt *mgmt, size_t len,
|
||||
int ssi_signal);
|
||||
void ieee802_11_set_beacon(struct hostapd_data *hapd);
|
||||
void ieee802_11_set_beacons(struct hostapd_iface *iface);
|
||||
void ieee802_11_update_beacons(struct hostapd_iface *iface);
|
||||
int ieee802_11_set_beacon(struct hostapd_data *hapd);
|
||||
int ieee802_11_set_beacons(struct hostapd_iface *iface);
|
||||
int ieee802_11_update_beacons(struct hostapd_iface *iface);
|
||||
int ieee802_11_build_ap_params(struct hostapd_data *hapd,
|
||||
struct wpa_driver_ap_params *params);
|
||||
void ieee802_11_free_ap_params(struct wpa_driver_ap_params *params);
|
||||
|
|
|
@ -810,8 +810,8 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!hapd->conf->start_disabled)
|
||||
ieee802_11_set_beacon(hapd);
|
||||
if (!hapd->conf->start_disabled && ieee802_11_set_beacon(hapd) < 0)
|
||||
return -1;
|
||||
|
||||
if (hapd->wpa_auth && wpa_init_keys(hapd->wpa_auth) < 0)
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue