Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Feb 2004 23:10:59 -0800 (PST)
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 46468 for review
Message-ID:  <200402040710.i147AxvV043609@repoman.freebsd.org>

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

Change 46468 by sam@sam_ebb on 2004/02/03 23:09:58

	o simplify transmit power handling: only one flag bit now to
	  indicate a fixed rate is set (check ni_txpower != 0 to see
	  if the radio was disabled)
	o remove global txpower and authmode setings; we get these from
	  ic_bss as they are inherited by associating stations
	o add #defines for max/min transmit power (.5 dbm units); probably
	  need to revise this after discussion
	o fix ieee80211_iserp_rateset
	o add debugging messages about erp handling
	o default 11g protection mode to CTS only
	o correct station/ibss short slot time handling (set state on
	  channel lock after scan so capabilities sent in the assocation
	  request are correct and honor capabilities return in the
	  assocation response frame)
	o correct problem where stations re-associating were being multiply
	  counted in the longsta and nonerpsta counts

Affected files ...

.. //depot/projects/netperf+sockets/sys/net80211/ieee80211_input.c#16 edit
.. //depot/projects/netperf+sockets/sys/net80211/ieee80211_node.c#8 edit
.. //depot/projects/netperf+sockets/sys/net80211/ieee80211_output.c#16 edit
.. //depot/projects/netperf+sockets/sys/net80211/ieee80211_proto.c#8 edit
.. //depot/projects/netperf+sockets/sys/net80211/ieee80211_var.h#10 edit

Differences ...

==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_input.c#16 (text+ko) ====

@@ -33,6 +33,9 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.13 2004/01/15 08:44:27 onoe Exp $");
 
+/*
+ * IEEE 802.11 input handling.
+ */
 #include "opt_inet.h"
 
 #include <sys/param.h>
@@ -807,11 +810,11 @@
 	 * it only if explicitly configured (it is supported
 	 * mainly for compatibility with clients like OS X).
 	 */
-	if (ic->ic_authmode != IEEE80211_AUTH_AUTO &&
-	    ic->ic_authmode != IEEE80211_AUTH_SHARED) {
+	if (ni->ni_authmode != IEEE80211_AUTH_AUTO &&
+	    ni->ni_authmode != IEEE80211_AUTH_SHARED) {
 		IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
 			("%s: operating in %u mode, reject\n",
-			 __func__, ic->ic_authmode));
+			 __func__, ni->ni_authmode));
 		ic->ic_stats.is_rx_bad_auth++;	/* XXX maybe a unique error? */
 		estatus = IEEE80211_STATUS_ALG;
 		goto bad;
@@ -1243,10 +1246,18 @@
 		 * Honor ERP: enable protection and/or disable
 		 * the use of short slot time.
 		 */
-		if (erp & IEEE80211_ERP_USE_PROTECTION)
+		if (erp & IEEE80211_ERP_USE_PROTECTION) {
+			IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
+				("station %s requires protection\n",
+				ether_sprintf(wh->i_addr2)));
 			ic->ic_flags |= IEEE80211_F_USEPROT;
-		if (erp & IEEE80211_ERP_LONG_PREAMBLE)
+		}
+		if (erp & IEEE80211_ERP_LONG_PREAMBLE) {
+			IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
+				("station %s requires long preamble\n",
+				ether_sprintf(wh->i_addr2)));
 			ic->ic_flags &= ~IEEE80211_F_SHPREAMBLE;
+		}
 		/* NB: must be after ni_chan is setup */
 		ieee80211_setup_rates(ic, ni, rates, xrates, IEEE80211_F_DOSORT);
 		ieee80211_unref_node(&ni);
@@ -1511,47 +1522,58 @@
 				IEEE80211_SEND_MGMT(ic, ni, resp,
 				    IEEE80211_REASON_ASSOC_TOOMANY);
 				return;
-			} else {
-				ni->ni_associd = aid | 0xc000;
-				IEEE80211_AID_SET(ni->ni_associd,
-				    ic->ic_aid_bitmap);
-				newassoc = 1;
 			}
