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