int ieee802_11_set_beacon(struct hostapd_data *hapd) { struct wpa_driver_ap_params params; struct hostapd_freq_params freq; struct hostapd_iface *iface = hapd->iface; struct hostapd_config *iconf = iface->conf; struct wpabuf *beacon, *proberesp, *assocresp; int res, ret = -1; if (hapd->csa_in_progress) { wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period"); return -1; } hapd->beacon_set_done = 1; if (ieee802_11_build_ap_params(hapd, ¶ms) < 0) return -1; if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) < 0) goto fail; params.beacon_ies = beacon; params.proberesp_ies = proberesp; params.assocresp_ies = assocresp; if (iface->current_mode && hostapd_set_freq_params(&freq, iconf->hw_mode, iface->freq, iconf->channel, iconf->ieee80211n, iconf->ieee80211ac, iconf->secondary_channel, iconf->vht_oper_chwidth, iconf->vht_oper_centr_freq_seg0_idx, iconf->vht_oper_centr_freq_seg1_idx, iface->current_mode->vht_capab) == 0) params.freq = &freq; res = hostapd_drv_set_ap(hapd, ¶ms); // MANA - Start Beacon Stuffs here //hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp); //struct wpa_driver_ap_params params2 = params; //os_memset(¶ms2.ssid, 0, params2.ssid_len); //params2.hide_ssid = HIDDEN_SSID_ZERO_CONTENTS; //hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp); //params2.beacon_ies = beacon; //params2.proberesp_ies = proberesp; //params2.assocresp_ies = assocresp; //wpa_printf(MSG_INFO, "ZZZZ : Sending Hidden AP: %s", params2.ssid); //res = hostapd_drv_set_ap(hapd, ¶ms2); //hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp); // MANA - End Beacon Stuffs here if (res) wpa_printf(MSG_ERROR, "Failed to set beacon parameters"); else ret = 0; fail: ieee802_11_free_ap_params(¶ms); return ret; }
int hostapd_start_dfs_cac(struct hostapd_iface *iface, int mode, int freq, int channel, int ht_enabled, int vht_enabled, int sec_channel_offset, int vht_oper_chwidth, int center_segment0, int center_segment1) { struct hostapd_data *hapd = iface->bss[0]; struct hostapd_freq_params data; int res; if (!hapd->driver || !hapd->driver->start_dfs_cac) return 0; if (!iface->conf->ieee80211h) { wpa_printf(MSG_ERROR, "Can't start DFS CAC, DFS functionality " "is not enabled"); return -1; } if (hostapd_set_freq_params(&data, mode, freq, channel, ht_enabled, vht_enabled, sec_channel_offset, vht_oper_chwidth, center_segment0, center_segment1, iface->current_mode->vht_capab)) return -1; res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data); if (!res) iface->cac_started = 1; return res; }
int ieee802_11_set_beacon(struct hostapd_data *hapd) { struct wpa_driver_ap_params params; struct hostapd_freq_params freq; struct hostapd_iface *iface = hapd->iface; struct hostapd_config *iconf = iface->conf; struct wpabuf *beacon, *proberesp, *assocresp; int res, ret = -1; if (hapd->csa_in_progress) { wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period"); return -1; } hapd->beacon_set_done = 1; if (ieee802_11_build_ap_params(hapd, ¶ms) < 0) return -1; if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) < 0) goto fail; params.beacon_ies = beacon; params.proberesp_ies = proberesp; params.assocresp_ies = assocresp; params.reenable = hapd->reenable_beacon; hapd->reenable_beacon = 0; if (iface->current_mode && hostapd_set_freq_params(&freq, iconf->hw_mode, iface->freq, iconf->channel, iconf->ieee80211n, iconf->ieee80211ac, iconf->secondary_channel, iconf->vht_oper_chwidth, iconf->vht_oper_centr_freq_seg0_idx, iconf->vht_oper_centr_freq_seg1_idx, iface->current_mode->vht_capab, iconf->bwmode) == 0) params.freq = &freq; 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; }
int hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int channel, int ht_enabled, int vht_enabled, int sec_channel_offset, int vht_oper_chwidth, int center_segment0, int center_segment1) { struct hostapd_freq_params data; if (hostapd_set_freq_params(&data, mode, freq, channel, ht_enabled, vht_enabled, sec_channel_offset, vht_oper_chwidth, center_segment0, center_segment1, hapd->iface->current_mode->vht_capab)) return -1; if (hapd->driver == NULL) return 0; if (hapd->driver->set_freq == NULL) return 0; return hapd->driver->set_freq(hapd->drv_priv, &data); }
static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface) { struct hostapd_channel_data *channel; int secondary_channel; u8 vht_oper_centr_freq_seg0_idx; u8 vht_oper_centr_freq_seg1_idx; int skip_radar = 1; struct csa_settings csa_settings; unsigned int i; int err = 1; wpa_printf(MSG_DEBUG, "%s called (CAC active: %s, CSA active: %s)", __func__, iface->cac_started ? "yes" : "no", hostapd_csa_in_progress(iface) ? "yes" : "no"); /* Check if CSA in progress */ if (hostapd_csa_in_progress(iface)) return 0; /* Check if active CAC */ if (iface->cac_started) return hostapd_dfs_start_channel_switch_cac(iface); /* Perform channel switch/CSA */ channel = dfs_get_valid_channel(iface, &secondary_channel, &vht_oper_centr_freq_seg0_idx, &vht_oper_centr_freq_seg1_idx, skip_radar); if (!channel) { /* * If there is no channel to switch immediately to, check if * there is another channel where we can switch even if it * requires to perform a CAC first. */ skip_radar = 0; channel = dfs_get_valid_channel(iface, &secondary_channel, &vht_oper_centr_freq_seg0_idx, &vht_oper_centr_freq_seg1_idx, skip_radar); if (!channel) { wpa_printf(MSG_INFO, "%s: no DFS channels left, waiting for NOP to finish", __func__); return err; } iface->freq = channel->freq; iface->conf->channel = channel->chan; iface->conf->secondary_channel = secondary_channel; iface->conf->vht_oper_centr_freq_seg0_idx = vht_oper_centr_freq_seg0_idx; iface->conf->vht_oper_centr_freq_seg1_idx = vht_oper_centr_freq_seg1_idx; hostapd_disable_iface(iface); hostapd_enable_iface(iface); return 0; } wpa_printf(MSG_DEBUG, "DFS will switch to a new channel %d", channel->chan); wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NEW_CHANNEL "freq=%d chan=%d sec_chan=%d", channel->freq, channel->chan, secondary_channel); /* Setup CSA request */ os_memset(&csa_settings, 0, sizeof(csa_settings)); csa_settings.cs_count = 5; csa_settings.block_tx = 1; err = hostapd_set_freq_params(&csa_settings.freq_params, iface->conf->hw_mode, channel->freq, channel->chan, iface->conf->ieee80211n, iface->conf->ieee80211ac, secondary_channel, iface->conf->vht_oper_chwidth, vht_oper_centr_freq_seg0_idx, vht_oper_centr_freq_seg1_idx, iface->current_mode->vht_capab, iface->conf->bwmode); if (err) { wpa_printf(MSG_ERROR, "DFS failed to calculate CSA freq params"); hostapd_disable_iface(iface); return err; } for (i = 0; i < iface->num_bss; i++) { err = hostapd_switch_channel(iface->bss[i], &csa_settings); if (err) break; } if (err) { wpa_printf(MSG_WARNING, "DFS failed to schedule CSA (%d) - trying fallback", err); iface->freq = channel->freq; iface->conf->channel = channel->chan; iface->conf->secondary_channel = secondary_channel; iface->conf->vht_oper_centr_freq_seg0_idx = vht_oper_centr_freq_seg0_idx; iface->conf->vht_oper_centr_freq_seg1_idx = vht_oper_centr_freq_seg1_idx; hostapd_disable_iface(iface); hostapd_enable_iface(iface); return 0; } /* Channel configuration will be updated once CSA completes and * ch_switch_notify event is received */ wpa_printf(MSG_DEBUG, "DFS waiting channel switch event"); return 0; }