PERFORCE change 64982 for review

Sam Leffler sam at FreeBSD.org
Fri Nov 12 15:40:32 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=64982

Change 64982 by sam at sam_ebb on 2004/11/12 23:39:47

	o must check ic_sta before referencing it
	o cleanup some aspects of channel handling in get+set channel

Affected files ...

.. //depot/projects/wifi/sys/net80211/ieee80211_ioctl.c#13 edit

Differences ...

==== //depot/projects/wifi/sys/net80211/ieee80211_ioctl.c#13 (text+ko) ====

@@ -789,13 +789,10 @@
 	switch (ic->ic_state) {
 	case IEEE80211_S_INIT:
 	case IEEE80211_S_SCAN:
-		if (ic->ic_opmode == IEEE80211_M_STA)
-			return ic->ic_des_chan;
-		break;
+		return ic->ic_des_chan;
 	default:
-		break;
+		return ic->ic_ibss_chan;
 	}
-	return ic->ic_ibss_chan;
 }
 
 static int
@@ -1356,10 +1353,13 @@
 			ni = ic->ic_bss;
 			if (!IEEE80211_ADDR_EQ(ik.ik_macaddr, ni->ni_bssid))
 				return EADDRNOTAVAIL;
-		} else
+		} else {
+			if (ic->ic_sta == NULL)
+				return EINVAL;
 			ni = ieee80211_find_node(ic->ic_sta, ik.ik_macaddr);
-		if (ni == NULL)
-			return ENOENT;
+			if (ni == NULL)
+				return ENOENT;
+		}
 		wk = &ni->ni_ucastkey;
 	} else {
 		if (kid >= IEEE80211_WEP_NKID)
@@ -1474,6 +1474,8 @@
 				mlme.im_reason);
 			break;
 		case IEEE80211_M_HOSTAP:
+			if (ic->ic_sta == NULL)
+				return EINVAL;
 			ni = ieee80211_find_node(ic->ic_sta, mlme.im_macaddr);
 			if (ni == NULL)
 				return EINVAL;
@@ -1491,6 +1493,8 @@
 	case IEEE80211_MLME_UNAUTHORIZE:
 		if (ic->ic_opmode != IEEE80211_M_HOSTAP)
 			return EINVAL;
+		if (ic->ic_sta == NULL)
+			return EINVAL;
 		ni = ieee80211_find_node(ic->ic_sta, mlme.im_macaddr);
 		if (ni == NULL)
 			return EINVAL;
@@ -1737,14 +1741,15 @@
 			error = ENETRESET;
 			break;
 		default:
-			if (ic->ic_opmode == IEEE80211_M_STA) {
-				if (ic->ic_des_chan != IEEE80211_CHAN_ANYC &&
-				    ic->ic_bss->ni_chan != ic->ic_des_chan)
-					error = ENETRESET;
-			} else {
-				if (ic->ic_bss->ni_chan != ic->ic_ibss_chan)
-					error = ENETRESET;
-			}
+			/*
+			 * If the desired channel has changed (to something
+			 * other than any) and we're not already scanning,
+			 * then kick the state machine.
+			 */
+			if (ic->ic_des_chan != IEEE80211_CHAN_ANYC &&
+			    ic->ic_bss->ni_chan != ic->ic_des_chan &&
+			    (ic->ic_flags & IEEE80211_F_SCAN) == 0)
+				error = ENETRESET;
 			break;
 		}
 		if (error == ENETRESET && ic->ic_opmode == IEEE80211_M_MONITOR)
@@ -1959,7 +1964,7 @@
 		if (ic->ic_opmode == IEEE80211_M_HOSTAP)
 			break;
 		error = ieee80211_setupscan(ic, ic->ic_chan_avail);
-		if (error == 0)
+		if (error == 0)		/* XXX background scan */
 			error = ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
 		break;
 	case IEEE80211_IOC_MACCMD:


More information about the p4-projects mailing list