Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Oct 2004 05:43:51 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 63623 for review
Message-ID:  <200410240543.i9O5hplF068376@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=63623

Change 63623 by sam@sam_ebb on 2004/10/24 05:42:53

	Bring in manual roaming mode support from madwifi.  Don't clock
	the 802.11 state machine for many ioctls; instead use the ic_reset
	method to push state into the hardware or defer the operation
	entirely.
	
	Fixup setting authentication mode handling.
	
	Fillin missing bit from new scan ioctl.
	
	With these changes wpa_supplicant is scanning.

Affected files ...

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

Differences ...

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

@@ -67,6 +67,11 @@
 
 #include <dev/wi/if_wavelan_ieee.h>
 
+#define	IS_UP(_ic) \
+	(((_ic)->ic_ifp->if_flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
+#define	IS_UP_AUTO(_ic) \
+	(IS_UP(_ic) && (_ic)->ic_roaming == IEEE80211_ROAMING_AUTO)
+
 /*
  * XXX
  * Wireless LAN specific configuration interface, which is compatible
@@ -401,6 +406,16 @@
 	u_char *chanlist = ic->ic_chan_active;
 	int i;
 
+	/*
+	 * XXX don't permit a scan to be started unless we
+	 * know the device is ready.  For the moment this means
+	 * the device is marked up as this is the required to
+	 * initialize the hardware.  It would be better to permit
+	 * scanning prior to being up but that'll require some
+	 * changes to the infrastructure.
+	 */
+	if (!IS_UP(ic))
+		return EINVAL;
 	if (ic->ic_ibss_chan == NULL ||
 	    isclr(chanlist, ieee80211_chan2ieee(ic, ic->ic_ibss_chan))) {
 		for (i = 0; i <= IEEE80211_CHAN_MAX; i++)
@@ -415,15 +430,7 @@
 	if (ic->ic_bss->ni_chan == IEEE80211_CHAN_ANYC ||
 	    isclr(chanlist, ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan)))
 		ic->ic_bss->ni_chan = ic->ic_ibss_chan;
-	/*
-	 * XXX don't permit a scan to be started unless we
-	 * know the device is ready.  For the moment this means
-	 * the device is marked up as this is the required to
-	 * initialize the hardware.  It would be better to permit
-	 * scanning prior to being up but that'll require some
-	 * changes to the infrastructure.
-	 */
-	return (ic->ic_ifp->if_flags & IFF_UP) ? 0 : ENETRESET;
+	return 0;
 }
 
 int
@@ -469,7 +476,9 @@
 		    isclr(ic->ic_chan_active, i))
 			return EINVAL;
 		ic->ic_ibss_chan = &ic->ic_channels[i];
-		if (ic->ic_flags & IEEE80211_F_SIBSS)
+		if (ic->ic_opmode == IEEE80211_M_MONITOR)
+			error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
+		else
 			error = ENETRESET;
 		break;
 	case WI_RID_CURRENT_CHAN:
@@ -515,7 +524,7 @@
 		}
 		if (le16toh(wreq.wi_val[0]) != ic->ic_opmode) {
 			ic->ic_opmode = le16toh(wreq.wi_val[0]);
-			error = ENETRESET;
+			error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		}
 		break;
 #if 0
@@ -563,7 +572,7 @@
 		return EINVAL;
 	setrate:
 		ic->ic_fixed_rate = i;
-		error = ENETRESET;
+		error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		break;
 	case WI_RID_CUR_TX_RATE:
 		return EPERM;
@@ -583,14 +592,14 @@
 				ic->ic_flags |= IEEE80211_F_IBSSON;
 				if (ic->ic_opmode == IEEE80211_M_IBSS &&
 				    ic->ic_state == IEEE80211_S_SCAN)
-					error = ENETRESET;
+					error = IS_UP_AUTO(ic) ? ENETRESET : 0;
 			}
 		} else {
 			if (ic->ic_flags & IEEE80211_F_IBSSON) {
 				ic->ic_flags &= ~IEEE80211_F_IBSSON;
 				if (ic->ic_flags & IEEE80211_F_SIBSS) {
 					ic->ic_flags &= ~IEEE80211_F_SIBSS;
-					error = ENETRESET;
+					error = IS_UP_AUTO(ic) ? ENETRESET : 0;
 				}
 			}
 		}
@@ -623,12 +632,12 @@
 				return EINVAL;
 			if ((ic->ic_flags & IEEE80211_F_PMGTON) == 0) {
 				ic->ic_flags |= IEEE80211_F_PMGTON;
-				error = ENETRESET;
+				error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 			}
 		} else {
 			if (ic->ic_flags & IEEE80211_F_PMGTON) {
 				ic->ic_flags &= ~IEEE80211_F_PMGTON;
-				error = ENETRESET;
+				error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 			}
 		}
 		break;
@@ -637,7 +646,7 @@
 			return EINVAL;
 		ic->ic_lintval = le16toh(wreq.wi_val[0]);
 		if (ic->ic_flags & IEEE80211_F_PMGTON)
-			error = ENETRESET;
+			error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		break;
 	case WI_RID_CUR_BEACON_INT:
 		return EPERM;
@@ -647,11 +656,10 @@
 		if (len != 2)
 			return EINVAL;
 		i = le16toh(wreq.wi_val[0]);
-		if (i > IEEE80211_AUTH_AUTO)
+		if (i > IEEE80211_AUTH_WPA)
 			return EINVAL;