-		} else
-			newassoc = 0;
-		/*
-		 * Station isn't capable of short slot time.  Bump
-		 * the count of long slot time stations and disable
-		 * use of short slot time.  Note that the actual switch
-		 * over to long slot time use will not occur until the
-		 * next beacon transmission (per sec. 7.3.1.4 of 11g).
-		 */
-		if ((capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME) == 0) {
-			ic->ic_longslotsta++;
-			ic->ic_flags &= ~IEEE80211_F_SHSLOT;
-		}
-		/*
-		 * If the new station is not an ERP station
-		 * then bump the counter and enable protection
-		 * if configured.
-		 */
-		if (!ieee80211_iserp_rateset(ic, &ni->ni_rates)) {
-			ic->ic_nonerpsta++;
+			ni->ni_associd = aid | 0xc000;
+			IEEE80211_AID_SET(ni->ni_associd, ic->ic_aid_bitmap);
+			newassoc = 1;
 			/*
-			 * If protection is configured, enable it.
+			 * Station isn't capable of short slot time.  Bump
+			 * the count of long slot time stations and disable
+			 * use of short slot time.  Note that the actual switch
+			 * over to long slot time use will not occur until the
+			 * next beacon transmission (per sec. 7.3.1.4 of 11g).
 			 */
-			if (ic->ic_protmode != IEEE80211_PROT_NONE)
-				ic->ic_flags |= IEEE80211_F_USEPROT;
+			if ((capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME) == 0) {
+				ic->ic_longslotsta++;
+				ic->ic_flags &= ~IEEE80211_F_SHSLOT;
+				IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
+					("station %s needs long slot time, "
+					"count %d\n",
+					ether_sprintf(ni->ni_macaddr),
+					ic->ic_longslotsta));
+			}
 			/*
-			 * If station does not support long preamble then
-			 * we must enable use of Barker preamble.
+			 * If the new station is not an ERP station
+			 * then bump the counter and enable protection
+			 * if configured.
 			 */
-			if ((capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE) == 0) {
-				ic->ic_flags |= IEEE80211_F_USEBARKER;
-				ic->ic_flags &= ~IEEE80211_F_SHPREAMBLE;
-			}
+			if (!ieee80211_iserp_rateset(ic, &ni->ni_rates)) {
+				ic->ic_nonerpsta++;
+				IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
+					("station %s is !erp, count %d\n",
+					ether_sprintf(ni->ni_macaddr),
+					ic->ic_nonerpsta));
+				/*
+				 * If protection is configured, enable it.
+				 */
+				if (ic->ic_protmode != IEEE80211_PROT_NONE)
+					ic->ic_flags |= IEEE80211_F_USEPROT;
+				/*
+				 * If station does not support short preamble
+				 * then we must enable use of Barker preamble.
+				 */
+				if ((capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE) == 0) {
+					IEEE80211_DPRINTF(ic,
+					    IEEE80211_MSG_ASSOC,
+					    ("station %s needs long preamble\n",
+					    ether_sprintf(ni->ni_macaddr)));
+					ic->ic_flags |= IEEE80211_F_USEBARKER;
+					ic->ic_flags &= ~IEEE80211_F_SHPREAMBLE;
+				}
+			} else
+				ni->ni_flags |= IEEE80211_NODE_ERP;
 		} else
-			ni->ni_flags |= IEEE80211_NODE_ERP;
+			newassoc = 0;
 		IEEE80211_SEND_MGMT(ic, ni, resp, IEEE80211_STATUS_SUCCESS);
 		IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC | IEEE80211_MSG_DEBUG,
 			("station %s %s associated at aid %d\n",
@@ -1583,6 +1605,14 @@
 		IEEE80211_VERIFY_LENGTH(efrm - frm, 6);
 		ni = ic->ic_bss;
 		ni->ni_capinfo = le16toh(*(u_int16_t *)frm);
+		if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)
+			ic->ic_flags |= IEEE80211_F_SHPREAMBLE;
+		else
+			ic->ic_flags &= ~IEEE80211_F_SHPREAMBLE;
+		if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME)
+			ic->ic_flags |= IEEE80211_F_SHSLOT;
+		else
+			ic->ic_flags &= ~IEEE80211_F_SHSLOT;
 		frm += 2;
 
 		status = le16toh(*(u_int16_t *)frm);

==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_node.c#8 (text+ko) ====

@@ -34,6 +34,9 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_node.c,v 1.13 2003/11/09 23:36:46 sam Exp $");
 __KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.8 2003/11/02 01:29:05 dyoung Exp $");
 
+/*
+ * IEEE 802.11 node handling support.
+ */
 #include "opt_inet.h"
 
 #include <sys/param.h>
@@ -108,8 +111,8 @@
 	 * each new station automatically inherits them.
 	 */
 	ni->ni_chan = IEEE80211_CHAN_ANYC;
-	ni->ni_authmode = ic->ic_authmode;
-	ni->ni_txpower = ic->ic_txpower;
+	ni->ni_authmode = IEEE80211_AUTH_OPEN;
+	ni->ni_txpower = IEEE80211_TXPOWER_MAX;
 	ic->ic_bss = ni;
 }
 
