svn commit: r188798 - in projects/vap7/sys: . contrib/pf dev dev/ath dev/ath/ath_hal dev/ath/ath_hal/ar5210 dev/ath/ath_hal/ar5211 dev/ath/ath_hal/ar5212 dev/ath/ath_hal/ar5312 dev/ath/ath_hal/ar54...

Sam Leffler sam at FreeBSD.org
Wed Feb 18 21:51:29 PST 2009


Author: sam
Date: Thu Feb 19 05:51:29 2009
New Revision: 188798
URL: http://svn.freebsd.org/changeset/base/188798

Log:
  merge r188781: prepare for adding new modes

Modified:
  projects/vap7/sys/   (props changed)
  projects/vap7/sys/contrib/pf/   (props changed)
  projects/vap7/sys/dev/   (props changed)
  projects/vap7/sys/dev/ath/   (props changed)
  projects/vap7/sys/dev/ath/ath_hal/   (props changed)
  projects/vap7/sys/dev/ath/ath_hal/ar5210/   (props changed)
  projects/vap7/sys/dev/ath/ath_hal/ar5211/   (props changed)
  projects/vap7/sys/dev/ath/ath_hal/ar5212/   (props changed)
  projects/vap7/sys/dev/ath/ath_hal/ar5312/   (props changed)
  projects/vap7/sys/dev/ath/ath_hal/ar5416/   (props changed)
  projects/vap7/sys/dev/cxgb/   (props changed)
  projects/vap7/sys/dev/usb2/   (props changed)
  projects/vap7/sys/i386/conf/USB2   (props changed)
  projects/vap7/sys/modules/usb2/   (props changed)
  projects/vap7/sys/net80211/   (props changed)
  projects/vap7/sys/net80211/ieee80211_ioctl.c

Modified: projects/vap7/sys/net80211/ieee80211_ioctl.c
==============================================================================
--- projects/vap7/sys/net80211/ieee80211_ioctl.c	Thu Feb 19 05:50:50 2009	(r188797)
+++ projects/vap7/sys/net80211/ieee80211_ioctl.c	Thu Feb 19 05:51:29 2009	(r188798)
@@ -675,19 +675,22 @@ static __noinline int
 ieee80211_ioctl_getroam(struct ieee80211vap *vap,
 	const struct ieee80211req *ireq)
 {
-	if (ireq->i_len != sizeof(vap->iv_roamparms))
-		return EINVAL;
-	return copyout(vap->iv_roamparms, ireq->i_data,
-	    sizeof(vap->iv_roamparms));
+	size_t len = ireq->i_len;
+	/* NB: accept short requests for backwards compat */
+	if (len > sizeof(vap->iv_roamparms))
+		len = sizeof(vap->iv_roamparms);
+	return copyout(vap->iv_roamparms, ireq->i_data, len);
 }
 
 static __noinline int
 ieee80211_ioctl_gettxparams(struct ieee80211vap *vap,
 	const struct ieee80211req *ireq)
 {
-	if (ireq->i_len != sizeof(vap->iv_txparms))
-		return EINVAL;
-	return copyout(vap->iv_txparms, ireq->i_data, sizeof(vap->iv_txparms));
+	size_t len = ireq->i_len;
+	/* NB: accept short requests for backwards compat */
+	if (len > sizeof(vap->iv_txparms))
+		len = sizeof(vap->iv_txparms);
+	return copyout(vap->iv_txparms, ireq->i_data, len);
 }
 
 static __noinline int
