Date: Mon, 15 Dec 2008 01:26:33 +0000 (UTC) From: Sam Leffler <sam@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r186107 - head/sys/net80211 Message-ID: <200812150126.mBF1QXtt080174@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sam Date: Mon Dec 15 01:26:33 2008 New Revision: 186107 URL: http://svn.freebsd.org/changeset/base/186107 Log: Fix definition of IEEE80211_CHAN_MAX; it was defined as 255 but really was meant to be 256. Adjust usage accordingly and replace bogus usage of this value in checking IEEE channel #'s. NB: this causes an ABI change; ifconfig must be recompiled Modified: head/sys/net80211/_ieee80211.h head/sys/net80211/ieee80211.c head/sys/net80211/ieee80211_ddb.c head/sys/net80211/ieee80211_dfs.h head/sys/net80211/ieee80211_input.c head/sys/net80211/ieee80211_ioctl.c head/sys/net80211/ieee80211_regdomain.c head/sys/net80211/ieee80211_scan_sta.c head/sys/net80211/ieee80211_var.h Modified: head/sys/net80211/_ieee80211.h ============================================================================== --- head/sys/net80211/_ieee80211.h Mon Dec 15 01:18:11 2008 (r186106) +++ head/sys/net80211/_ieee80211.h Mon Dec 15 01:26:33 2008 (r186107) @@ -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 \ Modified: head/sys/net80211/ieee80211.c ============================================================================== --- head/sys/net80211/ieee80211.c Mon Dec 15 01:18:11 2008 (r186106) +++ head/sys/net80211/ieee80211.c Mon Dec 15 01:26:33 2008 (r186107) @@ -118,7 +118,7 @@ ieee80211_chan_init(struct ieee80211com 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 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. Modified: head/sys/net80211/ieee80211_ddb.c ============================================================================== --- head/sys/net80211/ieee80211_ddb.c Mon Dec 15 01:18:11 2008 (r186106) +++ head/sys/net80211/ieee80211_ddb.c Mon Dec 15 01:26:33 2008 (r186107) @@ -542,7 +542,7 @@ _db_show_com(const struct ieee80211com * */ 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]; Modified: head/sys/net80211/ieee80211_dfs.h ============================================================================== --- head/sys/net80211/ieee80211_dfs.h Mon Dec 15 01:18:11 2008 (r186106) +++ head/sys/net80211/ieee80211_dfs.h Mon Dec 15 01:26:33 2008 (r186107) @@ -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 */ Modified: head/sys/net80211/ieee80211_input.c ============================================================================== --- head/sys/net80211/ieee80211_input.c Mon Dec 15 01:18:11 2008 (r186106) +++ head/sys/net80211/ieee80211_input.c Mon Dec 15 01:26:33 2008 (r186107) @@ -673,14 +673,6 @@ ieee80211_parse_beacon(struct ieee80211_ } 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 Modified: head/sys/net80211/ieee80211_ioctl.c ============================================================================== --- head/sys/net80211/ieee80211_ioctl.c Mon Dec 15 01:18:11 2008 (r186106) +++ head/sys/net80211/ieee80211_ioctl.c Mon Dec 15 01:26:33 2008 (r186107) @@ -1556,7 +1556,7 @@ ieee80211_ioctl_setchanlist(struct ieee8 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 ieee8 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 ieee80 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; Modified: head/sys/net80211/ieee80211_regdomain.c ============================================================================== --- head/sys/net80211/ieee80211_regdomain.c Mon Dec 15 01:18:11 2008 (r186106) +++ head/sys/net80211/ieee80211_regdomain.c Mon Dec 15 01:26:33 2008 (r186107) @@ -338,7 +338,7 @@ ieee80211_setregdomain(struct ieee80211v 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); Modified: head/sys/net80211/ieee80211_scan_sta.c ============================================================================== --- head/sys/net80211/ieee80211_scan_sta.c Mon Dec 15 01:18:11 2008 (r186106) +++ head/sys/net80211/ieee80211_scan_sta.c Mon Dec 15 01:26:33 2008 (r186107) @@ -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_st /* 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 */ Modified: head/sys/net80211/ieee80211_var.h ============================================================================== --- head/sys/net80211/ieee80211_var.h Mon Dec 15 01:18:11 2008 (r186106) +++ head/sys/net80211/ieee80211_var.h Mon Dec 15 01:26:33 2008 (r186107) @@ -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];
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812150126.mBF1QXtt080174>