@@ -390,6 +393,12 @@
 	if (selbs == NULL)
 		goto notfound;
 	(*ic->ic_node_copy)(ic, ic->ic_bss, selbs);
+	/*
+	 * Set the erp state (mostly the slot time) to deal with
+	 * the auto-select case; this should be redundant if the
+	 * mode is locked.
+	 */ 
+	ieee80211_reset_erp(ic, ieee80211_chan2mode(ic, ic->ic_bss->ni_chan));
 	if (ic->ic_opmode == IEEE80211_M_IBSS) {
 		ieee80211_fix_rate(ic, ic->ic_bss, IEEE80211_F_DOFRATE |
 		    IEEE80211_F_DONEGO | IEEE80211_F_DODEL);

==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_output.c#16 (text+ko) ====

@@ -34,6 +34,9 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_output.c,v 1.9 2003/10/17 23:15:30 sam Exp $");
 __KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.9 2003/11/02 00:17:27 dyoung Exp $");
 
+/*
+ * IEEE 802.11 output handling.
+ */
 #include "opt_inet.h"
 
 #include <sys/param.h>
@@ -481,7 +484,7 @@
 		is_shared_key = has_challenge ||
 		     arg >= IEEE80211_AUTH_SHARED_RESPONSE ||
 		     (arg == IEEE80211_AUTH_SHARED_REQUEST &&
-		      ic->ic_authmode == IEEE80211_AUTH_SHARED);
+		      ic->ic_bss->ni_authmode == IEEE80211_AUTH_SHARED);
 
 		m = ieee80211_getmgtframe(&frm,
 			  3 * sizeof(u_int16_t)
@@ -603,6 +606,8 @@
 		if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) &&
 		    IEEE80211_IS_CHAN_2GHZ(ni->ni_chan))
 			capinfo |= IEEE80211_CAPINFO_SHORT_PREAMBLE;
+		if (ic->ic_flags & IEEE80211_F_SHSLOT)
+			capinfo |= IEEE80211_CAPINFO_SHORT_SLOTTIME;
 		*(u_int16_t *)frm = htole16(capinfo);
 		frm += 2;
 

==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_proto.c#8 (text+ko) ====

@@ -103,7 +103,7 @@
 #endif
 	ic->ic_fragthreshold = 2346;		/* XXX not used yet */
 	ic->ic_fixed_rate = -1;			/* no fixed rate */
-	ic->ic_authmode = IEEE80211_AUTH_OPEN;
+	ic->ic_protmode = IEEE80211_PROT_CTSONLY;
 
 	mtx_init(&ic->ic_mgtq.ifq_mtx, ifp->if_xname, "mgmt send q", MTX_DEF);
 	mtx_init(&ic->ic_pwrsaveq.ifq_mtx, ifp->if_xname, "power save q", MTX_DEF);
@@ -319,10 +319,16 @@
 	if (rs->rs_nrates < N(rates))
 		return 0;
 	for (i = 0; i < N(rates); i++) {
-		for (j = 0; j < rs->rs_nrates && rates[i] < rs->rs_rates[j]; j++)
-			;
-		if (j == rs->rs_nrates || rates[i] > rs->rs_rates[j])
-			return 0;
+		for (j = 0; j < rs->rs_nrates; j++) {
+			int r = rs->rs_rates[j] & IEEE80211_RATE_VAL;
+			if (rates[i] == r)
+				goto next;
+			if (r > rates[i])
+				return 0;
+		}
+		return 0;
+	next:
+		;
 	}
 	return 1;
 #undef N
@@ -345,6 +351,10 @@
 		KASSERT(ic->ic_longslotsta > 0,
 		    ("bogus long slot station count %d", ic->ic_longslotsta));
 		ic->ic_longslotsta--;
+		IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
+			("long slot time station %s leaves, count now %d\n",
+			ether_sprintf(ni->ni_macaddr), ic->ic_longslotsta));
+		/* XXX auto mode? */
 		if (ic->ic_longslotsta == 0 &&
 		    ic->ic_curmode == IEEE80211_MODE_11G) {
 			/*
@@ -352,8 +362,11 @@
 			 * and not operating in IBSS mode (per spec).
 			 */
 			if ((ic->ic_caps & IEEE80211_C_SHSLOT) &&
-			    ic->ic_opmode != IEEE80211_M_IBSS)
+			    ic->ic_opmode != IEEE80211_M_IBSS) {
+				IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
+					("re-enable use of short slot time\n"));
 				ic->ic_flags |= IEEE80211_F_SHSLOT;