@@ -2082,61 +2085,40 @@ ieee80211_ioctl_settxparams(struct ieee8
 	struct ieee80211_txparams_req parms;	/* XXX stack use? */
 	struct ieee80211_txparam *src, *dst;
 	const struct ieee80211_rateset *rs;
-	int error, i, changed;
+	int error, mode, changed, is11n, nmodes;
 
-	if (ireq->i_len != sizeof(parms))
+	/* NB: accept short requests for backwards compat */
+	if (ireq->i_len > sizeof(parms))
 		return EINVAL;
-	error = copyin(ireq->i_data, &parms, sizeof(parms));
+	error = copyin(ireq->i_data, &parms, ireq->i_len);
 	if (error != 0)
 		return error;
+	nmodes = ireq->i_len / sizeof(struct ieee80211_txparam);
 	changed = 0;
 	/* validate parameters and check if anything changed */
-	for (i = IEEE80211_MODE_11A; i < IEEE80211_MODE_11NA; i++) {
-		if (isclr(ic->ic_modecaps, i))
-			continue;
-		src = &parms.params[i];
-		dst = &vap->iv_txparms[i];
-		rs = &ic->ic_sup_rates[i];
-		if (src->ucastrate != dst->ucastrate) {
-			if (!checkrate(rs, src->ucastrate))
-				return EINVAL;
-			changed++;
-		}
-		if (src->mcastrate != dst->mcastrate) {
-			if (!checkrate(rs, src->mcastrate))
-				return EINVAL;
-			changed++;
-		}
-		if (src->mgmtrate != dst->mgmtrate) {
-			if (!checkrate(rs, src->mgmtrate))
-				return EINVAL;
-			changed++;
-		}
-		if (src->maxretry != dst->maxretry)	/* NB: no bounds */
-			changed++;
-	}
-	/* 11n parameters are handled differently */
-	for (; i < IEEE80211_MODE_MAX; i++) {
-		if (isclr(ic->ic_modecaps, i))
+	for (mode = IEEE80211_MODE_11A; mode < nmodes; mode++) {
+		if (isclr(ic->ic_modecaps, mode))
 			continue;
-		src = &parms.params[i];
-		dst = &vap->iv_txparms[i];
-		rs = &ic->ic_sup_rates[i];
+		src = &parms.params[mode];
+		dst = &vap->iv_txparms[mode];
+		rs = &ic->ic_sup_rates[mode];	/* NB: 11n maps to legacy */
+		is11n = (mode == IEEE80211_MODE_11NA ||
+			 mode == IEEE80211_MODE_11NG);
 		if (src->ucastrate != dst->ucastrate) {
-			if (!checkmcs(src->ucastrate) &&
-			    !checkrate(rs, src->ucastrate))
+			if (!checkrate(rs, src->ucastrate) &&
+			    (!is11n || !checkmcs(src->ucastrate)))
 				return EINVAL;
 			changed++;
 		}
 		if (src->mcastrate != dst->mcastrate) {
-			if (!checkmcs(src->mcastrate) &&
-			    !checkrate(rs, src->mcastrate))
+			if (!checkrate(rs, src->mcastrate) &&
+			    (!is11n || !checkmcs(src->mcastrate)))
 				return EINVAL;
 			changed++;
 		}
 		if (src->mgmtrate != dst->mgmtrate) {
-			if (!checkmcs(src->mgmtrate) &&
-			    !checkrate(rs, src->mgmtrate))
+			if (!checkrate(rs, src->mgmtrate) &&
+			    (!is11n || !checkmcs(src->mgmtrate)))
 				return EINVAL;
 			changed++;
 		}
@@ -2148,9 +2130,9 @@ ieee80211_ioctl_settxparams(struct ieee8
 		 * Copy new parameters in place and notify the
 		 * driver so it can push state to the device.
 		 */
-		for (i = IEEE80211_MODE_11A; i < IEEE80211_MODE_MAX; i++) {
-			if (isset(ic->ic_modecaps, i))
-				vap->iv_txparms[i] = parms.params[i];
+		for (mode = IEEE80211_MODE_11A; mode < nmodes; mode++) {
+			if (isset(ic->ic_modecaps, mode))
+				vap->iv_txparms[mode] = parms.params[mode];
 		}
 		/* XXX could be more intelligent,
 		   e.g. don't reset if setting not being used */


More information about the svn-src-projects mailing list