xref: /titanic_52/usr/src/uts/common/sys/net80211.h (revision 4e942d8cd27c7f8bb80549d7c2564445f19ba4a3)
1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2001 Atsushi Onoe
8  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * Alternatively, this software may be distributed under the terms of the
23  * GNU General Public License ("GPL") version 2 as published by the Free
24  * Software Foundation.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #pragma ident	"%Z%%M%	%I%	%E% SMI"
39 
40 #ifndef _SYS_NET80211_H
41 #define	_SYS_NET80211_H
42 
43 #include <sys/mac.h>
44 #include <sys/ethernet.h>
45 #include <sys/net80211_proto.h>
46 #include <sys/net80211_crypto.h>
47 
48 /*
49  * IEEE802.11 kernel support module
50  */
51 
52 #ifdef	__cplusplus
53 extern "C" {
54 #endif
55 
56 /* ic_caps */
57 #define	IEEE80211_C_WEP		0x00000001	/* CAPABILITY: WEP available */
58 #define	IEEE80211_C_TKIP	0x00000002	/* CAPABILITY: TKIP available */
59 #define	IEEE80211_C_AES		0x00000004	/* CAPABILITY: AES OCB avail */
60 #define	IEEE80211_C_AES_CCM	0x00000008	/* CAPABILITY: AES CCM avail */
61 #define	IEEE80211_C_CKIP	0x00000010	/* CAPABILITY: CKIP available */
62 #define	IEEE80211_C_FF		0x00000040	/* CAPABILITY: ATH FF avail */
63 #define	IEEE80211_C_TURBOP	0x00000080
64 				/* CAPABILITY: ATH Turbo available */
65 #define	IEEE80211_C_IBSS	0x00000100	/* CAPABILITY: IBSS available */
66 #define	IEEE80211_C_PMGT	0x00000200	/* CAPABILITY: Power mgmt */
67 #define	IEEE80211_C_HOSTAP	0x00000400	/* CAPABILITY: HOSTAP avail */
68 #define	IEEE80211_C_AHDEMO	0x00000800	/* CAPABILITY: Old Adhoc Demo */
69 #define	IEEE80211_C_SWRETRY	0x00001000	/* CAPABILITY: sw tx retry */
70 #define	IEEE80211_C_TXPMGT	0x00002000	/* CAPABILITY: tx power mgmt */
71 #define	IEEE80211_C_SHSLOT	0x00004000	/* CAPABILITY: short slottime */
72 #define	IEEE80211_C_SHPREAMBLE	0x00008000	/* CAPABILITY: short preamble */
73 #define	IEEE80211_C_MONITOR	0x00010000	/* CAPABILITY: monitor mode */
74 #define	IEEE80211_C_TKIPMIC	0x00020000	/* CAPABILITY: TKIP MIC avail */
75 #define	IEEE80211_C_WPA1	0x00800000	/* CAPABILITY: WPA1 avail */
76 #define	IEEE80211_C_WPA2	0x01000000	/* CAPABILITY: WPA2 avail */
77 #define	IEEE80211_C_WPA		0x01800000
78 				/* CAPABILITY: WPA1+WPA2 avail */
79 #define	IEEE80211_C_BURST	0x02000000	/* CAPABILITY: frame bursting */
80 #define	IEEE80211_C_WME		0x04000000	/* CAPABILITY: WME avail */
81 #define	IEEE80211_C_WDS		0x08000000	/* CAPABILITY: 4-addr support */
82 /* 0x10000000 reserved */
83 #define	IEEE80211_C_BGSCAN	0x20000000	/* CAPABILITY: bg scanning */
84 #define	IEEE80211_C_TXFRAG	0x40000000	/* CAPABILITY: tx fragments */
85 /* XXX protection/barker? */
86 
87 #define	IEEE80211_C_CRYPTO	0x0000001f	/* CAPABILITY: crypto alg's */
88 
89 /* ic_flags */
90 /* NB: bits 0x4c available */
91 #define	IEEE80211_F_FF		0x00000001	/* CONF: ATH FF enabled */
92 #define	IEEE80211_F_TURBOP	0x00000002	/* CONF: ATH Turbo enabled */
93 #define	IEEE80211_F_BURST	0x00000004	/* CONF: bursting enabled */
94 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_PRIVACY */
95 #define	IEEE80211_F_PRIVACY	0x00000010	/* CONF: privacy enabled */
96 #define	IEEE80211_F_PUREG	0x00000020	/* CONF: 11g w/o 11b sta's */
97 #define	IEEE80211_F_SCANONLY	0x00000040	/* CONF: scan only */
98 #define	IEEE80211_F_SCAN	0x00000080	/* STATUS: scanning */
99 #define	IEEE80211_F_ASCAN	0x00000100	/* STATUS: active scan */
100 #define	IEEE80211_F_SIBSS	0x00000200	/* STATUS: start IBSS */
101 /* NB: this is intentionally setup to be IEEE80211_CAPINFO_SHORT_SLOTTIME */
102 #define	IEEE80211_F_SHSLOT	0x00000400
103 				/* STATUS: use short slot time */
104 #define	IEEE80211_F_PMGTON	0x00000800	/* CONF: Power mgmt enable */
105 #define	IEEE80211_F_DESBSSID	0x00001000	/* CONF: des_bssid is set */
106 #define	IEEE80211_F_WME		0x00002000	/* CONF: enable WME use */
107 #define	IEEE80211_F_BGSCAN	0x00004000
108 				/* CONF: bg scan enabled (???) */
109 #define	IEEE80211_F_SWRETRY	0x00008000	/* CONF: sw tx retry enabled */
110 #define	IEEE80211_F_TXPOW_FIXED	0x00010000	/* TX Power: fixed rate */
111 #define	IEEE80211_F_IBSSON	0x00020000	/* CONF: IBSS creation enable */
112 #define	IEEE80211_F_SHPREAMBLE	0x00040000	/* STATUS: use short preamble */
113 #define	IEEE80211_F_DATAPAD	0x00080000	/* CONF: do alignment pad */
114 #define	IEEE80211_F_USEPROT	0x00100000	/* STATUS: protection enabled */
115 #define	IEEE80211_F_USEBARKER	0x00200000
116 				/* STATUS: use barker preamble */
117 #define	IEEE80211_F_TIMUPDATE	0x00400000	/* STATUS: update beacon tim */
118 #define	IEEE80211_F_WPA1	0x00800000	/* CONF: WPA enabled */
119 #define	IEEE80211_F_WPA2	0x01000000	/* CONF: WPA2 enabled */
120 #define	IEEE80211_F_WPA		0x01800000	/* CONF: WPA/WPA2 enabled */
121 #define	IEEE80211_F_DROPUNENC	0x02000000	/* CONF: drop unencrypted */
122 #define	IEEE80211_F_COUNTERM	0x04000000	/* CONF: TKIP countermeasures */
123 #define	IEEE80211_F_HIDESSID	0x08000000	/* CONF: hide SSID in beacon */
124 #define	IEEE80211_F_NOBRIDGE	0x10000000	/* CONF: dis. internal bridge */
125 #define	IEEE80211_F_WMEUPDATE	0x20000000	/* STATUS: update beacon wme */
126 
127 /* ic_flags_ext */
128 #define	IEEE80211_FEXT_WDS	0x00000001	/* CONF: 4 addr allowed */
129 /* 0x00000006 reserved */
130 #define	IEEE80211_FEXT_BGSCAN	0x00000008
131 				/* STATUS: enable full bgscan completion */
132 #define	IEEE80211_FEXT_ERPUPDATE 0x00000200	/* STATUS: update ERP element */
133 #define	IEEE80211_FEXT_SWBMISS	0x00000400	/* CONF: do bmiss in s/w */
134 
135 /*
136  * Channel attributes (ich_flags)
137  * bits 0-3 are for private use by drivers
138  */
139 #define	IEEE80211_CHAN_TURBO	0x0010	/* Turbo channel */
140 #define	IEEE80211_CHAN_CCK	0x0020	/* CCK channel */
141 #define	IEEE80211_CHAN_OFDM	0x0040	/* OFDM channel */
142 #define	IEEE80211_CHAN_2GHZ	0x0080	/* 2 GHz spectrum channel. */
143 #define	IEEE80211_CHAN_5GHZ	0x0100	/* 5 GHz spectrum channel */
144 #define	IEEE80211_CHAN_PASSIVE	0x0200	/* Only passive scan allowed */
145 #define	IEEE80211_CHAN_DYN	0x0400	/* Dynamic CCK-OFDM channel */
146 #define	IEEE80211_CHAN_GFSK	0x0800	/* GFSK channel (FHSS PHY) */
147 
148 #define	IEEE80211_CHAN_MAX	255
149 #define	IEEE80211_CHAN_BYTES	32	/* howmany(IEEE80211_CHAN_MAX, NBBY) */
150 #define	IEEE80211_CHAN_ANY	0xffff	/* token for ``any channel'' */
151 #define	IEEE80211_CHAN_ANYC	\
152 	((struct ieee80211_channel *)IEEE80211_CHAN_ANY)
153 
154 #define	IEEE80211_IS_CHAN_2GHZ(_c)	\
155 	(((_c)->ich_flags & IEEE80211_CHAN_2GHZ) != 0)
156 #define	IEEE80211_IS_CHAN_5GHZ(_c)	\
157 	(((_c)->ich_flags & IEEE80211_CHAN_5GHZ) != 0)
158 
159 #define	IEEE80211_NODE_HASHSIZE	32
160 
161 #define	IEEE80211_FIXED_RATE_NONE	0
162 #define	IEEE80211_MCAST_RATE_DEFAULT	(2*1)	/* default mcast rate (1M) */
163 
164 /* WME stream classes */
165 #define	WME_AC_BE		0	/* best effort */
166 #define	WME_AC_BK		1	/* background */
167 #define	WME_AC_VI		2	/* video */
168 #define	WME_AC_VO		3	/* voice */
169 
170 /*
171  * Authentication mode.
172  */
173 enum ieee80211_authmode {
174 	IEEE80211_AUTH_NONE	= 0,
175 	IEEE80211_AUTH_OPEN	= 1,	/* open */
176 	IEEE80211_AUTH_SHARED	= 2,	/* shared-key */
177 	IEEE80211_AUTH_8021X	= 3,	/* 802.1x */
178 	IEEE80211_AUTH_AUTO	= 4,	/* auto-select/accept */
179 	/* NB: these are used only for ioctls */
180 	IEEE80211_AUTH_WPA	= 5	/* WPA/RSN w/ 802.1x/PSK */
181 };
182 
183 enum ieee80211_state {
184 	IEEE80211_S_INIT	= 0,	/* default state */
185 	IEEE80211_S_SCAN	= 1,	/* scanning */
186 	IEEE80211_S_AUTH	= 2,	/* try to authenticate */
187 	IEEE80211_S_ASSOC	= 3,	/* try to assoc */
188 	IEEE80211_S_RUN		= 4	/* associated */
189 };
190 #define	IEEE80211_S_MAX	(IEEE80211_S_RUN+1)
191 
192 /*
193  * 802.11 rate set.
194  */
195 #define	IEEE80211_RATE_MAXSIZE	15	/* max rates we'll handle */
196 #define	IEEE80211_RATE_SIZE	8	/* 802.11 standard */
197 #define	IEEE80211_XRATE_SIZE	(IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE)
198 					/* size of extended supported rates */
199 struct ieee80211_rateset {
200 	uint8_t			ir_nrates;
201 	uint8_t			ir_rates[IEEE80211_RATE_MAXSIZE];
202 };
203 
204 /*
205  * Channels are specified by frequency and attributes.
206  */
207 struct ieee80211_channel {
208 	uint16_t		ich_freq;	/* setting in Mhz */
209 	uint16_t		ich_flags;	/* see below */
210 };
211 
212 struct ieee80211_device_stats {
213 	uint32_t		is_tx_frags;
214 	uint32_t		is_tx_bytes;
215 	uint32_t		is_tx_mcast;
216 	uint32_t		is_tx_failed;
217 	uint32_t		is_tx_retries;
218 	uint32_t		is_rts_success;
219 	uint32_t		is_rts_failure;
220 	uint32_t		is_ack_failure;
221 	uint32_t		is_rx_frags;
222 	uint32_t		is_rx_bytes;
223 	uint32_t		is_rx_mcast;
224 	uint32_t		is_rx_dups;
225 	uint32_t		is_fcs_errors;
226 	uint32_t		is_wep_errors;
227 	uint32_t		is_tx_nobuf;
228 	uint32_t		is_tx_unknownmgt;
229 };
230 
231 struct ieee80211_crypto_state;
232 typedef struct ieee80211_node_table ieee80211_node_table_t;
233 typedef struct ieee80211_node ieee80211_node_t;
234 typedef struct ieee80211com ieee80211com_t;
235 
236 struct ieee80211_node_table {
237 	struct ieee80211com	*nt_ic;		/* back reference */
238 
239 	const char		*nt_name;	/* for debugging */
240 	/* For node inactivity processing */
241 	int			nt_inact_timer;	/* inactivity timer */
242 	int			nt_inact_init;	/* initial node inact setting */
243 	void			(*nt_timeout)(struct ieee80211_node_table *);
244 	uint32_t		nt_scangen;	/* gen# for timeout scan */
245 	kmutex_t		nt_scanlock;    /* on nt_scangen */
246 	kmutex_t		nt_nodelock;	/* on node table */
247 
248 	int			nt_keyixmax;	/* keyixmap size */
249 	struct ieee80211_node	**nt_keyixmap;	/* key ix -> node map */
250 
251 	list_t			nt_node;	/* information of all nodes */
252 	list_t			nt_hash[IEEE80211_NODE_HASHSIZE];
253 };
254 
255 /*
256  * Node specific information.  Note that drivers are expected
257  * to derive from this structure to add device-specific per-node
258  * state.  This is done by overriding the ic_node_* methods in
259  * the ieee80211com structure.
260  */
261 struct ieee80211_node {
262 	struct ieee80211com		*in_ic;
263 	struct ieee80211_node_table	*in_table;
264 
265 	uint8_t			in_authmode;	/* authentication algorithm */
266 	uint16_t		in_flags;	/* special purpose state */
267 	uint16_t		in_associd;	/* assoc response */
268 	uint16_t		in_txpower;	/* current transmit power */
269 	uint16_t		in_vlan;	/* vlan tag */
270 	/*
271 	 * Tx/Rx sequence number.
272 	 * index 0 is used when QoS is not enabled. index 1-16 is used
273 	 * when QoS is enabled. 1-16 corresponds to TID 0-15.
274 	 */
275 	uint16_t		in_txseqs[17];	/* tx seq per-tid */
276 	uint16_t		in_rxseqs[17];	/* rx seq previous per-tid */
277 	clock_t			in_rxfragstamp;	/* time stamp of last rx frag */
278 	mblk_t			*in_rxfrag;	/* rx frag reassembly */
279 	uint32_t		in_scangen;	/* gen# for timeout scan */
280 	uint32_t		in_refcnt;
281 
282 	/* hardware */
283 	uint32_t		in_rstamp;	/* recv timestamp */
284 	uint8_t			in_rssi;	/* recv ssi */
285 
286 	/* header */
287 	uint8_t			in_macaddr[IEEE80211_ADDR_LEN];
288 	uint8_t			in_bssid[IEEE80211_ADDR_LEN];
289 
290 	/* beacon, probe response */
291 	union {
292 		uint8_t		data[8];
293 		uint64_t	tsf;
294 	} in_tstamp;				/* from last rcv'd beacon */
295 	uint16_t		in_intval;	/* beacon interval */
296 	uint16_t		in_capinfo;	/* capabilities */
297 	uint8_t			in_esslen;
298 	uint8_t			in_essid[IEEE80211_NWID_LEN];
299 	struct ieee80211_rateset in_rates;	/* negotiated rate set */
300 	struct ieee80211_channel *in_chan;	/* XXX multiple uses */
301 	enum ieee80211_phytype	in_phytype;
302 	uint16_t		in_fhdwell;	/* FH only */
303 	uint8_t			in_fhindex;	/* FH only */
304 	uint8_t			in_erp;		/* ERP from beacon/probe resp */
305 	uint16_t		in_tim_off;	/* byte offset to TIM ie */
306 	uint8_t			in_dtim_period;	/* DTIM period */
307 	uint8_t			in_dtim_count;	/* DTIM count for last bcn */
308 
309 	uint32_t		*in_challenge;	/* shared-key challenge */
310 	struct ieee80211_key	in_ucastkey;	/* unicast key */
311 
312 	/* others */
313 	int32_t			in_fails;	/* failure count to associate */
314 	int16_t			in_inact;	/* inactivity mark count */
315 	int16_t			in_inact_reload; /* inactivity reload value */
316 	int32_t			in_txrate;	/* index to ni_rates[] */
317 
318 	list_node_t		in_node;	/* element of nt->nt_node */
319 	list_node_t		in_hash;	/* element of nt->nt_hash */
320 };
321 
322 struct ieee80211com {
323 	mac_handle_t		ic_mach;
324 
325 	/* Initialized by driver */
326 	uint8_t			ic_macaddr[IEEE80211_ADDR_LEN];
327 	uint32_t		ic_caps;	/* capabilities */
328 	enum ieee80211_phytype	ic_phytype;	/* XXX wrong for multi-mode */
329 	enum ieee80211_opmode	ic_opmode;	/* current operation mode */
330 	enum ieee80211_state	ic_state;	/* current 802.11 state */
331 	struct ieee80211_channel	ic_sup_channels[IEEE80211_CHAN_MAX+1];
332 	struct ieee80211_rateset	ic_sup_rates[IEEE80211_MODE_MAX];
333 	enum ieee80211_phymode		ic_curmode;  /* OPT current mode */
334 	struct ieee80211_channel	*ic_curchan; /* OPT current channel */
335 	struct ieee80211_channel	*ic_ibss_chan;	/* OPT bss channel */
336 	uint8_t				ic_maxrssi;  /* maximum hardware RSSI */
337 
338 	/* INITIALIZED by IEEE80211, used/overridden by driver */
339 	uint16_t		ic_modecaps;	/* set of mode capabilities */
340 	uint8_t			ic_chan_active[IEEE80211_CHAN_BYTES];
341 	enum ieee80211_protmode	ic_protmode;	/* 802.11g protection mode */
342 	uint16_t		ic_bintval;	/* beacon interval */
343 	uint16_t		ic_lintval;	/* listen interval */
344 	uint16_t		ic_txpowlimit;	/* global tx power limit */
345 	uint8_t			ic_bmissthreshold;
346 	uint16_t		ic_rtsthreshold;
347 	uint16_t		ic_fragthreshold;
348 	int32_t			ic_mcast_rate;	/* rate for mcast frames */
349 	uint8_t			ic_fixed_rate;	/* value of fixed rate */
350 	int32_t			ic_des_esslen;	/* length of desired essid */
351 	uint8_t			ic_des_essid[IEEE80211_NWID_LEN];
352 	uint8_t			ic_des_bssid[IEEE80211_ADDR_LEN];
353 	struct ieee80211_channel	*ic_des_chan;	/* desired channel */
354 	void			*ic_opt_ie;	/* user-specified IE's */
355 	uint16_t		ic_opt_ie_len;	/* length of ic_opt_ie */
356 	uint8_t			ic_nickname[IEEE80211_NWID_LEN];
357 	uint16_t		ic_tim_len;	/* ic_tim_bitmap size (bytes) */
358 	uint8_t			*ic_tim_bitmap;	/* powersave stations w/ data */
359 	timeout_id_t		ic_watchdog_timer;	/* watchdog timer */
360 	/* Cipher state/configuration. */
361 	struct ieee80211_crypto_state	ic_crypto;
362 
363 	/* Runtime states */
364 	uint32_t		ic_flags;	/* state/conf flags */
365 	uint32_t		ic_flags_ext;	/* extended state flags */
366 	struct ieee80211_node	*ic_bss;	/* information for this node */
367 	struct ieee80211_device_stats	ic_stats;
368 	struct ieee80211_node_table	ic_scan; /* STA: scan candidates */
369 	struct ieee80211_node_table	ic_sta; /* AP:stations/IBSS:neighbors */
370 
371 	/* callback functions */
372 	/*
373 	 * Functions initialized by driver before calling ieee80211_attach()
374 	 * Those must be initialized are marked with M(andatory)
375 	 *
376 	 *  ic_xmit		- [M] transmit a management or null data frame
377 	 *			return 0 on success, non-zero on error
378 	 *  ic_watchdog		- [O] periodic run function, enabled by
379 	 *			ieee80211_start_watchdog()
380 	 *  ic_set_tim		- [O] set/clear traffic indication map
381 	 *  ic_set_shortslot	- [O] enable/disable short slot timing
382 	 *  ic_node_newassoc	- [O] driver specific operation on a newly
383 	 *			associated or re-assoced node
384 	 */
385 	int			(*ic_xmit)(ieee80211com_t *, mblk_t *, uint8_t);
386 	void			(*ic_watchdog)(void *);
387 	void			(*ic_set_tim)(ieee80211com_t *,
388 					ieee80211_node_t *, int);
389 	void			(*ic_set_shortslot)(ieee80211com_t *, int);
390 	void			(*ic_node_newassoc)(ieee80211_node_t *, int);
391 	/*
392 	 * Functions initialized by ieee80211_attach(), driver could
393 	 * override these functions after calling ieee80211_attach()
394 	 *
395 	 *  ic_reset		- reset
396 	 *  ic_recv_mgmt	- handle received management frames
397 	 *  ic_send_mgmt	- construct and transmit management frames
398 	 *  ic_newstate		- handle state transition
399 	 *  ic_node_alloc	- allocate a new BSS info node
400 	 *  ic_node_cleanup	- cleanup or free memory spaces of a node
401 	 *  ic_node_free	- free a node
402 	 *  ic_node_getrssi	- get node's rssi
403 	 */
404 	int			(*ic_reset)(ieee80211com_t *);
405 	void			(*ic_recv_mgmt)(ieee80211com_t *,
406 					mblk_t *, ieee80211_node_t *,
407 					int, int, uint32_t);
408 	int			(*ic_send_mgmt)(ieee80211com_t *,
409 					ieee80211_node_t *, int, int);
410 	int			(*ic_newstate)(ieee80211com_t *,
411 					enum ieee80211_state, int);
412 	struct ieee80211_node	*(*ic_node_alloc)(ieee80211com_t *);
413 	void			(*ic_node_cleanup)(ieee80211_node_t *);
414 	void			(*ic_node_free)(ieee80211_node_t *);
415 	uint8_t			(*ic_node_getrssi)(const ieee80211_node_t *);
416 
417 	kmutex_t		ic_genlock;
418 	void			*ic_private;	/* ieee80211 private data */
419 };
420 #define	ic_nw_keys		ic_crypto.cs_nw_keys
421 #define	ic_def_txkey		ic_crypto.cs_def_txkey
422 
423 extern	const char *ieee80211_state_name[IEEE80211_S_MAX];
424 
425 #define	IEEE80211_RATE(_ix)			\
426 	(in->in_rates.ir_rates[(_ix)] & IEEE80211_RATE_VAL)
427 
428 #define	ieee80211_new_state(_ic, _nstate, _arg)	\
429 	(((_ic)->ic_newstate)((_ic), (_nstate), (_arg)))
430 
431 #define	ieee80211_macaddr_sprintf(_addr)	\
432 	ether_sprintf((struct ether_addr *)(_addr))
433 
434 /*
435  * Node reference counting definitions.
436  *
437  * ieee80211_node_initref	initialize the reference count to 1
438  * ieee80211_node_incref	add a reference
439  * ieee80211_node_decref	remove a reference
440  * ieee80211_node_decref_nv	remove a reference and return new value
441  * ieee80211_node_refcnt	reference count for printing (only)
442  */
443 #include <sys/atomic.h>
444 #define	ieee80211_node_initref(_in)		\
445 	((_in)->in_refcnt = 1)
446 #define	ieee80211_node_incref(_in)		\
447 	atomic_inc_uint(&(_in)->in_refcnt)
448 #define	ieee80211_node_decref(_in)		\
449 	atomic_dec_uint(&(_in)->in_refcnt)
450 #define	ieee80211_node_decref_nv(_in)		\
451 	atomic_dec_uint_nv(&(_in)->in_refcnt)
452 #define	ieee80211_node_refcnt(_in)		\
453 	(_in)->in_refcnt
454 
455 typedef void ieee80211_iter_func(void *, ieee80211_node_t *);
456 
457 /* Initialization */
458 void ieee80211_attach(ieee80211com_t *);
459 void ieee80211_detach(ieee80211com_t *);
460 void ieee80211_media_init(ieee80211com_t *);
461 int ieee80211_ioctl(ieee80211com_t *, queue_t *, mblk_t *);
462 
463 /* Protocol Processing */
464 int ieee80211_input(ieee80211com_t *, mblk_t *, ieee80211_node_t *,
465 	int32_t, uint32_t);
466 mblk_t *ieee80211_encap(ieee80211com_t *, mblk_t *, ieee80211_node_t *);
467 
468 mblk_t *ieee80211_beacon_alloc(ieee80211com_t *, ieee80211_node_t *,
469 	struct ieee80211_beacon_offsets *);
470 int ieee80211_beacon_update(ieee80211com_t *, ieee80211_node_t *,
471 	struct ieee80211_beacon_offsets *, mblk_t *, int);
472 void ieee80211_beacon_miss(ieee80211com_t *);
473 
474 void ieee80211_begin_scan(ieee80211com_t *, boolean_t);
475 void ieee80211_next_scan(ieee80211com_t *);
476 void ieee80211_end_scan(ieee80211com_t *);
477 void ieee80211_cancel_scan(ieee80211com_t *);
478 
479 void ieee80211_sta_join(ieee80211com_t *, ieee80211_node_t *);
480 void ieee80211_sta_leave(ieee80211com_t *, ieee80211_node_t *);
481 boolean_t ieee80211_ibss_merge(ieee80211_node_t *);
482 
483 /* Node Operation */
484 ieee80211_node_t *ieee80211_ref_node(ieee80211_node_t *);
485 void ieee80211_unref_node(ieee80211_node_t **);
486 void ieee80211_node_authorize(ieee80211_node_t *);
487 void ieee80211_node_unauthorize(ieee80211_node_t *);
488 ieee80211_node_t *ieee80211_alloc_node(ieee80211com_t *,
489 	ieee80211_node_table_t *, const uint8_t *);
490 void ieee80211_free_node(ieee80211_node_t *);
491 void ieee80211_node_table_reset(ieee80211_node_table_t *);
492 void ieee80211_iterate_nodes(ieee80211_node_table_t *, ieee80211_iter_func *,
493 	void *);
494 ieee80211_node_t *ieee80211_find_node(ieee80211_node_table_t *,
495 	const uint8_t *);
496 ieee80211_node_t *ieee80211_find_txnode(ieee80211com_t *,
497 	const uint8_t daddr[IEEE80211_ADDR_LEN]);
498 ieee80211_node_t *ieee80211_find_rxnode(ieee80211com_t *,
499 	const struct ieee80211_frame *);
500 
501 
502 /* Crypto */
503 extern struct ieee80211_key *ieee80211_crypto_encap(ieee80211com_t *, mblk_t *);
504 extern struct ieee80211_key *ieee80211_crypto_decap(ieee80211com_t *, mblk_t *,
505 	int);
506 extern int ieee80211_crypto_newkey(ieee80211com_t *, int, int,
507 	struct ieee80211_key *);
508 extern int ieee80211_crypto_delkey(ieee80211com_t *, struct ieee80211_key *);
509 extern int ieee80211_crypto_setkey(ieee80211com_t *, struct ieee80211_key *,
510 	const uint8_t macaddr[IEEE80211_ADDR_LEN]);
511 
512 /* Helper Functions */
513 int ieee80211_stat(ieee80211com_t *ic, uint_t stat, uint64_t *val);
514 uint32_t ieee80211_chan2ieee(ieee80211com_t *, struct ieee80211_channel *);
515 enum ieee80211_phymode ieee80211_chan2mode(ieee80211com_t *,
516 	struct ieee80211_channel *);
517 uint32_t ieee80211_ieee2mhz(uint32_t, uint32_t);
518 void ieee80211_reset_chan(ieee80211com_t *);
519 void ieee80211_dump_pkt(const uint8_t *, int32_t, int32_t, int32_t);
520 void ieee80211_watchdog(void *);
521 void ieee80211_start_watchdog(ieee80211com_t *, uint32_t);
522 void ieee80211_stop_watchdog(ieee80211com_t *);
523 
524 #ifdef	__cplusplus
525 }
526 #endif
527 
528 #endif	/* _SYS_NET80211_H */
529