+			}
 		}
 	}
 	/*
@@ -363,10 +376,17 @@
 		KASSERT(ic->ic_nonerpsta > 0,
 		    ("bogus non-ERP station count %d", ic->ic_nonerpsta));
 		ic->ic_nonerpsta--;
+		IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
+			("non-ERP station %s leaves, count now %d\n",
+			ether_sprintf(ni->ni_macaddr), ic->ic_nonerpsta));
 		if (ic->ic_nonerpsta == 0) {
+			IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
+				("disable use of protection\n"));
 			ic->ic_flags &= ~IEEE80211_F_USEPROT;
 			/* XXX verify mode? */
 			if (ic->ic_caps & IEEE80211_C_SHPREAMBLE) {
+				IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
+					("re-enable use of short preamble\n"));
 				ic->ic_flags |= IEEE80211_F_SHPREAMBLE;
 				ic->ic_flags &= ~IEEE80211_F_USEBARKER;
 			}

==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_var.h#10 (text+ko) ====

@@ -57,10 +57,13 @@
 #include <net80211/ieee80211_proto.h>
 
 #define	IEEE80211_CHAN_MAX	255
-#define	IEEE80211_CHAN_ANY	0xffff		/* token for ``any channel'' */
+#define	IEEE80211_CHAN_ANY	0xffff	/* token for ``any channel'' */
 #define	IEEE80211_CHAN_ANYC \
 	((struct ieee80211_channel *) IEEE80211_CHAN_ANY)
 
+#define	IEEE80211_TXPOWER_MAX	60	/* .5 dbM (XXX units?) */
+#define	IEEE80211_TXPOWER_MIN	0	/* kill radio */
+
 enum ieee80211_phytype {
 	IEEE80211_T_DS,			/* direct sequence spread spectrum */
 	IEEE80211_T_FH,			/* frequency hopping */
@@ -224,9 +227,7 @@
 	u_int16_t		ic_txmin;	/* min tx retry count */
 	u_int16_t		ic_txmax;	/* max tx retry count */
 	u_int16_t		ic_txlifetime;	/* tx lifetime */
-	u_int16_t		ic_txpower;	/* tx power setting (dbM) */
 	u_int16_t		ic_bmisstimeout;/* beacon miss threshold (ms) */
-	u_int16_t		ic_authmode;	/* authentication mode */
 	u_int16_t		ic_nonerpsta;	/* # non-ERP stations */
 	u_int16_t		ic_longslotsta;	/* # long slot time stations */
 	int			ic_mgt_timer;	/* mgmt timeout */
@@ -254,16 +255,13 @@
 #define	IEEE80211_F_SCANAP	0x00001000	/* CONF: Scanning AP */
 #define	IEEE80211_F_ROAMING	0x00002000	/* CONF: roaming enabled */
 #define	IEEE80211_F_SWRETRY	0x00004000	/* CONF: sw tx retry enabled */
-#define	IEEE80211_F_TXPMGT	0x00018000	/* STATUS: tx power */
-#define IEEE80211_F_TXPOW_OFF	0x00000000	/* TX Power: radio disabled */
 #define IEEE80211_F_TXPOW_FIXED	0x00008000	/* TX Power: fixed rate */
-#define IEEE80211_F_TXPOW_AUTO	0x00010000	/* TX Power: undefined */
-#define	IEEE80211_F_SHSLOT	0x00020000	/* CONF: short slot time */
-#define	IEEE80211_F_SHPREAMBLE	0x00040000	/* CONF: short preamble */
-#define	IEEE80211_F_DATAPAD	0x00080000	/* CONF: do alignment pad */
-#define	IEEE80211_F_USEPROT	0x00100000	/* STATUS: protection enabled */
-#define	IEEE80211_F_USEBARKER	0x00200000	/* STATUS: use barker preamble*/
-#define	IEEE80211_F_TIMUPDATE	0x00400000	/* STATUS: update beacon tim */
+#define	IEEE80211_F_SHSLOT	0x00010000	/* CONF: short slot time */
+#define	IEEE80211_F_SHPREAMBLE	0x00020000	/* CONF: short preamble */
+#define	IEEE80211_F_DATAPAD	0x00040000	/* CONF: do alignment pad */
+#define	IEEE80211_F_USEPROT	0x00080000	/* STATUS: protection enabled */
+#define	IEEE80211_F_USEBARKER	0x00100000	/* STATUS: use barker preamble*/
+#define	IEEE80211_F_TIMUPDATE	0x00200000	/* STATUS: update beacon tim */
 
 /* ic_caps */
 #define	IEEE80211_C_WEP		0x00000001	/* CAPABILITY: WEP available */



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