Esempio n. 1
0
bool
channel_change(int idx)
{
	if (!ifctrl_iwset_freq(conf.ifname, channels[idx].freq)) {
		printlog("ERROR: could not set channel %d", channels[idx].chan);
		return false;
	}
	conf.channel_idx = idx;
	last_channelchange = the_time;
	return true;
}
Esempio n. 2
0
/* Note: ht40plus is only used for HT40 channel width, to distinguish between
 * HT40+ and HT40- */
bool
channel_change(int idx, enum chan_width width, bool ht40plus)
{
	unsigned int center1 = 0;

	if (width == CHAN_WIDTH_UNSPEC)
		width = channel_get_band_from_idx(idx).max_chan_width;

	switch (width) {
		case CHAN_WIDTH_20_NOHT:
		case CHAN_WIDTH_20:
			break;
		case CHAN_WIDTH_40:
			center1 = get_center_freq_ht40(channels.chan[idx].freq, ht40plus);
			break;
		case CHAN_WIDTH_80:
		case CHAN_WIDTH_160:
			center1 = get_center_freq_vht(channels.chan[idx].freq, width);
			break;
		default:
			printlog("%s not implemented", channel_width_string(width, -1));
			break;
	}

	/* only 20 MHz channels don't need additional center freq, otherwise we fail here
	 * quietly because the scanning code sometimes tries invalid HT40+/- channels */
	if (center1 == 0 && !(width == CHAN_WIDTH_20_NOHT || width == CHAN_WIDTH_20))
		return false;

	if (!ifctrl_iwset_freq(conf.ifname, channels.chan[idx].freq, width, center1)) {
		printlog("ERROR: Failed to set CH %d (%d MHz) %s center %d",
			channels.chan[idx].chan, channels.chan[idx].freq,
			channel_width_string(width, ht40plus),
			center1);
		return false;
	}

	printlog("Set CH %d (%d MHz) %s center %d",
		channels.chan[idx].chan, channels.chan[idx].freq,
		channel_width_string(width, ht40plus),
		center1);

	conf.channel_idx = idx;
	conf.channel_width = width;
	conf.channel_ht40plus = ht40plus;
	last_channelchange = the_time;
	return true;
}