diff options
-rw-r--r-- | sys/net80211/_ieee80211.h | 2 | ||||
-rw-r--r-- | sys/net80211/ieee80211.c | 4 | ||||
-rw-r--r-- | sys/net80211/ieee80211_ddb.c | 2 | ||||
-rw-r--r-- | sys/net80211/ieee80211_dfs.h | 2 | ||||
-rw-r--r-- | sys/net80211/ieee80211_input.c | 8 | ||||
-rw-r--r-- | sys/net80211/ieee80211_ioctl.c | 24 | ||||
-rw-r--r-- | sys/net80211/ieee80211_regdomain.c | 2 | ||||
-rw-r--r-- | sys/net80211/ieee80211_scan_sta.c | 7 | ||||
-rw-r--r-- | sys/net80211/ieee80211_var.h | 2 |
9 files changed, 20 insertions, 33 deletions
diff --git a/sys/net80211/_ieee80211.h b/sys/net80211/_ieee80211.h index b735b5c..f5858fe 100644 --- a/sys/net80211/_ieee80211.h +++ b/sys/net80211/_ieee80211.h @@ -137,7 +137,7 @@ struct ieee80211_channel { uint8_t ic_extieee; /* HT40 extension channel number */ }; -#define IEEE80211_CHAN_MAX 255 +#define IEEE80211_CHAN_MAX 256 #define IEEE80211_CHAN_BYTES 32 /* howmany(IEEE80211_CHAN_MAX, NBBY) */ #define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */ #define IEEE80211_CHAN_ANYC \ diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index cce1312..e0a9432 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -118,7 +118,7 @@ ieee80211_chan_init(struct ieee80211com *ic) struct ieee80211_channel *c; int i; - KASSERT(0 < ic->ic_nchans && ic->ic_nchans < IEEE80211_CHAN_MAX, + KASSERT(0 < ic->ic_nchans && ic->ic_nchans <= IEEE80211_CHAN_MAX, ("invalid number of channels specified: %u", ic->ic_nchans)); memset(ic->ic_chan_avail, 0, sizeof(ic->ic_chan_avail)); memset(ic->ic_modecaps, 0, sizeof(ic->ic_modecaps)); @@ -126,8 +126,6 @@ ieee80211_chan_init(struct ieee80211com *ic) for (i = 0; i < ic->ic_nchans; i++) { c = &ic->ic_channels[i]; KASSERT(c->ic_flags != 0, ("channel with no flags")); - KASSERT(c->ic_ieee < IEEE80211_CHAN_MAX, - ("channel with bogus ieee number %u", c->ic_ieee)); setbit(ic->ic_chan_avail, c->ic_ieee); /* * Identify mode capabilities. diff --git a/sys/net80211/ieee80211_ddb.c b/sys/net80211/ieee80211_ddb.c index 8334d77..59c6a46 100644 --- a/sys/net80211/ieee80211_ddb.c +++ b/sys/net80211/ieee80211_ddb.c @@ -542,7 +542,7 @@ _db_show_com(const struct ieee80211com *ic, int showvaps, int showsta, int showp */ db_printf("\tnchans %d", ic->ic_nchans); #if 0 - struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1]; + struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX]; uint8_t ic_chan_avail[IEEE80211_CHAN_BYTES]; uint8_t ic_chan_active[IEEE80211_CHAN_BYTES]; uint8_t ic_chan_scan[IEEE80211_CHAN_BYTES]; diff --git a/sys/net80211/ieee80211_dfs.h b/sys/net80211/ieee80211_dfs.h index 36d14aa..9076077 100644 --- a/sys/net80211/ieee80211_dfs.h +++ b/sys/net80211/ieee80211_dfs.h @@ -32,7 +32,7 @@ */ struct ieee80211_dfs_state { - int nol_event[IEEE80211_CHAN_MAX+1]; + int nol_event[IEEE80211_CHAN_MAX]; struct callout nol_timer; /* NOL list processing */ struct callout cac_timer; /* CAC timer */ struct timeval lastevent; /* time of last radar event */ diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index e72a2a2..528587b 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -673,14 +673,6 @@ ieee80211_parse_beacon(struct ieee80211_node *ni, struct mbuf *m, } IEEE80211_VERIFY_ELEMENT(scan->ssid, IEEE80211_NWID_LEN, scan->status |= IEEE80211_BPARSE_SSID_INVALID); -#if IEEE80211_CHAN_MAX < 255 - if (scan->chan > IEEE80211_CHAN_MAX) { - IEEE80211_DISCARD(vap, IEEE80211_MSG_ELEMID, - wh, NULL, "invalid channel %u", scan->chan); - vap->iv_stats.is_rx_badchan++; - scan->status |= IEEE80211_BPARSE_CHAN_INVALID; - } -#endif if (scan->chan != scan->bchan && ic->ic_phytype != IEEE80211_T_FH) { /* * Frame was received on a channel different from the diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index ae39fd6..797ed8f 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -1556,7 +1556,7 @@ ieee80211_ioctl_setchanlist(struct ieee80211vap *vap, struct ieee80211req *ireq) struct ieee80211com *ic = vap->iv_ic; struct ieee80211req_chanlist list; u_char chanlist[IEEE80211_CHAN_BYTES]; - int i, j, nchan, error; + int i, nchan, error; if (ireq->i_len != sizeof(list)) return EINVAL; @@ -1564,22 +1564,16 @@ ieee80211_ioctl_setchanlist(struct ieee80211vap *vap, struct ieee80211req *ireq) if (error) return error; memset(chanlist, 0, sizeof(chanlist)); - /* - * Since channel 0 is not available for DS, channel 1 - * is assigned to LSB on WaveLAN. - */ - if (ic->ic_phytype == IEEE80211_T_DS) - i = 1; - else - i = 0; nchan = 0; - for (j = 0; i <= IEEE80211_CHAN_MAX; i++, j++) { + for (i = 0; i < ic->ic_nchans; i++) { + const struct ieee80211_channel *c = &ic->ic_channels[i]; /* - * NB: silently discard unavailable channels so users - * can specify 1-255 to get all available channels. + * Calculate the intersection of the user list and the + * available channels so users can do things like specify + * 1-255 to get all available channels. */ - if (isset(list.ic_channels, j) && isset(ic->ic_chan_avail, i)) { - setbit(chanlist, i); + if (isset(list.ic_channels, c->ic_ieee)) { + setbit(chanlist, c->ic_ieee); nchan++; } } @@ -1890,8 +1884,6 @@ ieee80211_ioctl_setchannel(struct ieee80211vap *vap, if (ireq->i_val == 0 || ireq->i_val == (int16_t) IEEE80211_CHAN_ANY) { c = IEEE80211_CHAN_ANYC; - } else if ((u_int) ireq->i_val > IEEE80211_CHAN_MAX) { - return EINVAL; } else { struct ieee80211_channel *c2; diff --git a/sys/net80211/ieee80211_regdomain.c b/sys/net80211/ieee80211_regdomain.c index 0e41355..724d00b 100644 --- a/sys/net80211/ieee80211_regdomain.c +++ b/sys/net80211/ieee80211_regdomain.c @@ -338,7 +338,7 @@ ieee80211_setregdomain(struct ieee80211vap *vap, reg->rd.isocc[0], reg->rd.isocc[1]); return EINVAL; } - if (reg->chaninfo.ic_nchans >= IEEE80211_CHAN_MAX) { + if (reg->chaninfo.ic_nchans > IEEE80211_CHAN_MAX) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_IOCTL, "%s: too many channels %u, max %u\n", __func__, reg->chaninfo.ic_nchans, IEEE80211_CHAN_MAX); diff --git a/sys/net80211/ieee80211_scan_sta.c b/sys/net80211/ieee80211_scan_sta.c index e3a4bda..f722d6b 100644 --- a/sys/net80211/ieee80211_scan_sta.c +++ b/sys/net80211/ieee80211_scan_sta.c @@ -87,6 +87,9 @@ struct sta_entry { #define STA_HASH(addr) \ (((const uint8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % STA_HASHSIZE) +#define MAX_IEEE_CHAN 256 /* max acceptable IEEE chan # */ +CTASSERT(MAX_IEEE_CHAN >= 256); + struct sta_table { struct mtx st_lock; /* on scan table */ TAILQ_HEAD(, sta_entry) st_entry; /* all entries */ @@ -96,7 +99,7 @@ struct sta_table { u_int st_scangen; /* scan generation # */ int st_newscan; /* ap-related state */ - int st_maxrssi[IEEE80211_CHAN_MAX]; + int st_maxrssi[MAX_IEEE_CHAN]; }; static void sta_flush_table(struct sta_table *); @@ -343,6 +346,7 @@ found: se->se_seen = 1; se->se_notseen = 0; + KASSERT(sizeof(sp->bchan) == 1, ("bchan size")); if (rssi > st->st_maxrssi[sp->bchan]) st->st_maxrssi[sp->bchan] = rssi; @@ -1604,6 +1608,7 @@ ap_pick_channel(struct ieee80211_scan_state *ss, int flags) /* check channel attributes for band compatibility */ if (flags != 0 && (chan->ic_flags & flags) != flags) continue; + KASSERT(sizeof(chan->ic_ieee) == 1, ("ic_chan size")); /* XXX channel have interference */ if (st->st_maxrssi[chan->ic_ieee] == 0) { /* XXX use other considerations */ diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 3e90201..ccd95d0 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -156,7 +156,7 @@ struct ieee80211com { * (e.g. for dynamic turbo) */ int ic_nchans; /* # entries in ic_channels */ - struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX+1]; + struct ieee80211_channel ic_channels[IEEE80211_CHAN_MAX]; uint8_t ic_chan_avail[IEEE80211_CHAN_BYTES]; uint8_t ic_chan_active[IEEE80211_CHAN_BYTES]; uint8_t ic_chan_scan[IEEE80211_CHAN_BYTES]; |