PERFORCE change 66380 for review
Sam Leffler
sam at FreeBSD.org
Fri Dec 3 16:57:31 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=66380
Change 66380 by sam at sam_ebb on 2004/12/04 00:57:02
suppress more meaningless status by default
Affected files ...
.. //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#26 edit
Differences ...
==== //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#26 (text+ko) ====
@@ -1178,6 +1178,31 @@
return 0;
}
+static const struct ieee80211_channel *
+getchaninfo(int s, int chan)
+{
+ struct ieee80211req ireq;
+ static struct ieee80211req_chaninfo chans;
+ static struct ieee80211_channel undef;
+ const struct ieee80211_channel *c;
+ int i, freq;
+
+ (void) memset(&ireq, 0, sizeof(ireq));
+ (void) strncpy(ireq.i_name, name, sizeof(ireq.i_name));
+ ireq.i_type = IEEE80211_IOC_CHANINFO;
+ ireq.i_data = &chans;
+ ireq.i_len = sizeof(chans);
+ if (ioctl(s, SIOCG80211, &ireq) < 0)
+ errx(1, "unable to get channel information");
+ freq = ieee80211_ieee2mhz(chan);
+ for (i = 0; i < chans.ic_nchans; i++) {
+ c = &chans.ic_chans[i];
+ if (c->ic_freq == freq)
+ return c;
+ }
+ return &undef;
+}
+
static void
ieee80211_status(int s, const struct rt_addrinfo *info __unused)
{
@@ -1186,6 +1211,7 @@
int i, num, wpa, wme;
struct ieee80211req ireq;
u_int8_t data[32];
+ const struct ieee80211_channel *c;
char spacer;
(void) memset(&ireq, 0, sizeof(ireq));
@@ -1219,10 +1245,11 @@
ireq.i_type = IEEE80211_IOC_CHANNEL;
if (ioctl(s, SIOCG80211, &ireq) < 0)
goto end;
+ c = getchaninfo(s, ireq.i_val);
if (ireq.i_val != -1) {
printf(" channel %d", ireq.i_val);
if (verbose)
- printf(" (%u)", ieee80211_ieee2mhz(ireq.i_val));
+ printf(" (%u)", c->ic_freq);
} else if (verbose)
printf(" channel UNDEF");
@@ -1361,27 +1388,27 @@
ireq.i_type = IEEE80211_IOC_POWERSAVE;
if (ioctl(s, SIOCG80211, &ireq) != -1 &&
ireq.i_val != IEEE80211_POWERSAVE_NOSUP ) {
- printf("%cpowersavemode", spacer);
- spacer = ' ';
- switch (ireq.i_val) {
- case IEEE80211_POWERSAVE_OFF:
- printf(" OFF");
- break;
- case IEEE80211_POWERSAVE_CAM:
- printf(" CAM");
- break;
- case IEEE80211_POWERSAVE_PSP:
- printf(" PSP");
- break;
- case IEEE80211_POWERSAVE_PSP_CAM:
- printf(" PSP-CAM");
- break;
- }
-
- ireq.i_type = IEEE80211_IOC_POWERSAVESLEEP;
- if (ioctl(s, SIOCG80211, &ireq) != -1) {
- if (ireq.i_val)
+ if (ireq.i_val != IEEE80211_POWERSAVE_OFF || verbose) {
+ printf("%cpowersavemode", spacer);
+ switch (ireq.i_val) {
+ case IEEE80211_POWERSAVE_OFF:
+ printf(" OFF");
+ break;
+ case IEEE80211_POWERSAVE_CAM:
+ printf(" CAM");
+ break;
+ case IEEE80211_POWERSAVE_PSP:
+ printf(" PSP");
+ break;
+ case IEEE80211_POWERSAVE_PSP_CAM:
+ printf(" PSP-CAM");
+ break;
+ }
+ ireq.i_type = IEEE80211_IOC_POWERSAVESLEEP;
+ if (ioctl(s, SIOCG80211, &ireq) != -1) {
printf(" powersavesleep %d", ireq.i_val);
+ }
+ spacer = ' ';
}
}
@@ -1409,24 +1436,26 @@
spacer = ' ';
}
- ireq.i_type = IEEE80211_IOC_PROTMODE;
- if (ioctl(s, SIOCG80211, &ireq) != -1) {
- printf("%cprotmode ", spacer);
- switch (ireq.i_val) {
- case IEEE80211_PROTMODE_OFF:
- printf("OFF");
- break;
- case IEEE80211_PROTMODE_CTS:
- printf("CTS");
- break;
- case IEEE80211_PROTMODE_RTSCTS:
- printf("RTSCTS");
- break;
- default:
- printf("UNKNOWN (0x%x)", ireq.i_val);
- break;
+ if (IEEE80211_IS_CHAN_G(c) || IEEE80211_IS_CHAN_PUREG(c) || verbose) {
+ ireq.i_type = IEEE80211_IOC_PROTMODE;
+ if (ioctl(s, SIOCG80211, &ireq) != -1) {
+ printf("%cprotmode ", spacer);
+ switch (ireq.i_val) {
+ case IEEE80211_PROTMODE_OFF:
+ printf("OFF");
+ break;
+ case IEEE80211_PROTMODE_CTS:
+ printf("CTS");
+ break;
+ case IEEE80211_PROTMODE_RTSCTS:
+ printf("RTSCTS");
+ break;
+ default:
+ printf("UNKNOWN (0x%x)", ireq.i_val);
+ break;
+ }
+ spacer = ' ';
}
- spacer = ' ';
}
ireq.i_type = IEEE80211_IOC_WME;
@@ -1473,22 +1502,24 @@
} else {
ireq.i_type = IEEE80211_IOC_ROAMING;
if (ioctl(s, SIOCG80211, &ireq) != -1) {
- printf("%croaming ", spacer);
- switch (ireq.i_val) {
- case IEEE80211_ROAMING_DEVICE:
- printf("DEVICE");
- break;
- case IEEE80211_ROAMING_AUTO:
- printf("AUTO");
- break;
- case IEEE80211_ROAMING_MANUAL:
- printf("MANUAL");
- break;
- default:
- printf("UNKNOWN (0x%x)", ireq.i_val);
- break;
+ if (ireq.i_val != IEEE80211_ROAMING_AUTO || verbose) {
+ printf("%croaming ", spacer);
+ switch (ireq.i_val) {
+ case IEEE80211_ROAMING_DEVICE:
+ printf("DEVICE");
+ break;
+ case IEEE80211_ROAMING_AUTO:
+ printf("AUTO");
+ break;
+ case IEEE80211_ROAMING_MANUAL:
+ printf("MANUAL");
+ break;
+ default:
+ printf("UNKNOWN (0x%x)", ireq.i_val);
+ break;
+ }
+ spacer = ' ';
}
- spacer = ' ';
}
}
ireq.i_type = IEEE80211_IOC_BEACON_INTERVAL;
More information about the p4-projects
mailing list