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