PERFORCE change 64987 for review
Sam Leffler
sam at FreeBSD.org
Fri Nov 12 17:23:37 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=64987
Change 64987 by sam at sam_ebb on 2004/11/13 01:23:23
list chan
list caps
Affected files ...
.. //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#10 edit
Differences ...
==== //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#10 (text+ko) ====
@@ -767,9 +767,88 @@
} while (len >= sizeof(struct ieee80211req_sta_info));
}
+#include <net80211/ieee80211_radiotap.h>
+
+/*
+ * Useful combinations of channel characteristics.
+ */
+#define IEEE80211_CHAN_FHSS \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
+#define IEEE80211_CHAN_A \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_B \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
+#define IEEE80211_CHAN_PUREG \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_T \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+
+#define IEEE80211_IS_CHAN_FHSS(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
+#define IEEE80211_IS_CHAN_A(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
+#define IEEE80211_IS_CHAN_B(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
+#define IEEE80211_IS_CHAN_PUREG(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
+#define IEEE80211_IS_CHAN_G(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
+#define IEEE80211_IS_CHAN_T(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_T) == IEEE80211_CHAN_T)
+#define IEEE80211_IS_CHAN_PASSIVE(_c) \
+ (((_c)->ic_flags & IEEE80211_CHAN_PASSIVE))
+
+static void
+print_chaninfo(const struct ieee80211_chaninfo *c)
+{
+ char buf[14];
+
+ buf[0] = '\0';
+ if (IEEE80211_IS_CHAN_FHSS(c))
+ strlcat(buf, " FHSS", sizeof(buf));
+ if (IEEE80211_IS_CHAN_A(c))
+ strlcat(buf, " 11a", sizeof(buf));
+ /* XXX 11g schizophrenia */
+ if (IEEE80211_IS_CHAN_G(c) ||
+ IEEE80211_IS_CHAN_PUREG(c))
+ strlcat(buf, " 11g", sizeof(buf));
+ else if (IEEE80211_IS_CHAN_B(c))
+ strlcat(buf, " 11b", sizeof(buf));
+ if (IEEE80211_IS_CHAN_T(c))
+ strlcat(buf, " Turbo", sizeof(buf));
+ printf("Channel %3u : %u%c Mhz%-14.14s",
+ ieee80211_mhz2ieee(c->ic_freq), c->ic_freq,
+ IEEE80211_IS_CHAN_PASSIVE(c) ? '*' : ' ', buf);
+}
+
static void
list_channels(int s)
{
+ struct ieee80211req ireq;
+ struct ieee80211req_chaninfo chans;
+ int i, half;
+
+ (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");
+ half = chans.ic_nchans / 2;
+ if (chans.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]);
+ printf("\n");
+ }
+ if (chans.ic_nchans % 2) {
+ print_chaninfo(&chans.ic_chans[i]);
+ printf("\n");
+ }
}
static void
@@ -777,9 +856,24 @@
{
}
+#define IEEE80211_C_BITS \
+"\020\1WEP\2TKIP\3AES\4AES_CCM\6CKIP\7IBSS\12PMGT\13HOSTAP\14AHDEMO\15SWRETRY" \
+"\16TXPMGT\17SHSLOT\20SHPREAMBLE\21MONITOR\22TKIPMIC\30WPA1\31WPA2"
+
static void
list_capabilities(int s)
{
+ struct ieee80211req ireq;
+ u_int32_t caps;
+
+ (void) memset(&ireq, 0, sizeof(ireq));
+ (void) strncpy(ireq.i_name, name, sizeof(ireq.i_name));
+ ireq.i_type = IEEE80211_IOC_DRIVER_CAPS;
+ if (ioctl(s, SIOCG80211, &ireq) < 0)
+ errx(1, "unable to get driver capabilities");
+ caps = (((u_int16_t) ireq.i_val) << 16) | ((u_int16_t) ireq.i_len);
+ printb(name, caps, IEEE80211_C_BITS);
+ putchar('\n');
}
static void
More information about the p4-projects
mailing list