The net80211 ioctl which ifconfig is using to obtain a list of all
supported channels is using a struct name that belongs to the kernel.
Fix this by renaming struct ieee80211_channel to struct ieee80211_chaninfo
in ieee80211_ioctl.h. The way this is done here keeps both old and new
ifconfig binaries happy.
Passes make release on amd64.
I don't expect fallout in ports from this, though just in case I will
wait for a build which sthen@ is running.
diff a6aa266c049fd224e816ccc36f6389e99b7c2826
7025912fb0f6924813974534ab33fc115d2f7369
blob - 8ee7b194d0be49a83771d72fe554b638fd116fdd
blob + 901c8412fd6d51a104b88a98850fc54132d54211
--- sbin/ifconfig/ifconfig.c
+++ sbin/ifconfig/ifconfig.c
@@ -116,6 +116,10 @@
#include "ifconfig.h"
+#ifndef nitems
+#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
+#endif
+
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
@@ -2670,7 +2674,7 @@ join_status(void)
void
ieee80211_listchans(void)
{
- static struct ieee80211_channel chans[256+1];
+ static struct ieee80211_chaninfo chans[256];
struct ieee80211_chanreq_all ca;
int i;
@@ -2684,11 +2688,11 @@ ieee80211_listchans(void)
return;
}
printf("\t\t%4s %-8s %s\n", "chan", "freq", "properties");
- for (i = 1; i <= 256; i++) {
- if (chans[i].ic_flags == 0)
+ for (i = 1; i < nitems(chans); i++) {
+ if (chans[i].ic_freq == 0)
continue;
printf("\t\t%4d %4d MHz ", i, chans[i].ic_freq);
- if (chans[i].ic_flags & IEEE80211_CHAN_PASSIVE)
+ if (chans[i].ic_flags & IEEE80211_CHANINFO_PASSIVE)
printf("passive scan");
else
putchar('-');
blob - e3da39394d224807bec39c777026f26e2a3022ba
blob + 64731538bdb47877bfce0bc3daa8d61d40de4bae
--- sys/net80211/ieee80211_ioctl.c
+++ sys/net80211/ieee80211_ioctl.c
@@ -469,6 +469,8 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t
struct ieee80211_nodereq *nr, nrbuf;
struct ieee80211_nodereq_all *na;
struct ieee80211_node *ni;
+ struct ieee80211_chaninfo chaninfo;
+ struct ieee80211_chanreq_all *allchans;
u_int32_t flags;
switch (cmd) {
@@ -791,9 +793,22 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t
chanreq->i_channel = ieee80211_chan2ieee(ic, chan);
break;
case SIOCG80211ALLCHANS:
- error = copyout(ic->ic_channels,
- ((struct ieee80211_chanreq_all *)data)->i_chans,
- sizeof(ic->ic_channels));
+ allchans = (struct ieee80211_chanreq_all *)data;
+ for (i = 0; i <= IEEE80211_CHAN_MAX; i++) {
+ chan = &ic->ic_channels[i];
+ chaninfo.ic_freq = chan->ic_freq;
+ chaninfo.ic_flags = 0;
+ if (chan->ic_flags & IEEE80211_CHAN_2GHZ)
+ chaninfo.ic_flags |= IEEE80211_CHANINFO_2GHZ;
+ if (chan->ic_flags & IEEE80211_CHAN_5GHZ)
+ chaninfo.ic_flags |= IEEE80211_CHANINFO_5GHZ;
+ if (chan->ic_flags & IEEE80211_CHAN_PASSIVE)
+ chaninfo.ic_flags |= IEEE80211_CHANINFO_PASSIVE;
+ error = copyout(&chaninfo, &allchans->i_chans[i],
+ sizeof(chaninfo));
+ if (error)
+ break;
+ }
break;
#if 0
case SIOCG80211ZSTATS:
blob - 20647ca5ee94709bb6bcbe5cb596e3b9270e4b8a
blob + bcfe3141aaa9286ceee30453614650c82d84ba9b
--- sys/net80211/ieee80211_ioctl.h
+++ sys/net80211/ieee80211_ioctl.h
@@ -161,31 +161,24 @@ struct ieee80211chanreq {
u_int16_t i_channel;
};
-#ifndef _KERNEL
/*
* Channels are specified by frequency and attributes.
*/
-struct ieee80211_channel {
+struct ieee80211_chaninfo {
u_int16_t ic_freq; /* setting in MHz */
u_int16_t ic_flags; /* see below */
};
/*
- * Channel attributes (XXX must keep in sync with radiotap flags).
+ * Channel attributes.
*/
-#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
-#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
-#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel */
-#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
-#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
-#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
-#define IEEE80211_CHAN_XR 0x1000 /* Extended range OFDM channel */
-#define IEEE80211_CHAN_HT 0x2000 /* 11n/HT channel */
-#endif /* !_KERNEL */
+#define IEEE80211_CHANINFO_2GHZ 0x0080 /* 2 GHz spectrum
channel */
+#define IEEE80211_CHANINFO_5GHZ 0x0100 /* 5 GHz spectrum
channel */
+#define IEEE80211_CHANINFO_PASSIVE 0x0200 /* Only passive scan allowed */
struct ieee80211_chanreq_all {
char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
- struct ieee80211_channel *i_chans;
+ struct ieee80211_chaninfo *i_chans; /* array of 256 elements */
};
#ifndef IEEE80211_CHAN_ANY