xref: /onnv-gate/usr/src/uts/common/io/net80211/net80211_impl.h (revision 10266:bbc5945eddd7)
13147Sxc151355 /*
2*10266SQuaker.Fang@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
8*10266SQuaker.Fang@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 #ifndef _SYS_NET80211_IMPL_H
393147Sxc151355 #define	_SYS_NET80211_IMPL_H
403147Sxc151355 
413147Sxc151355 #include <sys/sysmacros.h>
423147Sxc151355 #include <sys/list.h>
433147Sxc151355 #include <sys/note.h>
443147Sxc151355 #include <sys/net80211_proto.h>
453147Sxc151355 #include <sys/net80211.h>
463147Sxc151355 #include <sys/mac_wifi.h>
473147Sxc151355 
483147Sxc151355 /*
493147Sxc151355  * IEEE802.11 kernel support module
503147Sxc151355  */
513147Sxc151355 
523147Sxc151355 #ifdef	__cplusplus
533147Sxc151355 extern "C" {
543147Sxc151355 #endif
553147Sxc151355 
563147Sxc151355 #define	IEEE80211_TXPOWER_MAX	100	/* .5 dbM */
573147Sxc151355 #define	IEEE80211_TXPOWER_MIN	0	/* kill radio */
583147Sxc151355 
593147Sxc151355 #define	IEEE80211_DTIM_MAX	15	/* max DTIM period */
603147Sxc151355 #define	IEEE80211_DTIM_MIN	1	/* min DTIM period */
613147Sxc151355 #define	IEEE80211_DTIM_DEFAULT	1	/* default DTIM period */
623147Sxc151355 
633147Sxc151355 /* NB: min+max come from WiFi requirements */
643147Sxc151355 #define	IEEE80211_BINTVAL_MAX	1000	/* max beacon interval (TU's) */
653147Sxc151355 #define	IEEE80211_BINTVAL_MIN	25	/* min beacon interval (TU's) */
663147Sxc151355 #define	IEEE80211_BINTVAL_DEFAULT 100	/* default beacon interval (TU's) */
673147Sxc151355 
683147Sxc151355 #define	IEEE80211_BMISS_MAX	2	/* maximum consecutive bmiss allowed */
693147Sxc151355 #define	IEEE80211_SWBMISS_THRESHOLD 50	/* s/w bmiss threshold (TU's) */
703147Sxc151355 #define	IEEE80211_HWBMISS_DEFAULT 7	/* h/w bmiss threshold (beacons) */
713147Sxc151355 
723147Sxc151355 #define	IEEE80211_PS_SLEEP	0x1	/* STA is in power saving mode */
733147Sxc151355 #define	IEEE80211_PS_MAX_QUEUE	50	/* maximum saved packets */
743147Sxc151355 
753147Sxc151355 #define	IEEE80211_RTS_DEFAULT	IEEE80211_RTS_MAX
763147Sxc151355 #define	IEEE80211_FRAG_DEFAULT	IEEE80211_FRAG_MAX
773147Sxc151355 
783147Sxc151355 /*
793147Sxc151355  * The RSSI values of two node are taken as almost the same when
803147Sxc151355  * the difference between these two node's RSSI values is within
813147Sxc151355  * IEEE80211_RSSI_CMP_THRESHOLD
823147Sxc151355  */
833147Sxc151355 #define	IEEE80211_RSSI_CMP_THRESHOLD	5
843147Sxc151355 
853147Sxc151355 /*
863147Sxc151355  * Each ieee80211com instance has a single timer that fires once a
873147Sxc151355  * second.  This is used to initiate various work depending on the
883147Sxc151355  * state of the instance: scanning (passive or active), ``transition''
893147Sxc151355  * (waiting for a response to a management frame when operating
903147Sxc151355  * as a station), and node inactivity processing (when operating
913147Sxc151355  * as an AP).  For inactivity processing each node has a timeout
923147Sxc151355  * set in it's in_inact field that is decremented on each timeout
933147Sxc151355  * and the node is reclaimed when the counter goes to zero.  We
943147Sxc151355  * use different inactivity timeout values depending on whether
953147Sxc151355  * the node is associated and authorized (either by 802.1x or
963147Sxc151355  * open/shared key authentication) or associated but yet to be
973147Sxc151355  * authorized.  The latter timeout is shorter to more aggressively
983147Sxc151355  * reclaim nodes that leave part way through the 802.1x exchange.
993147Sxc151355  *
1003147Sxc151355  * IEEE80211_INACT_WAIT defines node table's inactivity interval in
1013147Sxc151355  * seconds. On timeout, node table's registered nt_timeout callback
1023147Sxc151355  * function is executed. Each node in the node table has a timeout
1033147Sxc151355  * set in its in_inact field with IEEE80211_INACT_<state>. In
1043147Sxc151355  * nt_timeout function, node table is iterated and each node's
1053147Sxc151355  * in_inact is decremented. So IEEE80211_INACT_<state> is defined in
1063147Sxc151355  * the form [inact_sec]/IEEE80211_INACT_WAIT.
1073147Sxc151355  *
1083147Sxc151355  */
1093147Sxc151355 #define	IEEE80211_INACT_WAIT	15	/* inactivity interval (secs) */
1103147Sxc151355 #define	IEEE80211_INACT_INIT	(30/IEEE80211_INACT_WAIT)	/* initial */
1113147Sxc151355 #define	IEEE80211_INACT_ASSOC	(180/IEEE80211_INACT_WAIT)
1123147Sxc151355 					/* associated but not authorized */
1133147Sxc151355 #define	IEEE80211_INACT_RUN	(300/IEEE80211_INACT_WAIT)	/* authorized */
1143147Sxc151355 #define	IEEE80211_INACT_PROBE	(30/IEEE80211_INACT_WAIT)	/* probe */
1153147Sxc151355 #define	IEEE80211_INACT_SCAN	(300/IEEE80211_INACT_WAIT)	/* scanned */
1163147Sxc151355 
1173147Sxc151355 #define	IEEE80211_TRANS_WAIT 	5	/* mgt frame tx timer (secs) */
1183147Sxc151355 
1193147Sxc151355 /*
1203147Sxc151355  * Useful combinations of channel characteristics.
1213147Sxc151355  */
1223147Sxc151355 #define	IEEE80211_CHAN_FHSS	\
1233147Sxc151355 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
1243147Sxc151355 #define	IEEE80211_CHAN_A	\
1253147Sxc151355 	(IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
1263147Sxc151355 #define	IEEE80211_CHAN_B	\
1273147Sxc151355 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
1283147Sxc151355 #define	IEEE80211_CHAN_PUREG	\
1293147Sxc151355 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
1303147Sxc151355 #define	IEEE80211_CHAN_G	\
1313147Sxc151355 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
1323147Sxc151355 #define	IEEE80211_CHAN_T	\
1333147Sxc151355 	(IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
1343147Sxc151355 #define	IEEE80211_CHAN_108G	\
1353147Sxc151355 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
136*10266SQuaker.Fang@Sun.COM #define	IEEE80211_CHAN_ST	\
137*10266SQuaker.Fang@Sun.COM 	(IEEE80211_CHAN_T | IEEE80211_CHAN_STURBO)
1383147Sxc151355 
1393147Sxc151355 #define	IEEE80211_CHAN_ALL	\
1403147Sxc151355 	(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
141*10266SQuaker.Fang@Sun.COM 	IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN |	\
142*10266SQuaker.Fang@Sun.COM 	IEEE80211_CHAN_HT)
1433147Sxc151355 #define	IEEE80211_CHAN_ALLTURBO	\
144*10266SQuaker.Fang@Sun.COM 	(IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)
1453147Sxc151355 
1463147Sxc151355 #define	IEEE80211_IS_CHAN_FHSS(_c)	\
1473147Sxc151355 	(((_c)->ich_flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
1483147Sxc151355 #define	IEEE80211_IS_CHAN_A(_c)		\
1493147Sxc151355 	(((_c)->ich_flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
1503147Sxc151355 #define	IEEE80211_IS_CHAN_B(_c)		\
1513147Sxc151355 	(((_c)->ich_flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
1523147Sxc151355 #define	IEEE80211_IS_CHAN_PUREG(_c)	\
1533147Sxc151355 	(((_c)->ich_flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
1543147Sxc151355 #define	IEEE80211_IS_CHAN_G(_c)		\
1553147Sxc151355 	(((_c)->ich_flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
1563147Sxc151355 #define	IEEE80211_IS_CHAN_ANYG(_c)	\
1573147Sxc151355 	(IEEE80211_IS_CHAN_PUREG(_c) || IEEE80211_IS_CHAN_G(_c))
1583147Sxc151355 #define	IEEE80211_IS_CHAN_T(_c)		\
1593147Sxc151355 	(((_c)->ich_flags & IEEE80211_CHAN_T) == IEEE80211_CHAN_T)
160*10266SQuaker.Fang@Sun.COM 		/* IEEE80211_IS_CHAN_108A */
1613147Sxc151355 #define	IEEE80211_IS_CHAN_108G(_c)	\
1623147Sxc151355 	(((_c)->ich_flags & IEEE80211_CHAN_108G) == IEEE80211_CHAN_108G)
163*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_ST(_c)	\
164*10266SQuaker.Fang@Sun.COM 	(((_c)->ich_flags & IEEE80211_CHAN_ST) == IEEE80211_CHAN_ST)
1653147Sxc151355 
1663147Sxc151355 #define	IEEE80211_IS_CHAN_OFDM(_c)	\
1673147Sxc151355 	((_c)->ich_flags & IEEE80211_CHAN_OFDM)
1683147Sxc151355 #define	IEEE80211_IS_CHAN_CCK(_c)	\
1693147Sxc151355 	((_c)->ich_flags & IEEE80211_CHAN_CCK)
1703147Sxc151355 #define	IEEE80211_IS_CHAN_GFSK(_c)	\
1713147Sxc151355 	((_c)->ich_flags & IEEE80211_CHAN_GFSK)
1723147Sxc151355 #define	IEEE80211_IS_CHAN_PASSIVE(_c)	\
1733147Sxc151355 	((_c)->ich_flags & IEEE80211_CHAN_PASSIVE)
1743147Sxc151355 
175*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_STURBO(_c) \
176*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_STURBO)
177*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_DTURBO(_c) \
178*10266SQuaker.Fang@Sun.COM 	(((_c)->ich_flags & \
179*10266SQuaker.Fang@Sun.COM 	(IEEE80211_CHAN_TURBO | IEEE80211_CHAN_STURBO)) == IEEE80211_CHAN_TURBO)
180*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_HALF(_c) \
181*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_HALF)
182*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_QUARTER(_c) \
183*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_QUARTER)
184*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_FULL(_c) \
185*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & (IEEE80211_CHAN_QUARTER | IEEE80211_CHAN_HALF))
186*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_GSM(_c) \
187*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_GSM)
188*10266SQuaker.Fang@Sun.COM 
189*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_HT(_c) \
190*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_HT)
191*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_HT20(_c) \
192*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_HT20)
193*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_HT40(_c) \
194*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_HT40)
195*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_HT40U(_c) \
196*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_HT40U)
197*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_HT40D(_c) \
198*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_HT40D)
199*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_HTA(_c) \
200*10266SQuaker.Fang@Sun.COM 	(IEEE80211_IS_CHAN_5GHZ(_c) && \
201*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_HT))
202*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_HTG(_c) \
203*10266SQuaker.Fang@Sun.COM 	(IEEE80211_IS_CHAN_2GHZ(_c) && \
204*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_HT))
205*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_DFS(_c) \
206*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_DFS)
207*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_NOADHOC(_c) \
208*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_NOADHOC)
209*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_NOHOSTAP(_c) \
210*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_NOHOSTAP)
211*10266SQuaker.Fang@Sun.COM #define	IEEE80211_IS_CHAN_11D(_c) \
212*10266SQuaker.Fang@Sun.COM 	((_c)->ich_flags & IEEE80211_CHAN_11D)
213*10266SQuaker.Fang@Sun.COM 
2143147Sxc151355 /* ni_chan encoding for FH phy */
2153147Sxc151355 #define	IEEE80211_FH_CHANMOD	80
2163147Sxc151355 #define	IEEE80211_FH_CHAN(set, pat)	\
2173147Sxc151355 	(((set) - 1) * IEEE80211_FH_CHANMOD + (pat))
2183147Sxc151355 #define	IEEE80211_FH_CHANSET(chan)	\
2193147Sxc151355 	((chan) / IEEE80211_FH_CHANMOD + 1)
2203147Sxc151355 #define	IEEE80211_FH_CHANPAT(chan)	\
2213147Sxc151355 	((chan) % IEEE80211_FH_CHANMOD)
2223147Sxc151355 
2233147Sxc151355 #define	IEEE80211_NODE_AUTH	0x0001		/* authorized for data */
2243147Sxc151355 #define	IEEE80211_NODE_QOS	0x0002		/* QoS enabled */
2253147Sxc151355 #define	IEEE80211_NODE_ERP	0x0004		/* ERP enabled */
2263147Sxc151355 #define	IEEE80211_NODE_PWR_MGT	0x0010		/* power save mode enabled */
2273147Sxc151355 #define	IEEE80211_NODE_AREF	0x0020		/* authentication ref held */
2283147Sxc151355 
2293147Sxc151355 #define	IEEE80211_MAXRSSI	127
2303147Sxc151355 
2313147Sxc151355 /* Debug Flags */
2327663SSowmini.Varadhan@Sun.COM #define	IEEE80211_MSG_BRUSSELS  0x80000000	/* BRUSSELS */
2333147Sxc151355 #define	IEEE80211_MSG_DEBUG	0x40000000	/* IFF_DEBUG equivalent */
2343147Sxc151355 #define	IEEE80211_MSG_DUMPPKTS	0x20000000	/* IFF_LINK2 equivalant */
2353147Sxc151355 #define	IEEE80211_MSG_CRYPTO	0x10000000	/* crypto work */
2363147Sxc151355 #define	IEEE80211_MSG_INPUT	0x08000000	/* input handling */
2373147Sxc151355 #define	IEEE80211_MSG_XRATE	0x04000000	/* rate set handling */
2383147Sxc151355 #define	IEEE80211_MSG_ELEMID	0x02000000	/* element id parsing */
2393147Sxc151355 #define	IEEE80211_MSG_NODE	0x01000000	/* node handling */
2403147Sxc151355 #define	IEEE80211_MSG_ASSOC	0x00800000	/* association handling */
2413147Sxc151355 #define	IEEE80211_MSG_AUTH	0x00400000	/* authentication handling */
2423147Sxc151355 #define	IEEE80211_MSG_SCAN	0x00200000	/* scanning */
2433147Sxc151355 #define	IEEE80211_MSG_OUTPUT	0x00100000	/* output handling */
2443147Sxc151355 #define	IEEE80211_MSG_STATE	0x00080000	/* state machine */
2453147Sxc151355 #define	IEEE80211_MSG_POWER	0x00040000	/* power save handling */
2463147Sxc151355 #define	IEEE80211_MSG_DOT1X	0x00020000	/* 802.1x authenticator */
2473147Sxc151355 #define	IEEE80211_MSG_DOT1XSM	0x00010000	/* 802.1x state machine */
2483147Sxc151355 #define	IEEE80211_MSG_RADIUS	0x00008000	/* 802.1x radius client */
2493147Sxc151355 #define	IEEE80211_MSG_RADDUMP	0x00004000	/* dump 802.1x radius packets */
2503147Sxc151355 #define	IEEE80211_MSG_RADKEYS	0x00002000	/* dump 802.1x keys */
2513147Sxc151355 #define	IEEE80211_MSG_WPA	0x00001000	/* WPA/RSN protocol */
2523147Sxc151355 #define	IEEE80211_MSG_ACL	0x00000800	/* ACL handling */
2533147Sxc151355 #define	IEEE80211_MSG_WME	0x00000400	/* WME protocol */
2543147Sxc151355 #define	IEEE80211_MSG_SUPERG	0x00000200	/* Atheros SuperG protocol */
2553147Sxc151355 #define	IEEE80211_MSG_DOTH	0x00000100	/* 802.11h support */
2563147Sxc151355 #define	IEEE80211_MSG_INACT	0x00000080	/* inactivity handling */
2573147Sxc151355 #define	IEEE80211_MSG_ROAM	0x00000040	/* sta-mode roaming */
2583147Sxc151355 #define	IEEE80211_MSG_CONFIG	0x00000020	/* wificonfig/dladm */
259*10266SQuaker.Fang@Sun.COM #define	IEEE80211_MSG_ACTION	0x00000010	/* action frame handling */
260*10266SQuaker.Fang@Sun.COM #define	IEEE80211_MSG_HT	0x00000008	/* 11n mode debug */
2613147Sxc151355 #define	IEEE80211_MSG_ANY	0xffffffff	/* anything */
2623147Sxc151355 
2633147Sxc151355 /* Error flags returned by ieee80211_match_bss */
2643147Sxc151355 #define	IEEE80211_BADCHAN	0x01
2653147Sxc151355 #define	IEEE80211_BADOPMODE	0x02
2663147Sxc151355 #define	IEEE80211_BADPRIVACY	0x04
2673147Sxc151355 #define	IEEE80211_BADRATE	0x08
2683147Sxc151355 #define	IEEE80211_BADESSID	0x10
2693147Sxc151355 #define	IEEE80211_BADBSSID	0x20
2703147Sxc151355 #define	IEEE80211_NODEFAIL	0x40
2713147Sxc151355 
2723147Sxc151355 typedef struct ieee80211_impl {
2733147Sxc151355 	struct ieee80211com	*ic;
2743147Sxc151355 	uint8_t			im_chan_avail[IEEE80211_CHAN_BYTES];
2753147Sxc151355 	uint8_t			im_chan_scan[IEEE80211_CHAN_BYTES];
2763147Sxc151355 
2773147Sxc151355 	uint8_t			im_bmiss_count;	/* current beacon miss count */
2783147Sxc151355 	int32_t			im_bmiss_max;	/* max bmiss before scan */
2793147Sxc151355 	timeout_id_t		im_swbmiss;
2803147Sxc151355 	uint16_t		im_swbmiss_count; /* beacons in last period */
2813147Sxc151355 	uint16_t		im_swbmiss_period;	/* s/w bmiss period */
2823147Sxc151355 
2833147Sxc151355 	int32_t			im_mgt_timer;	/* mgmt timeout, secs */
2843147Sxc151355 	int32_t			im_inact_timer;	/* inactivity timer wait, sec */
2853147Sxc151355 	int32_t			im_inact_init;	/* initial setting */
2863147Sxc151355 	int32_t			im_inact_assoc;	/* assoc but not authorized */
2873147Sxc151355 	int32_t			im_inact_run;	/* authorized setting */
2883147Sxc151355 	int32_t			im_inact_probe;	/* inactive probe time */
2893147Sxc151355 
2903147Sxc151355 	kcondvar_t		im_scan_cv;	/* wait scan complete */
2913147Sxc151355 } ieee80211_impl_t;
2923147Sxc151355 
2933147Sxc151355 /*
2943147Sxc151355  * Parameters supplied when adding/updating an entry in a
2953147Sxc151355  * scan cache.  Pointer variables should be set to NULL
2963147Sxc151355  * if no data is available.  Pointer references can be to
2973147Sxc151355  * local data; any information that is saved will be copied.
2983147Sxc151355  * All multi-byte values must be in host byte order.
2993147Sxc151355  */
3003147Sxc151355 struct ieee80211_scanparams {
3013147Sxc151355 	uint16_t		capinfo;	/* 802.11 capabilities */
3023147Sxc151355 	enum ieee80211_phytype	phytype;
3033147Sxc151355 	uint16_t		fhdwell;	/* FHSS dwell interval */
3043147Sxc151355 	uint8_t			chan;
3053147Sxc151355 	uint8_t			bchan;
3063147Sxc151355 	uint8_t			fhindex;
3073147Sxc151355 	uint8_t			erp;
3083147Sxc151355 	uint16_t		bintval;
3093147Sxc151355 	uint8_t			timoff;
3103147Sxc151355 	uint8_t			*tim;
3113147Sxc151355 	uint8_t			*tstamp;
3123147Sxc151355 	uint8_t			*country;
3133147Sxc151355 	uint8_t			*ssid;
3143147Sxc151355 	uint8_t			*rates;
3153147Sxc151355 	uint8_t			*xrates;
3163147Sxc151355 	uint8_t			*wpa;
3173147Sxc151355 	uint8_t			*wme;
318*10266SQuaker.Fang@Sun.COM 	uint8_t			*htcap;
319*10266SQuaker.Fang@Sun.COM 	uint8_t			*htinfo;
3203147Sxc151355 };
3213147Sxc151355 
3223147Sxc151355 #define	IEEE80211_SEND_MGMT(_ic, _in, _type, _arg)			\
3233147Sxc151355 	((*(_ic)->ic_send_mgmt)((_ic), (_in), (_type), (_arg)))
3243147Sxc151355 
3253147Sxc151355 /* Verify the existence and length of __elem or get out. */
3263147Sxc151355 #define	IEEE80211_VERIFY_ELEMENT(__elem, __maxlen, __func) do {		\
3273147Sxc151355 	_NOTE(CONSTCOND)						\
3283147Sxc151355 	if ((__elem) == NULL) {						\
3293147Sxc151355 		ieee80211_err("ieee80211: no #__elem \n");		\
3303147Sxc151355 		__func;							\
3313147Sxc151355 	}								\
3323147Sxc151355 	if ((__elem)[1] > (__maxlen)) {					\
3333147Sxc151355 		ieee80211_err("ieee80211: bad "#__elem " len %d\n",	\
3343147Sxc151355 		    (__elem)[1]);					\
3353147Sxc151355 		__func;							\
3363147Sxc151355 	}								\
3373147Sxc151355 	_NOTE(CONSTCOND)						\
3383147Sxc151355 } while (0)
3393147Sxc151355 
3403147Sxc151355 #define	IEEE80211_VERIFY_LENGTH(_len, _minlen, _func) do {		\
3413147Sxc151355 	_NOTE(CONSTCOND)						\
3423147Sxc151355 	if ((_len) < (_minlen)) {					\
3433147Sxc151355 		ieee80211_dbg(IEEE80211_MSG_ELEMID,			\
3443147Sxc151355 		    "ie of type %s too short",				\
3453147Sxc151355 		    ieee80211_mgt_subtype_name[subtype >>		\
3463147Sxc151355 			IEEE80211_FC0_SUBTYPE_SHIFT]);			\
3473147Sxc151355 		_func;							\
3483147Sxc151355 	}								\
3493147Sxc151355 	_NOTE(CONSTCOND)						\
3503147Sxc151355 } while (0)
3513147Sxc151355 
3523147Sxc151355 #define	IEEE80211_VERIFY_SSID(_in, _ssid, _func) do {			\
3533147Sxc151355 	_NOTE(CONSTCOND)						\
3543147Sxc151355 	ASSERT((_in) != NULL);						\
3553147Sxc151355 	if ((_ssid)[1] != 0 &&						\
3563147Sxc151355 	    ((_ssid)[1] != (_in)->in_esslen ||				\
3573147Sxc151355 	    bcmp((_ssid) + 2, (_in)->in_essid, (_ssid)[1]) != 0)) {	\
3583147Sxc151355 		_func;							\
3593147Sxc151355 	}								\
3603147Sxc151355 	_NOTE(CONSTCOND)						\
3613147Sxc151355 } while (0)
3623147Sxc151355 
3633147Sxc151355 #define	ieee80211_setbit(a, i)	((a)[(i)/NBBY] |= (1 << ((i)%NBBY)))
3643147Sxc151355 #define	ieee80211_clrbit(a, i)	((a)[(i)/NBBY] &= ~(1 << ((i)%NBBY)))
3653147Sxc151355 #define	ieee80211_isset(a, i)	((a)[(i)/NBBY] & (1 << ((i)%NBBY)))
3663147Sxc151355 #define	ieee80211_isclr(a, i)	(!((a)[(i)/NBBY] & (1 << ((i)%NBBY))))
3673147Sxc151355 
3683147Sxc151355 #define	IEEE80211_N(a)		(sizeof (a) / sizeof (a[0]))
3693147Sxc151355 
3703147Sxc151355 #define	IEEE80211_LOCK(_ic)		\
3713147Sxc151355 	mutex_enter(&(_ic)->ic_genlock)
3723147Sxc151355 #define	IEEE80211_UNLOCK(_ic)		\
3733147Sxc151355 	mutex_exit(&(_ic)->ic_genlock)
3743147Sxc151355 #define	IEEE80211_IS_LOCKED(_ic)	\
3753147Sxc151355 	mutex_owned(&(_ic)->ic_genlock)
3763147Sxc151355 #define	IEEE80211_LOCK_ASSERT(_ic)	\
3773147Sxc151355 	ASSERT(mutex_owned(&(_ic)->ic_genlock))
3783147Sxc151355 
3793147Sxc151355 #define	IEEE80211_NODE_LOCK(_nt)		\
3803147Sxc151355 	mutex_enter(&(_nt)->nt_nodelock)
3813147Sxc151355 #define	IEEE80211_NODE_UNLOCK(_nt)		\
3823147Sxc151355 	mutex_exit(&(_nt)->nt_nodelock)
3833147Sxc151355 #define	IEEE80211_NODE_IS_LOCKED(_nt)		\
3843147Sxc151355 	mutex_owned(&(_nt)->nt_nodelock)
3853147Sxc151355 #define	IEEE80211_NODE_LOCK_ASSERT(_nt)		\
3863147Sxc151355 	ASSERT(mutex_owned(&(_nt)->nt_nodelock))
3873147Sxc151355 #define	ieee80211_node_hash(addr)		\
3883147Sxc151355 	(((uint8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % IEEE80211_NODE_HASHSIZE)
3893147Sxc151355 
3903147Sxc151355 #define	IEEE80211_SCAN_LOCK(_nt)	mutex_enter(&(_nt)->nt_scanlock)
3913147Sxc151355 #define	IEEE80211_SCAN_UNLOCK(_nt)	mutex_exit(&(_nt)->nt_scanlock)
3923147Sxc151355 
3933147Sxc151355 #define	IEEE80211_RV(v)			((v) & IEEE80211_RATE_VAL)
3943147Sxc151355 
3953147Sxc151355 #define	IEEE80211_SUBTYPE_NAME(subtype)		\
3963147Sxc151355 	ieee80211_mgt_subtype_name[(subtype) >> IEEE80211_FC0_SUBTYPE_SHIFT]
3973147Sxc151355 
3983147Sxc151355 extern const char *ieee80211_mgt_subtype_name[];
3993147Sxc151355 extern const char *ieee80211_phymode_name[];
4003147Sxc151355 
4013147Sxc151355 void ieee80211_err(const int8_t *, ...);
4023147Sxc151355 void ieee80211_dbg(uint32_t, const int8_t *, ...);
4033147Sxc151355 
4044126Szf162725 void ieee80211_notify(ieee80211com_t *, wpa_event_type);
4054126Szf162725 void ieee80211_mac_update(ieee80211com_t *);
4064126Szf162725 
4074126Szf162725 uint64_t ieee80211_read_6(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
4084126Szf162725 
4093147Sxc151355 /* node */
4103147Sxc151355 void ieee80211_node_attach(ieee80211com_t *);
4113147Sxc151355 void ieee80211_node_lateattach(ieee80211com_t *);
4123147Sxc151355 void ieee80211_node_detach(ieee80211com_t *);
4133147Sxc151355 void ieee80211_reset_bss(ieee80211com_t *);
4143147Sxc151355 void ieee80211_cancel_scan(ieee80211com_t *);
4153147Sxc151355 void ieee80211_add_scan(ieee80211com_t *, const struct ieee80211_scanparams *,
4163147Sxc151355     const struct ieee80211_frame *, int, int, int);
4173147Sxc151355 void ieee80211_init_neighbor(ieee80211_node_t *, const struct ieee80211_frame *,
4183147Sxc151355     const struct ieee80211_scanparams *);
4193147Sxc151355 ieee80211_node_t *ieee80211_add_neighbor(ieee80211com_t *,
4203147Sxc151355     const struct ieee80211_frame *, const struct ieee80211_scanparams *);
4213147Sxc151355 void ieee80211_create_ibss(ieee80211com_t *, struct ieee80211_channel *);
4223147Sxc151355 ieee80211_node_t *ieee80211_fakeup_adhoc_node(ieee80211_node_table_t *,
4233147Sxc151355     const uint8_t *);
4243147Sxc151355 ieee80211_node_t *ieee80211_tmp_node(ieee80211com_t *, const uint8_t *);
425*10266SQuaker.Fang@Sun.COM void ieee80211_setcurchan(ieee80211com_t *, struct ieee80211_channel *);
4263147Sxc151355 
4273147Sxc151355 /* proto */
4283147Sxc151355 void ieee80211_proto_attach(ieee80211com_t *);
429*10266SQuaker.Fang@Sun.COM int ieee80211_fix_rate(ieee80211_node_t *, struct ieee80211_rateset *, int);
4303147Sxc151355 void ieee80211_setbasicrates(struct ieee80211_rateset *,
4313147Sxc151355     enum ieee80211_phymode);
4323147Sxc151355 void ieee80211_reset_erp(ieee80211com_t *);
4333147Sxc151355 void ieee80211_set_shortslottime(ieee80211com_t *, boolean_t);
4343147Sxc151355 
4353147Sxc151355 /* input */
4363147Sxc151355 int ieee80211_setup_rates(ieee80211_node_t *, const uint8_t *,
4373147Sxc151355     const uint8_t *, int);
4383147Sxc151355 void ieee80211_recv_mgmt(ieee80211com_t *, mblk_t *, ieee80211_node_t *,
4393147Sxc151355     int, int, uint32_t);
4403147Sxc151355 
4413147Sxc151355 /* output */
4423147Sxc151355 int ieee80211_send_probereq(ieee80211_node_t *, const uint8_t *,
4433147Sxc151355     const uint8_t *, const uint8_t *, const uint8_t *, size_t, const void *,
4443147Sxc151355     size_t);
4453147Sxc151355 int ieee80211_send_mgmt(ieee80211com_t *, ieee80211_node_t *, int, int);
4463147Sxc151355 int ieee80211_send_nulldata(ieee80211_node_t *);
447*10266SQuaker.Fang@Sun.COM int ieee80211_mgmt_output(ieee80211com_t *, ieee80211_node_t *, mblk_t *,
448*10266SQuaker.Fang@Sun.COM     int, int);
4493147Sxc151355 
4503147Sxc151355 /* crypto */
4513147Sxc151355 struct ieee80211_key *ieee80211_crypto_getkey(ieee80211com_t *);
4523147Sxc151355 uint8_t ieee80211_crypto_getciphertype(ieee80211com_t *);
4533147Sxc151355 
4543147Sxc151355 /* generic */
4553147Sxc151355 mblk_t *ieee80211_getmgtframe(uint8_t **, int);
4563147Sxc151355 void ieee80211_notify_node_join(ieee80211com_t *, ieee80211_node_t *);
4573147Sxc151355 void ieee80211_notify_node_leave(ieee80211com_t *, ieee80211_node_t *);
4583147Sxc151355 
459*10266SQuaker.Fang@Sun.COM /* WME */
460*10266SQuaker.Fang@Sun.COM void	ieee80211_wme_initparams(struct ieee80211com *);
461*10266SQuaker.Fang@Sun.COM void	ieee80211_wme_updateparams(struct ieee80211com *);
462*10266SQuaker.Fang@Sun.COM 
4633147Sxc151355 #ifdef	__cplusplus
4643147Sxc151355 }
4653147Sxc151355 #endif
4663147Sxc151355 
4673147Sxc151355 #endif	/* _SYS_NET80211_IMPL_H */
468