Exemple #1
0
bool
channel_init(void) {
	/* get available channels */
	ifctrl_iwget_freqlist(conf.if_phy, &channels);
	conf.channel_initialized = 1;

	printf("Got %d Bands, %d Channels:\n", channels.num_bands, channels.num_channels);
	for (int i = 0; i < channels.num_channels && i < MAX_CHANNELS; i++)
		printf("%s\n", channel_get_string(i));

	if (conf.channel_set_num > 0) {
		/* configured values */
		int ini_idx = channel_find_index_from_chan(conf.channel_set_num);
		if (!channel_change(ini_idx, conf.channel_set_width, conf.channel_set_ht40plus))
			return false;
	} else {
		conf.channel_idx = channel_find_index_from_freq(conf.if_freq);
		conf.channel_set_num = channel_get_chan(conf.channel_idx);
		if (conf.channel_idx < 0)
			return true; // not failure

		/* try to set max width */
		struct band_info b = channel_get_band_from_idx(conf.channel_idx);
		if (conf.channel_width != b.max_chan_width) {
			printlog("Try to set max channel width %s",
				channel_width_string(b.max_chan_width, -1));
			// try both HT40+ and HT40- if necessary
			if (!channel_change(conf.channel_idx, b.max_chan_width, true) &&
			    !channel_change(conf.channel_idx, b.max_chan_width, false))
				return false;
		}
	}
	return true;
}
Exemple #2
0
int
channel_input(WINDOW *win, int c)
{
	char buf[6];
	int x;

	switch (c) {
	case 'a': case 'A':
		conf.do_change_channel = conf.do_change_channel ? 0 : 1;
		break;

	case 'd': case 'D':
		echo();
		curs_set(1);
		mvwgetnstr(win, 3, 25, buf, 6);
		curs_set(0);
		noecho();
		sscanf(buf, "%d", &x);
		conf.channel_time = x*1000;
		break;

	case 'u': case 'U':
		echo();
		curs_set(1);
		mvwgetnstr(win, 4, 26, buf, 6);
		curs_set(0);
		noecho();
		sscanf(buf, "%d", &x);
		conf.channel_max = x;
		break;

	case 'm': case 'M':
		conf.do_change_channel = 0;
		echo();
		curs_set(1);
		mvwgetnstr(win, 6, 30, buf, 2);
		curs_set(0);
		noecho();
		sscanf(buf, "%d", &x);
		x = channel_find_index_from_chan(x);
		if (x >= 0) {
			if (!conf.serveraddr)
				channel_change(x);
			else
				conf.channel_idx = x;
		}
		break;

	default:
		return 0; /* didn't handle input */
	}

	net_send_channel_config();

	update_channel_win(win);
	return 1;
}
Exemple #3
0
bool
channel_init(void) {
	/* get available channels */
	ifctrl_iwget_freqlist(conf.if_phy, channels);
	conf.channel_idx = channel_find_index_from_freq(conf.if_freq);

	if (conf.channel_num_initial > 0) {
	    if (!channel_change(channel_find_index_from_chan(conf.channel_num_initial)))
	        return false;
	} else {
	    conf.channel_num_initial = channel_get_chan_from_idx(conf.channel_idx);
	}
	conf.channel_initialized = 1;
	return true;
}
Exemple #4
0
bool
channel_input(WINDOW *win, int c)
{
	char buf[6];
	int x;

	switch (c) {
	case 's': case 'S':
		conf.do_change_channel = conf.do_change_channel ? 0 : 1;
		break;

	case 'd': case 'D':
		echo();
		curs_set(1);
		mvwgetnstr(win, 18, 12, buf, 6);
		curs_set(0);
		noecho();
		sscanf(buf, "%d", &x);
		conf.channel_time = x*1000;
		break;

	case 'u': case 'U':
		echo();
		curs_set(1);
		mvwgetnstr(win, 19, 18, buf, 6);
		curs_set(0);
		noecho();
		sscanf(buf, "%d", &x);
		conf.channel_max = x;
		break;

	case 'm': case 'M':
		echo();
		curs_set(1);
		mvwgetnstr(win, 21, 18, buf, 3);
		curs_set(0);
		noecho();
		sscanf(buf, "%d", &x);
		int i = channel_find_index_from_chan(x);
		if (i >= 0) {
			if (!conf.serveraddr[0] != '\0') {
				if (!channel_change(i, conf.channel_set_width, conf.channel_set_ht40plus))
					printlog("Channel %d %s is not available/allowed", x,
						channel_width_string(conf.channel_set_width,
									 conf.channel_set_ht40plus));
			} else
				conf.channel_idx = i;
		}
		break;

	case '1':
		conf.channel_set_width = CHAN_WIDTH_20_NOHT;
		break;

	case '2':
		conf.channel_set_width = CHAN_WIDTH_20;
		break;

	case '4':
		conf.channel_set_width = CHAN_WIDTH_40;
		conf.channel_set_ht40plus = false;
		break;

	case '5':
		conf.channel_set_width = CHAN_WIDTH_40;
		conf.channel_set_ht40plus = true;
		break;

	case '8':
		conf.channel_set_width = CHAN_WIDTH_80;
		break;

	case '6':
		conf.channel_set_width = CHAN_WIDTH_160;
		break;

	default:
		return false; /* didn't handle input */
	}

	// TODO: net client has not set channel_width and ht40p yet:
	net_send_channel_config();

	update_channel_win(win);
	return true;
}