From owner-p4-projects@FreeBSD.ORG Fri Nov 12 23:40:31 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C400316A4D3; Fri, 12 Nov 2004 23:40:30 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 83E9A16A4CE for ; Fri, 12 Nov 2004 23:40:30 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 54C2343D46 for ; Fri, 12 Nov 2004 23:40:30 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id iACNeUsg042149 for ; Fri, 12 Nov 2004 23:40:30 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id iACNeUOM042146 for perforce@freebsd.org; Fri, 12 Nov 2004 23:40:30 GMT (envelope-from sam@freebsd.org) Date: Fri, 12 Nov 2004 23:40:30 GMT Message-Id: <200411122340.iACNeUOM042146@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 64982 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Nov 2004 23:40:32 -0000 http://perforce.freebsd.org/chv.cgi?CH=64982 Change 64982 by sam@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: