13147Sxc151355 /* 28594SFei.Feng@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 33147Sxc151355 * Use is subject to license terms. 43147Sxc151355 */ 53147Sxc151355 63147Sxc151355 /* 73147Sxc151355 * Copyright (c) 2001 Atsushi Onoe 88594SFei.Feng@Sun.COM * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 93147Sxc151355 * All rights reserved. 103147Sxc151355 * 113147Sxc151355 * Redistribution and use in source and binary forms, with or without 123147Sxc151355 * modification, are permitted provided that the following conditions 133147Sxc151355 * are met: 143147Sxc151355 * 1. Redistributions of source code must retain the above copyright 153147Sxc151355 * notice, this list of conditions and the following disclaimer. 163147Sxc151355 * 2. Redistributions in binary form must reproduce the above copyright 173147Sxc151355 * notice, this list of conditions and the following disclaimer in the 183147Sxc151355 * documentation and/or other materials provided with the distribution. 193147Sxc151355 * 3. The name of the author may not be used to endorse or promote products 203147Sxc151355 * derived from this software without specific prior written permission. 213147Sxc151355 * 223147Sxc151355 * Alternatively, this software may be distributed under the terms of the 233147Sxc151355 * GNU General Public License ("GPL") version 2 as published by the Free 243147Sxc151355 * Software Foundation. 253147Sxc151355 * 263147Sxc151355 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 273147Sxc151355 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 283147Sxc151355 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 293147Sxc151355 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 303147Sxc151355 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 313147Sxc151355 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 323147Sxc151355 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 333147Sxc151355 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 343147Sxc151355 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 353147Sxc151355 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 363147Sxc151355 */ 373147Sxc151355 383147Sxc151355 /* 393147Sxc151355 * Process received frame 403147Sxc151355 */ 413147Sxc151355 428275SEric Cheng #include <sys/mac_provider.h> 433147Sxc151355 #include <sys/byteorder.h> 447249Sff224033 #include <sys/strsun.h> 453147Sxc151355 #include "net80211_impl.h" 463147Sxc151355 473147Sxc151355 static mblk_t *ieee80211_defrag(ieee80211com_t *, ieee80211_node_t *, 483147Sxc151355 mblk_t *, int); 493147Sxc151355 503147Sxc151355 /* 513147Sxc151355 * Process a received frame. The node associated with the sender 523147Sxc151355 * should be supplied. If nothing was found in the node table then 533147Sxc151355 * the caller is assumed to supply a reference to ic_bss instead. 543147Sxc151355 * The RSSI and a timestamp are also supplied. The RSSI data is used 553147Sxc151355 * during AP scanning to select a AP to associate with; it can have 563147Sxc151355 * any units so long as values have consistent units and higher values 573147Sxc151355 * mean ``better signal''. The receive timestamp is currently not used 583147Sxc151355 * by the 802.11 layer. 593147Sxc151355 */ 603147Sxc151355 int 613147Sxc151355 ieee80211_input(ieee80211com_t *ic, mblk_t *mp, struct ieee80211_node *in, 623147Sxc151355 int32_t rssi, uint32_t rstamp) 633147Sxc151355 { 643147Sxc151355 struct ieee80211_frame *wh; 653147Sxc151355 struct ieee80211_key *key; 663147Sxc151355 uint8_t *bssid; 673147Sxc151355 int hdrspace; 683147Sxc151355 int len; 693147Sxc151355 uint16_t rxseq; 703147Sxc151355 uint8_t dir; 713147Sxc151355 uint8_t type; 723147Sxc151355 uint8_t subtype; 733147Sxc151355 uint8_t tid; 7410266SQuaker.Fang@Sun.COM uint8_t qos; 7510266SQuaker.Fang@Sun.COM 7610266SQuaker.Fang@Sun.COM if (mp->b_flag & M_AMPDU) { 7710266SQuaker.Fang@Sun.COM /* 7810266SQuaker.Fang@Sun.COM * Fastpath for A-MPDU reorder q resubmission. Frames 7910266SQuaker.Fang@Sun.COM * w/ M_AMPDU marked have already passed through here 8010266SQuaker.Fang@Sun.COM * but were received out of order and been held on the 8110266SQuaker.Fang@Sun.COM * reorder queue. When resubmitted they are marked 8210266SQuaker.Fang@Sun.COM * with the M_AMPDU flag and we can bypass most of the 8310266SQuaker.Fang@Sun.COM * normal processing. 8410266SQuaker.Fang@Sun.COM */ 8510266SQuaker.Fang@Sun.COM IEEE80211_LOCK(ic); 8610266SQuaker.Fang@Sun.COM wh = (struct ieee80211_frame *)mp->b_rptr; 8710266SQuaker.Fang@Sun.COM type = IEEE80211_FC0_TYPE_DATA; 8810266SQuaker.Fang@Sun.COM dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK; 8910266SQuaker.Fang@Sun.COM subtype = IEEE80211_FC0_SUBTYPE_QOS; 9010266SQuaker.Fang@Sun.COM hdrspace = ieee80211_hdrspace(ic, wh); /* optimize */ 9110266SQuaker.Fang@Sun.COM /* clear driver/net80211 flags before passing up */ 9210266SQuaker.Fang@Sun.COM mp->b_flag &= ~M_AMPDU; 9310266SQuaker.Fang@Sun.COM goto resubmit_ampdu; 9410266SQuaker.Fang@Sun.COM } 953147Sxc151355 963147Sxc151355 ASSERT(in != NULL); 978594SFei.Feng@Sun.COM in->in_inact = in->in_inact_reload; 983147Sxc151355 type = (uint8_t)-1; /* undefined */ 997249Sff224033 len = MBLKL(mp); 1003147Sxc151355 if (len < sizeof (struct ieee80211_frame_min)) { 1013147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ANY, "ieee80211_input: " 1027249Sff224033 "too short (1): len %u", len); 1033147Sxc151355 goto out; 1043147Sxc151355 } 1053147Sxc151355 /* 1063147Sxc151355 * Bit of a cheat here, we use a pointer for a 3-address 1073147Sxc151355 * frame format but don't reference fields past outside 1083147Sxc151355 * ieee80211_frame_min w/o first validating the data is 1093147Sxc151355 * present. 1103147Sxc151355 */ 1113147Sxc151355 wh = (struct ieee80211_frame *)mp->b_rptr; 1123147Sxc151355 if ((wh->i_fc[0] & IEEE80211_FC0_VERSION_MASK) != 1133147Sxc151355 IEEE80211_FC0_VERSION_0) { 1143147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ANY, "ieee80211_input: " 1157249Sff224033 "discard pkt with wrong version %x", wh->i_fc[0]); 1163147Sxc151355 goto out; 1173147Sxc151355 } 1183147Sxc151355 1193147Sxc151355 dir = wh->i_fc[1] & IEEE80211_FC1_DIR_MASK; 1203147Sxc151355 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; 1213147Sxc151355 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; 1223147Sxc151355 1233147Sxc151355 IEEE80211_LOCK(ic); 1243147Sxc151355 if (!(ic->ic_flags & IEEE80211_F_SCAN)) { 1253147Sxc151355 switch (ic->ic_opmode) { 1263147Sxc151355 case IEEE80211_M_STA: 1273147Sxc151355 bssid = wh->i_addr2; 1283147Sxc151355 if (!IEEE80211_ADDR_EQ(bssid, in->in_bssid)) 1293147Sxc151355 goto out_exit_mutex; 1303147Sxc151355 break; 1313147Sxc151355 case IEEE80211_M_IBSS: 1323147Sxc151355 case IEEE80211_M_AHDEMO: 1333147Sxc151355 if (dir != IEEE80211_FC1_DIR_NODS) { 1343147Sxc151355 bssid = wh->i_addr1; 1353147Sxc151355 } else if (type == IEEE80211_FC0_TYPE_CTL) { 1363147Sxc151355 bssid = wh->i_addr1; 1373147Sxc151355 } else { 1383147Sxc151355 if (len < sizeof (struct ieee80211_frame)) { 1393147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ANY, 1407249Sff224033 "ieee80211_input: too short(2):" 1417249Sff224033 "len %u\n", len); 1423147Sxc151355 goto out_exit_mutex; 1433147Sxc151355 } 1443147Sxc151355 bssid = wh->i_addr3; 1453147Sxc151355 } 1463147Sxc151355 if (type != IEEE80211_FC0_TYPE_DATA) 1473147Sxc151355 break; 1483147Sxc151355 /* 1493147Sxc151355 * Data frame, validate the bssid. 1503147Sxc151355 */ 1513147Sxc151355 if (!IEEE80211_ADDR_EQ(bssid, ic->ic_bss->in_bssid) && 1523147Sxc151355 !IEEE80211_ADDR_EQ(bssid, wifi_bcastaddr)) { 1533147Sxc151355 /* not interested in */ 1543147Sxc151355 ieee80211_dbg(IEEE80211_MSG_INPUT, 1557249Sff224033 "ieee80211_input: not to bss %s\n", 1567249Sff224033 ieee80211_macaddr_sprintf(bssid)); 1573147Sxc151355 goto out_exit_mutex; 1583147Sxc151355 } 1593147Sxc151355 /* 1603147Sxc151355 * For adhoc mode we cons up a node when it doesn't 1613147Sxc151355 * exist. This should probably done after an ACL check. 1623147Sxc151355 */ 1633147Sxc151355 if (in == ic->ic_bss && 1643147Sxc151355 ic->ic_opmode != IEEE80211_M_HOSTAP && 1653147Sxc151355 !IEEE80211_ADDR_EQ(wh->i_addr2, in->in_macaddr)) { 1663147Sxc151355 /* 1673147Sxc151355 * Fake up a node for this newly 1683147Sxc151355 * discovered member of the IBSS. 1693147Sxc151355 */ 1703147Sxc151355 in = ieee80211_fakeup_adhoc_node(&ic->ic_sta, 1717249Sff224033 wh->i_addr2); 1723147Sxc151355 if (in == NULL) { 1733147Sxc151355 /* NB: stat kept for alloc failure */ 1743147Sxc151355 goto out_exit_mutex; 1753147Sxc151355 } 1763147Sxc151355 } 1773147Sxc151355 break; 1783147Sxc151355 default: 1793147Sxc151355 goto out_exit_mutex; 1803147Sxc151355 } 1813147Sxc151355 in->in_rssi = (uint8_t)rssi; 1823147Sxc151355 in->in_rstamp = rstamp; 1833147Sxc151355 if (!(type & IEEE80211_FC0_TYPE_CTL)) { 18410266SQuaker.Fang@Sun.COM if (IEEE80211_QOS_HAS_SEQ(wh)) { 18510266SQuaker.Fang@Sun.COM tid = ((struct ieee80211_qosframe *)wh)-> 18610266SQuaker.Fang@Sun.COM i_qos[0] & IEEE80211_QOS_TID; 18710266SQuaker.Fang@Sun.COM if (TID_TO_WME_AC(tid) >= WME_AC_VI) 18810266SQuaker.Fang@Sun.COM ic->ic_wme.wme_hipri_traffic++; 18910266SQuaker.Fang@Sun.COM tid++; 19010266SQuaker.Fang@Sun.COM } else { 19110266SQuaker.Fang@Sun.COM tid = IEEE80211_NONQOS_TID; 19210266SQuaker.Fang@Sun.COM } 1939327SFei.Feng@Sun.COM rxseq = LE_16(*(uint16_t *)wh->i_seq); 19410266SQuaker.Fang@Sun.COM if ((in->in_flags & IEEE80211_NODE_HT) == 0 && 19510266SQuaker.Fang@Sun.COM (wh->i_fc[1] & IEEE80211_FC1_RETRY) && 1963147Sxc151355 (rxseq - in->in_rxseqs[tid]) <= 0) { 1973147Sxc151355 /* duplicate, discard */ 1983147Sxc151355 ieee80211_dbg(IEEE80211_MSG_INPUT, 1997249Sff224033 "ieee80211_input: duplicate", 2007249Sff224033 "seqno <%u,%u> fragno <%u,%u> tid %u", 2017249Sff224033 rxseq >> IEEE80211_SEQ_SEQ_SHIFT, 2027249Sff224033 in->in_rxseqs[tid] >> 2037249Sff224033 IEEE80211_SEQ_SEQ_SHIFT, 2047249Sff224033 rxseq & IEEE80211_SEQ_FRAG_MASK, 2057249Sff224033 in->in_rxseqs[tid] & 2067249Sff224033 IEEE80211_SEQ_FRAG_MASK, 2077249Sff224033 tid); 2083147Sxc151355 ic->ic_stats.is_rx_dups++; 2093147Sxc151355 goto out_exit_mutex; 2103147Sxc151355 } 2113147Sxc151355 in->in_rxseqs[tid] = rxseq; 2123147Sxc151355 } 2133147Sxc151355 } 2143147Sxc151355 2153147Sxc151355 switch (type) { 2163147Sxc151355 case IEEE80211_FC0_TYPE_DATA: 21710266SQuaker.Fang@Sun.COM hdrspace = ieee80211_hdrspace(ic, wh); 2183147Sxc151355 if (len < hdrspace) { 2193147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ANY, "ieee80211_input: " 2207249Sff224033 "data too short: expecting %u", hdrspace); 2213147Sxc151355 goto out_exit_mutex; 2223147Sxc151355 } 2233147Sxc151355 switch (ic->ic_opmode) { 2243147Sxc151355 case IEEE80211_M_STA: 2253147Sxc151355 if (dir != IEEE80211_FC1_DIR_FROMDS) { 2263147Sxc151355 ieee80211_dbg(IEEE80211_MSG_INPUT, 2277249Sff224033 "ieee80211_input: data ", 2287249Sff224033 "unknown dir 0x%x", dir); 2293147Sxc151355 goto out_exit_mutex; 2303147Sxc151355 } 2313147Sxc151355 if (IEEE80211_IS_MULTICAST(wh->i_addr1) && 2323147Sxc151355 IEEE80211_ADDR_EQ(wh->i_addr3, ic->ic_macaddr)) { 2333147Sxc151355 /* 2343147Sxc151355 * In IEEE802.11 network, multicast packet 2353147Sxc151355 * sent from me is broadcasted from AP. 2363147Sxc151355 * It should be silently discarded for 2373147Sxc151355 * SIMPLEX interface. 2383147Sxc151355 */ 2393147Sxc151355 ieee80211_dbg(IEEE80211_MSG_INPUT, 2407249Sff224033 "ieee80211_input: multicast echo\n"); 2413147Sxc151355 goto out_exit_mutex; 2423147Sxc151355 } 2433147Sxc151355 break; 2443147Sxc151355 case IEEE80211_M_IBSS: 2453147Sxc151355 case IEEE80211_M_AHDEMO: 2463147Sxc151355 if (dir != IEEE80211_FC1_DIR_NODS) { 2473147Sxc151355 ieee80211_dbg(IEEE80211_MSG_INPUT, 2487249Sff224033 "ieee80211_input: unknown dir 0x%x", 2497249Sff224033 dir); 2503147Sxc151355 goto out_exit_mutex; 2513147Sxc151355 } 2523147Sxc151355 break; 2533147Sxc151355 default: 2543147Sxc151355 ieee80211_err("ieee80211_input: " 2557249Sff224033 "receive data, unknown opmode %u, skip\n", 2567249Sff224033 ic->ic_opmode); 2573147Sxc151355 goto out_exit_mutex; 2583147Sxc151355 } 2593147Sxc151355 2603147Sxc151355 /* 26110266SQuaker.Fang@Sun.COM * Handle A-MPDU re-ordering. The station must be 26210266SQuaker.Fang@Sun.COM * associated and negotiated HT. The frame must be 26310266SQuaker.Fang@Sun.COM * a QoS frame (not QoS null data) and not previously 26410266SQuaker.Fang@Sun.COM * processed for A-MPDU re-ordering. If the frame is 26510266SQuaker.Fang@Sun.COM * to be processed directly then ieee80211_ampdu_reorder 26610266SQuaker.Fang@Sun.COM * will return 0; otherwise it has consumed the mbuf 26710266SQuaker.Fang@Sun.COM * and we should do nothing more with it. 26810266SQuaker.Fang@Sun.COM */ 26910266SQuaker.Fang@Sun.COM if ((in->in_flags & IEEE80211_NODE_HT) && 27010266SQuaker.Fang@Sun.COM (subtype == IEEE80211_FC0_SUBTYPE_QOS)) { 27110266SQuaker.Fang@Sun.COM IEEE80211_UNLOCK(ic); 27210266SQuaker.Fang@Sun.COM if (ieee80211_ampdu_reorder(in, mp) != 0) { 27310266SQuaker.Fang@Sun.COM mp = NULL; /* CONSUMED */ 27410266SQuaker.Fang@Sun.COM goto out; 27510266SQuaker.Fang@Sun.COM } 27610266SQuaker.Fang@Sun.COM IEEE80211_LOCK(ic); 27710266SQuaker.Fang@Sun.COM } 27810266SQuaker.Fang@Sun.COM resubmit_ampdu: 27910266SQuaker.Fang@Sun.COM 28010266SQuaker.Fang@Sun.COM /* 2813147Sxc151355 * Handle privacy requirements. 2823147Sxc151355 */ 2833147Sxc151355 if (wh->i_fc[1] & IEEE80211_FC1_WEP) { 2843147Sxc151355 if ((ic->ic_flags & IEEE80211_F_PRIVACY) == 0) { 2853147Sxc151355 /* 2863147Sxc151355 * Discard encrypted frames when privacy off. 2873147Sxc151355 */ 2883147Sxc151355 ieee80211_dbg(IEEE80211_MSG_INPUT, 2897249Sff224033 "ieee80211_input: ""WEP PRIVACY off"); 2903147Sxc151355 ic->ic_stats.is_wep_errors++; 2913147Sxc151355 goto out_exit_mutex; 2923147Sxc151355 } 2933147Sxc151355 key = ieee80211_crypto_decap(ic, mp, hdrspace); 2943147Sxc151355 if (key == NULL) { 2953147Sxc151355 /* NB: stats+msgs handled in crypto_decap */ 2963147Sxc151355 ic->ic_stats.is_wep_errors++; 2973147Sxc151355 goto out_exit_mutex; 2983147Sxc151355 } 2993147Sxc151355 wh = (struct ieee80211_frame *)mp->b_rptr; 3003147Sxc151355 wh->i_fc[1] &= ~IEEE80211_FC1_WEP; 3013147Sxc151355 } else { 3023147Sxc151355 key = NULL; 3033147Sxc151355 } 3043147Sxc151355 3053147Sxc151355 /* 30610266SQuaker.Fang@Sun.COM * Save QoS bits for use below--before we strip the header. 30710266SQuaker.Fang@Sun.COM */ 30810266SQuaker.Fang@Sun.COM if (subtype == IEEE80211_FC0_SUBTYPE_QOS) { 30910266SQuaker.Fang@Sun.COM qos = (dir == IEEE80211_FC1_DIR_DSTODS) ? 31010266SQuaker.Fang@Sun.COM ((struct ieee80211_qosframe_addr4 *)wh)->i_qos[0] : 31110266SQuaker.Fang@Sun.COM ((struct ieee80211_qosframe *)wh)->i_qos[0]; 31210266SQuaker.Fang@Sun.COM } else { 31310266SQuaker.Fang@Sun.COM qos = 0; 31410266SQuaker.Fang@Sun.COM } 31510266SQuaker.Fang@Sun.COM 31610266SQuaker.Fang@Sun.COM /* 3173147Sxc151355 * Next up, any fragmentation 3183147Sxc151355 */ 3193147Sxc151355 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { 3203147Sxc151355 mp = ieee80211_defrag(ic, in, mp, hdrspace); 3213147Sxc151355 if (mp == NULL) { 3223147Sxc151355 /* Fragment dropped or frame not complete yet */ 3233147Sxc151355 goto out_exit_mutex; 3243147Sxc151355 } 3253147Sxc151355 } 3263147Sxc151355 wh = NULL; /* no longer valid, catch any uses */ 3273147Sxc151355 3283147Sxc151355 /* 3293147Sxc151355 * Next strip any MSDU crypto bits. 3303147Sxc151355 */ 3313147Sxc151355 if (key != NULL && !ieee80211_crypto_demic(ic, key, mp, 0)) { 3323147Sxc151355 ieee80211_dbg(IEEE80211_MSG_INPUT, "ieee80211_input: " 3337249Sff224033 "data demic error\n"); 3343147Sxc151355 goto out_exit_mutex; 3353147Sxc151355 } 3363147Sxc151355 33710266SQuaker.Fang@Sun.COM if (qos & IEEE80211_QOS_AMSDU) { 33810266SQuaker.Fang@Sun.COM ieee80211_dbg(IEEE80211_MSG_INPUT | IEEE80211_MSG_HT, 33910266SQuaker.Fang@Sun.COM "ieee80211_input: QOS_AMSDU (%x)\n", qos); 34010266SQuaker.Fang@Sun.COM 34110266SQuaker.Fang@Sun.COM mp = ieee80211_decap_amsdu(in, mp); 34210266SQuaker.Fang@Sun.COM if (mp == NULL) /* MSDU processed by HT */ 34310266SQuaker.Fang@Sun.COM goto out_exit_mutex; 34410266SQuaker.Fang@Sun.COM } 34510266SQuaker.Fang@Sun.COM 3463147Sxc151355 ic->ic_stats.is_rx_frags++; 3473147Sxc151355 ic->ic_stats.is_rx_bytes += len; 3483147Sxc151355 IEEE80211_UNLOCK(ic); 3493147Sxc151355 mac_rx(ic->ic_mach, NULL, mp); 3503147Sxc151355 return (IEEE80211_FC0_TYPE_DATA); 3513147Sxc151355 3523147Sxc151355 case IEEE80211_FC0_TYPE_MGT: 3533147Sxc151355 if (dir != IEEE80211_FC1_DIR_NODS) 3543147Sxc151355 goto out_exit_mutex; 3553147Sxc151355 if (len < sizeof (struct ieee80211_frame)) 3563147Sxc151355 goto out_exit_mutex; 3573147Sxc151355 if (wh->i_fc[1] & IEEE80211_FC1_WEP) { 3583147Sxc151355 if (subtype != IEEE80211_FC0_SUBTYPE_AUTH) { 3593147Sxc151355 /* 3603147Sxc151355 * Only shared key auth frames with a challenge 3613147Sxc151355 * should be encrypted, discard all others. 3623147Sxc151355 */ 3633147Sxc151355 ieee80211_dbg(IEEE80211_MSG_INPUT, 3647249Sff224033 "ieee80211_input: " 3657249Sff224033 "%s WEP set but not permitted", 3667249Sff224033 IEEE80211_SUBTYPE_NAME(subtype)); 3673147Sxc151355 ic->ic_stats.is_wep_errors++; 3683147Sxc151355 goto out_exit_mutex; 3693147Sxc151355 } 3703147Sxc151355 if ((ic->ic_flags & IEEE80211_F_PRIVACY) == 0) { 3713147Sxc151355 /* 3723147Sxc151355 * Discard encrypted frames when privacy off. 3733147Sxc151355 */ 3743147Sxc151355 ieee80211_dbg(IEEE80211_MSG_INPUT, 3757249Sff224033 "ieee80211_input: " 3767249Sff224033 "mgt WEP set but PRIVACY off"); 3773147Sxc151355 ic->ic_stats.is_wep_errors++; 3783147Sxc151355 goto out_exit_mutex; 3793147Sxc151355 } 38010266SQuaker.Fang@Sun.COM hdrspace = ieee80211_hdrspace(ic, wh); 3813147Sxc151355 key = ieee80211_crypto_decap(ic, mp, hdrspace); 3823147Sxc151355 if (key == NULL) { 3833147Sxc151355 /* NB: stats+msgs handled in crypto_decap */ 3843147Sxc151355 goto out_exit_mutex; 3853147Sxc151355 } 3863147Sxc151355 wh = (struct ieee80211_frame *)mp->b_rptr; 3873147Sxc151355 wh->i_fc[1] &= ~IEEE80211_FC1_WEP; 3883147Sxc151355 } 3893147Sxc151355 IEEE80211_UNLOCK(ic); 3903147Sxc151355 ic->ic_recv_mgmt(ic, mp, in, subtype, rssi, rstamp); 3913147Sxc151355 goto out; 3923147Sxc151355 3933147Sxc151355 case IEEE80211_FC0_TYPE_CTL: 39410266SQuaker.Fang@Sun.COM if (ic->ic_opmode == IEEE80211_M_HOSTAP) { 39510266SQuaker.Fang@Sun.COM switch (subtype) { 39610266SQuaker.Fang@Sun.COM case IEEE80211_FC0_SUBTYPE_BAR: 39710266SQuaker.Fang@Sun.COM ieee80211_recv_bar(in, mp); 39810266SQuaker.Fang@Sun.COM break; 39910266SQuaker.Fang@Sun.COM } 40010266SQuaker.Fang@Sun.COM } 40110266SQuaker.Fang@Sun.COM break; 40210266SQuaker.Fang@Sun.COM 4033147Sxc151355 default: 4043147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ANY, "ieee80211_input: " 4057249Sff224033 "bad frame type 0x%x", type); 4063147Sxc151355 /* should not come here */ 4073147Sxc151355 break; 4083147Sxc151355 } 4093147Sxc151355 out_exit_mutex: 4103147Sxc151355 IEEE80211_UNLOCK(ic); 4113147Sxc151355 out: 4123147Sxc151355 if (mp != NULL) 4133147Sxc151355 freemsg(mp); 4143147Sxc151355 4153147Sxc151355 return (type); 4163147Sxc151355 } 4173147Sxc151355 4183147Sxc151355 /* 4193147Sxc151355 * This function reassemble fragments. 4203147Sxc151355 * More fragments bit in the frame control means the packet is fragmented. 4213147Sxc151355 * While the sequence control field consists of 4-bit fragment number 4223147Sxc151355 * field and a 12-bit sequence number field. 4233147Sxc151355 */ 4243147Sxc151355 /* ARGSUSED */ 4253147Sxc151355 static mblk_t * 4263147Sxc151355 ieee80211_defrag(ieee80211com_t *ic, struct ieee80211_node *in, mblk_t *mp, 4273147Sxc151355 int hdrspace) 4283147Sxc151355 { 4293147Sxc151355 struct ieee80211_frame *wh = (struct ieee80211_frame *)mp->b_rptr; 4303147Sxc151355 struct ieee80211_frame *lwh; 4313147Sxc151355 mblk_t *mfrag; 4323147Sxc151355 uint16_t rxseq; 4333147Sxc151355 uint8_t fragno; 4343147Sxc151355 uint8_t more_frag; 4353147Sxc151355 4363147Sxc151355 ASSERT(!IEEE80211_IS_MULTICAST(wh->i_addr1)); 4373147Sxc151355 more_frag = wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG; 4383147Sxc151355 rxseq = LE_16(*(uint16_t *)wh->i_seq); 4393147Sxc151355 fragno = rxseq & IEEE80211_SEQ_FRAG_MASK; 4403147Sxc151355 4413147Sxc151355 /* Quick way out, if there's nothing to defragment */ 4423147Sxc151355 if (!more_frag && fragno == 0 && in->in_rxfrag == NULL) 4433147Sxc151355 return (mp); 4443147Sxc151355 4453147Sxc151355 /* 4463147Sxc151355 * Remove frag to insure it doesn't get reaped by timer. 4473147Sxc151355 */ 4483147Sxc151355 if (in->in_table == NULL) { 4493147Sxc151355 /* 4503147Sxc151355 * Should never happen. If the node is orphaned (not in 4513147Sxc151355 * the table) then input packets should not reach here. 4523147Sxc151355 * Otherwise, a concurrent request that yanks the table 4533147Sxc151355 * should be blocked by other interlocking and/or by first 4543147Sxc151355 * shutting the driver down. Regardless, be defensive 4553147Sxc151355 * here and just bail 4563147Sxc151355 */ 4573147Sxc151355 freemsg(mp); 4583147Sxc151355 return (NULL); 4593147Sxc151355 } 4603147Sxc151355 IEEE80211_NODE_LOCK(in->in_table); 4613147Sxc151355 mfrag = in->in_rxfrag; 4623147Sxc151355 in->in_rxfrag = NULL; 4633147Sxc151355 IEEE80211_NODE_UNLOCK(in->in_table); 4643147Sxc151355 4653147Sxc151355 /* 4663147Sxc151355 * Validate new fragment is in order and 4673147Sxc151355 * related to the previous ones. 4683147Sxc151355 */ 4693147Sxc151355 if (mfrag != NULL) { 4703147Sxc151355 uint16_t last_rxseq; 4713147Sxc151355 4723147Sxc151355 lwh = (struct ieee80211_frame *)mfrag->b_rptr; 4733147Sxc151355 last_rxseq = LE_16(*(uint16_t *)lwh->i_seq); 4743147Sxc151355 /* 4753147Sxc151355 * Sequence control field contains 12-bit sequence no 4763147Sxc151355 * and 4-bit fragment number. For fragemnts, the 4773147Sxc151355 * sequence no is not changed. 4783147Sxc151355 * NB: check seq # and frag together 4793147Sxc151355 */ 4803147Sxc151355 if (rxseq != last_rxseq + 1 || 4813147Sxc151355 !IEEE80211_ADDR_EQ(wh->i_addr1, lwh->i_addr1) || 4823147Sxc151355 !IEEE80211_ADDR_EQ(wh->i_addr2, lwh->i_addr2)) { 4833147Sxc151355 /* 4843147Sxc151355 * Unrelated fragment or no space for it, 4853147Sxc151355 * clear current fragments. 4863147Sxc151355 */ 4873147Sxc151355 freemsg(mfrag); 4883147Sxc151355 mfrag = NULL; 4893147Sxc151355 } 4903147Sxc151355 } 4913147Sxc151355 4923147Sxc151355 if (mfrag == NULL) { 4933147Sxc151355 if (fragno != 0) { /* !first fragment, discard */ 4943147Sxc151355 freemsg(mp); 4953147Sxc151355 return (NULL); 4963147Sxc151355 } 4973147Sxc151355 mfrag = mp; 4983147Sxc151355 } else { /* concatenate */ 4993147Sxc151355 (void) adjmsg(mp, hdrspace); 5003147Sxc151355 linkb(mfrag, mp); 5013147Sxc151355 /* track last seqnum and fragno */ 5023147Sxc151355 lwh = (struct ieee80211_frame *)mfrag->b_rptr; 5033147Sxc151355 *(uint16_t *)lwh->i_seq = *(uint16_t *)wh->i_seq; 5043147Sxc151355 } 5053147Sxc151355 if (more_frag != 0) { /* more to come, save */ 5063147Sxc151355 in->in_rxfragstamp = ddi_get_lbolt(); 5073147Sxc151355 in->in_rxfrag = mfrag; 5083147Sxc151355 mfrag = NULL; 5093147Sxc151355 } 5103147Sxc151355 5113147Sxc151355 return (mfrag); 5123147Sxc151355 } 5133147Sxc151355 5143147Sxc151355 /* 5153147Sxc151355 * Install received rate set information in the node's state block. 5163147Sxc151355 */ 5173147Sxc151355 int 5183147Sxc151355 ieee80211_setup_rates(struct ieee80211_node *in, const uint8_t *rates, 5193147Sxc151355 const uint8_t *xrates, int flags) 5203147Sxc151355 { 5213147Sxc151355 struct ieee80211_rateset *rs = &in->in_rates; 5223147Sxc151355 5233147Sxc151355 bzero(rs, sizeof (*rs)); 5243147Sxc151355 rs->ir_nrates = rates[1]; 5253147Sxc151355 /* skip 1 byte element ID and 1 byte length */ 5263147Sxc151355 bcopy(rates + 2, rs->ir_rates, rs->ir_nrates); 5273147Sxc151355 if (xrates != NULL) { 5283147Sxc151355 uint8_t nxrates; 5293147Sxc151355 5303147Sxc151355 /* 5313147Sxc151355 * Tack on 11g extended supported rate element. 5323147Sxc151355 */ 5333147Sxc151355 nxrates = xrates[1]; 5343147Sxc151355 if (rs->ir_nrates + nxrates > IEEE80211_RATE_MAXSIZE) { 5353147Sxc151355 nxrates = IEEE80211_RATE_MAXSIZE - rs->ir_nrates; 5363147Sxc151355 ieee80211_dbg(IEEE80211_MSG_XRATE, 5377249Sff224033 "ieee80211_setup_rates: %s", 5387249Sff224033 "[%s] extended rate set too large;" 5397249Sff224033 " only using %u of %u rates\n", 5407249Sff224033 ieee80211_macaddr_sprintf(in->in_macaddr), 5417249Sff224033 nxrates, xrates[1]); 5423147Sxc151355 } 5433147Sxc151355 bcopy(xrates + 2, rs->ir_rates + rs->ir_nrates, nxrates); 5443147Sxc151355 rs->ir_nrates += nxrates; 5453147Sxc151355 } 54610266SQuaker.Fang@Sun.COM return (ieee80211_fix_rate(in, &in->in_rates, flags)); 5473147Sxc151355 } 5483147Sxc151355 5493147Sxc151355 /* 5503147Sxc151355 * Process open-system authentication response frame and start 5513147Sxc151355 * association if the authentication request is accepted. 5523147Sxc151355 */ 5533147Sxc151355 static void 5543147Sxc151355 ieee80211_auth_open(ieee80211com_t *ic, struct ieee80211_frame *wh, 5553147Sxc151355 struct ieee80211_node *in, uint16_t seq, uint16_t status) 5563147Sxc151355 { 5573147Sxc151355 IEEE80211_LOCK_ASSERT(ic); 5583147Sxc151355 if (in->in_authmode == IEEE80211_AUTH_SHARED) { 5593147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, 5607249Sff224033 "open auth: bad sta auth mode %u", in->in_authmode); 5613147Sxc151355 return; 5623147Sxc151355 } 5633147Sxc151355 if (ic->ic_opmode == IEEE80211_M_STA) { 5643147Sxc151355 if (ic->ic_state != IEEE80211_S_AUTH || 5653147Sxc151355 seq != IEEE80211_AUTH_OPEN_RESPONSE) { 5663147Sxc151355 return; 5673147Sxc151355 } 5683147Sxc151355 IEEE80211_UNLOCK(ic); 5693147Sxc151355 if (status != 0) { 5703147Sxc151355 ieee80211_dbg(IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH, 5717249Sff224033 "open auth failed (reason %d)\n", status); 5723147Sxc151355 if (in != ic->ic_bss) 5733147Sxc151355 in->in_fails++; 5743147Sxc151355 ieee80211_new_state(ic, IEEE80211_S_SCAN, 0); 5753147Sxc151355 } else { 5763147Sxc151355 /* i_fc[0] - frame control's type & subtype field */ 5773147Sxc151355 ieee80211_new_state(ic, IEEE80211_S_ASSOC, 5787249Sff224033 wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK); 5793147Sxc151355 } 5803147Sxc151355 IEEE80211_LOCK(ic); 5813147Sxc151355 } else { 5823147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, "ieee80211_auth_open: " 5837249Sff224033 "bad operating mode %u", ic->ic_opmode); 5843147Sxc151355 } 5853147Sxc151355 } 5863147Sxc151355 5873147Sxc151355 /* 5883147Sxc151355 * Allocate challenge text for use by shared-key authentication 5893147Sxc151355 * Return B_TRUE on success, B_FALST otherwise. 5903147Sxc151355 */ 5913147Sxc151355 static boolean_t 5923147Sxc151355 ieee80211_alloc_challenge(struct ieee80211_node *in) 5933147Sxc151355 { 5943147Sxc151355 if (in->in_challenge == NULL) { 5953147Sxc151355 in->in_challenge = kmem_alloc(IEEE80211_CHALLENGE_LEN, 5967249Sff224033 KM_NOSLEEP); 5973147Sxc151355 } 5983147Sxc151355 if (in->in_challenge == NULL) { 5993147Sxc151355 ieee80211_dbg(IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH, 6007249Sff224033 "[%s] shared key challenge alloc failed\n", 6017249Sff224033 ieee80211_macaddr_sprintf(in->in_macaddr)); 6023147Sxc151355 } 6033147Sxc151355 return (in->in_challenge != NULL); 6043147Sxc151355 } 6053147Sxc151355 6063147Sxc151355 /* 6073147Sxc151355 * Process shared-key authentication response frames. If authentication 6083147Sxc151355 * succeeds, start association; otherwise, restart scan. 6093147Sxc151355 */ 6103147Sxc151355 static void 6113147Sxc151355 ieee80211_auth_shared(ieee80211com_t *ic, struct ieee80211_frame *wh, 6123147Sxc151355 uint8_t *frm, uint8_t *efrm, struct ieee80211_node *in, uint16_t seq, 6133147Sxc151355 uint16_t status) 6143147Sxc151355 { 6153147Sxc151355 uint8_t *challenge; 6163147Sxc151355 6173147Sxc151355 /* 6183147Sxc151355 * Pre-shared key authentication is evil; accept 6193147Sxc151355 * it only if explicitly configured (it is supported 6203147Sxc151355 * mainly for compatibility with clients like OS X). 6213147Sxc151355 */ 6223147Sxc151355 IEEE80211_LOCK_ASSERT(ic); 6233147Sxc151355 if (in->in_authmode != IEEE80211_AUTH_AUTO && 6243147Sxc151355 in->in_authmode != IEEE80211_AUTH_SHARED) { 6253147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, "ieee80211_auth_shared: " 6267249Sff224033 "bad sta auth mode %u", in->in_authmode); 6273147Sxc151355 goto bad; 6283147Sxc151355 } 6293147Sxc151355 6303147Sxc151355 challenge = NULL; 6313147Sxc151355 if (frm + 1 < efrm) { 6323147Sxc151355 /* 6333147Sxc151355 * Challenge text information element 6343147Sxc151355 * frm[0] - element ID 6353147Sxc151355 * frm[1] - length 6363147Sxc151355 * frm[2]... - challenge text 6373147Sxc151355 */ 6387249Sff224033 if ((frm[1] + 2) > (_PTRDIFF(efrm, frm))) { 6393147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, 6407249Sff224033 "ieee80211_auth_shared: ie %d%d too long\n", 6417249Sff224033 frm[0], (frm[1] + 2) - (_PTRDIFF(efrm, frm))); 6423147Sxc151355 goto bad; 6433147Sxc151355 } 6443147Sxc151355 if (*frm == IEEE80211_ELEMID_CHALLENGE) 6453147Sxc151355 challenge = frm; 6463147Sxc151355 frm += frm[1] + 2; 6473147Sxc151355 } 6483147Sxc151355 switch (seq) { 6493147Sxc151355 case IEEE80211_AUTH_SHARED_CHALLENGE: 6503147Sxc151355 case IEEE80211_AUTH_SHARED_RESPONSE: 6513147Sxc151355 if (challenge == NULL) { 6523147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, 6537249Sff224033 "ieee80211_auth_shared: no challenge\n"); 6543147Sxc151355 goto bad; 6553147Sxc151355 } 6563147Sxc151355 if (challenge[1] != IEEE80211_CHALLENGE_LEN) { 6573147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, 6587249Sff224033 "ieee80211_auth_shared: bad challenge len %d\n", 6597249Sff224033 challenge[1]); 6603147Sxc151355 goto bad; 6613147Sxc151355 } 6623147Sxc151355 default: 6633147Sxc151355 break; 6643147Sxc151355 } 6653147Sxc151355 switch (ic->ic_opmode) { 6663147Sxc151355 case IEEE80211_M_STA: 6673147Sxc151355 if (ic->ic_state != IEEE80211_S_AUTH) 6683147Sxc151355 return; 6693147Sxc151355 switch (seq) { 6703147Sxc151355 case IEEE80211_AUTH_SHARED_PASS: 6713147Sxc151355 if (in->in_challenge != NULL) { 6723147Sxc151355 kmem_free(in->in_challenge, 6733147Sxc151355 IEEE80211_CHALLENGE_LEN); 6743147Sxc151355 in->in_challenge = NULL; 6753147Sxc151355 } 6763147Sxc151355 if (status != 0) { 6773147Sxc151355 ieee80211_dbg(IEEE80211_MSG_DEBUG | 6787249Sff224033 IEEE80211_MSG_AUTH, 6797249Sff224033 "shared key auth failed (reason %d)\n", 6807249Sff224033 status); 6813147Sxc151355 if (in != ic->ic_bss) 6823147Sxc151355 in->in_fails++; 6833147Sxc151355 return; 6843147Sxc151355 } 6853147Sxc151355 IEEE80211_UNLOCK(ic); 6863147Sxc151355 ieee80211_new_state(ic, IEEE80211_S_ASSOC, 6877249Sff224033 wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK); 6883147Sxc151355 IEEE80211_LOCK(ic); 6893147Sxc151355 break; 6903147Sxc151355 case IEEE80211_AUTH_SHARED_CHALLENGE: 6913147Sxc151355 if (!ieee80211_alloc_challenge(in)) 6923147Sxc151355 return; 6933147Sxc151355 bcopy(&challenge[2], in->in_challenge, challenge[1]); 6943147Sxc151355 IEEE80211_UNLOCK(ic); 6953147Sxc151355 IEEE80211_SEND_MGMT(ic, in, IEEE80211_FC0_SUBTYPE_AUTH, 6967249Sff224033 seq + 1); 6973147Sxc151355 IEEE80211_LOCK(ic); 6983147Sxc151355 break; 6993147Sxc151355 default: 7003147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, "80211_auth_shared: " 7017249Sff224033 "shared key auth: bad seq %d", seq); 7023147Sxc151355 return; 7033147Sxc151355 } 7043147Sxc151355 break; 7053147Sxc151355 7063147Sxc151355 default: 7073147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, 7087249Sff224033 "ieee80211_auth_shared: bad opmode %u\n", 7097249Sff224033 ic->ic_opmode); 7103147Sxc151355 break; 7113147Sxc151355 } 7123147Sxc151355 return; 7133147Sxc151355 bad: 7143147Sxc151355 if (ic->ic_opmode == IEEE80211_M_STA) { 7153147Sxc151355 /* 7163147Sxc151355 * Kick the state machine. This short-circuits 7173147Sxc151355 * using the mgt frame timeout to trigger the 7183147Sxc151355 * state transition. 7193147Sxc151355 */ 7203147Sxc151355 if (ic->ic_state == IEEE80211_S_AUTH) { 7213147Sxc151355 IEEE80211_UNLOCK(ic); 7223147Sxc151355 ieee80211_new_state(ic, IEEE80211_S_SCAN, 0); 7233147Sxc151355 IEEE80211_LOCK(ic); 7243147Sxc151355 } 7253147Sxc151355 } 7263147Sxc151355 } 7273147Sxc151355 7284126Szf162725 static int 7294126Szf162725 iswpaoui(const uint8_t *frm) 7304126Szf162725 { 7319327SFei.Feng@Sun.COM uint32_t c; 7329327SFei.Feng@Sun.COM bcopy(frm + 2, &c, 4); 7339327SFei.Feng@Sun.COM return (frm[1] > 3 && LE_32(c) == ((WPA_OUI_TYPE << 24) | WPA_OUI)); 7344126Szf162725 } 7354126Szf162725 73610266SQuaker.Fang@Sun.COM #define LE_READ_4(p) \ 73710266SQuaker.Fang@Sun.COM ((uint32_t) \ 73810266SQuaker.Fang@Sun.COM ((((uint8_t *)(p))[0]) | (((uint8_t *)(p))[1] << 8) | \ 73910266SQuaker.Fang@Sun.COM (((uint8_t *)(p))[2] << 16) | (((uint8_t *)(p))[3] << 24))) 74010266SQuaker.Fang@Sun.COM 74110266SQuaker.Fang@Sun.COM #define LE_READ_2(p) \ 74210266SQuaker.Fang@Sun.COM ((uint16_t) \ 74310266SQuaker.Fang@Sun.COM (((uint8_t *)(p))[0]) | (((uint8_t *)(p))[1] << 8)) 74410266SQuaker.Fang@Sun.COM 74510266SQuaker.Fang@Sun.COM static int 74610266SQuaker.Fang@Sun.COM iswmeoui(const uint8_t *frm) 74710266SQuaker.Fang@Sun.COM { 74810266SQuaker.Fang@Sun.COM return (frm[1] > 3 && LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI)); 74910266SQuaker.Fang@Sun.COM } 75010266SQuaker.Fang@Sun.COM 75110266SQuaker.Fang@Sun.COM static int 75210266SQuaker.Fang@Sun.COM iswmeparam(const uint8_t *frm) 75310266SQuaker.Fang@Sun.COM { 75410266SQuaker.Fang@Sun.COM return (frm[1] > 5 && 75510266SQuaker.Fang@Sun.COM LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI) && 75610266SQuaker.Fang@Sun.COM frm[6] == WME_PARAM_OUI_SUBTYPE); 75710266SQuaker.Fang@Sun.COM } 75810266SQuaker.Fang@Sun.COM 75910266SQuaker.Fang@Sun.COM static int 76010266SQuaker.Fang@Sun.COM iswmeinfo(const uint8_t *frm) 76110266SQuaker.Fang@Sun.COM { 76210266SQuaker.Fang@Sun.COM return (frm[1] > 5 && 76310266SQuaker.Fang@Sun.COM LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI) && 76410266SQuaker.Fang@Sun.COM frm[6] == WME_INFO_OUI_SUBTYPE); 76510266SQuaker.Fang@Sun.COM } 76610266SQuaker.Fang@Sun.COM 76710266SQuaker.Fang@Sun.COM static int 76810266SQuaker.Fang@Sun.COM ishtcapoui(const uint8_t *frm) 76910266SQuaker.Fang@Sun.COM { 77010266SQuaker.Fang@Sun.COM return (frm[1] > 3 && 77110266SQuaker.Fang@Sun.COM LE_READ_4(frm+2) == ((BCM_OUI_HTCAP<<24)|BCM_OUI)); 77210266SQuaker.Fang@Sun.COM } 77310266SQuaker.Fang@Sun.COM 77410266SQuaker.Fang@Sun.COM static int 77510266SQuaker.Fang@Sun.COM ishtinfooui(const uint8_t *frm) 77610266SQuaker.Fang@Sun.COM { 77710266SQuaker.Fang@Sun.COM return (frm[1] > 3 && 77810266SQuaker.Fang@Sun.COM LE_READ_4(frm+2) == ((BCM_OUI_HTINFO<<24)|BCM_OUI)); 77910266SQuaker.Fang@Sun.COM } 78010266SQuaker.Fang@Sun.COM 78110266SQuaker.Fang@Sun.COM /* ARGSUSED */ 78210266SQuaker.Fang@Sun.COM static int 78310266SQuaker.Fang@Sun.COM ieee80211_parse_wmeparams(struct ieee80211com *ic, uint8_t *frm, 78410266SQuaker.Fang@Sun.COM const struct ieee80211_frame *wh) 78510266SQuaker.Fang@Sun.COM { 78610266SQuaker.Fang@Sun.COM #define MS(_v, _f) (((_v) & _f) >> _f##_S) 78710266SQuaker.Fang@Sun.COM struct ieee80211_wme_state *wme = &ic->ic_wme; 78810266SQuaker.Fang@Sun.COM uint_t len = frm[1]; 78910266SQuaker.Fang@Sun.COM uint8_t qosinfo; 79010266SQuaker.Fang@Sun.COM int i; 79110266SQuaker.Fang@Sun.COM 79210266SQuaker.Fang@Sun.COM if (len < sizeof (struct ieee80211_wme_param) - 2) { 79310266SQuaker.Fang@Sun.COM ieee80211_dbg(IEEE80211_MSG_ELEMID | IEEE80211_MSG_WME, 79410266SQuaker.Fang@Sun.COM "WME too short, len %u", len); 79510266SQuaker.Fang@Sun.COM return (-1); 79610266SQuaker.Fang@Sun.COM } 79710266SQuaker.Fang@Sun.COM qosinfo = frm[offsetof(struct ieee80211_wme_param, wme_qosInfo)]; 79810266SQuaker.Fang@Sun.COM qosinfo &= WME_QOSINFO_COUNT; 79910266SQuaker.Fang@Sun.COM /* do proper check for wraparound */ 80010266SQuaker.Fang@Sun.COM if (qosinfo == wme->wme_wmeChanParams.cap_info) 80110266SQuaker.Fang@Sun.COM return (0); 80210266SQuaker.Fang@Sun.COM frm += offsetof(struct ieee80211_wme_param, wme_acParams); 80310266SQuaker.Fang@Sun.COM for (i = 0; i < WME_NUM_AC; i++) { 80410266SQuaker.Fang@Sun.COM struct wmeParams *wmep = 80510266SQuaker.Fang@Sun.COM &wme->wme_wmeChanParams.cap_wmeParams[i]; 80610266SQuaker.Fang@Sun.COM /* NB: ACI not used */ 80710266SQuaker.Fang@Sun.COM wmep->wmep_acm = MS(frm[0], WME_PARAM_ACM); 80810266SQuaker.Fang@Sun.COM wmep->wmep_aifsn = MS(frm[0], WME_PARAM_AIFSN); 80910266SQuaker.Fang@Sun.COM wmep->wmep_logcwmin = MS(frm[1], WME_PARAM_LOGCWMIN); 81010266SQuaker.Fang@Sun.COM wmep->wmep_logcwmax = MS(frm[1], WME_PARAM_LOGCWMAX); 81110266SQuaker.Fang@Sun.COM wmep->wmep_txopLimit = LE_READ_2(frm+2); 81210266SQuaker.Fang@Sun.COM frm += 4; 81310266SQuaker.Fang@Sun.COM } 81410266SQuaker.Fang@Sun.COM wme->wme_wmeChanParams.cap_info = qosinfo; 81510266SQuaker.Fang@Sun.COM return (1); 81610266SQuaker.Fang@Sun.COM #undef MS 81710266SQuaker.Fang@Sun.COM } 81810266SQuaker.Fang@Sun.COM 8193147Sxc151355 /* 8203147Sxc151355 * Process a beacon/probe response frame. 8213147Sxc151355 * When the device is in station mode, create a node and add it 8223147Sxc151355 * to the node database for a new ESS or update node info if it's 8233147Sxc151355 * already there. 8243147Sxc151355 */ 8253147Sxc151355 static void 8263147Sxc151355 ieee80211_recv_beacon(ieee80211com_t *ic, mblk_t *mp, struct ieee80211_node *in, 8273147Sxc151355 int subtype, int rssi, uint32_t rstamp) 8283147Sxc151355 { 8293147Sxc151355 ieee80211_impl_t *im = ic->ic_private; 8303147Sxc151355 struct ieee80211_frame *wh; 8313147Sxc151355 uint8_t *frm; 8323147Sxc151355 uint8_t *efrm; /* end of frame body */ 8333147Sxc151355 struct ieee80211_scanparams scan; 8343147Sxc151355 8353147Sxc151355 wh = (struct ieee80211_frame *)mp->b_rptr; 8363147Sxc151355 frm = (uint8_t *)&wh[1]; 8373147Sxc151355 efrm = (uint8_t *)mp->b_wptr; 8383147Sxc151355 839*11224SQuaker.Fang@Sun.COM ic->ic_beaconmiss = 0; /* clear beacon miss counter */ 840*11224SQuaker.Fang@Sun.COM 8413147Sxc151355 /* 8423147Sxc151355 * We process beacon/probe response frames: 8433147Sxc151355 * o when scanning, or 8443147Sxc151355 * o station mode when associated (to collect state 8453147Sxc151355 * updates such as 802.11g slot time), or 8463147Sxc151355 * o adhoc mode (to discover neighbors) 8473147Sxc151355 * Frames otherwise received are discarded. 8483147Sxc151355 */ 8493147Sxc151355 if (!((ic->ic_flags & IEEE80211_F_SCAN) || 8503147Sxc151355 (ic->ic_opmode == IEEE80211_M_STA && in->in_associd != 0) || 8513147Sxc151355 ic->ic_opmode == IEEE80211_M_IBSS)) { 8523147Sxc151355 return; 8533147Sxc151355 } 8543147Sxc151355 8553147Sxc151355 /* 8563147Sxc151355 * beacon/probe response frame format 8573147Sxc151355 * [8] time stamp 8583147Sxc151355 * [2] beacon interval 8593147Sxc151355 * [2] capability information 8603147Sxc151355 * [tlv] ssid 8613147Sxc151355 * [tlv] supported rates 8623147Sxc151355 * [tlv] country information 8633147Sxc151355 * [tlv] parameter set (FH/DS) 8643147Sxc151355 * [tlv] erp information 8653147Sxc151355 * [tlv] extended supported rates 8663147Sxc151355 * [tlv] WME 8673147Sxc151355 * [tlv] WPA or RSN 86810266SQuaker.Fang@Sun.COM * [tlv] HT capabilities 86910266SQuaker.Fang@Sun.COM * [tlv] HT information 8703147Sxc151355 */ 8717249Sff224033 IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 8727249Sff224033 IEEE80211_BEACON_ELEM_MIN, return); 8733147Sxc151355 bzero(&scan, sizeof (scan)); 8743147Sxc151355 scan.tstamp = frm; 8753147Sxc151355 frm += 8; 8769327SFei.Feng@Sun.COM scan.bintval = LE_16(*(uint16_t *)frm); 8773147Sxc151355 frm += 2; 8789327SFei.Feng@Sun.COM scan.capinfo = LE_16(*(uint16_t *)frm); 8793147Sxc151355 frm += 2; 8803147Sxc151355 scan.bchan = ieee80211_chan2ieee(ic, ic->ic_curchan); 8813147Sxc151355 scan.chan = scan.bchan; 8823147Sxc151355 8833147Sxc151355 while (frm < efrm) { 8843147Sxc151355 /* Agere element in beacon */ 8853147Sxc151355 if ((*frm == IEEE80211_ELEMID_AGERE1) || 8863147Sxc151355 (*frm == IEEE80211_ELEMID_AGERE2)) { 8873147Sxc151355 frm = efrm; 8883147Sxc151355 break; 8893147Sxc151355 } 8903147Sxc151355 8917249Sff224033 IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), frm[1], return); 8923147Sxc151355 switch (*frm) { 8933147Sxc151355 case IEEE80211_ELEMID_SSID: 8943147Sxc151355 scan.ssid = frm; 8953147Sxc151355 break; 8963147Sxc151355 case IEEE80211_ELEMID_RATES: 8973147Sxc151355 scan.rates = frm; 8983147Sxc151355 break; 8993147Sxc151355 case IEEE80211_ELEMID_COUNTRY: 9003147Sxc151355 scan.country = frm; 9013147Sxc151355 break; 9023147Sxc151355 case IEEE80211_ELEMID_FHPARMS: 9033147Sxc151355 if (ic->ic_phytype == IEEE80211_T_FH) { 9043147Sxc151355 scan.fhdwell = LE_16(*(uint16_t *)(frm + 2)); 9053147Sxc151355 scan.chan = IEEE80211_FH_CHAN(frm[4], frm[5]); 9063147Sxc151355 scan.fhindex = frm[6]; 9073147Sxc151355 scan.phytype = IEEE80211_T_FH; 9083147Sxc151355 } 9093147Sxc151355 break; 9103147Sxc151355 case IEEE80211_ELEMID_DSPARMS: 9113147Sxc151355 if (ic->ic_phytype != IEEE80211_T_FH) { 9123147Sxc151355 scan.chan = frm[2]; 9133147Sxc151355 scan.phytype = IEEE80211_T_DS; 9143147Sxc151355 } 9153147Sxc151355 break; 9163147Sxc151355 case IEEE80211_ELEMID_TIM: 9173147Sxc151355 scan.tim = frm; 9187249Sff224033 scan.timoff = _PTRDIFF(frm, mp->b_rptr); 9193147Sxc151355 break; 9203147Sxc151355 case IEEE80211_ELEMID_IBSSPARMS: 9213147Sxc151355 break; 9223147Sxc151355 case IEEE80211_ELEMID_XRATES: 9233147Sxc151355 scan.xrates = frm; 9243147Sxc151355 break; 9253147Sxc151355 case IEEE80211_ELEMID_ERP: 9263147Sxc151355 if (frm[1] != 1) { 9273147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ELEMID, 9287249Sff224033 "ieee80211_recv_mgmt: ignore %s, " 9297249Sff224033 "invalid ERP element; " 9307249Sff224033 "length %u, expecting 1\n", 9317249Sff224033 IEEE80211_SUBTYPE_NAME(subtype), 9327249Sff224033 frm[1]); 9333147Sxc151355 break; 9343147Sxc151355 } 9353147Sxc151355 scan.erp = frm[2]; 9363147Sxc151355 scan.phytype = IEEE80211_T_OFDM; 9373147Sxc151355 break; 93810266SQuaker.Fang@Sun.COM case IEEE80211_ELEMID_HTCAP: 93910266SQuaker.Fang@Sun.COM scan.htcap = frm; 94010266SQuaker.Fang@Sun.COM break; 9413147Sxc151355 case IEEE80211_ELEMID_RSN: 9423147Sxc151355 scan.wpa = frm; 9433147Sxc151355 break; 94410266SQuaker.Fang@Sun.COM case IEEE80211_ELEMID_HTINFO: 94510266SQuaker.Fang@Sun.COM scan.htinfo = frm; 94610266SQuaker.Fang@Sun.COM break; 9474126Szf162725 case IEEE80211_ELEMID_VENDOR: 9484126Szf162725 if (iswpaoui(frm)) 9494126Szf162725 scan.wpa = frm; /* IEEE802.11i D3.0 */ 95010266SQuaker.Fang@Sun.COM else if (iswmeparam(frm) || iswmeinfo(frm)) 95110266SQuaker.Fang@Sun.COM scan.wme = frm; 95210266SQuaker.Fang@Sun.COM else if (ic->ic_flags_ext & IEEE80211_FEXT_HTCOMPAT) { 95310266SQuaker.Fang@Sun.COM /* 95410266SQuaker.Fang@Sun.COM * Accept pre-draft HT ie's if the 95510266SQuaker.Fang@Sun.COM * standard ones have not been seen. 95610266SQuaker.Fang@Sun.COM */ 95710266SQuaker.Fang@Sun.COM if (ishtcapoui(frm)) { 95810266SQuaker.Fang@Sun.COM if (scan.htcap == NULL) 95910266SQuaker.Fang@Sun.COM scan.htcap = frm; 96010266SQuaker.Fang@Sun.COM } else if (ishtinfooui(frm)) { 96110266SQuaker.Fang@Sun.COM if (scan.htinfo == NULL) 96210266SQuaker.Fang@Sun.COM scan.htinfo = frm; 96310266SQuaker.Fang@Sun.COM } 96410266SQuaker.Fang@Sun.COM } 9654126Szf162725 break; 9663147Sxc151355 default: 9673147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ELEMID, 9687249Sff224033 "ieee80211_recv_mgmt: ignore %s," 9697249Sff224033 "unhandled id %u, len %u, totallen %u", 9707249Sff224033 IEEE80211_SUBTYPE_NAME(subtype), 9717249Sff224033 *frm, frm[1], 9727249Sff224033 MBLKL(mp)); 9733147Sxc151355 break; 9743147Sxc151355 } 9753147Sxc151355 /* frm[1] - component length */ 9763147Sxc151355 frm += IEEE80211_ELEM_LEN(frm[1]); 9773147Sxc151355 } 9783147Sxc151355 IEEE80211_VERIFY_ELEMENT(scan.rates, IEEE80211_RATE_MAXSIZE, return); 9793147Sxc151355 IEEE80211_VERIFY_ELEMENT(scan.ssid, IEEE80211_NWID_LEN, return); 9803147Sxc151355 if (ieee80211_isclr(ic->ic_chan_active, scan.chan)) { 9813147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ELEMID | IEEE80211_MSG_INPUT, 9827249Sff224033 "ieee80211_recv_mgmt: ignore %s ," 9837249Sff224033 "invalid channel %u\n", 9847249Sff224033 IEEE80211_SUBTYPE_NAME(subtype), scan.chan); 9853147Sxc151355 return; 9863147Sxc151355 } 9873147Sxc151355 if (scan.chan != scan.bchan && 9883147Sxc151355 ic->ic_phytype != IEEE80211_T_FH) { 9893147Sxc151355 /* 9903147Sxc151355 * Frame was received on a channel different from the 9913147Sxc151355 * one indicated in the DS params element id; 9923147Sxc151355 * silently discard it. 9933147Sxc151355 * 9943147Sxc151355 * NB: this can happen due to signal leakage. 9953147Sxc151355 * But we should take it for FH phy because 9963147Sxc151355 * the rssi value should be correct even for 9973147Sxc151355 * different hop pattern in FH. 9983147Sxc151355 */ 9993147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ELEMID, 10007249Sff224033 "ieee80211_recv_mgmt: ignore %s ," 10017249Sff224033 "phytype %u channel %u marked for %u\n", 10027249Sff224033 IEEE80211_SUBTYPE_NAME(subtype), 10037249Sff224033 ic->ic_phytype, scan.bchan, scan.chan); 10043147Sxc151355 return; 10053147Sxc151355 } 10063147Sxc151355 if (!(IEEE80211_BINTVAL_MIN <= scan.bintval && 10073147Sxc151355 scan.bintval <= IEEE80211_BINTVAL_MAX)) { 10083147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ELEMID | IEEE80211_MSG_INPUT, 10097249Sff224033 "ieee80211_recv_mgmt: ignore %s ," 10107249Sff224033 "bogus beacon interval %u\n", 10117249Sff224033 IEEE80211_SUBTYPE_NAME(subtype), scan.bintval); 10123147Sxc151355 return; 10133147Sxc151355 } 101410266SQuaker.Fang@Sun.COM /* 101510266SQuaker.Fang@Sun.COM * Process HT ie's. This is complicated by our 101610266SQuaker.Fang@Sun.COM * accepting both the standard ie's and the pre-draft 101710266SQuaker.Fang@Sun.COM * vendor OUI ie's that some vendors still use/require. 101810266SQuaker.Fang@Sun.COM */ 101910266SQuaker.Fang@Sun.COM if (scan.htcap != NULL) { 102010266SQuaker.Fang@Sun.COM IEEE80211_VERIFY_LENGTH(scan.htcap[1], 102110266SQuaker.Fang@Sun.COM scan.htcap[0] == IEEE80211_ELEMID_VENDOR ? 102210266SQuaker.Fang@Sun.COM 4 + sizeof (struct ieee80211_ie_htcap) - 2 : 102310266SQuaker.Fang@Sun.COM sizeof (struct ieee80211_ie_htcap) - 2, 102410266SQuaker.Fang@Sun.COM scan.htcap = NULL); 102510266SQuaker.Fang@Sun.COM } 102610266SQuaker.Fang@Sun.COM if (scan.htinfo != NULL) { 102710266SQuaker.Fang@Sun.COM IEEE80211_VERIFY_LENGTH(scan.htinfo[1], 102810266SQuaker.Fang@Sun.COM scan.htinfo[0] == IEEE80211_ELEMID_VENDOR ? 102910266SQuaker.Fang@Sun.COM 4 + sizeof (struct ieee80211_ie_htinfo) - 2 : 103010266SQuaker.Fang@Sun.COM sizeof (struct ieee80211_ie_htinfo) - 2, 103110266SQuaker.Fang@Sun.COM scan.htinfo = NULL); 103210266SQuaker.Fang@Sun.COM } 10333147Sxc151355 10343147Sxc151355 /* 10353147Sxc151355 * When operating in station mode, check for state updates. 10363147Sxc151355 * Be careful to ignore beacons received while doing a 10373147Sxc151355 * background scan. We consider only 11g/WMM stuff right now. 10383147Sxc151355 */ 10393147Sxc151355 if (ic->ic_opmode == IEEE80211_M_STA && 10403147Sxc151355 in->in_associd != 0 && 10413147Sxc151355 (!(ic->ic_flags & IEEE80211_F_SCAN) || 10423147Sxc151355 IEEE80211_ADDR_EQ(wh->i_addr2, in->in_bssid))) { 10433147Sxc151355 /* record tsf of last beacon */ 10443147Sxc151355 bcopy(scan.tstamp, in->in_tstamp.data, 10453147Sxc151355 sizeof (in->in_tstamp)); 10463147Sxc151355 /* count beacon frame for s/w bmiss handling */ 10473147Sxc151355 im->im_swbmiss_count++; 10483147Sxc151355 im->im_bmiss_count = 0; 10493147Sxc151355 10503147Sxc151355 if ((in->in_capinfo ^ scan.capinfo) & 10513147Sxc151355 IEEE80211_CAPINFO_SHORT_SLOTTIME) { 10523147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ASSOC, 10537249Sff224033 "ieee80211_recv_mgmt: " 10547249Sff224033 "[%s] cap change: before 0x%x, now 0x%x\n", 10557249Sff224033 ieee80211_macaddr_sprintf(wh->i_addr2), 10567249Sff224033 in->in_capinfo, scan.capinfo); 10573147Sxc151355 /* 10583147Sxc151355 * NB: we assume short preamble doesn't 10593147Sxc151355 * change dynamically 10603147Sxc151355 */ 10613147Sxc151355 ieee80211_set_shortslottime(ic, 10627249Sff224033 ic->ic_curmode == IEEE80211_MODE_11A || 10637249Sff224033 (scan.capinfo & 10647249Sff224033 IEEE80211_CAPINFO_SHORT_SLOTTIME)); 10653147Sxc151355 in->in_capinfo = scan.capinfo; 10663147Sxc151355 } 106710266SQuaker.Fang@Sun.COM if (scan.wme != NULL && 106810266SQuaker.Fang@Sun.COM (in->in_flags & IEEE80211_NODE_QOS) && 106910266SQuaker.Fang@Sun.COM ieee80211_parse_wmeparams(ic, scan.wme, wh) > 0) { 107010266SQuaker.Fang@Sun.COM ieee80211_wme_updateparams(ic); 107110266SQuaker.Fang@Sun.COM } 107210266SQuaker.Fang@Sun.COM if (scan.htcap != NULL) 107310266SQuaker.Fang@Sun.COM ieee80211_parse_htcap(in, scan.htcap); 107410266SQuaker.Fang@Sun.COM if (scan.htinfo != NULL) { 107510266SQuaker.Fang@Sun.COM ieee80211_parse_htinfo(in, scan.htinfo); 107610266SQuaker.Fang@Sun.COM if (in->in_chan != ic->ic_curchan) { 107710266SQuaker.Fang@Sun.COM /* 107810266SQuaker.Fang@Sun.COM * Channel has been adjusted based on 107910266SQuaker.Fang@Sun.COM * negotiated HT parameters; force the 108010266SQuaker.Fang@Sun.COM * channel state to follow. 108110266SQuaker.Fang@Sun.COM */ 108210266SQuaker.Fang@Sun.COM ieee80211_setcurchan(ic, in->in_chan); 108310266SQuaker.Fang@Sun.COM } 108410266SQuaker.Fang@Sun.COM } 10853147Sxc151355 if (scan.tim != NULL) { 10863147Sxc151355 struct ieee80211_tim_ie *ie; 10873147Sxc151355 10883147Sxc151355 ie = (struct ieee80211_tim_ie *)scan.tim; 10893147Sxc151355 in->in_dtim_count = ie->tim_count; 10903147Sxc151355 in->in_dtim_period = ie->tim_period; 10913147Sxc151355 } 10923147Sxc151355 if (ic->ic_flags & IEEE80211_F_SCAN) { 10933147Sxc151355 ieee80211_add_scan(ic, &scan, wh, subtype, rssi, 10947249Sff224033 rstamp); 10953147Sxc151355 } 10963147Sxc151355 return; 10973147Sxc151355 } 10983147Sxc151355 /* 10993147Sxc151355 * If scanning, just pass information to the scan module. 11003147Sxc151355 */ 11013147Sxc151355 if (ic->ic_flags & IEEE80211_F_SCAN) { 11023147Sxc151355 ieee80211_add_scan(ic, &scan, wh, subtype, rssi, rstamp); 11033147Sxc151355 return; 11043147Sxc151355 } 11053147Sxc151355 11068594SFei.Feng@Sun.COM if (ic->ic_opmode == IEEE80211_M_IBSS && 11078594SFei.Feng@Sun.COM scan.capinfo & IEEE80211_CAPINFO_IBSS) { 11083147Sxc151355 if (!IEEE80211_ADDR_EQ(wh->i_addr2, in->in_macaddr)) { 11093147Sxc151355 /* 11103147Sxc151355 * Create a new entry in the neighbor table. 11113147Sxc151355 */ 11123147Sxc151355 in = ieee80211_add_neighbor(ic, wh, &scan); 11138594SFei.Feng@Sun.COM } else { 11143147Sxc151355 /* 11158594SFei.Feng@Sun.COM * Copy data from beacon to neighbor table. 11168594SFei.Feng@Sun.COM * Some of this information might change after 11178594SFei.Feng@Sun.COM * ieee80211_add_neighbor(), so we just copy 11188594SFei.Feng@Sun.COM * everything over to be safe. 11193147Sxc151355 */ 11203147Sxc151355 ieee80211_init_neighbor(in, wh, &scan); 11213147Sxc151355 } 11223147Sxc151355 if (in != NULL) { 11233147Sxc151355 in->in_rssi = (uint8_t)rssi; 11243147Sxc151355 in->in_rstamp = rstamp; 11253147Sxc151355 } 11263147Sxc151355 } 11273147Sxc151355 } 11283147Sxc151355 11293147Sxc151355 /* 11303147Sxc151355 * Perform input processing for 802.11 management frames. 11313147Sxc151355 * It's the default ic_recv_mgmt callback function for the interface 11323147Sxc151355 * softc, ic. Tipically ic_recv_mgmt is called within ieee80211_input() 11333147Sxc151355 */ 11343147Sxc151355 void 11353147Sxc151355 ieee80211_recv_mgmt(ieee80211com_t *ic, mblk_t *mp, struct ieee80211_node *in, 11363147Sxc151355 int subtype, int rssi, uint32_t rstamp) 11373147Sxc151355 { 11383147Sxc151355 struct ieee80211_frame *wh; 11393147Sxc151355 uint8_t *frm; /* pointer to start of the frame */ 11403147Sxc151355 uint8_t *efrm; /* pointer to end of the frame */ 11413147Sxc151355 uint8_t *ssid; 11423147Sxc151355 uint8_t *rates; 11433147Sxc151355 uint8_t *xrates; /* extended rates */ 114410266SQuaker.Fang@Sun.COM uint8_t *wme; 114510266SQuaker.Fang@Sun.COM uint8_t *htcap, *htinfo; 11463147Sxc151355 boolean_t allocbs = B_FALSE; 11473147Sxc151355 uint8_t rate; 11483147Sxc151355 uint16_t algo; /* authentication algorithm */ 11493147Sxc151355 uint16_t seq; /* sequence no */ 11503147Sxc151355 uint16_t status; 11513147Sxc151355 uint16_t capinfo; 11523147Sxc151355 uint16_t associd; /* association ID */ 115310266SQuaker.Fang@Sun.COM const struct ieee80211_action *ia; 11543147Sxc151355 11553147Sxc151355 IEEE80211_LOCK(ic); 11563147Sxc151355 wh = (struct ieee80211_frame *)mp->b_rptr; 11573147Sxc151355 frm = (uint8_t *)&wh[1]; 11583147Sxc151355 efrm = (uint8_t *)mp->b_wptr; 11593147Sxc151355 switch (subtype) { 11603147Sxc151355 case IEEE80211_FC0_SUBTYPE_PROBE_RESP: 11613147Sxc151355 case IEEE80211_FC0_SUBTYPE_BEACON: 11623147Sxc151355 ieee80211_recv_beacon(ic, mp, in, subtype, rssi, rstamp); 11633147Sxc151355 break; 11643147Sxc151355 11653147Sxc151355 case IEEE80211_FC0_SUBTYPE_PROBE_REQ: 11663147Sxc151355 if (ic->ic_opmode == IEEE80211_M_STA || 11673147Sxc151355 ic->ic_state != IEEE80211_S_RUN || 11683147Sxc151355 IEEE80211_IS_MULTICAST(wh->i_addr2)) { 11693147Sxc151355 break; 11703147Sxc151355 } 11713147Sxc151355 11723147Sxc151355 /* 11733147Sxc151355 * prreq frame format 11743147Sxc151355 * [tlv] ssid 11753147Sxc151355 * [tlv] supported rates 11763147Sxc151355 * [tlv] extended supported rates 11773147Sxc151355 */ 11783147Sxc151355 ssid = rates = xrates = NULL; 11793147Sxc151355 while (frm < efrm) { 11807249Sff224033 IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 11817249Sff224033 frm[1], goto out); 11823147Sxc151355 switch (*frm) { 11833147Sxc151355 case IEEE80211_ELEMID_SSID: 11843147Sxc151355 ssid = frm; 11853147Sxc151355 break; 11863147Sxc151355 case IEEE80211_ELEMID_RATES: 11873147Sxc151355 rates = frm; 11883147Sxc151355 break; 11893147Sxc151355 case IEEE80211_ELEMID_XRATES: 11903147Sxc151355 xrates = frm; 11913147Sxc151355 break; 11923147Sxc151355 } 11933147Sxc151355 frm += frm[1] + 2; 11943147Sxc151355 } 11953147Sxc151355 IEEE80211_VERIFY_ELEMENT(rates, IEEE80211_RATE_MAXSIZE, break); 11968594SFei.Feng@Sun.COM if (xrates != NULL) { 11978594SFei.Feng@Sun.COM IEEE80211_VERIFY_ELEMENT(xrates, 11988594SFei.Feng@Sun.COM IEEE80211_RATE_MAXSIZE - rates[1], break); 11998594SFei.Feng@Sun.COM } 12003147Sxc151355 IEEE80211_VERIFY_ELEMENT(ssid, IEEE80211_NWID_LEN, break); 12013147Sxc151355 IEEE80211_VERIFY_SSID(ic->ic_bss, ssid, break); 12028594SFei.Feng@Sun.COM if (ic->ic_flags & IEEE80211_F_HIDESSID) { 12038594SFei.Feng@Sun.COM if (ssid == NULL || ssid[1] == 0) { 12048594SFei.Feng@Sun.COM ieee80211_dbg(IEEE80211_MSG_INPUT, 12058594SFei.Feng@Sun.COM "ieee80211_recv_mgmt: ignore %s, " 12068594SFei.Feng@Sun.COM "no ssid with ssid suppression enabled", 12078594SFei.Feng@Sun.COM IEEE80211_SUBTYPE_NAME(subtype)); 12088594SFei.Feng@Sun.COM break; 12098594SFei.Feng@Sun.COM } 12103147Sxc151355 } 12113147Sxc151355 12123147Sxc151355 if (in == ic->ic_bss) { 12133147Sxc151355 if (ic->ic_opmode != IEEE80211_M_IBSS) { 12143147Sxc151355 in = ieee80211_tmp_node(ic, wh->i_addr2); 12153147Sxc151355 allocbs = B_TRUE; 12163147Sxc151355 } else if (!IEEE80211_ADDR_EQ(wh->i_addr2, 12173147Sxc151355 in->in_macaddr)) { 12183147Sxc151355 /* 12193147Sxc151355 * Cannot tell if the sender is operating 12203147Sxc151355 * in ibss mode. But we need a new node to 12213147Sxc151355 * send the response so blindly add them to the 12223147Sxc151355 * neighbor table. 12233147Sxc151355 */ 12243147Sxc151355 in = ieee80211_fakeup_adhoc_node(&ic->ic_sta, 12257249Sff224033 wh->i_addr2); 12263147Sxc151355 } 12273147Sxc151355 if (in == NULL) 12283147Sxc151355 break; 12293147Sxc151355 } 12303147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ASSOC, "ieee80211_recv_mgmt: " 12317249Sff224033 "[%s] recv probe req\n", 12327249Sff224033 ieee80211_macaddr_sprintf(wh->i_addr2)); 12333147Sxc151355 in->in_rssi = (uint8_t)rssi; 12343147Sxc151355 in->in_rstamp = rstamp; 12353147Sxc151355 /* 12363147Sxc151355 * Adjust and check station's rate list with device's 12373147Sxc151355 * supported rate. Send back response if there is at 12383147Sxc151355 * least one rate or the fixed rate(if being set) is 12393147Sxc151355 * supported by both station and the device 12403147Sxc151355 */ 12413147Sxc151355 rate = ieee80211_setup_rates(in, rates, xrates, 12427249Sff224033 IEEE80211_F_DOSORT | IEEE80211_F_DOFRATE | 12437249Sff224033 IEEE80211_F_DONEGO | IEEE80211_F_DODEL); 12443147Sxc151355 if (rate & IEEE80211_RATE_BASIC) { 12453147Sxc151355 ieee80211_dbg(IEEE80211_MSG_XRATE, "ieee80211_recv_mgmt" 12467249Sff224033 "%s recv'd rate set invalid", 12477249Sff224033 IEEE80211_SUBTYPE_NAME(subtype)); 12483147Sxc151355 } else { 12493147Sxc151355 IEEE80211_UNLOCK(ic); 12503147Sxc151355 IEEE80211_SEND_MGMT(ic, in, 12517249Sff224033 IEEE80211_FC0_SUBTYPE_PROBE_RESP, 0); 12523147Sxc151355 IEEE80211_LOCK(ic); 12533147Sxc151355 } 12543147Sxc151355 if (allocbs) { 12553147Sxc151355 /* 12563147Sxc151355 * Temporary node created just to send a 12573147Sxc151355 * response, reclaim immediately. 12583147Sxc151355 */ 12593147Sxc151355 ieee80211_free_node(in); 12603147Sxc151355 } 12613147Sxc151355 break; 12623147Sxc151355 12633147Sxc151355 case IEEE80211_FC0_SUBTYPE_AUTH: 12643147Sxc151355 /* 12653147Sxc151355 * auth frame format 12663147Sxc151355 * [2] algorithm 12673147Sxc151355 * [2] sequence 12683147Sxc151355 * [2] status 12693147Sxc151355 * [tlv*] challenge 12703147Sxc151355 */ 12717249Sff224033 IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 12727249Sff224033 IEEE80211_AUTH_ELEM_MIN, break); 12739327SFei.Feng@Sun.COM algo = LE_16(*(uint16_t *)frm); 12749327SFei.Feng@Sun.COM seq = LE_16(*(uint16_t *)(frm + 2)); 12759327SFei.Feng@Sun.COM status = LE_16(*(uint16_t *)(frm + 4)); 12763147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, "ieee80211_recv_mgmt: " 12777249Sff224033 "[%s] recv auth frame with algorithm %d seq %d\n", 12787249Sff224033 ieee80211_macaddr_sprintf(wh->i_addr2), algo, seq); 12793147Sxc151355 12803147Sxc151355 if (ic->ic_flags & IEEE80211_F_COUNTERM) { 12813147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH | IEEE80211_MSG_CRYPTO, 12827249Sff224033 "ieee80211_recv_mgmt: ignore auth, %s\n", 12837249Sff224033 "TKIP countermeasures enabled"); 12843147Sxc151355 break; 12853147Sxc151355 } 12863147Sxc151355 switch (algo) { 12873147Sxc151355 case IEEE80211_AUTH_ALG_SHARED: 12883147Sxc151355 ieee80211_auth_shared(ic, wh, frm + 6, efrm, in, 12897249Sff224033 seq, status); 12903147Sxc151355 break; 12913147Sxc151355 case IEEE80211_AUTH_ALG_OPEN: 12923147Sxc151355 ieee80211_auth_open(ic, wh, in, seq, status); 12933147Sxc151355 break; 12943147Sxc151355 default: 12953147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ANY, "ieee80211_recv_mgmt: " 12967249Sff224033 "ignore auth, unsupported alg %d", algo); 12973147Sxc151355 break; 12983147Sxc151355 } 12993147Sxc151355 break; 13003147Sxc151355 13013147Sxc151355 case IEEE80211_FC0_SUBTYPE_ASSOC_RESP: 13023147Sxc151355 case IEEE80211_FC0_SUBTYPE_REASSOC_RESP: 13033147Sxc151355 if (ic->ic_opmode != IEEE80211_M_STA || 13043147Sxc151355 ic->ic_state != IEEE80211_S_ASSOC) 13053147Sxc151355 break; 13063147Sxc151355 13073147Sxc151355 /* 13083147Sxc151355 * asresp frame format 13093147Sxc151355 * [2] capability information 13103147Sxc151355 * [2] status 13113147Sxc151355 * [2] association ID 13123147Sxc151355 * [tlv] supported rates 13133147Sxc151355 * [tlv] extended supported rates 13143147Sxc151355 * [tlv] WME 131510266SQuaker.Fang@Sun.COM * [tlv] HT capabilities 131610266SQuaker.Fang@Sun.COM * [tlv] HT info 13173147Sxc151355 */ 13187249Sff224033 IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 13197249Sff224033 IEEE80211_ASSOC_RESP_ELEM_MIN, break); 13203147Sxc151355 in = ic->ic_bss; 13219327SFei.Feng@Sun.COM capinfo = LE_16(*(uint16_t *)frm); 13223147Sxc151355 frm += 2; 13239327SFei.Feng@Sun.COM status = LE_16(*(uint16_t *)frm); 13243147Sxc151355 frm += 2; 13253147Sxc151355 if (status != 0) { 13263147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ASSOC, 13277249Sff224033 "assoc failed (reason %d)\n", status); 13283147Sxc151355 in = ieee80211_find_node(&ic->ic_scan, wh->i_addr2); 13293147Sxc151355 if (in != NULL) { 13303147Sxc151355 in->in_fails++; 13313147Sxc151355 ieee80211_free_node(in); 13323147Sxc151355 } 13333147Sxc151355 break; 13343147Sxc151355 } 13359327SFei.Feng@Sun.COM associd = LE_16(*(uint16_t *)frm); 13363147Sxc151355 frm += 2; 13373147Sxc151355 133810266SQuaker.Fang@Sun.COM rates = xrates = wme = htcap = htinfo = NULL; 13393147Sxc151355 while (frm < efrm) { 13403147Sxc151355 /* 13413147Sxc151355 * Do not discard frames containing proprietary Agere 13423147Sxc151355 * elements 128 and 129, as the reported element length 13433147Sxc151355 * is often wrong. Skip rest of the frame, since we can 13443147Sxc151355 * not rely on the given element length making it 13453147Sxc151355 * impossible to know where the next element starts 13463147Sxc151355 */ 13473147Sxc151355 if ((*frm == IEEE80211_ELEMID_AGERE1) || 13483147Sxc151355 (*frm == IEEE80211_ELEMID_AGERE2)) { 13493147Sxc151355 frm = efrm; 13503147Sxc151355 break; 13513147Sxc151355 } 13523147Sxc151355 13537249Sff224033 IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 13547249Sff224033 frm[1], goto out); 13553147Sxc151355 switch (*frm) { 13563147Sxc151355 case IEEE80211_ELEMID_RATES: 13573147Sxc151355 rates = frm; 13583147Sxc151355 break; 13593147Sxc151355 case IEEE80211_ELEMID_XRATES: 13603147Sxc151355 xrates = frm; 13613147Sxc151355 break; 136210266SQuaker.Fang@Sun.COM case IEEE80211_ELEMID_HTCAP: 136310266SQuaker.Fang@Sun.COM htcap = frm; 136410266SQuaker.Fang@Sun.COM break; 136510266SQuaker.Fang@Sun.COM case IEEE80211_ELEMID_HTINFO: 136610266SQuaker.Fang@Sun.COM htinfo = frm; 136710266SQuaker.Fang@Sun.COM break; 136810266SQuaker.Fang@Sun.COM case IEEE80211_ELEMID_VENDOR: 136910266SQuaker.Fang@Sun.COM if (iswmeoui(frm)) 137010266SQuaker.Fang@Sun.COM wme = frm; 137110266SQuaker.Fang@Sun.COM else if (ic->ic_flags_ext & 137210266SQuaker.Fang@Sun.COM IEEE80211_FEXT_HTCOMPAT) { 137310266SQuaker.Fang@Sun.COM /* 137410266SQuaker.Fang@Sun.COM * Accept pre-draft HT ie's if the 137510266SQuaker.Fang@Sun.COM * standard ones have not been seen. 137610266SQuaker.Fang@Sun.COM */ 137710266SQuaker.Fang@Sun.COM if (ishtcapoui(frm)) { 137810266SQuaker.Fang@Sun.COM if (htcap == NULL) 137910266SQuaker.Fang@Sun.COM htcap = frm; 138010266SQuaker.Fang@Sun.COM } else if (ishtinfooui(frm)) { 138110266SQuaker.Fang@Sun.COM if (htinfo == NULL) 138210266SQuaker.Fang@Sun.COM htinfo = frm; 138310266SQuaker.Fang@Sun.COM } 138410266SQuaker.Fang@Sun.COM } 138510266SQuaker.Fang@Sun.COM break; 13863147Sxc151355 } 13873147Sxc151355 frm += frm[1] + 2; 13883147Sxc151355 } 13893147Sxc151355 13903147Sxc151355 IEEE80211_VERIFY_ELEMENT(rates, IEEE80211_RATE_MAXSIZE, break); 13913147Sxc151355 /* 13923147Sxc151355 * Adjust and check AP's rate list with device's 13933147Sxc151355 * supported rate. Re-start scan if no rate is or the 13943147Sxc151355 * fixed rate(if being set) cannot be supported by 13953147Sxc151355 * either AP or the device. 13963147Sxc151355 */ 13973147Sxc151355 rate = ieee80211_setup_rates(in, rates, xrates, 13987249Sff224033 IEEE80211_F_DOSORT | IEEE80211_F_DOFRATE | 13997249Sff224033 IEEE80211_F_DONEGO | IEEE80211_F_DODEL); 14003147Sxc151355 if (rate & IEEE80211_RATE_BASIC) { 14013147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ASSOC, 14027249Sff224033 "assoc failed (rate set mismatch)\n"); 14033147Sxc151355 if (in != ic->ic_bss) 14043147Sxc151355 in->in_fails++; 14053147Sxc151355 IEEE80211_UNLOCK(ic); 14063147Sxc151355 ieee80211_new_state(ic, IEEE80211_S_SCAN, 0); 14073147Sxc151355 return; 14083147Sxc151355 } 14093147Sxc151355 14103147Sxc151355 in->in_capinfo = capinfo; 14113147Sxc151355 in->in_associd = associd; 141210266SQuaker.Fang@Sun.COM if (wme != NULL && 141310266SQuaker.Fang@Sun.COM ieee80211_parse_wmeparams(ic, wme, wh) >= 0) { 141410266SQuaker.Fang@Sun.COM in->in_flags |= IEEE80211_NODE_QOS; 141510266SQuaker.Fang@Sun.COM ieee80211_wme_updateparams(ic); 141610266SQuaker.Fang@Sun.COM } else { 141710266SQuaker.Fang@Sun.COM in->in_flags &= ~IEEE80211_NODE_QOS; 141810266SQuaker.Fang@Sun.COM } 141910266SQuaker.Fang@Sun.COM /* 142010266SQuaker.Fang@Sun.COM * Setup HT state according to the negotiation. 142110266SQuaker.Fang@Sun.COM */ 142210266SQuaker.Fang@Sun.COM if ((ic->ic_htcaps & IEEE80211_HTC_HT) && 142310266SQuaker.Fang@Sun.COM htcap != NULL && htinfo != NULL) { 142410266SQuaker.Fang@Sun.COM ieee80211_ht_node_init(in, htcap); 142510266SQuaker.Fang@Sun.COM ieee80211_parse_htinfo(in, htinfo); 142610266SQuaker.Fang@Sun.COM (void) ieee80211_setup_htrates(in, 142710266SQuaker.Fang@Sun.COM htcap, IEEE80211_F_JOIN | IEEE80211_F_DOBRS); 142810266SQuaker.Fang@Sun.COM ieee80211_setup_basic_htrates(in, htinfo); 142910266SQuaker.Fang@Sun.COM if (in->in_chan != ic->ic_curchan) { 143010266SQuaker.Fang@Sun.COM /* 143110266SQuaker.Fang@Sun.COM * Channel has been adjusted based on 143210266SQuaker.Fang@Sun.COM * negotiated HT parameters; force the 143310266SQuaker.Fang@Sun.COM * channel state to follow. 143410266SQuaker.Fang@Sun.COM */ 143510266SQuaker.Fang@Sun.COM ieee80211_setcurchan(ic, in->in_chan); 143610266SQuaker.Fang@Sun.COM } 143710266SQuaker.Fang@Sun.COM } 14383147Sxc151355 /* 14393147Sxc151355 * Configure state now that we are associated. 14403147Sxc151355 */ 14413147Sxc151355 if (ic->ic_curmode == IEEE80211_MODE_11A || 14423147Sxc151355 (in->in_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)) { 14433147Sxc151355 ic->ic_flags |= IEEE80211_F_SHPREAMBLE; 14443147Sxc151355 ic->ic_flags &= ~IEEE80211_F_USEBARKER; 14453147Sxc151355 } else { 14463147Sxc151355 ic->ic_flags &= ~IEEE80211_F_SHPREAMBLE; 14473147Sxc151355 ic->ic_flags |= IEEE80211_F_USEBARKER; 14483147Sxc151355 } 14493147Sxc151355 ieee80211_set_shortslottime(ic, 14507249Sff224033 ic->ic_curmode == IEEE80211_MODE_11A || 14517249Sff224033 (in->in_capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME)); 14523147Sxc151355 /* 14533147Sxc151355 * Honor ERP protection. 14543147Sxc151355 * 14553147Sxc151355 * NB: in_erp should zero for non-11g operation. 14563147Sxc151355 * check ic_curmode anyway 14573147Sxc151355 */ 14583147Sxc151355 if (ic->ic_curmode == IEEE80211_MODE_11G && 14593147Sxc151355 (in->in_erp & IEEE80211_ERP_USE_PROTECTION)) 14603147Sxc151355 ic->ic_flags |= IEEE80211_F_USEPROT; 14613147Sxc151355 else 14623147Sxc151355 ic->ic_flags &= ~IEEE80211_F_USEPROT; 14633147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ASSOC, 14647249Sff224033 "assoc success: %s preamble, %s slot time%s%s\n", 14657249Sff224033 ic->ic_flags&IEEE80211_F_SHPREAMBLE ? "short" : "long", 14667249Sff224033 ic->ic_flags&IEEE80211_F_SHSLOT ? "short" : "long", 14677249Sff224033 ic->ic_flags&IEEE80211_F_USEPROT ? ", protection" : "", 14687249Sff224033 in->in_flags & IEEE80211_NODE_QOS ? ", QoS" : ""); 14693147Sxc151355 IEEE80211_UNLOCK(ic); 14703147Sxc151355 ieee80211_new_state(ic, IEEE80211_S_RUN, subtype); 14713147Sxc151355 return; 14723147Sxc151355 14733147Sxc151355 case IEEE80211_FC0_SUBTYPE_DEAUTH: 14743147Sxc151355 if (ic->ic_state == IEEE80211_S_SCAN) 14753147Sxc151355 break; 14763147Sxc151355 14773147Sxc151355 /* 14783147Sxc151355 * deauth frame format 14793147Sxc151355 * [2] reason 14803147Sxc151355 */ 14817249Sff224033 IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 2, break); 14829327SFei.Feng@Sun.COM status = LE_16(*(uint16_t *)frm); 14833147Sxc151355 14843147Sxc151355 ieee80211_dbg(IEEE80211_MSG_AUTH, 14857249Sff224033 "recv deauthenticate (reason %d)\n", status); 14863147Sxc151355 switch (ic->ic_opmode) { 14873147Sxc151355 case IEEE80211_M_STA: 14883147Sxc151355 IEEE80211_UNLOCK(ic); 14893147Sxc151355 ieee80211_new_state(ic, IEEE80211_S_AUTH, 14907249Sff224033 wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK); 14913147Sxc151355 return; 14923147Sxc151355 default: 14933147Sxc151355 break; 14943147Sxc151355 } 14953147Sxc151355 break; 14963147Sxc151355 14973147Sxc151355 case IEEE80211_FC0_SUBTYPE_DISASSOC: 14983147Sxc151355 if (ic->ic_state != IEEE80211_S_RUN && 14993147Sxc151355 ic->ic_state != IEEE80211_S_ASSOC && 15003147Sxc151355 ic->ic_state != IEEE80211_S_AUTH) 15013147Sxc151355 break; 15023147Sxc151355 /* 15033147Sxc151355 * disassoc frame format 15043147Sxc151355 * [2] reason 15053147Sxc151355 */ 15067249Sff224033 IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 2, break); 15079327SFei.Feng@Sun.COM status = LE_16(*(uint16_t *)frm); 15083147Sxc151355 15093147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ASSOC, 15107249Sff224033 "recv disassociate (reason %d)\n", status); 15113147Sxc151355 switch (ic->ic_opmode) { 15123147Sxc151355 case IEEE80211_M_STA: 15133147Sxc151355 IEEE80211_UNLOCK(ic); 15143147Sxc151355 ieee80211_new_state(ic, IEEE80211_S_ASSOC, 15157249Sff224033 wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK); 15163147Sxc151355 return; 15173147Sxc151355 default: 15183147Sxc151355 break; 15193147Sxc151355 } 15203147Sxc151355 break; 15213147Sxc151355 152210266SQuaker.Fang@Sun.COM case IEEE80211_FC0_SUBTYPE_ACTION: 152310266SQuaker.Fang@Sun.COM if (ic->ic_state != IEEE80211_S_RUN && 152410266SQuaker.Fang@Sun.COM ic->ic_state != IEEE80211_S_ASSOC && 152510266SQuaker.Fang@Sun.COM ic->ic_state != IEEE80211_S_AUTH) 152610266SQuaker.Fang@Sun.COM break; 152710266SQuaker.Fang@Sun.COM 152810266SQuaker.Fang@Sun.COM /* 152910266SQuaker.Fang@Sun.COM * action frame format: 153010266SQuaker.Fang@Sun.COM * [1] category 153110266SQuaker.Fang@Sun.COM * [1] action 153210266SQuaker.Fang@Sun.COM * [tlv] parameters 153310266SQuaker.Fang@Sun.COM */ 153410266SQuaker.Fang@Sun.COM IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 153510266SQuaker.Fang@Sun.COM sizeof (struct ieee80211_action), break); 153610266SQuaker.Fang@Sun.COM ia = (const struct ieee80211_action *) frm; 153710266SQuaker.Fang@Sun.COM 153810266SQuaker.Fang@Sun.COM /* verify frame payloads but defer processing */ 153910266SQuaker.Fang@Sun.COM /* maybe push this to method */ 154010266SQuaker.Fang@Sun.COM switch (ia->ia_category) { 154110266SQuaker.Fang@Sun.COM case IEEE80211_ACTION_CAT_BA: 154210266SQuaker.Fang@Sun.COM switch (ia->ia_action) { 154310266SQuaker.Fang@Sun.COM case IEEE80211_ACTION_BA_ADDBA_REQUEST: 154410266SQuaker.Fang@Sun.COM IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 154510266SQuaker.Fang@Sun.COM sizeof (struct ieee80211_action_ba_addbarequest), 154610266SQuaker.Fang@Sun.COM break); 154710266SQuaker.Fang@Sun.COM break; 154810266SQuaker.Fang@Sun.COM case IEEE80211_ACTION_BA_ADDBA_RESPONSE: 154910266SQuaker.Fang@Sun.COM IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 155010266SQuaker.Fang@Sun.COM sizeof (struct ieee80211_action_ba_addbaresponse), 155110266SQuaker.Fang@Sun.COM break); 155210266SQuaker.Fang@Sun.COM break; 155310266SQuaker.Fang@Sun.COM case IEEE80211_ACTION_BA_DELBA: 155410266SQuaker.Fang@Sun.COM IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 155510266SQuaker.Fang@Sun.COM sizeof (struct ieee80211_action_ba_delba), 155610266SQuaker.Fang@Sun.COM break); 155710266SQuaker.Fang@Sun.COM break; 155810266SQuaker.Fang@Sun.COM } 155910266SQuaker.Fang@Sun.COM break; 156010266SQuaker.Fang@Sun.COM case IEEE80211_ACTION_CAT_HT: 156110266SQuaker.Fang@Sun.COM switch (ia->ia_action) { 156210266SQuaker.Fang@Sun.COM case IEEE80211_ACTION_HT_TXCHWIDTH: 156310266SQuaker.Fang@Sun.COM IEEE80211_VERIFY_LENGTH(_PTRDIFF(efrm, frm), 156410266SQuaker.Fang@Sun.COM sizeof (struct ieee80211_action_ht_txchwidth), 156510266SQuaker.Fang@Sun.COM break); 156610266SQuaker.Fang@Sun.COM break; 156710266SQuaker.Fang@Sun.COM } 156810266SQuaker.Fang@Sun.COM break; 156910266SQuaker.Fang@Sun.COM } 157010266SQuaker.Fang@Sun.COM ic->ic_recv_action(in, frm, efrm); 157110266SQuaker.Fang@Sun.COM break; 157210266SQuaker.Fang@Sun.COM 15733147Sxc151355 default: 15743147Sxc151355 ieee80211_dbg(IEEE80211_MSG_ANY, "ieee80211_recv_mgmt: " 15757249Sff224033 "subtype 0x%x not handled\n", subtype); 15763147Sxc151355 break; 15773147Sxc151355 } /* switch subtype */ 15783147Sxc151355 out: 15793147Sxc151355 IEEE80211_UNLOCK(ic); 15803147Sxc151355 } 1581