-#if 0
-		ic->ic_authmode = i;		/* XXX ENETRESET? */
-#endif
+		ic->ic_bss->ni_authmode = i;		/* XXX ENETRESET? */
+		error = ENETRESET;
 		break;
 	case WI_RID_ENCRYPTION:
 		if (len != 2)
@@ -677,6 +685,7 @@
 		if (i >= IEEE80211_WEP_NKID)
 			return EINVAL;
 		ic->ic_def_txkey = i;
+		error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		break;
 	case WI_RID_DEFLT_CRYPT_KEYS:
 		if (len != sizeof(struct wi_ltv_keys))
@@ -710,7 +719,7 @@
 		if (len < 350 /* ? */ || len > IEEE80211_MAX_LEN)
 			return EINVAL;
 		ic->ic_fragthreshold = len;
-		error = ENETRESET;
+		error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		break;
 	case WI_RID_IFACE_STATS:
 		error = EPERM;
@@ -763,6 +772,8 @@
 		error = EINVAL;
 		break;
 	}
+	if (error == ENETRESET && !IS_UP_AUTO(ic))
+		error = 0;
 	return error;
 }
 
@@ -904,7 +915,7 @@
 		if (space < sr->isr_len)
 			break;
 		sr->isr_freq = ni->ni_chan->ic_freq;
-		sr->isr_freq = ni->ni_chan->ic_freq;
+		sr->isr_flags = ni->ni_chan->ic_flags;
 		sr->isr_noise = 0;
 		sr->isr_rssi = ic->ic_node_getrssi(ic, ni);
 		sr->isr_intval = ni->ni_intval;
@@ -1365,7 +1376,7 @@
 	if (ic->ic_bss->ni_chan == IEEE80211_CHAN_ANYC ||
 	    isclr(chanlist, ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan)))
 		ic->ic_bss->ni_chan = ic->ic_ibss_chan;
-	return ENETRESET;
+	return IS_UP_AUTO(ic) ? ENETRESET : 0;
 }
 
 static int
@@ -1386,7 +1397,7 @@
 {
 	static const u_int8_t zerobssid[IEEE80211_ADDR_LEN];
 	struct ieee80211_rsnparms *rsn = &ic->ic_bss->ni_rsn;
-	int error = 0;
+	int error;
 	const struct ieee80211_authenticator *auth;
 	u_int8_t tmpkey[IEEE80211_KEYBUF_SIZE];
 	char tmpssid[IEEE80211_NWID_LEN];
@@ -1395,6 +1406,7 @@
 	int j, caps;
 	u_int kid;
 
+	error = 0;
 	switch (ireq->i_type) {
 	case IEEE80211_IOC_SSID:
 		if (ireq->i_val != 0 ||
@@ -1527,6 +1539,8 @@
 			}
 			break;
 		}
+		if (error == ENETRESET && ic->ic_opmode == IEEE80211_M_MONITOR)
+			error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		break;
 	case IEEE80211_IOC_POWERSAVE:
 		switch (ireq->i_val) {
@@ -1553,14 +1567,14 @@
 		if (ireq->i_val < 0)
 			return EINVAL;
 		ic->ic_lintval = ireq->i_val;
-		error = ENETRESET;
+		error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		break;
 	case IEEE80211_IOC_RTSTHRESHOLD:
 		if (!(IEEE80211_RTS_MIN < ireq->i_val &&
 		      ireq->i_val < IEEE80211_RTS_MAX))
 			return EINVAL;
 		ic->ic_rtsthreshold = ireq->i_val;
-		error = ENETRESET;
+		error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		break;
 	case IEEE80211_IOC_PROTMODE:
 		if (ireq->i_val > IEEE80211_PROT_RTSCTS)
@@ -1568,7 +1582,7 @@
 		ic->ic_protmode = ireq->i_val;
 		/* NB: if not operating in 11g this can wait */
 		if (ic->ic_curmode == IEEE80211_MODE_11G)
-			error = ENETRESET;
+			error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		break;
 	case IEEE80211_IOC_TXPOWER:
 		if ((ic->ic_caps & IEEE80211_C_TXPMGT) == 0)
@@ -1577,13 +1591,14 @@
 		      ireq->i_val < IEEE80211_TXPOWER_MAX))
 			return EINVAL;
 		ic->ic_bss->ni_txpower = ireq->i_val;
-		error = ENETRESET;
+		error = IS_UP(ic) ? ic->ic_reset(ic->ic_ifp) : 0;
 		break;
 	case IEEE80211_IOC_ROAMING:
 		if (!(IEEE80211_ROAMING_DEVICE <= ireq->i_val &&
 		    ireq->i_val <= IEEE80211_ROAMING_MANUAL))
 			return EINVAL;
 		ic->ic_roaming = ireq->i_val;
+		/* XXXX reset? */
 		break;
 	case IEEE80211_IOC_PRIVACY:
 		if (ic->ic_opmode != IEEE80211_M_STA)
@@ -1735,12 +1750,18 @@
 		error = ieee80211_ioctl_setchanlist(ic, ireq);
 		break;
 	case IEEE80211_IOC_SCAN_REQ:
-		/* XXX */
+		if (ic->ic_opmode == IEEE80211_M_HOSTAP)
+			break;
+		error = ieee80211_setupscan(ic);
+		if (error == 0)
+			error = ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
 		break;
 	default:
 		error = EINVAL;
 		break;
 	}
+	if (error == ENETRESET && !IS_UP_AUTO(ic))
+		error = 0;
 	return error;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200410240543.i9O5hplF068376>