svn commit: r187502 - user/sam/wifi/sys/net80211

Sam Leffler sam at FreeBSD.org
Tue Jan 20 15:06:07 PST 2009


Author: sam
Date: Tue Jan 20 23:06:06 2009
New Revision: 187502
URL: http://svn.freebsd.org/changeset/base/187502

Log:
  remove dependency on max #'s channels for IEEE80211_IOC_CHANLIST (set)

Modified:
  user/sam/wifi/sys/net80211/ieee80211_ioctl.c
  user/sam/wifi/sys/net80211/ieee80211_ioctl.h

Modified: user/sam/wifi/sys/net80211/ieee80211_ioctl.c
==============================================================================
--- user/sam/wifi/sys/net80211/ieee80211_ioctl.c	Tue Jan 20 22:49:49 2009	(r187501)
+++ user/sam/wifi/sys/net80211/ieee80211_ioctl.c	Tue Jan 20 23:06:06 2009	(r187502)
@@ -1571,17 +1571,21 @@ static __noinline int
 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, nchan, error;
+	uint8_t *chanlist, *list;
+	int i, nchan, maxchan, error;
 
-	if (ireq->i_len != sizeof(list))
-		return EINVAL;
-	error = copyin(ireq->i_data, &list, sizeof(list));
+	if (ireq->i_len > sizeof(ic->ic_chan_active))
+		ireq->i_len = sizeof(ic->ic_chan_active);
+	list = malloc(ireq->i_len + IEEE80211_CHAN_BYTES, M_TEMP,
+	    M_NOWAIT | M_ZERO);
+	if (list == NULL)
+		return ENOMEM;
+	error = copyin(ireq->i_data, list, ireq->i_len);
 	if (error)
 		return error;
-	memset(chanlist, 0, sizeof(chanlist));
 	nchan = 0;
+	chanlist = list + ireq->i_len;		/* NB: zero'd already */
+	maxchan = ireq->i_len * NBBY;
 	for (i = 0; i < ic->ic_nchans; i++) {
 		const struct ieee80211_channel *c = &ic->ic_channels[i];
 		/*
@@ -1589,7 +1593,7 @@ ieee80211_ioctl_setchanlist(struct ieee8
 		 * available channels so users can do things like specify
 		 * 1-255 to get all available channels.
 		 */
-		if (isset(list.ic_channels, c->ic_ieee)) {
+		if (c->ic_ieee < maxchan && isset(list, c->ic_ieee)) {
 			setbit(chanlist, c->ic_ieee);
 			nchan++;
 		}
@@ -1599,8 +1603,9 @@ ieee80211_ioctl_setchanlist(struct ieee8
 	if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&	/* XXX */
 	    isclr(chanlist, ic->ic_bsschan->ic_ieee))
 		ic->ic_bsschan = IEEE80211_CHAN_ANYC;
-	memcpy(ic->ic_chan_active, chanlist, sizeof(ic->ic_chan_active));
+	memcpy(ic->ic_chan_active, chanlist, IEEE80211_CHAN_BYTES);
 	ieee80211_scan_flush(vap);
+	free(list, M_TEMP);
 	return ENETRESET;
 }
 

Modified: user/sam/wifi/sys/net80211/ieee80211_ioctl.h
==============================================================================
--- user/sam/wifi/sys/net80211/ieee80211_ioctl.h	Tue Jan 20 22:49:49 2009	(r187501)
+++ user/sam/wifi/sys/net80211/ieee80211_ioctl.h	Tue Jan 20 23:06:06 2009	(r187502)
@@ -299,13 +299,13 @@ struct ieee80211req_maclist {
 };
 
 /*
- * Set the active channel list.  Note this list is
- * intersected with the available channel list in
- * calculating the set of channels actually used in
- * scanning.
+ * Set the active channel list by IEEE channel #: each channel
+ * to be marked active is set in a bit vector.  Note this list is
+ * intersected with the available channel list in calculating
+ * the set of channels actually used in scanning.
  */
 struct ieee80211req_chanlist {
-	uint8_t		ic_channels[IEEE80211_CHAN_BYTES];
+	uint8_t		ic_channels[32];	/* NB: can be variable length */
 };
 
 /*


More information about the svn-src-user mailing list