コード例 #1
0
ファイル: network.c プロジェクト: latelee/horst
static void net_send_chan_list(int fd)
{
	char* buf;
	struct net_chan_list *nc;
	int i;

	buf = malloc(sizeof(struct net_chan_list) +
		     sizeof(unsigned int) * (channel_get_num_channels() - 1));
	if (buf == NULL)
		return;

	nc = (struct net_chan_list *)buf;
	nc->proto.version = PROTO_VERSION;
	nc->proto.type	= PROTO_CHAN_LIST;

	nc->num_bands = channel_get_num_bands();
	for (i = 0; i < nc->num_bands; i++) {
		const struct band_info* bp = channel_get_band(i);
		nc->band[i].num_chans = bp->num_channels;
		nc->band[i].max_width = bp->max_chan_width;
		nc->band[i].streams_rx = bp->streams_rx;
		nc->band[i].streams_tx = bp->streams_tx;
	}

	for (i = 0; i < channel_get_num_channels(); i++) {
		nc->freq[i] = htole32(channel_get_freq(i));
		DEBUG("NET send freq %d %d\n", i, channel_get_freq(i));
	}

	net_write(fd, (unsigned char *)buf, sizeof(struct net_chan_list) +
					    sizeof(unsigned int) * (i - 1));
	free(buf);
}
コード例 #2
0
ファイル: display-channel.c プロジェクト: JiantaoFu/horst
void
update_channel_win(WINDOW *win)
{
	int l = 2;

	box(win, 0 , 0);
	print_centered(win, 0, 39, " Channel Settings ");

	wattron(win, WHITE);
	for (int b = 0; b < channel_get_num_bands(); b++) {
		const struct band_info* bp = channel_get_band(b);
		int c = channel_get_idx_from_band_idx(b, 0);
		int col = channel_get_chan(c) > 14 ? COL_BAND2 : 2;
		wattron(win, A_BOLD);
		mvwprintw(win, 2, col, "%s: %s",
			col == 2 ? "2.4GHz" : "5GHz",
			channel_width_string(bp->max_chan_width, -1));

		if (bp->streams_rx || bp->streams_tx)
			wprintw(win, " %dx%d", bp->streams_rx, bp->streams_tx);
		wattroff(win, A_BOLD);
		l = 3;
		for (int i = 0; (c = channel_get_idx_from_band_idx(b, i)) != -1; i++) {
			if (c == conf.channel_idx)
				wattron(win, CYAN);
			else
				wattron(win, WHITE);
			mvwprintw(win, l++,
				col,
				"%s", channel_get_string(c));
		}
	}
	wattroff(win, WHITE);

	l = 17;
	wattron(win, A_BOLD);
	mvwprintw(win, l++, 2, "s: [%c] Scan",
		  CHECKED(conf.do_change_channel));
	wattroff(win, A_BOLD);
	mvwprintw(win, l++, 2, "d: Dwell: %d ms   ",
		  conf.channel_time/1000);
	mvwprintw(win, l++, 2, "u: Upper limit: %d  ", conf.channel_max);

	l++;
	wattron(win, A_BOLD);
	mvwprintw(win, l++, 2, "m: Set channel: %d  ",
		channel_get_chan(conf.channel_idx));
	wattroff(win, A_BOLD);
	mvwprintw(win, l++, 2, "1: [%c] 20 (no HT)",
		CHECKED(conf.channel_set_width == CHAN_WIDTH_20_NOHT));
	mvwprintw(win, l++, 2, "2: [%c] HT20",
		CHECKED(conf.channel_set_width == CHAN_WIDTH_20));
	mvwprintw(win, l++, 2, "4: [%c] HT40-",
		CHECKED(conf.channel_set_width == CHAN_WIDTH_40 && !conf.channel_set_ht40plus));
	mvwprintw(win, l++, 2, "5: [%c] HT40+",
		CHECKED(conf.channel_set_width == CHAN_WIDTH_40 && conf.channel_set_ht40plus));
	mvwprintw(win, l++, 2, "8: [%c] VHT80",
		CHECKED(conf.channel_set_width == CHAN_WIDTH_80));
	mvwprintw(win, l++, 2, "6: [%c] VHT160",
		CHECKED(conf.channel_set_width == CHAN_WIDTH_160));

	print_centered(win, CHANNEL_WIN_HEIGHT-1, CHANNEL_WIN_WIDTH,
		       "[ Press key or ENTER ]");
	wrefresh(win);
}