Date: Wed, 24 Nov 2004 02:40:05 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 65759 for review Message-ID: <200411240240.iAO2e5w4092853@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=65759 Change 65759 by sam@sam_ebb on 2004/11/24 02:39:40 add list active to list only active channels Affected files ... .. //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#17 edit Differences ... ==== //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#17 (text+ko) ==== @@ -902,10 +902,12 @@ } static void -list_channels(int s) +list_channels(int s, int allchans) { struct ieee80211req ireq; struct ieee80211req_chaninfo chans; + struct ieee80211req_chaninfo achans; + const struct ieee80211_channel *c; int i, half; (void) memset(&ireq, 0, sizeof(ireq)); @@ -915,16 +917,32 @@ ireq.i_len = sizeof(chans); if (ioctl(s, SIOCG80211, &ireq) < 0) errx(1, "unable to get channel information"); - half = chans.ic_nchans / 2; - if (chans.ic_nchans % 2) + if (!allchans) { + struct ieee80211req_chanlist active; + + ireq.i_type = IEEE80211_IOC_CHANLIST; + ireq.i_data = &active; + ireq.i_len = sizeof(active); + if (ioctl(s, SIOCG80211, &ireq) < 0) + errx(1, "unable to get active channel list"); + memset(&achans, 0, sizeof(achans)); + for (i = 0; i < chans.ic_nchans; i++) { + c = &chans.ic_chans[i]; + if (isset(active.ic_channels, ieee80211_mhz2ieee(c->ic_freq)) || allchans) + achans.ic_chans[achans.ic_nchans++] = *c; + } + } else + achans = chans; + half = achans.ic_nchans / 2; + if (achans.ic_nchans % 2) half++; - for (i = 0; i < chans.ic_nchans / 2; i++) { - print_chaninfo(&chans.ic_chans[i]); - print_chaninfo(&chans.ic_chans[half+i]); + for (i = 0; i < achans.ic_nchans / 2; i++) { + print_chaninfo(&achans.ic_chans[i]); + print_chaninfo(&achans.ic_chans[half+i]); printf("\n"); } - if (chans.ic_nchans % 2) { - print_chaninfo(&chans.ic_chans[i]); + if (achans.ic_nchans % 2) { + print_chaninfo(&achans.ic_chans[i]); printf("\n"); } } @@ -1023,7 +1041,9 @@ else if (iseq(arg, "scan") || iseq(arg, "ap")) list_scan(s); else if (iseq(arg, "chan") || iseq(arg, "freq")) - list_channels(s); + list_channels(s, 1); + else if (iseq(arg, "active")) + list_channels(s, 0); else if (iseq(arg, "keys")) list_keys(s); else if (iseq(arg, "caps"))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411240240.iAO2e5w4092853>