/** * reload_hw_mode_done - Callback for after the HW mode is setup * @hapd_iface: Pointer to interface data. * @status: Status of the HW mode setup. */ static void reload_hw_mode_done(struct hostapd_iface *hapd_iface, int status) { struct hostapd_data *hapd = hapd_iface->bss[0]; struct hostapd_config_change *change = hapd_iface->change; struct hostapd_config *newconf = change->newconf; hostapd_iface_cb cb; int freq; if (status) { printf("Failed to select hw_mode.\n"); cb = hapd_iface->reload_iface_cb; hapd_iface->reload_iface_cb = NULL; cb(hapd_iface, -1); return; } freq = hostapd_hw_get_freq(hapd, newconf->channel); HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "Mode: %s Channel: %d Frequency: %d MHz\n", hostapd_hw_mode_txt(newconf->hw_mode), newconf->channel, freq); if (hostapd_set_freq(hapd, newconf->hw_mode, freq)) { printf("Could not set channel %d (%d MHz) for kernel " "driver\n", newconf->channel, freq); } change->beacon_changed++; reload_iface2(hapd_iface); }
void SET_FREQ_handle(int fd, u8 *buf, int len, void *hapd){ struct hostapd_data *h = hapd; char str[5][10]; int i,j=0; int cnt = 0; for(i=0; i<len; i++){ if(buf[i]==' '){ str[cnt][j] = 0; j = 0; cnt++; }else{ str[cnt][j] = buf[i]; j++; } } wl.freq_params.freq = atoi(str[0]); wl.freq_params.sec_channel_offset = atoi(str[1]); wl.freq_params.ht_enabled = atoi(str[2]); wl.freq_params.channel = atoi(str[3]); wl.freq_params.mode = atoi(str[4]); int ret = hostapd_set_freq(h, wl.freq_params.mode, wl.freq_params.freq, wl.freq_params.channel, wl.freq_params.ht_enabled, wl.freq_params.sec_channel_offset); u8 ret_str[10]; sprintf(ret_str, "%d", ret); send_response(fd, SET_FREQ_R, ret_str, strlen(ret_str)); }
int hostapd_reload_config(struct hostapd_iface *iface) { struct hostapd_data *hapd = iface->bss[0]; struct hostapd_config *newconf, *oldconf; size_t j; if (iface->interfaces == NULL || iface->interfaces->config_read_cb == NULL) return -1; newconf = iface->interfaces->config_read_cb(iface->config_fname); if (newconf == NULL) return -1; /* * Deauthenticate all stations since the new configuration may not * allow them to use the BSS anymore. */ for (j = 0; j < iface->num_bss; j++) { hostapd_flush_old_stations(iface->bss[j], WLAN_REASON_PREV_AUTH_NOT_VALID); hostapd_broadcast_wep_clear(iface->bss[j]); #ifndef CONFIG_NO_RADIUS /* TODO: update dynamic data based on changed configuration * items (e.g., open/close sockets, etc.) */ radius_client_flush(iface->bss[j]->radius, 0); #endif /* CONFIG_NO_RADIUS */ } oldconf = hapd->iconf; iface->conf = newconf; hostapd_select_hw_mode(iface); iface->freq = hostapd_hw_get_freq(hapd, newconf->channel); if (hostapd_set_freq(hapd, newconf->hw_mode, iface->freq, newconf->channel, newconf->ieee80211n, newconf->secondary_channel)) { wpa_printf(MSG_ERROR, "Could not set channel for " "kernel driver"); } if (iface->current_mode) hostapd_prepare_rates(iface, iface->current_mode); for (j = 0; j < iface->num_bss; j++) { hapd = iface->bss[j]; hapd->iconf = newconf; hapd->conf = &newconf->bss[j]; hostapd_reload_bss(hapd); } hostapd_config_free(oldconf); return 0; }
void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht, int offset) { #ifdef NEED_AP_MLME int channel; hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_INFO, "driver had channel switch: " "freq=%d, ht=%d, offset=%d", freq, ht, offset); channel = hostapd_hw_get_channel(hapd, freq); if (!channel) { hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "driver switched to " "bad channel!"); return; } hapd->iconf->channel = channel; hapd->iconf->ieee80211n = ht; hapd->iconf->secondary_channel = offset; if (hapd->iface->freq == freq) return; hapd->iface->freq = freq; if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, freq, hapd->iconf->channel, hapd->iconf->ieee80211n, hapd->iconf->secondary_channel)) { hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "failed to update the freq !"); return; } hapd->next_channel = NULL; /* update the DS IE */ ieee802_11_set_beacon(hapd); wpa_printf(MSG_DEBUG, "AP/GO moved to channel %d", channel); #endif /* NEED_AP_MLME */ }
static void hostapd_set_force_20mhz(struct hostapd_iface *iface) { int secondary_channel; int i; ieee802_11_set_beacons(iface); for (i = 0; i < iface->num_bss; i++) { struct hostapd_data *hapd = iface->bss[i]; if (iface->force_20mhz) secondary_channel = 0; else secondary_channel = hapd->iconf->secondary_channel; if (hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq, hapd->iconf->channel, hapd->iconf->ieee80211n, secondary_channel)) { wpa_printf(MSG_ERROR, "Could not set channel for " "kernel driver"); } } }